<?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>Ben Huson &#187; API</title>
	<atom:link href="http://www.benhuson.co.uk/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.benhuson.co.uk</link>
	<description>Web Designer and Developer</description>
	<lastBuildDate>Mon, 06 Feb 2012 14:41:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>WordPress 2.8 Widget API</title>
		<link>http://www.benhuson.co.uk/2009/06/14/wordpress-28-widget-api/</link>
		<comments>http://www.benhuson.co.uk/2009/06/14/wordpress-28-widget-api/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 09:39:48 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[Web Developer]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Widgets]]></category>

		<guid isPermaLink="false">http://www.benhuson.co.uk/?p=801</guid>
		<description><![CDATA[Tweet I love the new widgets API in WordPress 2.8 I followed the excellent tutorial at WPengineer.com which gives a great overview about how to create a widget using the new API. Initially, the widget I created by following the guide seemed to &#8216;crash&#8217; WordPress when I installed it. After a little investigation I tracked [...]]]></description>
			<content:encoded><![CDATA[
<!-- This is the start of the WP Twitter Button code -->
<div id="rk_wp_twitter_button" style="margin: 0px 0px 0px 0px; float: left"><a href="http://redirectingat.com?id=3206X604054&xs=1&url=http%3A%2F%2Ftwitter.com%2Fshare&sref=rss" class="twitter-share-button" data-url="http://www.benhuson.co.uk/2009/06/14/wordpress-28-widget-api/" data-count="horizontal" data-via="benhuson">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>
<!-- This is the end of the WP Twitter Button code -->

 
<span class = "facebook-like" style = "height: 25px;  "><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.benhuson.co.uk/2009/06/14/wordpress-28-widget-api/&layout=button_count&send=false&show_faces=false&width=&action=like&colorscheme=light&font=lucida grande" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:px; height:25px"></iframe></span><p><strong>I love the new widgets API in <a href="http://redirectingat.com?id=3206X604054&xs=1&url=http%3A%2F%2Fwordpress.org%2Fdevelopment%2F2009%2F06%2Fwordpress-28%2Ftrackback%2F&sref=rss">WordPress 2.8</a></strong></p>
<p>I followed the excellent tutorial at <a href="http://redirectingat.com?id=3206X604054&xs=1&url=http%3A%2F%2Fwpengineer.com%2Fwordpress-built-a-widget%2Ftrackback%2F&sref=rss">WPengineer.com</a> which gives a great overview about how to create a widget using the new API. Initially, the widget I created by following the guide seemed to &#8216;crash&#8217; WordPress when I installed it. After a little investigation I tracked this down to the following&#8230;</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_myuniquewidget_register<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   register_sidebar_widget<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My Unique Widget'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'widget_myuniquewidget'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;</span>strong<span style="color: #339933;">&gt;</span>add_action<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'init'</span><span style="color: #339933;">,</span> widget_myuniquewidget_register<span style="color: #009900;">&#41;</span><span style="color: #339933;">;&lt;/</span>strong<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<p>You <strong>must</strong> initialise the register_sidebar_widget function by hooking into the &#8216;init&#8217; action. Failure to do so means the function is called too early which will cause problems. For more information read <a href="http://redirectingat.com?id=3206X604054&xs=1&url=http%3A%2F%2Fcodex.wordpress.org%2FWordPress_Widgets_Api&sref=rss">WordPress Widgets API</a> on the WordPress Codex.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.benhuson.co.uk/2009/06/14/wordpress-28-widget-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

