Changeset 53395
- Timestamp:
- 05/14/2022 03:08:58 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r51154 r53395 901 901 function is_main_query() { 902 902 global $wp_query; 903 904 if ( ! isset( $wp_query ) ) { 905 _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '6.1.0' ); 906 return false; 907 } 903 908 904 909 if ( 'pre_get_posts' === current_filter() ) { -
trunk/tests/phpunit/tests/query/conditionals.php
r52010 r53395 1617 1617 } 1618 1618 1619 /** 1620 * @ticket 55104 1621 * @expectedIncorrectUsage is_main_query 1622 */ 1623 public function test_is_main_query_returns_false_if_wp_query_is_not_set() { 1624 unset( $GLOBALS['wp_query'] ); 1625 1626 $this->assertFalse( is_main_query() ); 1627 } 1628 1619 1629 }
Note: See TracChangeset
for help on using the changeset viewer.