register_sidebar

The timeline below displays how wordpress function register_sidebar has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * @since 2.2.0
 * @since 5.6.0 Added the `before_sidebar` and `after_sidebar` arguments.
 * @since 5.9.0 Added the `show_in_rest` argument.
 *
 * @global array $wp_registered_sidebars The registered sidebars.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments for the sidebar being registered.
 *
 *     @type string $name           The name or title of the sidebar displayed in the Widgets
 *                                  interface. Default 'Sidebar $instance'.
 *     @type string $id             The unique identifier by which the sidebar will be called.
 *                                  Default 'sidebar-$instance'.
 *     @type string $description    Description of the sidebar, displayed in the Widgets interface.
 *                                  Default empty string.
 *     @type string $class          Extra CSS class to assign to the sidebar in the Widgets interface.
 *                                  Default empty.
 *     @type string $before_widget  HTML content to prepend to each widget's HTML output when assigned
 *                                  to this sidebar. Receives the widget's ID attribute as `%1$s`
 *                                  and class name as `%2$s`. Default is an opening list item element.
 *     @type string $after_widget   HTML content to append to each widget's HTML output when assigned
 *                                  to this sidebar. Default is a closing list item element.
 *     @type string $before_title   HTML content to prepend to the sidebar title when displayed.
 *                                  Default is an opening h2 element.
 *     @type string $after_title    HTML content to append to the sidebar title when displayed.
 *                                  Default is a closing h2 element.
 *     @type string $before_sidebar HTML content to prepend to the sidebar when displayed.
 *                                  Receives the `$id` argument as `%1$s` and `$class` as `%2$s`.
 *                                  Outputs after the {@see 'dynamic_sidebar_before'} action.
 *                                  Default empty string.
 *     @type string $after_sidebar  HTML content to append to the sidebar when displayed.
 *                                  Outputs before the {@see 'dynamic_sidebar_after'} action.
 *                                  Default empty string.
 *     @type bool $show_in_rest     Whether to show this sidebar publicly in the REST API.
 *                                  Defaults to only showing the sidebar to administrator users.
 * }
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $id_is_empty = empty($args['id']);
    $defaults = array(
        /* translators: %d: Sidebar number. */
        'name' => sprintf(__('Sidebar %d'), $i),
        'id' => "sidebar-{$i}",
        'description' => '',
        'class' => '',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => "</li>\n",
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => "</h2>\n",
        'before_sidebar' => '',
        'after_sidebar' => '',
        'show_in_rest' => false,
    );
    /**
     * Filters the sidebar default arguments.
     *
     * @since 5.3.0
     *
     * @see register_sidebar()
     *
     * @param array $defaults The default sidebar arguments.
     */
    $sidebar = wp_parse_args($args, apply_filters('register_sidebar_defaults', $defaults));
    if ($id_is_empty) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: 1: The 'id' argument, 2: Sidebar name, 3: Recommended 'id' value. */
            __('No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.'),
            '<code>id</code>',
            $sidebar['name'],
            $sidebar['id']
        ), '4.2.0');
    }
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    /**
     * Fires once a sidebar has been registered.
     *
     * @since 3.0.0
     *
     * @param array $sidebar Parsed arguments for the registered sidebar.
     */
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}

