The MU forums have moved to WordPress.org

How to use same widgets in each blog? (6 posts)

  1. psychicBOY
    Member
    Posted 18 years ago #

    Actually, I want that the widgets should be same on each new blog that I make as a default but users can change later.

  2. MrBrian
    Member
    Posted 18 years ago #

    //This activates the given widgets in sidebar-1 and -2. You need to know the internal names of the widgets.
    function change_blog_widgets($blog_id, $user_id) {
    
       	update_blog_option($blog_id, "sidebars_widgets",
    		array("sidebar-1" => array("tag_cloud"),
    			 "sidebar-2" => array("archives", "links")));
    
    }
    add_action("wpmu_new_blog", "change_blog_widgets", 10, 2);
  3. psychicBOY
    Member
    Posted 18 years ago #

    Ok. thanks for giving me the code but how and where and which file to add or replace.???

  4. JamesFrancis
    Member
    Posted 18 years ago #

    I have done it by editing the wp-admin/includes/schema.php file and causing the widgets to be added via the database any time a new blog is created.

    i.e. I set the widgets up the way I wanted on one subdomain, checked the database and copy and pasted the values into the schema.php file.

    In my case, it looks something like this:

    // Widgets
    add_option('sidebars_widgets', 'a:3:{s:9:"sidebar-2";a:5:{i:0;s:12:"recent-posts";i:1;s:15:"recent-comments";i:2;s:20:"categories-171877571";i:3;s:8:"archives";i:4;s:5:"links";}s:9:"sidebar-3";a:3:{i:0;s:4:"meta";i:1;s:8:"calendar";i:2;s:14:"widget_stags-1";}s:13:"array_version";i:3;}');
    add_option('widget_recent_entries', 'a:2:{s:5:"title";s:0:"";s:6:"number";i:15;}');
    add_option('widget_archives', 'a:3:{s:5:"count";b:1;s:8:"dropdown";b:0;s:5:"title";s:0:"";}');
    add_option('widget_calendar', 'a:1:{s:5:"title";s:8:"Calendar";}');
    add_option('widget_recent_comments', 'a:2:{s:5:"title";s:0:"";s:6:"number";i:15;}');

    etc.

    Hope this help psychicBOY.

  5. MrBrian
    Member
    Posted 18 years ago #

    I would recommend not hacking the core and using the plugin code i provided. You just create a file with that code and stick it in mu-plugins directory.

  6. dsader
    Member
    Posted 18 years ago #

    I use new hook/add_option for WPMU2.6 for the plugin found here
    http://www.ringofblogs.com/2008/07/31/wpmu-new-blog-settings-plugin-updated/

About this Topic

  • Started 18 years ago by psychicBOY
  • Latest reply from dsader