Skip to content

Commit 9ad162e

Browse files
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. git-svn-id: https://develop.svn.wordpress.org/trunk@58983 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 583bbce commit 9ad162e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/wp-admin/includes/post.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,18 +1804,21 @@ function _admin_notice_post_locked() {
18041804
$locked = false;
18051805
}
18061806

1807-
$sendback = wp_get_referer();
1808-
if ( $locked && $sendback && ! str_contains( $sendback, 'post.php' ) && ! str_contains( $sendback, 'post-new.php' ) ) {
1807+
$sendback = wp_get_referer();
1808+
$sendback_text = __( 'Go back' );
18091809

1810-
$sendback_text = __( 'Go back' );
1811-
} else {
1810+
if ( ! $locked || ! $sendback || str_contains( $sendback, 'post.php' ) || str_contains( $sendback, 'post-new.php' ) ) {
18121811
$sendback = admin_url( 'edit.php' );
18131812

18141813
if ( 'post' !== $post->post_type ) {
18151814
$sendback = add_query_arg( 'post_type', $post->post_type, $sendback );
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

18211824
$hidden = $locked ? '' : ' hidden';

0 commit comments

Comments
 (0)