Make WordPress Core


Ignore:
Timestamp:
09/03/2024 10:41:06 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Check if the post type exists in _admin_notice_post_locked().

This adds a guard to verify the result of get_post_type_object() before retrieving the all_items label, as the function returns null if the post type does not exist.

Follow-up to [24527].

Props pcarvalho, akshat280, mukesh27, SergeyBiryukov.
Fixes #60947.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r58961 r58983  
    18051805        }
    18061806
    1807         $sendback = wp_get_referer();
    1808         if ( $locked && $sendback && ! str_contains( $sendback, 'post.php' ) && ! str_contains( $sendback, 'post-new.php' ) ) {
    1809 
    1810                 $sendback_text = __( 'Go back' );
    1811         } else {
     1807        $sendback      = wp_get_referer();
     1808        $sendback_text = __( 'Go back' );
     1809
     1810        if ( ! $locked || ! $sendback || str_contains( $sendback, 'post.php' ) || str_contains( $sendback, 'post-new.php' ) ) {
    18121811                $sendback = admin_url( 'edit.php' );
    18131812
     
    18161815                }
    18171816
    1818                 $sendback_text = get_post_type_object( $post->post_type )->labels->all_items;
     1817                $post_type_object = get_post_type_object( $post->post_type );
     1818
     1819                if ( $post_type_object ) {
     1820                        $sendback_text = $post_type_object->labels->all_items;
     1821                }
    18191822        }
    18201823
Note: See TracChangeset for help on using the changeset viewer.