From 84e54974f1dbf6a43e3f00e3fe8a4c64713ae6d2 Mon Sep 17 00:00:00 2001 From: westi Date: Wed, 21 Apr 2010 21:32:08 +0000 Subject: [PATCH] Allow a theme to set an id on the container object for the wp_nav_menu output. Fixes #13057 props thee17. git-svn-id: http://svn.automattic.com/wordpress/trunk@14182 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/nav-menu-template.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/nav-menu-template.php b/wp-includes/nav-menu-template.php index 9751b9ada1..f547d9a163 100644 --- a/wp-includes/nav-menu-template.php +++ b/wp-includes/nav-menu-template.php @@ -17,6 +17,9 @@ * menu_class - CSS class to use for the div container of the menu list. Defaults to 'menu'. * format - Whether to format the ul. Defaults to 'div'. * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'. + * container - Type of container tag. Avalible options div, p, or nav. Defaults to 'div'. + * container_class - Chooses a class for the container. + * container_id - Chooses an id for the container. * before - Text before the link text. * after - Text after the link text. * link_before - Text before the link. @@ -30,7 +33,7 @@ * @param array $args Arguments */ function wp_nav_menu( $args = array() ) { - $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true, + $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 'depth' => 0, 'walker' => '', 'context' => 'frontend' ); @@ -70,7 +73,8 @@ function wp_nav_menu( $args = array() ) { if ( in_array( $args->container, $container_allowedtags ) ) { $class = $args->container_class ? ' class="' . esc_attr($args->container_class) . '"' : ' class="menu-'. $menu->slug .'-container"'; - $nav_menu .= '<'. $args->container . $class .'>'; + $container_id = $args->container_id ? ' id="' . esc_attr($args->container_id) . '"' : '' ; + $nav_menu .= '<'. $args->container . $class . $container_id .'>'; } // Set up the $menu_item variables