diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index 6791c98cbc..238e2e6660 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -331,12 +331,12 @@ 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. + // Don't allow non-publicly queryable taxonomies to be queried from the front-end. if ( ! is_admin() ) { - foreach ( get_taxonomies( array( 'public' => false ), 'objects' ) as $taxonomy => $t ) { + foreach ( get_taxonomies( array( 'publicly_queryable' => false ), 'objects' ) as $taxonomy => $t ) { /* * Disallow when set to the 'taxonomy' query var. - * Non-public taxonomies cannot register custom query vars. See register_taxonomy(). + * Non-publicly queryable taxonomies cannot register custom query vars. See register_taxonomy(). */ if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) { unset( $this->query_vars['taxonomy'], $this->query_vars['term'] ); diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 4d672564ef..0164b0f803 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -288,7 +288,12 @@ function is_taxonomy_hierarchical($taxonomy) { * taxonomies. See accepted values in get_taxonomy_labels(). * Default empty array. * @type string $description A short descriptive summary of what the taxonomy is for. Default empty. - * @type bool $public Whether the taxonomy is publicly queryable. Default true. + * @type bool $public Whether a taxonomy is intended for use publicly either via + * the admin interface or by front-end users. The default settings + * of `$publicly_queryable`, `$show_ui`, and `$show_in_nav_menus` + * are inherited from `$public`. + * @type bool $publicly_queryable Whether the taxonomy is publicly queryable. + * If not set, the default is inherited from `$public` * @type bool $hierarchical Whether the taxonomy is hierarchical. Default false. * @type bool $show_ui Whether to generate and allow a UI for managing terms in this taxonomy in * the admin. If not set, the default is inherited from `$public` @@ -362,6 +367,7 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { 'labels' => array(), 'description' => '', 'public' => true, + 'publicly_queryable' => null, 'hierarchical' => false, 'show_ui' => null, 'show_in_menu' => null, @@ -383,8 +389,13 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomy names must be between 1 and 32 characters in length.' ) ); } - // Non-public taxonomies should not register query vars, except in the admin. - if ( false !== $args['query_var'] && ( is_admin() || false !== $args['public'] ) && ! empty( $wp ) ) { + // If not set, default to the setting for public. + if ( null === $args['publicly_queryable'] ) { + $args['publicly_queryable'] = $args['public']; + } + + // Non-publicly queryable taxonomies should not register query vars, except in the admin. + if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) && ! empty( $wp ) ) { if ( true === $args['query_var'] ) $args['query_var'] = $taxonomy; else diff --git a/wp-includes/version.php b/wp-includes/version.php index b5a96e3e08..40e1fca2f8 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.5-alpha-36524'; +$wp_version = '4.5-alpha-36525'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.