WordPress.org

Make WordPress Core

Changeset 16519


Ignore:
Timestamp:
11/21/10 13:32:02 (5 years ago)
Author:
nacin
Message:

Introduce items_wrap arg to wp_nav_menu(). props filosofo, fixes #14235.

File:
1 edited

Legend:

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

    r16095 r16519  
    129129 * walker - allows a custom walker to be specified. 
    130130 * theme_location - the location in the theme to be used.  Must be registered with register_nav_menu() in order to be selectable by the user. 
     131 * items_wrap - How the list items should be wrapped. Defaults to a ul with an id and class. Uses printf() format with numbered placeholders. 
    131132 * 
    132133 * @since 3.0.0 
     
    138139 
    139140    $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 
    140     'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 
     141    'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>', 
    141142    'depth' => 0, 'walker' => '', 'theme_location' => '' ); 
    142143 
     
    216217    } 
    217218    $menu_id_slugs[] = $slug; 
    218     $attributes = ' id="' . $slug . '"'; 
    219     $attributes .= $args->menu_class ? ' class="'. $args->menu_class .'"' : ''; 
    220  
    221     $nav_menu .= '<ul'. $attributes .'>'; 
     219     
     220    $wrap_class = $args->menu_class ? $args->menu_class : ''; 
    222221 
    223222    // Allow plugins to hook into the menu to add their own <li>'s 
    224223    $items = apply_filters( 'wp_nav_menu_items', $items, $args ); 
    225224    $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args ); 
    226     $nav_menu .= $items; 
     225     
     226    $nav_menu .= sprintf( $args->items_wrap, $slug, $wrap_class, $items ); 
    227227    unset($items); 
    228  
    229     $nav_menu .= '</ul>'; 
    230228 
    231229    if ( $show_container ) 
Note: See TracChangeset for help on using the changeset viewer.