Menus: Do not show trashed posts in nav menus.

Trashed posts cannot be accessed by site visitors and thus should not be visible on the front end. By marking menu items of trashed posts as invalid, they are excluded from the output.

Props solarissmoke, swissspidy.
Fixes #19038.
Built from https://develop.svn.wordpress.org/trunk@38744


git-svn-id: http://core.svn.wordpress.org/trunk@38687 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Pascal Birchler 2016-10-07 16:50:29 +00:00
parent d7c994d1bf
commit ff411ed5f4
2 changed files with 5 additions and 1 deletions

View File

@ -747,6 +747,10 @@ function wp_setup_nav_menu_item( $menu_item ) {
$menu_item->_invalid = true;
}
if ( 'trash' === get_post_status( $menu_item->object_id ) ) {
$menu_item->_invalid = true;
}
$menu_item->url = get_permalink( $menu_item->object_id );
$original_object = get_post( $menu_item->object_id );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.7-alpha-38743';
$wp_version = '4.7-alpha-38744';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.