WordPress.org

Make WordPress Core

Changeset 16520


Ignore:
Timestamp:
11/21/10 13:37:09 (4 years ago)
Author:
nacin
Message:

Escape the wrap ID and class attributes going into sprintf() and s/slug/wrap_id/ to make it more obvious. see #14235.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/nav-menu-template.php

    r16519 r16520  
    206206    // Attributes 
    207207    if ( ! empty( $args->menu_id ) ) { 
    208         $slug = $args->menu_id; 
     208        $wrap_id = $args->menu_id; 
    209209    } else { 
    210         $slug = 'menu-' . $menu->slug; 
    211         while ( in_array( $slug, $menu_id_slugs ) ) { 
    212             if ( preg_match( '#-(\d+)$#', $slug, $matches ) ) 
    213                 $slug = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $slug); 
     210        $wrap_id = 'menu-' . $menu->slug; 
     211        while ( in_array( $wrap_id, $menu_id_slugs ) ) { 
     212            if ( preg_match( '#-(\d+)$#', $wrap_id, $matches ) ) 
     213                $wrap_id = preg_replace('#-(\d+)$#', '-' . ++$matches[1], $wrap_id ); 
    214214            else 
    215                 $slug = $slug . '-1'; 
    216         } 
    217     } 
    218     $menu_id_slugs[] = $slug; 
    219      
     215                $wrap_id = $wrap_id . '-1'; 
     216        } 
     217    } 
     218    $menu_id_slugs[] = $wrap_id; 
     219 
    220220    $wrap_class = $args->menu_class ? $args->menu_class : ''; 
    221221 
     
    223223    $items = apply_filters( 'wp_nav_menu_items', $items, $args ); 
    224224    $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args ); 
    225      
    226     $nav_menu .= sprintf( $args->items_wrap, $slug, $wrap_class, $items ); 
    227     unset($items); 
     225 
     226    $nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items ); 
     227    unset( $items ); 
    228228 
    229229    if ( $show_container ) 
Note: See TracChangeset for help on using the changeset viewer.