<?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>WP Engineer &#187; Widget API</title>
	<atom:link href="http://wpengineer.com/tag/widget-api/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Mon, 21 May 2012 22:48:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>24th Door &#8211; The WPE Quit Smoking Widget</title>
		<link>http://wpengineer.com/1918/24th-door-the-wpe-quit-smoking-widget/</link>
		<comments>http://wpengineer.com/1918/24th-door-the-wpe-quit-smoking-widget/#comments</comments>
		<pubDate>Thu, 24 Dec 2009 07:12:19 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Plugins]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[Widget API]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1918</guid>
		<description><![CDATA[For the last door in our Advent Calendar I had something special in mind. This year is coming to an end and I'm sure some of our readers want to quit smoking next year. To support their goal, I created a WP Engineer Quit Smoking Widget. Here a screenshot of all setting possibilities: And this [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-24.jpg" alt="" title="WordPress-Christmas-24" width="600" height="400" class="aligncenter size-full wp-image-1902" />For the last door in our Advent Calendar I had something special in mind. This year is coming to an end and I'm sure some of our readers want to quit smoking next year. To support their goal, I created a WP Engineer Quit Smoking Widget. <img src='http://wpengineer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span id="more-1918"></span><br />
Here a screenshot of all setting possibilities:</p>
<p><img src="http://wpengineer.com/wp-content/uploads/quit-smoking-widget.png" alt="WP Engineer Quit Smoking Widget" title="WPengineer Quit Smoking Widget" width="510" height="432" class="aligncenter size-full wp-image-1919" /></p>
<p>And this is how it would look like on your blog:</p>
<p><img src="http://wpengineer.com/wp-content/uploads/widget-output.png" alt="WP Enigineer Quit Smoking Widget Output" title="WP Enigineer Quit Smoking Widget Output" width="290" height="97" class="aligncenter size-full wp-image-1920" /></p>
<p>Even though, this idea seemed to be easy to realize. It was a piece of work. I don't want you to be bored, so I'm not explaining the whole code, but I just want go in detail on some details, what I had to consider to make this Widget workable.</p>
<p>I check the date if it's valid ( 2009/02/30 doesn't exist). Then I had to avoid division by zero, if the Widget is active but doesn't include any values yet. For the correct formatting of the saved money depending on the language I used the WordPress function <strong>number_format_i18n</strong>:</p>
<pre lang="php">
$saved = number_format_i18n($packs * $price, 2);
</pre>
<p>Unfortunately, there is no feature in WordPress, which displays the currencies correctly (but I guess, this is probably not necessary). Therefore, I added a field "Currency position" with the values "before" and "after", so that the currency will be displayed properly, depending on the country. The year field automatically displays the current year minus 5 years, so that the widget is also current in 100 years. <img src='http://wpengineer.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /><br />
The rest are fields for entering the text output before and after values.</p>
<h3>Installation</h3>
<p>Unzip file wpe_quit_smoking_widget.zip and copy it to wp-content/plugins/ , then activate it in your backend. After that the Widget will be available in your Widgets area.</p>
<p>Please Note: The Widget needs <strong>WordPress Version 2.8</strong> or higher, otherwise it won't be displayed.</p>
<h3>Download</h3>
<p>Download <a href="http://wpengineer.com/?download=WP%20Engineer%20Quit%20Smoking%20Widget">WPEngineer Quit Smoking Widget</a></p>
<p>Have fun with the Widget and good luck with your goal to stop smoking! The team of WP Engineer wish you all Happy Holidays!</p>
<p><img src="http://wpengineer.com/wp-content/uploads/merry-christmas-wpengineer.jpg" alt="" title="merry-christmas-wpengineer" width="368" height="280" class="aligncenter size-full wp-image-1935" /><br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1918/24th-door-the-wpe-quit-smoking-widget/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Advent Calendar &#8211; 24 Days Tips And Tricks Each Day! Today: WordPress Comment Form Widget</title>
		<link>http://wpengineer.com/1875/advent-calendar-24-days-tips-and-tricks-each-day-today-wordpress-comment-form-widget/</link>
		<comments>http://wpengineer.com/1875/advent-calendar-24-days-tips-and-tricks-each-day-today-wordpress-comment-form-widget/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 04:43:41 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Hacks]]></category>
		<category><![CDATA[Advent Calendar]]></category>
		<category><![CDATA[Theme]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[Widget API]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WordPress Themes]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1875</guid>
		<description><![CDATA[Especially in Germany we have the tradition of an Advent Calendar. An Advent calendar is a special calendar which is used to count down the days from December the 1st to Christmas Eve December 24th. An Advent Calendar has 24 doors, one of which is opened every day during Advent. Each door opens to reveal [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://wpengineer.com/wp-content/uploads/WordPress-Christmas-01.jpg" alt="WordPress-Christmas-01" title="WordPress-Christmas-01" width="600" height="400" class="aligncenter size-full wp-image-1879" /></p>
<p>Especially in Germany we have the tradition of an Advent Calendar. An Advent calendar is a special calendar which is used to count down the days from December the 1st to Christmas Eve December 24th. </p>
<p>An Advent Calendar has 24 doors, one of which is opened every day during Advent. Each door opens to reveal an image, a poem, or part of a story such as the Nativity story itself. More elaborate Advent calendars have a small gift concealed in each door, such as a toy or a chocolate item.</p>
<p>At WP Engineer, we thought we should do the same and open a door every day, which contains a little gift for our readers, by providing them a WordPress tip or trick each day. So we hope you will be exciting to see what tip, hack or news will be behind the door the next morning. Enjoy a new little WordPress gift every day until December 24th. <img src='http://wpengineer.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Our first little gift is a code snippet to implement the commentform as a widget in your sidebar. This Widget only works with WordPress 2.8 and higher since it's using the new <a href="http://wpengineer.com/wordpress-built-a-widget/" title="WordPress Widget API">Widget API</a>. Just paste the code in the functions.php of your theme and drag the Widget on your sidebar.<br />
<span id="more-1875"></span></p>
<pre lang="php">
&lt;?php
class wpe_comment_widget extends WP_Widget {

    function wpe_comment_widget() {
        $widget_ops = array(&#039;classname&#039; =&gt; &#039;wpe_widget_comments&#039;, &#039;description&#039; =&gt; __( &#039;Your comments and commentform&#039;, &#039;your_textdomain&#039;) );
        $this-&gt;WP_Widget(&#039;wpe-comment-widget&#039;, __(&#039;WPE Comments&#039;, &#039;your_textdomain&#039;), $widget_ops);
    }

    function widget($args, $instance) {
        if(is_single()) {
            extract($args);
            global $post;
            echo $before_widget;
            comments_template();
            echo $after_widget;
        }
    }

    function update($new_instance, $old_instance) {
        $instance = $old_instance;
        return $instance;
    }

    function form($instance) {
        ?&gt;
        &lt;p&gt;&lt;?php _e(&#039;This widget will only be displayed in single view.&#039;, &#039;your_textdomain&#039;); ?&gt;&lt;/p&gt;
       &lt;?php
    }
}

register_widget(&#039;wpe_comment_widget&#039;);
?&gt;
</pre>
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1875/advent-calendar-24-days-tips-and-tricks-each-day-today-wordpress-comment-form-widget/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>WordPress 2.8 Single Post Navigation Widget</title>
		<link>http://wpengineer.com/1551/wordpress-2-8-single-post-navigation-widget/</link>
		<comments>http://wpengineer.com/1551/wordpress-2-8-single-post-navigation-widget/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 13:38:57 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[Widget API]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.8]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1551</guid>
		<description><![CDATA[Since WordPress 2.8, there is a new Widget API. In our post Build A WordPress 2.8 Widget With The New Widget API, I have used a simple example to describe how to build a Widget. This time Heiko and I've created something more complex. It is a Post Navigation Widget, which lists in the single [...]]]></description>
			<content:encoded><![CDATA[<p>Since WordPress 2.8, there is a new <strong>Widget API</strong>. In our post <a title="WordPress 2.8 Widget API" href="http://wpengineer.com/wordpress-built-a-widget/">Build A WordPress 2.8 Widget With The New Widget API</a>, I have used a simple example to describe how to build a <strong>Widget</strong>. This time Heiko and I've created something more complex.</p>
<p><span id="more-1551"></span><br />
It is a Post Navigation Widget, which lists in the single post view (single.php) a specific number of posts which were published before this post and a certain number of posts which were published after this post. I think this is a nice way to show older posts in the sidebar. Here's a screenshot, left of the backend, right of the sidebar:</p>
<p><img src="http://wpengineer.com/wp-content/uploads/post-navigation-widget.png" alt="WordPress Single Post Navigation Widget" title="WordPress Single Post Navigation Widget" width="505" height="386" class="aligncenter size-full wp-image-1553" /></p>
<p>I created a query to check if the class <strong>WP_Widget</strong> even exists, so the user won't get any error messages in WordPress versions prior to 2.8.</p>
<pre lang="php">
&lt;?php
if (class_exists(&#039;WP_Widget&#039;)) {
    class WPE_Widget_Post_Navigation extends WP_Widget {

        function WPE_Widget_Post_Navigation() {
            $widget_ops = array(&#039;classname&#039; =&gt; &#039;wpe_widget_post_navi&#039;, &#039;description&#039; =&gt; __( &quot;Some posts before and after the current post&quot;) );
            $this-&gt;WP_Widget(&#039;wpe-post-navi&#039;, __(&#039;WPE Single Post Navigation&#039;), $widget_ops);
        }

        function widget($args, $instance) {
            if(is_single()) {
                global $post, $wpdb;
                extract($args);

                if ( !$number = (int) $instance&#091;&#039;number&#039;&#093; )
                    $number = 5;
                elseif( $number &lt; 1 )
                    $number = 1;
                elseif( $number &gt; 10 )
                    $number = 10;

                $title_before 		= apply_filters(&#039;widget_title&#039;, empty($instance&#091;&#039;title_before&#039;&#093;) ? &#039;Posts before&#039; : $instance&#091;&#039;title_before&#039;&#093;);
                $title_after	 	= apply_filters(&#039;widget_title&#039;, empty($instance&#091;&#039;title_after&#039;&#093;) ? &#039;Posts after&#039; : $instance&#091;&#039;title_after&#039;&#093;);
                $before_widget_2	= preg_replace(&quot;/(wpe\-post\-navi-\d+)/&quot;, &quot;$1-1&quot;, $before_widget);

                $querystr = &quot;
                    SELECT *
                    FROM $wpdb-&gt;posts wposts
                    WHERE wposts.ID != $post-&gt;ID
                    AND wposts.post_type = &#039;post&#039;
                    AND wposts.post_status = &#039;publish&#039;
                    AND wposts.post_date %s &#039;$post-&gt;post_date&#039;
                    ORDER BY wposts.post_date %s
                    LIMIT $number
                 &quot;;

                $leading_posts = $wpdb-&gt;get_results(sprintf($querystr, &#039;&lt;&#039;, &#039;DESC&#039;), OBJECT);
                $trailing_posts = $wpdb-&gt;get_results(sprintf($querystr, &#039;&gt;&#039;, &#039;ASC&#039;), OBJECT);

                if ($trailing_posts &amp;&amp; count($trailing_posts)) {
                    echo $before_widget_2 . $before_title . $title_before . $after_title . &quot;&lt;ul&gt;&quot;;
                    $trailing_posts = array_reverse($trailing_posts);
                    foreach ($trailing_posts as $post) {
                        setup_postdata($post);
                        ?&gt; &lt;li&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; title=&quot;&lt;?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?&gt;&quot;&gt;&lt;?php if ( get_the_title() ) the_title(); else the_ID(); ?&gt; &lt;/a&gt;&lt;/li&gt;&lt;?php
                    }
                    echo &quot;&lt;/ul&gt;&quot; . $after_widget;
                }

                if ($leading_posts &amp;&amp; count($leading_posts)) {
                    echo $before_widget . $before_title . $title_after . $after_title . &quot;&lt;ul&gt;&quot;;
                    foreach ($leading_posts as $post) {
                        setup_postdata($post);
                        ?&gt; &lt;li&gt;&lt;a href=&quot;&lt;?php the_permalink() ?&gt;&quot; title=&quot;&lt;?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?&gt;&quot;&gt;&lt;?php if ( get_the_title() ) the_title(); else the_ID(); ?&gt; &lt;/a&gt;&lt;/li&gt;&lt;?php
                    }
                    echo &quot;&lt;/ul&gt;&quot; . $after_widget;
                }
                wp_reset_query();
            }
        }

        function update( $new_instance, $old_instance ) {
            $instance = $old_instance;
            $instance&#091;&#039;title_before&#039;&#093; = strip_tags($new_instance&#091;&#039;title_before&#039;&#093;);
            $instance&#091;&#039;number&#039;&#093; = (int) $new_instance&#091;&#039;number&#039;&#093;;
            $instance&#091;&#039;title_after&#039;&#093; = strip_tags($new_instance&#091;&#039;title_after&#039;&#093;);

            return $instance;
        }
        function form( $instance ) {
            $title_before = ($instance&#091;&#039;title_before&#039;&#093; == &#039;&#039;) ? &#039;Posts before&#039; : esc_attr($instance&#091;&#039;title_before&#039;&#093;);
            $title_after = ($instance&#091;&#039;title_after&#039;&#093; == &#039;&#039;) ? &#039;Posts after&#039; : esc_attr($instance&#091;&#039;title_after&#039;&#093;);
            if ( !$number = (int) $instance&#091;&#039;number&#039;&#093; )
                $number = 5;
            elseif ( $number &lt; 1 )
                $number = 1;
            elseif ( $number &gt; 10 )
                $number = 10;
    ?&gt;
            &lt;p&gt;&lt;label for=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;title_before&#039;); ?&gt;&quot;&gt;Title before:&lt;/label&gt;
            &lt;input class=&quot;widefat&quot; id=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;title_before&#039;); ?&gt;&quot; name=&quot;&lt;?php echo $this-&gt;get_field_name(&#039;title_before&#039;); ?&gt;&quot; type=&quot;text&quot; value=&quot;&lt;?php echo $title_before; ?&gt;&quot; /&gt;&lt;/p&gt;
            &lt;p&gt;&lt;label for=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;title_after&#039;); ?&gt;&quot;&gt;Title after:&lt;/label&gt;
            &lt;input class=&quot;widefat&quot; id=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;title_after&#039;); ?&gt;&quot; name=&quot;&lt;?php echo $this-&gt;get_field_name(&#039;title_after&#039;); ?&gt;&quot; type=&quot;text&quot; value=&quot;&lt;?php echo $title_after; ?&gt;&quot; /&gt;&lt;/p&gt;
            &lt;p&gt;&lt;label for=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;number&#039;); ?&gt;&quot;&gt;Number of posts to show before and after current post:&lt;/label&gt;
            &lt;input id=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;number&#039;); ?&gt;&quot; name=&quot;&lt;?php echo $this-&gt;get_field_name(&#039;number&#039;); ?&gt;&quot; type=&quot;text&quot; value=&quot;&lt;?php echo $number; ?&gt;&quot; size=&quot;3&quot; /&gt;&lt;br /&gt;
            &lt;small&gt;(at most 10)&lt;/small&gt;&lt;/p&gt;
    &lt;?php
        }
    }
    register_widget(&#039;WPE_Widget_Post_Navigation&#039;);
}
?&gt;
</pre>
<p>Most of this should be self-explanatory. Now to the function <strong>widget () </strong>, which does the actual work. Here we had to do a little trick, because the widget actually creates 2 widgets, and they would get the same ID. That wouldn't be valid, so the code adds a -1 to one of the widget elements:</p>
<pre lang="php">
$before_widget_2 = preg_replace(&quot;/(wpe\-post\-navi-\d+)/&quot;, &quot;$1-1&quot;, $before_widget);
</pre>
<p>2 queries are getting executed. One for the posts before this post and one for the posts after this post. if posts are available they will show up on the sidebar.</p>
<p><a title="Download Widget" href="http://wpengineer.com/?download=Single%20Post%20Navigation%20Widget">Download Widget</a>.<br />
Then unpack and copy the code into <strong>functions.php</strong>. Please note, the widget is for <strong>WordPress 2.8</strong>.<br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1551/wordpress-2-8-single-post-navigation-widget/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Build A WordPress 2.8 Widget With The New Widget API</title>
		<link>http://wpengineer.com/1023/wordpress-built-a-widget/</link>
		<comments>http://wpengineer.com/1023/wordpress-built-a-widget/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 11:00:45 +0000</pubDate>
		<dc:creator>Michael</dc:creator>
				<category><![CDATA[WordPress Tutorials]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[Widget API]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp2.8]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=1023</guid>
		<description><![CDATA[One of the main changes in WordPress 2.8 is the new widget API. This API is fully object oriented and provides the programmer all the necessary functions to create a WordPress widgets. Also, it now allows multiple use of each widget. You can find the widget API in wp-includes/widget.php and the widgets itself in wp-includes/default-widgets.php. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the main changes in WordPress 2.8 is the new <strong>widget API</strong>. This API is fully object oriented and provides the programmer all the necessary functions to create a WordPress widgets. Also, it now allows multiple use of each widget.</p>
<p><span id="more-1023"></span></p>
<p>You can find the widget API in wp-includes/widget.php and the widgets itself in wp-includes/default-widgets.php. The class WP_Widget provides the functionality of the widgets, and each widget must be inherited. The class WP_Widget_Factory is for registration and instantiation of widgets responsible.</p>
<h3>How to create a widget in WordPress 2.8?</h3>
<p>It will be a simple example and will output the links for the RSS Feed of the articles and comments. In functions.php we first create the skeleton of our widgets:</p>
<pre lang="php">
class My_RSS_Widget extends WP_Widget {
	function My_RSS_Widget() {
		//Constructor
	}

	function widget($args, $instance) {
		// prints the widget
	}

	function update($new_instance, $old_instance) {
		//save the widget
	}

	function form($instance) {
		//widgetform in backend
	}
}
register_widget(&#039;My_RSS_Widget&#039;);
</pre>
<p>We have a class My_RSS_Widget created, which inherits the properties and methods of the WP_Widget class (extends). In a new widget, the methods <strong>widget</strong> and <strong>update</strong> always have to be created, <strong>form</strong> is optional. With <strong>register_widget</strong> ( 'My_RSS_Widget') will be the widget registered. Let's fill up our widget.</p>
<pre lang="php">
class My_RSS_Widget extends WP_Widget {
	function My_RSS_Widget() {
		$widget_ops = array(&#039;classname&#039; =&gt; &#039;widget_rss_links&#039;, &#039;description&#039; =&gt; &#039;A list with your feeds links&#039; );
		$this-&gt;WP_Widget(&#039;rss_links&#039;, &#039;Feed links&#039;, $widget_ops);
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$title = empty($instance&#091;&#039;title&#039;&#093;) ? &#039;&nbsp;&#039; : apply_filters(&#039;widget_title&#039;, $instance&#091;&#039;title&#039;&#093;);
		$entry_title = empty($instance&#091;&#039;entry_title&#039;&#093;) ? &#039;&nbsp;&#039; : apply_filters(&#039;widget_entry_title&#039;, $instance&#091;&#039;entry_title&#039;&#093;);
		$comments_title = empty($instance&#091;&#039;comments_title&#039;&#093;) ? &#039;&nbsp;&#039; : apply_filters(&#039;widget_comments_title&#039;, $instance&#091;&#039;comments_title&#039;&#093;);

		if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
		echo &#039;&lt;ul id=&quot;rss&quot;&gt;&#039;;
		echo &#039;  &lt;li&gt;&lt;a href=&quot; &#039; . get_bloginfo(&#039;rss2_url&#039;) . &#039;&quot; rel=&quot;nofollow&quot; title=&quot; &#039; . $entry_title . &#039; &quot;&gt;&#039; . $entry_title . &#039;&lt;/a&gt;&lt;/li&gt;&#039;;
		echo &#039;  &lt;li&gt;&lt;a href=&quot; &#039; . get_bloginfo(&#039;comments_rss2_url&#039;) . &#039;&quot; rel=&quot;nofollow&quot; title=&quot;  &#039;. $comments_title . &#039; &quot;&gt;&#039; . $comments_title . &#039;&lt;/a&gt;&lt;/li&gt;&#039;;
		echo &#039;&lt;/ul&gt;&#039;;
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance&#091;&#039;title&#039;&#093; = strip_tags($new_instance&#091;&#039;title&#039;&#093;);
		$instance&#091;&#039;entry_title&#039;&#093; = strip_tags($new_instance&#091;&#039;entry_title&#039;&#093;);
		$instance&#091;&#039;comments_title&#039;&#093; = strip_tags($new_instance&#091;&#039;comments_title&#039;&#093;);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( &#039;title&#039; =&gt; &#039;&#039;, &#039;entry_title&#039; =&gt; &#039;&#039;, &#039;comments_title&#039; =&gt; &#039;&#039; ) );
		$title = strip_tags($instance&#091;&#039;title&#039;&#093;);
		$entry_title = strip_tags($instance&#091;&#039;entry_title&#039;&#093;);
		$comments_title = strip_tags($instance&#091;&#039;comments_title&#039;&#093;);
?&gt;
			&lt;p&gt;&lt;label for=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;title&#039;); ?&gt;&quot;&gt;Title: &lt;input class=&quot;widefat&quot; id=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;title&#039;); ?&gt;&quot; name=&quot;&lt;?php echo $this-&gt;get_field_name(&#039;title&#039;); ?&gt;&quot; type=&quot;text&quot; value=&quot;&lt;?php echo attribute_escape($title); ?&gt;&quot; /&gt;&lt;/label&gt;&lt;/p&gt;
			&lt;p&gt;&lt;label for=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;entry_title&#039;); ?&gt;&quot;&gt;Title for entry feed: &lt;input class=&quot;widefat&quot; id=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;entry_title&#039;); ?&gt;&quot; name=&quot;&lt;?php echo $this-&gt;get_field_name(&#039;entry_title&#039;); ?&gt;&quot; type=&quot;text&quot; value=&quot;&lt;?php echo attribute_escape($entry_title); ?&gt;&quot; /&gt;&lt;/label&gt;&lt;/p&gt;
			&lt;p&gt;&lt;label for=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;comments_title&#039;); ?&gt;&quot;&gt;Title for comments feed: &lt;input class=&quot;widefat&quot; id=&quot;&lt;?php echo $this-&gt;get_field_id(&#039;comments_title&#039;); ?&gt;&quot; name=&quot;&lt;?php echo $this-&gt;get_field_name(&#039;comments_title&#039;); ?&gt;&quot; type=&quot;text&quot; value=&quot;&lt;?php echo attribute_escape($comments_title); ?&gt;&quot; /&gt;&lt;/label&gt;&lt;/p&gt;
&lt;?php
	}
}
register_widget(&#039;My_RSS_Widget&#039;);
</pre>
<p><img src="http://wpengineer.com/wp-content/uploads/rss-widget-backend.jpg" alt="RSS Widget Backend" title="RSS Widget Backend" width="286" height="321" class="aligncenter size-full wp-image-1025" /></p>
<p> The widget feature is for the output in the frontend to examine the update data and stores an instance of the widget and form creates in the backend the input mask, which in our case for the title of the widget and the displayed link text.</p>
<p>The code is self-explanatory. The function <strong>widget</strong> is for the output in the frontend responsible, <strong>update</strong> examine the data and stores an instance of the widget and <strong>form</strong> creates in the backend the input mask, which in our case for the title of the widget and the displayed link text.</p>
<p><img src="http://wpengineer.com/wp-content/uploads/rss-widget-frontend.jpg" alt="RSS Widget frontend" title="RSS Widget frontend" width="269" height="121" class="aligncenter size-full wp-image-1026" /></p>
<p>So now implement your own ideas!</p>
<p><strong>Please check out the post <a href="http://wpengineer.com/wordpress-2-8-single-post-navigation-widget/">WordPress 2.8 Single Post Navigation Widget</a> for a more advanced example.</strong><br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/1023/wordpress-built-a-widget/feed/</wfw:commentRss>
		<slash:comments>54</slash:comments>
		</item>
	</channel>
</rss>

