Skip to:
Content

bbPress.org

Changeset 7067


Ignore:
Timestamp:
02/07/2020 05:36:00 PM (4 years ago)
Author:
johnjamesjacoby
Message:

Templates: avoid possible fatal error in is_bbpress().

This commit confirms that the $wp_query global has been invoked before attempting to make comparisons against it. It also uses _doing_it_wrong() to alert developers to what is going on.

Props r-a-y. Fixes #3334. For 2.6.15, branches/2.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.6/src/includes/common/template.php

    r7054 r7067  
    11031103function is_bbpress() {
    11041104
    1105     // Defalt to false
    1106     $retval = false;
     1105    // Default to false
     1106    $retval = false;
     1107
     1108    // Bail if main query has not been populated.
     1109    if ( ! bbp_get_wp_query() ) {
     1110        _doing_it_wrong( __FUNCTION__, esc_html__( 'Conditional query tags do not work before the query is run. Before then, they always return false.', 'bbpress' ), '2.7.0' );
     1111        return $retval;
     1112    }
    11071113
    11081114    /** Archives **************************************************************/
Note: See TracChangeset for help on using the changeset viewer.