<?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>compu.terlicio.us &#187; Plug-ins</title>
	<atom:link href="http://compu.terlicio.us/tag/plug-ins/feed/" rel="self" type="application/rss+xml" />
	<link>http://compu.terlicio.us</link>
	<description>Flying, Computers, and Food</description>
	<lastBuildDate>Fri, 25 Nov 2011 01:16:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Poor Programming Proliferation</title>
		<link>http://compu.terlicio.us/2009/06/poor-programming-proliferation/</link>
		<comments>http://compu.terlicio.us/2009/06/poor-programming-proliferation/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 20:19:32 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[Coding Practices]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[Rant]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=145</guid>
		<description><![CDATA[It seems, reading the news, that nuclear proliferation will be the end of the world. For a WordPress developer, on the other hand, poor plugin programming seems likely be the end of the world. I rarely take shots at other people online (it seems rather trollish to me), but the sheer horror of Fire Studio&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>It seems, reading the news, that nuclear proliferation will be the end of the world. For a WordPress developer, on the other hand, poor plugin programming seems likely be the end of the world. I rarely take shots at other people online (it seems rather trollish to me), but the sheer horror of <a href="http://fire-studios.com/blog/wordpress-plugin-templates">Fire Studio&#8217;s WordPress Plugin Templates </a>compel me to say something.<br />
<span id="more-145"></span><br />
While I certainly applaud people who make plugin development easier, if one <em>is</em> going to distribute a plugin framework, it should, at the very least, follow the minimum best practices for WordPress programming. Fire Studio&#8217;s WordPress Plugin Templates is an epic fail in this regard. I fall pray to these mistakes from time to time myself, and there may be differences of opinion and style in programming. Nonetheless, as the WordPress Plugin Template is designed to be distributed, I must list out the reasons why NOT to use the WordPress Plugin Templates.</p>
<p><strong>1:</strong> Overuse of the options table:<br />
<code>get_option()</code> and <code>set_option()</code> are wonderfully useful features, if used in moderation. If not used in moderation, they result in a hellish jumble of entries in the wp-options table. Instead of using many discreet entries, an &#8220;options&#8221; object or array should be serialized into a <code>set_option()</code> call. While this <em>may</em> be overkill for a very simple plugin, once you get to any number of options it is a necessity.</p>
<p><strong>2: </strong> No NONCEs<br />
This is such an offensive mistake it makes me cry a little. As <a href="http://compu.terlicio.us/2008/05/stopping-nonces-part-1/">I</a>(and <a href="http://markjaquith.wordpress.com/2006/06/02/wordpress-203-nonces/">Mark Jaquith</a> and <a href="http://www.prelovac.com/vladimir/improving-security-in-wordpress-plugins-using-nonces">Vladimir Prelovac</a> and <a href="http://lorelle.wordpress.com/2009/03/07/firewalling-and-hack-proofing-your-wordpress-blog/">many others</a>) have written, using nonces is a <strong>must</strong> for any plugin which takes options from a user. Strangely enough, the nonce field is included, but then never checked (WTF?). Without the use of nonces, a nefarious user can arbitrarily change your plugin settings, and possibly even take over your database. Particularly if there are</p>
<p><strong>3: </strong> No SQL Injection Security<br />
Not having nonces is one thing. It&#8217;s bad, but I&#8217;ve forgotten from time to time myself. But not even escaping input before putting it in the database is, to quote &#8220;Yahtzee&#8221;, <a href="http://www.splitreason.com/product/582">pants on head retarded</a>!. Escaping user input is probably the single simplest and most basic security. It&#8217;s the last line of defense against people replacing your header image with horrific porn. Don&#8217;t write code without it.</p>
<p><strong>4: </strong> Unnecessary use of <code>global</code> variables<br />
This exists on two levels:<br />
A) In <code>purpose.php</code>, both <code>$wp_query</code> and <code>$post</code> are called into the function via global. While this probably won&#8217;t do any harm, globally including everything everywhere is what made earlier version of php such a nightmare and it looks messy. If you don&#8217;t need a variable, don&#8217;t include it.<br />
B) <code>$var1</code>-<code>$var4</code> are declared to static values at the top of the file where they will clutter up the global namespace. They are never accessed from their global context, they are always <code>get_option()</code>ed. In fact, the only reason they are declared here is so that they can be <code>add_option</code>ed into options. EVERY TIME THE CODE RUNS. That&#8217;s four superfluous function calls every single time the file loads. This should be done once, on plugin install. Not every single time WordPress loads a page.</p>
<p><strong>5: </strong> Include vs. Require<br />
I realize that this is pretty nit-picky, but, when including files that are <strong>required</strong> for the program to function, the appropriate function is <code>require()</code> (or better yet, <code>require_once()</code>. If the file is missing, the code to break while trying to include the file, instead of mysteriously throwing messages about redeclaration of functions.</p>
<p>In conclusion, while the concept of a plugin framework is laudable, Fire Studio&#8217;s implementation falls far short of any reasonable mark of best practices, and only serves to encourage worst practices.</p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2009/06/poor-programming-proliferation/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#181;Audio 0.6.2 Released</title>
		<link>http://compu.terlicio.us/2009/03/audio-062-released/</link>
		<comments>http://compu.terlicio.us/2009/03/audio-062-released/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 05:58:31 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[audio player]]></category>
		<category><![CDATA[micro-audio]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[µAudio]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=127</guid>
		<description><![CDATA[Due to one annoying bug that just missed the 0.6.1 release AND some missing documentation, I decided to push out another update. As always, head over the the &#181;Audio page at WordPress.org or grab a copy from my &#181;Audio page.]]></description>
			<content:encoded><![CDATA[<p>Due to one annoying bug that just missed the 0.6.1 release AND some missing documentation, I decided to push out another update.</p>
<p>As always, head over the the <a href="http://wordpress.org/extend/plugins/microaudio/" title="&micro;Audio at WordPress.org">&micro;Audio page at WordPress.org</a> or grab a copy from my <a href="http://compu.terlicio.us/code/plugins/audio/" title="&micro;Audio at Compu.terlicio.us">&micro;Audio page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2009/03/audio-062-released/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>&#181;Audio 0.6.1 Released</title>
		<link>http://compu.terlicio.us/2009/03/audio-061-released/</link>
		<comments>http://compu.terlicio.us/2009/03/audio-061-released/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 23:53:33 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[audio player]]></category>
		<category><![CDATA[micro-audio]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress.org]]></category>
		<category><![CDATA[µAudio]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=120</guid>
		<description><![CDATA[A minor bug fix release for &#181;Audio is out today. Properly validates at W3C now and fixes a couple little bugs in the css parser. Head over the the &#181;Audio page at WordPress.org or grab a copy from my &#181;Audio page. Those of you waiting for the 0.7 release with the new sidebar widget shouldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>A minor bug fix release for &micro;Audio is out today. Properly validates at W3C now and fixes a couple little bugs in the css parser.</p>
<p>Head over the the <a href="http://wordpress.org/extend/plugins/microaudio/" title="&micro;Audio at WordPress.org">&micro;Audio page at WordPress.org</a> or grab a copy from my <a href="http://compu.terlicio.us/code/plugins/audio/" title="&micro;Audio at Compu.terlicio.us">&micro;Audio page</a>.</p>
<p>Those of you waiting for the 0.7 release with the new sidebar widget shouldn&#8217;t have too much longer to wait. It&#8217;s coming with some major changes to how &micro;Audio handles javascript. There will probably be a 0.6.2 release in the next week or so to fix any lingering bugs with the current implementation, and then 0.7 will have the new code.</p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2009/03/audio-061-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#181;Audio 0.6 Released</title>
		<link>http://compu.terlicio.us/2009/01/audio-06-released/</link>
		<comments>http://compu.terlicio.us/2009/01/audio-06-released/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 22:56:43 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[audio player]]></category>
		<category><![CDATA[micro-audio]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[µAudio]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=108</guid>
		<description><![CDATA[Well, at long last it&#8217;s here, &#181;Audio version 0.6. This releases brings a bunch of changes, including support for css skinning, much improved javascript, a complete removal of all browser dependant code and a smaller basic install (just 450 Bytes). Head on over to WordPress.org or grab a copy from my &#181;Audio Page.]]></description>
			<content:encoded><![CDATA[<p>Well, at long last it&#8217;s here, &micro;Audio version 0.6. This releases brings a bunch of changes, including support for css skinning, much improved javascript, a complete removal of all browser dependant code and a smaller basic install (just 450 Bytes).</p>
<p>Head on over to <a href="http://wordpress.org/extend/plugins/microaudio/">WordPress.org</a> or grab a copy from my <a href="http://compu.terlicio.us/code/plugins/audio/">&micro;Audio Page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2009/01/audio-06-released/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#181;Mint 0.4 Released</title>
		<link>http://compu.terlicio.us/2008/12/mint-04-released/</link>
		<comments>http://compu.terlicio.us/2008/12/mint-04-released/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 01:20:56 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[micro-mint]]></category>
		<category><![CDATA[mint]]></category>
		<category><![CDATA[mint API]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress.org]]></category>
		<category><![CDATA[µMint]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=106</guid>
		<description><![CDATA[Just in time for WordPress 2.7, µMint 0.4. New Dashboard Widget Better number formatting 2.7 Compatible Mosey over to the &#181;Mint page at wordpress.org or grab a copy from my &#181;Mint page.]]></description>
			<content:encoded><![CDATA[<p>Just in time for WordPress 2.7, µMint 0.4.</p>
<ul>
<li>New Dashboard Widget</li>
<li>Better number formatting</li>
<li>2.7 Compatible</li>
</ul>
<p>Mosey over to the <a title="&micro;Mint at WordPress.org" href="http://wordpress.org/extend/plugins/micromint/">&micro;Mint page at wordpress.org</a> or grab a copy from my <a title="&micro;Mint at Compu.terlicio.us" href="http://compu.terlicio.us/code/plugins/mint/">&micro;Mint</a> page.</p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2008/12/mint-04-released/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Announcing &#181;Mint</title>
		<link>http://compu.terlicio.us/2008/10/announcing-mint/</link>
		<comments>http://compu.terlicio.us/2008/10/announcing-mint/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 02:43:00 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[Ramblings]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[announcements]]></category>
		<category><![CDATA[micro-mint]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[µMint]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=83</guid>
		<description><![CDATA[I am happy to announce the release of a new plugin today: µMint. Like my other µ plugins, it&#8217;s a small, lightweight plugin to (hopefully) do something useful. In this case, µMint allows you to painlessly integrate Shaun Inman&#8217;s Mint into WordPress. Unlike the currently existent solution, µMint does not make use of iframes. Instead, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://compu.terlicio.us/wp-content/uploads/2008/10/mm_sidebar1.jpg" style="float: left; padding: 4px;"><img class="size-medium wp-image-85" title="µMint Sidebar Widget" src="http://compu.terlicio.us/wp-content/uploads/2008/10/mm_sidebar1.jpg" alt="µMint Sidebar" width="141" height="149" /></a></p>
<p>I am happy to announce the release of a new plugin today: µMint. Like my other µ plugins, it&#8217;s a small, lightweight plugin to (hopefully) do something useful. In this case, µMint allows you to painlessly integrate <a title="Mint Gardener" href="http://www.shauninman.com/">Shaun Inman&#8217;s</a> <a href="http://haveamint.com">Mint</a> into WordPress. Unlike the currently existent solution, µMint does not make use of iframes. Instead, µMint is designed to work with both the <a href="http://84degrees.com/expose/">Exposé API</a>, by <a href="http://84degrees.com">Adam Livesley</a> as well as the included API, µAPI for Mint. Furthermore, there is a development version of a connector whcih allows WordPress to directly query Mint, when the two share a database.</p>
<p>µAPI does more than just get your stats, it displays them for you. You can have your choice of a sidebar widget, a dashboard widget, or both. And, in the µ plugin philosophy, stats are cached periodically to reduce the number of API calls required.</p>
<p>I think that µAPI neatly bridges the gap between Mint and WordPress, and I hope you&#8217;ll <a href="http://compu.terlicio.us/code/plugins/mint/">give it a try</a>.</p>
<div id="attachment_84" class="wp-caption alignright" style="width: 508px"><a href="http://compu.terlicio.us/wp-content/uploads/2008/10/mm_dashboard.jpg"><img class="size-full wp-image-84" title="µMint Dashboard" src="http://compu.terlicio.us/wp-content/uploads/2008/10/mm_dashboard.jpg" alt="µMint for WordPress Dashboard" width="498" height="321" /></a><p class="wp-caption-text">µMint for WordPress Dashboard</p></div>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2008/10/announcing-mint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>&#181;Mint 0.3 Released</title>
		<link>http://compu.terlicio.us/2008/10/mint-03-released/</link>
		<comments>http://compu.terlicio.us/2008/10/mint-03-released/#comments</comments>
		<pubDate>Mon, 13 Oct 2008 02:15:12 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[dashboard widget]]></category>
		<category><![CDATA[micro-mint]]></category>
		<category><![CDATA[mint]]></category>
		<category><![CDATA[mint API]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[statistics]]></category>
		<category><![CDATA[widget]]></category>
		<category><![CDATA[µAPI]]></category>
		<category><![CDATA[µMint]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=79</guid>
		<description><![CDATA[I know that there have been a couple of people waiting for this, so I&#8217;ve finally finished my &#181;Mint plugin (at least to a mostly stable state). You can get a version from my &#181;Mint Page. Installation Instructions.]]></description>
			<content:encoded><![CDATA[<p>I know that there have been a couple of people waiting for this, so I&#8217;ve finally finished my &micro;Mint plugin (at least to a mostly stable state).</p>
<p>You can get a version from my<a href="http://compu.terlicio.us/code/plugins/mint/"> &micro;Mint Page</a>.</p>
<p>Installation Instructions.</p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2008/10/mint-03-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#181;Audio 0.5 Released</title>
		<link>http://compu.terlicio.us/2008/10/audio-05-released/</link>
		<comments>http://compu.terlicio.us/2008/10/audio-05-released/#comments</comments>
		<pubDate>Sun, 05 Oct 2008 07:16:07 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[audio player]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[micro-audio]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[wordpress.org]]></category>
		<category><![CDATA[µAudio]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=72</guid>
		<description><![CDATA[A new, improved and super shrunk 0.5 branch is out. Check out my µAudio page, or head over to µAudio at wordpress.org for a copy of your very own. And yes, screenshot 5 is real, the minimal installation is just 495 Bytes! Thanks for all you patience.]]></description>
			<content:encoded><![CDATA[<p>A new, improved and super shrunk 0.5 branch is out. Check out <a href="http://compu.terlicio.us/code/plugins/audio/">my µAudio page</a>, or head over to <a href="http://wordpress.org/extend/plugins/microaudio/">µAudio at wordpress.org</a> for a copy of your very own.</p>
<p>And yes, <a href="http://wordpress.org/extend/plugins/microaudio/screenshots/">screenshot 5</a> is real, the minimal installation is just 495 Bytes!</p>
<p>Thanks for all you patience.</p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2008/10/audio-05-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stopping nonces with WordPress NONCE: Part 1 &#8212; Basic Nonce Usage</title>
		<link>http://compu.terlicio.us/2008/05/stopping-nonces-part-1/</link>
		<comments>http://compu.terlicio.us/2008/05/stopping-nonces-part-1/#comments</comments>
		<pubDate>Sat, 03 May 2008 22:19:01 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=49</guid>
		<description><![CDATA[In the introduction, I provided a brief overview of Numbers used ONCE (nonce) and how they are implemented in WordPress. In this part, I&#8217;ll introduce you to creating and verifying a nonce. To get started with WordPress nonces, we need a plugin administration page. To make life easier for the budding developer, I&#8217;ve created a [...]]]></description>
			<content:encoded><![CDATA[<p>In the introduction, I provided a brief overview of Numbers used ONCE (nonce) and how they are implemented in WordPress. In this part, I&#8217;ll introduce you to creating and verifying a nonce.</p>
<p><span id="more-49"></span></p>
<p>To get started with WordPress nonces, we need a plugin administration page. To make life easier for the budding developer, I&#8217;ve created a basic plugin called &#8220;WP Nonce Playground.&#8221; (<a rel="nofollow" title="Download version Part 1 of wpn.part1.zip" href="http://compu.terlicio.us/downloads/tutorials/wpn/wpn.part1.zip">'WP Nonce Playground: Part 1'</a>). Upload and activate the plugin. Under &#8220;Settings&#8221; you will have a new tab: &#8220;WP Nonce&#8221;. On this screen you can set a check box and some text.</p>
<p>Unfortunately, this is not really secure, because it doesn&#8217;t check any credentials. Lets add some. To create a nonce, we&#8217;ll be using the <code>wp_create_nonce($action)</code> function. The <code>$action</code> parameter is optional, but without it the system is not nearly as secure. <code>$action</code> is a string, and you should create a unique <code>$action</code> for each different action which you will create</p>
<p>Open up wpn.admin.php. On line 61, add:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;input name=&quot;wpn-update_settings&quot; type=&quot;hidden&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> wp_create_nonce<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wpn-update_setting'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></div>

<p>This creates a hidden form field with the name <code>wpn-update_settings</code> and places a custom nonce in the value field. If you save the page, refresh, and examine the source, you&#8217;ll see the nonce in a hidden form field down at the bottom. Of course, we&#8217;re not actually checking it right now, so it&#8217;s not much use at the moment.</p>
<p>It&#8217;s easy enough to start checking the nonce, however. We use the companion to the <code>wp_create_nonce($action)</code> function, <code>wp_verify_nonce($nonce, $action)</code>. Like <code>wp_create_nonce</code>, <code>wp_verify_nonce</code> does not explicitly require the <code>$action</code> parameter, however, whatever <code>$action</code> parameter was used to create the nonce must also be used for successful verification.</p>
<p>Back to wpn.admin.php. Replace lines 13 and 14 with:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wpn-update_settings'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hmm ..., looks like you didn't send any credentials&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>wp_verify_nonce<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'wpn-update_settings'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'wpn-update_settings'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Hmm ..., looks like you didn't send the right credentials&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Go ahead and save the page. Visit it and update the options.</p>
<p>Well, that didn&#8217;t work! If you copied and pasted exactly what I wrote above, you get the error:</p>
<blockquote><p>Hmm &#8230;, looks like you didn&#8217;t send the right credentials</p></blockquote>
<p>The eagle eyed among you will notice that on line 61, we created a nonce with the <code>$action</code> of &#8216;wp-update-setting&#8217;, but everywhere else, including in <code>wp_verify_nonce</code>, we used &#8216;wp-update-setting<em><strong>s</strong></em>&#8216;.</p>
<p>Update wpn.admin.php, line 61 to:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;input name=&quot;wpn-update_settings&quot; type=&quot;hidden&quot; value=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> wp_create_nonce<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wpn-update_settings'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; /&gt;</pre></div></div>

<p>Lo and behold, it works!</p>
<p>If your wpn.admin.php isn&#8217;t working, a working version with all the changes made in the part is also in the plugin folder at wpn.admin.final.php. You can rename this to wpn.admin.php to make the plugin work.</p>
<h3>More:</h3>
<ul>
<li><a href="http://compu.terlicio.us/2008/05/stopping-nonces-part-0/">Part 0 &#8212; Background</a></li>
<li><strong>Part 1 &#8212; Basic Nonce Usage</strong></li>
</ul>
<p><a href="http://compu.terlicio.us/tutorials/wpn">WordPress Nonce Tutorial Home</a></p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2008/05/stopping-nonces-part-1/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Stopping nonces with a WordPress NONCE: Part 0 &#8212; Background</title>
		<link>http://compu.terlicio.us/2008/05/stopping-nonces-part-0/</link>
		<comments>http://compu.terlicio.us/2008/05/stopping-nonces-part-0/#comments</comments>
		<pubDate>Sat, 03 May 2008 21:03:39 +0000</pubDate>
		<dc:creator>Christopher O'Connell</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[hacking]]></category>
		<category><![CDATA[Plug-ins]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://compu.terlicio.us/?p=48</guid>
		<description><![CDATA[It is with depressing frequency that blogs get hacked. Even with relatively secure software, like WordPress, it happens all to often. The ability to create plugins, and moreover, the recent fascination with adding AJAX type interfaces to the WordPress administration areas has resulted in a proliferation of ‘unsafe’ plugins which have the potential to provide [...]]]></description>
			<content:encoded><![CDATA[<p>It is with depressing frequency that blogs get hacked. Even  with relatively secure software, like WordPress, it happens all to often. The  ability to create plugins, and moreover, the recent fascination with adding  AJAX type interfaces to the WordPress administration areas has resulted in a  proliferation of ‘unsafe’ plugins which have the potential to provide  unfettered access to hackers.</p>
<p>Fortunately, WordPress supports Numbers used ONCE (nonce) as  a way of keeping nonces (pedophiles, hackers, and people who talk at the  theater) out. Follow along as I show you how to keep your plugin from being the  door to hackers.<br />
<span id="more-48"></span><br />
Since early in the version 2 branch wordpress has supported  nonces, unfortunately, the resources on using them effectively are all too  scarce. In actuality, they are quite easy and simple to use.</p>
<p>According to Wikipedia, a <a title="Crytographic nonce" href="http://en.wikipedia.org/wiki/Cryptographic_nonce">Crytographic nonce</a>:</p>
<blockquote><p>[Is] a <a title="Randomness" href="http://en.wikipedia.org/wiki/Randomness">random</a> or <a title="Pseudo-random" href="http://en.wikipedia.org/wiki/Pseudo-random">pseudo-random</a> number issued in an <a title="Authentication protocol" href="http://en.wikipedia.org/wiki/Authentication_protocol">authentication protocol</a> to ensure that old communications cannot be reused in <em><a title="Replay attack" href="http://en.wikipedia.org/wiki/Replay_attack">replay attacks</a></em>. &#8230; To ensure that a nonce is used only once, it should be time-variant (including a suitably granular <a title="Timestamp" href="http://en.wikipedia.org/wiki/Timestamp">timestamp</a> in its value), or generated with enough random bits to ensure a  probabilistically insignificant chance of repeating a previously  generated value.</p></blockquote>
<p>In WordPress terms, a nonce is either an <a title="HMAC at Wikipedia" href="http://en.wikipedia.org/wiki/HMAC">md5 HMAC</a> or a plain <a title="MD5 at Wikipedia" href="http://en.wikipedia.org/wiki/MD5">md5</a> hash. In general a WP nonce is valid for twelve hours but expires after 24 hours. Thus the current <em>or</em> previous nonce may both be used. While the <code>wp_generate_nonce($action)</code> function includes several internal components to make the nonce more secure, it also allows the developer to specify an <em>action</em> for the nonce. An action is simply a string which is included in the hash calculation. By creating a separate action for each edit page, etc., a hacker needs to intercept the nonce specific to the action they wish to perform. Thus, even if they intercept a nonce, there is only one (or a very limited number) of nefarious actions which they can perform.</p>
<h3>More:</h3>
<ul>
<li><strong>Part 0 &#8212; Background</strong></li>
<li><a href="http://compu.terlicio.us/2008/05/stopping-nonces-part-1/">Part 1 &#8212; Basic Nonce Usage</a></li>
</ul>
<p><a href="http://compu.terlicio.us/tutorials/wpn">WordPress Nonce Tutorial Home</a></p>
]]></content:encoded>
			<wfw:commentRss>http://compu.terlicio.us/2008/05/stopping-nonces-part-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