WordPress Version: 5.9

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * @since 2.2.0
 * @since 5.6.0 Added the `before_sidebar` and `after_sidebar` arguments.
 * @since 5.9.0 Added the `show_in_rest` argument.
 *
 * @global array $wp_registered_sidebars Registered sidebars.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments for the sidebar being registered.
 *
 *     @type string $name           The name or title of the sidebar displayed in the Widgets
 *                                  interface. Default 'Sidebar $instance'.
 *     @type string $id             The unique identifier by which the sidebar will be called.
 *                                  Default 'sidebar-$instance'.
 *     @type string $description    Description of the sidebar, displayed in the Widgets interface.
 *                                  Default empty string.
 *     @type string $class          Extra CSS class to assign to the sidebar in the Widgets interface.
 *                                  Default empty.
 *     @type string $before_widget  HTML content to prepend to each widget's HTML output when assigned
 *                                  to this sidebar. Receives the widget's ID attribute as `%1$s`
 *                                  and class name as `%2$s`. Default is an opening list item element.
 *     @type string $after_widget   HTML content to append to each widget's HTML output when assigned
 *                                  to this sidebar. Default is a closing list item element.
 *     @type string $before_title   HTML content to prepend to the sidebar title when displayed.
 *                                  Default is an opening h2 element.
 *     @type string $after_title    HTML content to append to the sidebar title when displayed.
 *                                  Default is a closing h2 element.
 *     @type string $before_sidebar HTML content to prepend to the sidebar when displayed.
 *                                  Receives the `$id` argument as `%1$s` and `$class` as `%2$s`.
 *                                  Outputs after the {@see 'dynamic_sidebar_before'} action.
 *                                  Default empty string.
 *     @type string $after_sidebar  HTML content to append to the sidebar when displayed.
 *                                  Outputs before the {@see 'dynamic_sidebar_after'} action.
 *                                  Default empty string.
 *     @type bool $show_in_rest     Whether to show this sidebar publicly in the REST API.
 *                                  Defaults to only showing the sidebar to administrator users.
 * }
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $id_is_empty = empty($args['id']);
    $defaults = array(
        /* translators: %d: Sidebar number. */
        'name' => sprintf(__('Sidebar %d'), $i),
        'id' => "sidebar-{$i}",
        'description' => '',
        'class' => '',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => "</li>\n",
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => "</h2>\n",
        'before_sidebar' => '',
        'after_sidebar' => '',
        'show_in_rest' => false,
    );
    /**
     * Filters the sidebar default arguments.
     *
     * @since 5.3.0
     *
     * @see register_sidebar()
     *
     * @param array $defaults The default sidebar arguments.
     */
    $sidebar = wp_parse_args($args, apply_filters('register_sidebar_defaults', $defaults));
    if ($id_is_empty) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: 1: The 'id' argument, 2: Sidebar name, 3: Recommended 'id' value. */
            __('No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.'),
            '<code>id</code>',
            $sidebar['name'],
            $sidebar['id']
        ), '4.2.0');
    }
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    /**
     * Fires once a sidebar has been registered.
     *
     * @since 3.0.0
     *
     * @param array $sidebar Parsed arguments for the registered sidebar.
     */
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}

WordPress Version: 5.6

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * @since 2.2.0
 * @since 5.6.0 Added the `before_sidebar` and `after_sidebar` arguments.
 *
 * @global array $wp_registered_sidebars Registered sidebars.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments for the sidebar being registered.
 *
 *     @type string $name           The name or title of the sidebar displayed in the Widgets
 *                                  interface. Default 'Sidebar $instance'.
 *     @type string $id             The unique identifier by which the sidebar will be called.
 *                                  Default 'sidebar-$instance'.
 *     @type string $description    Description of the sidebar, displayed in the Widgets interface.
 *                                  Default empty string.
 *     @type string $class          Extra CSS class to assign to the sidebar in the Widgets interface.
 *                                  Default empty.
 *     @type string $before_widget  HTML content to prepend to each widget's HTML output when assigned
 *                                  to this sidebar. Receives the widget's ID attribute as `%1$s`
 *                                  and class name as `%2$s`. Default is an opening list item element.
 *     @type string $after_widget   HTML content to append to each widget's HTML output when assigned
 *                                  to this sidebar. Default is a closing list item element.
 *     @type string $before_title   HTML content to prepend to the sidebar title when displayed.
 *                                  Default is an opening h2 element.
 *     @type string $after_title    HTML content to append to the sidebar title when displayed.
 *                                  Default is a closing h2 element.
 *     @type string $before_sidebar HTML content to prepend to the sidebar when displayed.
 *                                  Receives the `$id` argument as `%1$s` and `$class` as `%2$s`.
 *                                  Outputs after the {@see 'dynamic_sidebar_before'} action.
 *                                  Default empty string.
 *     @type string $after_sidebar  HTML content to append to the sidebar when displayed.
 *                                  Outputs before the {@see 'dynamic_sidebar_after'} action.
 *                                  Default empty string.
 * }
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $id_is_empty = empty($args['id']);
    $defaults = array(
        /* translators: %d: Sidebar number. */
        'name' => sprintf(__('Sidebar %d'), $i),
        'id' => "sidebar-{$i}",
        'description' => '',
        'class' => '',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => "</li>\n",
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => "</h2>\n",
        'before_sidebar' => '',
        'after_sidebar' => '',
    );
    /**
     * Filters the sidebar default arguments.
     *
     * @since 5.3.0
     *
     * @see register_sidebar()
     *
     * @param array $defaults The default sidebar arguments.
     */
    $sidebar = wp_parse_args($args, apply_filters('register_sidebar_defaults', $defaults));
    if ($id_is_empty) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: 1: The 'id' argument, 2: Sidebar name, 3: Recommended 'id' value. */
            __('No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.'),
            '<code>id</code>',
            $sidebar['name'],
            $sidebar['id']
        ), '4.2.0');
    }
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    /**
     * Fires once a sidebar has been registered.
     *
     * @since 3.0.0
     *
     * @param array $sidebar Parsed arguments for the registered sidebar.
     */
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}

