Set post_date for drafts. see #5698

git-svn-id: http://svn.automattic.com/wordpress/trunk@8920 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-09-17 20:19:29 +00:00
parent 9a3f8221c1
commit 3cf0e131c8
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 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 ( empty($post_date) || '0000-00-00 00:00:00' == $post_date )
if ( !in_array($post_status, array('draft', 'pending')) ) $post_date = current_time('mysql');
$post_date = current_time('mysql');
else
$post_date = '0000-00-00 00:00:00';
}
if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) { if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
if ( !in_array($post_status, array('draft', 'pending')) ) if ( !in_array($post_status, array('draft', 'pending')) )
@ -1534,8 +1530,8 @@ function wp_update_post($postarr = array()) {
$post_cats = $post['post_category']; $post_cats = $post['post_category'];
// Drafts shouldn't be assigned a date unless explicitly done so by the user // 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']) && if ( in_array($post['post_status'], array('draft', 'pending')) && empty($postarr['edit_date']) &&
('0000-00-00 00:00:00' == $post['post_date']) ) ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
$clear_date = true; $clear_date = true;
else else
$clear_date = false; $clear_date = false;
@ -1544,7 +1540,7 @@ function wp_update_post($postarr = array()) {
$postarr = array_merge($post, $postarr); $postarr = array_merge($post, $postarr);
$postarr['post_category'] = $post_cats; $postarr['post_category'] = $post_cats;
if ( $clear_date ) { if ( $clear_date ) {
$postarr['post_date'] = ''; $postarr['post_date'] = current_time('mysql');;
$postarr['post_date_gmt'] = ''; $postarr['post_date_gmt'] = '';
} }