Make WordPress Core


Ignore:
Timestamp:
09/09/2016 04:59:01 AM (8 years ago)
Author:
westonruter
Message:

Menus: Prevent non-published posts/pages from being returned in search results for adding as nav menu items.

Re-use the same query vars in searching as when listing posts. Aligns with behavior of nav menus in customizer.

Fixes #33742.
Props welcher, westonruter.

File:
1 edited

Legend:

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

    r38470 r38584  
    7171    } elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) {
    7272        if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
    73             $search_results_query = new WP_Query( array(
     73            $post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) );
     74            $args = array(
    7475                'no_found_rows'          => true,
    7576                'update_post_meta_cache' => false,
     
    7879                'post_type'              => $matches[2],
    7980                's'                      => $query,
    80             ) );
     81            );
     82            if ( isset( $post_type_obj->_default_query ) ) {
     83                $args = array_merge( $args, (array) $post_type_obj->_default_query );
     84            }
     85            $search_results_query = new WP_Query( $args );
    8186            if ( ! $search_results_query->have_posts() ) {
    8287                return;
Note: See TracChangeset for help on using the changeset viewer.