WordPress Version: 5.5

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_sidebars Registered sidebars.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments for the sidebar being registered.
 *
 *     @type string $name          The name or title of the sidebar displayed in the Widgets
 *                                 interface. Default 'Sidebar $instance'.
 *     @type string $id            The unique identifier by which the sidebar will be called.
 *                                 Default 'sidebar-$instance'.
 *     @type string $description   Description of the sidebar, displayed in the Widgets interface.
 *                                 Default empty string.
 *     @type string $class         Extra CSS class to assign to the sidebar in the Widgets interface.
 *                                 Default empty.
 *     @type string $before_widget HTML content to prepend to each widget's HTML output when
 *                                 assigned to this sidebar. Default is an opening list item element.
 *     @type string $after_widget  HTML content to append to each widget's HTML output when
 *                                 assigned to this sidebar. Default is a closing list item element.
 *     @type string $before_title  HTML content to prepend to the sidebar title when displayed.
 *                                 Default is an opening h2 element.
 *     @type string $after_title   HTML content to append to the sidebar title when displayed.
 *                                 Default is a closing h2 element.
 * }
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $id_is_empty = empty($args['id']);
    $defaults = array(
        /* translators: %d: Sidebar number. */
        'name' => sprintf(__('Sidebar %d'), $i),
        'id' => "sidebar-{$i}",
        'description' => '',
        'class' => '',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => "</li>\n",
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => "</h2>\n",
    );
    /**
     * Filters the sidebar default arguments.
     *
     * @since 5.3.0
     *
     * @see register_sidebar()
     *
     * @param array $defaults The default sidebar arguments.
     */
    $sidebar = wp_parse_args($args, apply_filters('register_sidebar_defaults', $defaults));
    if ($id_is_empty) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: 1: The 'id' argument, 2: Sidebar name, 3: Recommended 'id' value. */
            __('No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.'),
            '<code>id</code>',
            $sidebar['name'],
            $sidebar['id']
        ), '4.2.0');
    }
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    /**
     * Fires once a sidebar has been registered.
     *
     * @since 3.0.0
     *
     * @param array $sidebar Parsed arguments for the registered sidebar.
     */
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}

WordPress Version: 5.3

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments for the sidebar being registered.
 *
 *     @type string $name          The name or title of the sidebar displayed in the Widgets
 *                                 interface. Default 'Sidebar $instance'.
 *     @type string $id            The unique identifier by which the sidebar will be called.
 *                                 Default 'sidebar-$instance'.
 *     @type string $description   Description of the sidebar, displayed in the Widgets interface.
 *                                 Default empty string.
 *     @type string $class         Extra CSS class to assign to the sidebar in the Widgets interface.
 *                                 Default empty.
 *     @type string $before_widget HTML content to prepend to each widget's HTML output when
 *                                 assigned to this sidebar. Default is an opening list item element.
 *     @type string $after_widget  HTML content to append to each widget's HTML output when
 *                                 assigned to this sidebar. Default is a closing list item element.
 *     @type string $before_title  HTML content to prepend to the sidebar title when displayed.
 *                                 Default is an opening h2 element.
 *     @type string $after_title   HTML content to append to the sidebar title when displayed.
 *                                 Default is a closing h2 element.
 * }
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $id_is_empty = empty($args['id']);
    $defaults = array(
        /* translators: %d: Sidebar number. */
        'name' => sprintf(__('Sidebar %d'), $i),
        'id' => "sidebar-{$i}",
        'description' => '',
        'class' => '',
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => "</li>\n",
        'before_title' => '<h2 class="widgettitle">',
        'after_title' => "</h2>\n",
    );
    /**
     * Filters the sidebar default arguments.
     *
     * @since 5.3.0
     *
     * @see register_sidebar()
     *
     * @param array $defaults The default sidebar arguments.
     */
    $sidebar = wp_parse_args($args, apply_filters('register_sidebar_defaults', $defaults));
    if ($id_is_empty) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: 1: The 'id' argument, 2: Sidebar name, 3: Recommended 'id' value. */
            __('No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.'),
            '<code>id</code>',
            $sidebar['name'],
            $sidebar['id']
        ), '4.2.0');
    }
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    /**
     * Fires once a sidebar has been registered.
     *
     * @since 3.0.0
     *
     * @param array $sidebar Parsed arguments for the registered sidebar.
     */
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}

