Fixes #1837 timestamp funkiness
git-svn-id: https://develop.svn.wordpress.org/trunk@3074 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
1932ae4455
commit
a313d7adfb
@ -836,14 +836,11 @@ function update_meta($mid, $mkey, $mvalue) {
|
||||
|
||||
function touch_time($edit = 1, $for_post = 1) {
|
||||
global $month, $post, $comment;
|
||||
if ($for_post && ('draft' == $post->post_status)) {
|
||||
$checked = 'checked="checked" ';
|
||||
$edit = false;
|
||||
} else {
|
||||
$checked = ' ';
|
||||
}
|
||||
|
||||
echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" '.$checked.'/> <label for="timestamp">'.__('Edit timestamp').'</label></legend>';
|
||||
if ( $for_post )
|
||||
$edit = ( ('draft' == $post->post_status) && (!$post->post_date || '0000-00-00 00:00:00' == $post->post_date) ) ? false : true;
|
||||
|
||||
echo '<fieldset><legend><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp" /> <label for="timestamp">'.__('Edit timestamp').'</label></legend>';
|
||||
|
||||
$time_adj = time() + (get_settings('gmt_offset') * 3600);
|
||||
$post_date = ($for_post) ? $post->post_date : $comment->comment_date;
|
||||
@ -873,19 +870,11 @@ function touch_time($edit = 1, $for_post = 1) {
|
||||
<input type="text" id="hh" name="hh" value="<?php echo $hh ?>" size="2" maxlength="2" /> :
|
||||
<input type="text" id="mn" name="mn" value="<?php echo $mn ?>" size="2" maxlength="2" />
|
||||
<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
|
||||
<?php _e('Existing timestamp'); ?>:
|
||||
<?php
|
||||
|
||||
// We might need to readjust to display proper existing timestamp
|
||||
if ($for_post && ('draft' == $post->post_status)) {
|
||||
$jj = mysql2date('d', $post_date);
|
||||
$mm = mysql2date('m', $post_date);
|
||||
$aa = mysql2date('Y', $post_date);
|
||||
$hh = mysql2date('H', $post_date);
|
||||
$mn = mysql2date('i', $post_date);
|
||||
$ss = mysql2date('s', $post_date);
|
||||
if ( $edit ) {
|
||||
_e('Existing timestamp');
|
||||
echo ": {$month[$mm]} $jj, $aa @ $hh:$mn";
|
||||
}
|
||||
echo "{$month[$mm]} $jj, $aa @ $hh:$mn";
|
||||
?>
|
||||
</fieldset>
|
||||
<?php
|
||||
|
@ -54,10 +54,17 @@ function wp_insert_post($postarr = array()) {
|
||||
$post_name = sanitize_title($post_name);
|
||||
}
|
||||
|
||||
if (empty($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 (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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user