Make WordPress Core


Ignore:
Timestamp:
01/10/2026 06:36:40 AM (4 months ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/template.php

    r61463 r61465  
    22972297function get_post_states( $post ) {
    22982298    $post_states = array();
     2299    if ( ! $post instanceof WP_Post ) {
     2300        return $post_states;
     2301    }
     2302
    22992303    $post_status = $_REQUEST['post_status'] ?? '';
    23002304
Note: See TracChangeset for help on using the changeset viewer.