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

git-svn-id: https://develop.svn.wordpress.org/trunk@13699 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2010-03-14 11:34:51 +00:00
parent a486d9ed55
commit bd619cdb60
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);
}