Set post_date for drafts. see #5698

git-svn-id: https://develop.svn.wordpress.org/trunk@8920 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-09-17 20:19:29 +00:00
parent 96ec3c30ce
commit 160f106ca8
1 changed files with 5 additions and 9 deletions

View File

@ -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'] = '';
}