Changes in trunk/wp-includes/nav-menu.php [15788:18277]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/nav-menu.php
r15788 r18277 444 444 445 445 /** 446 * Returns if a menu item is valid. Bug #13958 447 * 448 * @since 3.2.0 449 * @access private 450 * 451 * @param object $menu_item The menu item to check 452 * @return bool false if invalid, else true. 453 */ 454 function _is_valid_nav_menu_item( $item ) { 455 if ( ! empty( $item->_invalid ) ) 456 return false; 457 458 return true; 459 } 460 461 /** 446 462 * Returns all menu items of a navigation menu. 447 463 * … … 513 529 514 530 $items = array_map( 'wp_setup_nav_menu_item', $items ); 531 532 if ( ! is_admin() ) // Remove invalid items only in frontend 533 $items = array_filter( $items, '_is_valid_nav_menu_item' ); 515 534 516 535 if ( ARRAY_A == $args['output'] ) { … … 561 580 if ( 'post_type' == $menu_item->type ) { 562 581 $object = get_post_type_object( $menu_item->object ); 563 $menu_item->type_label = $object->labels->singular_name; 582 if ( $object ) { 583 $menu_item->type_label = $object->labels->singular_name; 584 } else { 585 $menu_item->type_label = $menu_item->object; 586 $menu_item->_invalid = true; 587 } 588 564 589 $menu_item->url = get_permalink( $menu_item->object_id ); 565 590 … … 570 595 } elseif ( 'taxonomy' == $menu_item->type ) { 571 596 $object = get_taxonomy( $menu_item->object ); 572 $menu_item->type_label = $object->labels->singular_name; 597 if ( $object ) { 598 $menu_item->type_label = $object->labels->singular_name; 599 } else { 600 $menu_item->type_label = $menu_item->object; 601 $menu_item->_invalid = true; 602 } 603 573 604 $term_url = get_term_link( (int) $menu_item->object_id, $menu_item->object ); 574 605 $menu_item->url = !is_wp_error( $term_url ) ? $term_url : '';
Note: See TracChangeset
for help on using the changeset viewer.