<?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>夜游长空 &#187; Widget</title>
	<atom:link href="http://www.zhangdi.name/tag/widget/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zhangdi.name</link>
	<description>Blog of Daniel &#38; Kimi</description>
	<lastBuildDate>Wed, 13 Oct 2010 05:05:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>WordPress Widgets简介</title>
		<link>http://www.zhangdi.name/2007/07/23/an-introduction-about-wordpress-widgets.html</link>
		<comments>http://www.zhangdi.name/2007/07/23/an-introduction-about-wordpress-widgets.html#comments</comments>
		<pubDate>Mon, 23 Jul 2007 07:57:42 +0000</pubDate>
		<dc:creator>zhangdi</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Widget]]></category>
		<category><![CDATA[编程]]></category>

		<guid isPermaLink="false">http://www.zhangdi.name/2007/07/23/an-introduction-about-wordpress-widgets.html</guid>
		<description><![CDATA[WordPress2.2.x开始正式把widgets作为内部功能之一。这说明了widgets的成功和人心所向，也说明了大家对于添加一个小功能就要修改theme的template的厌倦。widgets最初是一个wordpress的plugin，叫dynamic sidebar，顾名思义，就是动态生成sidebar而不需要修改代码。而现在功能强大，不仅仅可以动态生成sidebar，页面的任何位置，只要设置了支持widgets就可以使用拖拽的方式来控制布局。 在安装了widgets插件后（wordpress2.2.x及以上版本无需安装），在Admin-&#62;Presentation-&#62;Widgets中，就可以看到所有页面上的widgets container和所有可以使用的widgets，需要做的就是将widgets拖拽到理想的区域就可以了。而且大多widgets还支持基于AJAX的设置页面，用户友好度也非常好。 实现一个widget也是非常惬意的一件事情。如果你有一个非widgetized的plugin那么只需要做很少的改动就可以把它变成一个widget。比如有一个plugin叫做recent_comments，原来你必须在sidebar.php中修改代码，加上相应的get_recent_comments()函数。现在只需要做一些改动，让这个plugin支持widget就可以直接拖拽了。大概是这个样子： function get_recent_comments() { /* 原来的函数，不需要改动 */ } // 下面的代码让这个plugin支持widget function widget_recent_comments_init() { // 万一我们没有widgets plugin的话 if ( !function_exists('register_sidebar_widget') ) return; function widget_recent_comments($args) { extract($args); // 下面就是输出的东西，直接打到页面上。 echo $before_widget; // 这些都不能丢下。（标准！） echo $before_title; echo 'Recent Comments'; echo $after_title; echo get_recent_comments(); echo $after_widget; } // 注册widget register_sidebar_widget('Recent Comments Widget', 'widget_recent_comments'); } // [...]]]></description>
			<content:encoded><![CDATA[<p><!--wordpress plugin widget blog AJAX--></p>
<p><a href="http://wordpress.org">WordPress2.2.x</a>开始正式把widgets作为内部功能之一。这说明了widgets的成功和人心所向，也说明了大家对于添加一个小功能就要修改theme的template的厌倦。widgets最初是一个wordpress的plugin，叫dynamic sidebar，顾名思义，就是动态生成sidebar而不需要修改代码。而现在功能强大，不仅仅可以动态生成sidebar，页面的任何位置，只要设置了支持widgets就可以使用拖拽的方式来控制布局。</p>
<p>在安装了widgets插件后（wordpress2.2.x及以上版本无需安装），在Admin-&gt;Presentation-&gt;Widgets中，就可以看到所有页面上的widgets container和所有可以使用的widgets，需要做的就是将widgets拖拽到理想的区域就可以了。而且大多widgets还支持基于AJAX的设置页面，用户友好度也非常好。</p>
<p>实现一个widget也是非常惬意的一件事情。如果你有一个非widgetized的plugin那么只需要做很少的改动就可以把它变成一个widget。比如有一个plugin叫做recent_comments，原来你必须在sidebar.php中修改代码，加上相应的get_recent_comments()函数。现在只需要做一些改动，让这个plugin支持widget就可以直接拖拽了。大概是这个样子：</p>
<p><span id="more-207"></span></p>
<pre name="code" class="php">
function get_recent_comments() {
    /* 原来的函数，不需要改动 */
}

// 下面的代码让这个plugin支持widget
function widget_recent_comments_init() {
    // 万一我们没有widgets plugin的话
    if ( !function_exists('register_sidebar_widget') )
        return;

    function widget_recent_comments($args) {
        extract($args);

        // 下面就是输出的东西，直接打到页面上。
        echo $before_widget; // 这些都不能丢下。（标准！）
        echo $before_title;
        echo 'Recent Comments';
        echo $after_title;
        echo get_recent_comments();
        echo $after_widget;
    }

    // 注册widget
    register_sidebar_widget('Recent Comments Widget', 'widget_recent_comments');
}

// 再所有plugin都载入之后再载入这个widget，防止有dependency的问题。
add_action("plugins_loaded", "widget_recent_comments_init");</pre>
<p>非常简单，所以我已经把我所有要用到的不是widget的plugin都widgetize了。</p>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://www.zhangdi.name/2007/07/23/blog-upgraded-again.html" title="Blog再一次升级">Blog再一次升级</a></li><li><a href="http://www.zhangdi.name/2008/12/19/post-delicious-bookmarks-to-wordpress-daily-automatically.html" title="将Delicious的bookmarks自动发布到Wordpress">将Delicious的bookmarks自动发布到Wordpress</a></li><li><a href="http://www.zhangdi.name/2008/12/12/wordpress-upgrades-to-27.html" title="Wordpress升级到2.7">Wordpress升级到2.7</a></li><li><a href="http://www.zhangdi.name/2008/07/24/add-avatar-to-wordpress-comment-section.html" title="为Wordpress的评论部分加上头像">为Wordpress的评论部分加上头像</a></li><li><a href="http://www.zhangdi.name/2007/10/25/wordpress-23.html" title="Wordpress升级到了2.3版本">Wordpress升级到了2.3版本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.zhangdi.name/2007/07/23/an-introduction-about-wordpress-widgets.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Blog再一次升级</title>
		<link>http://www.zhangdi.name/2007/07/23/blog-upgraded-again.html</link>
		<comments>http://www.zhangdi.name/2007/07/23/blog-upgraded-again.html#comments</comments>
		<pubDate>Mon, 23 Jul 2007 03:35:05 +0000</pubDate>
		<dc:creator>zhangdi</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Widget]]></category>

		<guid isPermaLink="false">http://www.zhangdi.name/2007/07/23/blog-upgraded-again.html</guid>
		<description><![CDATA[再一次对Blog进行了大规模升级，主要原因是wordpress升级到了2.2.1，有了一个非常吸引人的功能：Widget。 其实Widget是一个wordpress的plugin，自从2.0.x就有了，但是一直没有注意到，而且支持的theme和plugin也不是很广泛。Widget的核心功能就是能让你用拖拽的方式来design自己的wordpress布局，而不用再修改theme template的代码了。Wordpress的高层认为widget是一个很有前途的设计，所以最终决定将这个plugin作为wordpress的内部功能之一。所以以后将有越来越多的支持widgets的theme和plugin了。 WordPress从2.0.5升级到2.2.1。 将theme换成了一个widget ready的。（来自BloggingPro） 使用widget重新design了页面。 使用plugin实现自己的某些定制。（比如载入额外的JavaScript和CSS） 添加了一个投票的plugin。 相关文章Wordpress Widgets简介将Delicious的bookmarks自动发布到WordpressWordpress升级到2.7为Wordpress的评论部分加上头像Wordpress升级到了2.3版本]]></description>
			<content:encoded><![CDATA[<p><!--wordpress 升级 plugin blog widget WP-Polls--></p>
<p>再一次对Blog进行了大规模升级，主要原因是wordpress升级到了2.2.1，有了一个非常吸引人的功能：Widget。</p>
<p>其实Widget是一个wordpress的plugin，自从2.0.x就有了，但是一直没有注意到，而且支持的theme和plugin也不是很广泛。Widget的核心功能就是能让你用拖拽的方式来design自己的wordpress布局，而不用再修改theme template的代码了。Wordpress的高层认为widget是一个很有前途的设计，所以最终决定将这个plugin作为wordpress的内部功能之一。所以以后将有越来越多的支持widgets的theme和plugin了。</p>
<ul>
<li>WordPress从2.0.5升级到2.2.1。</li>
<li>将theme换成了一个widget ready的。（来自<a href="http://www.bloggingpro.com/">BloggingPro</a>）</li>
<li>使用widget重新design了页面。</li>
<li>使用plugin实现自己的某些定制。（比如载入额外的JavaScript和CSS）</li>
<li>添加了一个投票的plugin。</li>
</ul>
<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://www.zhangdi.name/2007/07/23/an-introduction-about-wordpress-widgets.html" title="Wordpress Widgets简介">Wordpress Widgets简介</a></li><li><a href="http://www.zhangdi.name/2008/12/19/post-delicious-bookmarks-to-wordpress-daily-automatically.html" title="将Delicious的bookmarks自动发布到Wordpress">将Delicious的bookmarks自动发布到Wordpress</a></li><li><a href="http://www.zhangdi.name/2008/12/12/wordpress-upgrades-to-27.html" title="Wordpress升级到2.7">Wordpress升级到2.7</a></li><li><a href="http://www.zhangdi.name/2008/07/24/add-avatar-to-wordpress-comment-section.html" title="为Wordpress的评论部分加上头像">为Wordpress的评论部分加上头像</a></li><li><a href="http://www.zhangdi.name/2007/10/25/wordpress-23.html" title="Wordpress升级到了2.3版本">Wordpress升级到了2.3版本</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.zhangdi.name/2007/07/23/blog-upgraded-again.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

