• vestaviascott

    (@vestaviascott)


    OK, I can create the code to add custom widgets to the widgets manager. Check.

    My next challenge is to, in the same plugin, during activation, check for the existence of my theme, and if active, pre-populate the widget areas with the custom widgets I’ve just created.

    I hope this makes sense. If I can do this, it will save a ton of time from configuring (and explaining how to configure) my default theme setup, which relies heavily on custom widgets. Things like an optin email form, custom slider widget, etc…

    So for example, my THEME registers several sidebar areas. One of the id’s is “home-sidebar-widget”.

    So I’d like to add code to my PLUGIN that not only creates the custom widgets, but also checks for the existence of my sidebars and if they are registered, it goes ahead and prepopulates the sidebar areas, with the appropriate custom widgets my plugin has just created.

    //This is my dummy stub code that seeks to explain programatically what I’m trying to do…

    If(sidebar_exists('home-sidebar-widget')) wp_add_widget('my-custom-widget-created-by-the-plugin');

    Thanks in advance if anyone can help me here.

    Here are my theme’s default sidebars…

    if ( function_exists(‘register_sidebar’) )
    register_sidebar(array(
    ‘name’ => ‘Home Sidebar’,
    ‘id’ => ‘home-sidebar-widget’,
    ));

    if ( function_exists(‘register_sidebar’) )
    register_sidebar(array(
    ‘name’ => ‘Home Header Area’,
    ‘id’ => ‘home-header-widget’,
    ));

    if ( function_exists(‘register_sidebar’) )
    register_sidebar(array(
    ‘name’ => ‘Inside Header Area’,
    ‘id’ => ‘inside-header-widget’,
    ));

    if ( function_exists(‘register_sidebar’) )
    register_sidebar(array(
    ‘name’ => ‘Home Footer Area’,
    ‘id’ => ‘home-footer-widget’,
    ));

    if ( function_exists(‘register_sidebar’) )
    register_sidebar(array(
    ‘name’ => ‘Inside Footer Area’,
    ‘id’ => ‘inside-footer-widget’,
    ));

    if ( function_exists(‘register_sidebar’) )
    register_sidebar(array(
    ‘name’ => ‘Inside Sidebar’,
    ‘id’ => ‘inside-sidebar-widget’,
    ));

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Can a plugin add code to a known sidebar id registered by a theme?’ is closed to new replies.