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

<channel>
	<title>Re-Cycled Air &#187; programming</title>
	<atom:link href="http://www.re-cycledair.com/tag/programming/feed" rel="self" type="application/rss+xml" />
	<link>http://www.re-cycledair.com</link>
	<description>Wordpress and PHP Tutorials</description>
	<lastBuildDate>Thu, 09 Sep 2010 01:44:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How To Create and Code WordPress Widgets</title>
		<link>http://www.re-cycledair.com/create-and-code-wordpress-widgets</link>
		<comments>http://www.re-cycledair.com/create-and-code-wordpress-widgets#comments</comments>
		<pubDate>Sat, 28 Aug 2010 00:49:23 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[widgets]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=630</guid>
		<description><![CDATA[Note:  The full source code for this plugin can be found here. Every time you go to WordPress blog and see items in the sidebar, it&#8217;s likely that they are widgets.  There are thousands of them for download on WordPress.org, but what if you want to create your own?  How would you code it? That&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<div>
<p><em>Note:  The full source code for this plugin can be found <a href="../wp-content/uploads/2010/08/sweet_math_widget.zip">here.</a></em></p>
<p>Every time you go to WordPress blog and see items in the sidebar, it&#8217;s likely that they are widgets.  There are thousands of them for download on WordPress.org, but what if you want to create your own?  How would you code it? That&#8217;s what I will answer in this quick How-To.</p>
</div>
<div>
<h3><strong>Step 1:  Create The Plugin</strong></h3>
<p><strong> </strong>We&#8217;re going to start out by creating a simple plugin.  It&#8217;s only purpose is to initialize our widget.</p>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">/*
Plugin Name<span class="phpOperator">:</span> Sweet Math Widget
Plugin URI<span class="phpOperator">:</span><span class="htmlText"> http</span><span class="phpOperator">:</span><span class="phpComment">//www<span class="phpOperator">.</span>re-cycledair.com
</span><span class="htmlText">Description</span><span class="phpOperator">:</span><span class="htmlText"> A math widget that takes the post id and multiplies it by </span><span class="phpNumber">5</span><span class="phpOperator">.</span>
<span class="htmlText">
Author</span><span class="phpOperator">:</span> Jack Slingerland
Version<span class="phpOperator">:</span> <span class="phpNumber">0</span><span class="phpOperator">.</span><span class="phpNumber">1</span>
<span class="htmlText">
Author URI</span><span class="phpOperator">:</span><span class="htmlText"> http</span><span class="phpOperator">:</span><span class="phpComment">//www<span class="phpOperator">.</span>re-cycledair.com
</span>*/</span>
<span class="phpFunctionKeyword">function</span><span class="htmlText"> sweetMathWidget</span><span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
global </span>$post;
<span class="phpFunction">echo</span> <span class="phpString">"<span class="phpOperator">{</span>$post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span><span class="htmlText">ID</span><span class="phpOperator">}</span><span class="htmlText"> x </span><span class="phpNumber">5</span> <span class="phpOperator">=</span> "</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> $post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>ID*<span class="phpNumber">5</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<h3><strong>Step 2:  Add &amp; Register the Widget</strong></h3>
<p>The nex step is the add the widget to WordPress and then register it.  Add this code to the plugin that you already have going.</p>
<pre class="php">
<span class="phpFunctionKeyword">function</span> sweetMathWidgetInit<span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
register_sidebar_widget<span class="phpOperator">(</span>__<span class="phpOperator">(</span><span class="phpString">'Sweet Math Widget'</span><span class="phpOperator">)</span>, <span class="phpString">'sweetMathWidget'</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
add_action<span class="phpOperator">(</span><span class="phpString">"plugins_loaded"</span>, <span class="phpString">"sweetMathWidgetInit"</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<h3><strong>Step 3:  Add Theme Compatibility</strong></h3>
<p>You want everyone you use your plugin right?  Well if it isn&#8217;t compatible with any themes nobody is going to use it.  To add theme compatibility we need to modify the first function we wrote to look like this.</p>
<pre class="php">
<span class="phpFunctionKeyword">function</span> sweetMathWidget<span class="phpOperator">(</span>$args<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
global </span>$post;
<span class="phpFunction">extract</span><span class="phpOperator">(</span>$args<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> $before_widget;
<span class="phpFunction">echo</span> $before_title<span class="phpText">;</span>
<span class="phpFunction">echo</span> <span class="phpString">"<span class="phpOperator">&lt;</span>h2<span class="phpOperator">&gt;</span> Sweet Math Widget <span class="phpOperator">&lt;</span>/h2<span class="phpOperator">&gt;</span>"</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> $after_title<span class="phpText">;</span>
<span class="phpFunction">echo</span> <span class="phpString">"<span class="phpOperator">{</span>$post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>ID<span class="phpOperator">}</span> x <span class="phpNumber">5</span> <span class="phpOperator">=</span> "</span><span class="phpText">;</span><span class="phpFunction">echo</span> $post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>ID*<span class="phpNumber">5</span><span class="phpText">;</span>
<span class="phpFunction">echo</span> $after_widget;
<span class="phpOperator">}</span>
</pre>
<h3><strong>Step 4:  Upload &amp; Add The Widget</strong></h3>
<p>Now that you&#8217;re done, save the file as sweet_math_widget.php and then zip the file using WinZip (or a similar tool).  Upload the plugin to your WordPress install and then activate.  If everything goes well, you&#8217;ll have a new widget in you Appearance -&gt; Widgets area.</p>
<p><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/math_widget_picture.jpg" rel="lightbox[630]"><img class="aligncenter size-full wp-image-634" title="Sweet Math Widget" src="http://www.re-cycledair.com/wp-content/uploads/2010/08/math_widget_picture.jpg" alt="How to Create / Code A WordPress Widget" width="489" height="248" /></a></p>
<p>Drag &#8220;Sweet Math Widget into your sidebar and you&#8217;re done.  Go to a post on your blog and you should see something like this.</p>
<p><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/final_product.jpg" rel="lightbox[630]"><img class="aligncenter size-full wp-image-636" title="Final Product" src="http://www.re-cycledair.com/wp-content/uploads/2010/08/final_product.jpg" alt="How to Create / Code a WordPress Widget Final Product" width="298" height="117" /></a></p>
<p>You can download the full source code for this widget <a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/sweet_math_widget.zip">here.</a></p>
</div>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/create-and-code-wordpress-widgets/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/create-and-code-wordpress-widgets&amp;title=How+To+Create+and+Code+Wordpress+Widgets" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/create-and-code-wordpress-widgets&amp;title=How+To+Create+and+Code+Wordpress+Widgets" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/create-and-code-wordpress-widgets&amp;title=How+To+Create+and+Code+Wordpress+Widgets&amp;desc=%0D%0A%0D%0ANote%3A%C2%A0%20The%20full%20source%20code%20for%20this%20plugin%20can%20be%20found%20here.%0D%0A%0D%0AEvery%20time%20you%20go%20to%20Wordpress%20blog%20and%20see%20items%20in%20the%20sidebar%2C%20it%27s%20likely%20that%20they%20are%20widgets.%20%C2%A0There%20are%20thousands%20of%20them%20for%20download%20on%20Wordpress.org%2C%20but%20what%20if%20you%20want%20to%20create%20your%20own%3F%20%C2%A0How%20would%20you%20code%20it%3F%20T" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/create-and-code-wordpress-widgets&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/create-and-code-wordpress-widgets&amp;bm_description=How+To+Create+and+Code+Wordpress+Widgets&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/create-and-code-wordpress-widgets&amp;title=How+To+Create+and+Code+Wordpress+Widgets" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/create-and-code-wordpress-widgets&amp;title=How+To+Create+and+Code+Wordpress+Widgets" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/create-and-code-wordpress-widgets&amp;title=How+To+Create+and+Code+Wordpress+Widgets" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/create-and-code-wordpress-widgets" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+To+Create+and+Code+Wordpress+Widgets+-+http://b2l.me/aqd4gz&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/create-and-code-wordpress-widgets/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Enable Post Thumbnails In WordPress</title>
		<link>http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress</link>
		<comments>http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress#comments</comments>
		<pubDate>Thu, 26 Aug 2010 23:00:52 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=615</guid>
		<description><![CDATA[Since version 2.9 of WordPress, it&#8217;s been possible to have post thumbnails.  Once these thumbnails have been set, they can be used throughout your site whenever your post is called.  Using post thumbnails is easy, and so is enabling them.  It&#8217;s only a few steps, so let&#8217;s get started. Enable The first step to using [...]]]></description>
			<content:encoded><![CDATA[<p>Since version 2.9 of WordPress, it&#8217;s been possible to have post thumbnails.  Once these thumbnails have been set, they can be used throughout your site whenever your post is called.  Using post thumbnails is easy, and so is enabling them.  It&#8217;s only a few steps, so let&#8217;s get started.</p>
<h2>Enable</h2>
<p>The first step to using post thumbnails in WordPress is to enable them.  To do that, all you need to do is put the following in you themes <em>functions.php</em> file.</p>
<pre class="php">add_theme_support<span class="phpOperator">(</span><span class="phpString">'post-thumbnails'</span><span class="phpOperator">)</span><span class="phpText">;</span></pre>
<p>Once you&#8217;ve added this code, you should see a box underneath &#8220;Post Tags&#8221; in the Edit Post screen.</p>
<h2><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/featured_images.jpg" rel="lightbox[615]"><img class="aligncenter size-full wp-image-617" title="Post Thumbnail Box" src="http://www.re-cycledair.com/wp-content/uploads/2010/08/featured_images.jpg" alt="Post Thumbnail Box" width="295" height="74" /></a></h2>
<h2>Set the Post Thumbnail</h2>
<p>Now that you have the featured image box in you WordPress Edit Post area, you need to click the &#8220;Set featured image&#8221; link.  Once you do that, you&#8217;ll be greeted with the usual WordPress image upload screen.  Select the image you would like to upload, and then let WordPress do it&#8217;s image crunching magic.  Now comes the most important part, you need need to click &#8220;Use as featured image&#8221;.</p>
<p><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/use_featured_image.jpg" rel="lightbox[615]"><img class="aligncenter size-full wp-image-619" title="Use Post Thumbnail" src="http://www.re-cycledair.com/wp-content/uploads/2010/08/use_featured_image.jpg" alt="Use Post Thumbnail" width="492" height="342" /><br />
</a>Once you&#8217;ve done that, you&#8217;ll get a thumbnail version of the photo you just uploaded in the lower-right hand corner of you Edit Posts screen.</p>
<h2><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/thumbnail_set.jpg" rel="lightbox[615]"><img class="aligncenter size-full wp-image-620" title="Post Thumbnail Set" src="http://www.re-cycledair.com/wp-content/uploads/2010/08/thumbnail_set.jpg" alt="Post Thumbnail Set" width="300" height="276" /></a></h2>
<h2><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/thumbnail_set.jpg" rel="lightbox[615]"></a>Using Post Thumbnails in Your Theme</h2>
<p>Obviously post thumbnails aren&#8217;t much use to you if nobody can see them.  To see them in your theme, you need to call the following function while inside The Loop.</p>
<pre class="php"> <span class="htmlOtherTag">&lt;? the_post_thumbnail(); ?&gt;</span> </pre>
<p>That&#8217;s it!  It&#8217;s now easier than ever you have each one of your posts have a thumbnail.  If you have any questions, please leave them in the comments.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress&amp;title=How+To+Enable+Post+Thumbnails+In+Wordpress" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress&amp;title=How+To+Enable+Post+Thumbnails+In+Wordpress" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress&amp;title=How+To+Enable+Post+Thumbnails+In+Wordpress&amp;desc=Since%20version%202.9%20of%20Wordpress%2C%20it%27s%20been%20possible%20to%20have%20post%20thumbnails.%C2%A0%20Once%20these%20thumbnails%20have%20been%20set%2C%20they%20can%20be%20used%20throughout%20your%20site%20whenever%20your%20post%20is%20called.%C2%A0%20Using%20post%20thumbnails%20is%20easy%2C%20and%20so%20is%20enabling%20them.%C2%A0%20It%27s%20only%20a%20few%20steps%2C%20so%20let%27s%20get%20started.%0D%0AEnable%0D%0AThe" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress&amp;bm_description=How+To+Enable+Post+Thumbnails+In+Wordpress&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress&amp;title=How+To+Enable+Post+Thumbnails+In+Wordpress" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress&amp;title=How+To+Enable+Post+Thumbnails+In+Wordpress" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress&amp;title=How+To+Enable+Post+Thumbnails+In+Wordpress" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+To+Enable+Post+Thumbnails+In+Wordpress+-+http://b2l.me/aqd4g2&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/how-to-enable-post-thumbnails-in-wordpress/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Shortcode Tutorial</title>
		<link>http://www.re-cycledair.com/wordpress-shortcode</link>
		<comments>http://www.re-cycledair.com/wordpress-shortcode#comments</comments>
		<pubDate>Thu, 26 Aug 2010 00:00:12 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[shortcode]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=600</guid>
		<description><![CDATA[Note:  This tutorial is out of date.  Please refer to the WordPress Shortcode API for more information. One neat feature of WordPress plugins is shortcode.  Shortcode enables a user to put something like &#8220;[myplugin]&#8221; in their posts or pages and have it display content from their plugin.  Making WordPress shortcode work for you isn&#8217;t terribly [...]]]></description>
			<content:encoded><![CDATA[<p><em><strong>Note:  This tutorial is out of date.  Please refer to the <a href="http://codex.wordpress.org/Shortcode_API">WordPress Shortcode API</a> for more information.</strong></em></p>
<p>One neat feature of WordPress plugins is shortcode.  Shortcode enables a user to put something like &#8220;[myplugin]&#8221; in their posts or pages and have it display content from their plugin.  Making WordPress shortcode work for you isn&#8217;t terribly difficult, but without some help it can be confusing.  In this tutorial, I&#8217;ll show you how to use shortcode in your plugins.</p>
<pre class="php">
<span class="phpFunctionKeyword">function</span> content_myshortcode<span class="phpOperator">(</span>$content<span class="phpOperator">)</span>
<span class="phpOperator">{</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span><span class="phpFunction">preg_match</span><span class="phpOperator">(</span><span class="phpString">'/<span class="phpOperator">&lt;</span><span class="phpOperator">!</span>--myshortcode<span class="phpOperator">[</span>\<span class="phpOperator">(</span><span class="phpOperator">]</span>*<span class="phpOperator">(</span>.*<span class="phpOperator">?</span><span class="phpOperator">)</span><span class="phpOperator">[</span>\<span class="phpOperator">)</span><span class="phpOperator">]</span>*-<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>/'</span>,$content,$matches<span class="phpOperator">)</span><span class="phpOperator">)</span>
<span class="phpOperator">{</span>
$parameter1 <span class="phpOperator">=</span> $matches<span class="phpOperator">[</span><span class="phpNumber">1</span><span class="phpOperator">]</span><span class="phpText">;</span>
$content <span class="phpOperator">=</span> <span class="phpFunction">preg_replace</span><span class="phpOperator">(</span><span class="phpString">'/<span class="phpOperator">&lt;</span><span class="phpOperator">!</span>--myshortcode<span class="phpOperator">(</span>.*<span class="phpOperator">?</span><span class="phpOperator">)</span>-<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>/'</span>,myshortcode<span class="phpKeyword"><span class="phpOperator">(</span>false,</span>$parameter1<span class="phpOperator">)</span>, $content<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpKeyword">
return </span>$content;
<span class="phpOperator">}</span>
</pre>
<p>Now what does this do?  This function will go through the content of your post/page, and look for the &lt;!&#8211;myshortcode&#8211;&gt; shortcode.  If it finds it, it will then call the &#8220;myshortcode()&#8221; function in your plugin and put it&#8217;s content there.  Now, this doesn&#8217;t happen automatically.  As with most WordPress development, we need to add a filter.</p>
<pre class="php">
add_filter<span class="phpOperator">(</span><span class="phpString">'the_content'</span>, <span class="phpString">'content_myshortcode'</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/wordpress-shortcode/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/wordpress-shortcode&amp;title=Wordpress+Shortcode+Tutorial" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/wordpress-shortcode&amp;title=Wordpress+Shortcode+Tutorial" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/wordpress-shortcode&amp;title=Wordpress+Shortcode+Tutorial&amp;desc=Note%3A%C2%A0%20This%20tutorial%20is%20out%20of%20date.%C2%A0%20Please%20refer%20to%20the%20Wordpress%20Shortcode%20API%20for%20more%20information.%0D%0A%0D%0AOne%20neat%20feature%20of%20Wordpress%20plugins%20is%20shortcode.%C2%A0%20Shortcode%20enables%20a%20user%20to%20put%20something%20like%20%22%5Bmyplugin%5D%22%20in%20their%20posts%20or%20pages%20and%20have%20it%20display%20content%20from%20their%20plugin.%C2%A0%20Maki" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/wordpress-shortcode&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/wordpress-shortcode&amp;bm_description=Wordpress+Shortcode+Tutorial&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/wordpress-shortcode&amp;title=Wordpress+Shortcode+Tutorial" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/wordpress-shortcode&amp;title=Wordpress+Shortcode+Tutorial" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/wordpress-shortcode&amp;title=Wordpress+Shortcode+Tutorial" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/wordpress-shortcode" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Wordpress+Shortcode+Tutorial+-+http://b2l.me/aqgbhd&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/wordpress-shortcode/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Database Query Using The WPDB Class</title>
		<link>http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class</link>
		<comments>http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class#comments</comments>
		<pubDate>Tue, 24 Aug 2010 23:29:07 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[wpdb]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=576</guid>
		<description><![CDATA[As a plugin developer or WordPress hacker, accessing the database used by a WordPress install is vital.  This can be accomplished through a few different means, but the best is by using the WPDB class that is provided.  The only requirement for using this class is that your code exists within the WordPress install (plugins, [...]]]></description>
			<content:encoded><![CDATA[<p>As a plugin developer or WordPress hacker, accessing the database used by a WordPress install is vital.  This can be accomplished through a few different means, but the best is by using the WPDB class that is provided.  The only requirement for using this class is that your code exists within the WordPress install (plugins, themes, etc).</p>
<p><strong>WPDB Queries</strong></p>
<p>Let&#8217;s say that you would like to run a simple query that returns all of the rows in the &#8220;posts&#8221; table.  With the WPDB class, all you need to do is execute:</p>
<pre class="php">$rows <span class="phpOperator">=</span> $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>get_results<span class="phpOperator">(</span> <span class="phpString">"SELECT * FROM $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>posts"</span> <span class="phpOperator">)</span><span class="phpText">;</span></pre>
<p>When this code is executed, it returns the entire table &#8220;posts&#8221; (<em>$wpdb-&gt;posts</em>) as an array of objects into the <em>$rows</em> variable.  From there, it&#8217;s easy enough to iterate over the array using a foreach loop.</p>
<p><strong>WPDB Insert</strong></p>
<p>Inserting data into a table is easy using the WPDB class.  All you need to know are the column name(s), the table name, and data you want to store.  I&#8217;ll lead with an example:</p>
<pre class="php">$wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>insert<span class="phpOperator">(</span> <span class="phpString">'links'</span>, <span class="phpFunction">array</span><span class="phpOperator">(</span> <span class="phpString">'link_url'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpString">'re-cycledair.com'</span>, <span class="phpString">'visit'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> 12 <span class="phpOperator">)</span>, <span class="phpFunction">array</span><span class="phpOperator">(</span> <span class="phpString">'%s'</span>, <span class="phpString">'%d'</span> <span class="phpOperator">)</span> <span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>This example of <em>$wpdb-&gt;insert</em>, inserts &#8220;re-cycledair.com&#8221; and &#8220;12&#8243; into the <em>link_url </em>and <em>visit</em> columns of the &#8220;links&#8221; table respectively.  The third argument in this function is one that tells the WPDB what type these values are.  The first value is a string, so we use &#8220;%s&#8221;, and the second is an integer, so we use &#8220;%d&#8221;.</p>
<p>If you would like to know the auto-incremented id of this insert, simply call:</p>
<pre class="php">$wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>insert_id</pre>
<p><strong>WPDB Update</strong></p>
<p>Updating rows in a table is also easy with the WPDB class.  Here is an example of an update.</p>
<pre class="php">$wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>update<span class="phpOperator">(</span> <span class="phpString">'links'</span>, <span class="phpFunction">array</span><span class="phpOperator">(</span> <span class="phpString">'link_url'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpString">'wordpress<span class="phpOperator">.</span>org'</span><span class="phpOperator">)</span>, <span class="phpFunction">array</span><span class="phpOperator">(</span> <span class="phpString">'ID'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> 15<span class="phpOperator">)</span>, <span class="phpFunction">array</span><span class="phpOperator">(</span> <span class="phpString">'%s'</span><span class="phpOperator">)</span>, <span class="phpFunction">array</span><span class="phpOperator">(</span> <span class="phpString">'%d'</span> <span class="phpOperator">)</span> <span class="phpOperator">)</span>
</pre>
<p>As you can see, this works a lot like <em>$wpdb-&gt;insert</em>.  The first argument is the table name.  The second argument is an array of column-value pairs.  The third argument is the where condition (if ID is equal to 15).  The fourth argument tells the WPDB class that you are updating a string, and the fifth argument says the WHERE condition is an integer.</p>
<p><strong>WPDB Prepare: Protect Against SQL Injection</strong></p>
<p>One thing every WordPress developer needs to know about is SQL injection.  SQL injection is when someone is able to modify your SQL query to execute their own.  To prevent this kind of malicious attack, the WPDB class has a method called &#8220;prepare&#8221;.  &#8220;Prepare&#8221; will take your input data an sanitize it, so that it cannot be used in a SQL injection attack.  An example is as follows:</p>
<pre class="php">$wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>query<span class="phpOperator">(</span> $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>prepare<span class="phpOperator">(</span> <span class="phpString">"
	INSERT INTO $wpdb<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>posts
	<span class="phpOperator">(</span> post_id, post_content <span class="phpOperator">)</span>
	VALUES <span class="phpOperator">(</span> %d, %s<span class="phpOperator">)</span>"</span>,
        15, <span class="phpString">"this is un&#039;safe"</span> <span class="phpOperator">)</span> <span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>As with previous examples, the &#8220;%d&#8221; and &#8220;%s&#8221; function as placeholders for the sanitized data.</p>
<p>With those functions and a little bit of work, you should be writing WordPress database queries with the WPDB class in no time!</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class&amp;title=Wordpress+Database+Query+Using+The+WPDB+Class" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class&amp;title=Wordpress+Database+Query+Using+The+WPDB+Class" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class&amp;title=Wordpress+Database+Query+Using+The+WPDB+Class&amp;desc=As%20a%20plugin%20developer%20or%20Wordpress%20hacker%2C%20accessing%20the%20database%20used%20by%20a%20Wordpress%20install%20is%20vital.%C2%A0%20This%20can%20be%20accomplished%20through%20a%20few%20different%20means%2C%20but%20the%20best%20is%20by%20using%20the%20WPDB%20class%20that%20is%20provided.%C2%A0%20The%20only%20requirement%20for%20using%20this%20class%20is%20that%20your%20code%20exists%20within%20the%20" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class&amp;bm_description=Wordpress+Database+Query+Using+The+WPDB+Class&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class&amp;title=Wordpress+Database+Query+Using+The+WPDB+Class" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class&amp;title=Wordpress+Database+Query+Using+The+WPDB+Class" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class&amp;title=Wordpress+Database+Query+Using+The+WPDB+Class" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Wordpress+Database+Query+Using+The+WPDB+Class+-+http://b2l.me/aqgh6d&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/wordpress-database-query-using-wpdb-class/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Form Ajax : How to Create and Submit a Form Using Ajax</title>
		<link>http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax</link>
		<comments>http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax#comments</comments>
		<pubDate>Thu, 19 Aug 2010 00:38:35 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[Other Programming]]></category>
		<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[form ajax]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=562</guid>
		<description><![CDATA[For the longest time, web developers were stuck submitting their forms in the normal way: Click a button, go to a processing page, redirect back.  However, now it is possible to submit a form without ever leaving the page with Ajax.  Ajax stands for Asynchronous JavaScript, which as stated before, basically means you can submit [...]]]></description>
			<content:encoded><![CDATA[<p>For the longest time, web developers were stuck submitting their forms in the normal way: Click a button, go to a processing page, redirect back.  However, now it is possible to submit a form without ever leaving the page with Ajax.  Ajax stands for Asynchronous JavaScript, which as stated before, basically means you can submit a form without ever leaving the page.</p>
<p style="text-align: center"><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/jquery.png" rel="lightbox[562]"><img class="aligncenter size-full wp-image-563" src="http://www.re-cycledair.com/wp-content/uploads/2010/08/jquery.png" alt="" width="242" height="76" /></a></p>
<p>So how do you use form Ajax? First of all, we&#8217;re going use a JavaScript library called jQuery.  Don&#8217;t be scared of it though, jQuery makes JavaScript easy.  What jQuery allows us to do is use form Ajax without having to muck around with all the tedious JavaScript details (which trust me, is a <strong>GOOD</strong> thing).   Without further a due, here is how to submit a form with Ajax.</p>
<p><em>To download the full working code for this, <a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/form_ajax.zip">click here</a>.</em></p>
<p><strong>Form Ajax Step 1:  The HTML Page.</strong></p>
<pre class="php">
<span class="phpOperator">&lt;</span>html<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>head<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>title<span class="phpOperator">&gt;</span>Form Ajax Tutorial<span class="phpOperator">&lt;</span>/title<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>script type=<span class="phpString">"text/javascript"</span> src=<span class="phpString">"jquery-<span class="phpNumber">1</span><span class="phpOperator">.</span><span class="phpNumber">4</span><span class="phpOperator">.</span><span class="phpNumber">2</span><span class="phpOperator">.</span>min<span class="phpOperator">.</span>js"</span><span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>/script<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>script type=<span class="phpString">"text/javascript"</span><span class="phpOperator">&gt;</span>
<span class="phpComment">//After the document has loaded, it adds the following handlers
</span><span class="phpComment">//to the web page.
</span>$<span class="phpOperator">(</span>document<span class="phpOperator">)</span>.ready<span class="phpOperator">(</span><span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpComment">//When the form with id<span class="phpOperator">=</span><span class="phpString">"myform"</span> is submitted<span class="phpOperator">.</span>.<span class="phpOperator">.</span>
</span>$<span class="phpOperator">(</span><span class="phpString">"#myform"</span><span class="phpOperator">)</span>.submit<span class="phpOperator">(</span><span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpComment">//Send the serialized data to formProcessor.php.
</span>$<span class="phpOperator">.</span>post<span class="phpOperator">(</span><span class="phpString">"formProcessor.php"</span>, $<span class="phpOperator">(</span><span class="phpString">"#myform"</span><span class="phpOperator">)</span>.<span class="phpFunction">serialize</span><span class="phpOperator">(</span><span class="phpOperator">)</span>,
<span class="phpComment">//Take our repsonse, and replace whatever is in the <span class="phpString">"formResponse"</span>
</span><span class="phpComment">//div with it.
</span><span class="phpFunctionKeyword">function</span><span class="phpOperator">(</span>data<span class="phpOperator">)</span> <span class="phpOperator">{</span>
$<span class="phpOperator">(</span><span class="phpString">"#formResponse"</span><span class="phpOperator">)</span>.html<span class="phpOperator">(</span>data<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpKeyword">
return </span>>false<span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">&lt;</span>/script<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>/head<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>body<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>h2<span class="phpOperator">&gt;</span>Form Ajax Tutorial<span class="phpOperator">&lt;</span>/h2<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>p<span class="phpOperator">&gt;</span> Fill out some information <span class="phpOperator">&lt;</span>/p<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>form id<span class="phpOperator">=</span><span class="phpString">"myform"</span><span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>input type=<span class="phpString">"text"</span> name=<span class="phpString">"firstName"</span> value=<span class="phpString">"" /&gt;&lt;br /&gt;
&lt;input type="text" name="lastName" value=""</span> /<span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>br /<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>input type=<span class="phpString">"submit"</span> name=<span class="phpString">"submit"</span> value=<span class="phpString">"Submit"</span> /<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>/form<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>div id<span class="phpOperator">=</span><span class="phpString">"formResponse"</span><span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>/div<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>/body<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>/html<span class="phpOperator">&gt;</span>
</pre>
<p>For anyone who is used to HTML programming, this should all look very familiar.  The only confusing part is the JavaScript, but I&#8217;ll explain that here.  The first bit just includes the jQuery library.  This is <strong>crucial</strong> for form ajax to work.  The rest of the function is explained below:</p>
<ul>
<li><a href="http://api.jquery.com/ready/">$(document).ready()</a> &#8211; This will add handlers to your web page only after the entire page has loaded.</li>
<li><a href="http://api.jquery.com/submit/">$().submit()</a> &#8211; This will catch the click of the submit button so that it doesn&#8217;t submit the form the normal way, but the Ajax way instead.</li>
<li><a href="http://api.jquery.com/jQuery.post/">$().post()</a> &#8211; This is the part that sends out data to the processing file.  It also has a callback function that will modify our page to contain data that the processing file sent back.</li>
<li><a href="http://api.jquery.com/serialize/">$().serialize()</a> &#8211; Takes our form data and puts it into an easy to parse format.</li>
</ul>
<p><strong>Form Ajax Step 2:  The Processing Page<br />
</strong>
<pre class="php">
<span class="phpScriptTag"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span>
<span class="phpComment">//Get the information that was sent from the form<span class="phpOperator">.</span>
</span>$firstName <span class="phpOperator">=</span> <span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'firstName'</span><span class="phpOperator">]</span><span class="phpText">;</span>
$lastName <span class="phpOperator">=</span> <span class="phpScriptVar">$_POST</span><span class="phpOperator">[</span><span class="phpString">'lastName'</span><span class="phpOperator">]</span><span class="phpText">;</span>
<span class="phpComment">//Get the unix <span class="phpFunction">time</span> stamp.
</span>$unixTimeStamp <span class="phpOperator">=</span> <span class="phpFunction">time</span><span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Print output<span class="phpKeyword"> for </span><span class="htmlText">out web page to</span><span class="phpKeyword"> catch<span class="phpOperator">.</span></span>
</span><span class="phpFunction">echo</span> <span class="phpString">"Hello $firstName $lastName.  The local unix <span class="phpFunction">time</span><span class="htmlText"> is </span><span class="phpOperator">&lt;</span><span class="htmlText">b</span><span class="phpOperator">&gt;</span>$unixTimeStamp<span class="phpOperator">&lt;</span>/b<span class="phpOperator">&gt;</span><span class="phpOperator">.</span>"</span><span class="phpText">;</span>
<span class="phpScriptTag"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span>
</pre>
<p>The processing page is very important for making form ajax work correctly.  What this file does is catch the data sent by the form, and then prints out some information.  The form is waiting for this information, and then will add it to your page.  <em>Note:  This file is a .PHP file.  You need to be running a web server (or have access to one) that can process php files.</em></p>
<p><strong>Form Ajax Step 3:  You&#8217;re Done!<br />
</strong></p>
<p>Form Ajax used to be pretty difficult, but now that their are JavaScript libraries like jQuery, MooTools, and Scriptaculous, it&#8217;s easier than ever.  To download the full working code for this example, <a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/form_ajax.zip">click here</a>.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax&amp;title=Form+Ajax+%3A+How+to+Create+and+Submit+a+Form+Using+Ajax" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax&amp;title=Form+Ajax+%3A+How+to+Create+and+Submit+a+Form+Using+Ajax" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax&amp;title=Form+Ajax+%3A+How+to+Create+and+Submit+a+Form+Using+Ajax&amp;desc=For%20the%20longest%20time%2C%20web%20developers%20were%20stuck%20submitting%20their%20forms%20in%20the%20normal%20way%3A%20Click%20a%20button%2C%20go%20to%20a%20processing%20page%2C%20redirect%20back.%C2%A0%20However%2C%20now%20it%20is%20possible%20to%20submit%20a%20form%20without%20ever%20leaving%20the%20page%20with%20Ajax.%C2%A0%20Ajax%20stands%20for%20Asynchronous%20JavaScript%2C%20which%20as%20stated%20before%2C" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax&amp;bm_description=Form+Ajax+%3A+How+to+Create+and+Submit+a+Form+Using+Ajax&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax&amp;title=Form+Ajax+%3A+How+to+Create+and+Submit+a+Form+Using+Ajax" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax&amp;title=Form+Ajax+%3A+How+to+Create+and+Submit+a+Form+Using+Ajax" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax&amp;title=Form+Ajax+%3A+How+to+Create+and+Submit+a+Form+Using+Ajax" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Form+Ajax+%3A+How+to+Create+and+Submit+a+Form+Using+Ajax+-+http://b2l.me/aqgq9g&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/form-ajax-how-to-create-and-submit-form-using-ajax/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Validate Email Addresses With PHP</title>
		<link>http://www.re-cycledair.com/validate-email-addresses-with-php</link>
		<comments>http://www.re-cycledair.com/validate-email-addresses-with-php#comments</comments>
		<pubDate>Fri, 13 Aug 2010 13:59:10 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[email validation]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=419</guid>
		<description><![CDATA[If you&#8217;re a web programmer, there will come a time when you need to validate an email address. It&#8217;s going to happen, so just accept it. In newer versions of PHP, there is built in functionality for this. However, for those of us not lucky enough to be running the latest and greatest version, we [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re a web programmer, there will come a time when you need to validate an email address.  It&#8217;s going to happen, so just accept it.  In newer versions of PHP, there is built in functionality for this.  However, for those of us not lucky enough to be running the latest and greatest version, we can use regular expressions.</p>
<p><span style="font-size: 13.3333px">The following PHP function will validate email addresses using regular expressions.  True is returned on success, and false is returned otherwise.</span></p>
<pre class="php">
<span class="phpFunctionKeyword">function</span> validate_email<span class="phpOperator">(</span>$email<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
return </span><span class="phpFunction">eregi</span><span class="phpOperator">(</span><span class="phpString">"^<span class="phpOperator">[</span>_a-z0-<span class="phpNumber">9</span>-<span class="phpOperator">]</span><span class="phpOperator">+</span><span class="phpOperator">(</span>\<span class="phpOperator">.</span><span class="phpOperator">[</span>_a-z0-<span class="phpNumber">9</span>-<span class="phpOperator">]</span><span class="phpOperator">+</span><span class="phpOperator">)</span>*@<span class="phpOperator">[</span>a-z0-<span class="phpNumber">9</span>-<span class="phpOperator">]</span><span class="phpOperator">+</span><span class="phpOperator">(</span>\<span class="phpOperator">.</span><span class="phpOperator">[</span>a-z0-<span class="phpNumber">9</span>-<span class="phpOperator">]</span><span class="phpOperator">+</span><span class="phpOperator">)</span>*<span class="phpOperator">(</span>\<span class="phpOperator">.</span><span class="phpOperator">[</span>a-z<span class="phpOperator">]</span><span class="phpOperator">{</span><span class="phpNumber">2</span>,4<span class="phpOperator">}</span><span class="phpOperator">)</span>$"</span>, $email<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
</pre>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/validate-email-addresses-with-php/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/validate-email-addresses-with-php&amp;title=Validate+Email+Addresses+With+PHP" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/validate-email-addresses-with-php&amp;title=Validate+Email+Addresses+With+PHP" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/validate-email-addresses-with-php&amp;title=Validate+Email+Addresses+With+PHP&amp;desc=If%20you%27re%20a%20web%20programmer%2C%20there%20will%20come%20a%20time%20when%20you%20need%20to%20validate%20an%20email%20address.%20%20It%27s%20going%20to%20happen%2C%20so%20just%20accept%20it.%20%20In%20newer%20versions%20of%20PHP%2C%20there%20is%20built%20in%20functionality%20for%20this.%20%20However%2C%20for%20those%20of%20us%20not%20lucky%20enough%20to%20be%20running%20the%20latest%20and%20greatest%20version%2C%20we%20c" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/validate-email-addresses-with-php&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/validate-email-addresses-with-php&amp;bm_description=Validate+Email+Addresses+With+PHP&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/validate-email-addresses-with-php&amp;title=Validate+Email+Addresses+With+PHP" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/validate-email-addresses-with-php&amp;title=Validate+Email+Addresses+With+PHP" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/validate-email-addresses-with-php&amp;title=Validate+Email+Addresses+With+PHP" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/validate-email-addresses-with-php" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Validate+Email+Addresses+With+PHP+-+http://b2l.me/aqg5ay&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/validate-email-addresses-with-php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple WordPress Plugin Tutorial</title>
		<link>http://www.re-cycledair.com/simple-wordpress-plugin-tutorial</link>
		<comments>http://www.re-cycledair.com/simple-wordpress-plugin-tutorial#comments</comments>
		<pubDate>Fri, 13 Aug 2010 04:57:51 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[simple wordpress plugin tutorial]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=385</guid>
		<description><![CDATA[Sometimes WordPress just doesn&#8217;t do what you want it to do.  When that happens, you turn to plugins for help.  But sometimes, the WordPress plugin repositories don&#8217;t have what you need either.  In those cases, it&#8217;s time to pull up your sleeves and get to work.  In this tutorial, I&#8217;m going to go through the [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes WordPress just doesn&#8217;t do what you want it to do.  When that happens, you turn to plugins for help.  But sometimes, the WordPress plugin repositories don&#8217;t have what you need either.  In those cases, it&#8217;s time to pull up your sleeves and get to work.  In this tutorial, I&#8217;m going to go through the process of creating a simple WordPress plugin from scratch.  I <a href="http://www.re-cycledair.com/wp-hacker-newsCNGPyQxqe_ywr-bZpdgTmlFWdSvTFg">created this plugin</a> as a proof of concept awhile ago, and thought that it would make a great learning tool now.</p>
<p><strong>Step 1:  What are you&#8217;re making anyways?</strong></p>
<p>This plugin does one thing only, and it does it well.  It will place a &#8220;Submit to Hacker News&#8221; button on all of your posts.  While this tutorial is only for a simple plugin, it could easily be extended to include other news aggregation services and social networks.</p>
<p><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/submit_to_hn.png" rel="lightbox[385]"><img class="aligncenter size-medium wp-image-412" title="Simple WordPress Plugin Tutorial Goal" src="http://www.re-cycledair.com/wp-content/uploads/2010/08/submit_to_hn-300x90.png" alt="" width="288" height="86" /></a><br />
<strong>Step 2:  Creating the plugin.</strong></p>
<p>Now that we know what we&#8217;re going to create, we need to create the plugin.  To do that, simply create a file called <em>wp-hacker-news.php</em> and then add the following to it.</p>
<pre class="php">
<span class="phpComment">/*
* Plugin Name<span class="phpOperator">:</span> WP Hacker News
* Version<span class="phpOperator">:</span> <span class="phpNumber">0</span><span class="phpOperator">.</span><span class="phpNumber">1</span>
* Description<span class="phpOperator">:</span> Adds a <span class="phpString">"Submit to Hacker News"</span> button to your posts<span class="phpOperator">.</span>
* Author<span class="phpOperator">:</span> Jack Slingerland
* Author URI<span class="phpOperator">:</span> http<span class="phpOperator">:</span><span class="phpComment">//www<span class="phpOperator">.</span>re-cycledair.com/
</span>* Plugin URI<span class="phpOperator">:</span> http<span class="phpOperator">:</span><span class="phpComment">//www<span class="phpOperator">.</span>re-cycledair.com/wp-hacker-news
</span>*/</span>
</pre>
<p>The lines above are all <strong>required</strong> for a WordPress plugin to function correctly.  Below is a quick run-through of what each of these means.</p>
<ul>
<li><strong>Plugin Name</strong> &#8211; This is the name of your plugin.  It is how it will appear in the WordPress back-end administration panels.</li>
<li><strong>Version</strong> &#8211; The version number.  I always start a 0.1 to start, and then increment like 0.1.1 for small changes.</li>
<li><strong>Description</strong> &#8211; This is the description of your plugin.  Feel free to be verbose here, as this is how people will know what your plugin does.</li>
<li><strong>Author </strong>- This is you!  Put your name or the name of your team here.</li>
<li><strong>Author URI</strong> &#8211; Your website.  In my case, I link it to<a href="http://www.re-cycledair.com"> http://www.re-cycledair.com</a>.</li>
<li><strong>Plugin URI</strong> &#8211; The web page for your plugin.  Here, I&#8217;m linking it to the original announcement I made for this plugin.</li>
</ul>
<p><strong>Step 3:  Creating a display function.</strong></p>
<p>So you finally have a WordPress plugin.  That&#8217;s great and all, but it doesn&#8217;t do anything yet.  What you need now is to create a  function that displays the &#8220;Submit To Hacker News&#8221; link.  To do that, add this below the comment section:</p>
<pre class="php">
<span class="phpComment">//Function to show the HN Link<span class="phpOperator">.</span>
</span><span class="phpFunctionKeyword">function</span> WPHackerNews_link<span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
global </span>$post;
$link <span class="phpOperator">=</span> <span class="phpFunction">urlencode</span><span class="phpOperator">(</span>get_permalink<span class="phpOperator">(</span>$post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>ID<span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span>
$title <span class="phpOperator">=</span> <span class="phpFunction">urlencode</span><span class="phpOperator">(</span>$post<span class="phpOperator">-<span class="phpOperator">&gt;</span></span>post_title<span class="phpOperator">)</span><span class="phpText">;</span>
$formattedLink <span class="phpOperator">=</span> <span class="phpString">"
<span class="phpOperator">&lt;</span>div style="</span>float<span class="phpOperator">:</span> right; margin-left<span class="phpOperator">:</span> 10px<span class="phpText">;</span> margin-bottom<span class="phpOperator">:</span> 4px<span class="phpText">;</span><span class="phpString">"<span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>a href="</span>http<span class="phpOperator">:</span><span class="phpComment"><span class="phpComment">//news<span class="phpOperator">.</span>ycombinator.com/submitlink<span class="phpOperator">?</span>u<span class="phpOperator">=</span>$link&#038;amp<span class="phpText">;</span>t<span class="phpOperator">=</span>$title<span class="phpString">"</span><span class="phpOperator">&gt;</span>
</span><span class="phpOperator">&lt;</span>img src="</span>http<span class="phpOperator">:</span><span class="phpComment"><span class="phpComment">//www<span class="phpOperator">.</span>re-cycledair.com/wp-content/uploads/2010/03/hn<span class="phpOperator">.</span>jpg<span class="phpString">" alt<span class="phpOperator">=</span>"</span><span class="phpString">" /</span><span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span>
</span>
<span class="phpOperator">&lt;</span>span style="</span>font-size<span class="phpOperator">:</span> 9px<span class="phpText">;</span><span class="phpString">"<span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>a href="</span>http<span class="phpOperator">:</span><span class="phpComment"><span class="phpComment">//news<span class="phpOperator">.</span>ycombinator.com/submitlink<span class="phpOperator">?</span>u<span class="phpOperator">=</span>$link&#038;amp<span class="phpText">;</span>t<span class="phpOperator">=</span>$title<span class="phpString">"</span><span class="phpOperator">&gt;</span>Submit to HN<span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>/span<span class="phpOperator">&gt;</span><span class="phpOperator">&lt;</span>a href="</span>http<span class="phpOperator">:</span><span class="phpComment">//news<span class="phpOperator">.</span>ycombinator.com/submitlink<span class="phpOperator">?</span>u<span class="phpOperator">=</span>$link&#038;amp<span class="phpText">;</span>t<span class="phpOperator">=</span>$title<span class="phpString">"</span><span class="phpOperator">&gt;</span>
</span><span class="phpOperator">&lt;</span>/a<span class="phpOperator">&gt;</span>
<span class="phpOperator">&lt;</span>/div<span class="phpOperator">&gt;</span>
"</span><span class="phpText">;</span>
<span class="phpKeyword">
return </span>$formattedLink<span class="phpText">;</span>
<span class="phpOperator">}</span>
</pre>
<p>The code above explains itself pretty well.  But I&#8217;ll break it down a bit anyways.</p>
<ol>
<li>We set the global post variable.  It holds all of the information about the post we&#8217;re currently on.</li>
<li>Store the current post&#8217;s permalink and title in variables.</li>
<li>Using some in-line css and good old HTML, we get the Y Combinator logo to float on the right side of the post.</li>
<li>Return the HTML for the button to the caller of the function.</li>
</ol>
<p><strong><br />
Step 4:  Displaying your plugin.</strong></p>
<p>Everything is going great, but now we need this to actually show up in posts.  To do that, we register a display function with WordPress.  With a bit of logic, we can make it only display on posts.</p>
<pre class="php">
<span class="phpComment">//Integrate with WordPress<span class="phpOperator">.</span>
</span><span class="phpFunctionKeyword">function</span> WPHackerNews_ContentFilter<span class="phpOperator">(</span>$content<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span>is_single<span class="phpOperator">(</span><span class="phpOperator">)</span><span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpKeyword">
return </span>WPHackerNews_link<span class="phpOperator">(</span><span class="phpOperator">)</span>.$content;
<span class="phpOperator">}</span><span class="phpKeyword"> else </span><span class="phpOperator">{</span>
<span class="phpKeyword">
return </span>$content;
<span class="phpOperator">}</span>
<span class="phpOperator">}</span>
<span class="phpComment">//Add the filter
</span>add_filter <span class="phpOperator">(</span><span class="phpString">'the_content'</span>, <span class="phpString">'WPHackerNews_ContentFilter'</span><span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>The above code isn&#8217;t self-explanatory at all, so here&#8217;s how it works.</p>
<ol>
<li>When we create the function, we make sure to pass it &#8220;$content&#8221;.  &#8220;$content&#8221; is a variable that holds the content of the post that the user is on.</li>
<li>We then check to make sure that we are on a single post with the function &#8220;is_single()&#8221;.</li>
<li>If so, we return our button by calling &#8220;WPHackerNews_link()&#8221; and appending &#8220;$content&#8221; to it.</li>
<li>If not, just return the original un-altered content.</li>
<li>The final step is to use the &#8220;add_filter&#8221; function to add this plugin into WordPress.  The first argument describes where our plugin should be used (&#8220;the_content&#8221;), and the second argument is what function it should use (&#8220;WPHackerNews_contentFilter&#8221;).</li>
</ol>
<p><strong>Step 5:  You&#8217;re Done!</strong></p>
<p>That concludes this tutorial on creating a simple WordPress plugin.  All you need to do now is drop this file in your wp-content/plugins directory and then activate it in the admin.  As usual, if you run in to any errors or notice any problems, please let me know and I&#8217;ll help the best I can.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/simple-wordpress-plugin-tutorial/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial&amp;title=Simple+Wordpress+Plugin+Tutorial" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial&amp;title=Simple+Wordpress+Plugin+Tutorial" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial&amp;title=Simple+Wordpress+Plugin+Tutorial&amp;desc=Sometimes%20Wordpress%20just%20doesn%27t%20do%20what%20you%20want%20it%20to%20do.%C2%A0%20When%20that%20happens%2C%20you%20turn%20to%20plugins%20for%20help.%C2%A0%20But%20sometimes%2C%20the%20Wordpress%20plugin%20repositories%20don%27t%20have%20what%20you%20need%20either.%C2%A0%20In%20those%20cases%2C%20it%27s%20time%20to%20pull%20up%20your%20sleeves%20and%20get%20to%20work.%C2%A0%20In%20this%20tutorial%2C%20I%27m%20going%20to%20go%20" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial&amp;bm_description=Simple+Wordpress+Plugin+Tutorial&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial&amp;title=Simple+Wordpress+Plugin+Tutorial" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial&amp;title=Simple+Wordpress+Plugin+Tutorial" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial&amp;title=Simple+Wordpress+Plugin+Tutorial" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/simple-wordpress-plugin-tutorial" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Simple+Wordpress+Plugin+Tutorial+-+http://b2l.me/aqg5a2&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/simple-wordpress-plugin-tutorial/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Displaying a WordPress Widget on Specific Pages</title>
		<link>http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages</link>
		<comments>http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages#comments</comments>
		<pubDate>Thu, 12 Aug 2010 16:04:09 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[widgets]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=380</guid>
		<description><![CDATA[Sometimes when you a creating a WordPress site or blog, you only want a widget to show up on specific pages or page types.  This used to be needlessly difficult, where you would need to edit your theme manually for it to work.  However, there is a new(ish) plugin called Widget Context, which allows you [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes when you a creating a WordPress site or blog, you only want a widget to show up on specific pages or page types.  This used to be needlessly difficult, where you would need to edit your theme manually for it to work.  However, there is a new(ish) plugin called Widget Context, which allows you to pick specific pages or page types on which you would like a widget to be shown.</p>
<p><a href="http://www.re-cycledair.com/wp-content/uploads/2010/08/Screen-shot-2010-08-12-at-11.59.37-AM.png" rel="lightbox[380]"><img class="aligncenter size-full wp-image-381" src="http://www.re-cycledair.com/wp-content/uploads/2010/08/Screen-shot-2010-08-12-at-11.59.37-AM.png" alt="Wordpress Widget on Specific Pages" width="471" height="207" /></a></p>
<p>This plugin is WordPress 3 compatibile, and can be downloaded at <a href="http://wordpress.org/extend/plugins/widget-context/">http://wordpress.org/extend/plugins/widget-context/</a>.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages&amp;title=Displaying+a+Wordpress+Widget+on+Specific+Pages" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages&amp;title=Displaying+a+Wordpress+Widget+on+Specific+Pages" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages&amp;title=Displaying+a+Wordpress+Widget+on+Specific+Pages&amp;desc=Sometimes%20when%20you%20a%20creating%20a%20Wordpress%20site%20or%20blog%2C%20you%20only%20want%20a%20widget%20to%20show%20up%20on%20specific%20pages%20or%20page%20types.%C2%A0%20This%20used%20to%20be%20needlessly%20difficult%2C%20where%20you%20would%20need%20to%20edit%20your%20theme%20manually%20for%20it%20to%20work.%C2%A0%20However%2C%20there%20is%20a%20new%28ish%29%20plugin%20called%20Widget%20Context%2C%20which%20allow" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages&amp;bm_description=Displaying+a+Wordpress+Widget+on+Specific+Pages&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages&amp;title=Displaying+a+Wordpress+Widget+on+Specific+Pages" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages&amp;title=Displaying+a+Wordpress+Widget+on+Specific+Pages" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages&amp;title=Displaying+a+Wordpress+Widget+on+Specific+Pages" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Displaying+a+Wordpress+Widget+on+Specific+Pages+-+http://b2l.me/aqg5a4&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/displaying-a-wordpress-widget-on-specific-pages/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Validate Email</title>
		<link>http://www.re-cycledair.com/php-validate-email</link>
		<comments>http://www.re-cycledair.com/php-validate-email#comments</comments>
		<pubDate>Tue, 27 Jul 2010 17:32:10 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=377</guid>
		<description><![CDATA[Every so often (ok, a lot more than that), you need to validate an email address. The obvious solution is to use regular expressions, however PHP provides a better method using the filter_var() function. To validate an email address using PHP, simply do the following: $email = "jack@re-cycledair.com"; if(filter_var($email, FILTER_VALIDATE_EMAIL) == TRUE) { echo "Valid [...]]]></description>
			<content:encoded><![CDATA[<p>Every so often (ok, a lot more than that), you need to validate an email address.  The obvious solution is to use regular expressions, however PHP provides a better method using the filter_var() function.</p>
<p>To validate an email address using PHP, simply do the following:</p>
<pre class="php">
$email <span class="phpOperator">=</span> <span class="phpString">"jack@re-cycledair.com"</span><span class="phpText">;</span>
<span class="phpKeyword">
if<span class="phpOperator">(</span></span><span class="phpFunction">filter_var</span><span class="phpOperator">(</span>$email, FILTER_VALIDATE_EMAIL<span class="phpOperator">)</span> <span class="phpOperator"><span class="phpOperator">=</span>=</span> TRUE<span class="phpOperator">)</span> <span class="phpOperator">{</span>
<span class="phpFunction">echo</span> <span class="phpString">"Valid Email<span class="phpOperator">.</span>"</span><span class="phpText">;</span>
<span class="phpOperator">}</span><span class="phpKeyword"> else </span><span class="phpOperator">{</span>
<span class="phpFunction">echo</span> <span class="phpString">"Email is not valid<span class="phpOperator">.</span>"</span><span class="phpText">;</span>
<span class="phpOperator">}</span>
</pre>
<p>Note:  This only works for PHP &gt;= 5.2</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/php-validate-email/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/php-validate-email&amp;title=PHP+Validate+Email" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/php-validate-email&amp;title=PHP+Validate+Email" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/php-validate-email&amp;title=PHP+Validate+Email&amp;desc=Every%20so%20often%20%28ok%2C%20a%20lot%20more%20than%20that%29%2C%20you%20need%20to%20validate%20an%20email%20address.%20%20The%20obvious%20solution%20is%20to%20use%20regular%20expressions%2C%20however%20PHP%20provides%20a%20better%20method%20using%20the%20filter_var%28%29%20function.%0D%0A%0D%0ATo%20validate%20an%20email%20address%20using%20PHP%2C%20simply%20do%20the%20following%3A%0D%0A%0D%0A%7Bcode%20type%3Dphp%7D%0D%0A%24email%20" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/php-validate-email&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/php-validate-email&amp;bm_description=PHP+Validate+Email&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/php-validate-email&amp;title=PHP+Validate+Email" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/php-validate-email&amp;title=PHP+Validate+Email" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/php-validate-email&amp;title=PHP+Validate+Email" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/php-validate-email" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=PHP+Validate+Email+-+http://b2l.me/aqgcxt&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/php-validate-email/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress 3 Custom Post Type Tutorial</title>
		<link>http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial</link>
		<comments>http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial#comments</comments>
		<pubDate>Thu, 22 Jul 2010 12:07:57 +0000</pubDate>
		<dc:creator>jack</dc:creator>
				<category><![CDATA[PHP Programming]]></category>
		<category><![CDATA[Wordpress Development]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.re-cycledair.com/?p=355</guid>
		<description><![CDATA[When WordPress 3.0 was released, all the hype was about something called &#8220;custom post types&#8221;.  Custom post types basically allow you to add your own content types to WordPress.  Lets say for instance that you want to create a newsletter.  A newsletter in your case, is a quick descriptions followed by the excerpts from several [...]]]></description>
			<content:encoded><![CDATA[<p>When WordPress 3.0 was released, all the hype was about something called &#8220;custom post types&#8221;.  Custom post types basically allow you to add your own content types to WordPress.  Lets say for instance that you want to create a newsletter.  A newsletter in your case, is a quick descriptions followed by the excerpts from several regular posts.  By default, WordPress doesn&#8217;t support this.  However, with custom post types we can add out own &#8220;Newsletter&#8221; post type and get to work.</p>
<p><a href="http://www.re-cycledair.com/wp-content/uploads/2010/07/Screen-shot-2010-07-22-at-7.33.57-AM.png" rel="lightbox[355]"><img class="aligncenter size-medium wp-image-356" src="http://www.re-cycledair.com/wp-content/uploads/2010/07/Screen-shot-2010-07-22-at-7.33.57-AM-300x127.png" alt="Wordpress Newsletter Cusotm Post Type" width="300" height="127" /><br />
</a></p>
<p><strong>Step 1:  Register the Custom Post Type</strong></p>
<p>When creating a new custom post type, the first thing you need to do is register it with your WordPress install.  This can happen at the theme or plugin level.  In my trials with custom post types, I&#8217;ve always done it at the plugin level (mainly because I&#8217;m a developer, not a designer).</p>
<pre class="php">
<span class="phpComment">//Set up custom post type variables<span class="phpOperator">.</span>
</span>$labels <span class="phpOperator">=</span> <span class="phpFunction">array</span><span class="phpOperator">(</span>
<span class="phpString">'name'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> _x<span class="phpOperator">(</span><span class="phpString">'Newsletters'</span>, <span class="phpString">'post type general name'</span><span class="phpOperator">)</span>,
<span class="phpString">'singular_name'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> _x<span class="phpOperator">(</span><span class="phpString">'Newsletter'</span>, <span class="phpString">'post type singular name'</span><span class="phpOperator">)</span>,
<span class="phpString">'add_new'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> _x<span class="phpOperator">(</span><span class="phpString">'Add New'</span>, <span class="phpString">'Newsletter'</span><span class="phpOperator">)</span>,
<span class="phpString">'add_new_item'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> __<span class="phpOperator">(</span><span class="phpString">'Add New Newsletter'</span><span class="phpOperator">)</span>,
<span class="phpString">'edit_item'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> __<span class="phpOperator">(</span><span class="phpString">'Edit Newsletter'</span><span class="phpOperator">)</span>,
<span class="phpString">'new_item'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> __<span class="phpOperator">(</span><span class="phpString">'New Newsletter'</span><span class="phpOperator">)</span>,
<span class="phpString">'view_item'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> __<span class="phpOperator">(</span><span class="phpString">'View Newsletter'</span><span class="phpOperator">)</span>,
<span class="phpString">'search_items'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> __<span class="phpOperator">(</span><span class="phpString">'Search Newsletters'</span><span class="phpOperator">)</span>,
<span class="phpString">'not_found'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span>  __<span class="phpOperator">(</span><span class="phpString">'Nothing found'</span><span class="phpOperator">)</span>,
<span class="phpString">'not_found_in_trash'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> __<span class="phpOperator">(</span><span class="phpString">'Nothing found in Trash'</span><span class="phpOperator">)</span>,
<span class="phpString">'parent_item_colon'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpString">''</span>
<span class="phpOperator">)</span><span class="phpText">;</span>
$args <span class="phpOperator">=</span> <span class="phpFunction">array</span><span class="phpOperator">(</span>
<span class="phpString">'labels'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> $labels,
<span class="phpString"><span class="phpKeyword">'public'</span></span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span><span class="phpKeyword"> true,</span>
<span class="phpString">'publicly_queryable'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span><span class="phpKeyword"> true,</span>
<span class="phpString">'show_ui'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span><span class="phpKeyword"> true,</span>
<span class="phpString">'query_var'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span><span class="phpKeyword"> true,</span>
<span class="phpString">'menu_icon'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> get_stylesheet_directory_uri<span class="phpOperator">(</span><span class="phpOperator">)</span> <span class="phpOperator">.</span> <span class="phpString">'/images/newsletter.gif'</span>,
<span class="phpString">'rewrite'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span><span class="phpKeyword"> true,</span>
<span class="phpString">'capability_type'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpString">'post'</span>,
<span class="phpString">'hierarchical'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span><span class="phpKeyword"> false,</span>
<span class="phpString">'menu_position'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> 20,
<span class="phpString">'supports'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">'title'</span>,<span class="phpString">'editor'</span>, <span class="phpString">'excerpt'</span><span class="phpOperator">)</span>
<span class="phpOperator">)</span><span class="phpText">;</span>
<span class="phpComment">//Register the newsletter post type.
</span>register_post_type<span class="phpOperator">(</span> <span class="phpString">'newsletter'</span> , $args <span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>Now, lets disect this a bit so you know what&#8217;s going on.</p>
<ul>
<li>Labels
<ul>
<li>name &#8211; The name of your custom post type.  Usually this is the plural form of it.</li>
<li>singular_name &#8211; This is the singular form of your plural name.</li>
<li>add_new &#8211; Normally when you add a post, you click &#8220;Add new&#8221;.  It&#8217;s the same thing for this example.  However, you could make it say &#8220;Be more awesome! Add a newsletter!&#8221; (if you REALLY wanted to).</li>
<li>edit_item &#8211; Same as add_new.  You can change how the edit link is displayed.</li>
<li>new_item &#8211; When you first create your new newletter, this is what it will describe it as.  Once you have a title on it, it will display that instead.</li>
<li>For more information on these, I suggest the <a href="http://codex.wordpress.org/Custom_Post_Types#Custom_Types">WordPress Codex</a>.</li>
</ul>
</li>
<li>Args
<ul>
<li>labels &#8211; General label information for your custom post type.</li>
<li>public &#8211; Should this be made available to all users?</li>
<li>publicly_queryable &#8211; Should the public be able to run queries against your post type?</li>
<li>show_ui &#8211; Do you need a user interface?</li>
<li>menu_icon &#8211; Path to the icon that is displayed in the admin.</li>
<li>rewrite &#8211; Should WordPress attempt to make the urls friendly?</li>
<li>supports &#8211; This bit is pretty important.  This is where you describe what is shown in the admin.  Currently I have &#8220;title&#8221;, &#8220;editor&#8221;, and &#8220;excerpt&#8221;.  You can also extend this with your own stuff later.</li>
<li><span style="font-size: 13.3333px">For more information on these, I suggest the <a href="http://codex.wordpress.org/Custom_Post_Types#Custom_Types">WordPress Codex</a>.</span></li>
</ul>
</li>
<li>register_post_type &#8211; This hook is how you register your shiny new custom post type with WordPress 3.0.  First argument is a unique name that you give to your custom post type.  The second argument is the array that was defined above.</li>
</ul>
<p><strong>Step 2: Custom Categories (Taxonomy) [optional]</strong></p>
<p>One of the nice things about custom post types in WordPress 3 is that you don&#8217;t have to use the same categories (taxonomy) as your other posts  and pages.  Registering a new taxonomy for your custom post type is very easy.</p>
<pre class="php">
<span class="phpComment">//Create taxonomy<span class="phpKeyword"> for </span>categorizing newsletters
</span>register_taxonomy<span class="phpOperator">(</span>
<span class="phpString">"Categories"</span>,
<span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">"newsletter"</span><span class="phpOperator">)</span>,
<span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">"hierarchical"</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span><span class="phpKeyword"> true,</span>
<span class="phpString">"label"</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpString">"Categories"</span>,
<span class="phpString">"singular_label"</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpString">"Category"</span>,
<span class="phpString">"rewrite"</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span><span class="phpKeyword"> true<span class="phpOperator">)</span></span>
<span class="phpOperator">)</span><span class="phpText">;</span>
</pre>
<p>How this works is fairly straight forward.  The first argument is what you&#8217;d like your new post type categories to be called.  In this example, I opted for simplicity and went with &#8220;Categories&#8221;.  The second argument is the post types that you would like this taxonomy to show up on.  Since we only want it on our new post type, I&#8217;ve defined it as such.  The third argument is for options (lables, rewrite on/off, etc).</p>
<p><strong>Step 3:  Your done!</strong></p>
<p>Really, it&#8217;s that easy.  If you want to make it really useful, you need to add meta boxes to admin interface so that you can do sweet custom content.  But at it&#8217;s bare minimum, this is all you need.</p>
<p>If there is sufficient interest, I can go into deeper detail about making a plugin with a custom post type.  Also, if you need help, drop a comment and I&#8217;d be happy to give your problem a shot.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-caring-old">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial&amp;title=Wordpress+3+Custom+Post+Type+Tutorial" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial&amp;title=Wordpress+3+Custom+Post+Type+Tutorial" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial&amp;title=Wordpress+3+Custom+Post+Type+Tutorial&amp;desc=When%20Wordpress%203.0%20was%20released%2C%20all%20the%20hype%20was%20about%20something%20called%20%22custom%20post%20types%22.%20%C2%A0Custom%20post%20types%20basically%20allow%20you%20to%20add%20your%20own%20content%20types%20to%20Wordpress.%20%C2%A0Lets%20say%20for%20instance%20that%20you%20want%20to%20create%20a%20newsletter.%20%C2%A0A%20newsletter%20in%20your%20case%2C%20is%20a%20quick%20descriptions%20followe" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial&amp;bm_description=Wordpress+3+Custom+Post+Type+Tutorial&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial&amp;title=Wordpress+3+Custom+Post+Type+Tutorial" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial&amp;title=Wordpress+3+Custom+Post+Type+Tutorial" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial&amp;title=Wordpress+3+Custom+Post+Type+Tutorial" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=Wordpress+3+Custom+Post+Type+Tutorial+-+http://b2l.me/aqfmv7&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.re-cycledair.com/wordpress-3-custom-post-type-tutorial/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 2.752 seconds -->
