Make WordPress Core


Ignore:
Timestamp:
04/30/2018 04:30:23 AM (7 years ago)
Author:
SergeyBiryukov
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.
Merges [43007] to the 4.9 branch.
Fixes #43739.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php

    r41731 r43038  
    156156            'description'  => $post_type->description,
    157157            'hierarchical' => $post_type->hierarchical,
     158            'viewable'     => is_post_type_viewable( $post_type ),
    158159            'labels'       => $post_type->labels,
    159160            'name'         => $post_type->label,
     
    224225                    'readonly'     => true,
    225226                ),
     227                'viewable'         => array(
     228                    'description'  => __( 'Whether or not the post type can be viewed.' ),
     229                    'type'         => 'boolean',
     230                    'context'      => array( 'edit' ),
     231                    'readonly'     => true,
     232                ),
    226233                'labels'           => array(
    227234                    'description'  => __( 'Human-readable labels for the post type for various contexts.' ),
Note: See TracChangeset for help on using the changeset viewer.