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.

Built from https://develop.svn.wordpress.org/trunk@39182


git-svn-id: http://core.svn.wordpress.org/trunk@39122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan McCue 2016-11-09 07:12:32 +00:00
parent 5b676af8ff
commit a2bbbddb9e
2 changed files with 8 additions and 10 deletions

View File

@ -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 * @since 4.7.0
* @access public * @access public
@ -1922,14 +1922,12 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
); );
} }
if ( 'page' === $this->post_type ) { $schema['properties']['template'] = array(
$schema['properties']['template'] = array( 'description' => __( 'The theme file to use to display the object.' ),
'description' => __( 'The theme file to use to display the object.' ), 'type' => 'string',
'type' => 'string', 'enum' => array_keys( wp_get_theme()->get_page_templates( null, $this->post_type ) ),
'enum' => array_keys( wp_get_theme()->get_page_templates() ), 'context' => array( 'view', 'edit' ),
'context' => array( 'view', 'edit' ), );
);
}
$taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) ); $taxonomies = wp_list_filter( get_object_taxonomies( $this->post_type, 'objects' ), array( 'show_in_rest' => true ) );
foreach ( $taxonomies as $taxonomy ) { foreach ( $taxonomies as $taxonomy ) {

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-beta2-39181'; $wp_version = '4.7-beta2-39182';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.