Menus: When adding a label for special pages in `wp_setup_nav_menu_item()`, check if `get_post_states()` is available, to avoid fatal errors on front end.

Fixes #49374.
Built from https://develop.svn.wordpress.org/trunk@47213


git-svn-id: http://core.svn.wordpress.org/trunk@47013 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-02-08 12:49:07 +00:00
parent 8fa6586958
commit 7748f7082f
2 changed files with 8 additions and 6 deletions

View File

@ -817,11 +817,13 @@ function wp_setup_nav_menu_item( $menu_item ) {
$object = get_post_type_object( $menu_item->object );
if ( $object ) {
$menu_item->type_label = $object->labels->singular_name;
// Use post states for special pages.
$menu_post = get_post( $menu_item->object_id );
$post_states = get_post_states( $menu_post );
if ( $post_states ) {
$menu_item->type_label = implode( ',', $post_states );
// Use post states for special pages (only in the admin).
if ( function_exists( 'get_post_states' ) ) {
$menu_post = get_post( $menu_item->object_id );
$post_states = get_post_states( $menu_post );
if ( $post_states ) {
$menu_item->type_label = implode( ',', $post_states );
}
}
} else {
$menu_item->type_label = $menu_item->object;

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.4-alpha-47212';
$wp_version = '5.4-alpha-47213';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.