Changeset 27150
- Timestamp:
- 02/09/2014 09:36:15 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/nav-menu.php
r25289 r27150 703 703 foreach( (array) $menu_items as $menu_item ) { 704 704 if ( isset( $menu_item->ID ) && is_nav_menu_item( $menu_item->ID ) ) { 705 if ( get_post_meta( $menu_item->ID, '_menu_item_type', true ) !== $object_type || 706 get_post_meta( $menu_item->ID, '_menu_item_object', true ) !== $taxonomy ) 707 continue; 708 709 $menu_item_ids[] = (int) $menu_item->ID; 705 $menu_item_type = get_post_meta( $menu_item->ID, '_menu_item_type', true ); 706 if ( 707 'post_type' == $object_type && 708 'post_type' == $menu_item_type 709 ) { 710 $menu_item_ids[] = (int) $menu_item->ID; 711 } else if ( 712 'taxonomy' == $object_type && 713 'taxonomy' == $menu_item_type && 714 get_post_meta( $menu_item->ID, '_menu_item_object', true ) == $taxonomy 715 ) { 716 $menu_item_ids[] = (int) $menu_item->ID; 717 } 710 718 } 711 719 } -
trunk/tests/phpunit/tests/post/nav-menu.php
r25163 r27150 19 19 $tag_id = $this->factory->tag->create(); 20 20 $cat_id = $this->factory->category->create(); 21 $post_id = $this->factory->post->create(); 22 $post_2_id = $this->factory->post->create(); 23 $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); 21 24 22 25 $tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( … … 34 37 ) ); 35 38 39 $post_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 40 'menu-item-type' => 'post_type', 41 'menu-item-object' => 'post', 42 'menu-item-object-id' => $post_id, 43 'menu-item-status' => 'publish' 44 ) ); 45 46 // Item without menu-item-object arg 47 $post_2_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 48 'menu-item-type' => 'post_type', 49 'menu-item-object-id' => $post_2_id, 50 'menu-item-status' => 'publish' 51 ) ); 52 53 $page_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 54 'menu-item-type' => 'post_type', 55 'menu-item-object' => 'page', 56 'menu-item-object-id' => $page_id, 57 'menu-item-status' => 'publish' 58 ) ); 59 36 60 $tag_items = wp_get_associated_nav_menu_items( $tag_id, 'taxonomy', 'post_tag' ); 37 61 $this->assertEqualSets( array( $tag_insert ), $tag_items ); 38 62 $cat_items = wp_get_associated_nav_menu_items( $cat_id, 'taxonomy', 'category' ); 39 63 $this->assertEqualSets( array( $cat_insert ), $cat_items ); 64 $post_items = wp_get_associated_nav_menu_items( $post_id ); 65 $this->assertEqualSets( array( $post_insert ), $post_items ); 66 $post_2_items = wp_get_associated_nav_menu_items( $post_2_id ); 67 $this->assertEqualSets( array( $post_2_insert ), $post_2_items ); 68 $page_items = wp_get_associated_nav_menu_items( $page_id ); 69 $this->assertEqualSets( array( $page_insert ), $page_items ); 70 71 wp_delete_term( $tag_id, 'post_tag' ); 72 $tag_items = wp_get_associated_nav_menu_items( $tag_id, 'taxonomy', 'post_tag' ); 73 $this->assertEqualSets( array(), $tag_items ); 74 75 wp_delete_term( $cat_id, 'category' ); 76 $cat_items = wp_get_associated_nav_menu_items( $cat_id, 'taxonomy', 'category' ); 77 $this->assertEqualSets( array(), $cat_items ); 78 79 wp_delete_post( $post_id, true ); 80 $post_items = wp_get_associated_nav_menu_items( $post_id ); 81 $this->assertEqualSets( array(), $post_items ); 82 83 wp_delete_post( $post_2_id, true ); 84 $post_2_items = wp_get_associated_nav_menu_items( $post_2_id ); 85 $this->assertEqualSets( array(), $post_2_items ); 86 87 wp_delete_post( $page_id, true ); 88 $page_items = wp_get_associated_nav_menu_items( $page_id ); 89 $this->assertEqualSets( array(), $page_items ); 40 90 } 41 91 }
Note: See TracChangeset
for help on using the changeset viewer.