WordPress.org

Make WordPress Core

Ticket #6250: better-date-editing.diff

File better-date-editing.diff, 8.6 KB (added by markjaquith, 10 years ago)
  • wp-includes/script-loader.php

     
    147147                                'add' => attribute_escape(__('Add')),
    148148                                'addTag' => attribute_escape(__('Add new tag')),
    149149                                'separate' => __('Separate tags with commas'),
     150                                'cancel' => __('Cancel'),
     151                                'edit' => __('Edit'),
    150152                        ) );
    151153                        $this->add( 'page', '/wp-admin/js/page.js', array('jquery', 'slug', 'postbox'), '20080208' );
    152154                        $this->add( 'link', '/wp-admin/js/link.js', array('jquery-ui-tabs', 'wp-lists', 'postbox'), '20080131' );
  • wp-admin/includes/comment.php

     
    2121        $_POST['comment_content'] = $_POST['content'];
    2222        $_POST['comment_ID'] = (int) $_POST['comment_ID'];
    2323
     24        foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
     25                if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
     26                        $_POST['edit_date'] = '1';
     27                        break;
     28                }
     29        }
     30
     31
    2432        if (!empty ( $_POST['edit_date'] ) ) {
    2533                $aa = $_POST['aa'];
    2634                $mm = $_POST['mm'];
  • wp-admin/includes/template.php

     
    830830        if ( (int) $tab_index > 0 )
    831831                $tab_index_attribute = " tabindex=\"$tab_index\"";
    832832
    833         echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
     833        // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />';
    834834
    835835        $time_adj = time() + (get_option( 'gmt_offset' ) * 3600 );
    836836        $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
     
    841841        $mn = ($edit) ? mysql2date( 'i', $post_date ) : gmdate( 'i', $time_adj );
    842842        $ss = ($edit) ? mysql2date( 's', $post_date ) : gmdate( 's', $time_adj );
    843843
    844         $month = "<select name=\"mm\" onchange=\"edit_date.checked=true\"$tab_index_attribute>\n";
     844        $month = "<select id=\"mm\" name=\"mm\" onchange=\"edit_date.checked=true\"$tab_index_attribute>\n";
    845845        for ( $i = 1; $i < 13; $i = $i +1 ) {
    846                 $month .= "\t\t\t<option value=\"$i\"";
     846                $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';
    847847                if ( $i == $mm )
    848848                        $month .= ' selected="selected"';
    849849                $month .= '>' . $wp_locale->get_month( $i ) . "</option>\n";
    850850        }
    851851        $month .= '</select>';
    852852
    853         $day = '<input type="text" id="jj" name="jj" value="' . $jj . '" size="2" maxlength="2" onchange="edit_date.checked=true"' . $tab_index_attribute . ' autocomplete="off"  />';
    854         $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5" onchange="edit_date.checked=true"' . $tab_index_attribute . ' autocomplete="off"  />';
    855         $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2" onchange="edit_date.checked=true"' . $tab_index_attribute . ' autocomplete="off"  />';
    856         $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2" onchange="edit_date.checked=true"' . $tab_index_attribute . ' autocomplete="off"  />';
    857         printf(_c('%1$s%2$s%3$s @ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
     853        $day = '<input type="text" id="jj" name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     854        $year = '<input type="text" id="aa" name="aa" value="' . $aa . '" size="4" maxlength="5"' . $tab_index_attribute . ' autocomplete="off"  />';
     855        $hour = '<input type="text" id="hh" name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     856        $minute = '<input type="text" id="mn" name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off"  />';
     857        printf(_c('%1$s%2$s, %3$s <br />@ %4$s : %5$s|1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input'), $month, $day, $year, $hour, $minute);
     858        echo "\n\n";
     859        foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit )
     860                echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
    858861?>
    859 <input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" onchange="edit_date.checked=true" />
     862
     863<input type="hidden" id="ss" name="ss" value="<?php echo $ss ?>" size="2" maxlength="2" />
    860864<?php
    861865}
    862866
  • wp-admin/includes/post.php

     
    7474        if (!isset( $_POST['ping_status'] ))
    7575                $_POST['ping_status'] = 'closed';
    7676
     77        foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
     78                if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
     79                        $_POST['edit_date'] = '1';
     80                        break;
     81                }
     82        }
     83
    7784        if (!empty ( $_POST['edit_date'] ) ) {
    7885                $aa = $_POST['aa'];
    7986                $mm = $_POST['mm'];
     
    281288        if (!isset( $_POST['ping_status'] ))
    282289                $_POST['ping_status'] = 'closed';
    283290
     291        foreach ( array ('aa', 'mm', 'jj', 'hh', 'mm') as $timeunit ) {
     292                if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) {
     293                        $_POST['edit_date'] = '1';
     294                        break;
     295                }
     296        }
     297
    284298        if (!empty ( $_POST['edit_date'] ) ) {
    285299                $aa = $_POST['aa'];
    286300                $mm = $_POST['mm'];
  • wp-admin/js/post.js

     
    149149        jQuery('.edit-timestamp').click(function () {
    150150                if (jQuery('#timestampdiv').is(":hidden")) {
    151151                        jQuery('#timestampdiv').slideDown("normal");
     152                        jQuery('.edit-timestamp').text(postL10n.cancel);
    152153                } else {
    153154                        jQuery('#timestampdiv').hide();
     155                        jQuery('#mm').val(jQuery('#hidden_mm').val());
     156                        jQuery('#jj').val(jQuery('#hidden_jj').val());
     157                        jQuery('#aa').val(jQuery('#hidden_aa').val());
     158                        jQuery('#hh').val(jQuery('#hidden_hh').val());
     159                        jQuery('#mn').val(jQuery('#hidden_mn').val());
     160                        jQuery('.edit-timestamp').text(postL10n.edit);
    154161                }
    155162                return false;
    156163    });
  • wp-admin/edit-form-advanced.php

     
    100100<p><label for="post_status_private" class="selectit"><input id="post_status_private" name="post_status" type="checkbox" value="private" <?php checked($post->post_status, 'private'); ?> /> <?php _e('Keep this post private') ?></label></p>
    101101<?php
    102102if ($post_ID) {
    103 
    104         if ( 'future' == $post->post_status ) {
     103        if ( 'future' == $post->post_status ) { // scheduled for publishing at a future date
    105104                $stamp = __('Scheduled for:<br />%1$s at %2$s');
    106         } else if ( 'publish' == $post->post_status ) {
    107                 $stamp = __('%1$s at %2$s');
    108         } else {
    109                 $stamp = __('Saved on:<br />%1$s at %2$s');
     105        } else if ( 'publish' == $post->post_status ) { // already published
     106                $stamp = __('Published on:<br />%1$s at %2$s');
     107        } else if ( '0000-00-00 00:00:00' == $post->post_date ) { // draft, 1 or more saves, no date specified
     108                $stamp = __('Publish immediately');
     109        } else { // draft, 1 or more saves, date specified
     110                $stamp = __('Publish on:<br />%1$s at %2$s');
    110111        }
    111 
    112112        $date = mysql2date(get_option('date_format'), $post->post_date);
    113113        $time = mysql2date(get_option('time_format'), $post->post_date);
    114 } else {
    115         $stamp = __('%1$s at %2$s');
     114} else { // draft (no saves, and thus no date specified)
     115        $stamp = __('Publish immediately');
    116116        $date = mysql2date(get_option('date_format'), current_time('mysql'));
    117117        $time = mysql2date(get_option('time_format'), current_time('mysql'));
    118118}
     
    143143<br class="clear" />
    144144<?php if ($post_ID): ?>
    145145<?php printf(__('Last edit: %1$s at %2$s'), mysql2date(get_option('date_format'), $post->post_modified), mysql2date(get_option('time_format'), $post->post_modified)); ?>
     146<?php if ( $last_id = get_post_meta($post_ID, '_edit_last', true) ) {
     147        $last_user = get_userdata($last_id);
     148        echo '<br />' . sprintf( __( 'by <b>%s</b>' ), wp_specialchars( $last_user->display_name ) );
     149}
     150
     151 ?>
    146152<br class="clear" />
    147153<?php endif; ?>
    148154<span id="autosave"></span>