Ticket #13793: patch_menu_child_of.patch
| File patch_menu_child_of.patch, 2.1 KB (added by DreadLox, 3 years ago) |
|---|
-
wp-includes/nav-menu-template.php
134 134 135 135 $defaults = array( 'menu' => '', 'container' => 'div', 'container_class' => '', 'container_id' => '', 'menu_class' => 'menu', 'menu_id' => '', 136 136 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'before' => '', 'after' => '', 'link_before' => '', 'link_after' => '', 137 'depth' => 0, 'walker' => '', 'theme_location' => '' );137 'depth' => 0, 'walker' => '', 'theme_location' => '', 'child_of'=>0 ); 138 138 139 139 $args = wp_parse_args( $args, $defaults ); 140 140 $args = apply_filters( 'wp_nav_menu_args', $args ); … … 187 187 // Set up the $menu_item variables 188 188 _wp_menu_item_classes_by_context( $menu_items ); 189 189 190 if($args->child_of) $menu_items = & _wp_nav_menu_item_children( $args->child_of, $menu_items ); 191 190 192 $sorted_menu_items = array(); 191 193 foreach ( (array) $menu_items as $key => $menu_item ) 192 194 $sorted_menu_items[$menu_item->menu_order] = $menu_item; … … 357 359 } 358 360 359 361 /** 362 * Retrieve child menu items from list of menus matching menu ID. 363 * 364 * Matches against the menus parameter against the page ID. Also matches all 365 * children for the same to retrieve all children of a menu. Does not make any 366 * SQL queries to get the children. 367 * 368 * @since 1.5.1 369 * 370 * @param int $menu_id Menu Item ID. 371 * @param array $items List of menu items' objects. 372 * @return array 373 */ 374 function &_wp_nav_menu_item_children($item_id, $items) { 375 376 $item_list = array(); 377 foreach ( (array) $items as $item ) { 378 if ( $item->menu_item_parent == $item_id ) { 379 $item_list[] = $item; 380 381 $children = _wp_nav_menu_item_children($item->db_id, $items); 382 if ( $children ) { 383 $item_list = array_merge($item_list, $children); 384 } 385 } 386 } 387 388 return $item_list; 389 } 390 391 /** 360 392 * Retrieve the HTML list content for nav menu items. 361 393 * 362 394 * @uses Walker_Nav_Menu to create HTML list content.