Making WordPress.org

Changeset 13190


Ignore:
Timestamp:
02/08/2024 04:40:01 AM (13 months ago)
Author:
dd32
Message:

Plugin Directory: Enable the Community/Comercial filters on Search results.

See #2753, #7430.

Location:
sites/trunk/wordpress.org/public_html/wp-content
Files:
2 edited

Legend:

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

    r12942 r13190  
    202202                    'taxonomy.plugin_section.name' => [
    203203                        'value' => 'block'
     204                    ]
     205                ]
     206            ];
     207        }
     208
     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' )
    204214                    ]
    205215                ]
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/header.php

    r12825 r13190  
    3030$is_favs = 'favorites' === $wp_query->get( 'browse' );
    3131// The filter bar should not be shown on:
    32 // - search: wp-query filters not compatible with ES search.
    3332// - singular: not relevant on pages or individual plugins.
    3433// - beta: likely unnecessary, these are probably all "community".
    3534// - favorites: not necessary.
    36 $show_filter_bar = ! ( is_search() || is_singular() || $is_beta || $is_favs );
     35$show_filter_bar = ! ( is_singular() || $is_beta || $is_favs );
    3736
    3837echo do_blocks( '<!-- wp:wporg/global-header /-->' ); // phpcs:ignore
     
    8786                    if (
    8887                        // URL contains this filter.
    89                         ( $slug && str_contains( $_SERVER['REQUEST_URI'], "plugin_business_model=$slug" ) ) || // phpcs:ignore
     88                        ( $slug === ( $_GET['plugin_business_model'] ?? false ) ) ||
    9089                        // Set the All item active if no business model is selected.
    91                         ( ! $slug && false === strpos( $_SERVER['REQUEST_URI'], 'plugin_business_model' ) ) // phpcs:ignore
     90                        ( ! $slug && empty( $_GET['plugin_business_model'] ) )
    9291                    ) {
    9392                        $class = 'is-active';
    9493                    }
    95                     $url = home_url( '/' );
    96                     // If a browse view, use that as the base.
    97                     if ( ! is_home() && $browse = get_query_var( 'browse' ) ) {
    98                         $url = home_url( "/browse/{$browse}/" );
     94
     95                    if ( $slug ) {
     96                        $url = add_query_arg( array( 'plugin_business_model' => $slug ) );
     97                    } else {
     98                        $url = remove_query_arg( 'plugin_business_model' );
    9999                    }
    100                     if ( $slug ) {
    101                         $url = add_query_arg( array( 'plugin_business_model' => $slug ), $url );
    102                     }
     100
     101                    // Reset pagination.
     102                    $url = remove_query_arg( 'paged', $url );
     103                    $url = preg_replace( '!/page/\d+/?!i', '/', $url );
     104
    103105                    printf(
    104106                        '<li class="page_item"><a class="%1$s" href="%2$s">%3$s</a></li>',
Note: See TracChangeset for help on using the changeset viewer.