Make WordPress Core

Ticket #8368: garyc40.8368.diff

File garyc40.8368.diff, 7.1 KB (added by garyc40, 14 years ago)
  • wp-admin/css/wp-admin.dev.css

    diff --git wp-admin/css/wp-admin.dev.css wp-admin/css/wp-admin.dev.css
    index 0a70bd5..cce3512 100644
    td.post-title p, td.plugin-title p { 
    23392339        border-style: solid;
    23402340}
    23412341
     2342#timestampdiv input[type=radio] {
     2343        margin-right:10px;
     2344}
    23422345
    23432346/*------------------------------------------------------------------------------
    23442347  11.1 - Custom Fields
  • wp-admin/includes/post.php

    diff --git wp-admin/includes/post.php wp-admin/includes/post.php
    index 510d59f..654a132 100644
    function _wp_translate_postdata( $update = false, $post_data = null ) { 
    9494        if (!isset( $post_data['ping_status'] ))
    9595                $post_data['ping_status'] = 'closed';
    9696
    97         foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
    98                 if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
    99                         $post_data['edit_date'] = '1';
    100                         break;
     97        // publish_immediately radio box is only displayed when editing scheduled post
     98        // so it's safe to assume that when we encounter this value, the new status is 'publish'
     99        if ( ! empty( $post_data['publish_immediately'] ) ) {
     100                $post_data['post_status'] = 'publish';
     101               
     102                // cancel the scheduled date
     103                $post_data['post_date'] = current_time( 'mysql' );
     104                $post_data['post_date_gmt'] = '';
     105        } else {
     106                foreach ( array('aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {
     107                        if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) {
     108                                $post_data['edit_date'] = '1';
     109                                break;
     110                        }
    101111                }
    102112        }
    103113
  • wp-admin/includes/template.php

    diff --git wp-admin/includes/template.php wp-admin/includes/template.php
    index d9790be..b31642c 100644
    function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { 
    594594
    595595        $time_adj = current_time('timestamp');
    596596        $post_date = ($for_post) ? $post->post_date : $comment->comment_date;
     597        $radio_boxes = ( $post->post_status == 'future' ); // only display radio boxes if post is scheduled
    597598        $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj );
    598599        $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj );
    599600        $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj );
    function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { 
    622623        $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';
    623624
    624625        echo '<div class="timestamp-wrap">';
     626       
     627        if ( $radio_boxes ) {
     628                echo '<label for="publish-immediately"><input type="radio" name="publish_immediately" value="1" id="publish-immediately" />' . __( 'Immediately' ) . '</label><br />';
     629                echo '<input type="radio" id="publish-future" name="publish_immediately" value="0" checked="checked" />';
     630        }
     631
    625632        /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */
    626633        printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute);
    627634
  • wp-admin/js/post.dev.js

    diff --git wp-admin/js/post.dev.js wp-admin/js/post.dev.js
    index 1c39edf..3b53913 100644
    jQuery(document).ready( function($) { 
    249249                });
    250250        }
    251251
     252        $('#aa, #mm, #jj, #hh, #mn').change(function(){
     253                $('#publish-future').attr('checked', true);
     254                updateText();
     255        });
     256       
     257        $('#timestampdiv input[type=radio]').change(function(){
     258                updateText();
     259        });
     260
    252261        // categories
    253262        $('.categorydiv').each( function(){
    254263                var this_id = $(this).attr('id'), noSyncChecks = false, syncChecks, catAddAfter, taxonomyParts, taxonomy, settingName;
    jQuery(document).ready( function($) { 
    374383                                $('.timestamp-wrap', '#timestampdiv').removeClass('form-invalid');
    375384                        }
    376385
    377                         if ( attemptedDate > currentDate && $('#original_post_status').val() != 'future' ) {
    378                                 publishOn = postL10n.publishOnFuture;
    379                                 $('#publish').val( postL10n.schedule );
    380                         } else if ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) {
     386                        if ( ( attemptedDate <= currentDate && $('#original_post_status').val() != 'publish' ) || $('#publish-immediately').is(':checked') ) {
    381387                                publishOn = postL10n.publishOn;
    382388                                $('#publish').val( postL10n.publish );
     389                        } else if ( attemptedDate > currentDate && attemptedDate.toUTCString() != originalDate.toUTCString() ) {
     390                                publishOn = postL10n.publishOnFuture;
     391                                $('#publish').val( postL10n.schedule );
    383392                        } else {
    384393                                publishOn = postL10n.publishOnPast;
    385394                                $('#publish').val( postL10n.update );
    386395                        }
    387                         if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
     396                        if ( $('#publish-immediately').is(':checked') ) {
     397                                $('#timestamp').html(postL10n.publishImmediately);
     398                        } else if ( originalDate.toUTCString() == attemptedDate.toUTCString() ) { //hack
    388399                                $('#timestamp').html(stamp);
    389400                        } else {
    390401                                $('#timestamp').html(
    jQuery(document).ready( function($) { 
    395406                                        hh + ':' +
    396407                                        mn + '</b> '
    397408                                );
     409                                $('#publish-future').attr('checked', true);
    398410                        }
    399411
    400412                        if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) {
    jQuery(document).ready( function($) { 
    493505                        $('#hh').val($('#hidden_hh').val());
    494506                        $('#mn').val($('#hidden_mn').val());
    495507                        $('#timestampdiv').siblings('a.edit-timestamp').show();
     508                        $('#publish-future').attr('checked', true);
    496509                        updateText();
    497510                        return false;
    498511                });
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index 3c3759e..b0c30eb 100644
    function wp_update_post($postarr = array()) { 
    26532653                $post_cats = $postarr['post_category'];
    26542654        else
    26552655                $post_cats = $post['post_category'];
    2656 
     2656       
    26572657        // Drafts shouldn't be assigned a date unless explicitly done so by the user
    2658         if ( isset( $post['post_status'] ) && in_array($post['post_status'], array('draft', 'pending', 'auto-draft')) && empty($postarr['edit_date']) &&
    2659                          ('0000-00-00 00:00:00' == $post['post_date_gmt']) )
    2660                 $clear_date = true;
    2661         else
    2662                 $clear_date = false;
     2658        $clear_date = isset( $post['post_status'] ) && in_array( $post['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) && empty( $postarr['edit_date'] )
     2659                                        && ( '0000-00-00 00:00:00' == $post['post_date_gmt'] );
    26632660
    26642661        // Merge old and new fields with new fields overwriting old ones.
    26652662        $postarr = array_merge($post, $postarr);
  • wp-includes/script-loader.php

    diff --git wp-includes/script-loader.php wp-includes/script-loader.php
    index 6f07db5..4a6f0b5 100644
    function wp_default_scripts( &$scripts ) { 
    338338                        'password' => __('Password Protected'),
    339339                        'privatelyPublished' => __('Privately Published'),
    340340                        'published' => __('Published'),
    341                         'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};'
     341                        'l10n_print_after' => 'try{convertEntities(postL10n);}catch(e){};',
     342                        'publishImmediately' => __('Publish <b>immediately</b>'),
    342343                ) );
    343344
    344345                $scripts->add( 'link', "/wp-admin/js/link$suffix.js", array('wp-lists', 'postbox'), '20090526' );