<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>WordPress Hardcore</title>
	
	<link>http://www.wphardcore.com</link>
	<description>Advanced WordPress Development</description>
	<lastBuildDate>Fri, 09 Apr 2010 18:46:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/wphardcore" /><feedburner:info uri="wphardcore" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>wphardcore</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/wphardcore" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare href="http://www.plusmo.com/add?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://plusmo.com/res/graphics/fbplusmo.gif">Subscribe with Plusmo</feedburner:feedFlare><feedburner:feedFlare href="http://www.thefreedictionary.com/_/hp/AddRSS.aspx?http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://img.tfd.com/hp/addToTheFreeDictionary.gif">Subscribe with The Free Dictionary</feedburner:feedFlare><feedburner:feedFlare href="http://www.bitty.com/manual/?contenttype=rssfeed&amp;contentvalue=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://www.bitty.com/img/bittychicklet_91x17.gif">Subscribe with Bitty Browser</feedburner:feedFlare><feedburner:feedFlare href="http://www.live.com/?add=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><feedburner:feedFlare href="http://mix.excite.eu/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://image.excite.co.uk/mix/addtomix.gif">Subscribe with Excite MIX</feedburner:feedFlare><feedburner:feedFlare href="http://www.webwag.com/wwgthis.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://www.webwag.com/images/wwgthis.gif">Subscribe with Webwag</feedburner:feedFlare><feedburner:feedFlare href="http://www.podcastready.com/oneclick_bookmark.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://www.podcastready.com/images/podcastready_button.gif">Subscribe with Podcast Ready</feedburner:feedFlare><feedburner:feedFlare href="http://www.wikio.com/subscribe?url=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://www.wikio.com/shared/img/add2wikio.gif">Subscribe with Wikio</feedburner:feedFlare><feedburner:feedFlare href="http://www.dailyrotation.com/index.php?feed=http%3A%2F%2Ffeeds.feedburner.com%2Fwphardcore" src="http://www.dailyrotation.com/rss-dr2.gif">Subscribe with Daily Rotation</feedburner:feedFlare><feedburner:browserFriendly>WordPress Hardcore has just been launched! More contents will come, but in the mean time, subscribe! Thanks.</feedburner:browserFriendly><item>
		<title>Follow Friday: Ben Gillbanks</title>
		<link>http://feedproxy.google.com/~r/wphardcore/~3/RcA6JwlMIBc/</link>
		<comments>http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 18:42:55 +0000</pubDate>
		<dc:creator>Gary Cao</dc:creator>
				<category><![CDATA[Follow Friday]]></category>

		<guid isPermaLink="false">http://www.wphardcore.com/?p=143</guid>
		<description><![CDATA[It's so hard to find good advanced WordPress materials nowadays. However, there are still authors and sites that continually publish solid quality articles on WordPress development. As a result, Follow Friday is a new category on WordPress Hardcore where I will share with you one WordPress site or author that you should follow on Twitter or subscribe to RSS. This week's author is Ben Gillbanks from <a href="http://binarymoon.co.uk">Binary Moon</a>.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wphardcore.com%2F2010%2Ffollow-friday-ben-gillbanks%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wphardcore.com%2F2010%2Ffollow-friday-ben-gillbanks%2F&amp;source=wphardcore&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>It&#8217;s so hard to find good advanced WordPress materials nowadays. However, there are still authors and sites that continually publish solid quality articles on WordPress development. As a result, Follow Friday is a new category on WordPress Hardcore where I will share with you one WordPress site or author that you should follow on Twitter or subscribe to RSS. This week&#8217;s author is Ben Gillbanks from <a href="http://binarymoon.co.uk">Binary Moon</a>.</p>
<p>Ben Gillbanks is a WordPress ninja who&#8217;s behind <a href="http://prothemedesign.com">Pro Theme Design</a> and <a href="http://wpvote.com">WPVote</a>. He&#8217;s also the developer in charge of TimThumb, which is one of the most popular thumbnail generator script for WordPress themes. His blog &#8211; <a href="http://binarymoon.co.uk">Binary Moon</a> &#8211; which usually was dominated by movie reviews, recently is stocked with lots of hardcore WordPress tutorials and tricks of the trade along with great advices for WordPress developers. <a href="http://twitter.com/binarymoon">Follow him on Twitter</a> and <a href="http://www.binarymoon.co.uk/feed/">Subscribe to his updates via RSS</a> if you haven&#8217;t done so already (which I doubt). Below is 5 of his articles that I hand picked for you to bookmark, seriously quality stuff:</p>
<h2><a href="http://www.binarymoon.co.uk/2010/03/yahoo-weather-api/">Using the Yahoo Weather API (in your WordPress themes)</a></h2>
<p>While you won&#8217;t be using this trick a lot, it still serves as an excellent example on how to use WordPress Http class to work with external API. You can extend this example to interact with other web services, like <a href="http://www.binarymoon.co.uk/2010/03/wordpress-http-read-content-from-other-websites/">fetching recent tweets from twitter</a> or loading a text file from a remote server.</p>
<h2><a href="http://www.binarymoon.co.uk/2010/03/5-wordpress-queryposts-tips/">10 WordPress query_posts tips you probably don’t know</a></h2>
<p>Some of these tricks I don&#8217;t know myself. Reading WordPress&#8217; official documentation on <a href="http://codex.wordpress.org/Template_Tags/query_posts"><code>query_posts()</code></a> is a must, but this article serves as an excellent supplement. I like how concise yet easy to understand his code examples are. By the way, If you&#8217;re turned on by really really hardcore stuff, play around with <a href="http://codex.wordpress.org/Function_Reference/WP_Query">WP_Query object</a> and filter hook <code>parse_query</code>.</p>
<h2><a href="http://www.binarymoon.co.uk/2010/02/creating-wordpress-permalink-structure-custom-content/">Creating Your Own WordPress Permalink Structure For Custom Content</a></h2>
<p>Like I said, stuff involving WP_Query and <code>parse_query</code> is pretty hardcore. I wanted to write something about this, but found out Ben covered it nicely with his article. My approach might be a little bit different, but you should really read Ben&#8217;s way, you&#8217;ll know how <a href="http://wpvote.com/">WPVote</a> works behind the scene.</p>
<h2><a href="http://www.binarymoon.co.uk/2010/04/wordpress-caching-part-1-basics/">WordPress Caching, Part 1: The Basics</a></h2>
<p>This article is basically an introduction to a series of articles about Caching and WordPress. Judging on the premise, I believe this will be a very informative and useful series. If I were you, I&#8217;d <a href="http://www.binarymoon.co.uk/feed/">subscribe to his RSS</a> in a blink to make sure I won&#8217;t miss anything in the future.</p>
<h2><a href="http://www.binarymoon.co.uk/2010/01/building-wpvote-part-7/">Building WPVote Part 7: Almost Done</a></h2>
<p>As you all probably know, <a href="http://wpvote.com">WPVote</a> was launched recently and I believe it&#8217;s a huge success. Ben even documented each step of his project in a series of 7 blog posts, and I found some of these articles really gave me good ideas about how to plan, design and implement a WordPress project from start to finish. </p>
<p>Enjoy your Friday!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-bg-">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Follow+Friday%3A+Ben+Gillbanks&amp;link=http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/&amp;notes=It%27s%20so%20hard%20to%20find%20good%20advanced%20WordPress%20materials%20nowadays.%20However%2C%20there%20are%20still%20authors%20and%20sites%20that%20continually%20publish%20solid%20quality%20articles%20on%20WordPress%20development.%20As%20a%20result%2C%20Follow%20Friday%20is%20a%20new%20category%20on%20WordPress%20Hardcore%20where%20I%20will%20share%20with%20you%20one%20WordPress%20site%20or%20author%20that%20you%20should%20follow%20on%20Twitter%20or%20subscribe%20to%20RSS.%20This%20week%27s%20author%20is%20Ben%20Gillbanks%20from%20Binary%20Moon.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designbump">
			<a href="http://www.shareaholic.com/api/share/?title=Follow+Friday%3A+Ben+Gillbanks&amp;link=http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/&amp;notes=It%27s%20so%20hard%20to%20find%20good%20advanced%20WordPress%20materials%20nowadays.%20However%2C%20there%20are%20still%20authors%20and%20sites%20that%20continually%20publish%20solid%20quality%20articles%20on%20WordPress%20development.%20As%20a%20result%2C%20Follow%20Friday%20is%20a%20new%20category%20on%20WordPress%20Hardcore%20where%20I%20will%20share%20with%20you%20one%20WordPress%20site%20or%20author%20that%20you%20should%20follow%20on%20Twitter%20or%20subscribe%20to%20RSS.%20This%20week%27s%20author%20is%20Ben%20Gillbanks%20from%20Binary%20Moon.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=282&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Bump this on DesignBump">Bump this on DesignBump</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.shareaholic.com/api/share/?title=Follow+Friday%3A+Ben+Gillbanks&amp;link=http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/&amp;notes=It%27s%20so%20hard%20to%20find%20good%20advanced%20WordPress%20materials%20nowadays.%20However%2C%20there%20are%20still%20authors%20and%20sites%20that%20continually%20publish%20solid%20quality%20articles%20on%20WordPress%20development.%20As%20a%20result%2C%20Follow%20Friday%20is%20a%20new%20category%20on%20WordPress%20Hardcore%20where%20I%20will%20share%20with%20you%20one%20WordPress%20site%20or%20author%20that%20you%20should%20follow%20on%20Twitter%20or%20subscribe%20to%20RSS.%20This%20week%27s%20author%20is%20Ben%20Gillbanks%20from%20Binary%20Moon.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=106&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.shareaholic.com/api/share/?title=Follow+Friday%3A+Ben+Gillbanks&amp;link=http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/&amp;notes=It%27s%20so%20hard%20to%20find%20good%20advanced%20WordPress%20materials%20nowadays.%20However%2C%20there%20are%20still%20authors%20and%20sites%20that%20continually%20publish%20solid%20quality%20articles%20on%20WordPress%20development.%20As%20a%20result%2C%20Follow%20Friday%20is%20a%20new%20category%20on%20WordPress%20Hardcore%20where%20I%20will%20share%20with%20you%20one%20WordPress%20site%20or%20author%20that%20you%20should%20follow%20on%20Twitter%20or%20subscribe%20to%20RSS.%20This%20week%27s%20author%20is%20Ben%20Gillbanks%20from%20Binary%20Moon.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=102&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Follow+Friday%3A+Ben+Gillbanks&amp;link=http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/&amp;notes=It%27s%20so%20hard%20to%20find%20good%20advanced%20WordPress%20materials%20nowadays.%20However%2C%20there%20are%20still%20authors%20and%20sites%20that%20continually%20publish%20solid%20quality%20articles%20on%20WordPress%20development.%20As%20a%20result%2C%20Follow%20Friday%20is%20a%20new%20category%20on%20WordPress%20Hardcore%20where%20I%20will%20share%20with%20you%20one%20WordPress%20site%20or%20author%20that%20you%20should%20follow%20on%20Twitter%20or%20subscribe%20to%20RSS.%20This%20week%27s%20author%20is%20Ben%20Gillbanks%20from%20Binary%20Moon.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.shareaholic.com/api/share/?title=Follow+Friday%3A+Ben+Gillbanks&amp;link=http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/&amp;notes=It%27s%20so%20hard%20to%20find%20good%20advanced%20WordPress%20materials%20nowadays.%20However%2C%20there%20are%20still%20authors%20and%20sites%20that%20continually%20publish%20solid%20quality%20articles%20on%20WordPress%20development.%20As%20a%20result%2C%20Follow%20Friday%20is%20a%20new%20category%20on%20WordPress%20Hardcore%20where%20I%20will%20share%20with%20you%20one%20WordPress%20site%20or%20author%20that%20you%20should%20follow%20on%20Twitter%20or%20subscribe%20to%20RSS.%20This%20week%27s%20author%20is%20Ben%20Gillbanks%20from%20Binary%20Moon.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=74&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Follow+Friday%3A+Ben+Gillbanks&amp;link=http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/&amp;notes=It%27s%20so%20hard%20to%20find%20good%20advanced%20WordPress%20materials%20nowadays.%20However%2C%20there%20are%20still%20authors%20and%20sites%20that%20continually%20publish%20solid%20quality%20articles%20on%20WordPress%20development.%20As%20a%20result%2C%20Follow%20Friday%20is%20a%20new%20category%20on%20WordPress%20Hardcore%20where%20I%20will%20share%20with%20you%20one%20WordPress%20site%20or%20author%20that%20you%20should%20follow%20on%20Twitter%20or%20subscribe%20to%20RSS.%20This%20week%27s%20author%20is%20Ben%20Gillbanks%20from%20Binary%20Moon.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-scriptstyle">
			<a href="http://www.shareaholic.com/api/share/?title=Follow+Friday%3A+Ben+Gillbanks&amp;link=http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/&amp;notes=It%27s%20so%20hard%20to%20find%20good%20advanced%20WordPress%20materials%20nowadays.%20However%2C%20there%20are%20still%20authors%20and%20sites%20that%20continually%20publish%20solid%20quality%20articles%20on%20WordPress%20development.%20As%20a%20result%2C%20Follow%20Friday%20is%20a%20new%20category%20on%20WordPress%20Hardcore%20where%20I%20will%20share%20with%20you%20one%20WordPress%20site%20or%20author%20that%20you%20should%20follow%20on%20Twitter%20or%20subscribe%20to%20RSS.%20This%20week%27s%20author%20is%20Ben%20Gillbanks%20from%20Binary%20Moon.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=278&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Submit this to Script &amp; Style">Submit this to Script &amp; Style</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/wphardcore?a=RcA6JwlMIBc:mhxyIW_jTAo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=RcA6JwlMIBc:mhxyIW_jTAo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=RcA6JwlMIBc:mhxyIW_jTAo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=RcA6JwlMIBc:mhxyIW_jTAo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=RcA6JwlMIBc:mhxyIW_jTAo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=RcA6JwlMIBc:mhxyIW_jTAo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=RcA6JwlMIBc:mhxyIW_jTAo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/wphardcore?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=RcA6JwlMIBc:mhxyIW_jTAo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=RcA6JwlMIBc:mhxyIW_jTAo:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/wphardcore/~4/RcA6JwlMIBc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.wphardcore.com/2010/follow-friday-ben-gillbanks/</feedburner:origLink></item>
		<item>
		<title>Ultimate Guide to Roles and Capabilities</title>
		<link>http://feedproxy.google.com/~r/wphardcore/~3/nQ23VlHe2uY/</link>
		<comments>http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 03:47:16 +0000</pubDate>
		<dc:creator>Gary Cao</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.wphardcore.com/?p=92</guid>
		<description><![CDATA[Since <a href="http://codex.wordpress.org/Roles_and_Capabilities">Roles and Capabilities</a> are introduced in WordPress 2.0, the <a href="http://codex.wordpress.org/User_Levels">User Level approach</a> has been declared deprecated. However, it's disappointing that most plugins and themes out there still use user levels to control access to admin option pages and other functionalities. This guide shows you how to properly use Roles and Capabilities in your plugins and themes.

<strong>Disclaimer</strong>: This article is a long one, therefore you should probably bookmark it so that you can always come back later for reference.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wphardcore.com%2F2010%2Fultimate-guide-to-roles-and-capabilities%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wphardcore.com%2F2010%2Fultimate-guide-to-roles-and-capabilities%2F&amp;source=wphardcore&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Since <a href="http://codex.wordpress.org/Roles_and_Capabilities">Roles and Capabilities</a> are introduced in WordPress 2.0, the <a href="http://codex.wordpress.org/User_Levels">User Level approach</a> has been declared deprecated. However, it&#8217;s disappointing that most plugins and themes out there still use user levels to control access to admin option pages and other functionalities. This guide shows you how to properly use Roles and Capabilities in your plugins and themes.</p>
<p><strong>Disclaimer</strong>: This article is a long one, therefore you should probably bookmark it so that you can always come back later for reference.</p>
<h2>Table of Contents</h2>
<ol>
<li><a href="#what">What are Roles and Capabilities?</a></li>
<li><a href="#admin-options">Capabilities and administration menus</a></li>
<li><a href="#check-capability">Checking a user&#8217;s capability</a></li>
<li><a href="#add-role">Adding custom user roles</a></li>
<li><a href="#add-capability">Adding custom user capabilities</a></li>
<li><a href="#api">WordPress Capability Classes</a></li>
</ol>
<h2 id="what">What are Roles and Capabilities?</h2>
<p>As in other CMS and web applications, WordPress has a built-in system to verify whether a particular user has enough privilege to take a certain action. Users are divided into Roles, and each Role is assigned certain capabilities (or permissions). Here is a summary of <a href="http://codex.wordpress.org/Roles_and_Capabilities#Summary_of_Roles">WordPress default roles</a>:</p>
<blockquote><p>
<strong>Administrator</strong> &#8211; Somebody who has access to all the administration features</p>
<p><strong>Editor</strong> &#8211; Somebody who can publish posts, manage posts as well as manage other people&#8217;s posts, etc.</p>
<p><strong>Author</strong> &#8211; Somebody who can publish and manage their own posts</p>
<p><strong>Contributor</strong> &#8211; Somebody who can write and manage their posts but not publish posts</p>
<p><strong>Subscriber</strong> &#8211; Somebody who can read comments/comment/receive news letters, etc.
</p>
</blockquote>
<p>This system of Roles and Capabilities is much more flexible than User Level, since it enables you to add, remove or reassign capabilities among roles. You can even add more roles to the system without destroying the default setup.</p>
<h2 id="admin-options">Capabilities and administration menus</h2>
<p>Almost every plugin needs to have at least one page in the admin area to let users customize how the plugin is used. In order to do this, you need to <a href="http://codex.wordpress.org/Adding_Administration_Menus">add your own administration menu items</a>. There are a bunch of WordPress functions which let you do this:</p>
<pre class="brush: php; title: ;">
// add top level menu
add_menu_page(page_title, menu_title, capability, handle, [function], [icon_url]);

// add sub-menu pages
add_submenu_page(parent, page_title, menu_title, capability, file/handle, [function]);

// add Options sub-menu
add_options_page(page_title, menu_title, capability, handle, [function]);

// add Management sub-menu
add_management_page(page_title, menu_title, capability, handle, [function]);

// add Pages sub-menu
add_pages_page( page_title, menu_title, capability, handle, [function]);

// add Posts sub-menu
add_posts_page( page_title, menu_title, capability, handle, [function]);

// add Appearances sub-menu
add_theme_page( page_title, menu_title, capability, handle, [function]);
</pre>
<p>As you can see, there&#8217;s always a required parameter called <code>capability</code> for each of those functions. This essentially means the user who logs in to the administration area needs to have a certain capability to see the menu item.  You can either use a user level (which is deprecated and not recommended), or a string representing a certain capability (for example, <code>edit_posts</code>).</p>
<p>Many plugins still use user levels (numeric representation of a user&#8217;s privilege, from 0 to 10). However, this is deprecated and should not be used anymore. By using capabilities, you won&#8217;t have to worry when user levels are not supported by WordPress, and if you want to add and use your custom capabilities, this is the way to go.</p>
<p>If you use the functions above to add menu items to the admin area, only the users who have the specified capability can see the menu items and access the pages associated with those items. If your theme or plugin has an option page, it&#8217;s important that you restrict access to that page properly. For example, if it&#8217;s a theme option page, you should use <code>edit_themes</code> capability, while if it&#8217;s a plugin option, <code>edit_plugins</code>. Another way is to use <code>manage_options</code> for both plugin and theme option pages.</p>
<p>Remember, sometimes the blog administrator wants to share and divide responsibilities among several other users. As a result, using capabilities make your themes and plugins much more customizable.</p>
<h2 id="check-capability">Checking a user&#8217;s capability</h2>
<p>If your plugin or theme involves the user making changes to the blog&#8217;s data (adding new or editing existing content etc.), it&#8217;s very important that you check whether the current user has enough capability to make a certain action. The <code>current_user_can()</code> function lets you do this:</p>
<pre class="brush: php; title: ;">
if ( current_user_can( $capability ) ) {
    // do something if the current user has $capability
}
</pre>
<p>This function also accepts an optional argument for a certain post ID, in case you want to check whether the current user can do something to that post:</p>
<pre class="brush: php; title: ;">
// check whether the current can edit a post with the ID $post_id
current_user_can( 'edit_post', $post_id );
</pre>
<p>There&#8217;s another function you can use to check whether the author of a certain post has a certain capability:</p>
<pre class="brush: php; title: ;">
if ( author_can( $post, $capability ) ) {
    // do something if the author of the post $post has $capability
}
</pre>
<p>The first argument can be either a post object, or a post ID. Although this function is rarely used, it&#8217;s helpful to know it&#8217;s there. I personally never had to use that function, but if you have an interesting example, let me know in the comment!</p>
<h2 id="add-roles">Adding custom user roles</h2>
<p>Sometimes it&#8217;s necessary for your plugin to add new roles to the system. Let&#8217;s say you&#8217;re coding a new gallery plugin where users can register to upload photos to your site, but that&#8217;s it &#8211; these registered users can&#8217;t add or modify any other type of content to your blog (such as posts or pages). The best way to do this, is to add a new custom role:</p>
<pre class="brush: php; title: ;">
add_role( $role_name, $display_name, $capabilities );

// for example:

add_role( 'photo_uploader', 'Photo Uploader', array( 'organize_gallery' ) );
</pre>
<p>What this function does is add a new role to the system with a set of capabilities. The example aboves add a role called &#8220;photo_uploader&#8221;, with a display name and an array containing a list of default capabilities for that role (in this case, <code>organize_gallery</code> ).</p>
<p>When you process a request to create, edit or upload galleries, you should use <code>current_user_can()</code> to check whether the current user are permitted to take these actions.</p>
<pre class="brush: php; title: ;">
if ( current_user_can( 'organize_gallery' ) ) {
    // do something
}
</pre>
<p>The users who are assigned this role can only <code>organize_gallery</code>, but cannot <code>edit_posts</code> or <code>publish_posts</code>.</p>
<p>To remove a role, you can use <code>remove_role()</code>:</p>
<pre class="brush: php; title: ;">
remove_role( 'photo_uploader' );
</pre>
<p>You should have an option somewhere for your plugin users to remove this custom role when they decide to uninstall your plugin.</p>
<p>But what if you want to add capabilities to existing users?</p>
<h2 id="add-capability">Adding custom user capabilities</h2>
<p>This is useful when you develop a plugin that allows users to take actions other than manipulating post contents. Let&#8217;s come back to our gallery plugin example above. Say, if you also want to assign <code>organize_gallery</code> capability to existing roles (administrator, editor, author, contributor etc. ), what would you do?</p>
<pre class="brush: php; title: ;">
// get the &quot;author&quot; role object
$role = get_role( 'author' );

// add &quot;organize_gallery&quot; to this role object
$role-&gt;add_cap( 'organize_gallery' );
</pre>
<h2 id="api">WordPress Capability Classes</h2>
<p>We&#8217;ve covered checking and adding capabilities, as well as adding roles. These are the most frequent used functions for managing user permissions in WordPress. However, as the title of this post contains the word &#8220;ultimate&#8221;, I&#8217;d like to also cover the three WordPress classes that work behind the scene and the API these classes provide, which you can use for advanced permission management in your plugin. These three classes are:</p>
<ul>
<li>WP_Roles</li>
<li>WP_Role</li>
<li>WP_User</li>
</ul>
<p>The source code of these three classes can be found in <code>wp-includes/capabilities.php</code>. The source code is documented in great details and I&#8217;m sure you can understand it easily, but I&#8217;d like to sum up what you can do with these classes.</p>
<h3 id="wp_roles-class">The WP_Roles Class</h3>
<p>This class, as its name suggests, is for managing roles in general. When you use it in your plugin, you actually don&#8217;t have to initiate a new object, but use a global object which has been created by WordPress:</p>
<pre class="brush: php; title: ;">
global $wp_roles;
</pre>
<p>The <code>$wp_roles</code> is available as a global object, and can be used anywhere in your functions, as long as it&#8217;s declared beforehand in your functions with the <code>global</code> keyword.</p>
<p>As covered before, you can add and remove roles using <code>add_role()</code> and <code>remove_role()</code>. These functions are actually wrappers for <code>$wp_roles->add_role()</code>, and <code>$wp_roles->remove_role</code>. Therefore you can add and remove roles using the <code>$wp_roles</code> object as well:</p>
<pre class="brush: php; title: ;">
global $wp_roles;

// add a new role, same arguments as add_role()
$wp_roles-&gt;add_role( $role, $display_name, $capabilities )

// remove a role, same arguments as remove_role()
$wp_roles-&gt;remove_role( $role );
</pre>
<p>Likewise, you can also get a role using this method:</p>
<pre class="brush: php; title: ;">
global $wp_roles;

// get a role based on role name, does the same thing as get_role()
$wp_roles-&gt;get_role( $role );
</pre>
<p>You can also get a list of available roles, containing pair of role names and role display names. This is useful when you want to provide an interface for the user to change capability assignment.</p>
<pre class="brush: php; title: ;">
global $wp_roles;

// get a list of values, containing pairs of: $role_name =&gt; $display_name
$roles = $wp_roles-&gt;get_names();
</pre>
<p>Finally, you can add and remove capabilities using <code>$wp_roles</code> too, making this object versatile for almost all roles and capabilities operations.</p>
<pre class="brush: php; title: ;">
global $wp_roles;

// add capability $cap to role $role
$wp_roles-&gt;add_cap( $role, $cap );

// remove capability $cap from role $role
$wp_roles-&gt;remove_cap( $role, $cap );

// for example
$wp_roles-&gt;add_cap( 'administrator', 'manage_galleries' );
$wp_roles-&gt;remove_cap( 'subscriber', 'view_galleries' );
</pre>
<h3 id="wp_role-class">WP_Role Class</h3>
<p>This is a very simple class. All it does is adding and removing capabilities.</p>
<pre class="brush: php; title: ;">
// get the the role object
$role_object = get_role( $role_name );

// add $cap capability to this role object
$role_object-&gt;add_cap( $capability_name );

// remove $cap capability from this role object
$role_object-&gt;remove_cap( $capability_name );
</pre>
<h3 id="wp_user-class">WP_User class</h3>
<p>This class lets you manage roles and capabilities per user, which means you can assign multiple roles to a particular user, or add a capability to a certain user regardless of his current role.</p>
<p>First of all, you need to get the user object before manipulating its roles and capabilities:</p>
<pre class="brush: php; title: ;">
// get user by user ID
$user = new WP_User( $id );

// or get user by username
$user = new WP_User( null, $name );
</pre>
<p>As you can see, you can get a user object based on either his user ID or username. With the latter, the first parameter must be empty (either <code>null</code> or an empty string). Examples:</p>
<pre class="brush: php; title: ;">
// get the administrator by ID
$admin = new WP_User( 1 );

// get the administrator by username
$admin = new WP_User( null, 'admin' );
</pre>
<p>Once you have the user object, you can add another role to this user without modifying his current role (which means the user can have as many roles as you want):</p>
<pre class="brush: php; title: ;">
$user-&gt;add_role( $role_name );
</pre>
<p>Or you can remove a role from this user, using <code>remove_role()</code>:</p>
<pre class="brush: php; title: ;">
$user-&gt;remove_role( $role_name );
</pre>
<p>You can also set a role to this user, which means removing all the current roles of this user and assign a new one:</p>
<pre class="brush: php; title: ;">
$user-&gt;set_role( $role_name );
</pre>
<p>For manipulating capabilities, you have a bunch of methods that allow you to do various things:</p>
<pre class="brush: php; title: ;">
// check whether the user has a certain capability or role name
if ( $user-&gt;has_cap( $cap_name ) ) {
    // do something
}

// add a capability to the user and grant access to that capability
$user-&gt;add_cap( $cap_name );

// remove a capability from the user
$user-&gt;remove_cap( $cap_name );

// remove all capabilities from the user
$user-&gt;remove_all_caps();
</pre>
<h3>Conclusion</h3>
<p>There, that&#8217;s all there is to know about Roles and Capabilities. You might not need to grasp all of this, but it&#8217;s definitely helpful to know WordPress has a full-fledged user and role management system, which you can always use for complicated projects. This post has been all theory so far, but in the next tutorial, I&#8217;ll show you how to use this knowledge to build a &#8220;client login&#8221; area for your WordPress portfolio site.</p>
<p>If you have any comment or suggestion, please leave it below!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-bg-">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Ultimate+Guide+to+Roles+and+Capabilities&amp;link=http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/&amp;notes=Since%20Roles%20and%20Capabilities%20are%20introduced%20in%20WordPress%202.0%2C%20the%20User%20Level%20approach%20has%20been%20declared%20deprecated.%20However%2C%20it%27s%20disappointing%20that%20most%20plugins%20and%20themes%20out%20there%20still%20use%20user%20levels%20to%20control%20access%20to%20admin%20option%20pages%20and%20other%20functionalities.%20This%20guide%20shows%20you%20how%20to%20properly%20use%20Roles%20and%20Capabilities%20in%20your%20plugins%20and%20themes.%0D%0A%0D%0ADisclaimer%3A%20This%20article%20is%20a%20long%20one%2C%20therefore%20you%20should%20probably%20bookmark%20it%20so%20that%20you%20can%20always%20come%20back%20later%20for%20reference.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designbump">
			<a href="http://www.shareaholic.com/api/share/?title=Ultimate+Guide+to+Roles+and+Capabilities&amp;link=http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/&amp;notes=Since%20Roles%20and%20Capabilities%20are%20introduced%20in%20WordPress%202.0%2C%20the%20User%20Level%20approach%20has%20been%20declared%20deprecated.%20However%2C%20it%27s%20disappointing%20that%20most%20plugins%20and%20themes%20out%20there%20still%20use%20user%20levels%20to%20control%20access%20to%20admin%20option%20pages%20and%20other%20functionalities.%20This%20guide%20shows%20you%20how%20to%20properly%20use%20Roles%20and%20Capabilities%20in%20your%20plugins%20and%20themes.%0D%0A%0D%0ADisclaimer%3A%20This%20article%20is%20a%20long%20one%2C%20therefore%20you%20should%20probably%20bookmark%20it%20so%20that%20you%20can%20always%20come%20back%20later%20for%20reference.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=282&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Bump this on DesignBump">Bump this on DesignBump</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.shareaholic.com/api/share/?title=Ultimate+Guide+to+Roles+and+Capabilities&amp;link=http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/&amp;notes=Since%20Roles%20and%20Capabilities%20are%20introduced%20in%20WordPress%202.0%2C%20the%20User%20Level%20approach%20has%20been%20declared%20deprecated.%20However%2C%20it%27s%20disappointing%20that%20most%20plugins%20and%20themes%20out%20there%20still%20use%20user%20levels%20to%20control%20access%20to%20admin%20option%20pages%20and%20other%20functionalities.%20This%20guide%20shows%20you%20how%20to%20properly%20use%20Roles%20and%20Capabilities%20in%20your%20plugins%20and%20themes.%0D%0A%0D%0ADisclaimer%3A%20This%20article%20is%20a%20long%20one%2C%20therefore%20you%20should%20probably%20bookmark%20it%20so%20that%20you%20can%20always%20come%20back%20later%20for%20reference.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=106&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.shareaholic.com/api/share/?title=Ultimate+Guide+to+Roles+and+Capabilities&amp;link=http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/&amp;notes=Since%20Roles%20and%20Capabilities%20are%20introduced%20in%20WordPress%202.0%2C%20the%20User%20Level%20approach%20has%20been%20declared%20deprecated.%20However%2C%20it%27s%20disappointing%20that%20most%20plugins%20and%20themes%20out%20there%20still%20use%20user%20levels%20to%20control%20access%20to%20admin%20option%20pages%20and%20other%20functionalities.%20This%20guide%20shows%20you%20how%20to%20properly%20use%20Roles%20and%20Capabilities%20in%20your%20plugins%20and%20themes.%0D%0A%0D%0ADisclaimer%3A%20This%20article%20is%20a%20long%20one%2C%20therefore%20you%20should%20probably%20bookmark%20it%20so%20that%20you%20can%20always%20come%20back%20later%20for%20reference.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=102&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Ultimate+Guide+to+Roles+and+Capabilities&amp;link=http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/&amp;notes=Since%20Roles%20and%20Capabilities%20are%20introduced%20in%20WordPress%202.0%2C%20the%20User%20Level%20approach%20has%20been%20declared%20deprecated.%20However%2C%20it%27s%20disappointing%20that%20most%20plugins%20and%20themes%20out%20there%20still%20use%20user%20levels%20to%20control%20access%20to%20admin%20option%20pages%20and%20other%20functionalities.%20This%20guide%20shows%20you%20how%20to%20properly%20use%20Roles%20and%20Capabilities%20in%20your%20plugins%20and%20themes.%0D%0A%0D%0ADisclaimer%3A%20This%20article%20is%20a%20long%20one%2C%20therefore%20you%20should%20probably%20bookmark%20it%20so%20that%20you%20can%20always%20come%20back%20later%20for%20reference.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.shareaholic.com/api/share/?title=Ultimate+Guide+to+Roles+and+Capabilities&amp;link=http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/&amp;notes=Since%20Roles%20and%20Capabilities%20are%20introduced%20in%20WordPress%202.0%2C%20the%20User%20Level%20approach%20has%20been%20declared%20deprecated.%20However%2C%20it%27s%20disappointing%20that%20most%20plugins%20and%20themes%20out%20there%20still%20use%20user%20levels%20to%20control%20access%20to%20admin%20option%20pages%20and%20other%20functionalities.%20This%20guide%20shows%20you%20how%20to%20properly%20use%20Roles%20and%20Capabilities%20in%20your%20plugins%20and%20themes.%0D%0A%0D%0ADisclaimer%3A%20This%20article%20is%20a%20long%20one%2C%20therefore%20you%20should%20probably%20bookmark%20it%20so%20that%20you%20can%20always%20come%20back%20later%20for%20reference.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=74&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Ultimate+Guide+to+Roles+and+Capabilities&amp;link=http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/&amp;notes=Since%20Roles%20and%20Capabilities%20are%20introduced%20in%20WordPress%202.0%2C%20the%20User%20Level%20approach%20has%20been%20declared%20deprecated.%20However%2C%20it%27s%20disappointing%20that%20most%20plugins%20and%20themes%20out%20there%20still%20use%20user%20levels%20to%20control%20access%20to%20admin%20option%20pages%20and%20other%20functionalities.%20This%20guide%20shows%20you%20how%20to%20properly%20use%20Roles%20and%20Capabilities%20in%20your%20plugins%20and%20themes.%0D%0A%0D%0ADisclaimer%3A%20This%20article%20is%20a%20long%20one%2C%20therefore%20you%20should%20probably%20bookmark%20it%20so%20that%20you%20can%20always%20come%20back%20later%20for%20reference.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-scriptstyle">
			<a href="http://www.shareaholic.com/api/share/?title=Ultimate+Guide+to+Roles+and+Capabilities&amp;link=http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/&amp;notes=Since%20Roles%20and%20Capabilities%20are%20introduced%20in%20WordPress%202.0%2C%20the%20User%20Level%20approach%20has%20been%20declared%20deprecated.%20However%2C%20it%27s%20disappointing%20that%20most%20plugins%20and%20themes%20out%20there%20still%20use%20user%20levels%20to%20control%20access%20to%20admin%20option%20pages%20and%20other%20functionalities.%20This%20guide%20shows%20you%20how%20to%20properly%20use%20Roles%20and%20Capabilities%20in%20your%20plugins%20and%20themes.%0D%0A%0D%0ADisclaimer%3A%20This%20article%20is%20a%20long%20one%2C%20therefore%20you%20should%20probably%20bookmark%20it%20so%20that%20you%20can%20always%20come%20back%20later%20for%20reference.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=278&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Submit this to Script &amp; Style">Submit this to Script &amp; Style</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/wphardcore?a=nQ23VlHe2uY:lzZCVoIp65U:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=nQ23VlHe2uY:lzZCVoIp65U:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=nQ23VlHe2uY:lzZCVoIp65U:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=nQ23VlHe2uY:lzZCVoIp65U:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=nQ23VlHe2uY:lzZCVoIp65U:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=nQ23VlHe2uY:lzZCVoIp65U:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=nQ23VlHe2uY:lzZCVoIp65U:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/wphardcore?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=nQ23VlHe2uY:lzZCVoIp65U:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=nQ23VlHe2uY:lzZCVoIp65U:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/wphardcore/~4/nQ23VlHe2uY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		<feedburner:origLink>http://www.wphardcore.com/2010/ultimate-guide-to-roles-and-capabilities/</feedburner:origLink></item>
		<item>
		<title>5 tips for using AJAX in WordPress</title>
		<link>http://feedproxy.google.com/~r/wphardcore/~3/yssRJhwperk/</link>
		<comments>http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 23:05:22 +0000</pubDate>
		<dc:creator>Gary Cao</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://www.wphardcore.com/?p=39</guid>
		<description><![CDATA[AJAX is used in many WordPress themes and plugins. However, not all of those themes and plugins implement AJAX properly. This article reveals 5 best practices in developing AJAX for WordPress.

<strong>Warning:</strong> This is a long and information-packed article. Be sure to bookmark this post so you can always go back for reference! ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wphardcore.com%2F2010%2F5-tips-for-using-ajax-in-wordpress%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wphardcore.com%2F2010%2F5-tips-for-using-ajax-in-wordpress%2F&amp;source=wphardcore&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>AJAX is used in many WordPress themes and plugins. However, not all of those themes and plugins implement AJAX properly. This article reveals 5 best practices in developing AJAX for WordPress.</p>
<p><strong>Warning:</strong> This is a long and information-packed article. Be sure to bookmark this post so you can always go back for reference! The links below makes it easier to navigate this article.</p>
<h3>Table of Content</h3>
<ul>
<li><a href="#bad-ways">Bad ways to implement AJAX</a></li>
<li><a href="#js-global">1. Use wp_localize_script() to declare javascript global variables</a></li>
<li><a href="#admin-ajax">2. Use admin-ajax.php to handle AJAX requests</a></li>
<li><a href="#nonce-permission">3. Use nonces and check for permission</a></li>
<li><a href="#form">4. Use the built-in jQuery Form plugin to submit forms</a></li>
<li><a href="#json-parse">5. Be careful with jQuery default JSON parsing</a></li>
</ul>
<h3 id="bad-ways">Bad ways to implement AJAX</h3>
<p>I have read the code of many plugins that implement AJAX. While some of them do it the right way, most of them don&#8217;t. The common pattern in those plugins is: a PHP file to handle the AJAX request, and another PHP file that spits out javascript code to make the AJAX request.</p>
<p>The PHP file that handles the AJAX almost always begin with this line:</p>
<pre class="brush: php; title: ;">
require_once( &quot;../../../../wp-config.php&quot; );
// or require_once( &quot;../../../../wp-load.php&quot; );
</pre>
<p>What&#8217;s wrong with this is that sometimes users set up their folder structure differently, making the relative path declared in the PHP file above invalid. Another downside to this, is if you&#8217;re using Object Oriented approach to develop your plugin (wrapping your plugin functions in a class), you won&#8217;t have direct access to the necessary properties and private functions of the class.</p>
<p>Along with the PHP file above, another PHP file is necessary to output the javascript that makes the AJAX request. This has to be a PHP file instead of a normal JavaScript file, because (again) it has to include wp-config.php (or wp-load.php), so that it can get the absolute URL to the PHP file that handles the request, or load some additional data from the database. In order to load this &#8220;fake&#8221; javascript file, the whole WordPress framework needs to be loaded again.</p>
<p>Sorry for keeping you off the good part of the article so long. But avoiding doing things the wrong way is as important as knowing how to do them right. Without further ado, here are 5 crucial tips for implementing AJAX in WordPress properly.</p>
<h3 id="js-global">1. Use wp_localize_script() to declare javascript global variables</h3>
<p>Although <code>wp_localize_script()</code> is created for localization, it also has another great use. You can declare javascript variables with namespaces to use with your script. Here&#8217;s the syntax:</p>
<pre class="brush: php; title: ;">wp_localize_script( $handle, $namespace, $variable_array );</pre>
<p>Here&#8217;s how you should declare the URL to the file that handles AJAX (in this example, I use admin-ajax.php, which is discussed in tip #2):</p>
<pre class="brush: php; title: ;">
// embed the javascript file that makes the AJAX request
wp_enqueue_script( 'my-ajax-request', plugin_dir_url( __FILE__ ) . 'js/ajax.js', array( 'jquery' ) );

// declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php)
wp_localize_script( 'my-ajax-request', 'MyAjax', array( 'ajaxurl' =&gt; admin_url( 'admin-ajax.php' ) ) );
</pre>
<p>This way, you won&#8217;t have to use PHP to print out JavaScript code, which is both ugly and non-cacheable. If you take a look at the generated HTML in the <code>&lt;head&gt;</code> element, you&#8217;ll find this:</p>
<pre class="brush: xml; title: ;">
&lt;script type=&quot;text/javascript&quot; src=&quot;http://example.com/wordpress/wp-content/plugins/myajax/js/ajax.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
/* &lt;![CDATA[ */
var MyAjax = {
	ajaxurl: &quot;http://example.com/wordpress/wp-admin/admin-ajax.php&quot;
};
/* ]]&gt; */
&lt;/script&gt;
</pre>
<p>Now, in your <code>ajax.js</code> file, you can use <code>MyAjax.ajaxurl</code> without having to resort to PHP and including <code>wp-load.php</code>. Please refer to tip #2 below for more about setting up the javascript code that sends the request, and how to handle the request properly.</p>
<h3 id="admin-ajax">2. Use admin-ajax.php to handle AJAX requests</h3>
<p>AJAX requests should be directed to <code>wp-admin/admin-ajax.php</code>. I know the &#8220;admin&#8221; part of the file name is a bit misleading, but all requests in the front-end (the viewing side) as well as the admin panel can be processed in <code>admin-ajax.php</code>.</p>
<p>There&#8217;s a required parameter for a request sent to <code>admin-ajax</code> : it&#8217;s called <code>action</code>. This parameter is necessary because when <code>admin-ajax</code> process the request, it will fire one of these hooks, depending on whether the current viewer is logged in or not:</p>
<pre class="brush: php; title: ;">
// this hook is fired if the current viewer is not logged in
do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'] );

// if logged in:
do_action( 'wp_ajax_' . $_POST['action'] );
</pre>
<p>The JavaScript code that submits the AJAX request should look something like this:</p>
<pre class="brush: jscript; title: ;">
jQuery.post(
	// see tip #1 for how we declare global javascript variables
	MyAjax.ajaxurl,
	{
		// here we declare the parameters to send along with the request
		// this means the following action hooks will be fired:
		// wp_ajax_nopriv_myajax-submit and wp_ajax_myajax-submit
		action : 'myajax-submit',

		// other parameters can be added along with &quot;action&quot;
		postID : MyAjax.postID
	},
	function( response ) {
		alert( response );
	}
);
</pre>
<p>Now all we have to do is hook our existing plugin or theme file up with those provided ajax actions without having to create a separate file to process the request:</p>
<pre class="brush: php; title: ;">
// if both logged in and not logged in users can send this AJAX request,
// add both of these actions, otherwise add only the appropriate one
add_action( 'wp_ajax_nopriv_myajax-submit', 'myajax_submit' );
add_action( 'wp_ajax_myajax-submit', 'myajax_submit' );

function myajax_submit() {
	// get the submitted parameters
	$postID = $_POST['postID'];

	// generate the response
	$response = json_encode( array( 'success' =&gt; true ) );

	// response output
	header( &quot;Content-Type: application/json&quot; );
	echo $response;

	// IMPORTANT: don't forget to &quot;exit&quot;
	exit;
}
</pre>
<h3 id="nonce-permission">3. Use nonces and check for permission</h3>
<p>It can&#8217;t be stressed enough that you need to check for permission for every action a user takes. Developers often neglect this, and the results are disastrous, because without layers that checks for sufficient permissions, a malicious user could escalate his privilege and do all sorts of naughty things with your website that you have spent so much effort to build. There are two layers of security that you need to apply to all AJAX request most of the time.</p>
<h4>Nonces</h4>
<p>Nonces are <strong>N</strong>umbers that are generated and used <strong>once</strong>. Nonces are used to make sure the action is initiated by the authorized user from a certain location. Here&#8217;s an <a href="http://blog.archive.jpsykes.com/57/nonce-its-like-the-deli-counter/index.html">interesting analogy by Jon Sykes</a>, which makes everything easier to understand:</p>
<blockquote><p>When you arrive at a deli counter you’re asked to take a ticket. Once the counter reaches your number you had the ticket back to the server (who throws it away) and they serve you. They then move onto serving the next person in the who’s ticket matches the number of the digital screen.</p>
<p>If someone comes along and tries to jump the line (queue) they can’t unless they have a ticket.</p>
<p>If they manage to get hold of someones old ticket, they can’t use it, as it’s already been used and the digital counter has moved on.</p>
<p>To further extend the analogy, you then make every customer sign for the ticket when they take one, and you then check not only that there ticket matches but also make them sign again to check that their first signature matches the one they have before they get served.</p>
<p>Taking it to a silly level, you’d only allow users to get a ticket when they walked in the front door of the store (that they have to sign for). This then prevents someone climbing in a window and trying to forge your signature to get served. Because they didn’t come in the front door, they don’t have any access to the tickets, so they have no way of jumping ahead of you and ordering the last of the Bologna.</p></blockquote>
<p><a href="http://markjaquith.wordpress.com/2006/06/02/wordpress-203-nonces/">Mark Jaquith</a> and <a href="http://www.prelovac.com/vladimir/improving-security-in-wordpress-plugins-using-nonces">Vladimir Prelovac</a> also covered Nonces and how to use them generally. Make sure you read those articles because you&#8217;ll definitely need them for almost all kinds of WP development (not only AJAX related).</p>
<p>However, it should be stressed that nonces are useful only in situations where the AJAX request has something to do with data or content manipulation. If the request is only for retrieving comment count, or post content for example, nonces are not required. AJAX requests to post / edit / delete contents definitely need nonce checking.</p>
<p>OK, enough theory. Here&#8217;s how to implement nonces in your AJAX request.</p>
<p>First, you need to generate a nonce, and use <code>wp_localize_script()</code> to include it as a javascript variable:</p>
<pre class="brush: php; title: ;">
// embed the javascript file that makes the AJAX request
wp_enqueue_script( 'my-ajax-request', plugin_dir_url( __FILE__ ) . 'js/ajax.js', array( 'jquery' ) );

wp_localize_script( 'my-ajax-request', 'MyAjax', array(
	// URL to wp-admin/admin-ajax.php to process the request
	'ajaxurl'          =&gt; admin_url( 'admin-ajax.php' ),

	// generate a nonce with a unique ID &quot;myajax-post-comment-nonce&quot;
	// so that you can check it later when an AJAX request is sent
	'postCommentNonce' =&gt; wp_create_nonce( 'myajax-post-comment-nonce' ),
	)
);
</pre>
<p>Now your JavaScript can use the global variable <code>MyAjax.postCommentNonce</code> to get the nonce. You have to send the nonce along with your request so that the AJAX handler can check it:</p>
<pre class="brush: jscript; title: ;">
jQuery.post(
	MyAjax.ajaxurl,
	{
		action : 'myajax-submit',
		postID : MyAjax.postID,

		// send the nonce along with the request
		postCommentNonce : MyAjax.postCommentNonce
	},
	function( response ) {
		alert( response );
	}
);
</pre>
<p>Here&#8217;s essentially the same code as in tip #2, except that I&#8217;ve added nonce validation to make sure the request is valid:</p>
<pre class="brush: php; title: ;">
// if both logged in and not logged in users can send this AJAX request,
// add both of these actions, otherwise add only the appropriate one
add_action( 'wp_ajax_nopriv_myajax-submit', 'myajax_submit' );
add_action( 'wp_ajax_myajax-submit', 'myajax_submit' );

function myajax_submit() {

	$nonce = $_POST['postCommentNonce'];

	// check to see if the submitted nonce matches with the
	// generated nonce we created earlier
	if ( ! wp_verify_nonce( $nonce, 'myajax-post-comment-nonce' ) )
		die ( 'Busted!')

	// get the submitted parameters
	$postID = $_POST['postID'];

	// generate the response
	$response = json_encode( array( 'success' =&gt; true ) );

	// response output
	header( &quot;Content-Type: application/json&quot; );
	echo $response;

	// IMPORTANT: don't forget to &quot;exit&quot;
	exit;
}
</pre>
<p>There, all done. Now here&#8217;s an important note. If you want to allow the user to initiate the AJAX request multiple times (like posting multiple comments on the same page) , you need to regenerate a new nonce, include it in your response, and then reassign that new nonce to MyAjax.postCommentNonce. Otherwise, the same nonce would be used over and over again, and the subsequent AJAX requests will fail.</p>
<h4>Check for permissions</h4>
<p>Lots of plugins neglect to check for sufficient permission for AJAX requests. Always use <code>current_user_can()</code> to make sure the request is made by an authorized user. Here&#8217;s the final bulletproofed version of the request handling code:</p>
<pre class="brush: php; title: ;">
// if both logged in and not logged in users can send this AJAX request,
// add both of these actions, otherwise add only the appropriate one
add_action( 'wp_ajax_nopriv_myajax-submit', 'myajax_submit' );
add_action( 'wp_ajax_myajax-submit', 'myajax_submit' );

function myajax_submit() {

	$nonce = $_POST['postCommentNonce'];

	// check to see if the submitted nonce matches with the
	// generated nonce we created earlier
	if ( ! wp_verify_nonce( $nonce, 'myajax-post-comment-nonce' ) )
		die ( 'Busted!')

	// ignore the request if the current user doesn't have
	// sufficient permissions
	if ( current_user_can( 'edit_posts' ) ) {
		// get the submitted parameters
		$postID = $_POST['postID'];

		// generate the response
		$response = json_encode( array( 'success' =&gt; true ) );

		// response output
		header( &quot;Content-Type: application/json&quot; );
		echo $response;
	}

	// IMPORTANT: don't forget to &quot;exit&quot;
	exit;
}
</pre>
<h3 id="form">4. Use the built-in jQuery Form plugin to submit forms</h3>
<p>Most of the time you use AJAX to avoid page reload when submitting forms. Not everyone knows that WordPress also provide a jQuery plugin to deal with AJAX form submission. To use this jQuery plugin, include it by using &#8220;jquery-form&#8221; as the handle:</p>
<pre class="brush: php; title: ;">
wp_enqueue_script( 'json-form' );
</pre>
<p>Then, submitting form using AJAX is a breeze:</p>
<pre class="brush: jscript; title: ;">
jQuery('#myForm1').ajaxForm({
	data: {
		// additional data to be included along with the form fields
	},
	dataType: 'json',
	beforeSubmit: function(formData, jqForm, options) {
		// optionally process data before submitting the form via AJAX
	},
	success : function(responseText, statusText, xhr, $form) {
		// code that's executed when the request is processed successfully
	}
});
</pre>
<p>There are a lot more options for you to configure. Check out <a href="http://jquery.malsup.com/form/">jQuery Form plugin documentation</a> for more details.</p>
<h3 id="json-parse">5. Be careful with jQuery default JSON parsing</h3>
<p>At the moment of this writing, the latest stable version of WordPress is 2.9.2 . In this version of WordPress, the default jQuery version is 1.3.2 . </p>
<p>In jQuery 1.3.2 or earlier, jQuery uses <code>eval</code> to convert a JSON string into an object. While this is fast, it&#8217;s not safe:</p>
<blockquote><p>
The eval function is very fast. However, it can compile and execute any JavaScript program, so there can be security issues. The use of eval is indicated when the source is trusted and competent. It is much safer to use a JSON parser. In web applications over XMLHttpRequest, communication is permitted only to the same origin that provide that page, so it is trusted. But it might not be competent. If the server is not rigorous in its JSON encoding, or if it does not scrupulously validate all of its inputs, then it could deliver invalid JSON text that could be carrying dangerous script. The eval function would execute the script, unleashing its malice.</p>
<p><small>from <a href="http://www.json.org/js.html">json.org</a></small>
</p></blockquote>
<p>jQuery 1.3.3 and later will automatically check if there&#8217;s already a JSON parser, and use that parser instead of <code>eval()</code>. WordPress also provides the javascript JSON parser in <code>wp-includes/js/json2.js</code>. Including it is simple:</p>
<pre class="brush: php; title: ;">
wp_enqueue_script( 'json2' );
</pre>
<p>Then, to make sure your script parses JSON the safe way, there are two ways:</p>
<p>The first way is to include your own version of jQuery (equal or later than 1.3.3)</p>
<pre class="brush: php; title: ;">
wp_enqueue_script( 'json2' );
// don't forget to specify dependency
wp_enqueue_script( 'myjQuery', plugin_dir_url( __FILE__ ) . 'js/jquery.1.4.2.js', array( 'json2' ) );
</pre>
<p>The second way is to use WordPress supplied jQuery, but make sure that you don&#8217;t specify &#8220;json&#8221; as the response type, and use the included JSON parser to do the dirty job. You need to set the dependency first:</p>
<pre class="brush: php; title: ;">
// embed the javascript file that makes the AJAX request
// don't forget to specify 'json2' as the dependency
wp_enqueue_script( 'my-ajax-request', plugin_dir_url( __FILE__ ) . 'js/ajax.js', array( 'jquery', 'json2' ) );
</pre>
<p>Then use JSON parser to parse the response string:</p>
<pre class="brush: jscript; title: ;">
jQuery.post( MyAjax.ajaxurl, { action : 'myajax-submit' },
	function( jsonString ) {
		// use JSON parser on the response string instead of
		// specifying the response type as json
		var object = JSON.parse(jsonString);
	}
);
</pre>
<h3>Conclusion</h3>
<p>AJAX makes interaction with users more smooth and responsive, and is highly recommended for consideration when you develop your own plugins or themes. However, it&#8217;s vital that AJAX is implemented correctly and securely, otherwise the consequence could be disastrous. This article covers 5 most essential tips that all serious WordPress developers should employ to make sure their AJAX plugins or themes function well and safe.</p>
<p>Do you have other AJAX tips or tricks that you want to share? Drop in a comment below. Your input is always appreciated!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-bg-">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=5+tips+for+using+AJAX+in+WordPress&amp;link=http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/&amp;notes=AJAX%20is%20used%20in%20many%20WordPress%20themes%20and%20plugins.%20However%2C%20not%20all%20of%20those%20themes%20and%20plugins%20implement%20AJAX%20properly.%20This%20article%20reveals%205%20best%20practices%20in%20developing%20AJAX%20for%20WordPress.%0D%0A%0D%0AWarning%3A%20This%20is%20a%20long%20and%20information-packed%20article.%20Be%20sure%20to%20bookmark%20this%20post%20so%20you%20can%20always%20go%20back%20for%20reference%21%20&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designbump">
			<a href="http://www.shareaholic.com/api/share/?title=5+tips+for+using+AJAX+in+WordPress&amp;link=http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/&amp;notes=AJAX%20is%20used%20in%20many%20WordPress%20themes%20and%20plugins.%20However%2C%20not%20all%20of%20those%20themes%20and%20plugins%20implement%20AJAX%20properly.%20This%20article%20reveals%205%20best%20practices%20in%20developing%20AJAX%20for%20WordPress.%0D%0A%0D%0AWarning%3A%20This%20is%20a%20long%20and%20information-packed%20article.%20Be%20sure%20to%20bookmark%20this%20post%20so%20you%20can%20always%20go%20back%20for%20reference%21%20&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=282&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Bump this on DesignBump">Bump this on DesignBump</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.shareaholic.com/api/share/?title=5+tips+for+using+AJAX+in+WordPress&amp;link=http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/&amp;notes=AJAX%20is%20used%20in%20many%20WordPress%20themes%20and%20plugins.%20However%2C%20not%20all%20of%20those%20themes%20and%20plugins%20implement%20AJAX%20properly.%20This%20article%20reveals%205%20best%20practices%20in%20developing%20AJAX%20for%20WordPress.%0D%0A%0D%0AWarning%3A%20This%20is%20a%20long%20and%20information-packed%20article.%20Be%20sure%20to%20bookmark%20this%20post%20so%20you%20can%20always%20go%20back%20for%20reference%21%20&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=106&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.shareaholic.com/api/share/?title=5+tips+for+using+AJAX+in+WordPress&amp;link=http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/&amp;notes=AJAX%20is%20used%20in%20many%20WordPress%20themes%20and%20plugins.%20However%2C%20not%20all%20of%20those%20themes%20and%20plugins%20implement%20AJAX%20properly.%20This%20article%20reveals%205%20best%20practices%20in%20developing%20AJAX%20for%20WordPress.%0D%0A%0D%0AWarning%3A%20This%20is%20a%20long%20and%20information-packed%20article.%20Be%20sure%20to%20bookmark%20this%20post%20so%20you%20can%20always%20go%20back%20for%20reference%21%20&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=102&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=5+tips+for+using+AJAX+in+WordPress&amp;link=http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/&amp;notes=AJAX%20is%20used%20in%20many%20WordPress%20themes%20and%20plugins.%20However%2C%20not%20all%20of%20those%20themes%20and%20plugins%20implement%20AJAX%20properly.%20This%20article%20reveals%205%20best%20practices%20in%20developing%20AJAX%20for%20WordPress.%0D%0A%0D%0AWarning%3A%20This%20is%20a%20long%20and%20information-packed%20article.%20Be%20sure%20to%20bookmark%20this%20post%20so%20you%20can%20always%20go%20back%20for%20reference%21%20&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.shareaholic.com/api/share/?title=5+tips+for+using+AJAX+in+WordPress&amp;link=http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/&amp;notes=AJAX%20is%20used%20in%20many%20WordPress%20themes%20and%20plugins.%20However%2C%20not%20all%20of%20those%20themes%20and%20plugins%20implement%20AJAX%20properly.%20This%20article%20reveals%205%20best%20practices%20in%20developing%20AJAX%20for%20WordPress.%0D%0A%0D%0AWarning%3A%20This%20is%20a%20long%20and%20information-packed%20article.%20Be%20sure%20to%20bookmark%20this%20post%20so%20you%20can%20always%20go%20back%20for%20reference%21%20&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=74&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=5+tips+for+using+AJAX+in+WordPress&amp;link=http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/&amp;notes=AJAX%20is%20used%20in%20many%20WordPress%20themes%20and%20plugins.%20However%2C%20not%20all%20of%20those%20themes%20and%20plugins%20implement%20AJAX%20properly.%20This%20article%20reveals%205%20best%20practices%20in%20developing%20AJAX%20for%20WordPress.%0D%0A%0D%0AWarning%3A%20This%20is%20a%20long%20and%20information-packed%20article.%20Be%20sure%20to%20bookmark%20this%20post%20so%20you%20can%20always%20go%20back%20for%20reference%21%20&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-scriptstyle">
			<a href="http://www.shareaholic.com/api/share/?title=5+tips+for+using+AJAX+in+WordPress&amp;link=http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/&amp;notes=AJAX%20is%20used%20in%20many%20WordPress%20themes%20and%20plugins.%20However%2C%20not%20all%20of%20those%20themes%20and%20plugins%20implement%20AJAX%20properly.%20This%20article%20reveals%205%20best%20practices%20in%20developing%20AJAX%20for%20WordPress.%0D%0A%0D%0AWarning%3A%20This%20is%20a%20long%20and%20information-packed%20article.%20Be%20sure%20to%20bookmark%20this%20post%20so%20you%20can%20always%20go%20back%20for%20reference%21%20&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=278&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Submit this to Script &amp; Style">Submit this to Script &amp; Style</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/wphardcore?a=yssRJhwperk:sPtJU-ytNb4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=yssRJhwperk:sPtJU-ytNb4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=yssRJhwperk:sPtJU-ytNb4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=yssRJhwperk:sPtJU-ytNb4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=yssRJhwperk:sPtJU-ytNb4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=yssRJhwperk:sPtJU-ytNb4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=yssRJhwperk:sPtJU-ytNb4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/wphardcore?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=yssRJhwperk:sPtJU-ytNb4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=yssRJhwperk:sPtJU-ytNb4:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/wphardcore/~4/yssRJhwperk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/feed/</wfw:commentRss>
		<slash:comments>78</slash:comments>
		<feedburner:origLink>http://www.wphardcore.com/2010/5-tips-for-using-ajax-in-wordpress/</feedburner:origLink></item>
		<item>
		<title>Make Shortcodes User-Friendly</title>
		<link>http://feedproxy.google.com/~r/wphardcore/~3/8iTdq39W1bU/</link>
		<comments>http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 19:37:14 +0000</pubDate>
		<dc:creator>Gary Cao</dc:creator>
				<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.wphardcore.com/wordpress/?p=12</guid>
		<description><![CDATA[Since WordPress 2.5, Shortcode has proven to be one of the most powerful features that allows lots of room for flexibility and customization. However, as anything that has the word "code" in it, shortcodes are not very user friendly. For people who are used to using <abbr title="What You See Is What You Get">WYSIWYG</abbr>, shortcode usage can be confusing sometimes. This article shows you how to make shortcodes in your themes and plugins more accessible and user friendly.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.wphardcore.com%2F2010%2Fhow-to-make-shortcodes-user-friendly%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.wphardcore.com%2F2010%2Fhow-to-make-shortcodes-user-friendly%2F&amp;source=wphardcore&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Since WordPress 2.5, Shortcode has proven to be one of the most powerful features that allows lots of room for flexibility and customization. However, as anything that has the word &#8220;code&#8221; in it, shortcodes are not very user friendly. For people who are used to using <abbr title="What You See Is What You Get">WYSIWYG</abbr>, shortcode usage can be confusing sometimes. This article shows you how to make shortcodes in your themes and plugins more accessible and user friendly.</p>
<p><span id="more-12"></span></p>
<h3>Usability Problems</h3>
<p>Take the <a href="http://codex.wordpress.org/Gallery_Shortcode"><code>gallery</code></a> shortcode for instance. It allows users to include a WordPress gallery in a post or page. Here&#8217;s its simplest form:</p>
<pre class="brush: plain; title: ;">
[ gallery ]
</pre>
<p>But if the user wants to set more advanced options, such as the number of columns, or the thumbnail size, they&#8217;ll have to type in some attributes, which look similar to HTML attributes</p>
<pre class="brush: plain; title: ;">
[ gallery columns=&amp;quot;4&amp;quot; size=&amp;quot;medium&amp;quot; ]
</pre>
<p>This is not user friendly, because of the following three reasons:</p>
<ol>
<li>To customize a shortcode, most of the time you have to look at the documentation. It&#8217;s hard to memorize all the available attributes and values.</li>
<li>Not all users are familiar with HTML syntax, as a result they might get confused about specifying attributes.</li>
<li>It&#8217;s easy to make a typo, or specify the wrong value for an attribute.</li>
</ol>
<h3>Solution</h3>
<p>Shortcode is, after all, <strong>code</strong>. And code is not user friendly. The less end-users have to &#8220;code&#8221;, the better.</p>
<p>Therefore, it&#8217;s essential that WordPress developers provide a user interface for everything that&#8217;s supposed to be customized by users. Shortcode is no exception. The best solution to deal with shortcode, is to add a button to the visual editor&#8217;s toolbar, and display a nice GUI to configure all available shortcode attributes.</p>
<p>What we&#8217;re going to do next, is create a small plugin that provides such an interface for the <code>gallery</code> shortcode.</p>
<p><strong>Note:</strong> WordPress already has an UI to customize the gallery shortcode, but it&#8217;s buried deep inside the Media Manager.</p>
<p>So, let&#8217;s start with the bare bones of a plugin file. I&#8217;ll assume that you already know how to develop your own plugin. Otherwise, <a href="http://codex.wordpress.org/Writing_a_Plugin">here&#8217;s your bible</a>.</p>
<p>I prefer the Object Oriented approach, so here&#8217;s what I&#8217;ve got:</p>
<pre class="brush: php; title: ;">
/*
Plugin Name: mygallery
Plugin URI: http://wphardcore.com
Description: A simple user interface for Gallery shortcode
Version: 0.1
Author: Gary Cao
Author URI: http://garyc40.com
*/

if ( ! defined( 'ABSPATH' ) )
	die( &amp;quot;Can't load this file directly&amp;quot; );

class MyGallery
{
	function __construct() {
	}

}

$mygallery = new MyGallery();
</pre>
<p>Now, there are two <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference">WordPress filters</a> that we&#8217;ll be using to add a button to the visual editor&#8217;s toolbar.</p>
<ul>
<li><a href="http://adambrown.info/p/wp_hooks/hook/mce_external_plugins"><code>mce_external_plugins</code></a>: registers our javascript file that implements our button.</li>
<li><a href="http://adambrown.info/p/wp_hooks/hook/mce_buttons"><code>mce_buttons</code></a>: registers our button.</li>
</ul>
<p>Go back to your WordPress admin panel, activate your plugin and hook our plugin up with these filters:</p>
<pre class="brush: php; title: ;">
function __construct() {
	add_action( 'admin_init', array( $this, 'action_admin_init' ) );
}

function action_admin_init() {
	// only hook up these filters if we're in the admin panel, and the current user has permission
	// to edit posts and pages
	if ( current_user_can( 'edit_posts' ) &amp;amp;&amp;amp; current_user_can( 'edit_pages' ) ) {
		add_filter( 'mce_buttons', array( $this, 'filter_mce_button' ) );
		add_filter( 'mce_external_plugins', array( $this, 'filter_mce_plugin' ) );
	}
}

function filter_mce_button( $buttons ) {
	// add a separation before our button, here our button's id is &amp;quot;mygallery_button&amp;quot;
	array_push( $buttons, '|', 'mygallery_button' );
	return $buttons;
}

function filter_mce_plugin( $plugins ) {
	// this plugin file will work the magic of our button
	$plugins['mygallery'] = plugin_dir_url( __FILE__ ) . 'mygallery_plugin.js';
	return $plugins;
}
</pre>
<p>Here&#8217;s the hard part. Create a new javascript file in the same folder as your plugin file, and name it <code>mygallery_plugin.js</code>.</p>
<pre class="brush: jscript; title: ;">
// closure to avoid namespace collision
(function(){
	// creates the plugin
	tinymce.create('tinymce.plugins.mygallery', {
		// creates control instances based on the control's id.
		// our button's id is &amp;quot;mygallery_button&amp;quot;
		createControl : function(id, controlManager) {
			if (id == 'mygallery_button') {
				// creates the button
				var button = controlManager.createButton('mygallery_button', {
					title : 'MyGallery Shortcode', // title of the button
					image : '../wp-includes/images/smilies/icon_mrgreen.gif',  // path to the button's image
					onclick : function() {
						// do something when the button is clicked :)
					}
				});
				return button;
			}
			return null;
		}
	});

	// registers the plugin. DON'T MISS THIS STEP!!!
	tinymce.PluginManager.add('mygallery', tinymce.plugins.mygallery);
})()
</pre>
<p>We&#8217;re using <a href="http://wiki.moxiecode.com/index.php/TinyMCE:API">tinyMCE&#8217;s API</a> to register our editor plugin, and create the button. If you don&#8217;t understand what the hell happened above, just close your eyes, and forget about it for a minute (seriously), then proceed with our next step. You can always come back and dig into <a href="http://wiki.moxiecode.com/index.php/TinyMCE:API">tinyMCE&#8217;s documentation</a> to get a grasp of what the snippet above means.</p>
<p>Now go to your WordPress admin panel, edit or create a new post (or page). You&#8217;ll see our tiny little button in the toolbar, preceded by a separator:</p>
<p><a href="http://www.wphardcore.com/wordpress/wp-content/uploads/2010/03/2.jpg"><img src="http://www.wphardcore.com/wordpress/wp-content/uploads/2010/03/2.jpg" alt="" title="1" class="alignnone size-full wp-image-13" /></a></p>
<p>If you click the button, nothing happens because you haven&#8217;t written any code that handles that part yet. If I cover that part in this article too, it&#8217;s going to be too long. So <a href="http://www.wphardcore.com/wordpress/wp-content/uploads/2010/03/mygallery.zip">Download the Sourcecode</a> and take a look for yourself. The code is abundant with documentation, but if you have any questions, shoot me a comment!</p>
<p>Here&#8217;s a screenshot of the final results:</p>
<p><a href="http://www.wphardcore.com/wordpress/wp-content/uploads/2010/03/3.jpg"><img src="http://www.wphardcore.com/wordpress/wp-content/uploads/2010/03/3.jpg" alt="" title="3" width="557" height="465" class="alignnone size-full wp-image-15" /></a></p>
<p><a class="download" href="http://www.wphardcore.com/wordpress/wp-content/uploads/2010/03/mygallery.zip">mygallery.zip</a></p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-bg-">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Make+Shortcodes+User-Friendly&amp;link=http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/&amp;notes=Since%20WordPress%202.5%2C%20Shortcode%20has%20proven%20to%20be%20one%20of%20the%20most%20powerful%20features%20that%20allows%20lots%20of%20room%20for%20flexibility%20and%20customization.%20However%2C%20as%20anything%20that%20has%20the%20word%20%22code%22%20in%20it%2C%20shortcodes%20are%20not%20very%20user%20friendly.%20For%20people%20who%20are%20used%20to%20using%20WYSIWYG%2C%20shortcode%20usage%20can%20be%20confusing%20sometimes.%20This%20article%20shows%20you%20how%20to%20make%20shortcodes%20in%20your%20themes%20and%20plugins%20more%20accessible%20and%20user%20friendly.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-designbump">
			<a href="http://www.shareaholic.com/api/share/?title=Make+Shortcodes+User-Friendly&amp;link=http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/&amp;notes=Since%20WordPress%202.5%2C%20Shortcode%20has%20proven%20to%20be%20one%20of%20the%20most%20powerful%20features%20that%20allows%20lots%20of%20room%20for%20flexibility%20and%20customization.%20However%2C%20as%20anything%20that%20has%20the%20word%20%22code%22%20in%20it%2C%20shortcodes%20are%20not%20very%20user%20friendly.%20For%20people%20who%20are%20used%20to%20using%20WYSIWYG%2C%20shortcode%20usage%20can%20be%20confusing%20sometimes.%20This%20article%20shows%20you%20how%20to%20make%20shortcodes%20in%20your%20themes%20and%20plugins%20more%20accessible%20and%20user%20friendly.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=282&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Bump this on DesignBump">Bump this on DesignBump</a>
		</li>
		<li class="shr-designfloat">
			<a href="http://www.shareaholic.com/api/share/?title=Make+Shortcodes+User-Friendly&amp;link=http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/&amp;notes=Since%20WordPress%202.5%2C%20Shortcode%20has%20proven%20to%20be%20one%20of%20the%20most%20powerful%20features%20that%20allows%20lots%20of%20room%20for%20flexibility%20and%20customization.%20However%2C%20as%20anything%20that%20has%20the%20word%20%22code%22%20in%20it%2C%20shortcodes%20are%20not%20very%20user%20friendly.%20For%20people%20who%20are%20used%20to%20using%20WYSIWYG%2C%20shortcode%20usage%20can%20be%20confusing%20sometimes.%20This%20article%20shows%20you%20how%20to%20make%20shortcodes%20in%20your%20themes%20and%20plugins%20more%20accessible%20and%20user%20friendly.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=106&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Submit this to DesignFloat">Submit this to DesignFloat</a>
		</li>
		<li class="shr-dzone">
			<a href="http://www.shareaholic.com/api/share/?title=Make+Shortcodes+User-Friendly&amp;link=http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/&amp;notes=Since%20WordPress%202.5%2C%20Shortcode%20has%20proven%20to%20be%20one%20of%20the%20most%20powerful%20features%20that%20allows%20lots%20of%20room%20for%20flexibility%20and%20customization.%20However%2C%20as%20anything%20that%20has%20the%20word%20%22code%22%20in%20it%2C%20shortcodes%20are%20not%20very%20user%20friendly.%20For%20people%20who%20are%20used%20to%20using%20WYSIWYG%2C%20shortcode%20usage%20can%20be%20confusing%20sometimes.%20This%20article%20shows%20you%20how%20to%20make%20shortcodes%20in%20your%20themes%20and%20plugins%20more%20accessible%20and%20user%20friendly.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=102&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Make+Shortcodes+User-Friendly&amp;link=http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/&amp;notes=Since%20WordPress%202.5%2C%20Shortcode%20has%20proven%20to%20be%20one%20of%20the%20most%20powerful%20features%20that%20allows%20lots%20of%20room%20for%20flexibility%20and%20customization.%20However%2C%20as%20anything%20that%20has%20the%20word%20%22code%22%20in%20it%2C%20shortcodes%20are%20not%20very%20user%20friendly.%20For%20people%20who%20are%20used%20to%20using%20WYSIWYG%2C%20shortcode%20usage%20can%20be%20confusing%20sometimes.%20This%20article%20shows%20you%20how%20to%20make%20shortcodes%20in%20your%20themes%20and%20plugins%20more%20accessible%20and%20user%20friendly.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.shareaholic.com/api/share/?title=Make+Shortcodes+User-Friendly&amp;link=http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/&amp;notes=Since%20WordPress%202.5%2C%20Shortcode%20has%20proven%20to%20be%20one%20of%20the%20most%20powerful%20features%20that%20allows%20lots%20of%20room%20for%20flexibility%20and%20customization.%20However%2C%20as%20anything%20that%20has%20the%20word%20%22code%22%20in%20it%2C%20shortcodes%20are%20not%20very%20user%20friendly.%20For%20people%20who%20are%20used%20to%20using%20WYSIWYG%2C%20shortcode%20usage%20can%20be%20confusing%20sometimes.%20This%20article%20shows%20you%20how%20to%20make%20shortcodes%20in%20your%20themes%20and%20plugins%20more%20accessible%20and%20user%20friendly.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=74&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-reddit">
			<a href="http://www.shareaholic.com/api/share/?title=Make+Shortcodes+User-Friendly&amp;link=http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/&amp;notes=Since%20WordPress%202.5%2C%20Shortcode%20has%20proven%20to%20be%20one%20of%20the%20most%20powerful%20features%20that%20allows%20lots%20of%20room%20for%20flexibility%20and%20customization.%20However%2C%20as%20anything%20that%20has%20the%20word%20%22code%22%20in%20it%2C%20shortcodes%20are%20not%20very%20user%20friendly.%20For%20people%20who%20are%20used%20to%20using%20WYSIWYG%2C%20shortcode%20usage%20can%20be%20confusing%20sometimes.%20This%20article%20shows%20you%20how%20to%20make%20shortcodes%20in%20your%20themes%20and%20plugins%20more%20accessible%20and%20user%20friendly.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=40&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-scriptstyle">
			<a href="http://www.shareaholic.com/api/share/?title=Make+Shortcodes+User-Friendly&amp;link=http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/&amp;notes=Since%20WordPress%202.5%2C%20Shortcode%20has%20proven%20to%20be%20one%20of%20the%20most%20powerful%20features%20that%20allows%20lots%20of%20room%20for%20flexibility%20and%20customization.%20However%2C%20as%20anything%20that%20has%20the%20word%20%22code%22%20in%20it%2C%20shortcodes%20are%20not%20very%20user%20friendly.%20For%20people%20who%20are%20used%20to%20using%20WYSIWYG%2C%20shortcode%20usage%20can%20be%20confusing%20sometimes.%20This%20article%20shows%20you%20how%20to%20make%20shortcodes%20in%20your%20themes%20and%20plugins%20more%20accessible%20and%20user%20friendly.&amp;short_link=&amp;shortener=supr&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=278&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Submit this to Script &amp; Style">Submit this to Script &amp; Style</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/wphardcore?a=8iTdq39W1bU:jl1RyRwmYvo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=8iTdq39W1bU:jl1RyRwmYvo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=8iTdq39W1bU:jl1RyRwmYvo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=8iTdq39W1bU:jl1RyRwmYvo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=8iTdq39W1bU:jl1RyRwmYvo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=8iTdq39W1bU:jl1RyRwmYvo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=8iTdq39W1bU:jl1RyRwmYvo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/wphardcore?d=qj6IDK7rITs" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/wphardcore?a=8iTdq39W1bU:jl1RyRwmYvo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/wphardcore?i=8iTdq39W1bU:jl1RyRwmYvo:gIN9vFwOqvQ" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/wphardcore/~4/8iTdq39W1bU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		<feedburner:origLink>http://www.wphardcore.com/2010/how-to-make-shortcodes-user-friendly/</feedburner:origLink></item>
	</channel>
</rss>

