WordPress:WPMU List All Blogs Widget

来自站长百科
Fludlen讨论 | 贡献2008年9月25日 (四) 13:51的版本
跳转至: 导航、​ 搜索
 <?php
/*
Plugin Name: List-All-Blogs Widget
Plugin URI: http://codex.wordpress.org/WPMU_List_All_Blogs_Widget
Description: Creates a list of all blogs 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_blogs_init() {
	if ( !function_exists('register_sidebar_widget') )
		return;


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

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

                 echo $before_title . 'All Blogs' . $after_title;
                        echo "<ul>\n";
                        list_all_wpmu_blogs('100', 'name', '<li>', '</li>', 'updated');
                        echo "</ul>\n";
                 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 blogs' ), 'Widgetize list all blogs', 'widget_list_all_blogs', array(), 1);
    else
      register_sidebar_widget('Widgetize list all blogs', 'widget_list_all_blogs', 1);
}
add_action('plugins_loaded', 'widget_list_all_blogs_init');
?>