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.
Built from https://develop.svn.wordpress.org/trunk@39343


git-svn-id: http://core.svn.wordpress.org/trunk@39283 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Joe Hoyle 2016-11-23 02:47:30 +00:00
parent d711f2c18d
commit 14654d9539
2 changed files with 2 additions and 2 deletions

View File

@ -1928,7 +1928,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
$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_merge( array_keys( wp_get_theme()->get_page_templates( null, $this->post_type ) ), array( '' ) ),
'context' => array( 'view', 'edit' ), 'context' => array( 'view', 'edit' ),
); );

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-beta4-39342'; $wp_version = '4.7-beta4-39343';
/** /**
* 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.