wp/wp-includes/nav-menu-template.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
     8  */
     8  */
     9 
     9 
    10 /**
    10 /**
    11  * Create HTML list of nav menu items.
    11  * Create HTML list of nav menu items.
    12  *
    12  *
    13  * @package WordPress
       
    14  * @since 3.0.0
    13  * @since 3.0.0
    15  * @uses Walker
    14  * @uses Walker
    16  */
    15  */
    17 class Walker_Nav_Menu extends Walker {
    16 class Walker_Nav_Menu extends Walker {
    18 	/**
    17 	/**
    20 	 *
    19 	 *
    21 	 * @see Walker::$tree_type
    20 	 * @see Walker::$tree_type
    22 	 * @since 3.0.0
    21 	 * @since 3.0.0
    23 	 * @var string
    22 	 * @var string
    24 	 */
    23 	 */
    25 	var $tree_type = array( 'post_type', 'taxonomy', 'custom' );
    24 	public $tree_type = array( 'post_type', 'taxonomy', 'custom' );
    26 
    25 
    27 	/**
    26 	/**
    28 	 * Database fields to use.
    27 	 * Database fields to use.
    29 	 *
    28 	 *
    30 	 * @see Walker::$db_fields
    29 	 * @see Walker::$db_fields
    31 	 * @since 3.0.0
    30 	 * @since 3.0.0
    32 	 * @todo Decouple this.
    31 	 * @todo Decouple this.
    33 	 * @var array
    32 	 * @var array
    34 	 */
    33 	 */
    35 	var $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
    34 	public $db_fields = array( 'parent' => 'menu_item_parent', 'id' => 'db_id' );
    36 
    35 
    37 	/**
    36 	/**
    38 	 * Starts the list before the elements are added.
    37 	 * Starts the list before the elements are added.
    39 	 *
    38 	 *
    40 	 * @see Walker::start_lvl()
    39 	 * @see Walker::start_lvl()
    43 	 *
    42 	 *
    44 	 * @param string $output Passed by reference. Used to append additional content.
    43 	 * @param string $output Passed by reference. Used to append additional content.
    45 	 * @param int    $depth  Depth of menu item. Used for padding.
    44 	 * @param int    $depth  Depth of menu item. Used for padding.
    46 	 * @param array  $args   An array of arguments. @see wp_nav_menu()
    45 	 * @param array  $args   An array of arguments. @see wp_nav_menu()
    47 	 */
    46 	 */
    48 	function start_lvl( &$output, $depth = 0, $args = array() ) {
    47 	public function start_lvl( &$output, $depth = 0, $args = array() ) {
    49 		$indent = str_repeat("\t", $depth);
    48 		$indent = str_repeat("\t", $depth);
    50 		$output .= "\n$indent<ul class=\"sub-menu\">\n";
    49 		$output .= "\n$indent<ul class=\"sub-menu\">\n";
    51 	}
    50 	}
    52 
    51 
    53 	/**
    52 	/**
    59 	 *
    58 	 *
    60 	 * @param string $output Passed by reference. Used to append additional content.
    59 	 * @param string $output Passed by reference. Used to append additional content.
    61 	 * @param int    $depth  Depth of menu item. Used for padding.
    60 	 * @param int    $depth  Depth of menu item. Used for padding.
    62 	 * @param array  $args   An array of arguments. @see wp_nav_menu()
    61 	 * @param array  $args   An array of arguments. @see wp_nav_menu()
    63 	 */
    62 	 */
    64 	function end_lvl( &$output, $depth = 0, $args = array() ) {
    63 	public function end_lvl( &$output, $depth = 0, $args = array() ) {
    65 		$indent = str_repeat("\t", $depth);
    64 		$indent = str_repeat("\t", $depth);
    66 		$output .= "$indent</ul>\n";
    65 		$output .= "$indent</ul>\n";
    67 	}
    66 	}
    68 
    67 
    69 	/**
    68 	/**
    77 	 * @param object $item   Menu item data object.
    76 	 * @param object $item   Menu item data object.
    78 	 * @param int    $depth  Depth of menu item. Used for padding.
    77 	 * @param int    $depth  Depth of menu item. Used for padding.
    79 	 * @param array  $args   An array of arguments. @see wp_nav_menu()
    78 	 * @param array  $args   An array of arguments. @see wp_nav_menu()
    80 	 * @param int    $id     Current item ID.
    79 	 * @param int    $id     Current item ID.
    81 	 */
    80 	 */
    82 	function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
    81 	public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
    83 		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    82 		$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
    84 
       
    85 		$class_names = $value = '';
       
    86 
    83 
    87 		$classes = empty( $item->classes ) ? array() : (array) $item->classes;
    84 		$classes = empty( $item->classes ) ? array() : (array) $item->classes;
    88 		$classes[] = 'menu-item-' . $item->ID;
    85 		$classes[] = 'menu-item-' . $item->ID;
    89 
    86 
    90 		/**
    87 		/**
    91 		 * Filter the CSS class(es) applied to a menu item's <li>.
    88 		 * Filter the CSS class(es) applied to a menu item's list item element.
    92 		 *
    89 		 *
    93 		 * @since 3.0.0
    90 		 * @since 3.0.0
    94 		 *
    91 		 * @since 4.1.0 The `$depth` parameter was added.
    95 		 * @param array  $classes The CSS classes that are applied to the menu item's <li>.
    92 		 *
       
    93 		 * @param array  $classes The CSS classes that are applied to the menu item's `<li>` element.
    96 		 * @param object $item    The current menu item.
    94 		 * @param object $item    The current menu item.
    97 		 * @param array  $args    An array of arguments. @see wp_nav_menu()
    95 		 * @param array  $args    An array of {@see wp_nav_menu()} arguments.
       
    96 		 * @param int    $depth   Depth of menu item. Used for padding.
    98 		 */
    97 		 */
    99 		$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
    98 		$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) );
   100 		$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
    99 		$class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
   101 
   100 
   102 		/**
   101 		/**
   103 		 * Filter the ID applied to a menu item's <li>.
   102 		 * Filter the ID applied to a menu item's list item element.
   104 		 *
   103 		 *
   105 		 * @since 3.0.1
   104 		 * @since 3.0.1
   106 		 *
   105 		 * @since 4.1.0 The `$depth` parameter was added.
   107 		 * @param string The ID that is applied to the menu item's <li>.
   106 		 *
   108 		 * @param object $item The current menu item.
   107 		 * @param string $menu_id The ID that is applied to the menu item's `<li>` element.
   109 		 * @param array $args An array of arguments. @see wp_nav_menu()
   108 		 * @param object $item    The current menu item.
       
   109 		 * @param array  $args    An array of {@see wp_nav_menu()} arguments.
       
   110 		 * @param int    $depth   Depth of menu item. Used for padding.
   110 		 */
   111 		 */
   111 		$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args );
   112 		$id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth );
   112 		$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
   113 		$id = $id ? ' id="' . esc_attr( $id ) . '"' : '';
   113 
   114 
   114 		$output .= $indent . '<li' . $id . $value . $class_names .'>';
   115 		$output .= $indent . '<li' . $id . $class_names .'>';
   115 
   116 
   116 		$atts = array();
   117 		$atts = array();
   117 		$atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : '';
   118 		$atts['title']  = ! empty( $item->attr_title ) ? $item->attr_title : '';
   118 		$atts['target'] = ! empty( $item->target )     ? $item->target     : '';
   119 		$atts['target'] = ! empty( $item->target )     ? $item->target     : '';
   119 		$atts['rel']    = ! empty( $item->xfn )        ? $item->xfn        : '';
   120 		$atts['rel']    = ! empty( $item->xfn )        ? $item->xfn        : '';
   120 		$atts['href']   = ! empty( $item->url )        ? $item->url        : '';
   121 		$atts['href']   = ! empty( $item->url )        ? $item->url        : '';
   121 
   122 
   122 		/**
   123 		/**
   123 		 * Filter the HTML attributes applied to a menu item's <a>.
   124 		 * Filter the HTML attributes applied to a menu item's anchor element.
   124 		 *
   125 		 *
   125 		 * @since 3.6.0
   126 		 * @since 3.6.0
       
   127 		 * @since 4.1.0 The `$depth` parameter was added.
   126 		 *
   128 		 *
   127 		 * @param array $atts {
   129 		 * @param array $atts {
   128 		 *     The HTML attributes applied to the menu item's <a>, empty strings are ignored.
   130 		 *     The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored.
   129 		 *
   131 		 *
   130 		 *     @type string $title  The title attribute.
   132 		 *     @type string $title  Title attribute.
   131 		 *     @type string $target The target attribute.
   133 		 *     @type string $target Target attribute.
   132 		 *     @type string $rel    The rel attribute.
   134 		 *     @type string $rel    The rel attribute.
   133 		 *     @type string $href   The href attribute.
   135 		 *     @type string $href   The href attribute.
   134 		 * }
   136 		 * }
   135 		 * @param object $item The current menu item.
   137 		 * @param object $item  The current menu item.
   136 		 * @param array  $args An array of arguments. @see wp_nav_menu()
   138 		 * @param array  $args  An array of {@see wp_nav_menu()} arguments.
       
   139 		 * @param int    $depth Depth of menu item. Used for padding.
   137 		 */
   140 		 */
   138 		$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args );
   141 		$atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
   139 
   142 
   140 		$attributes = '';
   143 		$attributes = '';
   141 		foreach ( $atts as $attr => $value ) {
   144 		foreach ( $atts as $attr => $value ) {
   142 			if ( ! empty( $value ) ) {
   145 			if ( ! empty( $value ) ) {
   143 				$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
   146 				$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
   153 		$item_output .= $args->after;
   156 		$item_output .= $args->after;
   154 
   157 
   155 		/**
   158 		/**
   156 		 * Filter a menu item's starting output.
   159 		 * Filter a menu item's starting output.
   157 		 *
   160 		 *
   158 		 * The menu item's starting output only includes $args->before, the opening <a>,
   161 		 * The menu item's starting output only includes `$args->before`, the opening `<a>`,
   159 		 * the menu item's title, the closing </a>, and $args->after. Currently, there is
   162 		 * the menu item's title, the closing `</a>`, and `$args->after`. Currently, there is
   160 		 * no filter for modifying the opening and closing <li> for a menu item.
   163 		 * no filter for modifying the opening and closing `<li>` for a menu item.
   161 		 *
   164 		 *
   162 		 * @since 3.0.0
   165 		 * @since 3.0.0
   163 		 *
   166 		 *
   164 		 * @param string $item_output The menu item's starting HTML output.
   167 		 * @param string $item_output The menu item's starting HTML output.
   165 		 * @param object $item        Menu item data object.
   168 		 * @param object $item        Menu item data object.
   166 		 * @param int    $depth       Depth of menu item. Used for padding.
   169 		 * @param int    $depth       Depth of menu item. Used for padding.
   167 		 * @param array  $args        An array of arguments. @see wp_nav_menu()
   170 		 * @param array  $args        An array of {@see wp_nav_menu()} arguments.
   168 		 */
   171 		 */
   169 		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
   172 		$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
   170 	}
   173 	}
   171 
   174 
   172 	/**
   175 	/**
   179 	 * @param string $output Passed by reference. Used to append additional content.
   182 	 * @param string $output Passed by reference. Used to append additional content.
   180 	 * @param object $item   Page data object. Not used.
   183 	 * @param object $item   Page data object. Not used.
   181 	 * @param int    $depth  Depth of page. Not Used.
   184 	 * @param int    $depth  Depth of page. Not Used.
   182 	 * @param array  $args   An array of arguments. @see wp_nav_menu()
   185 	 * @param array  $args   An array of arguments. @see wp_nav_menu()
   183 	 */
   186 	 */
   184 	function end_el( &$output, $item, $depth = 0, $args = array() ) {
   187 	public function end_el( &$output, $item, $depth = 0, $args = array() ) {
   185 		$output .= "</li>\n";
   188 		$output .= "</li>\n";
   186 	}
   189 	}
   187 
   190 
   188 } // Walker_Nav_Menu
   191 } // Walker_Nav_Menu
   189 
   192 
   190 /**
   193 /**
   191  * Displays a navigation menu.
   194  * Displays a navigation menu.
   192  *
   195  *
   193  * Optional $args contents:
       
   194  *
       
   195  * menu - The menu that is desired. Accepts (matching in order) id, slug, name. Defaults to blank.
       
   196  * menu_class - CSS class to use for the ul element which forms the menu. Defaults to 'menu'.
       
   197  * menu_id - The ID that is applied to the ul element which forms the menu. Defaults to the menu slug, incremented.
       
   198  * container - Whether to wrap the ul, and what to wrap it with. Defaults to 'div'.
       
   199  * container_class - the class that is applied to the container. Defaults to 'menu-{menu slug}-container'.
       
   200  * container_id - The ID that is applied to the container. Defaults to blank.
       
   201  * fallback_cb - If the menu doesn't exists, a callback function will fire. Defaults to 'wp_page_menu'. Set to false for no fallback.
       
   202  * before - Text before the link text.
       
   203  * after - Text after the link text.
       
   204  * link_before - Text before the link.
       
   205  * link_after - Text after the link.
       
   206  * echo - Whether to echo the menu or return it. Defaults to echo.
       
   207  * depth - how many levels of the hierarchy are to be included. 0 means all. Defaults to 0.
       
   208  * walker - allows a custom walker to be specified.
       
   209  * 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.
       
   210  * items_wrap - How the list items should be wrapped. Defaults to a ul with an id and class. Uses printf() format with numbered placeholders.
       
   211  *
       
   212  * @since 3.0.0
   196  * @since 3.0.0
   213  *
   197  *
   214  * @param array $args Arguments
   198  * @param array $args {
       
   199  *     Optional. Array of nav menu arguments.
       
   200  *
       
   201  *     @type string        $menu            Desired menu. Accepts (matching in order) id, slug, name. Default empty.
       
   202  *     @type string        $menu_class      CSS class to use for the ul element which forms the menu. Default 'menu'.
       
   203  *     @type string        $menu_id         The ID that is applied to the ul element which forms the menu.
       
   204  *                                          Default is the menu slug, incremented.
       
   205  *     @type string        $container       Whether to wrap the ul, and what to wrap it with. Default 'div'.
       
   206  *     @type string        $container_class Class that is applied to the container. Default 'menu-{menu slug}-container'.
       
   207  *     @type string        $container_id    The ID that is applied to the container. Default empty.
       
   208  *     @type callback|bool $fallback_cb     If the menu doesn't exists, a callback function will fire.
       
   209  *                                          Default is 'wp_page_menu'. Set to false for no fallback.
       
   210  *     @type string        $before          Text before the link text. Default empty.
       
   211  *     @type string        $after           Text after the link text. Default empty.
       
   212  *     @type string        $link_before     Text before the link. Default empty.
       
   213  *     @type string        $link_after      Text after the link. Default empty.
       
   214  *     @type bool          $echo            Whether to echo the menu or return it. Default true.
       
   215  *     @type int           $depth           How many levels of the hierarchy are to be included. 0 means all. Default 0.
       
   216  *     @type object        $walker          Instance of a custom walker class. Default empty.
       
   217  *     @type string        $theme_location  Theme location to be used. Must be registered with register_nav_menu()
       
   218  *                                          in order to be selectable by the user.
       
   219  *     @type string        $items_wrap      How the list items should be wrapped. Default is a ul with an id and class.
       
   220  *                                          Uses printf() format with numbered placeholders.
       
   221  * }
       
   222  * @return mixed Menu output if $echo is false, false if there are no items or no menu was found.
   215  */
   223  */
   216 function wp_nav_menu( $args = array() ) {
   224 function wp_nav_menu( $args = array() ) {
   217 	static $menu_id_slugs = array();
   225 	static $menu_id_slugs = array();
   218 
   226 
   219 	$defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',
   227 	$defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '',
   224 	/**
   232 	/**
   225 	 * Filter the arguments used to display a navigation menu.
   233 	 * Filter the arguments used to display a navigation menu.
   226 	 *
   234 	 *
   227 	 * @since 3.0.0
   235 	 * @since 3.0.0
   228 	 *
   236 	 *
   229 	 * @param array $args Arguments from {@see wp_nav_menu()}.
   237 	 * @see wp_nav_menu()
       
   238 	 *
       
   239 	 * @param array $args Array of wp_nav_menu() arguments.
   230 	 */
   240 	 */
   231 	$args = apply_filters( 'wp_nav_menu_args', $args );
   241 	$args = apply_filters( 'wp_nav_menu_args', $args );
   232 	$args = (object) $args;
   242 	$args = (object) $args;
       
   243 
       
   244 	/**
       
   245 	 * Filter whether to short-circuit the wp_nav_menu() output.
       
   246 	 *
       
   247 	 * Returning a non-null value to the filter will short-circuit
       
   248 	 * wp_nav_menu(), echoing that value if $args->echo is true,
       
   249 	 * returning that value otherwise.
       
   250 	 *
       
   251 	 * @since 3.9.0
       
   252 	 *
       
   253 	 * @see wp_nav_menu()
       
   254 	 *
       
   255 	 * @param string|null $output Nav menu output to short-circuit with. Default null.
       
   256 	 * @param object      $args   An object containing wp_nav_menu() arguments.
       
   257 	 */
       
   258 	$nav_menu = apply_filters( 'pre_wp_nav_menu', null, $args );
       
   259 
       
   260 	if ( null !== $nav_menu ) {
       
   261 		if ( $args->echo ) {
       
   262 			echo $nav_menu;
       
   263 			return;
       
   264 		}
       
   265 
       
   266 		return $nav_menu;
       
   267 	}
   233 
   268 
   234 	// Get the nav menu based on the requested menu
   269 	// Get the nav menu based on the requested menu
   235 	$menu = wp_get_nav_menu_object( $args->menu );
   270 	$menu = wp_get_nav_menu_object( $args->menu );
   236 
   271 
   237 	// Get the nav menu based on the theme_location
   272 	// Get the nav menu based on the theme_location
   275 		/**
   310 		/**
   276 		 * Filter the list of HTML tags that are valid for use as menu containers.
   311 		 * Filter the list of HTML tags that are valid for use as menu containers.
   277 		 *
   312 		 *
   278 		 * @since 3.0.0
   313 		 * @since 3.0.0
   279 		 *
   314 		 *
   280 		 * @param array The acceptable HTML tags for use as menu containers, defaults as 'div' and 'nav'.
   315 		 * @param array $tags The acceptable HTML tags for use as menu containers.
       
   316 		 *                    Default is array containing 'div' and 'nav'.
   281 		 */
   317 		 */
   282 		$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
   318 		$allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
   283 		if ( in_array( $args->container, $allowed_tags ) ) {
   319 		if ( in_array( $args->container, $allowed_tags ) ) {
   284 			$show_container = true;
   320 			$show_container = true;
   285 			$class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-'. $menu->slug .'-container"';
   321 			$class = $args->container_class ? ' class="' . esc_attr( $args->container_class ) . '"' : ' class="menu-'. $menu->slug .'-container"';
   311 	/**
   347 	/**
   312 	 * Filter the sorted list of menu item objects before generating the menu's HTML.
   348 	 * Filter the sorted list of menu item objects before generating the menu's HTML.
   313 	 *
   349 	 *
   314 	 * @since 3.1.0
   350 	 * @since 3.1.0
   315 	 *
   351 	 *
   316 	 * @param array $sorted_menu_items The menu items, sorted by each menu item's menu order.
   352 	 * @param array  $sorted_menu_items The menu items, sorted by each menu item's menu order.
       
   353 	 * @param object $args              An object containing wp_nav_menu() arguments.
   317 	 */
   354 	 */
   318 	$sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
   355 	$sorted_menu_items = apply_filters( 'wp_nav_menu_objects', $sorted_menu_items, $args );
   319 
   356 
   320 	$items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
   357 	$items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
   321 	unset($sorted_menu_items);
   358 	unset($sorted_menu_items);
   339 	/**
   376 	/**
   340 	 * Filter the HTML list content for navigation menus.
   377 	 * Filter the HTML list content for navigation menus.
   341 	 *
   378 	 *
   342 	 * @since 3.0.0
   379 	 * @since 3.0.0
   343 	 *
   380 	 *
       
   381 	 * @see wp_nav_menu()
       
   382 	 *
   344 	 * @param string $items The HTML list content for the menu items.
   383 	 * @param string $items The HTML list content for the menu items.
   345 	 * @param array $args Arguments from {@see wp_nav_menu()}.
   384 	 * @param object $args  An object containing wp_nav_menu() arguments.
   346 	 */
   385 	 */
   347 	$items = apply_filters( 'wp_nav_menu_items', $items, $args );
   386 	$items = apply_filters( 'wp_nav_menu_items', $items, $args );
   348 	/**
   387 	/**
   349 	 * Filter the HTML list content for a specific navigation menu.
   388 	 * Filter the HTML list content for a specific navigation menu.
   350 	 *
   389 	 *
   351 	 * @since 3.0.0
   390 	 * @since 3.0.0
   352 	 *
   391 	 *
       
   392 	 * @see wp_nav_menu()
       
   393 	 *
   353 	 * @param string $items The HTML list content for the menu items.
   394 	 * @param string $items The HTML list content for the menu items.
   354 	 * @param array $args Arguments from {@see wp_nav_menu()}.
   395 	 * @param object $args  An object containing wp_nav_menu() arguments.
   355 	 */
   396 	 */
   356 	$items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
   397 	$items = apply_filters( "wp_nav_menu_{$menu->slug}_items", $items, $args );
   357 
   398 
   358 	// Don't print any markup if there are no items at this point.
   399 	// Don't print any markup if there are no items at this point.
   359 	if ( empty( $items ) )
   400 	if ( empty( $items ) )
   368 	/**
   409 	/**
   369 	 * Filter the HTML content for navigation menus.
   410 	 * Filter the HTML content for navigation menus.
   370 	 *
   411 	 *
   371 	 * @since 3.0.0
   412 	 * @since 3.0.0
   372 	 *
   413 	 *
       
   414 	 * @see wp_nav_menu()
       
   415 	 *
   373 	 * @param string $nav_menu The HTML content for the navigation menu.
   416 	 * @param string $nav_menu The HTML content for the navigation menu.
   374 	 * @param array $args Arguments from {@see wp_nav_menu()}.
   417 	 * @param object $args     An object containing wp_nav_menu() arguments.
   375 	 */
   418 	 */
   376 	$nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
   419 	$nav_menu = apply_filters( 'wp_nav_menu', $nav_menu, $args );
   377 
   420 
   378 	if ( $args->echo )
   421 	if ( $args->echo )
   379 		echo $nav_menu;
   422 		echo $nav_menu;
   383 
   426 
   384 /**
   427 /**
   385  * Add the class property classes for the current context, if applicable.
   428  * Add the class property classes for the current context, if applicable.
   386  *
   429  *
   387  * @access private
   430  * @access private
   388  * @since 3.0
   431  * @since 3.0.0
   389  *
   432  *
   390  * @param array $menu_items The current menu item objects to which to add the class property information.
   433  * @param array $menu_items The current menu item objects to which to add the class property information.
   391  */
   434  */
   392 function _wp_menu_item_classes_by_context( &$menu_items ) {
   435 function _wp_menu_item_classes_by_context( &$menu_items ) {
   393 	global $wp_query, $wp_rewrite;
   436 	global $wp_query, $wp_rewrite;
   628 	if ( in_array( $item->ID, $_used_ids ) )
   671 	if ( in_array( $item->ID, $_used_ids ) )
   629 		return '';
   672 		return '';
   630 	$_used_ids[] = $item->ID;
   673 	$_used_ids[] = $item->ID;
   631 	return $id;
   674 	return $id;
   632 }
   675 }
   633 add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );