mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-06 23:58:03 +00:00
Allow taxonomies to be non-public.
[13216] introduced the 'public' argument for `register_taxonomy()`. This param was used to set defaults for 'show_ui' and a number of other params, but it never did anything itself. With this changeset, taxonomies registered with `public=false` will no longer be queryable on the front end, ie via taxonomy archive queries. Props wpsmith, ocean90, nacin, ericlewis, boonebgorges. Fixes #21949. git-svn-id: https://develop.svn.wordpress.org/trunk@34247 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -442,4 +442,44 @@ class Tests_Taxonomy extends WP_UnitTestCase {
|
||||
$this->assertEqualSets( array( $t1 ), get_ancestors( $t2, 'wptests_conflict' ) );
|
||||
_unregister_post_type( 'wptests_pt' );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21949
|
||||
*/
|
||||
public function test_nonpublic_taxonomy_should_not_be_queryable_using_taxname_query_var() {
|
||||
register_taxonomy( 'wptests_tax', 'post', array(
|
||||
'public' => false,
|
||||
) );
|
||||
|
||||
$t = $this->factory->term->create_and_get( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
) );
|
||||
|
||||
$p = $this->factory->post->create();
|
||||
wp_set_object_terms( $p, $t->slug, 'wptests_tax' );
|
||||
|
||||
$this->go_to( '/?wptests_tax=' . $t->slug );
|
||||
|
||||
$this->assertFalse( is_tax( 'wptests_tax' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 21949
|
||||
*/
|
||||
public function test_nonpublic_taxonomy_should_not_be_queryable_using_taxonomy_and_term_vars() {
|
||||
register_taxonomy( 'wptests_tax', 'post', array(
|
||||
'public' => false,
|
||||
) );
|
||||
|
||||
$t = $this->factory->term->create_and_get( array(
|
||||
'taxonomy' => 'wptests_tax',
|
||||
) );
|
||||
|
||||
$p = $this->factory->post->create();
|
||||
wp_set_object_terms( $p, $t->slug, 'wptests_tax' );
|
||||
|
||||
$this->go_to( '/?taxonomy=wptests_tax&term=' . $t->slug );
|
||||
|
||||
$this->assertFalse( is_tax( 'wptests_tax' ) );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user