Making WordPress.org


Ignore:
Timestamp:
06/19/2018 09:44:33 AM (8 years ago)
Author:
obenland
Message:

Developer: Use query_vars correctly.

Props grapplerulrich, johnbillion, SergeyBiryukov.
Fixes #2882.

File:
1 edited

Legend:

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

    r5432 r7319  
    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;
    4327        }
    4428
    … …  
    6044                // Separates searches for handbook pages from non-handbook pages depending on
    6145                // whether the search was performed within context of a handbook page or not.
    62                 if ( get_query_var( 'is_handbook' ) ) {
     46                if ( $query->is_handbook ) {
    6347                        // Search only in current handbook post type.
    6448                        // Just to make sure. post type should already be set.
    … …  
    8367                if ( ! $qv_post_types ) {
    8468                        // Record the fact no post types were explicitly supplied.
    85                         $query->set( 'empty_post_type_search', true );
     69                        $query->is_empty_post_type_search = true;
    8670
    8771                        // Not a handbook page, or exact search, or filters used.
Note: See TracChangeset for help on using the changeset viewer.