Skip to content

Commit

Permalink
Jetpack JSON API: Fix Fatal in WPCOM_JSON_API_Update_Post_v1_2_Endpoi…
Browse files Browse the repository at this point in the history
…nt (#40393)

* Jetpack JSON API: Fix Fatal in WPCOM_JSON_API_Update_Post_v1_2_Endpoint
  • Loading branch information
fgiannar authored Dec 2, 2024
1 parent d407cbc commit 1a0a361
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: other
Comment: Jetpack JSON API: Fix Fatal in WPCOM_JSON_API_Update_Post_v1_2_Endpoint


Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,14 @@ public function write_post( $path, $blog_id, $post_id ) {

// If date is set, $this->input will set date_gmt, date still needs to be adjusted.
if ( isset( $input['date_gmt'] ) ) {
$gmt_offset = get_option( 'gmt_offset' );
$time_with_offset = strtotime( $input['date_gmt'] ) + $gmt_offset * HOUR_IN_SECONDS;
$input['date'] = gmdate( 'Y-m-d H:i:s', $time_with_offset );
$date_gmt_timestamp = strtotime( $input['date_gmt'] );
if ( $date_gmt_timestamp ) {
$gmt_offset = (int) get_option( 'gmt_offset' );
$time_with_offset = $date_gmt_timestamp + $gmt_offset * HOUR_IN_SECONDS;
$input['date'] = gmdate( 'Y-m-d H:i:s', $time_with_offset );
} else { // Invalid input.
unset( $input['date_gmt'] );
}
}

if ( ! empty( $author_id ) && get_current_user_id() !== $author_id ) {
Expand Down

0 comments on commit 1a0a361

Please sign in to comment.