WordPress.org

Make WordPress Core

Ticket #10092: 10092.patch

File 10092.patch, 639 bytes (added by azaozz, 6 years ago)
  • wp-admin/includes/widgets.php

     
    9797 
    9898function next_widget_id_number($id_base) { 
    9999        global $wp_registered_widgets; 
    100         $number = 2; 
     100        $number = 1; 
    101101 
    102         while ( isset($wp_registered_widgets["$id_base-$number"]) ) 
    103                 $number++; 
     102        foreach ( $wp_registered_widgets as $widget_id => $widget ) { 
     103                if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) ) 
     104                        $number = max($number, $matches[1]); 
     105        } 
     106        $number++; 
    104107 
    105108        return $number; 
    106109}