From 2a7375a600297fb8717fbf60d5bd14a6224f2d81 Mon Sep 17 00:00:00 2001 From: dd32 Date: Sun, 14 Mar 2010 11:34:51 +0000 Subject: [PATCH] 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 --- wp-includes/widgets.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php index 008f1bca6..4c7e11ccd 100644 --- a/wp-includes/widgets.php +++ b/wp-includes/widgets.php @@ -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); }