Make WordPress Core

Changeset 25605


Ignore:
Timestamp:
09/24/2013 05:09:56 PM (11 years ago)
Author:
nacin
Message:

When is_main_query() is called during the pre_get_posts hook, issue _doing_it_wrong().

The is_main_query() WP_Query method should be used in these instances instead.
see #23329.

File:
1 edited

Legend:

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

    r25601 r25605  
    718718 */
    719719function is_main_query() {
     720    if ( 'pre_get_posts' === current_filter() ) {
     721        $message = sprintf( __( 'In <code>%1$s</code>, use the <code>%2$s</code> method, not the <code>%3$s</code> function. See %4$s.' ),
     722            'pre_get_posts', 'WP_Query::is_main_query()', 'is_main_query()', __( 'http://codex.wordpress.org/Function_Reference/is_main_query' ) );
     723        _doing_it_wrong( __FUNCTION__, $message, '3.7' );
     724    }
     725
    720726    global $wp_query;
    721727    return $wp_query->is_main_query();
Note: See TracChangeset for help on using the changeset viewer.