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:
parent
9a3f8221c1
commit
3cf0e131c8
|
@ -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'] = '';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue