REST API: Include template in all post type schemas.

[38951] added templates to all post types, but didn't add them to the schema.

Props swissspidy.
Fixes #38698.


git-svn-id: https://develop.svn.wordpress.org/trunk@39182 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan McCue
2016-11-09 07:12:01 +00:00
parent 8a0c502703
commit 446dc73042
3 changed files with 59 additions and 11 deletions
@@ -1094,7 +1094,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
}
/**
* Sets the template for a page.
* Sets the template for a post.
*
* @since 4.7.0
* @access public
@@ -1922,14 +1922,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
);
}
if ( 'page' === $this->post_type ) {
$schema['properties']['template'] = array(
'description' => __( 'The theme file to use to display the object.' ),
'type' => 'string',
'enum' => array_keys( wp_get_theme()->get_page_templates() ),
'context' => array( 'view', 'edit' ),
);
}
$schema['properties']['template'] = array(
'description' => __( 'The theme file to use to display the object.' ),
'type' => 'string',
'enum' => array_keys( wp_get_theme()->get_page_templates( null, $this->post_type ) ),
'context' => array( 'view', 'edit' ),
);
$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
foreach ( $taxonomies as $taxonomy ) {