WordPress.org

Make WordPress Core

Ticket #13057: container-id-rev-1.diff

File container-id-rev-1.diff, 1.8 KB (added by thee17, 4 years ago)

Patch to add feature

  • .php

    old new  
    1717 * menu_class - CSS class to use for the div container of the menu list. Defaults to 'menu'. 
    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. 
    2225 * link_before - Text before the link. 
     
    3033 * @param array $args Arguments 
    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' ); 
    3639 
     
    7073 
    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 
    7680        // Set up the $menu_item variables