diff options
Diffstat (limited to 'plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php')
-rw-r--r-- | plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php index 98186ca3..6deae172 100644 --- a/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php +++ b/plugins/jetpack/json-endpoints/class.wpcom-json-api-update-post-v1-2-endpoint.php @@ -265,8 +265,12 @@ class WPCOM_JSON_API_Update_Post_v1_2_Endpoint extends WPCOM_JSON_API_Update_Pos $new_status = isset( $input['status'] ) ? $input['status'] : $last_status; // Make sure that drafts get the current date when transitioning to publish if not supplied in the post. + // Similarly, scheduled posts that are manually published before their scheduled date should have the date reset. $date_in_past = ( strtotime($post->post_date_gmt) < time() ); - if ( 'publish' === $new_status && 'draft' === $last_status && ! isset( $input['date_gmt'] ) && $date_in_past ) { + $reset_draft_date = 'publish' === $new_status && 'draft' === $last_status && ! isset( $input['date_gmt'] ) && $date_in_past; + $reset_scheduled_date = 'publish' === $new_status && 'future' === $last_status && ! isset( $input['date_gmt'] ) && ! $date_in_past; + + if ( $reset_draft_date || $reset_scheduled_date ) { $input['date_gmt'] = gmdate( 'Y-m-d H:i:s' ); } } |