<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bavotasan.com &#187; head</title>
	<atom:link href="http://bavotasan.com/tag/head/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Tue, 07 Feb 2012 15:42:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Use jQuery to Replace a Word with a Link</title>
		<link>http://bavotasan.com/2010/jquery-replace-word-with-link/</link>
		<comments>http://bavotasan.com/2010/jquery-replace-word-with-link/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 20:54:46 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[body]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[site]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[var]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[Word]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=2615</guid>
		<description><![CDATA[If you use a word multiple times on your site and you don&#8217;t feel like going through all your posts to replace every instance of it, you can use jQuery to search your page and do the replacing for you. I wanted to replace a word throughout an entire site with a link and all [...]]]></description>
			<content:encoded><![CDATA[<p>If you use a word multiple times on your site and you don&#8217;t feel like going through all your posts to replace every instance of it, you can use jQuery to search your page and do the replacing for you. I wanted to replace a word throughout an entire site with a link and all it took was a small piece of code. </p>
<p>If you don&#8217;t already have jQuery loaded into your page, include this before your closing <code>&lt;head&gt;</code>.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">'text/javascript'</span> src<span style="color: #339933;">=</span><span style="color: #3366CC;">'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js'</span><span style="color: #339933;">&gt;&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>That will load up jQuery from Google.</p>
<p>Now you just need to include this in your site&#8217;s footer, before the closing <code>&lt;body&gt;</code>. (Why in the footer? Because including your JavaScript after all of your code is the efficient way to do it.)</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> thePage <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;body&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  thePage.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>thePage.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/jQuery/ig</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'&lt;a href=&quot;http://jquery.com&quot;&gt;jQuery&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>jQuery<span style="color: #009900;">&#41;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>Since jQuery doesn&#8217;t have a core function for replacing text, we will use the JavaScript <code><a href="http://www.w3schools.com/jsref/jsref_replace.asp">replace()</a></code> function. The <code>i</code> after the slash makes the search and replace case-insensitive, and the <code>g</code> makes it global. </p>
<p>I have the script working on this page to replace every instance of the word jQuery with a link to the jQuery Web site.</p>
<p><script type="text/javascript">
(function($) {
  $(".posttop p").each(function() {
    $(this).html($(this).html().replace(/jQuery/ig, '<a href="http://jquery.com">jQuery</a>')); 
  });
})(jQuery)
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/jquery-replace-word-with-link/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Force WordPress to use the Latest Version of jQuery</title>
		<link>http://bavotasan.com/2010/force-wordpress-use-latest-version-jquery/</link>
		<comments>http://bavotasan.com/2010/force-wordpress-use-latest-version-jquery/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 15:20:43 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[action]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[animation]]></category>
		<category><![CDATA[Change]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[New Features]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[piece]]></category>
		<category><![CDATA[Place]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[version]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=1875</guid>
		<description><![CDATA[If you&#8217;re using WordPress 2.9.x, then the latest version of jQuery included is 1.3.2. What if you want to take advantage of new features in version 1.4, like delaying an animation queue or binding multiple event handlers? You can easily add a link in your header to the latest version, but that might end up [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re using WordPress 2.9.x, then the latest version of <a href="http://jquery.com/">jQuery</a> included is 1.3.2. What if you want to take advantage of new features in version 1.4, like delaying an animation queue or binding multiple event handlers? You can easily add a link in your header to the latest version, but that might end up conflicting with some plugins or themes.<br />
<span id="more-1875"></span><br />
The best approach would be to use the following piece of code to let WordPress know that you want to load the current version instead.</p>
<p>Place this into your theme&#8217;s <code>functions.php</code> file:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> current_jquery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$version</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wp_scripts</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">version_compare</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$version</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wp_scripts</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">registered</span><span style="color: #009900;">&#91;</span>jquery<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">ver</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>is_admin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                wp_deregister_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
                wp_register_script<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'jquery'</span><span style="color: #339933;">,</span>
                        <span style="color: #0000ff;">'http://ajax.googleapis.com/ajax/libs/jquery/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$version</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/jquery.min.js'</span><span style="color: #339933;">,</span>
                        <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #000088;">$version</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_action<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'wp_head'</span><span style="color: #339933;">,</span> current_jquery<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'1.4.2'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// change number to latest version</span></pre></div></td></tr></table></div>

<p>If jQuery is updated, all you have to do is change the version number when calling the function.</p>
<p><strong>Reference</strong>: <a href="http://binarybonsai.com/2010/02/14/how-to-load-the-latest-jquery-in-wordpress/">Binary Bonsai</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2010/force-wordpress-use-latest-version-jquery/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Processing Multiple Forms on One Page with PHP</title>
		<link>http://bavotasan.com/2009/processing-multiple-forms-on-one-page-with-php/</link>
		<comments>http://bavotasan.com/2009/processing-multiple-forms-on-one-page-with-php/#comments</comments>
		<pubDate>Tue, 05 May 2009 02:58:42 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Array]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[Function]]></category>
		<category><![CDATA[head]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[Lt]]></category>
		<category><![CDATA[name]]></category>
		<category><![CDATA[page]]></category>
		<category><![CDATA[Php File]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[something]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[trick]]></category>
		<category><![CDATA[way]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=567</guid>
		<description><![CDATA[I know that the way most people treat multiple forms on one page is to have each form post to another PHP file where the form is validated, its information is entered into a database or an email is sent off. So you usually have something like this: &#60;form name=&#34;contactform&#34; method=&#34;post&#34; action=&#34;sendmail.php&#34;&#62; blah blah blah [...]]]></description>
			<content:encoded><![CDATA[<p>I know that the way most people treat multiple forms on one page is to have each form post to another PHP file where the form is validated, its information is entered into a database or an email is sent off. So you usually have something like this:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>form name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contactform&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span> action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;sendmail.php&quot;</span><span style="color: #339933;">&gt;</span>
blah blah blah
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>form name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;mailinglist&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span> action<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;join.php&quot;</span><span style="color: #339933;">&gt;</span>
blah blah blah
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>That  work great, but why would you create all those extra files when you can just have the form post to the same file and create multiple functions to process your multiple forms.<br />
<span id="more-567"></span><br />
The solution is very simple and super efficient. </p>
<p>First, lets create some forms.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>form name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;mailinglist&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;mailing-submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Join Our Mailing List&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;</span>form name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contactus&quot;</span> method<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;post&quot;</span><span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;email&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;text&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;subjet&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;</span>textarea name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;message&quot;</span><span style="color: #339933;">&gt;&lt;/</span>textarea<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>input type<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;submit&quot;</span> name<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;contact-submit&quot;</span> value<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Send Email&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>form<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>Now lets put some PHP code before the <code>&lt;head&gt;</code> tag to have different processes for each form.</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mailing-submit'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;">//do something here;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'contact-submit'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #666666; font-style: italic;">//do something here;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>Now all you need to do is create your processes within those two &#8220;if&#8221; statements and each form will be dealt with accordingly when it it filled and submitted.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2009/processing-multiple-forms-on-one-page-with-php/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
	</channel>
</rss>

