Make WordPress Core


Ignore:
Timestamp:
10/20/2025 08:29:54 PM (13 months ago)
Author:
joedolson
Message:

Menus: Improve usability and accessibility of menu quick search.

Change the admin menu quick search to limit to searching post titles. Add filter wp_ajax_menu_quick_search_args to support customizing post columns in query. Clear quick search results when search query is cleared. Send announcements about search status via wp.a11y.speak().

Props diebombe, afercia, audrasjb, nickjbedford, kevinlearynet, mukesh27, joedolson.
Fixes #48655.

File:
1 edited

Legend:

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

    r60980 r60991  
    8484                if ( 'posttype' === $matches[1] && get_post_type_object( $matches[2] ) ) {
    8585                        $post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) );
    86                         $args          = array_merge(
    87                                 $args,
    88                                 array(
    89                                         'no_found_rows'          => true,
    90                                         'update_post_meta_cache' => false,
    91                                         'update_post_term_cache' => false,
    92                                         'posts_per_page'         => 10,
    93                                         'post_type'              => $matches[2],
    94                                         's'                      => $query,
    95                                 )
     86                        $query_args    = array(
     87                                'no_found_rows'          => true,
     88                                'update_post_meta_cache' => false,
     89                                'update_post_term_cache' => false,
     90                                'posts_per_page'         => 10,
     91                                'post_type'              => $matches[2],
     92                                's'                      => $query,
     93                                'search_columns'         => array( 'post_title' ),
    9694                        );
     95                        /**
     96                         * Filter the menu quick search arguments.
     97                         *
     98                         * @since 6.9.0
     99                         *
     100                         * @param array $args {
     101                         *     Menu quick search arguments.
     102                         *
     103                         *     @type boolean      $no_found_rows          Whether to return found rows data. Default true.
     104                         *     @type boolean      $update_post_meta_cache Whether to update post meta cache. Default false.
     105                         *     @type boolean      $update_post_term_cache Whether to update post term cache. Default false.
     106                         *     @type int          $posts_per_page         Number of posts to return. Default 10.
     107                         *     @type string       $post_type              Type of post to return.
     108                         *     @type string       $s                      Search query.
     109                         *     @type array        $search_columns         Which post table columns to query.
     110                         * }
     111                        */
     112                        $query_args = apply_filters( 'wp_ajax_menu_quick_search_args', $query_args );
     113                        $args       = array_merge( $args, $query_args );
    97114
    98115                        if ( isset( $post_type_obj->_default_query ) ) {
Note: See TracChangeset for help on using the changeset viewer.