diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php
index 2eaf67454394e..ba4ecdc6d3ed4 100644
|
a
|
b
|
function _post_states( $post, $display = true ) { |
| 2297 | 2297 | function get_post_states( $post ) { |
| 2298 | 2298 | $post_states = array(); |
| 2299 | 2299 | |
| | 2300 | if ( ! $post instanceof WP_Post ) { |
| | 2301 | return $post_states; |
| | 2302 | } |
| | 2303 | |
| 2300 | 2304 | if ( isset( $_REQUEST['post_status'] ) ) { |
| 2301 | 2305 | $post_status = $_REQUEST['post_status']; |
| 2302 | 2306 | } else { |
diff --git a/src/wp-includes/nav-menu.php b/src/wp-includes/nav-menu.php
index 83a67cfe2a800..dc6de5c70c662 100644
|
a
|
b
|
function wp_setup_nav_menu_item( $menu_item ) { |
| 875 | 875 | $menu_item->type_label = $object->labels->singular_name; |
| 876 | 876 | // Denote post states for special pages (only in the admin). |
| 877 | 877 | if ( function_exists( 'get_post_states' ) ) { |
| 878 | | $menu_post = get_post( $menu_item->object_id ); |
| 879 | | $post_states = get_post_states( $menu_post ); |
| 880 | | if ( $post_states ) { |
| 881 | | $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) ); |
| | 878 | $menu_post = get_post( $menu_item->object_id ); |
| | 879 | if ( $menu_post instanceof WP_Post ) { |
| | 880 | $post_states = get_post_states( $menu_post ); |
| | 881 | if ( $post_states ) { |
| | 882 | $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) ); |
| | 883 | } |
| 882 | 884 | } |
| 883 | 885 | } |
| 884 | 886 | } else { |
diff --git a/tests/phpunit/tests/admin/includesTemplate.php b/tests/phpunit/tests/admin/includesTemplate.php
index 909aff217a583..436659179dd26 100644
|
a
|
b
|
public function test_wp_add_dashboard_widget() { |
| 494 | 494 | // This doesn't actually get removed due to the invalid priority. |
| 495 | 495 | remove_meta_box( 'dashboard2', 'dashboard', 'normal' ); |
| 496 | 496 | } |
| | 497 | |
| | 498 | /** |
| | 499 | * Tests that get_post_states() handles a null value gracefully. |
| | 500 | * |
| | 501 | * This can happen when get_post() returns null (e.g., when a post |
| | 502 | * doesn't exist) and that result is passed to get_post_states() |
| | 503 | * without being checked first. |
| | 504 | * |
| | 505 | * @ticket 58932 |
| | 506 | * |
| | 507 | * @covers ::get_post_states |
| | 508 | */ |
| | 509 | public function test_get_post_states_with_null_returns_empty_array() { |
| | 510 | $result = get_post_states( null ); |
| | 511 | $this->assertIsArray( $result, 'get_post_states() should return an array when passed null.' ); |
| | 512 | $this->assertEmpty( $result, 'get_post_states() should return an empty array when passed null.' ); |
| | 513 | } |
| 497 | 514 | } |