Ticket #26795: 26795.patch
| File 26795.patch, 3.3 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/nav-menu.php
702 702 ); 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 $object_type === 'post_type' && 708 $menu_item_type === 'post_type' 709 ) { 710 $menu_item_ids[] = (int) $menu_item->ID; 711 } else if ( 712 $object_type === 'taxonomy' && 713 $menu_item_type === 'taxonomy' && 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 } 712 720 -
tests/phpunit/tests/post/nav-menu.php
18 18 function test_wp_get_associated_nav_menu_items() { 19 19 $tag_id = $this->factory->tag->create(); 20 20 $cat_id = $this->factory->category->create(); 21 $post_id = $this->factory->post->create(); 22 $page_id = $this->factory->post->create( array( 'post_type' => 'page' ) ); 21 23 22 24 $tag_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 23 25 'menu-item-type' => 'taxonomy', … … 33 35 'menu-item-status' => 'publish' 34 36 ) ); 35 37 38 $post_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 39 'menu-item-type' => 'post_type', 40 'menu-item-object' => 'post', 41 'menu-item-object-id' => $post_id, 42 'menu-item-status' => 'publish' 43 ) ); 44 45 $page_insert = wp_update_nav_menu_item( $this->menu_id, 0, array( 46 'menu-item-type' => 'post_type', 47 'menu-item-object' => 'page', 48 'menu-item-object-id' => $page_id, 49 'menu-item-status' => 'publish' 50 ) ); 51 36 52 $tag_items = wp_get_associated_nav_menu_items( $tag_id, 'taxonomy', 'post_tag' ); 37 53 $this->assertEqualSets( array( $tag_insert ), $tag_items ); 38 54 $cat_items = wp_get_associated_nav_menu_items( $cat_id, 'taxonomy', 'category' ); 39 55 $this->assertEqualSets( array( $cat_insert ), $cat_items ); 56 $post_items = wp_get_associated_nav_menu_items( $post_id ); 57 $this->assertEqualSets( array( $post_insert ), $post_items ); 58 $page_items = wp_get_associated_nav_menu_items( $page_id ); 59 $this->assertEqualSets( array( $page_insert ), $page_items ); 60 61 wp_delete_term( $tag_id, 'post_tag' ); 62 $tag_items = wp_get_associated_nav_menu_items( $tag_id, 'taxonomy', 'post_tag' ); 63 $this->assertEqualSets( array(), $tag_items ); 64 65 wp_delete_term( $cat_id, 'category' ); 66 $cat_items = wp_get_associated_nav_menu_items( $cat_id, 'taxonomy', 'category' ); 67 $this->assertEqualSets( array(), $cat_items ); 68 69 wp_delete_post( $post_id, true ); 70 $post_items = wp_get_associated_nav_menu_items( $post_id ); 71 $this->assertEqualSets( array(), $post_items ); 72 73 wp_delete_post( $page_id, true ); 74 $page_items = wp_get_associated_nav_menu_items( $page_id ); 75 $this->assertEqualSets( array(), $page_items ); 40 76 } 41 } 42 No newline at end of file 77 }