From 5c6c4e37131cd69af502adfbc31247be2611ebfe Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 2 Oct 2015 04:36:24 +0000 Subject: [PATCH] Posts: In `wp_insert_post()`, don't set `post_date` to current time if it can be derived from a passed value for `post_date_gmt`. Adds unit tests. Props oso96_2000, kawauso. Fixes #15946. Built from https://develop.svn.wordpress.org/trunk@34762 git-svn-id: http://core.svn.wordpress.org/trunk@34727 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-functions.php | 6 +++++- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/wp-includes/post-functions.php b/wp-includes/post-functions.php index 10e6be4e21..4d012f6de0 100644 --- a/wp-includes/post-functions.php +++ b/wp-includes/post-functions.php @@ -3012,7 +3012,11 @@ function wp_insert_post( $postarr, $wp_error = false ) { * is not 'draft' or 'pending', set date to now. */ if ( empty( $postarr['post_date'] ) || '0000-00-00 00:00:00' == $postarr['post_date'] ) { - $post_date = current_time( 'mysql' ); + if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' == $postarr['post_date_gmt'] ) { + $post_date = current_time( 'mysql' ); + } else { + $post_date = get_date_from_gmt( $postarr['post_date_gmt'] ); + } } else { $post_date = $postarr['post_date']; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 59cc9afcc3..41fed00809 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34761'; +$wp_version = '4.4-alpha-34762'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.