Making WordPress.org

Changeset 10074


Ignore:
Timestamp:
07/16/2020 03:29:51 AM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Block Search: Search in the plugin title as well as block titles.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/api/routes/class-query-plugins.php

    r9980 r10074  
    6868                $block_search = trim( strtolower( $request->get_param( 'block' ) ) );
    6969                if ( $block_search ) {
    70                         global $wpdb;
    7170                        $meta_query = array(
    7271                                'relation' => 'AND',
    … …  
    7978                                        array(
    8079                                                'key' => 'block_name',
    81                                                 'value' => '^' . $block_search,
     80                                                'value' => '^' . preg_quote( $block_search ),
    8281                                                'compare' => 'RLIKE',
    8382                                        ),
    … …  
    8584                                                'key' => 'block_name',
    8685                                                'value' => '/' . $block_search, // search following the slash
    87                                                 'compare' => 'RLIKE',
     86                                                'compare' => 'LIKE',
    8887                                        ),
    8988                                        array(
    9089                                                'key' => 'block_title',
    9190                                                'value' => $block_search, // search in title
    92                                                 'compare' => 'RLIKE',
     91                                                'compare' => 'LIKE',
     92                                        ),
     93                                        array(
     94                                                'key' => 'header_name',
     95                                                'value' => $block_search, // search in plugin title
     96                                                'compare' => 'LIKE',
    9397                                        ),
    9498                                )
    … …  
    115119                // Use the main query so that is_main_query() is triggered for the filters.
    116120                $wp_query->query( $query );
     121
    117122                $response['info']['page']    = (int) $wp_query->get( 'paged' ) ?: 1;
    118123                $response['info']['pages']   = (int) $wp_query->max_num_pages ?: 0;
Note: See TracChangeset for help on using the changeset viewer.