From 0a787caec63e2bad00ae19fa4e04cfa75f9b0bd7 Mon Sep 17 00:00:00 2001 From: Joe Hoyle Date: Wed, 23 Nov 2016 23:13:32 +0000 Subject: [PATCH] =?UTF-8?q?REST=20API:=20Allow=20unsetting=20a=20post?= =?UTF-8?q?=E2=80=99s=20password.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Props danielbachhuber, iseulde. Fixes #38919. Built from https://develop.svn.wordpress.org/trunk@39352 git-svn-id: http://core.svn.wordpress.org/trunk@39292 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../endpoints/class-wp-rest-posts-controller.php | 14 ++++++++------ wp-includes/version.php | 2 +- 2 files changed, 9 insertions(+), 7 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 df8ac1a892..d249ab81f5 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 @@ -973,15 +973,17 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } // Post password. - if ( ! empty( $schema['properties']['password'] ) && isset( $request['password'] ) && '' !== $request['password'] ) { + if ( ! empty( $schema['properties']['password'] ) && isset( $request['password'] ) ) { $prepared_post->post_password = $request['password']; - if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) { - return new WP_Error( 'rest_invalid_field', __( 'A post can not be sticky and have a password.' ), array( 'status' => 400 ) ); - } + if ( '' !== $request['password'] ) { + if ( ! empty( $schema['properties']['sticky'] ) && ! empty( $request['sticky'] ) ) { + return new WP_Error( 'rest_invalid_field', __( 'A post can not be sticky and have a password.' ), array( 'status' => 400 ) ); + } - if ( ! empty( $prepared_post->ID ) && is_sticky( $prepared_post->ID ) ) { - return new WP_Error( 'rest_invalid_field', __( 'A sticky post can not be password protected.' ), array( 'status' => 400 ) ); + if ( ! empty( $prepared_post->ID ) && is_sticky( $prepared_post->ID ) ) { + return new WP_Error( 'rest_invalid_field', __( 'A sticky post can not be password protected.' ), array( 'status' => 400 ) ); + } } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 4a5351b2b5..ae0be4b61b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7-beta4-39351'; +$wp_version = '4.7-beta4-39352'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.