mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-04 17:20:07 +00:00
REST API: Allow unsetting a post’s password.
Props danielbachhuber, iseulde. Fixes #38919. git-svn-id: https://develop.svn.wordpress.org/trunk@39352 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -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 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user