WordPress Version: 4.2

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments for the sidebar being registered.
 *
 *     @type string $name          The name or title of the sidebar displayed in the Widgets
 *                                 interface. Default 'Sidebar $instance'.
 *     @type string $id            The unique identifier by which the sidebar will be called.
 *                                 Default 'sidebar-$instance'.
 *     @type string $description   Description of the sidebar, displayed in the Widgets interface.
 *                                 Default empty string.
 *     @type string $class         Extra CSS class to assign to the sidebar in the Widgets interface.
 *                                 Default empty.
 *     @type string $before_widget HTML content to prepend to each widget's HTML output when
 *                                 assigned to this sidebar. Default is an opening list item element.
 *     @type string $after_widget  HTML content to append to each widget's HTML output when
 *                                 assigned to this sidebar. Default is a closing list item element.
 *     @type string $before_title  HTML content to prepend to the sidebar title when displayed.
 *                                 Default is an opening h2 element.
 *     @type string $after_title   HTML content to append to the sidebar title when displayed.
 *                                 Default is a closing h2 element.
 * }
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $id_is_empty = empty($args['id']);
    $defaults = array('name' => sprintf(__('Sidebar %d'), $i), 'id' => "sidebar-{$i}", 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => "</li>\n", 'before_title' => '<h2 class="widgettitle">', 'after_title' => "</h2>\n");
    $sidebar = wp_parse_args($args, $defaults);
    if ($id_is_empty) {
        /* translators: 1: the id argument, 2: sidebar name, 3: recommended id value */
        _doing_it_wrong(__FUNCTION__, sprintf(__('No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.'), '<code>id</code>', $sidebar['name'], $sidebar['id']), '4.2.0');
    }
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    /**
     * Fires once a sidebar has been registered.
     *
     * @since 3.0.0
     *
     * @param array $sidebar Parsed arguments for the registered sidebar.
     */
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}

WordPress Version: 4.1

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
 *
 * @param array|string $args {
 *     Optional. Array or string of arguments for the sidebar being registered.
 *
 *     @type string $name          The name or title of the sidebar displayed in the Widgets
 *                                 interface. Default 'Sidebar $instance'.
 *     @type string $id            The unique identifier by which the sidebar will be called.
 *                                 Default 'sidebar-$instance'.
 *     @type string $description   Description of the sidebar, displayed in the Widgets interface.
 *                                 Default empty string.
 *     @type string $class         Extra CSS class to assign to the sidebar in the Widgets interface.
 *                                 Default empty.
 *     @type string $before_widget HTML content to prepend to each widget's HTML output when
 *                                 assigned to this sidebar. Default is an opening list item element.
 *     @type string $after_widget  HTML content to append to each widget's HTML output when
 *                                 assigned to this sidebar. Default is a closing list item element.
 *     @type string $before_title  HTML content to prepend to the sidebar title when displayed.
 *                                 Default is an opening h2 element.
 *     @type string $after_title   HTML content to append to the sidebar title when displayed.
 *                                 Default is a closing h2 element.
 * }
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $defaults = array('name' => sprintf(__('Sidebar %d'), $i), 'id' => "sidebar-{$i}", 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => "</li>\n", 'before_title' => '<h2 class="widgettitle">', 'after_title' => "</h2>\n");
    $sidebar = wp_parse_args($args, $defaults);
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    /**
     * Fires once a sidebar has been registered.
     *
     * @since 3.0.0
     *
     * @param array $sidebar Parsed arguments for the registered sidebar.
     */
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}

