mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +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:
@@ -300,6 +300,21 @@ class WP {
|
||||
if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) )
|
||||
$this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] );
|
||||
|
||||
// Don't allow non-public taxonomies to be queried from the front-end.
|
||||
if ( ! is_admin() ) {
|
||||
foreach ( get_taxonomies( array( 'public' => false ), 'objects' ) as $taxonomy => $t ) {
|
||||
// Check first for taxonomy-specific query_var.
|
||||
if ( $t->query_var && isset( $this->query_vars[ $t->query_var ] ) ) {
|
||||
unset( $this->query_vars[ $t->query_var ] );
|
||||
}
|
||||
|
||||
// Next, check the 'taxonomy' query_var.
|
||||
if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) {
|
||||
unset( $this->query_vars['taxonomy'], $this->query_vars['term'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Limit publicly queried post_types to those that are publicly_queryable
|
||||
if ( isset( $this->query_vars['post_type']) ) {
|
||||
$queryable_post_types = get_post_types( array('publicly_queryable' => true) );
|
||||
|
||||
Reference in New Issue
Block a user