Ticket #1837: bug1837_drafts_shouldnt_get_auto_timestamped.diff
File bug1837_drafts_shouldnt_get_auto_timestamped.diff, 3.4 KB (added by , 18 years ago) |
---|
-
wp-admin/admin-functions.php
839 839 840 840 function touch_time($edit = 1, $for_post = 1) { 841 841 global $month, $post, $comment; 842 if ($for_post && ('draft' == $post->post_status)) {843 $checked = 'checked="checked" ';844 $edit = false;845 } else {846 $checked = ' ';847 }848 842 849 echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">'.__('Edit timestamp').'</label></legend>'; 843 if ( $for_post ) 844 $edit = ( ('draft' == $post->post_status) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true; 850 845 846 echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__('Edit timestamp').'</label></legend>'; 847 851 848 $time_adj = time() + (get_settings('gmt_offset') * 3600); 852 849 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; 853 850 $jj = ($edit) ? mysql2date('d', $post_date) : gmdate('d', $time_adj); … … 876 873 <input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> : 877 874 <input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" /> 878 875 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" /> 879 <?php _e('Existing timestamp'); ?>: 880 <?php 881 882 // We might need to readjust to display proper existing timestamp 883 if ($for_post && ('draft' == $post->post_status)) { 884 $jj = mysql2date('d', $post_date); 885 $mm = mysql2date('m', $post_date); 886 $aa = mysql2date('Y', $post_date); 887 $hh = mysql2date('H', $post_date); 888 $mn = mysql2date('i', $post_date); 889 $ss = mysql2date('s', $post_date); 876 <?php 877 if ( $edit ) { 878 _e('Existing timestamp'); 879 echo ": {$month[$mm]} $jj, $aa @ $hh:$mn"; 890 880 } 891 echo "{$month[$mm]} $jj, $aa @ $hh:$mn";892 881 ?> 893 882 </fieldset> 894 883 <?php -
wp-includes/functions-post.php
54 54 $post_name = sanitize_title($post_name); 55 55 } 56 56 57 if (empty($post_date)) 58 $post_date = current_time('mysql'); 59 if (empty($post_date_gmt)) 60 $post_date_gmt = get_gmt_from_date($post_date); 57 // If the post date is empty (due to having been new or a draft) and status is not 'draft', set date to now 58 if (empty($post_date)) { 59 if ( 'draft' != $post_status ) 60 $post_date = current_time('mysql'); 61 } 62 if (empty($post_date_gmt)) { 63 if ( 'draft' != $post_status ) 64 $post_date_gmt = get_gmt_from_date($post_date); 65 } 61 66 62 67 if ( empty($comment_status) ) { 63 68 if ( $update ) … … 376 381 else 377 382 $post_cats = $post['post_category']; 378 383 384 // Drafts shouldn't be assigned a date unless explicitly done so by the user 385 if ( 'draft' == $post['post_status'] && empty($postarr['edit_date']) && empty($postarr['post_date']) && 386 ('0000-00-00 00:00:00' == $post['post_date']) ) 387 $clear_date = true; 388 else 389 $clear_date = false; 390 379 391 // Merge old and new fields with new fields overwriting old ones. 380 392 $postarr = array_merge($post, $postarr); 381 393 $postarr['post_category'] = $post_cats; 382 394 if ( $clear_date ) { 395 $postarr['post_date'] = ''; 396 $postarr['post_date_gmt'] = ''; 397 } 383 398 return wp_insert_post($postarr); 384 399 } 385 400