Making WordPress.org

Changeset 13648


Ignore:
Timestamp:
05/02/2024 06:08:26 AM (6 weeks ago)
Author:
dd32
Message:

Plugin Directory: Search: Properly limit block searches to the Block directory.

Likely broke via [13332].

File:
1 edited

Legend:

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

    r13642 r13648  
    217217        // These are the things that jetpack_search_es_wp_query_args doesn't let us change, so we need to filter the es_query_args late in the code path to add more custom stuff.
    218218
    219         $es_query_args['filter']['and'] ??= [];
    220 
    221         // Exclude disabled plugins.
    222         $es_query_args['filter']['and'][] = [
    223             'term' => [
    224                 'disabled' => [
    225                     'value' => false,
    226                 ],
     219        // Replace any existing filter with an AND for our custom filters.
     220        $es_query_args['filter'] = [
     221            'and' => $es_query_args['filter'] ? [ $es_query_args['filter'] ] : [],
     222        ];
     223
     224        // Exclude 'disabled' plugins. This is separate from the 'status' field, which is used for the plugin status.
     225        $es_query_args['filter']['and'] = [
     226            'terms' => [
     227                'disabled' => false,
    227228            ]
    228229        ];
    229230
     231        // Limit to the Block Directory.
    230232        if ( $this->is_block_search ) {
    231             // Limit to the Block Tax.
    232233            $es_query_args['filter']['and'][] = [
    233                 'term' => [
    234                     'taxonomy.plugin_section.name' => [
    235                         'value' => 'block'
    236                     ]
     234                'terms' => [
     235                    'taxonomy.plugin_section.name' => 'block',
    237236                ]
    238237            ];
Note: See TracChangeset for help on using the changeset viewer.