From d65e65cd6c56a7b346925a6abac624acbd4d332b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 3 Sep 2024 22:43:14 +0000 Subject: [PATCH] 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 --- wp-admin/includes/post.php | 13 ++++++++----- wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/wp-admin/includes/post.php b/wp-admin/includes/post.php index 6da6601931..e5e1e5d147 100644 --- a/wp-admin/includes/post.php +++ b/wp-admin/includes/post.php @@ -1804,18 +1804,21 @@ function _admin_notice_post_locked() { $locked = false; } - $sendback = wp_get_referer(); - if ( $locked && $sendback && ! str_contains( $sendback, 'post.php' ) && ! str_contains( $sendback, 'post-new.php' ) ) { + $sendback = wp_get_referer(); + $sendback_text = __( 'Go back' ); - $sendback_text = __( 'Go back' ); - } else { + if ( ! $locked || ! $sendback || str_contains( $sendback, 'post.php' ) || str_contains( $sendback, 'post-new.php' ) ) { $sendback = admin_url( 'edit.php' ); if ( 'post' !== $post->post_type ) { $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'; diff --git a/wp-includes/version.php b/wp-includes/version.php index 1bf0015d67..0fb1852372 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @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.