Make WordPress Core


Ignore:
Timestamp:
09/24/2015 12:29:54 AM (9 years ago)
Author:
wonderboymusic
Message:

Widgets: when passing a string arg value to dynamic_sidebar(), don't reset $index when the arg's sanitized value matches the sanitized name of a sidebar.

Adds unit test.

Props tyxla, fjarrett.
Fixes #23423.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/widget-functions.php

    r34392 r34465  
    502502 * @return bool True, if widget sidebar was found and called. False if not found or not called.
    503503 */
    504 function dynamic_sidebar($index = 1) {
     504function dynamic_sidebar( $index = 1 ) {
    505505    global $wp_registered_sidebars, $wp_registered_widgets;
    506506
    507     if ( is_int($index) ) {
     507    if ( is_int( $index ) ) {
    508508        $index = "sidebar-$index";
    509509    } else {
    510         $index = sanitize_title($index);
     510        $sanitized_index = sanitize_title( $index );
    511511        foreach ( (array) $wp_registered_sidebars as $key => $value ) {
    512             if ( sanitize_title($value['name']) == $index ) {
     512            if ( sanitize_title( $value['name'] ) == $sanitized_index ) {
    513513                $index = $key;
    514514                break;
Note: See TracChangeset for help on using the changeset viewer.