<?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>Blue Anvil Journal &#187; widgets</title>
	<atom:link href="http://blue-anvil.com/tag/widgets/feed/" rel="self" type="application/rss+xml" />
	<link>http://blue-anvil.com</link>
	<description>The online blogfolio of Mike Jolley</description>
	<lastBuildDate>Fri, 03 Dec 2010 18:16:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>WordPress Sidebar Login 2 &#8211; Optimised for wordpress 2.6</title>
		<link>http://blue-anvil.com/archives/wordpress-sidebar-login-2-optimised-for-wordpress-26/</link>
		<comments>http://blue-anvil.com/archives/wordpress-sidebar-login-2-optimised-for-wordpress-26/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 11:44:26 +0000</pubDate>
		<dc:creator>Mike Jolley</dc:creator>
				<category><![CDATA[Wordpress & plugins]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[login widget]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[sidebar]]></category>
		<category><![CDATA[widgets]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blue-anvil.com/?p=127</guid>
		<description><![CDATA[At last! My sidebar login widget has evolved into &#8216;Sidebar Login&#8217; which has both a widget and a template tag to allow you to have a login form in the sidebar of your wordpress powered blog. It lets users login, and then redirects them back to the page they logged in from rather than the [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blue-anvil.com/img/sidebarlogin.jpg" class="floatleft" style="float:left;margin:0 4px 2px 0;" alt="Sidebar Login 2" />At last! My sidebar login widget has evolved into &#8216;Sidebar Login&#8217; which has both a widget and a template tag to allow you to have a login form in the sidebar of your wordpress powered blog.</p>
<p>It lets users login, and then redirects them back to the page they logged in from rather than the backend, it also shows error messages. Read more for more information and the download link.</p>
<p><span id="more-127"></span></p>
<h2>Sidebar Login</h2>
<p>Sidebar login is self explanatory really; it allows users to login to wordpress from the sidebar! This plugin requires wordpress 2.6 (that is all I have tested) in order to function; this is because wordpress 2.6 has a modified login system to older versions.</p>
<h3>Screenshots</h3>
<div id="attachment_135" class="wp-caption aligncenter" style="width: 188px"><img src="http://blue-anvil.com/wp-content/uploads/2008/07/wid1.gif" alt="Login Form" title="Login Form" width="178" height="205" class="size-full wp-image-135" /><p class="wp-caption-text">Login Form</p></div>
<div id="attachment_134" class="wp-caption aligncenter" style="width: 105px"><img src="http://blue-anvil.com/wp-content/uploads/2008/07/wid2.gif" alt="Logged in" title="Logged in" width="95" height="79" class="size-full wp-image-134" /><p class="wp-caption-text">Logged in</p></div>
<h2>Change Log</h2>
<p>You can track changes to the plugin in the <a href="http://plugins.trac.wordpress.org/log/sidebar-login">wordpress plugin SVN</a>.</p>
<h2>Get it now!</h2>
<p>You can get the latest version from the wordpress plugin database; <a href="http://wordpress.org/extend/plugins/sidebar-login/">Download it here!</a></p>
<p><p style="text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-6928386133078955";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "444444";
google_color_text = "444444";
google_color_url = "444444";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p></p>
<h2>Installation Instructions</h2>
<ol>
<li>Unzip and upload the php file to your wordpress plugin directory</li>
<li>Activate the plugin</li>
<li><strong>For a sidebar widget:</strong> Goto the design > widgets tab &#8211; Drag the widget into a sidebar and save!</li>
<li><strong>To use the template tag:</strong> Add <code>&lt;?php sidebarlogin(); ?&gt;</code> to your template.</li>
</ol>
<h2>License</h2>
<p>WordPress Sidebar Login &copy; Copyright 2008-current. <a href="http://www.blue-anvil.com/">Mike Jolley</a></p>
<p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.<br />
optimised </p>
<p>You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA</p>
<h2>Show your support &#8211; ensure continued development</h2>
<p>I put a lot of effort into all of my plugins; its thirsty work so why not show your support by buying me a nice coffee <img src='http://blue-anvil.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blue-anvil.com/archives/wordpress-sidebar-login-2-optimised-for-wordpress-26/feed/</wfw:commentRss>
		<slash:comments>358</slash:comments>
		</item>
		<item>
		<title>WordPress Sidebar Login Widget Update</title>
		<link>http://blue-anvil.com/archives/wordpress-sidebar-login-widget-update/</link>
		<comments>http://blue-anvil.com/archives/wordpress-sidebar-login-widget-update/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 11:05:45 +0000</pubDate>
		<dc:creator>Mike Jolley</dc:creator>
				<category><![CDATA[Wordpress & plugins]]></category>
		<category><![CDATA[login widget]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[sidebar]]></category>
		<category><![CDATA[widgets]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blue-anvil.com/archives/wordpress-sidebar-login-widget-update</guid>
		<description><![CDATA[This plugin has now been replaced by an updated version which you can find here A number of users were experiencing errors with the sidebar login widget I created, issues such as bugs with cookies and headers sent. In a bid to stop these errors I have created a new version, compatible with wordpress 2.3. [...]]]></description>
			<content:encoded><![CDATA[<p>This plugin has now been replaced by an updated version which you can find <a href="http://blue-anvil.com/archives/wordpress-sidebar-login-2-optimised-for-wordpress-26">here</a></p>
<hr/>
<p><img src="http://blue-anvil.com/img/swid.gif" class="floatleft" style="float:left;margin:0 4px 2px 0;" alt="Sidebar Login Widget" />A number of users were experiencing errors with the sidebar login widget I created, issues such as bugs with cookies and headers sent. In a bid to stop these errors I have created a new version, compatible with wordpress 2.3.</p>
<p>This version is different to the others because rather than redirecting to the normal wordpress login page to log the user in, it has the code for login built into it, thus (in theory) solving the cookie/headers problems. Hoorar. Read more about the widget after the break.</p>
<p><span id="more-106"></span></p>
<p>This clever little widget lets users login from the sidebar, without even touching the wordpress login page. Very handy. The <a href="http://blue-anvil.com/archives/a-wordpress-login-widget-sidebar-login-widget-v10">official post is here.</a> Enjoy =)</p>
<h2>Download</h2>
<p class="center img"><a class="downloadlink dlimg" href="http://blue-anvil.com/download/sidebarLogin.zip" title="Version 1.55 downloaded 16749 times" ><img src="http://blue-anvil.com/wp-content/plugins/download-monitor/img/download.gif" alt="Download Sidebar Login Widget Version 1.55" /></a></p>
<p><p style="text-align:center"><script type="text/javascript"><!--
google_ad_client = "pub-6928386133078955";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = "468x60_as";
google_ad_type = "text_image";
google_ad_channel = "";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "444444";
google_color_text = "444444";
google_color_url = "444444";
//-->
</script>
<script type="text/javascript"
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p></p>
<h2>Show your support</h2>
<p class="center">
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick" />
<input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but21.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
            <img alt="" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1" /></p>
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----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-----END PKCS7-----" />
</form></p>
]]></content:encoded>
			<wfw:commentRss>http://blue-anvil.com/archives/wordpress-sidebar-login-widget-update/feed/</wfw:commentRss>
		<slash:comments>41</slash:comments>
		</item>
		<item>
		<title>The great wordpress plugin update extravaganza of the year</title>
		<link>http://blue-anvil.com/archives/the-great-wordpress-plugin-update-extravaganza-of-the-year/</link>
		<comments>http://blue-anvil.com/archives/the-great-wordpress-plugin-update-extravaganza-of-the-year/#comments</comments>
		<pubDate>Sat, 08 Dec 2007 01:21:07 +0000</pubDate>
		<dc:creator>Mike Jolley</dc:creator>
				<category><![CDATA[Wordpress & plugins]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[download monitor]]></category>
		<category><![CDATA[downloads]]></category>
		<category><![CDATA[login widget]]></category>
		<category><![CDATA[monitor]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[spam]]></category>
		<category><![CDATA[spam stopper]]></category>
		<category><![CDATA[widgets]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blue-anvil.com/archives/the-great-wordpress-plugin-update-extravaganza-of-the-year</guid>
		<description><![CDATA[Be honest, the title got you excited right? Anyhow&#8230;three of my wordpress plugins have been neglected of late so I have taken some time to do some bug fixing, add some new features, and get them working with wordpress 2.3. These three are Download monitor, Comment spam stopper, and sidebar login widget. WordPress Download Monitor [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blue-anvil.com/img/updated.gif" class="floatleft" style="float:left;margin:0 4px 2px 0;" alt="Plugin Updates" />Be honest, the title got you excited right? Anyhow&#8230;three of my wordpress plugins have been neglected of late so I have taken some time to do some bug fixing, add some new features, and get them working with wordpress 2.3. These three are Download monitor, Comment spam stopper, and sidebar login widget.</p>
<p><span id="more-103"></span></p>
<h2>WordPress Download Monitor 1.6</h2>
<p>The download monitor lets you upload files to let your visitors download, whilst tracking hits, and letting you easily output the download links in posts.</p>
<p>The 1.6 release has numerous bug fixes, and is fully compatible with wordpress 2.3.</p>
<p><a href="http://blue-anvil.com/archives/wordpress-download-monitor-plugin-v15">Dedicated official page is here.</a></p>
<p class="center"><img src='http://blue-anvil.com/wp-content/uploads/2007/12/dm_small.jpg' class="border" alt='Download monitor screenshot' /></p>
<p class="center"><a class="downloadlink dlimg" href="http://blue-anvil.com/download/download-monitor.3.1.zip" title="Version 3.x downloaded 70814 times" ><img src="http://blue-anvil.com/wp-content/plugins/download-monitor/img/download.gif" alt="Download Download Monitor Version 3.x" /></a></p>
<h2>WordPress Comment spam stopper</h2>
<p>The comment spam stopper plugin adds a simple question to the comment form to stop bots from posting junk comments. Very handy.</p>
<p>This release fixes the bug that made the comment disappear when clicking the back button. For some reason it happened when the anti-spam question was above the comment textarea, so I have moved the spam question below the comment form to fix.</p>
<p><a href="http://blue-anvil.com/archives/wordpress-comment-spam-stopper-plugin">Dedicated official page is here.</a></p>
<p class="center"><a class="downloadlink dlimg" href="http://blue-anvil.com/download/spam-stopper.3.0.2.zip" title="Version 3.x downloaded 3020 times" ><img src="http://blue-anvil.com/wp-content/plugins/download-monitor/img/download.gif" alt="Download Wordpress Comment Spam Stopper Version 3.x" /></a></p>
<p><!--adsense--></p>
<h2>Sidebar login widget</h2>
<p class="clearfix"><img src='http://blue-anvil.com/wp-content/uploads/2007/12/wid1.gif' alt='Sidebar login in action' class="floatleft border" /> This plugin allows users to login to wordpress from the sidebar, as well as providing links to register.</p>
<p>In wordpress 2.3 some people noticed a cookie bug, I believe this is now fixed.</p>
<p><a href="http://blue-anvil.com/archives/a-wordpress-login-widget-sidebar-login-widget-v10">Dedicated official page is here.</a></p>
<p class="center"><a class="downloadlink dlimg" href="http://blue-anvil.com/download/sidebarLogin.zip" title="Version 1.55 downloaded 16749 times" ><img src="http://blue-anvil.com/wp-content/plugins/download-monitor/img/download.gif" alt="Download Sidebar Login Widget Version 1.55" /></a></p>
<p><!--adsense--></p>
]]></content:encoded>
			<wfw:commentRss>http://blue-anvil.com/archives/the-great-wordpress-plugin-update-extravaganza-of-the-year/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>A WordPress Login Widget &#8211; Sidebar Login Widget</title>
		<link>http://blue-anvil.com/archives/a-wordpress-login-widget-sidebar-login-widget-v10/</link>
		<comments>http://blue-anvil.com/archives/a-wordpress-login-widget-sidebar-login-widget-v10/#comments</comments>
		<pubDate>Sat, 11 Aug 2007 01:19:38 +0000</pubDate>
		<dc:creator>Mike Jolley</dc:creator>
				<category><![CDATA[Wordpress & plugins]]></category>
		<category><![CDATA[login widget]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[sidebar]]></category>
		<category><![CDATA[widgets]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://82.110.105.91/blue-anvil.co.uk/?p=90</guid>
		<description><![CDATA[This plugin has now been replaced by an updated version which you can find here Want to allow users to log into wordpress from the sidebar? Doing so is not as simple as it sounds, so to ease your stress I have created a widget to handle everything. It lets users login, and then redirects [...]]]></description>
			<content:encoded><![CDATA[<p>This plugin has now been replaced by an updated version which you can find <a href="http://blue-anvil.com/archives/wordpress-sidebar-login-2-optimised-for-wordpress-26">here</a></p>
<hr/>
<p><img src="http://blue-anvil.com/img/swid.gif" class="floatleft" style="float:left;margin:0 4px 2px 0;" alt="Sidebar Login Widget" />Want to allow users to log into wordpress from the sidebar? Doing so is not as simple as it sounds, so to ease your stress I have created a widget to handle everything.</p>
<p>It lets users login, and then redirects them back to the page they logged in from rather than the backend, it also shows error messages. Read more for more information and the download link.</p>
<p><span id="more-90"></span></p>
<h2>Sidebar Login Widget v1.5 Build 20070122</h2>
<p>By <strong>Mike Jolley</strong> (<a href=" http://www.blue-anvil.com/"> http://www.blue-anvil.com</a> )</p>
<h2>What is it?</h2>
<p>It&#8217;s a widget that allows users to login to wordpress from the sidebar! It uses php sessions to cleverly retrieve the wordpress login error messages, and uses redirects to send the user back to the site, rather than the wordpress backend.</p>
<h3>Screenshots</h3>
<p>User not logged in:</p>
<p class="center"><img src='http://blue-anvil.com/wp-content/uploads/2007/08/wid1.gif' alt='Not logged in screenshot.gif' /></p>
<p>User logged in:</p>
<p class="center"><img src='http://blue-anvil.com/wp-content/uploads/2007/08/wid2.gif' alt='Logged in screenshot.gif' /></p>
<p>Errors!</p>
<p class="center"><img src='http://blue-anvil.com/wp-content/uploads/2007/08/wid3.gif' alt='Error! Screenshot.gif' /></p>
<p><a name="download"></a></p>
<h2>Get it now!</h2>
<p class="center img"><a class="downloadlink dlimg" href="http://blue-anvil.com/download/sidebarLogin.zip" title="Version 1.55 downloaded 16749 times" ><img src="http://blue-anvil.com/wp-content/plugins/download-monitor/img/download.gif" alt="Download Sidebar Login Widget Version 1.55" /></a></p>
<p style="text-align:right;"><small>| <a href="#index">Index</a> |</small></p>
<p><!--adsense--></p>
<p><a name="install"></a></p>
<h2>Installation Instructions</h2>
<p>Simply:</p>
<ol>
<li>Unzip and upload the php file to your wordpress plugin directory</li>
<li>Activate the plugin</li>
<li>Goto the presentation > widgets tab</li>
<li>Drag the widget into a sidebar and save!</li>
</ol>
<p style="text-align:right;"><small>| <a href="#index">Index</a> |</small></p>
<p><a name="lic"></a></p>
<h2>License</h2>
<p>WordPress Sidebar Login Widget &copy; Copyright 2007-current.<br />
<a href="http://www.blue-anvil.com/">Mike Jolley</a></p>
<p><!--adsense#postad--></p>
<p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p>
<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.</p>
<p>You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA</p>
<p style="text-align:right;"><small>| <a href="#index">Index</a> |</small></p>
<p><a name="support"></a></p>
<h2>Support my sweat, blood and tears</h2>
<p>I know, that sounds gross, but we really did put <strong>ALOT</strong> of effort into this widget. If you like this widget please make a donation via paypal! Any amounts are welcome, your support is much appreciated.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="9582380">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_GB/i/scr/pixel.gif" width="1" height="1"><br />
</form>
<p style="text-align:right;"><small>| <a href="#index">Index</a> |</small></p>
]]></content:encoded>
			<wfw:commentRss>http://blue-anvil.com/archives/a-wordpress-login-widget-sidebar-login-widget-v10/feed/</wfw:commentRss>
		<slash:comments>120</slash:comments>
		</item>
		<item>
		<title>Create a WordPress Recent-Posts Widget</title>
		<link>http://blue-anvil.com/archives/create-a-wordpress-recent-posts-widget/</link>
		<comments>http://blue-anvil.com/archives/create-a-wordpress-recent-posts-widget/#comments</comments>
		<pubDate>Thu, 17 May 2007 01:14:59 +0000</pubDate>
		<dc:creator>Mike Jolley</dc:creator>
				<category><![CDATA[Wordpress & plugins]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[recent posts]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[widgets]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://82.110.105.91/blue-anvil.co.uk/?p=69</guid>
		<description><![CDATA[Widgets are a cool new feature built into wordpress version 2.2, and allow you to drag mini plugins into your widget-enabled theme&#8217;s sidebars. They have all kinds of uses, searches, polls, you name it. This article will show you how to create a customisable Recent post widget for yourself. Step 1 &#8211; Creating the file [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blue-anvil.com/img/wid.jpg" class="floatleft" style="float:left;margin:4px 4px 4px 0;" alt="Wordpress Widgets" />Widgets are a cool new feature built into wordpress version 2.2, and allow you to drag mini plugins into your widget-enabled theme&#8217;s sidebars.</p>
<p>They have all kinds of uses, searches, polls, you name it.</p>
<p>This article will show you how to create a customisable Recent post widget for yourself.</p>
<p><span id="more-69"></span><br />
<!--adsense--></p>
<h2>Step 1 &#8211; Creating the file</h2>
<p>First create a file called <code>myRecentPosts_widget.php</code>, you can call it what you like really, as long as you know what it is. Open it up in your favorite text/code editor.</p>
<p>Lets start by adding the &#8216;php&#8217; tag and some information about the author:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</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: My Recent Posts widget
Description: Adds a sidebar widget to display posts from a specified category
Author: Mike Jolley, jolley_small@tesco.net
Version: 1.0
Author URI: http://blue-anvil.com
*/</span></pre></td></tr></table></div>

<p>Done that? Well done, lets move on.</p>
<h2>Step 2 &#8211; The widget function begin</h2>
<p>Next we need to add the widgets functionality. Lets add the start of our function: the init function, which will wrap all our plugin functionality. We will also add a little code to make sure widgets are enabled (and the widget functions exist), to avoid errors:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> widget_myRecentPosts_init<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> <span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'register_sidebar_widget'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #b1b100;">return</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now we can start adding our widgets functionality, the next code creates our function and gets variable values (some of these we will set later).</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> widget_myRecentPosts<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// &quot;$args is an array of strings that help widgets to conform to</span>
		<span style="color: #666666; font-style: italic;">// the active theme: before_widget, before_title, after_widget,</span>
		<span style="color: #666666; font-style: italic;">// and after_title are the array keys.&quot; - These are set up by the theme</span>
		<span style="color: #990000;">extract</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// These are our own options</span>
		<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_myRecentPosts'</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: #000088;">$options</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: #666666; font-style: italic;">// Title in sidebar for widget</span>
		<span style="color: #000088;">$show</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// # of Posts we are showing</span>
		<span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ex'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Showing the excerpt or not</span>
		<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'exclude'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Categories to exclude</span>
                      <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$show</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$show</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$exclude</span><span style="color: #339933;">==</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The next piece of code will start outputting to the screen, using the default $args, and our widget title.</p>

<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: #666666; font-style: italic;">// Output</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$before_widget</span> <span style="color: #339933;">.</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></pre></td></tr></table></div>

<h2>Step 3 &#8211; The Posts Query</h2>
<p>The next code starts pulling results from the database using queries. This is more complex, so don&#8217;t worry if it confuses you!</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// GET POSTS</span>
			<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'select DISTINCT * from '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">posts</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'
			INNER JOIN (select * from '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post2cat</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'
			INNER JOIN '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">categories</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">' ON '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post2cat</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.category_id = '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">categories</span> <span style="color: #339933;">.</span><span style="color: #0000ff;">'.cat_ID)
			as A ON '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">posts</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.ID = A.post_ID
			WHERE (A.cat_ID NOT IN ('</span><span style="color: #339933;">.</span><span style="color: #000088;">$exclude</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'))
			AND '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">posts</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.post_status=&quot;publish&quot;
			AND '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">posts</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.post_type=&quot;post&quot;
                        GROUP BY ID
			ORDER BY '</span><span style="color: #339933;">.</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">posts</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'.post_date
			DESC LIMIT 0,'</span><span style="color: #339933;">.</span><span style="color: #000088;">$show</span><span style="color: #339933;">.</span><span style="color: #0000ff;">';'</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000088;">$posts</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The above query gets all posts that are published, not excluded (from one of our options), and orders them by date, limiting the number queried to another of our options.</p>
<p>The next piece of code checks if we had any results, and starts looping to output them in the sidebar.</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">			<span style="color: #666666; font-style: italic;">// start list</span>
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;ul&gt;'</span><span style="color: #339933;">;</span>
				<span style="color: #666666; font-style: italic;">// were there any posts found?</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #666666; font-style: italic;">// posts were found, loop through them</span>
					 <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
							<span style="color: #666666; font-style: italic;">// format a date for the posts</span>
							<span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_date</span> <span style="color: #339933;">=</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;F j, Y&quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">strtotime</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_date</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #666666; font-style: italic;">// if we want to display an excerpt, get it/generate it if no excerpt found</span>
							<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ex</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
								 <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
									 <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">,</span><span style="color: #990000;">strrev</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_content</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</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;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strrev</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
									 <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; [...]&quot;</span><span style="color: #339933;">;</span>
								 <span style="color: #009900;">&#125;</span>
							<span style="color: #009900;">&#125;</span>
&nbsp;
							<span style="color: #666666; font-style: italic;">//output to screen</span>
							<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;li&gt;
							&lt;a class=&quot;post&quot; rel=&quot;bookmark&quot; href=&quot;'</span><span style="color: #339933;">.</span>get_permalink<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: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;&lt;span class=&quot;inner&quot;&gt;
							&lt;strong class=&quot;title lifestyle&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_date</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' - '</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/strong&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$ex</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">.</span><span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_excerpt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
							<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
					 <span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;li&gt;No recent Posts&lt;/li&gt;&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// end list</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>That was a lot, but its commented so read through to get a better understanding of how the rows are outputted. To finish our function we just close the function (and output the closing element of the widget).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// echo widget closing tag</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>

<h2>Step 4 &#8211; Creating the settings</h2>
<p>Widgets make it easy to create a small settings dialog for your widget, our widget is going to get settings for:</p>
<ul>
<li>Widget title</li>
<li>posts to show</li>
<li>whether or not to show excerpt</li>
<li>Categories to exclude from the list</li>
</ul>
<p>Lets get started. We declare our settings function, and load the variables.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #666666; font-style: italic;">// Settings form</span>
	<span style="color: #000000; font-weight: bold;">function</span> widget_myRecentPosts_control<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// Get options</span>
		<span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_myRecentPosts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// options exist? if not set defaults</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
			<span style="color: #000088;">$options</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;">'Recent Posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'show'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'5'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'excerpt'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">'1'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'exclude'</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Next we check if the settings form has been posted, updating the settings if it has.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">                      <span style="color: #666666; font-style: italic;">// form posted?</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'recentArticles-submit'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			<span style="color: #666666; font-style: italic;">// Remember to sanitize and format use input appropriately.</span>
			<span style="color: #000088;">$options</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: #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;">'recentArticles-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>
			<span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show'</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: #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;">'recentArticles-show'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'excerpt'</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: #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;">'recentArticles-excerpt'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'exclude'</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: #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;">'recentArticles-exclude'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'widget_myRecentPosts'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>So we have handled posted options, now we need a form! Lets get the options to show in the form by default.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">		<span style="color: #666666; font-style: italic;">// Get options for form fields to show</span>
		<span style="color: #000088;">$title</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</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: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$show</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'show'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$excerpt</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'excerpt'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$exclude</span> <span style="color: #339933;">=</span> <span style="color: #990000;">htmlspecialchars</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'exclude'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">ENT_QUOTES</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now we can happily display the form. Notice we only need to write the fields, the widgets engine handles the form code!</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
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">		<span style="color: #666666; font-style: italic;">// The form fields</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align:right;&quot;&gt;
				&lt;label for=&quot;myRecentPosts-title&quot;&gt;'</span> <span style="color: #339933;">.</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: #0000ff;">'
				&lt;input style=&quot;width: 200px;&quot; id=&quot;myRecentPosts-title&quot; name=&quot;myRecentPosts-title&quot; type=&quot;text&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$title</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;
				&lt;/label&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align:right;&quot;&gt;
				&lt;label for=&quot;myRecentPosts-show&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Show:'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'
				&lt;input style=&quot;width: 200px;&quot; id=&quot;myRecentPosts-show&quot; name=&quot;myRecentPosts-show&quot; type=&quot;text&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$show</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;
				&lt;/label&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align:right;&quot;&gt;
				&lt;label for=&quot;myRecentPosts-excerpt&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Show excerpt:'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'
				&lt;input style=&quot;width: 200px;&quot; id=&quot;myRecentPosts-excerpt&quot; name=&quot;myRecentPosts-excerpt&quot; type=&quot;text&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$excerpt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;
				&lt;/label&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p&gt;Enter the categories to exclude below, this must be a comma separated list of category id\'s!&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;p style=&quot;text-align:right;&quot;&gt;
				&lt;label for=&quot;myRecentPosts-exclude&quot;&gt;'</span> <span style="color: #339933;">.</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Exclude:'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'
				&lt;input style=&quot;width: 200px;&quot; id=&quot;myRecentPosts-exclude&quot; name=&quot;myRecentPosts-exclude&quot; type=&quot;text&quot; value=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$exclude</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; /&gt;
				&lt;/label&gt;&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;input type=&quot;hidden&quot; id=&quot;myRecentPosts-submit&quot; name=&quot;myRecentPosts-submit&quot; value=&quot;1&quot; /&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And thats that for settings!</p>
<h2>Step 5 &#8211; Register the widgets</h2>
<p>The last piece of code registers the widget for use. After that were done.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">	<span style="color: #666666; font-style: italic;">// Register widget for use</span>
	register_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My Recent Posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widgets'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget_myRecentPosts'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Register settings for use, 300x100 pixel form</span>
	register_widget_control<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My Recent Posts'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widgets'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'widget_myRecentPosts_control'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">300</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">200</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;">// Run code and init</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;">'widget_myRecentPosts_init'</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>

<h2>Widget armed</h2>
<p>Now its finished, upload to plugins directory, activate it, then go to the widgets control panel (under the presentation tab of the wordpress admin) and drag it into one of your sidebar widget sections.</p>
<p class="center"><img src='http://blue-anvil.com/wp-content/uploads/2007/05/screen2.png' alt='Added widget' /></p>
<p>Click the little form icon on the widget to bring up the settings form</p>
<p class="center"><img src='http://blue-anvil.com/wp-content/uploads/2007/05/screen3.png' alt='Settings' /></p>
<p>In action it looks like this:</p>
<p class="center"><img src='http://blue-anvil.com/wp-content/uploads/2007/05/screen1.png' alt='In action' /></p>
<h2>Lazy mans corner</h2>
<p>For a full code listing, <a href="http://blue-anvil.com/downloads/myRecentPosts.php.txt">click here</a></p>
<p>Download it all zipped up below.</p>
<p class="center image"><a class="downloadlink dlimg" href="http://blue-anvil.com/download/myRecentPosts.zip" title="Version 1.1 downloaded 3585 times" ><img src="http://blue-anvil.com/wp-content/plugins/download-monitor/img/download.gif" alt="Download My Recent posts widget Version 1.1" /></a></p>
<p><!--adsense--></p>
<h2>Enjoy</h2>
<p>I hope my little tutorial on widget creation was of a great help <img src='http://blue-anvil.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blue-anvil.com/archives/create-a-wordpress-recent-posts-widget/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
	</channel>
</rss>

