From 4a8aefaf72bd62afecc4aafb94e26f1dd787de52 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 30 Mar 2021 15:17:05 +0000 Subject: [PATCH] Coding Standards: Remove some extra whitespace in `_wp_translate_postdata()`. See #52627. git-svn-id: https://develop.svn.wordpress.org/trunk@50618 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/post.php | 36 +++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/wp-admin/includes/post.php b/src/wp-admin/includes/post.php index 37b9239b25..5f32e44051 100644 --- a/src/wp-admin/includes/post.php +++ b/src/wp-admin/includes/post.php @@ -169,24 +169,27 @@ function _wp_translate_postdata( $update = false, $post_data = null ) { } if ( ! empty( $post_data['edit_date'] ) ) { - $aa = $post_data['aa']; - $mm = $post_data['mm']; - $jj = $post_data['jj']; - $hh = $post_data['hh']; - $mn = $post_data['mn']; - $ss = $post_data['ss']; - $aa = ( $aa <= 0 ) ? gmdate( 'Y' ) : $aa; - $mm = ( $mm <= 0 ) ? gmdate( 'n' ) : $mm; - $jj = ( $jj > 31 ) ? 31 : $jj; - $jj = ( $jj <= 0 ) ? gmdate( 'j' ) : $jj; - $hh = ( $hh > 23 ) ? $hh - 24 : $hh; - $mn = ( $mn > 59 ) ? $mn - 60 : $mn; - $ss = ( $ss > 59 ) ? $ss - 60 : $ss; + $aa = $post_data['aa']; + $mm = $post_data['mm']; + $jj = $post_data['jj']; + $hh = $post_data['hh']; + $mn = $post_data['mn']; + $ss = $post_data['ss']; + $aa = ( $aa <= 0 ) ? gmdate( 'Y' ) : $aa; + $mm = ( $mm <= 0 ) ? gmdate( 'n' ) : $mm; + $jj = ( $jj > 31 ) ? 31 : $jj; + $jj = ( $jj <= 0 ) ? gmdate( 'j' ) : $jj; + $hh = ( $hh > 23 ) ? $hh - 24 : $hh; + $mn = ( $mn > 59 ) ? $mn - 60 : $mn; + $ss = ( $ss > 59 ) ? $ss - 60 : $ss; + $post_data['post_date'] = sprintf( '%04d-%02d-%02d %02d:%02d:%02d', $aa, $mm, $jj, $hh, $mn, $ss ); - $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); + + $valid_date = wp_checkdate( $mm, $jj, $aa, $post_data['post_date'] ); if ( ! $valid_date ) { return new WP_Error( 'invalid_date', __( 'Invalid date.' ) ); } + $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); } @@ -246,8 +249,9 @@ function edit_post( $post_data = null ) { // Clear out any data in internal vars. unset( $post_data['filter'] ); - $post_ID = (int) $post_data['post_ID']; - $post = get_post( $post_ID ); + $post_ID = (int) $post_data['post_ID']; + $post = get_post( $post_ID ); + $post_data['post_type'] = $post->post_type; $post_data['post_mime_type'] = $post->post_mime_type;