Make WordPress Core

Changeset 13700


Ignore:
Timestamp:
03/14/2010 11:58:53 AM (15 years ago)
Author:
dd32
Message:

Revert [13699], It breaks dynamic_sidebar(<int>) compatibility. Use a safer loop for clashes. See #12606

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/widgets.php

    r13699 r13700  
    482482        parse_str($args, $args);
    483483
     484    $n = count($wp_registered_sidebars);
    484485    for ( $i = 1; $i <= $number; $i++ ) {
    485486        $_args = $args;
     
    490491            $_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
    491492
    492         $id = isset($args['id']) ? $args['id'] : 'sidebar';
    493         $_args['id'] = $id;
    494 
    495         $n = count($wp_registered_sidebars);
    496         while ( isset($wp_registered_sidebars[$_args['id']]) )
    497             $_args['id'] = $id . '-' . $n++;
    498 
     493        // Custom specified ID's are suffixed if they exist already.
     494        // Automatically generated sidebar names need to be suffixed regardless.
     495        if ( isset($args['id']) ) {
     496            $_args['id'] = $args['id'];
     497            while ( isset($wp_registered_sidebars[$_args['id']]) )
     498                $_args['id'] = $args['id'] . '-' . $n++;
     499        } else {
     500            do {
     501                $_args['id'] = 'sidebar-' . $n++;
     502            } while ( isset($wp_registered_sidebars[$_args['id']]) );
     503        }
    499504        register_sidebar($_args);
    500505    }
Note: See TracChangeset for help on using the changeset viewer.