Revert [13699], It breaks dynamic_sidebar(<int>) compatibility. Use a safer loop for clashes. See #12606

git-svn-id: http://svn.automattic.com/wordpress/trunk@13700 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-03-14 11:58:53 +00:00
parent 2a7375a600
commit a9ff74237a
1 changed files with 12 additions and 7 deletions

View File

@ -481,6 +481,7 @@ function register_sidebars($number = 1, $args = array()) {
if ( is_string($args) )
parse_str($args, $args);
$n = count($wp_registered_sidebars);
for ( $i = 1; $i <= $number; $i++ ) {
$_args = $args;
@ -489,13 +490,17 @@ function register_sidebars($number = 1, $args = array()) {
else
$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
$id = isset($args['id']) ? $args['id'] : 'sidebar';
$_args['id'] = $id;
$n = count($wp_registered_sidebars);
while ( isset($wp_registered_sidebars[$_args['id']]) )
$_args['id'] = $id . '-' . $n++;
// Custom specified ID's are suffixed if they exist already.
// Automatically generated sidebar names need to be suffixed regardless.
if ( isset($args['id']) ) {
$_args['id'] = $args['id'];
while ( isset($wp_registered_sidebars[$_args['id']]) )
$_args['id'] = $args['id'] . '-' . $n++;
} else {
do {
$_args['id'] = 'sidebar-' . $n++;
} while ( isset($wp_registered_sidebars[$_args['id']]) );
}
register_sidebar($_args);
}
}