Make WordPress Core


Ignore:
Timestamp:
02/08/2020 12:47:33 PM (5 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu.php

    r47211 r47213  
    818818                if ( $object ) {
    819819                    $menu_item->type_label = $object->labels->singular_name;
    820                     // Use post states for special pages.
    821                     $menu_post   = get_post( $menu_item->object_id );
    822                     $post_states = get_post_states( $menu_post );
    823                     if ( $post_states ) {
    824                         $menu_item->type_label = implode( ',', $post_states );
     820                    // Use post states for special pages (only in the admin).
     821                    if ( function_exists( 'get_post_states' ) ) {
     822                        $menu_post   = get_post( $menu_item->object_id );
     823                        $post_states = get_post_states( $menu_post );
     824                        if ( $post_states ) {
     825                            $menu_item->type_label = implode( ',', $post_states );
     826                        }
    825827                    }
    826828                } else {
Note: See TracChangeset for help on using the changeset viewer.