From 52d0b2f982af2b7c0233f41196627541d0212406 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 27 Apr 2018 03:06:21 +0000 Subject: [PATCH] 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 --- .../endpoints/class-wp-rest-post-types-controller.php | 7 +++++++ wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php index 203cea2530..de0ccab598 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php @@ -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', diff --git a/wp-includes/version.php b/wp-includes/version.php index 58eb5b5fdb..552baf376d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.