Making WordPress.org

Changeset 3278


Ignore:
Timestamp:
05/31/2016 07:44:10 PM (10 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Unset search filter checkboxes if no filters were explicitly set.

The behavior had gotten undone during recent search-related changes.

Props keesiemeijer for initial patch.
See #1671.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/search.php

    r3276 r3278  
    2525                add_filter( 'posts_orderby', array( __CLASS__, 'search_posts_orderby' ), 10, 2 );
    2626                add_filter( 'the_posts',     array( __CLASS__, 'rerun_empty_exact_search' ), 10, 2 );
     27                add_filter( 'query_vars',    array( __CLASS__, 'default_qv_empty_post_type_search' ) );
     28        }
     29
     30        /**
     31         * Add query var to indicate if no post type filters were explicitly used for
     32         * a search.
     33         *
     34         * Defaults the query var 'empty_post_type_search' to false. It is potentially
     35         * set to true elsewhere.
     36         *
     37         * @param array $public_query_vars The array of whitelisted query variables.
     38         * @return array
     39         */
     40        public static function default_qv_empty_post_type_search( $public_query_vars ) {
     41                $public_query_vars['empty_post_type_search'] = false;
     42                return $public_query_vars;
    2743        }
    2844
    … …  
    6682
    6783                if ( ! $qv_post_types ) {
     84                        // Record the fact no post types were explicitly supplied.
     85                        $query->set( 'empty_post_type_search', true );
     86
    6887                        // Not a handbook page, or exact search, or filters used.
    6988                        // Fallback to parsed post types.
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/searchform.php

    r3243 r3278  
    6262                               
    6363                                $qv_post_type = array_filter( (array) get_query_var( 'post_type' ) );   
     64                                $no_filters   = get_query_var( 'empty_post_type_search' );
    6465
    65                                 if ( ! is_search() || in_array( 'any', $qv_post_type ) ) {
    66                                         // no filters used
     66                                if ( ! is_search() || in_array( 'any', $qv_post_type ) || $no_filters ) {
     67                                        // No filters used.
    6768                                        $qv_post_type = array();
    6869                                }
Note: See TracChangeset for help on using the changeset viewer.