From fe813ce063b5870130df9591a0b83cee5b326daa Mon Sep 17 00:00:00 2001 From: azaozz Date: Mon, 15 Jun 2009 23:57:52 +0000 Subject: [PATCH] Do not reuse deleted widget instances IDs, fixes #10092 for trunk git-svn-id: http://svn.automattic.com/wordpress/trunk@11577 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/widgets.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-admin/includes/widgets.php b/wp-admin/includes/widgets.php index 2be8145345..d6d930dae0 100644 --- a/wp-admin/includes/widgets.php +++ b/wp-admin/includes/widgets.php @@ -97,10 +97,13 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) { function next_widget_id_number($id_base) { global $wp_registered_widgets; - $number = 2; + $number = 1; - while ( isset($wp_registered_widgets["$id_base-$number"]) ) - $number++; + foreach ( $wp_registered_widgets as $widget_id => $widget ) { + if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) ) + $number = max($number, $matches[1]); + } + $number++; return $number; }