Make WordPress Core


Ignore:
Timestamp:
12/15/2010 12:21:27 PM (14 years ago)
Author:
nacin
Message:

You are doing it wrong in query.php. see #15824, see #14729.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r16894 r16947  
    143143    global $wp_query;
    144144
     145    if ( ! isset( $wp_query ) ) {
     146        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     147        // return false;
     148    }
     149
    145150    return $wp_query->is_archive();
    146151}
     
    159164    global $wp_query;
    160165
     166    if ( ! isset( $wp_query ) ) {
     167        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     168        // return false;
     169    }
     170
    161171    return $wp_query->is_post_type_archive( $post_types );
    162172}
     
    174184    global $wp_query;
    175185
     186    if ( ! isset( $wp_query ) ) {
     187        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     188        // return false;
     189    }
     190
    176191    return $wp_query->is_attachment();
    177192}
     
    193208    global $wp_query;
    194209
     210    if ( ! isset( $wp_query ) ) {
     211        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     212        // return false;
     213    }
     214
    195215    return $wp_query->is_author( $author );
    196216}
     
    212232    global $wp_query;
    213233
     234    if ( ! isset( $wp_query ) ) {
     235        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     236        // return false;
     237    }
     238
    214239    return $wp_query->is_category( $category );
    215240}
     
    230255function is_tag( $slug = '' ) {
    231256    global $wp_query;
     257
     258    if ( ! isset( $wp_query ) ) {
     259        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     260        // return false;
     261    }
    232262
    233263    return $wp_query->is_tag( $slug );
     
    253283 */
    254284function is_tax( $taxonomy = '', $term = '' ) {
    255     global $wp_query, $wp_taxonomies;
     285    global $wp_query;
     286
     287    if ( ! isset( $wp_query ) ) {
     288        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     289        // return false;
     290    }
    256291
    257292    return $wp_query->is_tax( $taxonomy, $term );
     
    270305    global $wp_query;
    271306
     307    if ( ! isset( $wp_query ) ) {
     308        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     309        // return false;
     310    }
     311
    272312    return $wp_query->is_comments_popup();
    273313}
     
    285325    global $wp_query;
    286326
     327    if ( ! isset( $wp_query ) ) {
     328        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     329        // return false;
     330    }
     331
    287332    return $wp_query->is_date();
    288333}
     
    300345    global $wp_query;
    301346
     347    if ( ! isset( $wp_query ) ) {
     348        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     349        // return false;
     350    }
     351
    302352    return $wp_query->is_day();
    303353}
     
    316366    global $wp_query;
    317367
     368    if ( ! isset( $wp_query ) ) {
     369        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     370        // return false;
     371    }
     372
    318373    return $wp_query->is_feed( $feeds );
    319374}
     
    330385function is_comment_feed() {
    331386    global $wp_query;
     387
     388    if ( ! isset( $wp_query ) ) {
     389        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     390        // return false;
     391    }
    332392
    333393    return $wp_query->is_comment_feed();
     
    356416    global $wp_query;
    357417
     418    if ( ! isset( $wp_query ) ) {
     419        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     420        // return false;
     421    }
     422
    358423    return $wp_query->is_front_page();
    359424}
     
    380445    global $wp_query;
    381446
     447    if ( ! isset( $wp_query ) ) {
     448        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     449        // return false;
     450    }
     451
    382452    return $wp_query->is_home();
    383453}
     
    395465    global $wp_query;
    396466
     467    if ( ! isset( $wp_query ) ) {
     468        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     469        // return false;
     470    }
     471
    397472    return $wp_query->is_month();
    398473}
     
    417492    global $wp_query;
    418493
     494    if ( ! isset( $wp_query ) ) {
     495        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     496        // return false;
     497    }
     498
    419499    return $wp_query->is_page( $page );
    420500}
     
    432512    global $wp_query;
    433513
     514    if ( ! isset( $wp_query ) ) {
     515        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     516        // return false;
     517    }
     518
    434519    return $wp_query->is_paged();
    435520}
     
    447532    global $wp_query;
    448533
     534    if ( ! isset( $wp_query ) ) {
     535        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     536        // return false;
     537    }
     538
    449539    return $wp_query->is_preview();
    450540}
     
    462552    global $wp_query;
    463553
     554    if ( ! isset( $wp_query ) ) {
     555        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     556        // return false;
     557    }
     558
    464559    return $wp_query->is_robots();
    465560}
     
    477572    global $wp_query;
    478573
     574    if ( ! isset( $wp_query ) ) {
     575        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     576        // return false;
     577    }
     578
    479579    return $wp_query->is_search();
    480580}
     
    501601    global $wp_query;
    502602
     603    if ( ! isset( $wp_query ) ) {
     604        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     605        // return false;
     606    }
     607
    503608    return $wp_query->is_single( $post );
    504609}
     
    523628    global $wp_query;
    524629
     630    if ( ! isset( $wp_query ) ) {
     631        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     632        // return false;
     633    }
     634
    525635    return $wp_query->is_singular( $post_types );
    526636}
     
    538648    global $wp_query;
    539649
     650    if ( ! isset( $wp_query ) ) {
     651        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     652        // return false;
     653    }
     654
    540655    return $wp_query->is_time();
    541656}
     
    553668    global $wp_query;
    554669
     670    if ( ! isset( $wp_query ) ) {
     671        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     672        // return false;
     673    }
     674
    555675    return $wp_query->is_trackback();
    556676}
     
    568688    global $wp_query;
    569689
     690    if ( ! isset( $wp_query ) ) {
     691        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     692        // return false;
     693    }
     694
    570695    return $wp_query->is_year();
    571696}
     
    582707function is_404() {
    583708    global $wp_query;
     709
     710    if ( ! isset( $wp_query ) ) {
     711        _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the init hook. They always return false.' ), '3.1' );
     712        // return false;
     713    }
    584714
    585715    return $wp_query->is_404();
Note: See TracChangeset for help on using the changeset viewer.