Making WordPress.org


Ignore:
Timestamp:
03/14/2024 03:26:56 AM (3 months ago)
Author:
dd32
Message:

Plugin Directory: Adjust the query customisations to allow for custom sorting.

This doesn't expose any UI, but provides the underlying API required for supporting it.

See #2753.

File:
1 edited

Legend:

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

    r13190 r13332  
    183183        // 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.
    184184
     185        $es_query_args['filter']['and'] ??= [];
     186
    185187        // Exclude disabled plugins.
    186         $es_query_args[ 'filter' ] = [
    187             'and' => [
    188               0 => [
    189                 'term' => [
    190                   'disabled' => [
     188        $es_query_args['filter']['and'][] = [
     189            'term' => [
     190                'disabled' => [
    191191                    'value' => false,
    192                   ],
    193                 ],
    194             ],
     192                ],
    195193            ]
    196194        ];
     
    207205        }
    208206
    209         if ( $query->get( 'plugin_business_model' ) ) {
    210             $es_query_args['filter']['and'][] = [
    211                 'term' => [
    212                     'taxonomy.plugin_business_model.name' => [
    213                         'value' => $query->get( 'plugin_business_model' )
    214                     ]
    215                 ]
    216             ];
    217         }
    218 
    219207        // Set boost on the match query
    220208
     
    232220            unset( $es_query_args[ 'query' ][ 'function_score' ][ 'query' ][ 'bool' ][ 'should' ][0][ 'multi_match' ][ 'operator' ] );
    233221        }
    234 
    235222
    236223        // Some extra fields here
Note: See TracChangeset for help on using the changeset viewer.