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.

Built from https://develop.svn.wordpress.org/trunk@25605


git-svn-id: http://core.svn.wordpress.org/trunk@25522 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-09-24 17:10:09 +00:00
parent 288482e862
commit dba857a39a
1 changed files with 6 additions and 0 deletions

View File

@ -717,6 +717,12 @@ function is_404() {
* @return bool
*/
function is_main_query() {
if ( 'pre_get_posts' === current_filter() ) {
$message = sprintf( __( 'In <code>%1$s</code>, use the <code>%2$s</code> method, not the <code>%3$s</code> function. See %4$s.' ),
'pre_get_posts', 'WP_Query::is_main_query()', 'is_main_query()', __( 'http://codex.wordpress.org/Function_Reference/is_main_query' ) );
_doing_it_wrong( __FUNCTION__, $message, '3.7' );
}
global $wp_query;
return $wp_query->is_main_query();
}