REST API: Include `viewable` attribute on Post Type resource for `edit` context

For the block editor to be able to expose the Preview button correctly, it needs to know the `is_post_type_viewable()` setting, this change adds it to the Post Type response.

Props danielbachhuber.
Fixes #43739.


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


git-svn-id: http://core.svn.wordpress.org/trunk@42836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Gary Pendergast 2018-04-27 03:06:21 +00:00
parent 6b2e34f703
commit 52d0b2f982
2 changed files with 8 additions and 1 deletions

View File

@ -159,6 +159,7 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
'capabilities' => $post_type->cap,
'description' => $post_type->description,
'hierarchical' => $post_type->hierarchical,
'viewable' => is_post_type_viewable( $post_type ),
'labels' => $post_type->labels,
'name' => $post_type->label,
'slug' => $post_type->name,
@ -229,6 +230,12 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'viewable' => array(
'description' => __( 'Whether or not the post type can be viewed.' ),
'type' => 'boolean',
'context' => array( 'edit' ),
'readonly' => true,
),
'labels' => array(
'description' => __( 'Human-readable labels for the post type for various contexts.' ),
'type' => 'object',

View File

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