WordPress:WPMU List All Postings Widget

来自站长百科
跳转至: 导航、​ 搜索

This code is the code needed to create a widget to show a list of on post in each of your blogs. It is dependent on the plug-in List All Posts, that should be installed first. Create a blank text file named widget_list_all_posts.php in your plugins folder, add the following php code. You should them be able to activate the List All Posts plugin and the List-All-Posts Widget on the plugins tab. Then look over in the presentation/widgets tab and you should have a new widget named List All Posts Widget.

需要这个代码,创建widget显示你的博客上的文章列表。这个代码依赖的插件,插件List All Posts必须先安装。在你的插件文件夹中创建名为widget_list_all_posts.php的空白文本文件,添加以下的php代码,然后你就可以激活插件标签中的List All Posts 插件和List-All-Posts Widget。然后查看presentation/widgets标签,你应该有个新的,名为List All Posts Widget的widget。

<?php
/*
Plugin Name: List-All-Blogs Widget
Plugin URI: http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
Description: Creates a list of all posts on a WPMU site as a widget, conversion from previous version based on code in http://www.erik-rasmussen.com/blog/2006/11/30/widgetize-anything/
Author: Unkown - last edited Iolaire McFadden 
Author URI: http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
Version: 0.0.1
*/

function widget_list_all_posts_init() {
	if ( !function_exists('register_sidebar_widget') )
		return;


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

        if(function_exists(list_all_wpmu_blogs)) {
	                 echo $before_widget;

	                 echo $before_title . 'All Recent Deals' . $after_title;
	                        list_all_wpmu_posts(20, 0, '<p>', '</p>', '<p>', '</p>','show','hide','hide');
	                 echo $after_widget;
	        }
		else 
		{
                 echo "Error - function  list_all_wpmu_blogs not found";
        }
	}
	

    if ( function_exists('wp_register_sidebar_widget') ) // fix for wordpress 2.2.1
      wp_register_sidebar_widget(sanitize_title('Widgetize list all posts' ), 'Widgetize list all posts', 'widget_list_all_posts', array(), 1);
    else
      register_sidebar_widget('Widgetize list all posts', 'widget_list_all_posts', 1);
}
add_action('plugins_loaded', 'widget_list_all_posts_init');
?>










<?php
/*
插件名: List-All-Blogs Widget
插件 URI: http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
描述: 在WPMU站点上创建所有文章列表,从先前以http://www.erik-rasmussen.com/blog/2006/11/30/widgetize-anything/上的代码为基础,转变
作者: 未知 –最后由 Iolaire McFadden 编辑
作者 URI: http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
Version: 0.0.1
*/

function widget_list_all_posts_init() {
	if ( !function_exists('register_sidebar_widget') )
		return;


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

        if(function_exists(list_all_wpmu_blogs)) {
	                 echo $before_widget;

	                 echo $before_title . 'All Recent Deals' . $after_title;
	                        list_all_wpmu_posts(20, 0, '<p>', '</p>', '<p>', '</p>','show','hide','hide');
	                 echo $after_widget;
	        }
		else 
		{
                 echo "Error - function  list_all_wpmu_blogs not found";
        }
	}
	

    if ( function_exists('wp_register_sidebar_widget') ) // fix for wordpress 2.2.1
      wp_register_sidebar_widget(sanitize_title('Widgetize list all posts' ), 'Widgetize list all posts', 'widget_list_all_posts', array(), 1);
    else
      register_sidebar_widget('Widgetize list all posts', 'widget_list_all_posts', 1);
}
add_action('plugins_loaded', 'widget_list_all_posts_init');
?>