diff --git src/wp-includes/nav-menu.php src/wp-includes/nav-menu.php
index 58a5d11..16653ca 100644
|
|
|
function wp_setup_nav_menu_item( $menu_item ) { |
| 747 | 747 | $menu_item->_invalid = true; |
| 748 | 748 | } |
| 749 | 749 | |
| | 750 | if ( 'trash' === get_post_status( $menu_item->object_id ) ) { |
| | 751 | $menu_item->_invalid = true; |
| | 752 | } |
| | 753 | |
| 750 | 754 | $menu_item->url = get_permalink( $menu_item->object_id ); |
| 751 | 755 | |
| 752 | 756 | $original_object = get_post( $menu_item->object_id ); |
diff --git tests/phpunit/tests/post/nav-menu.php tests/phpunit/tests/post/nav-menu.php
index bbcbbab..83edce5 100644
|
|
|
class Test_Nav_Menus extends WP_UnitTestCase { |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
| | 280 | * @ticket 19038 |
| | 281 | */ |
| | 282 | function test_wp_setup_nav_menu_item_for_trashed_post() { |
| | 283 | $post_id = self::factory()->post->create( array( |
| | 284 | 'post_status' => 'trash', |
| | 285 | ) ); |
| | 286 | |
| | 287 | $menu_item_id = wp_update_nav_menu_item( $this->menu_id, 0, array( |
| | 288 | 'menu-item-type' => 'post_type', |
| | 289 | 'menu-item-object' => 'post', |
| | 290 | 'menu-item-object-id' => $post_id, |
| | 291 | 'menu-item-status' => 'publish', |
| | 292 | ) ); |
| | 293 | |
| | 294 | $menu_item = wp_setup_nav_menu_item( get_post( $menu_item_id ) ); |
| | 295 | |
| | 296 | $this->assertTrue( ! _is_valid_nav_menu_item( $menu_item ) ); |
| | 297 | } |
| | 298 | |
| | 299 | /** |
| 280 | 300 | * @ticket 35206 |
| 281 | 301 | */ |
| 282 | 302 | function test_wp_nav_menu_whitespace_options() { |