Make WordPress Core


Ignore:
Timestamp:
04/27/2018 03:05:40 AM (7 years ago)
Author:
pento
Message:

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.

File:
1 edited

Legend:

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

    r42343 r43007  
    160160            'description'  => $post_type->description,
    161161            'hierarchical' => $post_type->hierarchical,
     162            'viewable'     => is_post_type_viewable( $post_type ),
    162163            'labels'       => $post_type->labels,
    163164            'name'         => $post_type->label,
     
    230231                    'readonly'    => true,
    231232                ),
     233                'viewable'     => array(
     234                    'description' => __( 'Whether or not the post type can be viewed.' ),
     235                    'type'        => 'boolean',
     236                    'context'     => array( 'edit' ),
     237                    'readonly'    => true,
     238                ),
    232239                'labels'       => array(
    233240                    'description' => __( 'Human-readable labels for the post type for various contexts.' ),
Note: See TracChangeset for help on using the changeset viewer.