WordPress.org

Make WordPress Core

Ticket #14235: menu_items_wrap_class.14235.diff

File menu_items_wrap_class.14235.diff, 1.5 KB (added by filosofo, 9 years ago)
  • wp-includes/nav-menu-template.php

     
    133133        static $menu_id_slugs = array();
    134134
    135135        $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',
    136         'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
     136        '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>',
    137137        'depth' => 0, 'walker' => '', 'theme_location' => '' );
    138138
    139139        $args = wp_parse_args( $args, $defaults );
     
    209209                }
    210210        }
    211211        $menu_id_slugs[] = $slug;
    212         $attributes = ' id="' . $slug . '"';
    213         $attributes .= $args->menu_class ? ' class="'. $args->menu_class .'"' : '';
     212       
     213        $wrap_class = $args->menu_class ? $args->menu_class : '';
    214214
    215         $nav_menu .= '<ul'. $attributes .'>';
    216 
    217215        // Allow plugins to hook into the menu to add their own <li>'s
    218216        $items = apply_filters( 'wp_nav_menu_items', $items, $args );
    219217        $items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
    220         $nav_menu .= $items;
     218       
     219        $nav_menu .= sprintf( $args->items_wrap, $slug, $wrap_class, $items );
    221220        unset($items);
    222221
    223         $nav_menu .= '</ul>';
    224 
    225222        if ( $show_container )
    226223                $nav_menu .= '</' . $args->container . '>';
    227224