WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/29/2016 05:27:37 PM (4 years ago)
Author:
rachelbaker
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php

    r39342 r39647  
    150150        $taxonomies = wp_list_pluck( $taxonomies, 'name' );
    151151        $base = ! empty( $post_type->rest_base ) ? $post_type->rest_base : $post_type->name;
     152        $supports = get_all_post_type_supports( $post_type->name );
     153
    152154        $data = array(
    153155            'capabilities' => $post_type->cap,
     
    157159            'name'         => $post_type->label,
    158160            'slug'         => $post_type->name,
     161            'supports'     => $supports,
    159162            'taxonomies'   => array_values( $taxonomies ),
    160163            'rest_base'    => $base,
     
    240243                    'readonly'     => true,
    241244                ),
     245                'supports'         => array(
     246                    'description'  => __( 'All features, supported by the post type.' ),
     247                    'type'         => 'object',
     248                    'context'      => array( 'edit' ),
     249                    'readonly'     => true,
     250                ),
    242251                'taxonomies'       => array(
    243252                    'description'  => __( 'Taxonomies associated with post type.' ),
Note: See TracChangeset for help on using the changeset viewer.