Making WordPress.org


Ignore:
Timestamp:
03/15/2024 07:16:32 AM (21 months ago)
Author:
dd32
Message:

wporg-plugins-2024: Attempt to support retaining the filters for searches.

This has many rough edges, as the UI doesn't match the WordPress template heirachy that was never designed for combination views.

File:
1 edited

Legend:

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

    r13332 r13349  
    10221022                break;
    10231023
     1024            case 'ratings':
     1025                $wp_query->query_vars['orderby'] = 'num_ratings';
     1026                // Fall through.
    10241027            case 'num_ratings':
    1025             case 'ratings':
    10261028                $wp_query->query_vars['meta_query']['num_ratings'] ??= [
    10271029                    'key'     => 'num_ratings',
     
    10301032                    'value'   => 0,
    10311033                ];
    1032 
    1033                 $wp_query->query_vars['orderby']  = 'num_ratings';
    10341034                break;
    10351035
    10361036            case '_active_installs':
     1037                $wp_query->query_vars['orderby']  = 'active_installs';
     1038                // Fall through.
    10371039            case 'active_installs':
    10381040                $wp_query->query_vars['meta_query']['active_installs'] ??= [
     
    10411043                    'compare' => 'EXISTS'
    10421044                ];
    1043 
    1044                 $wp_query->query_vars['orderby']  = 'active_installs';
    10451045                break;
    10461046
     
    10671067                    'compare' => 'EXISTS',
    10681068                ];
    1069                 $wp_query->query_vars['orderby']  = 'downloads';
    10701069                break;
    10711070        }
     
    14681467        // New-style search links.
    14691468        if ( get_query_var( 's' ) && isset( $_GET['s'] ) ) {
    1470             $url = site_url( '/search/' . urlencode( get_query_var( 's' ) ) . '/' );
    1471             if ( get_query_var( 'block_search' ) ) {
    1472                 $url = add_query_arg( 'block_search', get_query_var( 'block_search' ), $url );
     1469            $url        = site_url( '/search/' . urlencode( get_query_var( 's' ) ) . '/' );
     1470            $query_vars = array_filter( $wp_query->query );
     1471
     1472            // Don't need the search..
     1473            unset( $query_vars['s'] );
     1474
     1475            // Temporary: Disable sorts for search.
     1476            unset( $query_vars['order'], $query_vars['orderby'] );
     1477
     1478            if ( ! empty( $query_vars ) ) {
     1479                $url = add_query_arg( $query_vars, $url );
    14731480            }
    14741481
Note: See TracChangeset for help on using the changeset viewer.