Simplify the Id uniqueness loops. Guard against more use-cases which might cause ID conflicts. See #12606

git-svn-id: http://svn.automattic.com/wordpress/trunk@13699 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-03-14 11:34:51 +00:00
parent c6daeea61e
commit 2a7375a600
1 changed files with 6 additions and 11 deletions

View File

@ -489,17 +489,12 @@ function register_sidebars($number = 1, $args = array()) {
else
$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
if ( isset($args['id']) ) {
$_args['id'] = $args['id'];
if ( $number > 1 ) // Ensure that for multiple additions, the ID is unique (even if specified). Append -xx for > 1 sidebars.
$_args['id'] .= '-' . $i;
} else {
$n = count($wp_registered_sidebars);
do {
$n++;
$_args['id'] = "sidebar-$n";
} while ( isset($wp_registered_sidebars[$_args['id']]) );
}
$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++;
register_sidebar($_args);
}