mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Query: Check if $wp_query
is set in is_main_query()
.
This avoids a PHP fatal error and triggers a `_doing_it_wrong()` notice if `is_main_query()` is called too early, bringing consistency with all the other `is_*()` conditionals: `is_single()`, `is_home()`, etc. Follow-up to [16947], [17068], [17083], [18699], [37985]. Props vdankbaar, nhadsall, johnbillion, costdev, thijsoo, teunvgisteren, timkersten655, SergeyBiryukov. Fixes #55104. Built from https://develop.svn.wordpress.org/trunk@53395 git-svn-id: http://core.svn.wordpress.org/trunk@52984 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
04f9d9bdf6
commit
a5db52030f
@ -901,6 +901,11 @@ function is_embed() {
|
|||||||
function is_main_query() {
|
function is_main_query() {
|
||||||
global $wp_query;
|
global $wp_query;
|
||||||
|
|
||||||
|
if ( ! isset( $wp_query ) ) {
|
||||||
|
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '6.1.0' );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( 'pre_get_posts' === current_filter() ) {
|
if ( 'pre_get_posts' === current_filter() ) {
|
||||||
_doing_it_wrong(
|
_doing_it_wrong(
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-alpha-53394';
|
$wp_version = '6.1-alpha-53395';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user