Feb
15
2014

Diamond Multisite Widgets Update 1

This entry is part 2 of 2 in the series Diamond Multisite Widget Series

I did end up digging into the code of Diamond Multisite Widgets (see previous post) a little bit. In the end it looks like it will be best for me to just use the Duplicate Widget Plugin since it does everything I personally need.

In the past (I think pre-2.8) WordPress only allowed a widget to be added once. It was fairly easy to update the plugin to use the new widget class structure and at least allow it to be added to multiple side bars. However, the internal code of the plugin just retrieves its options straight from the database and assumes there is only one instance. To get it to work with the new per instance settings would require too much rewriting to be worth it to me.

For anyone who wants to see the changes I made to get basic multiuse working with the Diamond-Bloglist go to your site or network admin page. Then to plugins and “Edit” Diamond MultiSite Widgets. Select the file “diamond-bloglist.php”. Start with commenting out these lines at the top of the file:

	
   //function DiamondBL() {
    //    add_action('widgets_init', array($this, 'init_diamondBL'));
    //}
         
    //function init_diamondBL() {    
        
        //add_shortcode('diamond-bloglist', array($this, 'diamond_bloglist_handler'));
        
        //if ( !function_exists('register_sidebar_widget') ||
        //!function_exists('register_widget_control') )
        //return;
         
        //register_sidebar_widget(array(__('Diamond Bloglist', 'diamond'),'widgets'),array($this, 'widget_endView'));
        //register_widget_control(array(__('Diamond Bloglist', 'diamond'), 'widgets'), array($this, widget_controlView'));        

    //}

Then add the following lines:


       function __construct() {
        parent::__construct(
            'DiamondBL', // Base ID
            __('Diamond Bloglist', 'text_domain'), // Name
            array( 'description' => __( 'Lists blogs in the network', 'text_domain' ), ) // Args
        );
        add_shortcode('diamond-bloglist', array($this, 'diamond_bloglist_handler'));
    }

    function widget($args, $instance){$this->widget_endView($args);}
    //function update($new_instance, $old_instance){return $new_instance;} //this is what the parent class already does
    function form($instance){$this->widget_controlView();}

Comment out one line at the very bottom:


	//$bloglistObj = new DiamondBL ();

Then add the following:


       // register DiamondBL
       function register_diamondbl_widget() {
         register_widget( 'DiamondBL' );
       }
       add_action( 'widgets_init', 'register_diamondbl_widget' );

 

Series Navigation<< Diamond Multisite Widgets

Leave a comment