Changeset 14560
- Timestamp:
- 05/11/2010 03:55:17 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/nav-menu.php
r14557 r14560 406 406 */ 407 407 function wp_get_nav_menu_items( $menu, $args = array() ) { 408 global $_wp_using_ext_object_cache; 409 408 410 $menu = wp_get_nav_menu_object( $menu ); 409 411 410 412 if ( ! $menu ) 411 413 return false; 414 415 static $fetched = array(); 412 416 413 417 $items = get_objects_in_term( $menu->term_id, 'nav_menu' ); … … 430 434 431 435 // Get all posts and terms at once to prime the caches 432 $posts = array(); 433 $terms = array(); 434 foreach ( $items as $item ) { 435 $object_id = get_post_meta( $item->ID, '_menu_item_object_id', true ); 436 $object = get_post_meta( $item->ID, '_menu_item_object', true ); 437 $type = get_post_meta( $item->ID, '_menu_item_type', true ); 438 439 if ( 'post_type' == $type ) 440 $posts[$object][] = $object_id; 441 elseif ( 'taxonomy' == $type) 442 $terms[$object][] = $object_id; 443 } 444 445 if ( !empty($posts) ) { 446 foreach ( array_keys($posts) as $post_type ) { 447 get_posts( array('post__in' => $posts[$post_type], 'post_type' => $post_type, 'nopaging' => true, 'update_post_term_cache' => false) ); 448 } 449 } 450 unset($posts); 451 452 if ( !empty($terms) ) { 453 foreach ( array_keys($terms) as $taxonomy ) { 454 get_terms($taxonomy, array('include' => $terms[$taxonomy]) ); 455 } 456 } 457 unset($terms); 436 if ( empty($fetched[$menu->term_id]) || $_wp_using_ext_object_cache ) { 437 $fetched[$menu->term_id] = true; 438 $posts = array(); 439 $terms = array(); 440 foreach ( $items as $item ) { 441 $object_id = get_post_meta( $item->ID, '_menu_item_object_id', true ); 442 $object = get_post_meta( $item->ID, '_menu_item_object', true ); 443 $type = get_post_meta( $item->ID, '_menu_item_type', true ); 444 445 if ( 'post_type' == $type ) 446 $posts[$object][] = $object_id; 447 elseif ( 'taxonomy' == $type) 448 $terms[$object][] = $object_id; 449 } 450 451 if ( !empty($posts) ) { 452 foreach ( array_keys($posts) as $post_type ) { 453 get_posts( array('post__in' => $posts[$post_type], 'post_type' => $post_type, 'nopaging' => true, 'update_post_term_cache' => false) ); 454 } 455 } 456 unset($posts); 457 458 if ( !empty($terms) ) { 459 foreach ( array_keys($terms) as $taxonomy ) { 460 get_terms($taxonomy, array('include' => $terms[$taxonomy]) ); 461 } 462 } 463 unset($terms); 464 } 458 465 459 466 $items = array_map( 'wp_setup_nav_menu_item', $items );
Note: See TracChangeset
for help on using the changeset viewer.