Permalink
Browse files

Menus: Prevent non-published posts/pages from being returned in searc…

…h 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.

Built from https://develop.svn.wordpress.org/trunk@38584


git-svn-id: http://core.svn.wordpress.org/trunk@38527 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information...
1 parent e482549 commit 84f9592f88a19dd3fb4d1b8780679c99ea678688 @westonruter westonruter committed Sep 9, 2016
Showing with 8 additions and 3 deletions.
  1. +7 −2 wp-admin/includes/nav-menu.php
  2. +1 −1 wp-includes/version.php
@@ -70,14 +70,19 @@ function _wp_ajax_menu_quick_search( $request = array() ) {
} elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) {
if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) {
- $search_results_query = new WP_Query( array(
+ $post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) );
+ $args = array(
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
'posts_per_page' => 10,
'post_type' => $matches[2],
's' => $query,
- ) );
+ );
+ if ( isset( $post_type_obj->_default_query ) ) {
+ $args = array_merge( $args, (array) $post_type_obj->_default_query );
+ }
+ $search_results_query = new WP_Query( $args );
if ( ! $search_results_query->have_posts() ) {
return;
}
@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
-$wp_version = '4.7-alpha-38583';
+$wp_version = '4.7-alpha-38584';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 comments on commit 84f9592

Please sign in to comment.