From a2bbbddb9e812a8b4888eb6fa2ae60184bf5bd55 Mon Sep 17 00:00:00 2001 From: Ryan McCue Date: Wed, 9 Nov 2016 07:12:32 +0000 Subject: [PATCH] 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 --- .../endpoints/class-wp-rest-posts-controller.php | 16 +++++++--------- wp-includes/version.php | 2 +- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 716f3297c0..11ae1ec798 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -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 ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 25e90b33d4..012a0a96d2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.