Make WordPress Core

Changeset 13699


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

Simplify the Id uniqueness loops. Guard against more use-cases which might cause ID conflicts. See #12606

File:
1 edited

Legend:

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

    r13698 r13699  
    490490            $_args['name'] = isset($args['name']) ? $args['name'] : __('Sidebar');
    491491
    492         if ( isset($args['id']) ) {
    493             $_args['id'] = $args['id'];
    494             if ( $number > 1 ) // Ensure that for multiple additions, the ID is unique (even if specified). Append -xx for > 1 sidebars.
    495                 $_args['id'] .= '-' . $i;
    496         } else {
    497             $n = count($wp_registered_sidebars);
    498             do {
    499                 $n++;
    500                 $_args['id'] = "sidebar-$n";
    501             } while ( isset($wp_registered_sidebars[$_args['id']]) );
    502         }
     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++;
    503498
    504499        register_sidebar($_args);
Note: See TracChangeset for help on using the changeset viewer.