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
This commit is contained in:
azaozz 2009-06-15 23:57:52 +00:00
parent ae5848d393
commit fe813ce063
1 changed files with 6 additions and 3 deletions

View File

@ -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;
}