`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.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25937 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Category and tag are typically checked before checking for a custom taxonomy. If the global query matches category or tag (even if it also has tax_query set), return category/tag as the queried object, instead of arbitrarily returning the first term in the `tax_query` stack (typically those added with 'pre_get_posts').

Real world example: http://www.emusic.com/17dots/topics/daily-download/ - "tag" page, regionalized for US-only content using `pre_get_posts` passing in the terms "US" and "ALL" for "region" (custom tax). All of the theme functions would output "ALL" as the term name. Even though it was a tag archive, the queried object was an arbitrary term from `tax_query`.

See [26006]. All unit tests pass.
Fixes #20767.



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


git-svn-id: http://core.svn.wordpress.org/trunk@25938 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When WordPress is loaded in a function (e.g. unit tests) the variables initialized at the top level aren't globals, but we expect them to be. Explicitly make the version variables global.

Props nbachiyski.
Fixes #23685.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25939 1a063a9b-81f0-0310-95a4-ce76da25c4cd