The MU forums have moved to WordPress.org

Default theme, pages & widgets (7 posts)

  1. expromo
    Member
    Posted 14 years ago #

    Hi guys!

    I'm designing Wordpress MU so I can showcase my new Wordpress Theme.

    I would like to give my customers a possibility to register a new blog with the premium theme already loaded.

    Here are the problems I have - I would really appreciate your help:
    a) I have only my premium theme - Expresso - activated in Admin / Themes in WPMU but still when the new blog is created it uses Wordpress Default - I have to change it

    b) My theme uses a lot of widgets and is CMS optimized - Can i setup you accounts to have default widgets and pages? This would be a great help for me

    Please help :)
    Thanks in advance

  2. andrea_r
    Moderator
    Posted 14 years ago #

    Try the New Blog defaults plugin from the wp.org repo. You can set the default theme there.

    There isn't a way to have the widgets & options set up, unless you've coded them that way in your theme.

  3. DeannaS
    Member
    Posted 14 years ago #

    In your widgetized area on your theme, you can use "the_widget()" function to set up default widgets. They'll be hardcoded into the theme, but use the exact same functionality as the normal widgets and will be able to be overwritten by the normal widgets.

    For default pages, you can use the blog templates plugin plugin. It might handle widgets, too:
    http://wpmudevorg.wordpress.com/project/blog-templates/installation

  4. sswells
    Member
    Posted 14 years ago #

    Here's a portion of the code I'm using. It was in my very first plugin, so it's not great code and it doesn't work with widgets with multiple instances. (I'm working on that today.) Maybe I'll release this one sometime. Hopefully it helps someone.

    Add widgets when the blog is created:

    add_action('wpmu_new_blog', 'copy_auto_populate_settings', 100, 2);
    function default_settings($blog_id, $user_id){
       switch_to_blog($blog_id);
       $wpdb->suppress_errors();
    
        // Set Widgets
        $sidebars_widgets = array();
        $sidebars_widgets['sidebar-1'] = array();
        $sidebars_widgets['sidebar-2'] = array();
        $sidebars_widgets['array_version'] = 1;
    
        //this list is a list of the widget ids. For a widget with multiple instances, the widget id would be dynamic ie. 'calendar-2', 'calendar-5'
        $widgets1 = array('real-estate-tools', 'ask-expert', 'recently-asked-questions','market-alert','archives');
    
        $widgets2 = array('local-sponsor', 'subscribe-to-blog', 'market-recap', 'local-experts', 'local-listings');
    
        foreach ($widgets1 as $widget1)
    	$sidebars_widgets['sidebar-1'][] = $widget1;
    
        foreach ($widgets2 as $widget2)
    	$sidebars_widgets['sidebar-2'][] = $widget2;
    
        update_option('sidebars_widgets', $sidebars_widgets);
        restore_current_blog();
    }
  5. sswells
    Member
    Posted 14 years ago #

    After a lot of digging, I finally found the function needed for the widgets with multiple instances:
    next_widget_id_number('calendar');

    So in the function above, a calendar widget would be added with this:

    $sidebars_widgets['sidebar-1'][] = 'calendar-' . next_widget_id_number('calendar');
    update_option('sidebars_widgets', $sidebars_widgets);
  6. andrea_r
    Moderator
    Posted 14 years ago #

    High fives, this is awesome.

  7. scend
    Member
    Posted 13 years ago #

    sswells,

    It looks like you've created exactly what we need. We want widgets to be cloned with new blogs in WPMU.

    Would it be possible to license this plugin from you?

    Travis

About this Topic