<?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; WordPress</title>
	<atom:link href="http://bavotasan.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://bavotasan.com</link>
	<description>by c.bavota</description>
	<lastBuildDate>Thu, 19 Jan 2012 18:04:52 +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>Increase Max Upload File Size in WordPress</title>
		<link>http://bavotasan.com/2012/increase-max-upload-file-size-in-wordpress/</link>
		<comments>http://bavotasan.com/2012/increase-max-upload-file-size-in-wordpress/#comments</comments>
		<pubDate>Tue, 17 Jan 2012 21:12:51 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[post_max_size]]></category>
		<category><![CDATA[uploader]]></category>
		<category><![CDATA[upload_max_filesize]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3764</guid>
		<description><![CDATA[Sometimes, you need to upload a large file to your site, and the default 8mb limit in WordPress isn&#8217;t enough. I attempted to change my limit directly on my server, then in the .htaccess file and then in wp-config.php but neither change worked for me. Then I came across this little snippet by Word Impressed [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, you need to upload a large file to your site, and the default 8mb limit in WordPress isn&#8217;t enough. I attempted to change my limit directly on my server, then in the .htaccess file and then in wp-config.php but neither change worked for me. Then I came across this little snippet by <a href="http://www.wordimpressed.com/coding/how-to-increase-wordpress-file-upload-size-correctly/">Word Impressed</a> which actually worked and allowed me to increase my max upload file size limit.</p>
<p>All you need to do is create a <code>php.ini</code> file and upload it into your <code>/wp-admin</code> folder. Then add the following:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">memory_limit <span style="color: #339933;">=</span> 32M
upload_max_filesize <span style="color: #339933;">=</span> 32M
post_max_size <span style="color: #339933;">=</span> 32M
file_uploads <span style="color: #339933;">=</span> On</pre></div></td></tr></table></div>

<p>You can change <code>32m</code> to whatever max file size you want.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2012/increase-max-upload-file-size-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Update to Add Logo to Admin Plugin</title>
		<link>http://bavotasan.com/2012/update-to-add-logo-to-admin-plugin/</link>
		<comments>http://bavotasan.com/2012/update-to-add-logo-to-admin-plugin/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 20:40:32 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[add logo to admin]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress plugin]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3780</guid>
		<description><![CDATA[I have had a lot of requests to revisit and update my Add Logo to Admin WordPress plugin so today I sat down and went over the code. There have been quite a few changes in WordPress 3.3 so I had to make things a little different but the plugin is now compatible with the [...]]]></description>
			<content:encoded><![CDATA[<p>I have had a lot of requests to revisit and update my <a href="http://bit.ly/cQ6Pa0">Add Logo to Admin</a> WordPress plugin so today I sat down and went over the code. There have been quite a few changes in WordPress 3.3 so I had to make things a little different but the plugin is now compatible with the latest release of WP.</p>
<p><img src="http://bavotasan.com/wp-content/uploads/2012/01/addlogo_big.jpg" alt="" title="addlogo_big" width="550" height="402" class="aligncenter size-full wp-image-3783" /></p>
<p>If you have any feedback please leave a comment below or open up a discussion in my <a href="http://themes.bavotasan.com/support/">support forum</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2012/update-to-add-logo-to-admin-plugin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Shortcode to Encode Email in WordPress Posts</title>
		<link>http://bavotasan.com/2012/shortcode-to-encode-email-in-wordpress-posts/</link>
		<comments>http://bavotasan.com/2012/shortcode-to-encode-email-in-wordpress-posts/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 22:18:05 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[antispambot]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3762</guid>
		<description><![CDATA[A while back I wrote a short tutorial entitled &#8220;A Clever and Safe Way to Display your Email Address&#8221; which explained how you could use CSS to safely display your email on a web page. That way still works well but if you&#8217;re using WordPress, you can take advantage of a function called antispambot() to [...]]]></description>
			<content:encoded><![CDATA[<p>A while back I wrote a short tutorial entitled <a href="http://bit.ly/cuRBa2">&#8220;A Clever and Safe Way to Display your Email Address&#8221;</a> which explained how you could use CSS to safely display your email on a web page. That way still works well but if you&#8217;re using WordPress, you can take advantage of a function called <code>antispambot()</code> to display emails addresses anywhere on your site. </p>
<p>If you code a page template directly, you can add the function like so:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">antispambot<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;youremail@yoursite.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>I needed a away to take advantage of the <code>antispambot()</code> function within my post and page content, so I decided to create a shortcode that would make it super easy to reuse.</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: #666666; font-style: italic;">// EMAIL ENCODE SHORTCODE</span>
<span style="color: #000000; font-weight: bold;">function</span> email_encode_function<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span>antispambot<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mailto:&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">.</span>antispambot<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'email_encode_function'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Once you add the above code snippet to your theme&#8217;s function.php file you can use the following structure to safely display an email address in your post or page content:</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: #009900;">&#91;</span>email<span style="color: #009900;">&#93;</span>you<span style="color: #339933;">@</span>you<span style="color: #339933;">.</span>com<span style="color: #009900;">&#91;</span><span style="color: #339933;">/</span>email<span style="color: #009900;">&#93;</span></pre></div></td></tr></table></div>

<p>You can read more about <code>antispambot()</code> in the codex: <a href="http://codex.wordpress.org/Function_Reference/antispambot">http://codex.wordpress.org/Function_Reference/antispambot</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2012/shortcode-to-encode-email-in-wordpress-posts/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Log in to WordPress using an Email Address</title>
		<link>http://bavotasan.com/2011/log-in-to-wordpress-using-an-email-address/</link>
		<comments>http://bavotasan.com/2011/log-in-to-wordpress-using-an-email-address/#comments</comments>
		<pubDate>Wed, 28 Dec 2011 16:26:52 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[email address]]></category>
		<category><![CDATA[functions.php]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[username]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3744</guid>
		<description><![CDATA[I needed to figure out how to allow a user to use either their username or email address to log into WordPress. It took a bit of rooting around but the final piece of code ended up being pretty simple. function login_with_email_address&#40;$username&#41; &#123; $user = get_user_by_email&#40;$username&#41;; if&#40;!empty&#40;$user-&#62;user_login&#41;&#41; $username = $user-&#62;user_login; return $username; &#125; add_action&#40;'wp_authenticate','login_with_email_address'&#41;; Place [...]]]></description>
			<content:encoded><![CDATA[<p>I needed to figure out how to allow a user to use either their username or email address to log into WordPress. It took a bit of rooting around but the final piece of code ended up being pretty simple.</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> login_with_email_address<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> get_user_by_email<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_login</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">user_login</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$username</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_authenticate'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'login_with_email_address'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Place that in your <code>functions.php</code> file and you will be able to sign into your WordPress site using an email address or by default, the username.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/log-in-to-wordpress-using-an-email-address/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Holiday Bundle</title>
		<link>http://bavotasan.com/2011/holiday-bundle/</link>
		<comments>http://bavotasan.com/2011/holiday-bundle/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 17:42:51 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[magazine flow]]></category>
		<category><![CDATA[magazine premium]]></category>
		<category><![CDATA[Themes]]></category>
		<category><![CDATA[themes by bavotasan.com]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3748</guid>
		<description><![CDATA[The year is almost over and the holidays are coming closer, so I thought it would be a good time to package together some WordPress themes and offer people a great deal. For the month of December, you can now get Magazine Premium, Magazine Flow and Arturo all for only $99.99. That’s a savings of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://themes.bavotasan.com/wp-content/uploads/2011/12/holidaybundle2.jpg" alt="" class="aligncenter" />The year is almost over and the holidays are coming closer, so I thought it would be a good time to package together some WordPress themes and offer people a great deal. For the month of December, you can now get <a href="http://themes.bavotasan.com/2010/magazine-premium/">Magazine Premium</a>, <a href="http://themes.bavotasan.com/2010/magazine-flow/">Magazine Flow</a> and <a href="http://themes.bavotasan.com/2010/arturo/">Arturo</a> all for only $99.99. That’s a savings of almost $80! All you have to do is click on the link below to take advantage of this amazing deal.</p>
<form id="buynow" action="https://www.paypal.com/cgi-bin/webscr" method="post" name="_xclick">
<input type="hidden" name="cmd" value="_xclick" />
<input type="hidden" name="business" value="c@bavotasan.com" />
<input type="hidden" name="currency_code" value="CAD" />
<input type="hidden" name="item_name" value="Holiday Bundle" />
<input type="hidden" name="item_number" value="wpt-bundle" />
<input type="hidden" name="amount" value="99.99" /></form>
<p><a class="purchase buynow" style="margin: 30px auto;" href="javascript:void(0)">Purchase Now</a></p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/holiday-bundle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Better Voting System for WordPress</title>
		<link>http://bavotasan.com/2011/a-better-voting-system-for-wordpress/</link>
		<comments>http://bavotasan.com/2011/a-better-voting-system-for-wordpress/#comments</comments>
		<pubDate>Mon, 24 Oct 2011 11:14:56 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[voting]]></category>
		<category><![CDATA[voting system]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3718</guid>
		<description><![CDATA[I published a tutorial quite a while back called Simple Voting for WordPress with PHP and jQuery. It was not without its problems, and recently I needed to improve on it for a client, so I thought it would be a good idea to finally release an updated version. The original tutorial relied on an [...]]]></description>
			<content:encoded><![CDATA[<p>I published a tutorial quite a while back called <a href="http://bit.ly/aLhLbd">Simple Voting for WordPress with PHP and jQuery</a>. It was not without its problems, and recently I needed to improve on it for a client, so I thought it would be a good idea to finally release an updated version.</p>
<p>The original tutorial relied on an outside PHP file to process the votes but now I use the built-in Ajax function in WordPress. That way it&#8217;s more secure and efficient. To get everything started, let&#8217;s take a look at the jQuery required:</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: #009966; font-style: italic;">/* &lt;![CDATA[ */</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: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#vote&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">not</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.disabled&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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> el <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> nonce <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input#voting_nonce&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
			action<span style="color: #339933;">:</span> <span style="color: #3366CC;">'add_votes_options'</span><span style="color: #339933;">,</span>
			nonce<span style="color: #339933;">:</span> nonce<span style="color: #339933;">,</span>
			postid<span style="color: #339933;">:</span> <span style="color: #3366CC;">'&lt;?php echo $post-&gt;ID; ?&gt;'</span><span style="color: #339933;">,</span>
			ip<span style="color: #339933;">:</span> <span style="color: #3366CC;">'&lt;?php echo $_SERVER['</span>REMOTE_ADDR<span style="color: #3366CC;">']; ?&gt;'</span>			
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		$.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;?php echo admin_url('</span>admin<span style="color: #339933;">-</span>ajax.<span style="color: #660066;">php</span><span style="color: #3366CC;">'); ?&gt;'</span><span style="color: #339933;">,</span> data<span style="color: #339933;">,</span>
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>response<span style="color: #339933;">!=</span><span style="color: #3366CC;">&quot;-1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				el.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;VOTED&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">unbind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>response<span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;null&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;A vote has already been registered to this IP address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#votecounter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Thanks for your vote.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;There was a problem registering your vote. Please try again later.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</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;">;</span>
<span style="color: #009966; font-style: italic;">/* ]]&gt; */</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>If the vote button is clicked, it will send the Ajax request and process it accordingly, depending on a few things. The only thing missing, is the code to register a cookie once the vote has been calculated so that voters can only vote once. Let&#8217;s include two cookie functions originally created by <a href="http://www.quirksmode.org/js/cookies.html">Peter-Paul Koch</a> and add a block of code to our original script:</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: #009966; font-style: italic;">/* &lt;![CDATA[ */</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;">function</span> setCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #339933;">,</span>value<span style="color: #339933;">,</span>days<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>days<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        <span style="color: #003366; font-weight: bold;">var</span> date <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        date.<span style="color: #660066;">setTime</span><span style="color: #009900;">&#40;</span>date.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>days<span style="color: #339933;">*</span><span style="color: #CC0000;">24</span><span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">*</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        <span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;; expires=&quot;</span><span style="color: #339933;">+</span>date.<span style="color: #660066;">toGMTString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
	    <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #003366; font-weight: bold;">var</span> expires <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span>
	    document.<span style="color: #660066;">cookie</span> <span style="color: #339933;">=</span> <span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">+</span>value<span style="color: #339933;">+</span>expires<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;; path=/&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> getCookie<span style="color: #009900;">&#40;</span><span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #003366; font-weight: bold;">var</span> nameEQ <span style="color: #339933;">=</span> <span style="color: #000066;">name</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;=&quot;</span><span style="color: #339933;">;</span>
	    <span style="color: #003366; font-weight: bold;">var</span> ca <span style="color: #339933;">=</span> document.<span style="color: #660066;">cookie</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">';'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i <span style="color: #339933;">&lt;</span> ca.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        <span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> ca<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	        <span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">charAt</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #3366CC;">' '</span><span style="color: #009900;">&#41;</span> c <span style="color: #339933;">=</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span>c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>nameEQ<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> c.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>nameEQ.<span style="color: #660066;">length</span><span style="color: #339933;">,</span>c.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
	    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#vote&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">not</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.disabled&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</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> el <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		el.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;span id=&quot;loader&quot;&gt;&lt;/span&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> nonce <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input#voting_nonce&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
			action<span style="color: #339933;">:</span> <span style="color: #3366CC;">'add_votes_options'</span><span style="color: #339933;">,</span>
			nonce<span style="color: #339933;">:</span> nonce<span style="color: #339933;">,</span>
			postid<span style="color: #339933;">:</span> <span style="color: #3366CC;">'&lt;?php echo $post-&gt;ID; ?&gt;'</span><span style="color: #339933;">,</span>
			ip<span style="color: #339933;">:</span> <span style="color: #3366CC;">'&lt;?php echo $_SERVER['</span>REMOTE_ADDR<span style="color: #3366CC;">']; ?&gt;'</span>			
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
		$.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;?php echo admin_url('</span>admin<span style="color: #339933;">-</span>ajax.<span style="color: #660066;">php</span><span style="color: #3366CC;">'); ?&gt;'</span><span style="color: #339933;">,</span> data<span style="color: #339933;">,</span>
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>response<span style="color: #339933;">!=</span><span style="color: #3366CC;">&quot;-1&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				el.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;VOTED&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">unbind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>response<span style="color: #339933;">==</span><span style="color: #3366CC;">&quot;null&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;A vote has already been registered to this IP address.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#votecounter&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Thanks for your vote.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #003366; font-weight: bold;">var</span> cookie <span style="color: #339933;">=</span> getCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;better_votes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>cookie<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003366; font-weight: bold;">var</span> newcookie <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&lt;?php echo $post-&gt;ID; ?&gt;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003366; font-weight: bold;">var</span> newcookie <span style="color: #339933;">=</span> cookie <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;,&lt;?php echo $post-&gt;ID; ?&gt;&quot;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				setCookie<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;better_votes&quot;</span><span style="color: #339933;">,</span> newcookie<span style="color: #339933;">,</span> <span style="color: #CC0000;">365</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;There was a problem registering your vote. Please try again later.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</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;">;</span>
<span style="color: #009966; font-style: italic;">/* ]]&gt; */</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></td></tr></table></div>

<p>Now a cookie will be registered once the vote has been tallied. This is all the jQuery we need to make our voting system work. If jQuery is not already loaded in your WordPress theme, you may also need to add this into your header.php file before the <code>wp_head()</code> 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>php wp_enqueue_script<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'jquery'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">?&gt;</span></pre></div></td></tr></table></div>

<p>The following is the PHP code that we need to process the vote on the server side. This will need to be placed in your theme&#8217;s functions.php file. If the file doesn&#8217;t exist, just create it and make sure this code is placed between the PHP tags:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wp_ajax_add_votes_options&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;add_votes_options&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;wp_ajax_nopriv_add_votes_options&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;add_votes_options&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> add_votes_options<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>wp_verify_nonce<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nonce'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'voting_nonce'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$postid</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'postid'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$ip</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ip'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000088;">$voter_ips</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postid</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;voter_ips&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;">$voter_ips</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ip</span><span style="color: #339933;">,</span> <span style="color: #000088;">$voter_ips</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;null&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$voter_ips</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ip</span><span style="color: #339933;">;</span>
		update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postid</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;voter_ips&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$voter_ips</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>	
&nbsp;
	<span style="color: #000088;">$current_votes</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postid</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;votes&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$new_votes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current_votes</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
	update_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$postid</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;votes&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$new_votes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$new_votes</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">1</span> ? <span style="color: #000088;">$new_votes</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; votes&quot;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$new_votes</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; vote&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>The two action calls at the beginning hook into the Ajax function from the jQuery. We need both since one is for logged-in users and the other is for guests. Next we check for the security nonce, and end the process if it is not set correctly. This is a huge improvement over my old code that had absolutely no security whatsoever. If all is good, we start processing the vote by checking if the voters IP address has already been registered. If so, the process stops and returns a &#8220;null&#8221; value. Otherwise we registered the vote and IP address and echo out the total votes.</p>
<p>If you take a look at the jQuery above, you can see how the different responses will be processed. A &#8220;null&#8221; response will alert the voter that their IP address has already been registered so their new vote will not count. A response of &#8220;-1&#8243; means something went wrong and we alert the voter. If everything goes well, the vote is registered, the voter is thanked and the total number of votes increases on the page.</p>
<p>There you have all the jQuery and PHP required to get it working on the backend, but you still need some PHP/HTML in order for things to work on the front end.</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: #666666; font-style: italic;">// This will display &quot;0 votes&quot; and increase as votes are added</span>
<span style="color: #000088;">$votes</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;votes&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$votes</span> <span style="color: #339933;">=</span> <span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$votes</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$votes</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$votes</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$plural</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span> <span style="color: #000088;">$plural</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;s&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;div id=&quot;votecounter&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$votes</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' vote'</span><span style="color: #339933;">.</span><span style="color: #000088;">$plural</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/div&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// This will display the vote button and disable it if a cookie has already</span>
<span style="color: #666666; font-style: italic;">// been set. We also add the security nonce here. </span>
<span style="color: #000088;">$hasvoted</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_COOKIE</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'better_votes'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$hasvoted</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hasvoted</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$hasvoted</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$vtext</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;VOTED&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">' class=&quot;disabled&quot;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$vtext</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;VOTE&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;a href=&quot;javascript:void(0)&quot; id=&quot;vote&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$class</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$vtext</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;
<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: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_nonce_field'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> wp_nonce_field<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'voting_nonce'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'voting_nonce'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>So there you have it, a more efficient voting system for WordPress that is secure and will hopefully double guard you against fraudulent voting. You can see this working live on the new <a href="http://2011.bloodshotscanada.com">Bloodshots</a> website. It will only be active between Oct 24th and Oct 28th while people can vote for the films.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/a-better-voting-system-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>An Even Better Author List in WordPress</title>
		<link>http://bavotasan.com/2011/an-even-better-author-list-in-wordpress/</link>
		<comments>http://bavotasan.com/2011/an-even-better-author-list-in-wordpress/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 17:11:32 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Authors]]></category>
		<category><![CDATA[contributors]]></category>
		<category><![CDATA[get_users()]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3665</guid>
		<description><![CDATA[I already wrote about this a while back in &#8220;How to Display an Author List with Avatars in WordPress&#8221; but I recently realized that it needed updating. There&#8217;s a better way of collecting and displaying all the information and you can also add a few variables to give you more control over the output. Let&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bavotasan.com/wp-content/uploads/2011/09/author_big.jpg" alt="" title="author_big" width="550" height="200" class="aligncenter size-full wp-image-3682" />I already wrote about this a while back in <a href="http://bavotasan.com/2009/how-to-display-an-author-list-with-avatars-in-wordpress/">&#8220;How to Display an Author List with Avatars in WordPress&#8221;</a> but I recently realized that it needed updating. There&#8217;s a better way of collecting and displaying all the information and you can also add a few variables to give you more control over the output.</p>
<p>Let&#8217;s start off with creating our variables:</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: #000088;">$display_admins</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$order_by</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'display_name'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'nicename', 'email', 'url', 'registered', 'display_name', or 'post_count'</span>
<span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'subscriber', 'contributor', 'editor', 'author' - leave blank for 'all'</span>
<span style="color: #000088;">$avatar_size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$hide_empty</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// hides authors with zero posts</span></pre></div></td></tr></table></div>

<p>Next we can add the code to gather our contributors:</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: #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;">$display_admins</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'orderby='</span><span style="color: #339933;">.</span><span style="color: #000088;">$order_by</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;role='</span><span style="color: #339933;">.</span><span style="color: #000088;">$role</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$admins</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'role=administrator'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$admins</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$ad</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$exclude</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ad</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exclude</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exclude='</span><span style="color: #339933;">.</span><span style="color: #000088;">$exclude</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;orderby='</span><span style="color: #339933;">.</span><span style="color: #000088;">$order_by</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;role='</span><span style="color: #339933;">.</span><span style="color: #000088;">$role</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$authors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$blogusers</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$bloguser</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bloguser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;">$hide_empty</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$numposts</span> <span style="color: #339933;">=</span> count_user_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numposts</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$authors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>Now that we have all the information we need, let&#8217;s display it:</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: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul class=&quot;contributors&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$authors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$display_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'display_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$avatar</span> <span style="color: #339933;">=</span> get_avatar<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$avatar_size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$author_profile_url</span> <span style="color: #339933;">=</span> get_author_posts_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$author_profile_url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$avatar</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$author_profile_url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot; class=&quot;contributor-link&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$display_name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>If we put all the code together we get the following:</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: #000088;">$display_admins</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$order_by</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'display_name'</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'nicename', 'email', 'url', 'registered', 'display_name', or 'post_count'</span>
<span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 'subscriber', 'contributor', 'editor', 'author' - leave blank for 'all'</span>
<span style="color: #000088;">$avatar_size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">32</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$hide_empty</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// hides authors with zero posts</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;">$display_admins</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'orderby='</span><span style="color: #339933;">.</span><span style="color: #000088;">$order_by</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;role='</span><span style="color: #339933;">.</span><span style="color: #000088;">$role</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$admins</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'role=administrator'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$admins</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$ad</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$exclude</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ad</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span> <span style="color: #000088;">$exclude</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$blogusers</span> <span style="color: #339933;">=</span> get_users<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'exclude='</span><span style="color: #339933;">.</span><span style="color: #000088;">$exclude</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;orderby='</span><span style="color: #339933;">.</span><span style="color: #000088;">$order_by</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;role='</span><span style="color: #339933;">.</span><span style="color: #000088;">$role</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000088;">$authors</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$blogusers</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$bloguser</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> get_userdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$bloguser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;">$hide_empty</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$numposts</span> <span style="color: #339933;">=</span> count_user_posts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$numposts</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000088;">$authors</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul class=&quot;contributors&quot;&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$authors</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$display_name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'display_name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$avatar</span> <span style="color: #339933;">=</span> get_avatar<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$avatar_size</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$author_profile_url</span> <span style="color: #339933;">=</span> get_author_posts_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$author</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$author_profile_url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$avatar</span> <span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;a href=&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$author_profile_url</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&quot; class=&quot;contributor-link&quot;&gt;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$display_name</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></td></tr></table></div>

<p>All it needs is a little CSS to style it:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.contributors</span> <span style="color: #6666ff;">.avatar</span> <span style="color: #00AA00;">&#123;</span>	
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">clear</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">both</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#ccc</span><span style="color: #00AA00;">;</span>
	border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	-moz-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	-webkit-border-radius<span style="color: #00AA00;">:</span> <span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
	box-sizing<span style="color: #00AA00;">:</span> content-box<span style="color: #00AA00;">;</span> 
	-moz-box-sizing<span style="color: #00AA00;">:</span> content-box<span style="color: #00AA00;">;</span> 
	-webkit-box-sizing<span style="color: #00AA00;">:</span> content-box<span style="color: #00AA00;">;</span> 
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.contributors</span> <span style="color: #6666ff;">.avatar</span><span style="color: #3333ff;">:hover  </span><span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">border-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999</span><span style="color: #00AA00;">;</span>
		<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.contributors</span> <span style="color: #6666ff;">.contributor-link</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #933;">10px</span> <span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p>You can play around with the CSS to get it looking the way you want and with the variables in place, you can control exactly what type of author list will be displayed.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/an-even-better-author-list-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Create a Black &amp; White Thumbnail in WordPress</title>
		<link>http://bavotasan.com/2011/create-black-white-thumbnail-wordpress/</link>
		<comments>http://bavotasan.com/2011/create-black-white-thumbnail-wordpress/#comments</comments>
		<pubDate>Tue, 13 Sep 2011 18:37:52 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[black and white]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[thumbnails]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3641</guid>
		<description><![CDATA[A while back I worked on a site that required a hover effect where a black and white image faded into a color image. I wrote a tutorial called Creating a Mouseover Fade Effect with jQuery on the jQuery technique I used for the hover. That effect no longer requires jQuery since we can now [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://bavotasan.com/wp-content/uploads/2011/09/colorballs_big.jpg" alt="" title="colorballs_big" width="550" height="200" class="aligncenter size-full wp-image-3649" />A while back I worked on a site that required a hover effect where a black and white image faded into a color image. I wrote a tutorial called <a href="http://bavotasan.com/2009/creating-a-jquery-mouseover-fade-effect/" title="Creating a Mouseover Fade Effect with jQuery">Creating a Mouseover Fade Effect with jQuery</a> on the jQuery technique I used for the hover. That effect no longer requires jQuery since we can now use CSS3 transitions (see <a href="http://bavotasan.com/2011/a-simple-fade-with-css3/" title="A Simple Fade with CSS3">A Simple Fade with CSS3</a>) but the real issue was with having to upload two separate images to get the effect to work, which required an image editing software like Photoshop. Thankfully, <a href="http://ottopress.com/2011/customizing-wordpress-images/">Otto</a> just wrote a great article on a way that you can use some built in WordPress functions and a little PHP to automatically create a black and white thumbnail when you upload an image. </p>
<p>First we need to create a new thumbnail using <code>add_image_size()</code>. We&#8217;ll use the same thumbnail settings from the WordPress Media page in the wp-admin. Add this to your functions.php file within the PHP tags:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'after_setup_theme'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'bw_images_size'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> bw_images_size<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$crop</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnail_crop'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span> ? <span style="color: #009900; font-weight: bold;">true</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	add_image_size<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnail-bw'</span><span style="color: #339933;">,</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnail_size_w'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnail_size_h'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$crop</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>With that in place, we can now add the following function which will automatically create a black and white thumbnail:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_generate_attachment_metadata'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'bw_images_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">function</span> bw_images_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$meta</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> wp_upload_dir<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> trailingslashit<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'path'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #000088;">$meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sizes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail-bw'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$orig_w</span><span style="color: #339933;">,</span> <span style="color: #000088;">$orig_h</span><span style="color: #339933;">,</span> <span style="color: #000088;">$orig_type</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">getimagesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> wp_load_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">imagefilter</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> IMG_FILTER_GRAYSCALE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);</span>
	<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$orig_type</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">case</span> IMAGETYPE_GIF<span style="color: #339933;">:</span>
			<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.gif&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;-bw.gif&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">imagegif</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> IMAGETYPE_PNG<span style="color: #339933;">:</span>
			<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.png&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;-bw.png&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">imagepng</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">case</span> IMAGETYPE_JPEG<span style="color: #339933;">:</span>
			<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;-bw.jpg&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #990000;">imagejpeg</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$meta</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>Whenever you upload an image, this function will create a new black and white thumbnail automatically. I also added a Gaussian Blur but commented it out. Remove those two slashes &#8220;//&#8221; to add a Gaussian Blur to your new black and white thumbnail. See other <a href="http://php.net/manual/en/function.imagefilter.php">available filters</a>.</p>
<p>Once you&#8217;ve added the above code, you can use <code>get_post_thumbnail()</code> within your WordPress loop to display the two images for the effect:</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: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'has_post_thumbnail'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> has_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span>get_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; class=&quot;fade-image&quot;&gt;'</span><span style="color: #339933;">;</span>
	the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnail-bw'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'fade-image-a'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	the_post_thumbnail<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'thumbnail'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'class'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'fade-image-b'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></td></tr></table></div>

<p>This displays both images and surrounds them by an anchor tag. All we need is a little CSS3 to get our fade working:</p>

<div class="wp_syntax"><table border='0' cellpadding='0' cellspacing='0'><tr><td><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.fade-image</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">150px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	.fade-image-a<span style="color: #00AA00;">,</span>
	<span style="color: #6666ff;">.fade-image</span> b <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
		<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #6666ff;">.fade-image-a</span> <span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">z-index</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">5</span><span style="color: #00AA00;">;</span>
		opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
		transition<span style="color: #00AA00;">:</span> opacity .25s ease-in-out<span style="color: #00AA00;">;</span>
		-moz-transition<span style="color: #00AA00;">:</span> opacity .25s ease-in-out<span style="color: #00AA00;">;</span>
		-webkit-transition<span style="color: #00AA00;">:</span> opacity .25s ease-in-out<span style="color: #00AA00;">;</span>
   		<span style="color: #00AA00;">&#125;</span>	
&nbsp;
		<span style="color: #6666ff;">.fade-image-a</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
			opacity<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
			<span style="color: #00AA00;">&#125;</span></pre></div></td></tr></table></div>

<p><a href="javascript:void(0)" class="fade-image"><img src="http://bavotasan.com/wp-content/uploads/2011/09/colorballs-bw.jpg" class="fade-image-a" alt="" /><img src="http://bavotasan.com/wp-content/uploads/2011/09/colorballs.jpg" class="fade-image-b" alt="" /></a></p>
<p>The fade will only work in browsers that support CSS3 transitions but everything else should work on any server that supports the latest release of WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/create-black-white-thumbnail-wordpress/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>Add a Post&#8217;s Category Name to Body Class in WordPress</title>
		<link>http://bavotasan.com/2011/add-a-posts-category-name-to-body-class-in-wordpress/</link>
		<comments>http://bavotasan.com/2011/add-a-posts-category-name-to-body-class-in-wordpress/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 15:44:49 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[body class]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[functions.php]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3605</guid>
		<description><![CDATA[I was working with Digibomb on presswork.me and we needed to add the current post&#8217;s category name to the body class in order to style the page differently from the others. All it took was a few lines of code added to the functions.php file: function add_category_name&#40;$classes = ''&#41; &#123; if&#40;is_single&#40;&#41;&#41; &#123; $category = get_the_category&#40;&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>I was working with <a href="http://dropthedigibomb.com/">Digibomb</a> on <a href="http://presswork.me">presswork.me</a> and we needed to add the current post&#8217;s category name to the body class in order to style the page differently from the others.</p>
<p>All it took was a few lines of code added to the <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> add_category_name<span style="color: #009900;">&#40;</span><span style="color: #000088;">$classes</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$category</span> <span style="color: #339933;">=</span> get_the_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000088;">$classes</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'category-'</span><span style="color: #339933;">.</span><span style="color: #000088;">$category</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">slug</span><span style="color: #339933;">;</span> 
   <span style="color: #009900;">&#125;</span>
   <span style="color: #b1b100;">return</span> <span style="color: #000088;">$classes</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'body_class'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'add_category_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>With that in place, you should now see a new class at the end of your body tag when you are on a single post or single page.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/add-a-posts-category-name-to-body-class-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Shortcode for HTML5 Video Tag in WordPress</title>
		<link>http://bavotasan.com/2011/shortcode-for-html5-video-tag-in-wordpress/</link>
		<comments>http://bavotasan.com/2011/shortcode-for-html5-video-tag-in-wordpress/#comments</comments>
		<pubDate>Sun, 31 Jul 2011 13:43:58 +0000</pubDate>
		<dc:creator>c.bavota</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5 video]]></category>
		<category><![CDATA[mp4]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bavotasan.com/?p=3577</guid>
		<description><![CDATA[HTML5 has made it a lot easier to include certain elements. Especially videos, since you no longer have to embed them with all those parameters. Here&#8217;s a short code snippet that will add an HTML5 video shortcode to WordPress. Just include this code in your functions.php file and you are ready to go: function html5_video&#40;$atts, [...]]]></description>
			<content:encoded><![CDATA[<p>HTML5 has made it a lot easier to include certain elements. Especially videos, since you no longer have to embed them with all those parameters. Here&#8217;s a short code snippet that will add an HTML5 video shortcode to WordPress. Just include this code in your functions.php file and you are ready to go:</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> html5_video<span style="color: #009900;">&#40;</span><span style="color: #000088;">$atts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$content</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span>shortcode_atts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
		<span style="color: #0000ff;">&quot;src&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;width&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span>
		<span style="color: #0000ff;">&quot;height&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$atts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;video src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$src</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; width=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$width</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; height=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$height</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; controls autobuffer&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
add_shortcode<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'video5'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'html5_video'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></td></tr></table></div>

<p>Now you can use the following shortcode in your post:</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: #009900;">&#91;</span>video5 src<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;http://your-site/videos/your-video.mp4&quot;</span> width<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;720&quot;</span> height<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;480&quot;</span><span style="color: #009900;">&#93;</span></pre></div></td></tr></table></div>

<p>You can read more on which browsers support which formats at <a href="http://en.wikipedia.org/wiki/HTML5_video">http://en.wikipedia.org/wiki/HTML5_video</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bavotasan.com/2011/shortcode-for-html5-video-tag-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 3.218 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-04 16:13:50 -->

