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.
Built from https://develop.svn.wordpress.org/trunk@58983


git-svn-id: http://core.svn.wordpress.org/trunk@58379 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-09-03 22:43:14 +00:00
parent 02d2fa959a
commit d65e65cd6c
2 changed files with 9 additions and 6 deletions

View File

@ -1804,18 +1804,21 @@ function _admin_notice_post_locked() {
$locked = false; $locked = false;
} }
$sendback = wp_get_referer(); $sendback = wp_get_referer();
if ( $locked && $sendback && ! str_contains( $sendback, 'post.php' ) && ! str_contains( $sendback, 'post-new.php' ) ) { $sendback_text = __( 'Go back' );
$sendback_text = __( 'Go back' ); if ( ! $locked || ! $sendback || str_contains( $sendback, 'post.php' ) || str_contains( $sendback, 'post-new.php' ) ) {
} else {
$sendback = admin_url( 'edit.php' ); $sendback = admin_url( 'edit.php' );
if ( 'post' !== $post->post_type ) { if ( 'post' !== $post->post_type ) {
$sendback = add_query_arg( 'post_type', $post->post_type, $sendback ); $sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
} }
$sendback_text = get_post_type_object( $post->post_type )->labels->all_items; $post_type_object = get_post_type_object( $post->post_type );
if ( $post_type_object ) {
$sendback_text = $post_type_object->labels->all_items;
}
} }
$hidden = $locked ? '' : ' hidden'; $hidden = $locked ? '' : ' hidden';

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.7-alpha-58981'; $wp_version = '6.7-alpha-58983';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.