mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-30 18:24:31 +00:00
Fixes #1837 timestamp funkiness
git-svn-id: https://develop.svn.wordpress.org/trunk@3074 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -54,10 +54,17 @@ function wp_insert_post($postarr = array()) {
|
||||
$post_name = sanitize_title($post_name);
|
||||
}
|
||||
|
||||
if (empty($post_date))
|
||||
$post_date = current_time('mysql');
|
||||
if (empty($post_date_gmt))
|
||||
$post_date_gmt = get_gmt_from_date($post_date);
|
||||
|
||||
// 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)) {
|
||||
if ( 'draft' != $post_status )
|
||||
$post_date = current_time('mysql');
|
||||
}
|
||||
|
||||
if (empty($post_date_gmt)) {
|
||||
if ( 'draft' != $post_status )
|
||||
$post_date_gmt = get_gmt_from_date($post_date);
|
||||
}
|
||||
|
||||
if ( empty($comment_status) ) {
|
||||
if ( $update )
|
||||
@@ -382,6 +389,21 @@ function wp_update_post($postarr = array()) {
|
||||
$postarr = array_merge($post, $postarr);
|
||||
$postarr['post_category'] = $post_cats;
|
||||
|
||||
// Drafts shouldn't be assigned a date unless explicitly done so by the user
|
||||
if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) &&
|
||||
('0000-00-00 00:00:00' == $post['post_date']) )
|
||||
$clear_date = true;
|
||||
else
|
||||
$clear_date = false;
|
||||
|
||||
// Merge old and new fields with new fields overwriting old ones.
|
||||
$postarr = array_merge($post, $postarr);
|
||||
$postarr['post_category'] = $post_cats;
|
||||
if ( $clear_date ) {
|
||||
$postarr['post_date'] = '';
|
||||
$postarr['post_date_gmt'] = '';
|
||||
}
|
||||
|
||||
return wp_insert_post($postarr);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user