From 160f106ca8120647b15347be13f8e559e834cd1d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 17 Sep 2008 20:19:29 +0000 Subject: [PATCH] Set post_date for drafts. see #5698 git-svn-id: https://develop.svn.wordpress.org/trunk@8920 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 453f45c70e..bf9d7bd13b 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -1360,12 +1360,8 @@ function wp_insert_post($postarr = array(), $wp_error = false) { } // If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now - if ( empty($post_date) || '0000-00-00 00:00:00' == $post_date ) { - if ( !in_array($post_status, array('draft', 'pending')) ) - $post_date = current_time('mysql'); - else - $post_date = '0000-00-00 00:00:00'; - } + if ( empty($post_date) || '0000-00-00 00:00:00' == $post_date ) + $post_date = current_time('mysql'); if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) { if ( !in_array($post_status, array('draft', 'pending')) ) @@ -1534,8 +1530,8 @@ function wp_update_post($postarr = array()) { $post_cats = $post['post_category']; // Drafts shouldn't be assigned a date unless explicitly done so by the user - if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) && empty($postarr['post_date']) && - ('0000-00-00 00:00:00' == $post['post_date']) ) + if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) && + ('0000-00-00 00:00:00' == $post['post_date_gmt']) ) $clear_date = true; else $clear_date = false; @@ -1544,7 +1540,7 @@ function wp_update_post($postarr = array()) { $postarr = array_merge($post, $postarr); $postarr['post_category'] = $post_cats; if ( $clear_date ) { - $postarr['post_date'] = ''; + $postarr['post_date'] = current_time('mysql');; $postarr['post_date_gmt'] = ''; }