<?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>Website In A Weekend &#187; Extending WordPress</title>
	<atom:link href="http://website-in-a-weekend.net/category/extending-wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>http://website-in-a-weekend.net</link>
	<description>Web Zero to Web Hero</description>
	<lastBuildDate>Wed, 18 Apr 2012 23:24:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Custom post types at San Francisco WordPress Meetup (Face time!)</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/wordpress-custom-post-types-san-francisco-wordpress-meetup/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/wordpress-custom-post-types-san-francisco-wordpress-meetup/#comments</comments>
		<pubDate>Sat, 05 Mar 2011 08:14:21 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Automattic]]></category>
		<category><![CDATA[Beau Lebens]]></category>
		<category><![CDATA[Chantal]]></category>
		<category><![CDATA[Face time]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[HTML5Boilerplate]]></category>
		<category><![CDATA[Lydia Sugarman]]></category>
		<category><![CDATA[Meetup]]></category>
		<category><![CDATA[Michael Enslow]]></category>
		<category><![CDATA[Yoli]]></category>
		<category><![CDATA[Zach Berke]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=23928</guid>
		<description><![CDATA[(Reading time: 4 &#8211; 7 minutes) It has been cold in the San Francisco Bay Area the last week or so&#8230; I know, I know, I can hear you out there &#8220;Cry me a river, Dave, it&#8217;s what you deserve for all those `Another beautiful day in Paradise&#8217; tweets.&#8221; Fine. We&#8217;re spoiled here in The [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/wordpress-custom-post-types-san-francisco-wordpress-meetup/">Custom post types at San Francisco WordPress Meetup (Face time!)</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 4 &#8211; 7 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-custom-post-types-san-francisco-wordpress-meetup%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-custom-post-types-san-francisco-wordpress-meetup%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><em>It has been <strong>cold</strong> in the San Francisco Bay Area the last week or so&#8230;</em>  I know, I know, I can hear you out there &#8220;Cry me a river, Dave, it&#8217;s what you deserve for all those `Another beautiful day in Paradise&#8217; tweets.&#8221;</p>
<p><strong>Fine. We&#8217;re spoiled here in The City by the Bay. And we like it!</strong></p>
<p>We&#8217;re spoiled in more ways than the weather here in San Fran. For example, I&#8217;m sitting here in the Automattic lounge on San Francisco&#8217;s Embarcadero listening to developer <a href="http://michaelenslow.com/about">Michael Enslow</a> present the work his company <a href="http://mistermachine.com/">Mister Machine</a> did for <a href="http://socialmediaweek.org/">Social Media Week</a>.  <div id="attachment_23952" class="wp-caption alignright" style="width: 310px"><a href="http://website-in-a-weekend.net/wp-content/uploads/2011/02/automattic.jpeg"><img src="http://website-in-a-weekend.net/wp-content/uploads/2011/02/automattic-300x200.jpg" alt="" title="Automattic Lounge" width="300" height="200" class="size-medium wp-image-23952" /></a><p class="wp-caption-text">Automattic Lounge (courtesy Beau Lebens)</p></div>I don&#8217;t know Michael personally, but he&#8217;s someone I pay attention to because 1. he works with WordPress and 2. he actively develops with HTML5, an important technology you will be using very soon.</p>
<p>You may not <em>know</em> when you&#8217;re using HTML5, and that&#8217;s ok. Just expect better websites, that&#8217;s the take home.</p>
<p>Here&#8217;s what&#8217;s interesting about the talk:</p>
<ul>
<li>The Social Media Week site was built from scratch using a stripped down, in-house WordPress theme template.</li>
<li>The theme leveraged <a href="http://html5boilerplate.com/">HTML5Boilerplate</a> and <a href="https://github.com/Modernizr/Modernizr">Modernizr</a> to bring cutting edge capability to the website.</li>
<li>The advantage of using custom post type is being able to get better display of the content on the browser page.</li>
</ul>
<p>What&#8217;s best about all this is hanging out, <em>in person</em>, at the San Francisco WordPress Meetup with about <strong>75 other rabid WordPress aficionados</strong>. </p>
<p><a href="http://venntive.com/">Lydia Sugarman</a>, a good friend of mine from the San Francisco entreprenuerial startup circles is here.  <a href="http://ralphcarlsonblog.com/">Ralph Carlson</a> was on his way down from the hills, but his car got <a href="http://cantankerousoldcoots.com/">cantankerous</a> around Davis (60 miles up the road). No worries, Ralph will be down for a future Meetup.  New friends <a href="http://chantal.ws/">Chantal</a> and <a href="http://aponeurotica.com/">Yoli</a>, both talented website designers, are also in the audience.</p>
<p>Woops, someone asked for a show of hands&#8230; about 30% of the audience has been working with custom post types and taxonomies. An invisible groundswell. </p>
<h2>Stir in custom taxonomies</h2>
<p>Next up is Zach Berke of <a href="http://exygy.com/">Exygy.com</a>, with details about how custom post types and taxonomies for the <a href="http://www.skollfoundation.org/">Skoll Foundation</a> website. </p>
<ul>
<li>Custom taxonomies are to categories as custom post types are to regular posts.  This allows more dynamic feeds, as a new custom post can be associated with custom taxonomy.</li>
<li>Where you would normally see a &#8220;Category&#8221; metabox on the post editor, you can have a custom taxonomy box.</li>
<li>Using Brad Williams <a href="http://www.strangework.com/2010/03/03/custom-post-type-ui-plugin-for-wordpress/">Custom Post Type UI Plugin for WordPress</a> was a key piece of the implementation puzzle.</li>
</ul>
<p>This is powerful stuff!</p>
<p>The key to custom taxonomy is defining the <a href="http://daviddoolin.com/pedantry/taxon-taxa-taxonomies-ruh-roh/">elements of the taxonomy</a>. That is, you have to get your <em>taxa</em> in order, taxa being those taxon comprising your taxonomy.</p>
<p>Zach showed how getting this right allowed much more sensible navigation through the Skoll Foundation website. People associated with various issues and causes can be found and listed automatically. </p>
<h2>Post formats make life easy for theme developers</h2>
<p>Next up: Beau Lebens on <a href="http://codex.wordpress.org/Post_Formats">Post Formats</a>, a feature introduced in WordPress 3.1. From the Codex link: </p>
<blockquote><p>Post Formats is a theme feature introduced with Version 3.1. A Post Format is a piece of meta information that can be used by a theme to customize its presentation of a post. The Post Formats feature provides a standardized list of formats that are available to all themes that support the feature.</p></blockquote>
<p>Having <em>standard</em> post formats in WordPress Core really helps theme developers. </p>
<p>This is not to be confused with Custom Post Types, even though it is confusing.  A custom post type is a reference to the content contained in a post, and nothing to do with how such content may be displayed.  WordPress developer Mark Jaquith has an excellent article on <a href="http://markjaquith.wordpress.com/2010/11/12/post-formats-vs-custom-post-types/">Post Formats vs. Custom Post Types</a>.  Definitely worth reading if the difference is important to you.</p>
<h2>Mixed media socialization</h2>
<p>You&#8217;ve undoubtedly heard of mixed media art, maybe even seen it in real life.  Certainly, if you&#8217;ve ever been to Burning Man, that&#8217;s about as mixed as media gets.</p>
<p>A while back, in a comment elsewhere, I described social media as getting the &#8220;social,&#8221; and not worrying overmuch about the medium.  While I&#8217;m definitely <em>not</em> the most relentlessly social person, since I&#8217;ve started reaching out in person to people I know from online, I&#8217;ve noticed a nice carryover effect: the offline and online work together.</p>
<p>If you can find a WordPress or marketing or writing or some other group or meetup close by, attend!</p>
<p>The upshot: if you&#8217;re not out there getting some <a href="http://website-in-a-weekend.net/general/wordpress-31-techliminal-oakland/">face time with your online colleagues</a>, consider reducing some of your online time and increasing your offline time.</p>
<p><strong>What&#8217;s your experience? Are you getting out there and pounding some pavement? Is it helping?  Hurting? Comment below!</strong></p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-custom-post-types-san-francisco-wordpress-meetup%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-custom-post-types-san-francisco-wordpress-meetup%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/wordpress-custom-post-types-san-francisco-wordpress-meetup/">Custom post types at San Francisco WordPress Meetup (Face time!)</a></p>
<div class="shr-publisher-23928"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-custom-post-types-san-francisco-wordpress-meetup%2F' data-shr_title='Custom+post+types+at+San+Francisco+WordPress+Meetup+%28Face+time%21%29'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-custom-post-types-san-francisco-wordpress-meetup%2F' data-shr_title='Custom+post+types+at+San+Francisco+WordPress+Meetup+%28Face+time%21%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/wordpress-custom-post-types-san-francisco-wordpress-meetup/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Saturday Morning Surfing: When a bug is unfixable; leave it alone</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/bug-unfixable-leave/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/bug-unfixable-leave/#comments</comments>
		<pubDate>Sat, 13 Nov 2010 16:13:30 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Bug fixing]]></category>
		<category><![CDATA[Custom page template]]></category>
		<category><![CDATA[Digg]]></category>
		<category><![CDATA[Forward hook]]></category>
		<category><![CDATA[Holly Jahangiri]]></category>
		<category><![CDATA[Jena Isle]]></category>
		<category><![CDATA[Thesis]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=6837</guid>
		<description><![CDATA[(Reading time: 5 &#8211; 8 minutes) Programming is fun and easy compared to keeping track of everything. One of the things I have to keep track of is the Thesis custom_functions.php source file for my Thesis custom template pages. This file sits on the web server of course, but also in a source code repository, [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/bug-unfixable-leave/">Saturday Morning Surfing: When a bug is unfixable; leave it alone</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 5 &#8211; 8 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fbug-unfixable-leave%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fbug-unfixable-leave%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Programming is fun and easy compared to keeping track of everything.</p>
<p>One of the things I have to keep track of is the Thesis <code>custom_functions.php</code> source file for my <a href="http://website-in-a-weekend.net/extending-wordpress/create-custom-template-pages-thesis-theme/">Thesis custom template pages</a>. This file sits on the web server of course, but also in a source code repository, and in a local copy running on my development computer.  </p>
<p>Normally, this isn&#8217;t a problem.</p>
<p>Then I edited <code>custom_functions.php</code> through the built-in WordPress file editor.   I forgot that the plugin editor strips out <a href="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double">newline escapes</a> (<code>"\n"</code> &rarr; <code>"n"</code>), which litters the web page with random letters &#8220;n&#8221; and thoroughly destroys the layout. </p>
<p>Now, having multiple copies is a problem, because one of the copies is broken.</p>
<p>So I spent a unhappy afternoon being stymied by an &#8220;unfixable bug&#8221; in the WordPress plugin editor.  </p>
<h2>&#8220;Works for me&#8221;</h2>
<p>I&#8217;m not the only person who has had this trouble.<br />
<a href="http://website-in-a-weekend.net/extending-wordpress/bug-unfixable-leave/attachment/worksforme/" rel="attachment wp-att-14614"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/08/worksforme-126x470.png" alt="" title="worksforme" width="126" height="470" class="alignright size-large wp-image-14614" /></a></p>
<p>But none of the WordPress developers have it.</p>
<p>As you can see from the screen capture of the WordPress Trac ticketing system, <a href="http://core.trac.wordpress.org/ticket/10903">issue #10903 is closed with a &#8220;worksforme.&#8221;</a> </p>
<p>That&#8217;s a very hackerish thing to say.</p>
<p>I can&#8217;t say I blame them.  WordPress is free software after all.  If this issue really were a problem for me, I&#8217;d knuckle down and fix it myself, or pay someone to fix it for me.</p>
<p>Instead, I make like the internet and route around the damage. </p>
<h2>The No-solution Solution</h2>
<p>The no-solution solution for fixing bugs is pretty simple.  Here&#8217;s a few concrete suggestions:</p>
<p><strong>1. Leverage the pain of others.</strong></p>
<p>Typically, when you have a bug in a piece of software like WordPress, many other people are experiencing the same problem.  </p>
<p><em>Most likely, someone has also reported the problem.</em>  </p>
<p>Once the problem has been reported, it goes on a release schedule for eventual fixing (or not).  You have little control (none) over the release schedule, so&#8230;</p>
<p><strong>2. Do something else.</strong></p>
<p>For me it falls into the category of &#8220;If it don&#8217;t work, find sumpin else to do.&#8221;</p>
<p>In my example above, I just stopped using the built-in plugin editor.  I routed around the problem. Simple. </p>
<p>But that&#8217;s not good enough for some people.  For example, Holly Jahangiri prefers a more direct approach: </p>
<blockquote><p>That is an entirely-too-practical approach to life, David. I gravitate towards the &#8220;if it don&#8217;t work, beat your head against a brick wall until your ears bleed and some geek takes pity on you and figures it out so you&#8217;ll stop&#8221; approach. :)</p></blockquote>
<p><strong>3. Bang your head until your ears bleed.</strong></p>
<p>A while back, <a href="http://jenaisleonline.com/">Jena Isle</a> had a problem with one of her articles submitted to Digg.  The article could be loaded from her blog, but it came back with Invalid URL from Digg. It ended in my lap via <a href="http://jahangiri.us/new/">Holly Jahangiri</a>:</p>
<blockquote><p>&#8230;&#8221;Invalid URL&#8221; has to do with special characters in the title. In this case, there are no obvious special characters, but when you try to Digg (or strangely enough, even copy from the address bar) the URL from the post page &#8211; Bam! error.</p></blockquote>
<p><a href="http://website-in-a-weekend.net/wp-content/uploads/2010/11/headbang.jpg"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/11/headbang-150x150.jpg" alt="Bang your head until your ears bleed." title="headbang" width="150" height="150" class="alignleft size-thumbnail wp-image-23036" /></a></p>
<p>I did some poking around on Google, and found that it was known but infrequent problem, and nobody has any idea how to fix it.  Blood, leaking from my ears&#8230; I emailed Holly something like &#8220;Don&#8217;t Digg that article.&#8221;  Problem solved!  </p>
<p>Holly, to her credit, continued to bang her head:</p>
<blockquote><p>
Oh, well, it&#8217;s still working for me &#8211; that bleeding out the ears thing &#8211; except there were no geekier geeks racing to my rescue and I did figure it out, finally, I think. For some reason, somehow, it was taking the url as having a comma before blogspot (I have no idea why, unless there&#8217;s some place to set that in the plug-in Jen&#8217;s using, but I suspect maybe, just maybe, it&#8217;s some weird error somewhere in her settings). Anyway, digging it from the FRONT page, not the post page, worked.</p></blockquote>
<p>Yikes!</p>
<p>If head banging isn&#8217;t your thing (and nothing wrong with it if it is), you need to know&#8230; </p>
<h2>When to punt</h2>
<p>Free software such as WordPress depends on users reporting and, when possible, fixing bugs.  It&#8217;s a good model, as you can see from the wild success of WordPress.</p>
<p>Fixing, or even reporting bugs isn&#8217;t always feasible.  Putting on my developer hat, when a user can&#8217;t precisely describe a bug so that I can reproduce it, I&#8217;m not going to have time to fix it.  Likewise, when I don&#8217;t have to precisely describe a bug, I won&#8217;t report it either.</p>
<p>Here are a few guidelines I use for deciding whether to fix or report bugs:</p>
<ul>
<li><strong>Do I have time?</strong>  It&#8217;s going to be an hour&#8217;s work, at least. If fixing it won&#8217;t save me time in the long run, punt.</li>
<li><strong>Does Google bring back junk?</strong>  We&#8217;re getting close to the day when just about any keyword or phrase with traffic is going to be gamed. If I get no related results from search, punt.</li>
<li><strong>Is the bug close to my competence level?</strong>   There is this notion of a &#8220;technology stack&#8221; (which I&#8217;ll write more about in the future*).  This means I&#8217;ll consider fixing bugs in WordPress, but not in the web server, etc.</li>
</ul>
<p><em>NOTE: All of these guidelines apply to like activities, for example, web and WordPress theme design.</em> </p>
<p>If something is just too hard to do, that&#8217;s a hint!</p>
<p>As a public service, here&#8217;s a recap of techniques for handling bugs:</p>
<ol>
<li>Leverage the pain of others.</li>
<li>Do something else.</li>
<li>Bang your head until your ears are bleeding.</li>
</ol>
<p>Can you add to this list?  What&#8217;s your special technique for handling bugs?</p>
<hr />
<div class="footnote">* BPE customers: this is a forward hook.</div>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fbug-unfixable-leave%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fbug-unfixable-leave%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/bug-unfixable-leave/">Saturday Morning Surfing: When a bug is unfixable; leave it alone</a></p>
<div class="shr-publisher-6837"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fbug-unfixable-leave%2F' data-shr_title='Saturday+Morning+Surfing%3A+When+a+bug+is+unfixable%3B+leave+it+alone'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fbug-unfixable-leave%2F' data-shr_title='Saturday+Morning+Surfing%3A+When+a+bug+is+unfixable%3B+leave+it+alone'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/bug-unfixable-leave/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>DIY WordPress:  What&#8217;s Your Toolchain Look Like?</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/diy-wordpress-toolchain/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/diy-wordpress-toolchain/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 17:56:00 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Amplify]]></category>
		<category><![CDATA[Aptana]]></category>
		<category><![CDATA[Blogging]]></category>
		<category><![CDATA[content management systems]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[DIY WordPress]]></category>
		<category><![CDATA[Free software]]></category>
		<category><![CDATA[Gimp]]></category>
		<category><![CDATA[hammers]]></category>
		<category><![CDATA[inkscape]]></category>
		<category><![CDATA[localhost]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[Nails]]></category>
		<category><![CDATA[php programming language]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=21338</guid>
		<description><![CDATA[(Reading time: 4 &#8211; 7 minutes) When all you have is a hammer, everything looks like a nail. Or something like that, according to Lofti Zadeh. WordPress is a pretty big hammer, and even when you have screws instead of nails, the hammer still works. And you, dear reader, are most likely a do-it-yourselfer. Kind [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/diy-wordpress-toolchain/">DIY WordPress:  What&#8217;s Your Toolchain Look Like?</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 4 &#8211; 7 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fdiy-wordpress-toolchain%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fdiy-wordpress-toolchain%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>When all you have is a hammer, everything looks like a nail.  Or something like that, according to <a href="http://www.cs.berkeley.edu/~zadeh/">Lofti Zadeh</a>. </p>
<p>WordPress is a pretty big hammer, and even when you have screws instead of nails, the hammer still works.</p>
<p>And you, dear reader, are most likely a do-it-yourselfer.  Kind of goes with the &#8220;website in a weekend&#8221; territory.</p>
<p>Sometimes you need more than a hammer.  WordPress isn&#8217;t always enough. You need more tools in your toolkit.  As any good DIYer, you make a point of mastering the selected tools in your toolkit.</p>
<p>Here&#8217;s a few of the tools in my WordPress DIY toolkit:</p>
<ul>
<li>GIMP, the <a href="http://www.gimp.org/">Gnu Image Manipulation Program</a>.  Disclaimer: I was across the street from the  Berkeley XCF when Peter and Spencer first wrote the GIMP.  I&#8217;ve dabbled since version 0.56.  GIMP has come a long way!</li>
<li><a href="http://www.inkscape.org/">Inkscape, SVG done right</a>. Every good pixel program (i.e., GIMP) needs a vector program to drive it. Inkscape fits my bill.  While SVG hasn&#8217;t gotten the traction it deserves (this is a political problem, not a technical problem), it&#8217;s got enough traction to make it worthwhile.  And Adobe stiffed me hard on the update from Illustrator 8 to the Creative Suite programs (i.e., no upgrade incentive, so I&#8217;m not upgrading).</li>
<li><a href="http://www.aptana.com/">Aptana Studio</a>, best of a bad breed.  Aptana has succeeded in taming Eclipse, a long running Java Integrated Development Environment which seems to introduce as many problems as it solves from release to release. I&#8217;ll probably get flamed for that one, but I&#8217;ve tried (unsuccessfully) off and on to like Eclipse since it was first announced &#8211; with much fanfare &#8211; about 10 years ago. Aptana works beautifully, and it&#8217;s free for a basic edition (all you probably need as a small business person).</li>
<li><a href="http://winmerge.org/">Winmerge</a> for Windows, <a href="http://www.deltopia.com/compare-merge-sync/macosx/">DeltaWalker for MacOSX</a>.  Do you know the difference between those two custom.css files? No?  How do you plan to find out?  I do it the easy way and use a differencing tool.  On MS Windows, I use the free Winmerge application.  On MacOSX I use DeltaWalker, which is around $40 US, and a very good value.  </li>
<li><a href="http://filezilla-project.org/">Filezilla</a>.  FTP is a critically important in every DITer&#8217;s toolkit, and Filezilla is one of the best.</li>
<li><a href="http://trac.edgewall.org/">Trac wiki, from Edgewall</a>.  Trac is the same software used by Automattic for WordPress development.  I also lean heavily on the bug and issue tracking capability of Trac, which is integrated into the wiki.  Super convenient!</li>
<li><a href="http://subversion.tigris.org/">Subversion source code control</a>. Think of subversion as &#8220;collaborative backups, with complete version history.&#8221; It&#8217;s more than that, but that&#8217;s good enough for now.  Take home: you need to have a back up plan in place, and using it, before you go banging away on your WordPress files.  Really, you do.</li>
<li>Notepad/TextEdit: these come with your computer, no need to link.  Both of these are invaluable for snapping out fast notes without having to think very much.  For example, this blog post was mostly written in TextEdit on my Macbook, then copied into WordPress.  </li>
</ul>
<h2>Some DIY Theme Work</h2>
<p>I need to add some updates to Thesis theme custom.css that Amanda Farough sent along a couple of weeks ago.  As it turns out, I&#8217;ve added a large number of modifications to her work, so I can&#8217;t just copy her file into my WordPress theme.  Everything would break.  It would be nasty and you would think &#8220;WTH is Dave smoking?&#8221;</p>
<p>You may or may not be thinking that anyway…</p>
<p>While we&#8217;re at it, let&#8217;s upgrade to Thesis 1.8 along the way.</p>
<p>Here&#8217;s the order of business: </p>
<ol>
<li>Download current custom.css to Desktop.</li>
<li>Compared and merged remote version to Amanda&#8217;s version.</li>
<li>Compared merged version to version in repository.  Woops.  That&#8217;s no good.  The repository is out of date!  time to change course, time to install WordPress locally!</li>
<li>Started MAMP server.</li>
<li>Rebuilt WordPress Whitepaper 6: Develop WordPress Plugins on Windows with WAMP Environment.  (I use these whitepapers.  Dogfood. [link])</li>
<li>Create database for WiaW on localhost.</li>
<li>Download WordPress 3.0.1, copy into localhost (MAMP/htdocs) directory.</li>
<li>Woops, doesn&#8217;t work, install fails.  What gives?  Bad MySQL command is what gives:<br />
<blockquote><p><code>mysql> grant all privileges on *.* to 'wiaw'@'loclahost' with grant option;</code>  </p></blockquote>
<p>&#8220;loclahost?&#8221; </p>
<p>I don&#8217;t think so.  It&#8217;s &#8220;localhost.&#8221; Fixed.</li>
<li>WordPress installed!  Yahoo!</li>
<li>Copy Thesis 1.8 into themes. This was done by checking out the Thesis code from the subversion repository.  That way, when I&#8217;m done, I can check it back in and have a archival record of it.  (No, I can&#8217;t recall why I didn&#8217;t do this after the last update to Website In A Weekend. Pretty slack if you ask me, and if you forget back up or archive your junk, I&#8217;ll certainly harsh you up about it. =)</li>
<li>Copied the &#8220;correct&#8221; custom.css file into thesis_18 on the new localhost installation.</li>
</ol>
<p>And that&#8217;s enough for my hour. As usual, getting one thing done (theme modification) requires doing something else first (building development environment).   </p>
<p>Remember, this DIY hour includes writing this blog post!  </p>
<p>And back to you: </p>
<p><strong>How much DIY do you do?  What&#8217;s in your toolkit?  What&#8217;s your favorite tool? </strong> </p>
<hr />
<p>Update September 22, 2010: As it turns out, I&#8217;m reviewing the Scribe SEO plugin for the next release of Blog Post Engineering.  This is the first article I&#8217;ve checked. Scribe SEO scored this blog post at 96%. </p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fdiy-wordpress-toolchain%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fdiy-wordpress-toolchain%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/diy-wordpress-toolchain/">DIY WordPress:  What&#8217;s Your Toolchain Look Like?</a></p>
<div class="shr-publisher-21338"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fdiy-wordpress-toolchain%2F' data-shr_title='DIY+WordPress%3A++What%27s+Your+Toolchain+Look+Like%3F'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fdiy-wordpress-toolchain%2F' data-shr_title='DIY+WordPress%3A++What%27s+Your+Toolchain+Look+Like%3F'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/diy-wordpress-toolchain/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>Thickbox Ajax Form Handling in WordPress</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/thickbox-ajax-form-handling-wordpress/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/thickbox-ajax-form-handling-wordpress/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 07:14:22 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[hRecipe]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Thickbox]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=21128</guid>
		<description><![CDATA[(Reading time: 5 &#8211; 8 minutes) &#8220;Code is poetry.&#8221; You&#8217;ve probably seen that little epigram floating around the net. If you code, you &#8220;get it.&#8221; If you don&#8217;t code, it&#8217;s not hard to understand: whatever intrinsic beauty is latent in a piece of code should be found. As with poetry, finding that latent beauty is [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/thickbox-ajax-form-handling-wordpress/">Thickbox Ajax Form Handling in WordPress</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 5 &#8211; 8 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fthickbox-ajax-form-handling-wordpress%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fthickbox-ajax-form-handling-wordpress%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>&#8220;Code is poetry.&#8221; </p>
<p>You&#8217;ve probably seen that little epigram floating around the net.  If you code, you &#8220;get it.&#8221; If you don&#8217;t code, it&#8217;s not hard to understand: whatever intrinsic beauty is latent in a piece of code should be found.</p>
<p>As with poetry, <em>finding</em> that latent beauty is the hard part.</p>
<p>In my <strong>Ongoing Quest for World Domination</strong> of <a href="http://hrecipe.com/">WordPress recipe formatting</a>, I have plenty of occasion to look for latent beauty.  </p>
<p>Lately, that beauty has been lurking in PHP form handling.  Specifically, hRecipe provides a spiffy Javascript popup box allowing the WordPress recipe maven a friendly way to enter their recipes for publication on blog posts and pages.  This popup box is called a &#8220;thickbox&#8221; and it&#8217;s a component of the nearly ubiquitous jQuery library which ships with every installation of WordPress.</p>
<p>After entering a recipe, it&#8217;s easy to send the formatted information directly to a blog post.  This is how it&#8217;s been done so far, and how the hReview plugin (upon which hRecipe) is based works. </p>
<p>But that&#8217;s not good enough.  All this recipe data should be in the WordPress database. </p>
<h2>PHP vs. Javascript form handling</h2>
<p>In general, handling HTML forms is well-understood technology.  But the specific details vary enough from platform-to-platform that it&#8217;s worth learning new techniques.  What follows is a few notes on how to implement form handling using the WordPress Ajax capability.</p>
<p>First the motivation: because of the way thickbox is implemented as a child window of the blog post editor, code for handling the form can be written in the thickbox handler or the class that invokes the thickbox handler.</p>
<p>Which leaves the database out of scope.</p>
<p>Even if you derived a class from the database handler itself, you may still be out of scope with respect to the instance of the current hRecipe class.</p>
<p>Conversely, there&#8217;s no easy and elegant way to pass the database handling code into the thickbox handler.  The database code is all PHP running on the server, and the thickbox code is mostly Javascript, running in your browser.  An ugly problem to be sure.</p>
<p>Succinctly, we want the form data processed such the database is in scope, but the processing is encapsulated within it&#8217;s own file.  </p>
<p>Enter WordPress.</p>
<h2>WordPress Ajax form handling</h2>
<p>It turns out that WordPress has an Ajax broker (for lack of a better word) which will pass the form data from the Javascript code to the form handler running on the server.  Here&#8217;s what that looks like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#hrecipe_form&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> ajaxurl <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&lt;?php echo admin_url('admin-ajax.php');?&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">serialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		jQuery.<span style="color: #660066;">post</span><span style="color: #009900;">&#40;</span>ajaxurl<span style="color: #339933;">,</span> data<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Simple, right?</p>
<p>Ok, it&#8217;s a little more complicated than specifying the action attribute in your form, but I guarantee the tradeoff for power is worth the slight added complexity. Since you&#8217;re using Javascript anyway (thickbox), it really isn&#8217;t a problem.</p>
<p>Taking it from the top&#8230;</p>
<ul>
<li>Line 1: The usual JQuery invocation. </li>
<li>Line 2: The id attribute of your form.  This should be self-explanatory.  If you don&#8217;t know what id attributes are, you have some homework to do.  In this case, we&#8217;re passing an anonymous function into .submit.  The usual JQuery way.</li>
<li>Line 3: It&#8217;s absolutely key to get the admin-ajax.php file included.   The methods you need for hooking the WordPress Ajax interface up are in that file.  If you implement this, and it doesn&#8217;t work, checking for this file should be your first step in debugging.</li>
<li>Line 4: This is all of your form data.  Every single element.  Spiffy!</li>
<li>Line 5: The Ajax call.  The third argument captures whatever you return from your handler.  In this case, I&#8217;m choosing not to do anything with the returned data.  You could (should) put a Javascript alert box here when you first implement; it&#8217;s fun watching this code execute.</li>
</ul>
<p>And that&#8217;s it for the Javascript part.</p>
<p>Now you need to ensure your form has the correct id attribute, and a field for triggering the action handler.</p>
<h2>Form data for Ajax</h2>
<p>Simple: <code>&lt;form method="post" id="hrecipe_form" action="" &gt;</code>.</p>
<p>You probably don&#8217;t need the method attribute, that&#8217;s taken care of using Javascript.</p>
<p>Next, add a hidden input field named &#8220;action,&#8221; like this:<br />
<code>&lt;input type="hidden" name="action" value="thickbox_form" /&gt;</code></p>
<p>Simple, right?</p>
<p>Let&#8217;s get the handler installed.</p>
<h2>Handling the request with PHP</h2>
<p>The cool part is that the PHP side of WordPress won&#8217;t know the difference.  As far as it&#8217;s concerned, it&#8217;s $_GET and $_POST as usual.  Here&#8217;s how to do it.<br />
<code>add_action("wp_ajax_thickbox_form", array ($recipe, 'thickbox_form_handler'));</code></p>
<p>The key to this action is understanding the <code>wp_ajax</code> tag, which registers the handler given as the second argument to <code>add_action</code>.  Nothing new here; even if <code>wp_ajax</code> is new to you, you have seen the pattern before.</p>
<p>Note also that I&#8217;m using a class-based design for hRecipe, thus I have to pass <code>add_action</code> the hRecipe class instance (<code>$recipe</code>) where the handler is located. Otherwise, <code>thickbox_form_handler</code> will be out of scope.</p>
<p>The handler code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>103
104
105
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> thickbox_form_handler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #b1b100;">include</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'view/recipe_form.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The form data is all nicely tucked away into recipe_form.php, which connects to the WordPress database and handles all the messy chores of extracting the values of the form fields.</p>
<p>We&#8217;ve solved the problem: recipe_form.php is now in scope, but all it&#8217;s ugliness is &#8220;under the hood.&#8221;  </p>
<h2>Implementing Ajax in WordPress</h2>
<p>If you have arrived here from other pages showing you how to do the same thing,  you have probably read that all of this needs to be in the same file.  Or perhaps some other limitation must be respected.  With all due respect to the authors of other articles, such limitations are artifacts of the main requirement: </p>
<p><strong>Everything must be in scope.</strong></p>
<p>If you have every call and function in scope, it&#8217;s as simple as shown here.  If this code doesn&#8217;t work for you, checking scope should be your first step in debugging.  Here&#8217;s a checklist:</p>
<ol>
<li>Ensure your form id matches the Javascript id you&#8217;re invoking <code>.submit</code> for.</li>
<li>Check to see that you have an input field named &#8220;action&#8221; with an appropriate value.</li>
<li>Make sure your <code>add_action</code> is using the same value appended to the wp_ajax tag as you set for your input field with <code>name="action"</code>.</li>
<li>Ensure the admin-ajax.php is in your path.  This is critical, none of this works without the handlers in that file.</li>
</ol>
<p>Questions welcome, I&#8217;ll do my best to answer.</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fthickbox-ajax-form-handling-wordpress%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fthickbox-ajax-form-handling-wordpress%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/thickbox-ajax-form-handling-wordpress/">Thickbox Ajax Form Handling in WordPress</a></p>
<div class="shr-publisher-21128"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fthickbox-ajax-form-handling-wordpress%2F' data-shr_title='Thickbox+Ajax+Form+Handling+in+WordPress'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fthickbox-ajax-form-handling-wordpress%2F' data-shr_title='Thickbox+Ajax+Form+Handling+in+WordPress'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/thickbox-ajax-form-handling-wordpress/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>DIY WordPress: What You Need to Know About PHP if You Don&#8217;t Yet Know a Damn Thing</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/wordpress-php-basics/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/wordpress-php-basics/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 17:00:36 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Deliberate practice]]></category>
		<category><![CDATA[Fairy Blog Mother]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=13369</guid>
		<description><![CDATA[(Reading time: 6 &#8211; 9 minutes) WordPress can be considered a dynamic web application. What that means depends a little bit on who you talk to, and what you are using WordPress to achieve. (Look for related reading at the end of this article.) What &#8220;dynamic web application&#8221; means for this article is a web [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/wordpress-php-basics/">DIY WordPress: What You Need to Know About PHP if You Don&#8217;t Yet Know a Damn Thing</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 6 &#8211; 9 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-php-basics%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-php-basics%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>WordPress can be considered a <a href="http://website-in-a-weekend.net/website-design/static-dynamic-information/">dynamic web application</a>.  What that means depends a little bit on who you talk to, and what you are using WordPress to achieve. (Look for related reading at the end of this article.)</p>
<p>What &#8220;dynamic web application&#8221; means for this article is a web page resulting from an unholy fusion of HTML, CSS, PHP and MySQL.  And Javascript.  Can&#8217;t forget Javascript.  </p>
<p>5 different langguages. That&#8217;s crazy.  Seriously, it&#8217;s crazy.  Back in the dinosaur days (1990s), it was plenty to master one programming language per application.*  You could  even spend most of a career just in one or a few languages. </p>
<p>Anyway, if you&#8217;re still with me, you probably know a little bit about HTML and CSS by now.  It turns out that for WordPress, you don&#8217;t need a lot of Javascript or MySQL for tweaking themes and plugins.  Helpful, they are, but not necessary.</p>
<p>What you need now is a little PHP, so that&#8217;s where we&#8217;re going next.</p>
<h2>&#8220;Why should I care about PHP?&#8221;</h2>
<p>You continue, <em>despite your better judgement</em>, to read Website In A Weekend on a regular basis. Which means by hook or by crook, you&#8217;re at least partly in the do-it-yourself camp.  You may not <em>want</em> to camp in DIY, but there you are.  So you should care because if you don&#8217;t, you&#8217;re gonna mess something up sooner or later.</p>
<div style="float: right; width: 35%; border: 1px; background-color: #eeeeee; margin: 5px; padding: 5px; font-size:small; border-style: solid;"><strong>Sidenote</strong>: If you whitescreen WordPress, that is, all of sudden, the only thing displayed is a blank white page, you almost 100% surely have a syntax error in your PHP code, and that syntax error is almost surely a missing semi-colon &#8220;;&#8221;.</div>
<p>And it won&#8217;t be pleasant. </p>
<p>So that&#8217;s why you should care.</p>
<h2>WTH is PHP, anyway?</h2>
<p>PHP is a recursive acronym, meaning PHP Hypertext Preprocessor.  For more on recursive acronyms, I suggest Wikipedia.  </p>
<p>PHP is a programming language that slides in and around HTML to do a lot of tedious dirty work so you don&#8217;t have to.  PHP code intermingled with HTML often appears ugly. In programming, something appearing ugly often <em>is</em> ugly.  One of the weaknesses of PHP is that some of this ugliness can&#8217;t be helped.  It was designed in.</p>
<p>PHP is a module that plugs into your web server that translates (preprocesses) PHP files into HTML (hypertext).  The PHP interpreter is different than the web server.  You can run a web server without PHP, but you can&#8217;t serve PHP over the web without a web server.</p>
<p>PHP is all that and more!</p>
<h2>PHP Hypertext Preprocessor</h2>
<p>From the above, PHP the programming language is what&#8217;s of most concern to you, right here and right now.  The language is what you&#8217;re going to see when you&#8217;re poking around in WordPress.  Here&#8217;s the basic concepts.</p>
<ul>
<li><strong>PHP language syntax</strong>. PHP syntax derives from the family of C like languages.  If you know already know C, you will pick up PHP pretty quick (but you probably already know that).  If you don&#8217;t know C, no worries, it&#8217;s not that important.  The point is, there&#8217;s history and meaning behind PHP syntax.  It didn&#8217;t sprout from someone&#8217;s forehead, ex nihilo.
<p>Current versions of PHP are &#8220;object-oriented.&#8221;  But really, PHP is procedural, object-oriented capability was bolted on, not designed in.
</li>
<li><strong>Understand variable scope</strong>.  Understanding variable scope is critical.  If you have programmed before, you may need to unlearn some assumptions, like global variables not acting how you think they should.  Variable scope in PHP <em>still</em> trips me up.  If you have little programming experience, you won&#8217;t have to unlearn anything.  That&#8217;s a good thing.</li>
<li><strong>PHP paths are critical</strong>.  When you write an application or even tweak a plugin for WordPress, you need to know how WordPress and PHP find things like files and images you want to deliver to your readers.  WordPress does a pretty good job of standardizing paths.  Spend the time to figure that out.</li>
<li><strong>Understand single and double quoting</strong>. Single and double quoting in PHP behave slightly differently, but these small differences are important.  Sometimes single and double quotes can be used the same way, other times, they can&#8217;t be used the same way.  Most people develop their own scheme for when and how to use each type of quoting.</li>
<li><strong>WordPress and PHP APIs are different</strong>.  A collection (library) of functions is called an Application Programming Interface (API).  When you&#8217;re just starting out, it&#8217;s critical to figure out the difference between functions that are part of PHP and functions that are part of WordPress.</li>
</ul>
<p>Here&#8217;s four functions you absolutely must know for effectively programming in WordPress.  I suggest either memorizing these functions (smart) or have their definitions on speed dial (not as good, but it&#8217;s how I do it).</p>
<ul>
<li><code>dirname</code>: returns the directory path to the file given as argument.  This is the directory on the server, not the URL path. PHP function.</li>
<li><code>basename</code>: returns just the file name for a given path.  Dual to <code>dirname</code>. PHP function.</li>
<li><code>add_action</code>: adds a specified function to a WordPress <em>action</em>. Example: if you want to print your own meta tags into your web page head element, create a function and use add_action to tell WordPress where to print the output of your function. See Line 20 in <a href="http://website-in-a-weekend.net/extending-wordpress/seo-anchor-text/#anchortextplugin">Anchor Text Plugin</a>.WordPress function.</li>
<li><code>add_filter</code>: modifies text before printing that text to a WordPress page.  For example, WordPress uses a filter to automatically add paragraph breaks to your blog posts.  (Which some people really hate, but what can you do?).  WordPress function.</li>
</ul>
<p><a href="http://groovera.com/groovera-low-mercury-music-stream-homepage.php"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/06/low_mercury.png" alt="Low Mercury from Groovera Chilled Web Radio" title="Low Mercury from Groovera Chilled Web Radio" width="210" height="183" class="alignright size-full wp-image-19771" /></a>By the way, I just got a nice email from Tim Lumen, who operates <a href="http://groovera.com/">Groovera.com</a>.  Curiously, I just happen to be listening to <a href="http://groovera.com/groovera-low-mercury-music-stream-homepage.php">Low Mercury</a> right at this very moment.  Low Mercury is super-chill, great for those days when Trance, Techno and Breakbeats is just a little too much.  If you&#8217;re in a kick back writing mode, check &#8216;em out.  Groovera is 100% listener supported, and worth it. If you like what you hear, donate or subscribe.   If you&#8217;re in budget mode, give Tim a little link love.  Or both!</p>
<h2>Related reading</h2>
<p>Here&#8217;s some articles you might like from 2009:</p>
<ul>
<li><a href="http://website-in-a-weekend.net/creating-content/static-dynamic-websites-operational-informational/">Static Versus Dynamic Websites – Operational, Informational, Interactional</a>. The meaning of static and dynamic websites depends on the context of your discussion, and you need to know these 3 definitions so you won&#8217;t get ripped off.</li>
<li><a href="http://website-in-a-weekend.net/website-design/wordpress-dynamic-content-generation/">Dynamic Content Generation – How WordPress is Like a Sushi Restaurant</a>.  Understanding how WordPress works is easy: it works just like a sushi restaurant. Read it and see, I&#8217;m sure you&#8217;ll agree.</li>
</ul>
<hr />
*<span style="font-size:65%;">Make and cpp don&#8217;t count.  La la la I can&#8217;t hear you. Never let facts interfere with a good story.</span></p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-php-basics%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-php-basics%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/wordpress-php-basics/">DIY WordPress: What You Need to Know About PHP if You Don&#8217;t Yet Know a Damn Thing</a></p>
<div class="shr-publisher-13369"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-php-basics%2F' data-shr_title='DIY+WordPress%3A+What+You+Need+to+Know+About+PHP+if+You+Don%27t+Yet+Know+a+Damn+Thing'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-php-basics%2F' data-shr_title='DIY+WordPress%3A+What+You+Need+to+Know+About+PHP+if+You+Don%27t+Yet+Know+a+Damn+Thing'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/wordpress-php-basics/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>SEO Anchor Text SEO Anchor Text SEO Anchor Text SEO Anchor Text</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/seo-anchor-text/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/seo-anchor-text/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 07:11:45 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Anchor text]]></category>
		<category><![CDATA[Backlinking]]></category>
		<category><![CDATA[Forward hook]]></category>
		<category><![CDATA[Internal linking]]></category>
		<category><![CDATA[Linking]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Plugin development]]></category>
		<category><![CDATA[Plugin series]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=19516</guid>
		<description><![CDATA[(Reading time: 3 &#8211; 5 minutes) Do I have your attention? Good. I&#8217;ve mentioned this before, anchor text matters. If linking is the door to higher search results, anchor text is the key that unlocks that door. I know this for several reasons. I rank pretty well for a couple of long tail terms. I [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/seo-anchor-text/">SEO Anchor Text SEO Anchor Text SEO Anchor Text SEO Anchor Text</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 3 &#8211; 5 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fseo-anchor-text%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fseo-anchor-text%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Do I have your attention?</p>
<p>Good.</p>
<p>I&#8217;ve mentioned this before,  <a href="http://website-in-a-weekend.net/building-traffic/anchor-text/">anchor text</a> matters.</p>
<p>If linking is the door to higher search results, anchor text is the key that unlocks that door.</p>
<p>I know this for several reasons. I rank pretty well for a couple of long tail terms.  I also watch as many of those free SEO videos as I can from people like Brad Callen, Andy Jenkins and the like.  You know, the Stompernet guys and big time internet marketers.  They give away a lot of good stuff for free.  And if they&#8217;re a-givin&#8217; I&#8217;m a-takin&#8217;.</p>
<p>Using anchor text naturally, such that it doesn&#8217;t break the flow of your prose (and sound all weird) is a bit of an art.  </p>
<p>But first you have to get the anchor text (if you are linking), or find a way to provide it people who want to link.</p>
<h2>1. Ask for anchor text</h2>
<p>If you aren&#8217;t sure what anchor text to use when linking to an article, ask the article&#8217;s author.  </p>
<p>If you&#8217;re an author, provide anchor text information to people who want to link to you.</p>
<p>If you find yourself being linked to with unsuitable anchor text, here&#8217;s what Erica Douglass does:</p>
<blockquote><p>
I send them an email thanking them for linking to my blog, and then say &#8220;Instead of erica.biz as your link text, can you put &#8216;<a href="http://erica.biz/">starting your own business</a>&#8216;?&#8221; (I&#8217;ll also often throw in an entire sentence with the <code>&lt;a href=""&gt;&lt;/a&gt;</code> etc. already in there.</p>
<p>Sometimes it works. Sometimes it doesn&#8217;t. I&#8217;ve gotten most of my good rankings from guest posting and putting the SEO&#8217;d text in my blurb. I show how to do this in <a href="http://www.guestpostsecrets.com/">Guest Post Secrets</a>.
</p></blockquote>
<h2>2. Using SEO keyword metadata</h2>
<p><strong>STOP.</strong></p>
<p>I&#8217;m not going to write what you think I&#8217;m going to write about keywords.  Instead, I&#8217;m going to make an offer.  First:</p>
<p><strong>Use your meta keywords to specify your preferred anchor text.</strong></p>
<p>That way, when I want to link to you, I&#8217;ll know what you want to rank for.  I just look at the source for your page, extract what I need. Easy.</p>
<p>Here&#8217;s the offer: if you want to link to one of my articles, and you find that it (the article) has no keyword metadata (there are plenty, too many), email me, I&#8217;ll add keywords you can use for anchor text, and <strong>send you a free copy of Blog Post Engineering</strong> when I get the trackback from your link.  </p>
<h2 id="anchortextplugin">3. Let&#8217;s plug it in</h2>
<p>If the notion of specifying keyword metadata is simply too repellent, I offer a tiny plugin for your amusement.</p>
<p>Since it&#8217;s Tuesday, we can go technical.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
 * Plugin name: Fast Anchor Text
 * Plugin URI: http://website-in-a-weekend.net/seo-anchor-text
 * Description: Set desired anchor text as custom field.
 * Version: 0.1
 * Author: Dave Doolin
 * Author URI: http://website-in-a-weekend.net/
 */</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> anchor_text_meta<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_home<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
   <span style="color: #000088;">$anchor</span> <span style="color: #339933;">=</span> get_post_meta<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'anchortext'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
   <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$anchor</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;meta name=<span style="color: #000099; font-weight: bold;">\&quot;</span>anchortext<span style="color: #000099; font-weight: bold;">\&quot;</span> content=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$anchor</span><span style="color: #000099; font-weight: bold;">\&quot;</span> /&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>  
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_head'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'anchor_text_meta'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>If you don&#8217;t like plugins, and you prefer messing around with functions.php (or custom_functions.php in Thesis theme), you can just paste the functional parts into those files.</p>
<p>Here&#8217;s a screenshot of how to use it:</p>
<div id="attachment_19555" class="wp-caption aligncenter" style="width: 437px"><a href="http://website-in-a-weekend.net/wp-content/uploads/2010/06/custom_anchor_text.png"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/06/custom_anchor_text.png" alt="Custom anchor text" title="custom_anchor_text" width="427" height="319" class="size-full wp-image-19555" /></a><p class="wp-caption-text">Key in blue box, anchor text in red box</p></div>
<p>Here&#8217;s the plugin file: <a href='http://website-in-a-weekend.net/wp-content/uploads/2010/06/anchor.zip'>anchor.zip</a>.</p>
<h2>Blog Maintenance Challenge</h2>
<p>Believe it or not, I am slowly yet surely adding material to the Blog Maintenance Challenge.  Dealing with keywords and anchors is definitely on the curriculum.  </p>
<p>I&#8217;ll have some videos over there too.</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fseo-anchor-text%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fseo-anchor-text%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/seo-anchor-text/">SEO Anchor Text SEO Anchor Text SEO Anchor Text SEO Anchor Text</a></p>
<div class="shr-publisher-19516"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fseo-anchor-text%2F' data-shr_title='SEO+Anchor+Text+SEO+Anchor+Text+SEO+Anchor+Text+SEO+Anchor+Text+'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fseo-anchor-text%2F' data-shr_title='SEO+Anchor+Text+SEO+Anchor+Text+SEO+Anchor+Text+SEO+Anchor+Text+'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/seo-anchor-text/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>WordPress Widget Plugin &#8211; Super easy customization (Tuesday means technical)</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/wordpress-widget-plugin-super-easy-customization-tuesday-means-technical/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/wordpress-widget-plugin-super-easy-customization-tuesday-means-technical/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 07:21:11 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Plugin performance]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=19081</guid>
		<description><![CDATA[(Reading time: 11 &#8211; 18 minutes) We hear it all the time: speed of implementation. Execute fast. Fail fast, even. But all of this sterling advice assumes we know how to execute. When you&#8217;re starting from scratch, with big ambitions, you have a problem: you can&#8217;t execute on any of your ideas. There is a [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/wordpress-widget-plugin-super-easy-customization-tuesday-means-technical/">WordPress Widget Plugin &#8211; Super easy customization (Tuesday means technical)</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 11 &#8211; 18 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-widget-plugin-super-easy-customization-tuesday-means-technical%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-widget-plugin-super-easy-customization-tuesday-means-technical%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>We hear it all the time: <a href="http://tinobox.com/wordpress/smallbusiness/speed-of-implementation-the-1-principle-determining-business-success/">speed of implementation</a>.  Execute fast.  Fail fast, even.  But all of this sterling advice assumes we know <em>how</em> to execute.</p>
<p>When you&#8217;re starting from scratch, with big ambitions, you have a problem: you can&#8217;t execute on <em>any</em> of your ideas.</p>
<p>There is a solution&#8230;</p>
<p><strong>&#8230;when you can&#8217;t do what you want, do what you can.</strong>  </p>
<p>For example, I want to build the Next Big Thing, but my network programming skills aren&#8217;t up to scratch.  I could choose to be in a bind and do nothing, or I could choose to build the necessary skill set.  </p>
<p><strong>It&#8217;s building the skill set for me.</strong></p>
<p>Note: in the software business, and especially within the startup ecosystem, business acumen and programming wizardry are not assumed to be mutually exclusive.  In fact, a lot of the real rock stars in Silicon Valley are better than average at both.  </p>
<p>As it turns out, I was chatting with <a href="http://www.gurls-asylum.us/">Jenn Jinright</a> about this very problem, this skill building problem. She&#8217;s relatively new, and has just started to realize the stupendiosity of the amount of work involved in building any business, much less a business based on the internet subject to global labor pressure.</p>
<p>I told her I was in the same boat, in a different area, and that I would finish up an article to demonstrate how I do it. </p>
<p>This is that article.</p>
<h2>Design top down, build bottom up</h2>
<p>The strategy is to fix a general picture of what you&#8217;re aiming for, then figure out what the pieces of that puzzle look like.  You won&#8217;t see it clearly.  That&#8217;s ok.  <strong>This is top down design</strong>.</p>
<p>Once you have a general notion of what the pieces look like, build those pieces, which is easier said than done. <strong>This is building from the bottom up</strong>.</p>
<p>You may (will) end up building things you don&#8217;t need.  That&#8217;s how it is.  The things you do build may not (won&#8217;t) work the way you think. But if you keep after it, you will build yourself a toolchest, an arsenal of weaponry which you can haul out to solve tactical problems as they come up.</p>
<p>Because this is Technical Tuesday and because I&#8217;m building a suite of WordPress plugins for various reasons, I&#8217;m going to <strong>use WordPress plugin development as my motivating example</strong>.  I&#8217;d be delighted to write another article on this topic using, say, an AWeber list segmentation to deal with a technical upgrade to an information product (Thesis theme customization).  Just let me know.</p>
<p>Note: If you&#8217;re a DIY&#8217;er (and a lot of you are), you don&#8217;t need to understand <em>exactly</em> what&#8217;s going on in the code example below.  But if you follow along, you will <strong>learn a great technique for teaching yourself</strong>.</p>
<h2>6 reasons for Technical Tuesday</h2>
<p>Most of my articles on Website In A Weekend solve several problems at once, but just to be clear, here&#8217;s my motivation for these &#8220;technical tuesdays&#8221;: </p>
<ol>
<li><strong>Building out a plugin toolset for fast execution</strong>. With a little care, plugins can be designed to snap together like Legos.  I leveraged a couple of existing plugins this way to build the Statustar demo at the last <a href="http://website-in-a-weekend.net/extending-wordpress/startup-weekend-start-brand-business-56-hours/">Bay Area Startup Weekend</a>.</li>
<li><strong>Search engine bait for WordPress widget development</strong>, on a topic not well covered. This means I didn&#8217;t find any code that worked the way I wanted, out-of-the-box, so I write my own code and article.</li>
<li><strong>My content strategy reserves one day a week for deep tech</strong>, the hard stuff, <strong>The Hero Stuff</strong>.  Long time readers (bofem) know this.</li>
<li><strong>I write to learn</strong>.  I teach this stuff to myself.  You can learn right along with me, and what I do here is an excellent way to teach yourself.</li>
<li><strong>Deliberate practice forces learning</strong>. It turns out the difference between &#8220;good&#8221; and &#8220;great&#8221; is doing the work that matters. Building technical skill <em>very fast</em> matters to me.  Once a week I do that work.</li>
<li><em>Last, and far from least, this is part of the base code I used to <strong>create the Blog Post Engineering Affiliate Widget plugin</strong>.  No messy text boxes in my sidebar.  More about that at the end, including how you can get the plugin yourself</em>.
</li>
</ol>
<p>This still begs the question&#8230;</p>
<h2>Why use plugins at all, if they&#8217;re so slow?</h2>
<p>Here&#8217;s the deal: instead of fooling around with <code>functions.php</code> or <code>custom_functions.php</code>, write a little plugin instead.  Theme files aren&#8217;t portable, plugins are.  If you break your theme,  that&#8217;s a major malfunction.  Breaking an accessory plugin, no big deal, just delete it.</p>
<p><center><strong>Warning: Informed Opinion Ahead.</strong></center></p>
<p>Before we go any further, I&#8217;m just sure <strong>someone</strong> is thinking &#8220;Too many plugins makes WordPress slow!!!&#8221;</p>
<p>Yes and no.</p>
<p>How WordPress plugins affect loading speed depends on not just the extra HTTP requests, but also on:</p>
<ol>
<li>What those plugins are doing, that is, what functions they use in WordPress.</li>
<li>How many files are packaged with the plugin.</li>
<li>How many lines of code in the plugin are executed.</li>
</ol>
<p>It turns out it&#8217;s pretty hard to predict performance in advance, which is why we have (surprise) performance testing.  I&#8217;m not aware of anyone who has published performance results accounting for any of these plugin dependencies.  Hopefully, somebody smart will latch on to this notion and do some quantitative testing.  Or pay me to do some quantitative testing, that would be fine too.</p>
<p>We&#8217;re going to look at code now.  If this is a problem, <a href="#breakdown" title="Skip the whole listing.">jump the code</a>.</p>
<h2>WordPress Widget Demo Plugin</h2>
<p>Here&#8217;s the whole listing, it&#8217;s pretty short, you can cut and paste it if you want but I would recommend <a href="http://fuelyourcoding.com/interview-with-wess-cope-wattz-net/">typing it all in by hand</a>.  You will learn it better that way.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
 * Plugin name: Demo Plugin Widget
 * Plugin URI: http://website-in-a-weekend.net/plugins/demo-plugins/
 * Description: Demonstrating how to add a WordPress widget with a plugin.
 * Version: 0.1
 * Author: Dave Doolin
 * Author URI: http://website-in-a-weekend.net/
 */</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">class_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;demo_plugin_widget&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">class</span> demo_plugin_widget <span style="color: #000000; font-weight: bold;">extends</span> WP_Widget <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> demo_plugin_widget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$widget_ops</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'classname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'demo_plugin_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'A Widget Demo'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">WP_Widget</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'demo_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Plugin Demo Widget'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$widget_ops</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/* This is the code that gets displayed on the UI side,
		 * what readers see.
		 */</span>
		<span style="color: #000000; font-weight: bold;">function</span> widget<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> EXTR_SKIP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_widget</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'&amp;nbsp;'</span> <span style="color: #339933;">:</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_title'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
				<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_title</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$title</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$after_title</span><span style="color: #339933;">;</span> 
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;ul&gt;
	&lt;li&gt;Some text here.&lt;/li&gt;
	&lt;li&gt;More text.&lt;/li&gt;
&lt;/ul&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$after_widget</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$instance</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$old_instance</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$instance</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">/* Back end, the interface shown in Appearance -&gt; Widgets
		 * administration interface.
		 */</span>
		<span style="color: #000000; font-weight: bold;">function</span> form<span style="color: #009900;">&#40;</span><span style="color: #000088;">$instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$instance</span> <span style="color: #339933;">=</span> wp_parse_args<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$instance</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'entry_title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'comments_title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;p&gt;
&lt;label for=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;Title: 
    &lt;input
	   class=&quot;widefat&quot; id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;
	   name=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; type=&quot;text&quot;
	   value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> attribute_escape<span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; 
	/&gt;
&lt;/label&gt;
&lt;/p&gt;
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #009900;">&#125;</span>			
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> demo_widget_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		register_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'demo_plugin_widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widgets_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'demo_widget_init'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$wpdpd</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> demo_plugin_widget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>A few dozen lines of code gets a simple widget.  This is very cool, seriously cool.</p>
<h2 id="breakdown">Break it down!</h2>
<p>Now we&#8217;re going to explain how the widget code works by breaking it down piecewise.  If this is a problem, <a href="#usingthewidget">jump the code explanation</a>.</p>
<p>Let the learning begin: I&#8217;m using Safari browser on my Macbook, and I&#8217;ll be using Google to look up a few references I&#8217;m not sure about.  We&#8217;ll figure out <em>what</em> is going on, and <em>why</em>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">class_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;demo_plugin_widget&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">class</span> demo_plugin_widget <span style="color: #000000; font-weight: bold;">extends</span> WP_Widget <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">function</span> demo_plugin_widget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$widget_ops</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'classname'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'demo_plugin_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'A Widget Demo'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">WP_Widget</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'demo_widget'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Plugin Demo Widget'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$widget_ops</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The easy stuff:</p>
<ul>
<li><strong>Line 11</strong>: ensure there isn&#8217;t any conflict with existing code.  This may seem faintly ridiculous, and in production (shipping) code, maybe it is (maybe it isn&#8217;t&#8230; I&#8217;ve had collisions with my recipe plugin in the past).  When you&#8217;re developing, these kinds of conflicts can occur as a side effect from using advanced development techniques such as &#8220;cut-n-paste.&#8221;
</li>
<li><strong>Line 13</strong> opens the class definition.  We&#8217;ll close the class definition on line 75.</li>
<li><strong>Line 16</strong>: The widget needs to know about itself, and it needs to be able to tell you about itself.</li>
<li><strong>Line 17</strong>: Set the WP_Widget base class parameters 1. the ID used for targeting, css, etc., 2. descriptive text to display in the title bar in the Widgets interface, and 3. our class array.
</li>
</ul>
<p>Standard stuff, really, once you see it a few times.</p>
<p>Next, we need to override the three required functions of WP_Widget: <code>widget</code>, <code>update</code> and <code>form</code>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>23
24
25
26
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">		<span style="color: #000000; font-weight: bold;">function</span> widget<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #339933;">,</span> EXTR_SKIP<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_widget</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'&amp;nbsp;'</span> <span style="color: #339933;">:</span> apply_filters<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_title'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<ul>
<li><strong>Line 23</strong>: <code>widget</code> is a required function, you have to override it.</li>
<li><strong>Line 24</strong>:  grab the variables we need, but (EXTR_SKIP) don&#8217;t overwrite any variable we already have.
</li>
<li><strong>Line 25</strong>: <code>$before_widget</code> is a variable obtained from the sidebar.  It might contain some HTML markup controlling the layout of the widget in the sidebar.  For example, check out this <a href="http://website-in-a-weekend.net/extending-wordpress/thesis-theme-custom-splash-page/#splashpagesidebar">WordPress custom sidebar</a> example.  This is really interesting code design, the layout is manually controlled within the widget. I would not have done it this way (too easy to forget), and I&#8217;m curious what the design tradeoffs are.
</li>
<li><strong>Line 26</strong>: If the <code>title</code> variable is <code>empty</code>, give it a single space (&#038;nbsp)  to help the layout render when it&#8217;s displayed.  Else set the <code>title</code>.</li>
</ul>
<p>Moving right along&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>28
29
30
31
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">			if (!empty($title)) { 
				echo $before_title . $title . $after_title; 
			}
			?&gt;
&nbsp;
&lt;ul&gt;
	&lt;li&gt;Some text here.&lt;/li&gt;
	&lt;li&gt;More text.&lt;/li&gt;
&lt;/ul&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
            <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$after_widget</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>It&#8217;s getting easier, sort of&#8230;</p>
<ul>
<li><strong>Line 28</strong>: Not a big fan of double negatives.  I&#8217;m not the brightest bulb in the building, so I always have to pause for a moment with &#8220;not empty.&#8221;  I&#8217;d prefer something like &#8220;full.&#8221;  Heresy.</li>
<li><strong>Line 31</strong>: We need to jump out of PHP and write some HTML directly.</li>
<li><strong>Lines 33-36</strong>: Dummy text, instructional purposes only.</li>
<li><strong>Line 38</strong>: Get back into PHP, more work to do.</li>
</ul>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>42
43
44
45
46
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">		<span style="color: #000000; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #339933;">,</span> <span style="color: #000088;">$old_instance</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$instance</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$old_instance</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$new_instance</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">return</span> <span style="color: #000088;">$instance</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This is easy, the <code>update</code> function handles everything that happens when you set the values in the widget when your in the Appearance -> Widgets administration area.</p>
<p>Form is also easy, it lays out the HTML you use in the administration area:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">		function form($instance) {
			$instance = wp_parse_args( (array) $instance, array( 'title' =&gt; '' ));
			$title = strip_tags($instance['title']);
			?&gt;
&nbsp;
&lt;p&gt;
&lt;label for=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;Title: 
    &lt;input
	   class=&quot;widefat&quot; id=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;
	   name=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_field_name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; type=&quot;text&quot;
	   value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> attribute_escape<span style="color: #009900;">&#40;</span><span style="color: #000088;">$title</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; 
	/&gt;
&lt;/label&gt;
&lt;/p&gt;
&nbsp;
			<span style="color: #000000; font-weight: bold;">&lt;?php</span>
		<span style="color: #009900;">&#125;</span>			
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Long snippet here.  No matter, we&#8217;ll take it a line at a time.</p>
<ul>
<li><strong>Line 52</strong>: <code>$instance</code> is where the current data lives.  If we change that data, the changes are handled in <code>update</code>.</li>
<li><strong>Line 53</strong>: Strip tags gets rid of HTML, Javascript and other potentially nasty artifacts, increasing the security of your code.</li>
<li><strong>Lines 56-64</strong>: This is the HTML code shown in the actual widget itself.  In this case, &#8220;Title:&#8221; labels an input element which sets <code>title</code> variable.</li>
</ul>
<p>Not so bad.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>70
71
72
73
74
75
76
77
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">function</span> demo_widget_init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		register_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'demo_plugin_widget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widgets_init'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'demo_widget_init'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$wpdpd</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> demo_plugin_widget<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Almost done:</p>
<ul>
<li><strong>Line 73</strong> adds our custom widget to the list of widgets WordPress already knows about, using the function defined in <strong>line 70</strong> as the relevant callback.  You probably already know this, I&#8217;m just writing it out to be complete.</li>
<li><strong>Line 75</strong> closes the class definition.</li>
<li><strong>Line 77</strong> is important, it initializes an instant of the widget.  If you used this widget in your own plugin, you might want to initialize it somewhere else, perhaps in the main plugin class.</li>
</ul>
<p>And that&#8217;s the end of that.</p>
<p>Get a grip on this simple code, and you will be able to snap a widget into your own code very easily.  Not quite cut and paste, but very close.</p>
<h2 id="usingthewidget">Using the widget plugin</h2>
<p>Having developed this widget component for Startup Weekend, it was only natural to snap it into the the <a href="http://website-in-a-weekend.net/affiliates/">Blog Post Engineering Affiliate plugin</a>.  </p>
<p>It&#8217;s really cool.  You just <a href="http://website-in-a-weekend.net/wp-content/uploads/2010/04/bpe.zip">download the bpe.zip file</a> to your desktop, upload it using the WordPress plugin installation panel, and configure your sidebar with your affiliate link.  No more messing around with text widgets and URLs.  </p>
<p>Having the widget code &#8220;in my back pocket&#8221; let me build the affiliate plugin really fast.  It took about 45 minutes to implement the widget, and part of that was an error on my part.  Using it will save you a LOT of time.</p>
<h2>So, are plugins slow or not?</h2>
<p>As mentioned in my <a href="http://website-in-a-weekend.net/extending-wordpress/estimated-reading-time-plugin-2/">estimated reading time plugin</a> article, having more plugins goes counter to received opinion in Blogistan (i.e., more plugins is bad.)  </p>
<p>Recall I said something about taking anyone&#8217;s opinion on this with a grain of salt.  Because until you measure performance, it is simply <em>opinion</em>.  I guarantee 99% of the people that spout this nonsense haven&#8217;t ever fired up YSlow and checked to see which plugin <em>is</em> the slowest.  Last I checked, it was Tweetmeme here on Website In A Weekend.  It&#8217;s going to be different on your WordPress installation.</p>
<p>Here&#8217;s how the expert opinion works: if <em>you</em> have very little experience, and you ask someone with a lot of experience&#8230; they&#8217;re going to tell you something you can understand and act on: &#8220;Remove your plugins to speed up WordPress.&#8221; (<span style="font-size: 75%;">If they don&#8217;t tell you to Read The Effen Manual instead.</span>)</p>
<p>Easy.  Useless.  I like my plugins.  All of them.</p>
<p>They aren&#8217;t likely to tell you &#8220;Install Firebug and YSlow, then run a few performance tests to average plugin load time to see which plugins are slowing you down.&#8221;  (Actually, they might if you paid them real money.)</p>
<p>Don&#8217;t take my word for it.  Think for yourself.  Test it for yourself.</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-widget-plugin-super-easy-customization-tuesday-means-technical%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-widget-plugin-super-easy-customization-tuesday-means-technical%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/wordpress-widget-plugin-super-easy-customization-tuesday-means-technical/">WordPress Widget Plugin &#8211; Super easy customization (Tuesday means technical)</a></p>
<div class="shr-publisher-19081"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-widget-plugin-super-easy-customization-tuesday-means-technical%2F' data-shr_title='WordPress+Widget+Plugin+-+Super+easy+customization+%28Tuesday+means+technical%29'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fwordpress-widget-plugin-super-easy-customization-tuesday-means-technical%2F' data-shr_title='WordPress+Widget+Plugin+-+Super+easy+customization+%28Tuesday+means+technical%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/wordpress-widget-plugin-super-easy-customization-tuesday-means-technical/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Estimated Reading Time Plugin : Sharpening the stick (technical tuesday)</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/estimated-reading-time-plugin-2/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/estimated-reading-time-plugin-2/#comments</comments>
		<pubDate>Tue, 25 May 2010 07:53:10 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Deliberate practice]]></category>
		<category><![CDATA[Estimated reading time]]></category>
		<category><![CDATA[Path to mastery]]></category>
		<category><![CDATA[Plugin performance]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Technical Tuesday]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=18671</guid>
		<description><![CDATA[(Reading time: 6 &#8211; 10 minutes) Tim Ferriss has a lot to say about blogging. In fact, he can talk for an hour straight about it, as I found out last year at WordCamp 2009 in San Francisco. I learned about Tim&#8217;s strategy, and he gave us a few of his tactics and techniques. One [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/estimated-reading-time-plugin-2/">Estimated Reading Time Plugin : Sharpening the stick (technical tuesday)</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 6 &#8211; 10 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Festimated-reading-time-plugin-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Festimated-reading-time-plugin-2%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://website-in-a-weekend.net/creating-content/wordcamp-sf-tim-ferris-speaks-about-blogging/">Tim Ferriss has a lot to say about blogging</a>.  In fact, he can talk for an hour straight about it, as I found out last year at WordCamp 2009 in San Francisco.  </p>
<p>I learned about Tim&#8217;s strategy, and he gave us a few of his tactics and techniques.  One of Tim&#8217;s really interesting tactics for treating readers with respect was providing an estimate of how much time it might take them to read an article.  For those unacquainted with Tim&#8217;s writing, sometimes it&#8217;s long, 3000 words or more long.</p>
<p>These days, I&#8217;m starting to see a lot more blogs with an estimated reading time displayed. Back last June, a whole year ago, there weren&#8217;t very many.  There are surely several ways to implement an estimated reading time; being WordPress, there is a plugin.</p>
<p>And so, once again, a Technical Tuesday, where we break down one of Website In A Weekend&#8217;s most popular plugins: Estimated Reading Time.  </p>
<p>But&#8230;</p>
<p>Before we get started, (<strong>IMPORTANT &rarr;</strong>) You Do Not Need To Read The Code To Get The Point.</p>
<p>You do, however, need to scan over the code.  Take it in as a &#8220;block.&#8221;  Notice it&#8217;s not very long.  </p>
<h2>The Estimated Reading Time plugin</h2>
<p>The Estimated Reading Time plugin is pretty short, just a couple of dozen  lines.  If this hurts your eyeballs, by all means <a href="#jumpovercode">jump right over the code</a>.</p>
<p>Otherwise, check it out in all it&#8217;s PHP glory:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'est_read_time'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">function</span> est_read_time<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$wordcount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">str_word_count</span><span style="color: #009900;">&#40;</span>get_the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$minutes_fast</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wordcount</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$minutes_slow</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wordcount</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">150</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wordcount</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">150</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Reading time: &lt; 1 minute&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Reading time: <span style="color: #009933; font-weight: bold;">%s</span> - <span style="color: #009933; font-weight: bold;">%s</span> minutes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$minutes_fast</span><span style="color: #339933;">,</span> <span style="color: #000088;">$minutes_slow</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;p class=&quot;estread&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p class=&quot;estread&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'est_the_content'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">function</span> est_the_content<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$orig</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Prepend the reading time to the post content</span>
	<span style="color: #b1b100;">return</span> est_read_time<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$orig</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
   <span style="color: #666666; font-style: italic;">// Set this to priority 9 so it's called before wptextuarize/wpautop/etc</span>
   add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'est_the_content'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>That&#8217;s not bad, 30 lines of pure D elegance.</p>
<p>Just for fun, let&#8217;s break it down&#8230;  (no? <a href="#goforthegoodies">Go for the goodies</a>?)</p>
<h2 id="jumpovercode">The break down</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'est_read_time'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">function</span> est_read_time<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></pre></td></tr></table></div>

<p>Let&#8217;s check to see if this function for estimated reading time already exists in WordPress, perhaps in another plugin.  If so, skip over it.</p>
<p>If not, do some computation.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #000088;">$wordcount</span> <span style="color: #339933;">=</span> <span style="color: #990000;">round</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">str_word_count</span><span style="color: #009900;">&#40;</span>get_the_content<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$minutes_fast</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wordcount</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$minutes_slow</span> <span style="color: #339933;">=</span> <span style="color: #990000;">ceil</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$wordcount</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">150</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>These simple computations are the heart of the plugin, and if you&#8217;ve noticed the &#8220;2-2&#8243; bug, this computation is where that occurs.  Here&#8217;s how it works:</p>
<ol>
<li>After counting the words with <code>str_word_count</code>, the PHP <code>round</code> function with argument -2 multiplies the result by 100.</li>
<li>Then, dividing by 250 and 150, respectively, gives a range, and the <code>ceil</code> function returns the next highest integer from the division.</li>
</ol>
<p>Not hard, right?</p>
<p>Let&#8217;s figure out what to show the reader:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wordcount</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">150</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Reading time: &lt; 1 minute&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Reading time: <span style="color: #009933; font-weight: bold;">%s</span> - <span style="color: #009933; font-weight: bold;">%s</span> minutes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$minutes_fast</span><span style="color: #339933;">,</span> <span style="color: #000088;">$minutes_slow</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here&#8217;s the other half of the &#8220;2-2 minutes&#8221; bug.  Fixing it won&#8217;t be hard, will just take a little time examining how round and ceil work, or kludging in a fix by checking to see if <code>$minutes_fast</code> equals <code>$minutes_slow</code>.</p>
<p>Once we know what we want to display&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$return</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'&lt;p class=&quot;estread&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p class=&quot;estread&quot;&gt;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This means that when the function is called from some other part of WordPress, it will return a string to wherever it&#8217;s wanted.  Else, it prints the estimated reading time string straight to your screen.  </p>
<p>Note that &#8220;estread&#8221; class is added automatically.  This CSS currently has to be added manually to your style sheet. (custom.css if you use Thesis)  In the near future, the plugin will have it&#8217;s own style sheet.</p>
<p>Here&#8217;s where we set up for the hook&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>12
13
14
15
16
17
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'est_the_content'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
<span style="color: #000000; font-weight: bold;">function</span> est_the_content<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$orig</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">// Prepend the reading time to the post content</span>
	<span style="color: #b1b100;">return</span> est_read_time<span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$orig</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Calling est_reading_time with true.  We want the string back because&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>12
13
14
15
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'add_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">:</span>
   <span style="color: #666666; font-style: italic;">// Set this to priority 9 so it's called before wptextuarize/wpautop/etc</span>
   add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'the_content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'est_the_content'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>&#8230;we&#8217;re adding the string with the reading time directly to the content.</p>
<p>Easy, right?</p>
<p>&#8220;But why,&#8221; you might ask, &#8220;should I bother myself with these tedious  details?&#8221;</p>
<p>That&#8217;s an excellent question, and you, Website In A Weekend reader, deserve an answer.  </p>
<h2 id="goforthegoodies">Ripping back the (plugin) veil</h2>
<p>Long time readers (bofem) recall that I&#8217;ve published similar code and plugin breakdowns in the past. Just last week, we tore into the <a href="http://website-in-a-weekend.net/extending-wordpress/really-fast-seo-slugs/">SEO Slugs plugin</a>.  A month or two past, we had the <a href="http://website-in-a-weekend.net/extending-wordpress/diy-wordpress-worlds-shortest-plugin/">world&#8217;s shortest plugin</a>. </p>
<p><strong>Stay with me here&#8230;</strong></p>
<p>If you think I might <strong>demonstrating</strong> something <span style="font-size:65%">(more than just showing off even though I am sort of showing off, at least a little bit)</span>, you might be right.</p>
<p>I&#8217;m <em>setting the stage</em> for a nice big twist of Blogistan&#8217;s collective nose.  Remember this old saw &#8220;Too many plugins is bad and makes your blog slow.&#8221;? </p>
<p>Who says so?  Why do they say it? How do they know, who granted their authority and why should I believe what J. Random Blogger says about plugins, loading speed, or any other damn thing about blogging?</p>
<p><em>More important, why should you believe it?</em></p>
<p><strong>Rule of thumb</strong>: If it didn&#8217;t come directly from a WordPress core developer, or plugin author with years of experience, or a professional webmaster, take it with a grain of salt.  Maybe a big lump of salt.</p>
<p>Worse yet, even if you get your information straight from the horse&#8217;s mouth (so to speak), it may be suspect.  I&#8217;ll go deeper into &#8220;why&#8221; in the future.</p>
<p>Let&#8217;s wrap this up.</p>
<h2>Do you need estimated reading time?</h2>
<p>This plugin is pretty small, and it&#8217;s not going to put much of a load on your WordPress installation (almost none, really), so using it won&#8217;t cost much more than installing it.  But before you &#8220;just install it,&#8221; note that my primary reason for using it is because the length of my articles varies wildly between roughly 1 minute reading time to over 20 minutes reading time.</p>
<p>Further, <em>the topics that I write on vary between highly accessible to highly technical</em>.</p>
<p>Because of this wide range of length and topical difficulty in my blog posts, letting the reader know what&#8217;s in store just seems polite.  And it works.  Readers have commented that having some notion of their commitment ahead of time is very helpful.</p>
<p>Seeing a short post (1 &#8211; 2 minutes) may bring a reader in who might otherwise pass.  Seeing a long post, a reader might choose to go get a cup of coffee before starting to read (I say this because this is what I&#8217;ve been told by a reader in the past.)</p>
<p>Displaying an estimated reading may or may not be useful for you.  If you write articles of uniform length, your readers always know what to expect, reading time is superfluous.  Likewise, if your articles are fairly well-focused and written in a uniform voice, your articles can be any length, from 100 to 3000 words, and your readers will be there for you regardless of article length.</p>
<p>Also. Remember why I do this stuff: <a href="http://www.amazon.com/Talent-Overrated-Separates-World-Class-Performers/dp/1591842948/tinb-20">Talent is Overrated</a>, I <a href="http://tinobox.com/wordpress/productivity/writing-to-learn-the-open-secret-writers-rarely-write-about/">write to learn</a>, and <a href="http://calnewport.com/blog/2010/01/06/the-grandmaster-in-the-corner-office-what-the-study-of-chess-experts-teaches-us-about-building-a-remarkable-life/">deliberate practice</a> is the only sure <a href="http://www.amazon.com/Mastery-Keys-Success-Long-Term-Fulfillment/dp/0452267560/tinb-20">path to mastery</a>.</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Festimated-reading-time-plugin-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Festimated-reading-time-plugin-2%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/estimated-reading-time-plugin-2/">Estimated Reading Time Plugin : Sharpening the stick (technical tuesday)</a></p>
<div class="shr-publisher-18671"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Festimated-reading-time-plugin-2%2F' data-shr_title='Estimated+Reading+Time+Plugin+%3A+Sharpening+the+stick+%28technical+tuesday%29'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Festimated-reading-time-plugin-2%2F' data-shr_title='Estimated+Reading+Time+Plugin+%3A+Sharpening+the+stick+%28technical+tuesday%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/estimated-reading-time-plugin-2/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Really Fast SEO Slugs with WordPress plugin (Technical Tuesday)</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/really-fast-seo-slugs/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/really-fast-seo-slugs/#comments</comments>
		<pubDate>Tue, 18 May 2010 07:06:28 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Julie Roads]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[Post slug]]></category>
		<category><![CDATA[SEO]]></category>
		<category><![CDATA[Slate]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=18390</guid>
		<description><![CDATA[(Reading time: 12 &#8211; 19 minutes) I was talking to Julie Roads the other day about post slugs, and it occurred to me I haven&#8217;t written on post slugs for quite a while. In fact, while it&#8217;s on my mind, go visit Julie and get yourself some refresh and reload. Now that you&#8217;ve wiped your [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/really-fast-seo-slugs/">Really Fast SEO Slugs with WordPress plugin (Technical Tuesday)</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 12 &#8211; 19 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Freally-fast-seo-slugs%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Freally-fast-seo-slugs%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I was talking to Julie Roads the other day about post slugs, and it occurred to me I haven&#8217;t written on post slugs for quite a while.  In fact, while it&#8217;s on my mind, go visit Julie and get yourself some <a href="http://writingroads.com/blog/2010/05/hard-refresh-wiping-creative-slate-clean/">refresh and reload</a>.</p>
<p>Now that you&#8217;ve wiped your slate clean, let&#8217;s reload it with Stuff You Need To Know. Like post slugs.<br />
<div id="attachment_18470" class="wp-caption alignright" style="width: 185px"><a href="http://website-in-a-weekend.net/wp-content/uploads/2010/05/slate.jpg"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/05/slate.jpg" alt="Writing slate from the 19th century - Interactive Ancient History from Historic Connections" title="slate" width="175" height="241" class="size-full wp-image-18470" /></a><p class="wp-caption-text">Life without paper - Interactive Ancient History from Historic Connections</p></div></p>
<p>Although I discuss post slugs in Blog Post Engineering in some detail, much of what follows is new material. Some of this may go into the next release of <a href="http://website-in-a-weekend.net/building-traffic/publish-blog-post/">Blog Post Engineering</a> as well.</p>
<p>It turns out there exists a spiffy little plugin called &#8220;<a href="http://wordpress.org/extend/plugins/seo-slugs/">SEO Slugs</a>,&#8221; which will: </p>
<ul>
<li>Help you create shorter, keyword-rich slugs using your article title.</li>
<li>Will not automatically change your title, so you have ultimate control (as it should be).</li>
</ul>
<p>The SEO Slugs plugin is very old and hasn&#8217;t been updated in years.  I <em>usually</em> <a href="http://website-in-a-weekend.net/getting-started/wordpress-plugins-how-to-evaluate-which-plugins-you-need-and-which-plugins-to-avoid/">recommend NOT using older plugins</a> (for good reason), but as you will see, there isn&#8217;t anything out of date in SEO Slugs.  (That&#8217;s either a testament to the strength of WordPress design, or an indictment to it&#8217;s lack of innovation. I could argue both sides.  I&#8217;ll spare us all.)</p>
<p>This plugin is cool, because you don&#8217;t really have to do anything, it just works quietly in the background:<br />
<div id="attachment_18431" class="wp-caption aligncenter" style="width: 480px"><a href="http://website-in-a-weekend.net/wp-content/uploads/2010/05/free_post_slug.png"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/05/free_post_slug-470x89.png" alt="SEO Slugs plugin works automatically to remove stopwords" title="free_post_slug" width="470" height="89" class="size-large wp-image-18431" /></a><p class="wp-caption-text">SEO Slugs plugin works automatically to remove stopwords</p></div></p>
<p>Since it&#8217;s (Technical) Tuesday, it&#8217;s a perfect opportunity to get all hard core about it too.  So I&#8217;m going to break this stepwise for you.  You will see how I attack plugin problems, and how this particular plugin works to your benefit.</p>
<h2>SEO Slugs plugin</h2>
<p>First, if code makes your eyes glaze over, just <a href="#breakdown">skip right over</a> to where I break this plugin down one piece at a time.  </p>
<p>Since SEO Slugs is really short, I&#8217;m listing out all 43 lines right here:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">/*
Plugin Name: SEO Slugs
Plugin URI: http://www.vretoolbar.com/news/seo-slugs-wordpress-plugin
Description: Removes common words like 'a', 'the', 'in' from post slugs to improve SEO.
Version: 1.0
Author: Andrei Mikrukov
Author URI: http://www.vretoolbar.com
*/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*
Copyright Andrei Mikrukov 2007
&nbsp;
Licensed under the terms of the GPL version 2, see:
http://www.gnu.org/licenses/gpl.txt
&nbsp;
Provided without warranty, inluding any implied warrant of merchantability or fitness for purpose.
*/</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name_save_pre'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'seo_slugs'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> seo_slugs<span style="color: #009900;">&#40;</span><span style="color: #000088;">$slug</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// We don't want to change an existing slug</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$slug</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$slug</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$seo_slug</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$seo_slug</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&amp;.+?;/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seo_slug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// kill HTML entities</span>
    <span style="color: #666666; font-style: italic;">// kill anything that is not a letter, digit, space or apostrophe</span>
    <span style="color: #000088;">$seo_slug</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[^a-zA-Z0-9 \']/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seo_slug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Turn it to an array and strip common words by comparing against c.w. array</span>
    <span style="color: #000088;">$seo_slug_array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_diff</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seo_slug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> seo_slugs_stop_words<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Turn the sanitized array into a string</span>
    <span style="color: #000088;">$seo_slug</span> <span style="color: #339933;">=</span> <span style="color: #990000;">join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seo_slug_array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$seo_slug</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> seo_slugs_stop_words <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;able&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;about&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;above&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;abroad&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;according&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;accordingly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;across&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;actually&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;adj&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;after&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;afterwards&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;again&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;against&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ago&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ahead&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ain't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;all&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;allow&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;allows&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;almost&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;alone&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;along&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;alongside&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;already&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;also&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;although&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;always&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;am&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;amid&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;amidst&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;among&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;amongst&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;an&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;and&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;another&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;any&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;anybody&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;anyhow&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;anyone&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;anything&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;anyway&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;anyways&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;anywhere&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;apart&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;appear&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;appreciate&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;appropriate&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;are&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;aren't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;around&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;as&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;a's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;aside&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ask&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;asking&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;associated&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;at&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;available&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;away&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;awfully&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;b&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;back&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;backward&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;backwards&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;be&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;became&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;because&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;become&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;becomes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;becoming&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;been&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;before&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;beforehand&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;begin&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;behind&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;being&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;believe&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;below&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;beside&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;besides&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;best&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;better&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;between&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;beyond&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;both&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;brief&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;but&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;by&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;c&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;came&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;can&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;cannot&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;cant&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;can't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;caption&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;cause&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;causes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;certain&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;certainly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;changes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;clearly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;c'mon&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;co&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;co.&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;com&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;come&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;comes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;concerning&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;consequently&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;consider&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;considering&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;contain&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;containing&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;contains&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;corresponding&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;could&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;couldn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;course&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;c's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;currently&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;d&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;dare&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;daren't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;definitely&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;described&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;despite&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;did&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;didn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;different&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;directly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;do&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;does&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;doesn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;doing&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;done&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;don't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;down&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;downwards&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;during&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;e&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;each&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;edu&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;eg&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;eight&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;eighty&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;either&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;else&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;elsewhere&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;end&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ending&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;enough&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;entirely&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;especially&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;et&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;etc&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;even&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ever&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;evermore&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;every&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;everybody&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;everyone&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;everything&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;everywhere&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ex&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;exactly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;example&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;except&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;f&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;fairly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;far&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;farther&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;few&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;fewer&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;fifth&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;first&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;five&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;followed&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;following&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;follows&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;for&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;forever&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;former&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;formerly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;forth&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;forward&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;found&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;four&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;from&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;further&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;furthermore&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;g&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;get&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;gets&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;getting&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;given&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;gives&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;go&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;goes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;going&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;gone&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;got&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;gotten&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;greetings&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;h&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;had&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hadn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;half&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;happens&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hardly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;has&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hasn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;have&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;haven't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;having&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;he&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;he'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;he'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hello&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;help&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hence&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;her&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;here&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hereafter&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hereby&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;herein&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;here's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hereupon&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hers&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;herself&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;he's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hi&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;him&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;himself&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;his&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hither&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hopefully&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;how&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;howbeit&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;however&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;hundred&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;i&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;i'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ie&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;if&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ignored&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;i'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;i'm&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;immediate&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;in&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;inasmuch&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;inc&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;inc.&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;indeed&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;indicate&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;indicated&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;indicates&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;inner&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;inside&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;insofar&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;instead&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;into&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;inward&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;is&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;isn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;it&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;it'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;it'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;its&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;it's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;itself&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;i've&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;j&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;just&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;k&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;keep&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;keeps&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;kept&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;know&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;known&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;knows&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;l&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;last&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lately&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;later&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;latter&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;latterly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;least&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;less&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lest&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;let&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;let's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;like&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;liked&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;likely&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;likewise&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;little&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;look&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;looking&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;looks&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;low&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;lower&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ltd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;m&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;made&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mainly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;make&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;makes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;many&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;may&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;maybe&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mayn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;me&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mean&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;meantime&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;meanwhile&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;merely&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;might&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mightn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mine&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;minus&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;miss&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;more&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;moreover&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;most&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mostly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mr&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mrs&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;much&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;must&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;mustn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;my&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;myself&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;n&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;namely&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;near&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nearly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;necessary&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;need&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;needn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;needs&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;neither&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;never&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;neverf&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;neverless&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nevertheless&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;new&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;next&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nine&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ninety&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;no&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nobody&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;non&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;none&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nonetheless&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;noone&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;no-one&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nor&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;normally&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;not&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nothing&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;notwithstanding&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;novel&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;now&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;nowhere&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;o&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;obviously&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;of&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;off&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;often&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;oh&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ok&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;okay&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;old&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;on&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;once&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;one&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ones&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;one's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;only&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;onto&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;opposite&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;or&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;other&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;others&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;otherwise&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ought&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;oughtn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;our&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ours&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;ourselves&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;out&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;outside&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;over&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;overall&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;own&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;p&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;particular&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;particularly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;past&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;per&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;perhaps&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;placed&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;please&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;plus&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;possible&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;presumably&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;probably&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;provided&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;provides&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;q&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;que&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;quite&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;qv&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;r&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;rather&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;rd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;re&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;really&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;reasonably&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;recent&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;recently&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;regarding&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;regardless&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;regards&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;relatively&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;respectively&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;right&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;round&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;s&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;said&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;same&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;saw&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;say&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;saying&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;says&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;second&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;secondly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;see&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;seeing&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;seem&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;seemed&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;seeming&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;seems&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;seen&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;self&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;selves&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sensible&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sent&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;serious&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;seriously&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;seven&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;several&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;shall&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;shan't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;she&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;she'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;she'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;she's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;should&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;shouldn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;since&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;six&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;so&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;some&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;somebody&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;someday&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;somehow&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;someone&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;something&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sometime&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sometimes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;somewhat&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;somewhere&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;soon&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sorry&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;specified&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;specify&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;specifying&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;still&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sub&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;such&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sup&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sure&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;t&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;take&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;taken&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;taking&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;tell&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;tends&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;th&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;than&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thank&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thanks&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thanx&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;that&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;that'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thats&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;that's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;that've&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;the&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;their&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;theirs&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;them&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;themselves&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;then&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thence&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;there&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thereafter&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thereby&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;there'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;therefore&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;therein&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;there'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;there're&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;theres&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;there's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thereupon&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;there've&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;these&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;they&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;they'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;they'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;they're&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;they've&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thing&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;things&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;think&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;third&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thirty&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;this&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thorough&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thoroughly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;those&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;though&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;three&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;through&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;throughout&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thru&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;thus&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;till&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;to&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;together&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;too&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;took&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;toward&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;towards&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;tried&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;tries&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;truly&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;try&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;trying&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;t's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;twice&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;two&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;u&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;un&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;under&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;underneath&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;undoing&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;unfortunately&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;unless&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;unlike&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;unlikely&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;until&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;unto&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;up&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;upon&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;upwards&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;us&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;use&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;used&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;useful&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;uses&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;using&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;usually&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;v&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;value&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;various&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;versus&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;very&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;via&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;viz&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;vs&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;w&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;want&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wants&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;was&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wasn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;way&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;we&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;we'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;welcome&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;well&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;we'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;went&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;were&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;we're&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;weren't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;we've&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;what&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whatever&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;what'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;what's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;what've&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;when&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whence&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whenever&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;where&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whereafter&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whereas&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whereby&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wherein&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;where's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whereupon&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wherever&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whether&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;which&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whichever&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;while&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whilst&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whither&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;who&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;who'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whoever&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whole&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;who'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whom&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whomever&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;who's&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;whose&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;why&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;will&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;willing&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wish&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;with&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;within&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;without&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wonder&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;won't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;would&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;wouldn't&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;x&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;y&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;yes&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;yet&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;you&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;you'd&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;you'll&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;your&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;you're&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;yours&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;yourself&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;yourselves&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;you've&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;z&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;zero&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Spiffy, right?  I love little pieces of code like this. Pure poetry.</p>
<p>Let&#8217;s prise it apart and ponder it piecewise.</p>
<h2 id="breakdown">Let&#8217;s break it down</h2>
<p>Once again, if you&#8217;re getting queasy, just skip right over this part to get to the <a href="#goodies">goodies at the end</a>.</p>
<p>And once again, why all this trouble?  Couple of reasons: SEO Slugs is very short, so &#8220;Because I can&#8221; is really all the justification I need.  But another, more important reason is that it illustrates a very important and powerful capability of WordPress, in a context that most intermediate WordPress bloggers can understand. That is, <em>you</em>. (<span style="font-size:70%">And that includes you too Mr. El Dorado</span>) </p>
<h3>Start at the beginning&#8230;</h3>
<p>&#8230;which is usually the best place to start.</p>
<p><a href="http://website-in-a-weekend.net/wp-content/uploads/2010/05/paper-filters-cropped.png"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/05/paper-filters-cropped.png" alt="add_filter is a critical WordPress function" title="paper-filters-cropped" width="126" height="83" class="alignright size-full wp-image-18425" /></a></p>
<p>In this case, on line 20 we&#8217;re kicking off with <code>add_filter</code>, one of the top five most important functions in WordPress. Dig into the WordPress code, <code>add_filter</code> is everywhere you look.  Even with relatively benign functions such as <code>register_activation_hook</code>, scratch it deep enough, there&#8217;s a daggone <a href="http://website-in-a-weekend.net/extending-wordpress/reverse-engineering-activation-hook-in-wordpress-plugin-api/#add_filter">add_filter lurking down in the basement</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name_save_pre'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'seo_slugs'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Here&#8217;s what add_filter does: it takes a <em>function</em>, here given by <code>seo_slugs</code> declared on line 22, and adds that function to the list of functions which get called when the <a href="http://adambrown.info/p/wp_hooks/hook/name_save_pre"><code>name_save_pre</code> template</a> is invoked.  That is, when you press &#8220;Save Draft,&#8221; the <code>seo_slugs</code> function processes your article title and emits a <strong>tasty new post slug full of keyword-rich scrumptiousness</strong>.</p>
<p>But suppose you like <em>your</em> post slug.  It&#8217;s quite tasty enough, thank you.  That&#8217;s cool, SEO Slugs will keeps it mitts to itself.  Here&#8217;s proof:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>24
25
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">// We don't want to change an existing slug</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$slug</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$slug</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>All this means is that when you put your own slug in the little box, you get to keep it:<br />
<div id="attachment_18439" class="wp-caption aligncenter" style="width: 480px"><a href="http://website-in-a-weekend.net/wp-content/uploads/2010/05/use_your_own_slug.png"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/05/use_your_own_slug-470x81.png" alt="Use your own post slug." title="use_your_own_slug" width="470" height="81" class="size-large wp-image-18439" /></a><p class="wp-caption-text">Use your own post slug.</p></div></p>
<p>What&#8217;s next&#8230;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$seo_slug</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">stripslashes</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'post_title'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p><code>wpdb</code> is your WordPress database.  It&#8217;s another one of those things that&#8217;s everywhere, you need to make it&#8217;s acquaintance sooner or later.<br />
<a href="http://website-in-a-weekend.net/wp-content/uploads/2010/05/rabbit_hole_150.jpg"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/05/rabbit_hole_150.jpg" alt="" title="Not gonna..." width="150" height="107" class="alignright size-full wp-image-18486" /></a><br />
The next function, <code>strtolower</code> takes your title and turns all your capital letters into lower case letters.  Actually, it takes your title after it does a little magic on it with <code>stripslashes</code>, but let&#8217;s leave that rabbit hole for another day.</p>
<p>Next, if you have some of those cool HTML symbols in your title, like hearts <span class="removed_link" title="http://julieangelos.com/2010/07/16/ㄥ❀∨モ-criticism-♥/">&hearts;s</span> and stuff <span style="font-size:125%;"><a name="interrobang" title="First person telling me what this punctuation mark is, I'll give you a 90% discount on Blog Post Engineering!">&#8253;</a></span>, we have to remove those for the post slug:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>30
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #000088;">$seo_slug</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/&amp;.+?;/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seo_slug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// kill HTML entities</span></pre></td></tr></table></div>

<p><code>preg_replace</code> is easy: Perl-compatible regular expression, replace all matching instances.</p>
<p>You know how I always say, &#8220;Simple, but not easy&#8221;?  Well, <strong>this is easy, but not simple</strong>.  </p>
<p>Let&#8217;s get rid of more cruft people like me put in our blog post titles, like punctation marks, etc.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>31
32
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">// kill anything that is not a letter, digit, space or apostrophe</span>
    <span style="color: #000088;">$seo_slug</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/[^a-zA-Z0-9 \']/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seo_slug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Self-explanatory, if you grok regular expressions. <code>^a-zA-Z0-9</code> means get rid of everything not a through z, A through Z or 0 through 9.  Easy peasy.  (But <em>not</em> simple.)</p>
<p>Here&#8217;s where we get to the good stuff.  Our post slug is all prepped, now it&#8217;s time to strip out the stop words.  Words like &#8220;a&#8221; and &#8220;the&#8221; and &#8220;and&#8221; which are boring and unrankable.  Seriously, trying to rank for the word &#8220;the&#8221; would be pretty hard.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>31
32
33
34
35
36
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">// Turn it to an array and strip common words by comparing against c.w. array</span>
    <span style="color: #000088;">$seo_slug_array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_diff</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">split</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seo_slug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> seo_slugs_stop_words<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// Turn the sanitized array into a string</span>
    <span style="color: #000088;">$seo_slug</span> <span style="color: #339933;">=</span> <span style="color: #990000;">join</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$seo_slug_array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$seo_slug</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Picking up the pace, line 32 matches your title against an array of stop words, and deletes everything in your title that is also in the array.  Line 34 puts it all back together, this is what you see in your permalink after you save or publish your blog post.  Line 36 is the <code>seo_slugs</code> function giving your brand new slug back to WordPress.</p>
<p>And there you have it, the entire SEO Slugs plugin.</p>
<p>Give it try, see what you think. </p>
<p><strong>UPDATE</strong>: Don&#8217;t know why I didn&#8217;t think of this before.</p>
<p><object width="500" height="306"><param name="movie" value="http://www.youtube.com/v/uHXISV9ts-w?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/uHXISV9ts-w?version=3" type="application/x-shockwave-flash" width="500" height="306" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h2 id="goodies">&#8220;Why all this toil and trouble?&#8221;</h2>
<p>That&#8217;s a pretty good question. </p>
<p>In part, <em>I&#8217;m showing you exactly what I do when I teach myself</em>. I just go through the code one line at a time, learn what each line does, then (the hard part) <em>figure out why that line is necessary</em>.</p>
<p>Understanding source code requires an investment of time and mental energy. While I eat this stuff two or three meals per day, it&#8217;s not quite to some people&#8217;s taste, and others are downright allergic to the very notion.</p>
<p>But there are rewards.</p>
<p><a href="https://www.e-junkie.com/ecom/gb.php?c=cart&#038;i=298435&#038;cl=63393&#038;ejc=2"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/05/bpe_cover_125x202.jpg" alt="Blog Post Engineering!" title="There's a copy of Blog Post Engineering, just for you." width="125" height="202" class="alignright size-full wp-image-18473" /></a></p>
<p>One of which is overcoming all fear of WordPress coding.  Well, at least most fear.  There is some <a href="http://markjaquith.wordpress.com/2010/05/14/web-hosts-should-adapt-to-wordpress/#comment-94855">scary sh*t in the WordPress core</a>, but you never need look at that if you just stick to WordPress plugins.  </p>
<p>Knowledge builds on itself incrementally.  Learning a half dozen of the most common functions you find in plugins goes a long way to stomping that learning curve flat.  This is usually irrelevant, I admit, except when it&#8217;s Zero Dark Thirty and your blog is down. And you don&#8217;t know why.  Then knowing a little WordPress seems pretty smart.</p>
<p>In any case, between this article and Blog Post Engineering, you have a grip on post slugs.  Provided you have a grip on Blog Post Engineering&#8230;  <a href="https://www.e-junkie.com/ecom/gb.php?c=cart&#038;i=298435&#038;cl=63393&#038;ejc=2" target="ej_ejc" class="ec_ejc_thkbx" onClick="javascript:return EJEJC_lc(this);"><img src="http://www.e-junkie.com/ej/ej_add_to_cart.gif" border="0" alt="Add to Cart"/></a></p>
<h2 id="lagniappe">Lagniappe</h2>
<p>July 17, 2010, and I&#8217;ve put a full week into the next release of Blog Post Engineering.  Julie Angelos just pinged <a href="http://website-in-a-weekend.net/getting-started/top-10-reasons-wordpress-future-internet/#comment-13966">Top 10 Reasons WordPress is the future of the internet</a>, with a CommentLuv link looking like this:<span class="removed_link" title="http://julieangelos.com/2010/07/16/ㄥ❀∨モ-criticism-♥/">ㄥ❀∨モ criticism ♥</span>.</p>
<p>How could anyone resist that?</p>
<p>Now, I asserted that SEO Slugs removes fancy pants HTML entities, and it does.  But you can still have such beasties in your post slug, just paste them in manually.  </p>
<p>Here&#8217;s proof:<br />
<span class="removed_link" title="http://julieangelos.com/2010/07/16/ㄥ❀∨モ-criticism-♥/"><img src="http://website-in-a-weekend.net/wp-content/uploads/2010/05/hearts-n-stuff-470x54.png" alt="" title="hearts-n-stuff" width="470" height="54" class="aligncenter size-large wp-image-20605" /></span></p>
<p>I have no idea what the effect on SEO is with such a spiffy little post slug.  Neither do I care!  Once in a while, just have some fun tweaking the rules.</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Freally-fast-seo-slugs%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Freally-fast-seo-slugs%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/really-fast-seo-slugs/">Really Fast SEO Slugs with WordPress plugin (Technical Tuesday)</a></p>
<div class="shr-publisher-18390"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Freally-fast-seo-slugs%2F' data-shr_title='Really+Fast+SEO+Slugs+with+WordPress+plugin+%28Technical+Tuesday%29'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Freally-fast-seo-slugs%2F' data-shr_title='Really+Fast+SEO+Slugs+with+WordPress+plugin+%28Technical+Tuesday%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/really-fast-seo-slugs/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Startup Weekend &#8211; Start a brand new business in 56 hours (Saturday Morning Surfing)</title>
		<link>http://website-in-a-weekend.net/extending-wordpress/startup-weekend-start-brand-business-56-hours/</link>
		<comments>http://website-in-a-weekend.net/extending-wordpress/startup-weekend-start-brand-business-56-hours/#comments</comments>
		<pubDate>Sat, 08 May 2010 07:11:06 +0000</pubDate>
		<dc:creator>Dave Doolin</dc:creator>
				<category><![CDATA[Extending WordPress]]></category>
		<category><![CDATA[Statustar]]></category>

		<guid isPermaLink="false">http://website-in-a-weekend.net/?p=17929</guid>
		<description><![CDATA[(Reading time: 3 &#8211; 4 minutes) I&#8217;m sitting here on a Mayday Saturday morning (that is, last weekend) at Paypal Town Center here at eBay central in San Jose California. It&#8217;s another Startup Weekend; Walter and I are building a new business in one weekend. Here&#8217;s the problem we want to solve: Sometimes I want [...]<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/startup-weekend-start-brand-business-56-hours/">Startup Weekend &#8211; Start a brand new business in 56 hours (Saturday Morning Surfing)</a></p>
]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p class="estread return-true">(Reading time: 3 &#8211; 4 minutes)</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fstartup-weekend-start-brand-business-56-hours%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fstartup-weekend-start-brand-business-56-hours%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;m sitting here on a Mayday Saturday morning (that is, last weekend) at Paypal Town Center here at eBay central in San Jose California.</p>
<p>It&#8217;s another Startup Weekend; Walter and I are building a new business in one weekend.</p>
<p>Here&#8217;s the problem we want to solve: </p>
<p><em>Sometimes I want people to contact me directly, sometimes I don&#8217;t.</em></p>
<p>But every application I use, such as Skype, and Gmail, and Facebook has it&#8217;s own status indicator.  Except that some don&#8217;t have status indicators at all (yeah I&#8217;m talking to you, Twitter).</p>
<p>What we want is a <em>global way</em> of letting people know &#8220;I&#8217;m available&#8221; or &#8220;Go &#8216;way.&#8221;</p>
<p>Such that anywhere I&#8217;m at, like Website In A Weekend, or iPhone, or Gmail chat, or Skype, or Facebook (ok, maybe not Facebook &#8217;cause they play by their own rules), I can set my status and it will be set everywhere else.  </p>
<p>&#8220;But, what,&#8221; you ask, &#8220;has this to do with WordPress and blogging?&#8221;</p>
<p>That&#8217;s an excellent question  Let&#8217;s find out.</p>
<h2>What&#8217;s in it for you</h2>
<p>If you had a notion that maybe this &#8220;Weekend Apps&#8221; or &#8220;Startup Weekend&#8221; was somehow related to &#8220;Website In A Weekend,&#8221; you&#8217;d be pretty close to the truth.  </p>
<p>The inspiration for Website In A Weekend came from attending these startup weekends.</p>
<p>It&#8217;s a great model.  In one intensive weekend, you get yourself crammed full of everything you need to get a business going.</p>
<p>Remember my <a href="http://website-in-a-weekend.net/creating-content/week-review-4/">writeup on Foodspotting</a>?  Startup Weekend.</p>
<h2>A disclaimer, of sorts</h2>
<p>I have to be completely honest here&#8230;</p>
<p>A lot of people assume they get weekends off.  As in, every weekend.  </p>
<p>I cannot relate to that.</p>
<p>The only time I&#8217;ve had much in the way of &#8220;weekends off&#8221; was the 4 years in the USMC (except for deployments, which are work every day of course), and a couple of brief stint as a post-graduate researcher.  </p>
<p>Pretty much half my life, weekends have been nice to have off, but not something I could necessarily count on.  When I was working construction, if it rained on Tuesday, we work on Saturday.  Otherwise, lose a day&#8217;s pay.</p>
<p>School?  Part time work to pay the bills, and studying, always.  </p>
<p>So as an entrepreneur, it doesn&#8217;t feel strange at all to work on weekends.  </p>
<p>For me, scheduling an entire weekend to build a brand new application &#8211; or a brand new website &#8211; well, that&#8217;s just how the world is.  And I&#8217;m not the only person working this hard!  I&#8217;m not sure if I feel validated or terrified, but most of the <a href="http://www.dailyblogtips.com/interview-12-top-online-entrepreneurs-share-how-hard-they-work/">people at the top of this blogging craft</a> put in 60+ hours per week!</p>
<h2>What are you doing this weekend?</h2>
<p>To be sure, working on weekends isn&#8217;t everyone&#8217;s cup of tea. </p>
<p>But having a huge block of time which is all yours, that is, time your employer doesn&#8217;t have demands on, really let&#8217;s you focus on the task at hand.  It&#8217;s like getting two weeks work done in two days!</p>
<p>What this means for you: when you&#8217;re ready to buckle down on a Friday evening&#8230; I&#8217;m all in!  We&#8217;ll have you a brand new WordPress site, <em>with all the bells and whistles</em>, by late Sunday afternoon.  You can even go get one of those &#8220;free&#8221; WordPress installs if you like.  I&#8217;m totally cool with that, in fact, I&#8217;d love it if you did because that stuff is boring and having it handled already would be awesome.</p>
<p>Just let me know!</p>
<div class="tweetmeme_button" style="float: left; margin-right: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fstartup-weekend-start-brand-business-56-hours%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fstartup-weekend-start-brand-business-56-hours%2F&amp;source=websiteweekend&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Post from: <a href="http://website-in-a-weekend.net">Website In A Weekend</a><br/><br/><a href="http://website-in-a-weekend.net/extending-wordpress/startup-weekend-start-brand-business-56-hours/">Startup Weekend &#8211; Start a brand new business in 56 hours (Saturday Morning Surfing)</a></p>
<div class="shr-publisher-17929"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:30px;'><a class='shareaholic-fblike' data-shr_layout='button_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fstartup-weekend-start-brand-business-56-hours%2F' data-shr_title='Startup+Weekend+-+Start+a+brand+new+business+in+56+hours+%28Saturday+Morning+Surfing%29'></a><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwebsite-in-a-weekend.net%2Fextending-wordpress%2Fstartup-weekend-start-brand-business-56-hours%2F' data-shr_title='Startup+Weekend+-+Start+a+brand+new+business+in+56+hours+%28Saturday+Morning+Surfing%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://website-in-a-weekend.net/extending-wordpress/startup-weekend-start-brand-business-56-hours/feed/</wfw:commentRss>
		<slash:comments>30</slash:comments>
		</item>
	</channel>
</rss>

