Make WordPress Core


Ignore:
Timestamp:
12/14/2007 08:06:08 AM (17 years ago)
Author:
ryan
Message:

Fix registration of multiple sidebars. Props watson. fixes #5352

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/widgets.php

    r6364 r6381  
    1414
    1515function register_sidebars($number = 1, $args = array()) {
     16    global $wp_registered_sidebars;
    1617    $number = (int) $number;
    1718
     
    2122    for ( $i=1; $i <= $number; $i++ ) {
    2223        $_args = $args;
     24
    2325        if ( $number > 1 ) {
    24             $_args['name'] = isset($args['name']) ? $args['name'] : sprintf(__('Sidebar %d'), $i);
     26            $_args['name'] = isset($args['name']) ? sprintf($args['name'], $i) : sprintf(__('Sidebar %d'), $i);
    2527        } else {
    2628            $_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
    2729        }
    28         $_args['id'] = isset($args['id']) ? $args['id'] : "sidebar-$i";
     30
     31        if (isset($args['id'])) {
     32            $_args['id'] = $args['id'];
     33        } else {
     34            $n = count($wp_registered_sidebars);
     35            do {
     36                $n++;
     37                $_args['id'] = "sidebar-$n";
     38            } while (isset($wp_registered_sidebars[$_args['id']]));
     39        }
     40
    2941        register_sidebar($_args);
    3042    }
Note: See TracChangeset for help on using the changeset viewer.