WordPress Version: 3.9

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * Arguments passed as a string should be separated by '&':
 *
 *     e.g. 'name=Sidebar&id=my_prefix_sidebar'
 *
 * The same arguments passed as an array:
 *
 *     array(
 *         'name' => 'Sidebar',
 *         'id'   => 'my_prefix_sidebar',
 *     )
 *
 * Arguments:
 *     name          - The name or title of the sidebar displayed in the admin dashboard.
 *     id            - The unique identifier by which the sidebar will be called.
 *     before_widget - HTML content that will be prepended to each widget's HTML output
 *                     when assigned to this sidebar.
 *     after_widget  - HTML content that will be appended to each widget's HTML output
 *                     when assigned to this sidebar.
 *     before_title  - HTML content that will be prepended to the sidebar title when displayed.
 *     after_title   - HTML content that will be appended to the sidebar title when displayed.
 *
 * @since 2.2.0
 * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
 * @uses add_theme_support() to ensure widget support has been added.
 *
 * @param string|array $args Arguments for the sidebar being registered.
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $defaults = array('name' => sprintf(__('Sidebar %d'), $i), 'id' => "sidebar-{$i}", 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => "</li>\n", 'before_title' => '<h2 class="widgettitle">', 'after_title' => "</h2>\n");
    $sidebar = wp_parse_args($args, $defaults);
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    /**
     * Fires once a sidebar has been registered.
     *
     * @since 3.0.0
     *
     * @param array $sidebar Parsed arguments for the registered sidebar.
     */
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}

WordPress Version: 3.7

/**
 * Builds the definition for a single sidebar and returns the ID.
 *
 * Accepts either a string or an array and then parses that against a set
 * of default arguments for the new sidebar. WordPress will automatically
 * generate a sidebar ID and name based on the current number of registered
 * sidebars if those arguments are not included.
 *
 * When allowing for automatic generation of the name and ID parameters, keep
 * in mind that the incrementor for your sidebar can change over time depending
 * on what other plugins and themes are installed.
 *
 * If theme support for 'widgets' has not yet been added when this function is
 * called, it will be automatically enabled through the use of add_theme_support()
 *
 * Arguments passed as a string should be separated by '&':
 *
 *     e.g. 'name=Sidebar&id=my_prefix_sidebar'
 *
 * The same arguments passed as an array:
 *
 *     array(
 *         'name' => 'Sidebar',
 *         'id'   => 'my_prefix_sidebar',
 *     )
 *
 * Arguments:
 *     name          - The name or title of the sidebar displayed in the admin dashboard.
 *     id            - The unique identifier by which the sidebar will be called.
 *     before_widget - HTML content that will be prepended to each widget's HTML output
 *                     when assigned to this sidebar.
 *     after_widget  - HTML content that will be appended to each widget's HTML output
 *                     when assigned to this sidebar.
 *     before_title  - HTML content that will be prepended to the sidebar title when displayed.
 *     after_title   - HTML content that will be appended to the sidebar title when displayed.
 *
 * @since 2.2.0
 * @uses $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
 * @uses add_theme_support() to ensure widget support has been added.
 *
 * @param string|array $args Arguments for the sidebar being registered.
 * @return string Sidebar ID added to $wp_registered_sidebars global.
 */
function register_sidebar($args = array())
{
    global $wp_registered_sidebars;
    $i = count($wp_registered_sidebars) + 1;
    $defaults = array('name' => sprintf(__('Sidebar %d'), $i), 'id' => "sidebar-{$i}", 'description' => '', 'class' => '', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => "</li>\n", 'before_title' => '<h2 class="widgettitle">', 'after_title' => "</h2>\n");
    $sidebar = wp_parse_args($args, $defaults);
    $wp_registered_sidebars[$sidebar['id']] = $sidebar;
    add_theme_support('widgets');
    do_action('register_sidebar', $sidebar);
    return $sidebar['id'];
}