Making WordPress.org


Ignore:
Timestamp:
06/19/2018 09:44:33 AM (7 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/handbooks.php

    r5681 r7319  
    6363     */
    6464    public static function add_query_vars( $public_query_vars ) {
    65         $public_query_vars['is_handbook'] = false;
    66         $public_query_vars['current_handbook'] = false;
    67         $public_query_vars['current_handbook_home_url'] = false;
    68         $public_query_vars['current_handbook_name'] = '';
     65        $public_query_vars[] = 'current_handbook';
     66        $public_query_vars[] = 'current_handbook_home_url';
     67        $public_query_vars[] = 'current_handbook_name';
    6968
    7069        return $public_query_vars;
     
    7776     */
    7877    public static function pre_get_posts( $query ) {
    79         $is_handbook = function_exists( 'wporg_is_handbook' ) ? wporg_is_handbook() : false;
    80         $query->set( 'is_handbook', $is_handbook );
    81 
    82         $current_handbook = function_exists( 'wporg_get_current_handbook' ) ? wporg_get_current_handbook() : false;
     78        $query->is_handbook = function_exists( 'wporg_is_handbook' ) && wporg_is_handbook();
     79
     80        $current_handbook = function_exists( 'wporg_get_current_handbook' ) ? (string) wporg_get_current_handbook() : '';
    8381        $query->set( 'current_handbook', $current_handbook );
    8482
    85         $current_handbook_home_url = function_exists( 'wporg_get_current_handbook_home_url' ) ? wporg_get_current_handbook_home_url() : false;
     83        $current_handbook_home_url = function_exists( 'wporg_get_current_handbook_home_url' ) ? (string) wporg_get_current_handbook_home_url() : '';
    8684        $query->set( 'current_handbook_home_url', $current_handbook_home_url );
    8785
    88         $current_handbook_name = function_exists( 'wporg_get_current_handbook_name' ) ? wporg_get_current_handbook_name() : '';
     86        $current_handbook_name = function_exists( 'wporg_get_current_handbook_name' ) ? (string) wporg_get_current_handbook_name() : '';
    8987        $query->set( 'current_handbook_name', $current_handbook_name );
    9088    }
Note: See TracChangeset for help on using the changeset viewer.