mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
WP_UnitTestCase::go_to() tried its best to clean up global space, but ultimately fell short. Because it was blowing away WP every time it was called, it was dropping all the query vars that were registered for custom taxonomies and custom post types (ouch).
Introduces `_cleanup_query_vars()`. This is a prerequisite for the unit tests on #20767. All unit tests pass with this change. See #20767. Fixes #25818. git-svn-id: https://develop.svn.wordpress.org/trunk@26006 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -363,3 +363,22 @@ function _unregister_post_type( $cpt_name ) {
|
||||
function _unregister_taxonomy( $taxonomy_name ) {
|
||||
unset( $GLOBALS['wp_taxonomies'][$taxonomy_name] );
|
||||
}
|
||||
|
||||
function _cleanup_query_vars() {
|
||||
// clean out globals to stop them polluting wp and wp_query
|
||||
foreach ( $GLOBALS['wp']->public_query_vars as $v )
|
||||
unset( $GLOBALS[$v] );
|
||||
|
||||
foreach ( $GLOBALS['wp']->private_query_vars as $v )
|
||||
unset( $GLOBALS[$v] );
|
||||
|
||||
foreach ( get_taxonomies( array() , 'objects' ) as $t ) {
|
||||
if ( ! empty( $t->query_var ) )
|
||||
$GLOBALS['wp']->add_query_var( $t->query_var );
|
||||
}
|
||||
|
||||
foreach ( get_post_types( array() , 'objects' ) as $t ) {
|
||||
if ( ! empty( $t->query_var ) )
|
||||
$GLOBALS['wp']->add_query_var( $t->query_var );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user