Make WordPress Core

Changeset 14182


Ignore:
Timestamp:
04/21/2010 09:32:08 PM (14 years ago)
Author:
westi
Message:

Allow a theme to set an id on the container object for the wp_nav_menu output. Fixes #13057 props thee17.

File:
1 edited

Legend:

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

    r14031 r14182  
    1818 * format - Whether to format the ul. Defaults to 'div'.
    1919 * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'.
     20 * container - Type of container tag. Avalible options div, p, or nav. Defaults to 'div'.
     21 * container_class - Chooses a class for the container.
     22 * container_id - Chooses an id for the container.
    2023 * before - Text before the link text.
    2124 * after - Text after the link text.
     
    3134 */
    3235function wp_nav_menu( $args = array() ) {
    33     $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true,
     36    $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'echo' => true,
    3437    'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '',
    3538    'depth' => 0, 'walker' => '', 'context' => 'frontend' );
     
    7174    if ( in_array( $args->container, $container_allowedtags ) ) {
    7275        $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : ' class="menu-'. $menu->slug .'-container"';
    73         $nav_menu .= '<'. $args->container . $class .'>';
     76        $container_id = $args->container_id ? ' id="' . esc_attr($args->container_id) . '"' : '' ;
     77        $nav_menu .= '<'. $args->container . $class . $container_id .'>';
    7478    }
    7579
Note: See TracChangeset for help on using the changeset viewer.