Make WordPress Core

Ticket #24804: 24804.11.diff

File 24804.11.diff, 10.2 KB (added by nacin, 10 years ago)
  • wp-admin/css/wp-admin.css

     
    36413641.revisions-controls .author-card .date {
    36423642        color: #777;
    36433643}
     3644
     3645.revisions-controls .author-card.autosave {
     3646        color: #d54e21;
     3647}
     3648
    36443649.revisions-controls .author-card .author-name {
    36453650        font-weight: bold;
    36463651}
  • wp-admin/edit-form-advanced.php

     
    106106// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
    107107require_once('./includes/meta-boxes.php');
    108108
     109
     110$publish_callback_args = null;
     111if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
     112        $revisions = wp_get_post_revisions( $post_ID );
     113
     114        // Check if the revisions have been upgraded
     115        if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 )
     116                _wp_upgrade_revisions_of_post( $post, $revisions );
     117
     118        // We should aim to show the revisions metabox only when there are revisions.
     119        if ( count( $revisions ) > 1 ) {
     120                reset( $revisions ); // Reset pointer for key()
     121                $publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) );
     122                // add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
     123        }
     124}
     125
    109126if ( 'attachment' == $post_type ) {
    110127        wp_enqueue_script( 'image-edit' );
    111128        wp_enqueue_style( 'imgareaselect' );
     
    112129        add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
    113130        add_action( 'edit_form_after_title', 'edit_form_image_editor' );
    114131} else {
    115         add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );
     132        add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args );
    116133}
    117134
    118135if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
     
    169186                add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
    170187}
    171188
    172 if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
    173         $revisions = wp_get_post_revisions( $post_ID );
    174 
    175         // Check if the revisions have been upgraded
    176         if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 )
    177                 _wp_upgrade_revisions_of_post( $post, $revisions );
    178 
    179         // We should aim to show the revisions metabox only when there are revisions.
    180         if ( count( $revisions ) > 1 )
    181                 add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
    182 }
    183 
    184189do_action('add_meta_boxes', $post_type, $post);
    185190do_action('add_meta_boxes_' . $post_type, $post);
    186191
  • wp-admin/includes/meta-boxes.php

     
    99 *
    1010 * @param object $post
    1111 */
    12 function post_submit_meta_box($post) {
     12function post_submit_meta_box($post, $args = array() ) {
    1313        global $action;
    1414
    1515        $post_type = $post->post_type;
     
    171171        $date = date_i18n( $datef, strtotime( current_time('mysql') ) );
    172172}
    173173
     174if ( ! empty( $args['args']['revisions_count'] ) ) : ?>
     175<div class="misc-pub-section num-revisions">
     176        <?php printf( 'Revisions: %s', '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' ); ?>
     177        <a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><?php _ex( 'Browse', 'revisions' ); ?></a>
     178</div>
     179<?php endif;
     180
    174181if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
    175182<div class="misc-pub-section curtime">
    176183        <span id="timestamp">
  • wp-admin/includes/revision.php

     
    9696
    9797        cache_users( wp_list_pluck( $revisions, 'post_author' ) );
    9898
     99        $can_restore = current_user_can( 'edit_post', $post->ID );
     100
    99101        foreach ( $revisions as $revision ) {
    100102                $modified = strtotime( $revision->post_modified );
    101103                $modified_gmt = strtotime( $revision->post_modified_gmt );
    102                 $restore_link = str_replace( '&amp;', '&', wp_nonce_url(
    103                         add_query_arg(
    104                                 array( 'revision' => $revision->ID,
    105                                         'action' => 'restore' ),
    106                                         admin_url( 'revision.php' )
    107                         ),
    108                         "restore-post_{$revision->ID}"
    109                 ) );
     104                if ( $can_restore ) {
     105                        $restore_link = str_replace( '&amp;', '&', wp_nonce_url(
     106                                add_query_arg(
     107                                        array( 'revision' => $revision->ID,
     108                                                'action' => 'restore' ),
     109                                                admin_url( 'revision.php' )
     110                                ),
     111                                "restore-post_{$revision->ID}"
     112                        ) );
     113                }
    110114
    111115                if ( ! isset( $authors[ $revision->post_author ] ) ) {
    112116                        $authors[ $revision->post_author ] = array(
     
    138142                        'timeAgo'    => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
    139143                        'autosave'   => $autosave,
    140144                        'current'    => $current,
    141                         'restoreUrl' => urldecode( $restore_link ),
     145                        'restoreUrl' => $can_restore ? $restore_link : false,
    142146                );
    143147        }
    144148
  • wp-admin/revision.php

     
    3131        if ( ! $post = get_post( $revision->post_parent ) )
    3232                break;
    3333
    34         // Revisions disabled (previously checked autosavegs && ! wp_is_post_autosave( $revision ))
     34        // Revisions disabled (previously checked autosaves && ! wp_is_post_autosave( $revision ))
    3535        if ( ! wp_revisions_enabled( $post ) ) {
    3636                $redirect = 'edit.php?post_type=' . $post->post_type;
    3737                break;
     
    133133<script id="tmpl-revisions-tooltip" type="text/html">
    134134        <div class="author-card">
    135135        <# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
    136                 {{{ data.author.avatar }}}
    137                 <div class="author-info">
    138                                
    139                         <span class="byline"><?php printf( __( 'Revision by %s' ),
    140                                 '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
    141                         <span class="time-ago">{{ data.timeAgo }}</span>
    142                         <span class="date">({{ data.dateShort }})</span>
    143                 </div>
     136                        <div class="author-card<# if ( data.autosave ) { #> autosave<# } #>">
     137                                {{{ data.author.avatar }}}
     138                                <div class="author-info">
     139                                <# if ( data.autosave ) { #>
     140                                        <span class="byline"><?php printf( __( 'Autosave by %s' ),
     141                                                '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
     142                                <# } else if ( data.current ) { #>
     143                                        <span class="byline"><?php printf( __( 'Current Revision by %s' ),
     144                                                '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
     145                                <# } else { #>
     146                                        <span class="byline"><?php printf( __( 'Revision by %s' ),
     147                                                '<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
     148                                <# } #>
     149                                        <span class="time-ago">{{ data.timeAgo }}</span>
     150                                        <span class="date">({{ data.dateShort }})</span>
     151                                </div>
     152                        </div>
    144153        <# } #>
    145154        </div>
    146155        <div class="revisions-tooltip-arrow"><span></span></div>
     
    166175                <div class="diff-title">
    167176                        <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
    168177                <# if ( 'undefined' !== typeof data.from ) { #>
    169                         <div class="author-card">
     178                        <div class="author-card<# if ( data.from.attributes.autosave ) { #> autosave<# } #>">
    170179                                {{{ data.from.attributes.author.avatar }}}
    171180                                <div class="author-info">
     181                                <# if ( data.from.attributes.autosave ) { #>
     182                                        <span class="byline"><?php printf( __( 'Autosave by %s' ),
     183                                                '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
     184                                <# } else if ( data.from.attributes.current ) { #>
     185                                        <span class="byline"><?php printf( __( 'Current Revision by %s' ),
     186                                                '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
     187                                <# } else { #>
    172188                                        <span class="byline"><?php printf( __( 'Revision by %s' ),
    173189                                                '<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
     190                                <# } #>
    174191                                        <span class="time-ago">{{ data.from.attributes.timeAgo }}</span>
    175192                                        <span class="date">({{ data.from.attributes.dateShort }})</span>
    176193                                </div>
     
    183200                <div class="diff-title">
    184201                        <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
    185202                <# if ( 'undefined' !== typeof data.to ) { #>
    186                         <div class="author-card">
     203                        <div class="author-card<# if ( data.to.attributes.autosave ) { #> autosave<# } #>">
    187204                                {{{ data.to.attributes.author.avatar }}}
    188205                                <div class="author-info">
     206                                <# if ( data.to.attributes.autosave ) { #>
     207                                        <span class="byline"><?php printf( __( 'Autosave by %s' ),
     208                                                '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
     209                                <# } else if ( data.to.attributes.current ) { #>
     210                                        <span class="byline"><?php printf( __( 'Current Revision by %s' ),
     211                                                '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
     212                                <# } else { #>
    189213                                        <span class="byline"><?php printf( __( 'Revision by %s' ),
    190214                                                '<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
     215                                <# } #>
    191216                                        <span class="time-ago">{{ data.to.attributes.timeAgo }}</span>
    192217                                        <span class="date">({{ data.to.attributes.dateShort }})</span>
    193218                                </div>
    194219                <# } #>
     220                <# if ( data.to.attributes.restoreUrl ) { #>
    195221                        <input
    196222                        <# if ( data.to.attributes.current ) { #>
    197223                                disabled="disabled"
    198224                        <# } #>
    199                         type="button" class="restore-revision button button-primary" data-restore-link="{{{ data.restoreLink }}}" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
     225                        <# if ( data.to.attributes.autosave ) { #>
     226                                type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
     227                        <# } else { #>
     228                                type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
     229                        <# } #>
     230                <# } #>
    200231                </div>
    201232        </div>
    202233</script>