Introduce `publicly_queryable` taxonomy argument.
Taxonomies registered as `publicly_queryable` can be queried as taxonomy archives. If not provided explicitly, the value of `publicly_queryable` is inherited from `public`. Props Chouby. Fixes #34491. Built from https://develop.svn.wordpress.org/trunk@36525 git-svn-id: http://core.svn.wordpress.org/trunk@36492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
60cf073672
commit
48b8ea78da
|
@ -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'] );
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue