mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-22 06:29:30 +00:00
REST API: Add the supports
property to the Post Type response object.
Includes a new `supports` property in the response object and schema for the `/types` endpoints for users with the `edit_posts` capability for the given post type. The `supports` property returns an object of the features the given post type *supports*. Props timmydcrawford, tyxla. Fixes #39033. Built from https://develop.svn.wordpress.org/trunk@39647 git-svn-id: http://core.svn.wordpress.org/trunk@39587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
24767c76d3
commit
158f302112
@ -149,6 +149,8 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
|
||||
$taxonomies = wp_list_filter( get_object_taxonomies( $post_type->name, 'objects' ), array( 'show_in_rest' => true ) );
|
||||
$taxonomies = wp_list_pluck( $taxonomies, 'name' );
|
||||
$base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name;
|
||||
$supports = get_all_post_type_supports( $post_type->name );
|
||||
|
||||
$data = array(
|
||||
'capabilities' => $post_type->cap,
|
||||
'description' => $post_type->description,
|
||||
@ -156,6 +158,7 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
|
||||
'labels' => $post_type->labels,
|
||||
'name' => $post_type->label,
|
||||
'slug' => $post_type->name,
|
||||
'supports' => $supports,
|
||||
'taxonomies' => array_values( $taxonomies ),
|
||||
'rest_base' => $base,
|
||||
);
|
||||
@ -239,6 +242,12 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'supports' => array(
|
||||
'description' => __( 'All features, supported by the post type.' ),
|
||||
'type' => 'object',
|
||||
'context' => array( 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'taxonomies' => array(
|
||||
'description' => __( 'Taxonomies associated with post type.' ),
|
||||
'type' => 'array',
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-39645';
|
||||
$wp_version = '4.8-alpha-39647';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user