Commit a5b2d8e7ba for wordpress.org
commit a5b2d8e7ba9b161af78eeae25c486a780a4a2bbe
Author: Weston Ruter <weston@xwp.co>
Date: Sat Jan 10 06:38:56 2026 +0000
Menus: Ensure a `WP_Post` instance gets passed to `get_post_states()` in `wp_setup_nav_menu_item()`.
The `get_post_states()` function is also hardened to short-circuit in case a non-`WP_Post` is passed. A test is added to verify this.
Developed in https://github.com/WordPress/wordpress-develop/pull/10706
Follow-up to [47211].
Props apedog, josephscott, joemcgill, westonruter.
See #49374.
Fixes #58932.
Built from https://develop.svn.wordpress.org/trunk@61465
git-svn-id: http://core.svn.wordpress.org/trunk@60777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index 9513095232..b50ebc8c76 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -2296,6 +2296,10 @@ function _post_states( $post, $display = true ) {
*/
function get_post_states( $post ) {
$post_states = array();
+ if ( ! $post instanceof WP_Post ) {
+ return $post_states;
+ }
+
$post_status = $_REQUEST['post_status'] ?? '';
if ( ! empty( $post->post_password ) ) {
diff --git a/wp-includes/css/dist/index.php b/wp-includes/css/dist/index.php
index 112aacc7cb..0bdf505c53 100644
--- a/wp-includes/css/dist/index.php
+++ b/wp-includes/css/dist/index.php
@@ -27,25 +27,25 @@ return array(
'path' => 'commands/style',
'dependencies' => array('wp-components'),
),
- array(
- 'handle' => 'wp-components',
- 'path' => 'components/style',
- 'dependencies' => array(),
- ),
array(
'handle' => 'wp-reusable-blocks',
'path' => 'reusable-blocks/style',
'dependencies' => array('wp-block-editor', 'wp-components'),
),
+ array(
+ 'handle' => 'wp-patterns',
+ 'path' => 'patterns/style',
+ 'dependencies' => array('wp-block-editor', 'wp-components'),
+ ),
array(
'handle' => 'wp-widgets',
'path' => 'widgets/style',
'dependencies' => array('wp-block-editor', 'wp-components'),
),
array(
- 'handle' => 'wp-patterns',
- 'path' => 'patterns/style',
- 'dependencies' => array('wp-block-editor', 'wp-components'),
+ 'handle' => 'wp-components',
+ 'path' => 'components/style',
+ 'dependencies' => array(),
),
array(
'handle' => 'wp-format-library',
@@ -57,16 +57,16 @@ return array(
'path' => 'block-directory/style',
'dependencies' => array('wp-block-editor', 'wp-components', 'wp-editor'),
),
- array(
- 'handle' => 'wp-media-utils',
- 'path' => 'media-utils/style',
- 'dependencies' => array('wp-components'),
- ),
array(
'handle' => 'wp-customize-widgets',
'path' => 'customize-widgets/style',
'dependencies' => array('wp-block-editor', 'wp-block-library', 'wp-components', 'wp-media-utils', 'wp-preferences', 'wp-widgets'),
),
+ array(
+ 'handle' => 'wp-media-utils',
+ 'path' => 'media-utils/style',
+ 'dependencies' => array('wp-components'),
+ ),
array(
'handle' => 'wp-edit-widgets',
'path' => 'edit-widgets/style',
@@ -87,14 +87,14 @@ return array(
'path' => 'editor/style',
'dependencies' => array('wp-block-editor', 'wp-commands', 'wp-components', 'wp-media-utils', 'wp-patterns', 'wp-preferences'),
),
- array(
- 'handle' => 'wp-block-editor',
- 'path' => 'block-editor/style',
- 'dependencies' => array('wp-commands', 'wp-components', 'wp-preferences'),
- ),
array(
'handle' => 'wp-edit-site',
'path' => 'edit-site/style',
'dependencies' => array('wp-block-editor', 'wp-block-library', 'wp-commands', 'wp-components', 'wp-editor', 'wp-patterns', 'wp-preferences', 'wp-widgets'),
),
+ array(
+ 'handle' => 'wp-block-editor',
+ 'path' => 'block-editor/style',
+ 'dependencies' => array('wp-commands', 'wp-components', 'wp-preferences'),
+ ),
);
diff --git a/wp-includes/js/dist/script-modules/index.php b/wp-includes/js/dist/script-modules/index.php
index 1ec1a71635..0583013225 100644
--- a/wp-includes/js/dist/script-modules/index.php
+++ b/wp-includes/js/dist/script-modules/index.php
@@ -8,9 +8,19 @@
return array(
array(
- 'id' => '@wordpress/interactivity',
- 'path' => 'interactivity/index',
- 'asset' => 'interactivity/index.min.asset.php',
+ 'id' => '@wordpress/a11y',
+ 'path' => 'a11y/index',
+ 'asset' => 'a11y/index.min.asset.php',
+ ),
+ array(
+ 'id' => '@wordpress/interactivity-router',
+ 'path' => 'interactivity-router/index',
+ 'asset' => 'interactivity-router/index.min.asset.php',
+ ),
+ array(
+ 'id' => '@wordpress/interactivity-router/full-page',
+ 'path' => 'interactivity-router/full-page',
+ 'asset' => 'interactivity-router/full-page.min.asset.php',
),
array(
'id' => '@wordpress/abilities',
@@ -23,14 +33,9 @@ return array(
'asset' => 'core-abilities/index.min.asset.php',
),
array(
- 'id' => '@wordpress/interactivity-router',
- 'path' => 'interactivity-router/index',
- 'asset' => 'interactivity-router/index.min.asset.php',
- ),
- array(
- 'id' => '@wordpress/interactivity-router/full-page',
- 'path' => 'interactivity-router/full-page',
- 'asset' => 'interactivity-router/full-page.min.asset.php',
+ 'id' => '@wordpress/interactivity',
+ 'path' => 'interactivity/index',
+ 'asset' => 'interactivity/index.min.asset.php',
),
array(
'id' => '@wordpress/latex-to-mathml',
@@ -43,20 +48,15 @@ return array(
'asset' => 'latex-to-mathml/loader.min.asset.php',
),
array(
- 'id' => '@wordpress/a11y',
- 'path' => 'a11y/index',
- 'asset' => 'a11y/index.min.asset.php',
+ 'id' => '@wordpress/route',
+ 'path' => 'route/index',
+ 'asset' => 'route/index.min.asset.php',
),
array(
'id' => '@wordpress/edit-site-init',
'path' => 'edit-site-init/index',
'asset' => 'edit-site-init/index.min.asset.php',
),
- array(
- 'id' => '@wordpress/route',
- 'path' => 'route/index',
- 'asset' => 'route/index.min.asset.php',
- ),
array(
'id' => '@wordpress/lazy-editor',
'path' => 'lazy-editor/index',
diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php
index 83a67cfe2a..dc6de5c70c 100644
--- a/wp-includes/nav-menu.php
+++ b/wp-includes/nav-menu.php
@@ -875,10 +875,12 @@ function wp_setup_nav_menu_item( $menu_item ) {
$menu_item->type_label = $object->labels->singular_name;
// Denote post states for special pages (only in the admin).
if ( function_exists( 'get_post_states' ) ) {
- $menu_post = get_post( $menu_item->object_id );
- $post_states = get_post_states( $menu_post );
- if ( $post_states ) {
- $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) );
+ $menu_post = get_post( $menu_item->object_id );
+ if ( $menu_post instanceof WP_Post ) {
+ $post_states = get_post_states( $menu_post );
+ if ( $post_states ) {
+ $menu_item->type_label = wp_strip_all_tags( implode( ', ', $post_states ) );
+ }
}
}
} else {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index a3598bbfb7..4e22ee19ab 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.0-alpha-61464';
+$wp_version = '7.0-alpha-61465';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.