diff --git a/admin/duplicate-post.php b/admin/duplicate-post.php index 971fd5d..4acc287 100644 --- a/admin/duplicate-post.php +++ b/admin/duplicate-post.php @@ -1169,10 +1169,14 @@ function duplicate_post_create_duplicate($post_to_dup, $status = '', $parent_id $new_post["ID"] = $to_post_id; } - if($this->get_option('duplicate_post_copydate') == 1){ - $new_post['post_date'] = $new_post_date = $post_to_dup->post_date ; - $new_post['post_date_gmt'] = get_gmt_from_date($new_post_date); - } + if($this->get_option('duplicate_post_copydate') == 1 && empty( $to_post_id ) ){ + $new_post['post_date'] = $new_post_date = $post_to_dup->post_date ; + $new_post['post_date_gmt'] = get_gmt_from_date($new_post_date); + } else if( ! empty( $to_post_id ) ) { + // We are merging back, do not override publish date + $new_post['post_date'] = $new_post_date = $to_post->post_date ; + $new_post['post_date_gmt'] = get_gmt_from_date($new_post_date); + } $new_post_id = wp_insert_post($new_post); delete_post_meta($new_post_id, '_dp_original_backup'); @@ -1226,4 +1230,4 @@ function save_to_original( $post_id ){ } -} \ No newline at end of file +}