REST API: Show taxonomy visibility settings.

For Gutenberg and other admin-type interfaces, it's useful to be able to see the visibility settings for taxonomies.

Props joehoyle, pento.
Fixes #42707.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2018-02-22 00:24:31 +00:00
parent f4f64377b7
commit d6923d285c
2 changed files with 42 additions and 1 deletions

View File

@ -191,6 +191,14 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller {
'show_cloud' => $taxonomy->show_tagcloud, 'show_cloud' => $taxonomy->show_tagcloud,
'hierarchical' => $taxonomy->hierarchical, 'hierarchical' => $taxonomy->hierarchical,
'rest_base' => $base, 'rest_base' => $base,
'visibility' => array(
'public' => (bool) $taxonomy->public,
'publicly_queryable' => (bool) $taxonomy->publicly_queryable,
'show_admin_column' => (bool) $taxonomy->show_admin_column,
'show_in_nav_menus' => (bool) $taxonomy->show_in_nav_menus,
'show_in_quick_edit' => (bool) $taxonomy->show_in_quick_edit,
'show_ui' => (bool) $taxonomy->show_ui,
),
); );
$context = ! empty( $request['context'] ) ? $request['context'] : 'view'; $context = ! empty( $request['context'] ) ? $request['context'] : 'view';
@ -295,6 +303,39 @@ class WP_REST_Taxonomies_Controller extends WP_REST_Controller {
'context' => array( 'view', 'edit', 'embed' ), 'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true, 'readonly' => true,
), ),
'visibility' => array(
'description' => __( 'The visibility settings for the taxomonmy.' ),
'type' => 'object',
'context' => array( 'edit' ),
'readonly' => true,
'properties' => array(
'public' => array(
'description' => 'Whether a taxonomy is intended for use publicly either via the admin interface or by front-end users.',
'type' => 'boolean',
),
'publicly_queryable' => array(
'description' => 'Whether the taxonomy is publicly queryable.',
'type' => 'boolean',
),
'show_ui' => array(
'description' => 'Whether to generate a default UI for managing this taxonomy.',
'type' => 'boolean',
),
'show_admin_column' => array(
'description' => 'Whether to allow automatic creation of taxonomy columns on associated post-types table.',
'type' => 'boolean',
),
'show_in_nav_menus' => array(
'description' => 'Whether to make the taxonomy available for selection in navigation menus.',
'type' => 'boolean',
),
'show_in_quick_edit' => array(
'description' => 'Whether to show the taxonomy in the quick/bulk edit panel.',
'type' => 'boolean',
),
),
),
), ),
); );
return $this->add_additional_fields_schema( $schema ); return $this->add_additional_fields_schema( $schema );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.0-alpha-42728'; $wp_version = '5.0-alpha-42729';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.