WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/21/2013 03:54:11 PM (8 years ago)
Author:
westi
Message:

Revisions: UI Update.

  • Refines the UI to make it clearer and easier to use
  • Introduces weighted tickmarks
  • Fixes comparison bugs.

See #23497 props adamsilverstein

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/revision.php

    r23639 r23769  
    1818    if ( ! $revision = wp_get_post_revision( $revision_id ) )
    1919        break;
     20
    2021    if ( ! current_user_can( 'edit_post', $revision->post_parent ) )
    2122        break;
     23
     24
    2225    if ( ! $post = get_post( $revision->post_parent ) )
    2326        break;
    2427
    25     // Revisions disabled and we're not looking at an autosave
    26     if ( ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions' ) ) && ! wp_is_post_autosave( $revision ) ) {
     28    // Revisions disabled (previously checked autosavegs && ! wp_is_post_autosave( $revision ))
     29    if ( ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions' ) ) ) {
    2730        $redirect = 'edit.php?post_type=' . $post->post_type;
    2831        break;
    2932    }
    30     check_admin_referer( "restore-post_{$post->ID}|{$revision->ID}" );
    3133
    32     //store revision event in post meta
    33     $restore_details = array(
    34         'restored_revision_id' => $revision->ID,
    35         'restored_by_user' => get_current_user_id(),
    36         'restored_time' => time()
    37     );
    38     update_post_meta( $post->ID, '_post_restored_from', $restore_details );
     34    check_admin_referer( "restore-post_{$revision->ID}" );
    3935
    4036    wp_restore_post_revision( $revision->ID );
     
    5955
    6056    $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
    61     $revision_title = wp_post_revision_title( $revision, false );
    6257    $h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
    6358    $title = __( 'Revisions' );
     
    8176else
    8277    $parent_file = $submenu_file = 'edit.php';
    83 
    8478wp_enqueue_script( 'revisions' );
    8579
     
    8882//TODO - Some of the translations below split things into multiple strings that are contextually related and this makes it pretty impossible for RTL translation.
    8983//TODO can we pass the context in a better way
    90 ?>
    91 <script type="text/javascript">
    92 var wpRevisionsSettings = <?php echo json_encode( array( 'post_id' => $post->ID, 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ) ) ); ?>;
    93 </script>
    94 <?php
    95     $comparetworevisionslink = get_edit_post_link( $revision->ID );
     84$wpRevisionsSettings = array( 'post_id' => $post->ID,
     85                        'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ),
     86                        'revision_id' => $revision_id );
     87wp_localize_script( 'revisions', 'wpRevisionsSettings', $wpRevisionsSettings );
     88
     89$comparetworevisionslink = get_edit_post_link( $revision->ID );
    9690?>
    9791
    98 <div id="backbonerevisionsoptions"></div>
     92<div id="backbonerevisionsoptions">
     93</div>
    9994<div class="wrap">
    100     <div class="icon32 icon32-posts-post" id="icon-edit"><br></div>
     95    <div class="icon32 icon32-posts-post" id="icon-edit">
     96        <br>
     97    </div>
    10198    <div class="revisiondiffcontainer diffsplit currentversion rightmodelloading">
    102         <div id="modelsloading" class="updated message"><span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?></div>
     99        <div id="modelsloading" class="updated message">
     100            <span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?>
     101        </div>
    103102        <h2 class="long-header"><?php echo $h2; ?></h2>
    104         <div id="backbonerevisionsinteract"></div>
    105         <div id="backbonerevisionsdiff"></div>
     103        <div class="diff-slider-ticks-wrapper">
     104            <div id="diff-slider-ticks">
     105            </div>
     106        </div>
     107        <div id="backbonerevisionsinteract">
     108        </div>
     109        <div id="backbonerevisionsdiff">
     110        </div>
    106111        <hr />
    107112    </div>
     
    109114
    110115<script id="tmpl-revision" type="text/html">
     116    <div id="diffsubheader" class="diff-left-hand-meta-row">
     117        <div id="diff_from_current_revision">
     118            <?php printf( '<b>%1$s</b> %2$s.' , __( 'From:' ), __( 'the current version' ) ); ?>
     119        </div>
     120        <div id="difftitlefrom">
     121            <div class="diff-from-title"><?php _e( 'From:' ); ?></div>{{{ data.revision_from_date_author }}}
     122        </div>
     123    </div>
     124
    111125    <div id="diffsubheader">
    112         <span id="diff_from_current_revision"><?php _e( 'Current version' ); ?><?php _e( '- compared to -' ); ?></span>
    113         <div id="difftitlefrom">{{{ data.revision_from_date_author }}} <?php _e( '- compared to -' ); ?></div>
    114         <div id="difftitle">{{{ data.revision_date_author }}}</div>
    115         <div id="diffcancel"><input class="button" onClick="document.location='<?php echo get_edit_post_link( $post->ID ); ?>'" type="submit" id="cancel" value="<?php esc_attr_e( 'Cancel' )?>" /></div>
    116         <div id="diffrestore"><input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore revision ID' )?>" /></div>
    117         <div id="comparetworevisions"><input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> <label for="comparetwo"><?php esc_attr_e( 'Compare two revisions' ); ?></a></div>    </div>
     126        <div id="difftitle">
     127            <div class="diff-to-title"><?php _e( 'To:' ); ?></div>{{{ data.revision_date_author }}}
     128        </div>
     129        <div id="diffrestore">
     130            <input class="button button-primary restore-button" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore This Revision' )?>" />
     131        </div>
     132        <div id="comparetworevisions">
     133            <input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/>
     134                <label for="comparetwo"><?php esc_attr_e( 'Compare two revisions' ); ?></a></label>
     135        </div>
     136    </div>
     137
    118138    <div id="removedandadded">
    119139        <div id="removed"><?php _e( 'Removed -' ); ?></div>
     
    125145<script id="tmpl-revisionvinteract" type="text/html">
    126146    <div id="diffheader">
    127 <div id="diffprevious"><input class="button" type="submit" id="previous" value="<?php esc_attr_e( 'Previous' ); ?>" /></div>
    128             <div id="diffnext"><input class="button" type="submit" id="next" value="<?php esc_attr_e( 'Next' ); ?>" /></div>
    129             <div id="diffslider">
    130     <div id="revisioncount">
    131                     <?php _e( 'Comparing' ); ?>
    132                     <span id="diff_left_count"> <?php _e( 'revision' ); ?></span> <span id="diff_left_count_inner"></span>
    133                     <span id="diff_left_current_revision"><?php _e( 'current version' ); ?></span>
    134                     <span id="diff_revision_from">{{{ data.diff_revision_from }}}</span>
    135                     <?php _e( ' to revision' ); ?>
    136                     <span id="diff_count">{{{ data.current_diff }}}</span>
    137                     <?php _e( ' of ' ); ?>
    138                     <span id="diff_max" ></span>
    139                 </div>
    140 
    141             <div id="slider" class="wp-slider"></div>
     147        <div id="diffprevious"><input class="button" type="submit" id="previous" value="<?php esc_attr_e( 'Previous' ); ?>" />
    142148        </div>
     149        <div id="diffnext"><input class="button" type="submit" id="next" value="<?php esc_attr_e( 'Next' ); ?>" />
     150        </div>
     151        <div id="diffslider">
     152            <div id="slider" class="wp-slider">
     153            </div>
     154        </div>
     155    </div>
     156</script>
     157<script id="tmpl-revision-ticks" type="text/html">
     158    <div class="revision-tick revision-toload{{{ data.revision_toload }}} revision-scopeofchanges-{{{ data.scope_of_changes }}}">
    143159    </div>
    144160</script>
Note: See TracChangeset for help on using the changeset viewer.