REST API: Allow unsetting of page templates in update requests.

Sending a request to update a page with the template property set to an empty string resulted in an error because “” was not a valid value in the enum.

Props lucasstark, swissspidy.
Fixes #38877.

git-svn-id: https://develop.svn.wordpress.org/trunk@39343 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Hoyle
2016-11-23 02:46:42 +00:00
parent 2341473a5f
commit e606bc36c1
4 changed files with 101 additions and 1 deletions
@@ -1928,7 +1928,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
$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 ) ),
'enum' => array_merge( array_keys( wp_get_theme()->get_page_templates( null, $this->post_type ) ), array( '' ) ),
'context' => array( 'view', 'edit' ),
);