Do not reuse deleted widget instances IDs, fixes #10092 for 2.8.1

git-svn-id: http://svn.automattic.com/wordpress/branches/2.8@11576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-06-15 23:57:00 +00:00
parent 8322d8aca0
commit 141b34477f
1 changed files with 6 additions and 3 deletions

View File

@ -97,9 +97,12 @@ function wp_list_widget_controls_dynamic_sidebar( $params ) {
function next_widget_id_number($id_base) { function next_widget_id_number($id_base) {
global $wp_registered_widgets; global $wp_registered_widgets;
$number = 2; $number = 1;
while ( isset($wp_registered_widgets["$id_base-$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++; $number++;
return $number; return $number;