Revert [13699], It breaks dynamic_sidebar(<int>) compatibility. Use a safer loop for clashes. See #12606
git-svn-id: https://develop.svn.wordpress.org/trunk@13700 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
bd619cdb60
commit
20a430c8fb
|
@ -481,6 +481,7 @@ function register_sidebars($number = 1, $args = array()) {
|
||||||
if ( is_string($args) )
|
if ( is_string($args) )
|
||||||
parse_str($args, $args);
|
parse_str($args, $args);
|
||||||
|
|
||||||
|
$n = count($wp_registered_sidebars);
|
||||||
for ( $i = 1; $i <= $number; $i++ ) {
|
for ( $i = 1; $i <= $number; $i++ ) {
|
||||||
$_args = $args;
|
$_args = $args;
|
||||||
|
|
||||||
|
@ -489,13 +490,17 @@ function register_sidebars($number = 1, $args = array()) {
|
||||||
else
|
else
|
||||||
$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
|
$_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
|
||||||
|
|
||||||
$id = isset($args['id']) ? $args['id'] : 'sidebar';
|
// Custom specified ID's are suffixed if they exist already.
|
||||||
$_args['id'] = $id;
|
// Automatically generated sidebar names need to be suffixed regardless.
|
||||||
|
if ( isset($args['id']) ) {
|
||||||
$n = count($wp_registered_sidebars);
|
$_args['id'] = $args['id'];
|
||||||
while ( isset($wp_registered_sidebars[$_args['id']]) )
|
while ( isset($wp_registered_sidebars[$_args['id']]) )
|
||||||
$_args['id'] = $id . '-' . $n++;
|
$_args['id'] = $args['id'] . '-' . $n++;
|
||||||
|
} else {
|
||||||
|
do {
|
||||||
|
$_args['id'] = 'sidebar-' . $n++;
|
||||||
|
} while ( isset($wp_registered_sidebars[$_args['id']]) );
|
||||||
|
}
|
||||||
register_sidebar($_args);
|
register_sidebar($_args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue