<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[23639] trunk: Revisions: Updates to the new Revisions UI.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/23639">23639</a></dd>
<dt>Author</dt> <dd>westi</dd>
<dt>Date</dt> <dd>2013-03-07 15:32:26 +0000 (Thu, 07 Mar 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Revisions: Updates to the new Revisions UI.
Various Updates including:
* i18n fixes
* Added tracking of what revision ID was restored
* async fetching of diffs so that slider works sooner even with many revisions
See <a href="http://core.trac.wordpress.org/ticket/23497">#23497</a> props adamsilverstein, ethitter</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadmincsswpadmincss">trunk/wp-admin/css/wp-admin.css</a></li>
<li><a href="#trunkwpadminincludesajaxactionsphp">trunk/wp-admin/includes/ajax-actions.php</a></li>
<li><a href="#trunkwpadminjsrevisionsjs">trunk/wp-admin/js/revisions.js</a></li>
<li><a href="#trunkwpadminrevisionphp">trunk/wp-admin/revision.php</a></li>
<li><a href="#trunkwpincludespluggablephp">trunk/wp-includes/pluggable.php</a></li>
<li><a href="#trunkwpincludesposttemplatephp">trunk/wp-includes/post-template.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadmincsswpadmincss"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/css/wp-admin.css (23638 => 23639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/css/wp-admin.css        2013-03-07 15:11:23 UTC (rev 23638)
+++ trunk/wp-admin/css/wp-admin.css        2013-03-07 15:32:26 UTC (rev 23639)
</span><span class="lines">@@ -3722,10 +3722,25 @@
</span><span class="cx"> .leftmodelloading #modelsloading,
</span><span class="cx"> .rightmodelloading #modelsloading,
</span><span class="cx"> .leftmodelloading #modelsloading .spinner,
</span><del>-.rightmodelloading #modelsloading .spinner {
</del><ins>+.rightmodelloading #modelsloading .spinner,
+{
</ins><span class="cx">         display: inline;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+.diff-loading {
+        margin-top: 50px;
+        width: 100%;
+        height: 200px;
+}
+.diff-loading .spinner
+{
+        clear: both;
+        margin-left: auto;
+        margin-right: auto;
+        display: block;
+        float: none;
+}
+
</ins><span class="cx"> #difftitlefrom {
</span><span class="cx">         float: left;
</span><span class="cx">         display: none;
</span></span></pre></div>
<a id="trunkwpadminincludesajaxactionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/ajax-actions.php (23638 => 23639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/ajax-actions.php        2013-03-07 15:11:23 UTC (rev 23638)
+++ trunk/wp-admin/includes/ajax-actions.php        2013-03-07 15:32:26 UTC (rev 23639)
</span><span class="lines">@@ -2131,132 +2131,139 @@
</span><span class="cx"> function wp_ajax_revisions_data() {
</span><span class="cx">         check_ajax_referer( 'revisions-ajax-nonce', 'nonce' );
</span><span class="cx">
</span><del>-        $compareto = isset( $_GET['compareto'] ) ? absint( $_GET['compareto'] ) : 0;
-        $showautosaves = isset( $_GET['showautosaves'] ) ? $_GET['showautosaves'] : '';
-        $showsplitview = isset( $_GET['showsplitview'] ) ? $_GET['showsplitview'] : '';
-        $postid = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : '';
</del><ins>+        $compare_to = isset( $_GET['compare_to'] ) ? absint( $_GET['compare_to'] ) : 0;
+        $show_autosaves = isset( $_GET['show_autosaves'] ) ? $_GET['show_autosaves'] : '';
+        $show_split_view = isset( $_GET['show_split_view'] ) ? $_GET['show_split_view'] : '';
+        $post_id = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : '';
+        $right_handle_at = isset( $_GET['right_handle_at'] ) ? $_GET['right_handle_at'] : 0;
+        $left_handle_at = isset( $_GET['left_handle_at'] ) ? $_GET['left_handle_at'] : 0;
+        $single_revision_id = isset( $_GET['single_revision_id'] ) ? $_GET['single_revision_id'] : 0;
</ins><span class="cx">
</span><del>-        $comparetwomode = ( '' == $postid ) ? false : true;
</del><ins>+        $compare_two_mode = ( '' == $post_id ) ? false : true;
</ins><span class="cx">         //
</span><del>-        //TODO: currently code returns all possible comparisons for the indicated 'compareto' revision
</del><ins>+        //TODO: currently code returns all possible comparisons for the indicated 'compare_to' revision
</ins><span class="cx">         //however, the front end prevents users from pulling the right handle past the left or the left pass the right,
</span><span class="cx">         //so only the possible diffs need be generated
</span><span class="cx">         //
</span><span class="cx">         $alltherevisions = array();
</span><del>-        if ( '' == $postid )
-                $postid = $compareto;
</del><ins>+        if ( '' == $post_id )
+                $post_id = $compare_to;
</ins><span class="cx">
</span><del>-        if ( ! current_user_can( 'read_post', $postid ) )
</del><ins>+        if ( ! current_user_can( 'read_post', $post_id ) )
</ins><span class="cx">                 continue;
</span><span class="cx">
</span><del>-        if ( ! $revisions = wp_get_post_revisions( $postid ) )
</del><ins>+        if ( ! $revisions = wp_get_post_revisions( $post_id ) )
</ins><span class="cx">                 return;
</span><span class="cx">
</span><ins>+        /* translators: revision date format, see http://php.net/date */
+        $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
</ins><span class="cx">
</span><del>-        //if we are comparing two revisions, the first 'revision' represented by the leftmost
-        //slider position is the current revision, prepend a comparison to this revision
-        if ( $comparetwomode )
-                array_unshift( $revisions, get_post( $postid ) );
</del><ins>+        //single model fetch mode
+        if ( 0 != $single_revision_id ) {
+                $left_revision = get_post( $compare_to );
+                $right_revision = get_post( $single_revision_id );
</ins><span class="cx">
</span><del>-        $count = 1;
-        foreach ( $revisions as $revision ) :
-        if ( 'true' != $showautosaves && wp_is_post_autosave( $revision ) )
-                        continue;
</del><ins>+                if ( $compare_two_mode ) {
+                        $compare_to_gravatar = get_avatar( $left_revision->post_author, 18 );
+                        $compare_to_author = get_the_author_meta( 'display_name', $left_revision->post_author );
+                        $compare_to_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) );
</ins><span class="cx">
</span><del>-        $revision_from_date_author = '';
</del><ins>+                        $revision_from_date_author = sprintf(
+                                '%s %s, %s %s (%s)',
+                                $compare_to_gravatar,
+                                $compare_to_author,
+                                human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ),
+                                __( ' ago ' ),
+                                $compare_to_date
+                        );
+                }
</ins><span class="cx">
</span><ins>+                //
+                //make sure the left revision is the most recent
+                //
+                if ( strtotime( $right_revision->post_modified_gmt ) < strtotime( $left_revision->post_modified_gmt ) ) {
+                        $temp = $left_revision;
+                        $left_revision = $right_revision;
+                        $right_revision = $temp;
+                }
</ins><span class="cx">
</span><del>-        $left_revision = get_post( $compareto );
-        $right_revision = get_post( $revision );
</del><ins>+                //
+                //compare from left to right, passed from application
+                //
+                $content='';
+                foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
+                        $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' );
+                        $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' );
</ins><span class="cx">
</span><del>-        $author = get_the_author_meta( 'display_name', $revision->post_author );
-        /* translators: revision date format, see http://php.net/date */
-        $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
</del><ins>+                        add_filter( "_wp_post_revision_field_$field", 'wp_kses_post' );
</ins><span class="cx">
</span><del>-        $gravatar = get_avatar( $revision->post_author, 18 );
</del><ins>+                        $args = array();
</ins><span class="cx">
</span><del>-        $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
-        $revision_date_author = sprintf(
-                '%s %s, %s %s (%s)',
-                $gravatar,
-                $author,
-                human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ),
-                __( ' ago ' ),
-                $date
-        );
</del><ins>+                        if ( ! empty( $show_split_view ) )
+                                 $args = array( 'show_split_view' => true );
</ins><span class="cx">
</span><del>-        if ( $comparetwomode ) {
-                $compareto_gravatar = get_avatar( $left_revision->post_author, 18 );
-                $compareto_author = get_the_author_meta( 'display_name', $left_revision->post_author );
-                $compareto_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) );
-
-                $revision_from_date_author = sprintf(
-                        '%s %s, %s %s (%s)',
-                        $compareto_gravatar,
-                        $compareto_author,
-                        human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ),
-                        __( ' ago ' ),
-                        $compareto_date
-                );
</del><ins>+                        $content .= wp_text_diff( $left_content, $right_content, $args );
+                }
+                        $content = '' == $content ? __( 'No difference' ) : $content;
+                        $alltherevisions = array (
+                                'revisiondiff' => $content
+                        );
+                echo json_encode( $alltherevisions );
+                exit();
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        $restoreaction = wp_nonce_url(
-                add_query_arg(
-                        array( 'revision' => $revision->ID,
-                                'action' => 'restore' ),
-                                '/wp-admin/revision.php'
-                ),
-                "restore-post_{$compareto}|{$revision->ID}"
-        );
</del><ins>+        //if we are comparing two revisions, the first 'revision' represented by the leftmost
+        //slider position is the current revision, prepend a comparison to this revision
+        if ( $compare_two_mode )
+                array_unshift( $revisions, get_post( $post_id ) );
+                
+        $count = -1;
</ins><span class="cx">
</span><del>-        //
-        //make sure the left revision is the most recent
-        //
-        if ( strtotime( $right_revision->post_modified_gmt ) < strtotime( $left_revision->post_modified_gmt ) ) {
-                $temp = $left_revision;
-                $left_revision = $right_revision;
-                $right_revision = $temp;
-        }
</del><ins>+        foreach ( $revisions as $revision ) :
+                if ( ! empty( $show_autosaves ) && wp_is_post_autosave( $revision ) )
+                                continue;
</ins><span class="cx">
</span><del>-        //
-        //compare from left to right, passed from application
-        //
-        $content='';
-        foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
-                $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' );
-                $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' );
</del><ins>+                $revision_from_date_author = '';
+                $count++;
+                // return blank data for diffs to the left of the left handle (for right handel model)
+                // or to the right of the right handle (for left handel model)
+                if ( ( 0 != $left_handle_at && $count <= $left_handle_at ) ||
+                         ( 0 != $right_handle_at && $count > $right_handle_at )) {
+                        $alltherevisions[] = array (
+                                'ID' => $revision->ID,
+                        );
+                        
+                        continue;
+                }
</ins><span class="cx">
</span><del>-                add_filter( "_wp_post_revision_field_$field", 'wp_kses_post' );
</del><ins>+                $gravatar = get_avatar( $revision->post_author, 18 );
+                $author = get_the_author_meta( 'display_name', $revision->post_author );
+                $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
+                $revision_date_author = sprintf(
+                        '%s %s, %s %s (%s)',
+                        $gravatar,
+                        $author,
+                        human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ),
+                        __( ' ago ' ),
+                        $date
+                );
</ins><span class="cx">
</span><del>-                $args = array();
-
-                if ( 'true' == $showsplitview )
-                         $args = array( 'showsplitview' => 'true' );
-
-                $content .= wp_text_diff( $left_content, $right_content, $args );
-        }
-
-        //if we are comparing two revisions
-        //and we are on the matching revision
-        //add an error revision indicating unable to compare to self
-        if ( $comparetwomode && $compareto == $revision->ID )
-                $alltherevisions[] = array (
-                        'ID' => $revision->ID,
-                        'revision_date_author' => $revision_date_author,
-                        'revisiondiff' => sprintf('<div id="selfcomparisonerror">%s</div>', __( 'Cannot compare revision to itself' ) ),
-                        'restoreaction' => urldecode( $restoreaction ),
-                        'revision_from_date_author' => ''
</del><ins>+                $restoreaction = wp_nonce_url(
+                        add_query_arg(
+                                array( 'revision' => $revision->ID,
+                                        'action' => 'restore' ),
+                                        admin_url( 'revision.php' )
+                        ),
+                        "restore-post_{$compare_to}|{$revision->ID}"
</ins><span class="cx">                 );
</span><span class="cx">
</span><del>-        //add to the return data only if there is a difference
-        if ( '' != $content )
</del><span class="cx">                 $alltherevisions[] = array (
</span><del>-                        'ID' => $revision->ID,
-                        'revision_date_author' => $revision_date_author,
-                        'revisiondiff' => $content,
-                        'restoreaction' => urldecode( $restoreaction ),
-                        'revision_from_date_author' => $revision_from_date_author
-                );
</del><ins>+                                'ID' => $revision->ID,
+                                'revision_date_author' => $revision_date_author,
+                                'revision_from_date_author' => $revision_from_date_author,
+                                'restoreaction' => urldecode( $restoreaction ),
+                                'revision_toload' => true
+                        );
</ins><span class="cx">
</span><span class="cx">         endforeach;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpadminjsrevisionsjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/revisions.js (23638 => 23639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/revisions.js        2013-03-07 15:11:23 UTC (rev 23638)
+++ trunk/wp-admin/js/revisions.js        2013-03-07 15:32:26 UTC (rev 23639)
</span><span class="lines">@@ -6,16 +6,22 @@
</span><span class="cx">                 views : {},
</span><span class="cx">
</span><span class="cx">                 Model : Backbone.Model.extend({
</span><ins>+                        idAttribute : 'ID',
+                        urlRoot : ajaxurl +        '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id +
+                                '&show_autosaves=false&show_split_view=true&nonce=' + wpRevisionsSettings.nonce,
</ins><span class="cx">                         defaults: {
</span><span class="cx">                                 ID : 0,
</span><span class="cx">                                 revision_date_author : '',
</span><del>-                                revisiondiff : '',
-                                restoreaction: '',
-                                diff_max : 0,
-                                diff_count : 0,
-                                diff_revision_to : 0,
</del><ins>+                                revisiondiff : '<div class="diff-loading"><div class="spinner"></div></div>',
+                                restoreaction : '',
</ins><span class="cx">                                 revision_from_date_author : '',
</span><ins>+                                revision_toload : false
+                        },
+
+                        url : function() {
+                                return this.urlRoot + '&single_revision_id=' + this.id;
</ins><span class="cx">                         }
</span><ins>+
</ins><span class="cx">                 }),
</span><span class="cx">
</span><span class="cx">                 app: _.extend({}, Backbone.Events),
</span><span class="lines">@@ -30,42 +36,68 @@
</span><span class="cx">                         _left_diff : 0,
</span><span class="cx">                         _right_diff : 1,
</span><span class="cx">                         _autosaves : false,
</span><del>-                        _showsplitview : true,
</del><ins>+                        _show_split_view : true,
</ins><span class="cx">                         _compareoneortwo : 1,
</span><del>-                        left_model_loading : false,                //keep track of model loads
-                        right_model_loading : false,        //disallow slider interaction, also repeat loads, while loading
</del><ins>+                        _left_model_loading : false,        //keep track of model loads
+                        _right_model_loading : false,        //disallow slider interaction, also repeat loads, while loading
</ins><span class="cx">
</span><span class="cx">                         //TODO add ability to arrive on specific revision
</span><span class="cx">                         routes : {
</span><del>-                                "viewrevision/:revision": "viewrevision",
</del><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         viewrevision : function( revision ) {
</span><span class="cx">                                 //coming soon
</span><span class="cx">                         },
</span><span class="cx">
</span><ins>+                        reload_toload_revisions : function( model_collection, reverse_direction ) {
+                                var self = this;
+                                var revisions_to_load = model_collection.where( { revision_toload : true } );
+                                //console.log(revisions_to_load);
+                                var delay=0;
+                                _.each(revisions_to_load, function( the_model ) {
+                                                the_model.urlRoot = model_collection.url;
+                                                _.delay( function() {
+                                                        the_model.fetch( {
+                                                                update : true,
+                                                                add : false,
+                                                                remove : false,
+                                                                //async : false,
+                                                                success : function( model ) {
+                                                                        //console.log(model.get( 'ID' ) +'-'+self._revisions.at( self._right_diff ).get( 'ID' ));
+                                                                        if ( model.get( 'ID' ) === self._revisions.at( self._right_diff - 1 ).get( 'ID' ) ) { //reload if current model refreshed
+                                                                                //console.log('render');
+                                                                                self._revisionView.render();
+                                                                        }
+                                                                }
+                                                } );
+                                                }, delay ) ;
+                                                delay = delay + 200; //stagger model loads by 200 ms to avoid hammering server with requests
+                                        }
+                                );
+                        },
+
</ins><span class="cx">                         start_left_model_loading : function() {
</span><del>-                                this.left_model_loading = true;
</del><ins>+                                this._left_model_loading = true;
</ins><span class="cx">                                 $('.revisiondiffcontainer').addClass('leftmodelloading');
</span><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         stop_left_model_loading : function() {
</span><del>-                                this.left_model_loading = false;
</del><ins>+                                this._left_model_loading = false;
</ins><span class="cx">                                 $('.revisiondiffcontainer').removeClass('leftmodelloading');
</span><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         start_right_model_loading : function() {
</span><del>-                                this.right_model_loading = true;
</del><ins>+                                this._right_model_loading = true;
</ins><span class="cx">                                 $('.revisiondiffcontainer').addClass('rightmodelloading');
</span><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         stop_right_model_loading : function() {
</span><del>-                                this.right_model_loading = false;
</del><ins>+                                this._right_model_loading = false;
</ins><span class="cx">                                 $('.revisiondiffcontainer').removeClass('rightmodelloading');
</span><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         reloadmodel : function() {
</span><del>-                                if ( 2 == this._compareoneortwo ) {
</del><ins>+                                if ( 2 === this._compareoneortwo ) {
</ins><span class="cx">                                         this.reloadleftright();
</span><span class="cx">                                 } else {
</span><span class="cx">                                         this.reloadmodelsingle();
</span><span class="lines">@@ -74,9 +106,9 @@
</span><span class="cx">
</span><span class="cx">                         reloadmodelsingle : function() {
</span><span class="cx">                                 var self = this;
</span><del>-                                self._revisions.url = ajaxurl +        '?action=revisions-data&compareto=' + wpRevisionsSettings.post_id +
-                                                                                        '&showautosaves=' + self.self_autosaves +
-                                                                                        '&showsplitview=' + REVAPP._showsplitview +
</del><ins>+                                self._revisions.url = ajaxurl +        '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id +
+                                                                                        '&show_autosaves=' + self._autosaves +
+                                                                                        '&show_split_view=' + REVAPP._show_split_view +
</ins><span class="cx">                                                                                         '&nonce=' + wpRevisionsSettings.nonce;
</span><span class="cx">                                 self.start_right_model_loading();
</span><span class="cx">                                 this._revisions.fetch({ //reload revision data
</span><span class="lines">@@ -85,94 +117,91 @@
</span><span class="cx">                                                 var revisioncount = self._revisions.length;
</span><span class="cx">                                                 if ( self._right_diff > revisioncount ) //if right handle past rightmost, move
</span><span class="cx">                                                         self._right_diff = revisioncount;
</span><del>-                                                //TODO add a test for matchind left revision and push left, testing
-                                                //also reset the slider values here
</del><span class="cx">
</span><span class="cx">                                                 self._revisionView.render();
</span><del>-                                                $( '#slider' ).slider( 'option', 'max', revisioncount-1 ); //TODO test this
</del><ins>+                                                self.reload_toload_revisions( self._revisions );
+
+                                                $( '#slider' ).slider( 'option', 'max', revisioncount-1 ); //TODO test this, autsaves changed
</ins><span class="cx">                                         },
</span><span class="cx">
</span><span class="cx">                                         error : function () {
</span><span class="cx">                                                 self.stop_right_model_loading();
</span><del>-                                                window.console && console.log( 'Error loading revision data' );
</del><ins>+                                                //console.log( 'Error loading revision data' );
</ins><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                 });
</span><span class="cx">                         },
</span><span class="cx">
</span><del>-                        reloadleftright : function() {
</del><ins>+                        reloadleft : function() {
</ins><span class="cx">                                 var self = this;
</span><span class="cx">                                 self.start_left_model_loading();
</span><del>-                                self.start_right_model_loading();
-
</del><span class="cx">                                 self._left_handle_revisions = new wp.revisions.Collection();
</span><del>-                                self._right_handle_revisions = new wp.revisions.Collection();
-
-                                if ( 0 == self._left_diff ) {
-                                        self._right_handle_revisions.url =
-                                                ajaxurl +
-                                                '?action=revisions-data&compareto=' + wpRevisionsSettings.post_id +
-                                                '&post_id=' + wpRevisionsSettings.post_id +
-                                                '&showautosaves=' + self._autosaves +
-                                                '&showsplitview=' + self._showsplitview +
-                                                '&nonce=' + wpRevisionsSettings.nonce;
-                                } else {
-                                        self._right_handle_revisions.url =
-                                                ajaxurl +
-                                                '?action=revisions-data&compareto=' + self._revisions.at( self._left_diff - 1 ).get( 'ID' ) +
-                                                '&post_id=' + wpRevisionsSettings.post_id +
-                                                '&showautosaves=' + self._autosaves +
-                                                '&showsplitview=' + self._showsplitview +
-                                                '&nonce=' + wpRevisionsSettings.nonce;
-                                }
-
</del><span class="cx">                                 self._left_handle_revisions.url =
</span><span class="cx">                                         ajaxurl +
</span><del>-                                        '?action=revisions-data&compareto=' + self._revisions.at( self._right_diff - 1 ).get( 'ID' ) +
</del><ins>+                                        '?action=revisions-data&compare_to=' + self._revisions.at( self._right_diff - 1 ).get( 'ID' ) +
</ins><span class="cx">                                         '&post_id=' + wpRevisionsSettings.post_id +
</span><del>-                                        '&showautosaves=' + self._autosaves +
-                                        '&showsplitview=' + self._showsplitview +
-                                        '&nonce=' + wpRevisionsSettings.nonce;
</del><ins>+                                        '&show_autosaves=' + self._autosaves +
+                                        '&show_split_view=' + self._show_split_view +
+                                        '&nonce=' + wpRevisionsSettings.nonce +
+                                        '&right_handle_at=' + ( self._right_diff );
</ins><span class="cx">
</span><span class="cx">                                 self._left_handle_revisions.fetch({
</span><span class="cx">
</span><del>-                                        xhr: function() {
-                                                var xhr = $.ajaxSettings.xhr();
-                                                xhr.onprogress = self.handleProgress;
-                                                return xhr;
-                                        },
-
-                                        handleProgress: function(evt){
-                                                var percentComplete = 0;
-                                                if (evt.lengthComputable) {
-                                                        percentComplete = evt.loaded / evt.total;
-                                                        window.console && console.log( Math.round( percentComplete * 100) + "%" );
-                                                }
-                                        },
-
</del><span class="cx">                                         success : function(){
</span><span class="cx">                                                 self.stop_left_model_loading();
</span><ins>+                                                self.reload_toload_revisions( self._left_handle_revisions );
</ins><span class="cx">                                         },
</span><span class="cx">
</span><span class="cx">                                         error : function () {
</span><del>-                                                window.console && console.log( 'Error loading revision data' );
</del><ins>+                                                //console.log( 'Error loading revision data' );
</ins><span class="cx">                                                 self.stop_left_model_loading();
</span><span class="cx">                                         }
</span><span class="cx">                                 });
</span><ins>+                        },
</ins><span class="cx">
</span><ins>+                        reloadright : function() {
+                                var self = this;
+                                self.start_right_model_loading();
+                                self._right_handle_revisions = new wp.revisions.Collection();
+                                if ( 0 === self._left_diff ) {
+                                        self._right_handle_revisions.url =
+                                                ajaxurl +
+                                                '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id +
+                                                '&post_id=' + wpRevisionsSettings.post_id +
+                                                '&show_autosaves=' + self._autosaves +
+                                                '&show_split_view=' + self._show_split_view +
+                                                '&nonce=' + wpRevisionsSettings.nonce;
+                                } else {
+                                        self._right_handle_revisions.url =
+                                                ajaxurl +
+                                                '?action=revisions-data&compare_to=' + self._revisions.at( self._left_diff - 1 ).get( 'ID' ) +
+                                                '&post_id=' + wpRevisionsSettings.post_id +
+                                                '&show_autosaves=' + self._autosaves +
+                                                '&show_split_view=' + self._show_split_view +
+                                                '&nonce=' + wpRevisionsSettings.nonce +
+                                                '&left_handle_at=' + (self._left_diff ) ;
+                                }
+
</ins><span class="cx">                                 self._right_handle_revisions.fetch({
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         success : function(){
</span><span class="cx">                                                 self.stop_right_model_loading();
</span><ins>+                                                self.reload_toload_revisions( self._right_handle_revisions );
</ins><span class="cx">                                         },
</span><span class="cx">
</span><del>-                                        error : function () {
-                                                window.console && console.log( 'Error loading revision data' );
</del><ins>+                                        error : function ( response ) {
+                                                //console.log( 'Error loading revision data - ' + response.toSource() );
</ins><span class="cx">                                                 self.stop_right_model_loading();
</span><span class="cx">                                         }
</span><span class="cx">                                 });
</span><ins>+
</ins><span class="cx">                         },
</span><span class="cx">
</span><ins>+                        reloadleftright : function() {
+                                this.reloadleft();
+                                this.reloadright();
+                        },
+
</ins><span class="cx">                         /*
</span><span class="cx">                          * initialize the revision application
</span><span class="cx">                          */
</span><span class="lines">@@ -194,22 +223,27 @@
</span><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         revisionDiffSetup : function() {
</span><del>-                                var self = this, slider;
-
</del><span class="cx">                                 this._revisionView = new wp.revisions.views.View({
</span><span class="cx">                                         model : this._revisions
</span><span class="cx">                                 });
</span><span class="cx">                                 this._revisionView.render();
</span><ins>+                                $( '#diff_max, #diff_maxof' ).html( this._revisions.length );
+                                $( '#diff_count' ).html( REVAPP._right_diff );
+                                $( '#slider' ).slider( 'option', 'max', this._revisions.length - 1 );
</ins><span class="cx">
</span><ins>+                                this.reload_toload_revisions( this._revisions );
</ins><span class="cx">                                 this._revisionsInteractions = new wp.revisions.views.Interact({
</span><span class="cx">                                         model : this._revisions
</span><span class="cx">                                 });
</span><span class="cx">                                 this._revisionsInteractions.render();
</span><span class="cx">
</span><ins>+                                /*
+                                //Options hidden for now, moving to screen options
</ins><span class="cx">                                 this._revisionsOptions = new wp.revisions.views.Options({
</span><span class="cx">                                         model : this._revisions
</span><span class="cx">                                 });
</span><span class="cx">                                 this._revisionsOptions.render();
</span><ins>+                                */
</ins><span class="cx">
</span><span class="cx">                         }
</span><span class="cx">                 })
</span><span class="lines">@@ -217,9 +251,13 @@
</span><span class="cx">
</span><span class="cx">         wp.revisions.Collection = Backbone.Collection.extend({
</span><span class="cx">                 model : wp.revisions.Model,
</span><del>-                url : ajaxurl +        '?action=revisions-data&compareto=' + wpRevisionsSettings.post_id + '&showautosaves=false&showsplitview=true&nonce=' + wpRevisionsSettings.nonce
-        });
</del><ins>+                url : ajaxurl +        '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id +
+                        '&show_autosaves=false&show_split_view=true&nonce=' + wpRevisionsSettings.nonce,
</ins><span class="cx">
</span><ins>+                initialize : function() {
+                        }
+        } );
+
</ins><span class="cx">         _.extend(wp.revisions.views, {
</span><span class="cx">                 //
</span><span class="cx">                 //primary revision diff view
</span><span class="lines">@@ -242,7 +280,7 @@
</span><span class="cx">                         render : function() {
</span><span class="cx">                                 var addhtml = '';
</span><span class="cx">                                 //compare two revisions mode?
</span><del>-                                if ( 2 == REVAPP._compareoneortwo ) {
</del><ins>+                                if ( 2 === REVAPP._compareoneortwo ) {
</ins><span class="cx">                                         this.comparetwochecked = 'checked';
</span><span class="cx">                                         if ( this.draggingleft ) {
</span><span class="cx">                                                         if ( this.model.at( REVAPP._left_diff ) ) {
</span><span class="lines">@@ -260,16 +298,21 @@
</span><span class="cx">                                                         ) );
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                } else { //end compare two revisions mode, eg only one slider handel
</del><ins>+                                } else { //end compare two revisions mode, eg only one slider handle
</ins><span class="cx">                                         this.comparetwochecked = '';
</span><span class="cx">                                         if ( this.model.at( REVAPP._right_diff - 1 ) ) {
</span><span class="cx">                                                 addhtml = this.template( _.extend(
</span><del>-                                                        this.model.at( REVAPP._right_diff-1 ).toJSON(),
-                                                        { comparetwochecked : this.comparetwochecked } //keep the checkmark checked
</del><ins>+                                                        this.model.at( REVAPP._right_diff - 1 ).toJSON(),
+                                                        { comparetwochecked : this.comparetwochecked } //keep the checkmark unchecked
</ins><span class="cx">                                                 ) );
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                                 this.$el.html( addhtml );
</span><ins>+                                if ( this.model.length < 3 ) {
+                                        $( 'div#comparetworevisions' ).hide(); //don't allow compare two if fewer than three revisions
+
+                                }
+                                //console.log ( (this.model.at( REVAPP._right_diff - 1 )).url());
</ins><span class="cx">                                 return this;
</span><span class="cx">                         },
</span><span class="cx">
</span><span class="lines">@@ -322,7 +365,7 @@
</span><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         //
</span><del>-                        //toggle include autosaves
</del><ins>+                        //toggle include autosaves
</ins><span class="cx">                         //
</span><span class="cx">                         toggleshowautosaves : function() {
</span><span class="cx">                                 var self = this;
</span><span class="lines">@@ -331,11 +374,9 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         REVAPP._autosaves = false ;
</span><span class="cx">                                 }
</span><ins>+
</ins><span class="cx">                                 //refresh the model data
</span><del>-
</del><span class="cx">                                 REVAPP.reloadmodel();
</span><del>-                                //TODO check for two handle mode
-                                
</del><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         //
</span><span class="lines">@@ -345,10 +386,10 @@
</span><span class="cx">                                 var self = this;
</span><span class="cx">
</span><span class="cx">                                 if ( $( 'input#showsplitview' ).is( ':checked' ) ) {
</span><del>-                                        REVAPP._showsplitview = 'true';
</del><ins>+                                        REVAPP._show_split_view = 'true';
</ins><span class="cx">                                         $('.revisiondiffcontainer').addClass('diffsplit');
</span><span class="cx">                                 } else {
</span><del>-                                        REVAPP._showsplitview = '';
</del><ins>+                                        REVAPP._show_split_view = '';
</ins><span class="cx">                                         $('.revisiondiffcontainer').removeClass('diffsplit');
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -364,10 +405,16 @@
</span><span class="cx">                         tagName : 'revisionvinteract',
</span><span class="cx">                         className : 'revisionvinteract-container',
</span><span class="cx">                         template : wp.template('revisionvinteract'),
</span><ins>+                        _restoreword : '',
</ins><span class="cx">
</span><span class="cx">                         initialize : function() {
</span><ins>+                                this._restoreword = $( 'input#restore' ).attr( 'value' );
</ins><span class="cx">                         },
</span><span class="cx">
</span><ins>+                        reset_restore_button : function() {
+                                $( 'input#restore' ).attr( 'value', this._restoreword + ' ' + REVAPP._revisions.at( REVAPP._right_diff - 1 ).get( 'ID' ) );
+                        },
+
</ins><span class="cx">                         render : function() {
</span><span class="cx">                                 var self = this;
</span><span class="cx">
</span><span class="lines">@@ -375,12 +422,13 @@
</span><span class="cx">                                 this.$el.html( addhtml );
</span><span class="cx">                                 $( '#diff_max, #diff_maxof' ).html( this.model.length );
</span><span class="cx">                                 $( '#diff_count' ).html( REVAPP._right_diff );
</span><del>-                                $( '#diff_left_count_inner' ).html( 0 == REVAPP._left_diff ? '' : 'revision' + REVAPP._left_diff );
</del><ins>+                                $( '#diff_left_count_inner' ).html( 0 === REVAPP._left_diff ? '' : 'revision' + REVAPP._left_diff );
+                                self.reset_restore_button();
</ins><span class="cx">
</span><span class="cx">                                 var modelcount = REVAPP._revisions.length;
</span><span class="cx">
</span><del>-                                slider = $("#slider");
-                                if ( 1 == REVAPP._compareoneortwo ) {
</del><ins>+                                slider = $( "#slider" );
+                                if ( 1 === REVAPP._compareoneortwo ) {
</ins><span class="cx">                                         //set up the slider with a single handle
</span><span class="cx">                                         slider.slider({
</span><span class="cx">                                                 value : REVAPP._right_diff-1,
</span><span class="lines">@@ -390,12 +438,13 @@
</span><span class="cx">
</span><span class="cx">                                                 //slide interactions for one handles slider
</span><span class="cx">                                                 slide : function( event, ui ) {
</span><del>-                                                        if ( REVAPP.right_model_loading ) //left model stoll loading, prevent sliding left handle
</del><ins>+                                                        if ( REVAPP._right_model_loading ) //left model stoll loading, prevent sliding left handle
</ins><span class="cx">                                                                                 return false;
</span><span class="cx">
</span><span class="cx">                                                         REVAPP._right_diff =( ui.value+1 );
</span><span class="cx">                                                         $( '#diff_count' ).html( REVAPP._right_diff );
</span><span class="cx">                                                         REVAPP._revisionView.render();
</span><ins>+                                                        self.reset_restore_button();
</ins><span class="cx">                                                 }
</span><span class="cx">                                         });
</span><span class="cx">                                         $( '.revisiondiffcontainer' ).removeClass( 'comparetwo' );
</span><span class="lines">@@ -414,57 +463,58 @@
</span><span class="cx">
</span><span class="cx">                                                         switch ( index ) {
</span><span class="cx">                                                                 case 1: //left handle drag
</span><del>-                                                                        if ( REVAPP.left_model_loading ) //left model stoll loading, prevent sliding left handle
</del><ins>+                                                                        if ( REVAPP._left_model_loading ) //left model stoll loading, prevent sliding left handle
</ins><span class="cx">                                                                                 return false;
</span><span class="cx">
</span><span class="cx">                                                                         if ( REVAPP._revisionView.model !== REVAPP._left_handle_revisions &&
</span><del>-                                                                                        null != REVAPP._left_handle_revisions )
</del><ins>+                                                                                        null !== REVAPP._left_handle_revisions )
</ins><span class="cx">                                                                                 REVAPP._revisionView.model = REVAPP._left_handle_revisions;
</span><span class="cx">
</span><span class="cx">                                                                         REVAPP._revisionView.draggingleft = true;
</span><ins>+                                                                        REVAPP._left_diff_start = ui.values[ 0 ];
</ins><span class="cx">                                                                         break;
</span><span class="cx">
</span><span class="cx">                                                                 case 2: //right
</span><del>-                                                                        if ( REVAPP.right_model_loading ) //right model stoll loading, prevent sliding right handle
</del><ins>+                                                                        if ( REVAPP._right_model_loading ) //right model stoll loading, prevent sliding right handle
</ins><span class="cx">                                                                                 return false;
</span><span class="cx">
</span><span class="cx">                                                                         //one extra spot at left end when comparing two
</span><span class="cx">                                                                         if ( REVAPP._revisionView.model !== REVAPP._right_handle_revisions &&
</span><del>-                                                                                        null != REVAPP._right_handle_revisions )
</del><ins>+                                                                                        null !== REVAPP._right_handle_revisions )
</ins><span class="cx">                                                                                 REVAPP._revisionView.model = REVAPP._right_handle_revisions;
</span><span class="cx">
</span><span class="cx">                                                                         REVAPP._revisionView.draggingleft = false;
</span><del>-                                                                        REVAPP._right_diff = ui.values[1] - 1 ;
</del><ins>+                                                                        REVAPP._right_diff_start = ui.values[ 1 ];
</ins><span class="cx">                                                                         break;
</span><span class="cx">                                                         }
</span><span class="cx">                                                 },
</span><span class="cx">
</span><span class="cx">                                                 //when sliding in two handled mode change appropriate value
</span><span class="cx">                                                 slide : function( event, ui ) {
</span><del>-                                                        if ( ui.values[0] == ui.values[1] ) //prevent compare to self
</del><ins>+                                                        if ( ui.values[ 0 ] === ui.values[ 1 ] ) //prevent compare to self
</ins><span class="cx">                                                                 return false;
</span><span class="cx">
</span><span class="cx">                                                         var index = $( ui.handle ).index(); //0 (left) or 1 (right)
</span><span class="cx">
</span><span class="cx">                                                         switch ( index ) {
</span><span class="cx">                                                                 case 1: //left
</span><del>-                                                                        if ( REVAPP.left_model_loading ) //left model stoll loading, prevent sliding left handle
</del><ins>+                                                                        if ( REVAPP._left_model_loading ) //left model still loading, prevent sliding left handle
</ins><span class="cx">                                                                                 return false;
</span><span class="cx">
</span><del>-                                                                        REVAPP._left_diff = ui.values[0] - 1; //one extra spot at left end when comparing two
</del><ins>+                                                                        REVAPP._left_diff = ui.values[ 0 ] - 1; //one extra spot at left end when comparing two
</ins><span class="cx">                                                                         break;
</span><span class="cx">
</span><span class="cx">                                                                 case 2: //right
</span><del>-                                                                        if ( REVAPP.right_model_loading ) //right model stoll loading, prevent sliding right handle
</del><ins>+                                                                        if ( REVAPP._right_model_loading ) //right model still loading, prevent sliding right handle
</ins><span class="cx">                                                                                 return false;
</span><span class="cx">
</span><del>-                                                                        REVAPP._right_diff = ui.values[1] - 1 ;
</del><ins>+                                                                        REVAPP._right_diff = ui.values[ 1 ] - 1 ;
</ins><span class="cx">                                                                         break;
</span><span class="cx">                                                         }
</span><span class="cx">
</span><span class="cx">                                                         $( '#diff_count' ).html( REVAPP._right_diff );
</span><span class="cx">
</span><del>-                                                        if ( 0 == REVAPP._left_diff ) {
</del><ins>+                                                        if ( 0 === REVAPP._left_diff ) {
</ins><span class="cx">                                                                 $( '.revisiondiffcontainer' ).addClass( 'currentversion' );
</span><span class="cx">
</span><span class="cx">                                                         } else {
</span><span class="lines">@@ -473,15 +523,31 @@
</span><span class="cx">                                                         }
</span><span class="cx">
</span><span class="cx">                                                         REVAPP._revisionView.render(); //render the diff view
</span><ins>+                                                        self.reset_restore_button();
</ins><span class="cx">                                                 },
</span><span class="cx">
</span><span class="cx">                                                 //when the user stops sliding in 2 handle mode, recalculate diffs
</span><span class="cx">                                                 stop : function( event, ui ) {
</span><del>-                                                        if ( 2 == REVAPP._compareoneortwo ) {
</del><ins>+                                                        if ( 2 === REVAPP._compareoneortwo ) {
</ins><span class="cx">                                                                 //calculate and generate a diff for comparing to the left handle
</span><span class="cx">                                                                 //and the right handle, swap out when dragging
</span><del>-                                                                if ( ! (REVAPP.left_model_loading && REVAPP.right_model.loading ) ) {
-                                                                        REVAPP.reloadleftright();
</del><ins>+
+                                                                var index = $( ui.handle ).index(); //0 (left) or 1 (right)
+
+                                                                switch ( index ) {
+                                                                        case 1: //left
+                                                                                //left handle dragged & changed, reload right handle model
+                                                                                if ( ! ( REVAPP._left_diff_start === ui.values[ 0 ] || REVAPP._left_model_loading ) )
+                                                                                        REVAPP.reloadright();
+
+                                                                                break;
+
+                                                                        case 2: //right
+                                                                                //right handle dragged & changed, reload left handle model if changed
+                                                                                if ( ! ( REVAPP._right_diff_start === ui.values[ 1 ] || REVAPP._right_model_loading ) ) {
+                                                                                        REVAPP.reloadleft();
+                                                                                }
+                                                                                break;
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><span class="lines">@@ -507,6 +573,7 @@
</span><span class="cx">
</span><span class="cx">                                 $( '#diff_count' ).html( REVAPP._right_diff );
</span><span class="cx">                                 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' );
</span><ins>+                                this.reset_restore_button();
</ins><span class="cx">                         },
</span><span class="cx">
</span><span class="cx">                         //go the the previous revision
</span><span class="lines">@@ -518,6 +585,7 @@
</span><span class="cx">
</span><span class="cx">                                 $( '#diff_count' ).html( REVAPP._right_diff );
</span><span class="cx">                                 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' );
</span><ins>+                                this.reset_restore_button();
</ins><span class="cx">                         }
</span><span class="cx">                 })
</span><span class="cx">         });
</span><span class="lines">@@ -525,6 +593,6 @@
</span><span class="cx">         //instantiate Revision Application
</span><span class="cx">         REVAPP = new wp.revisions.App();
</span><span class="cx">         //TODO consider enable back button to step back thru states?
</span><del>-        Backbone.history.start();
</del><ins>+        //Backbone.history.start({pushState: true});
</ins><span class="cx">
</span><span class="cx"> }(jQuery));
</span></span></pre></div>
<a id="trunkwpadminrevisionphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/revision.php (23638 => 23639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/revision.php        2013-03-07 15:11:23 UTC (rev 23638)
+++ trunk/wp-admin/revision.php        2013-03-07 15:32:26 UTC (rev 23639)
</span><span class="lines">@@ -10,37 +10,45 @@
</span><span class="cx"> require_once('./admin.php');
</span><span class="cx"> wp_reset_vars( array( 'revision', 'action' ) );
</span><span class="cx">
</span><del>-$revision_id = absint($revision);
</del><ins>+$revision_id = absint( $revision );
</ins><span class="cx"> $redirect = 'edit.php';
</span><span class="cx">
</span><span class="cx"> switch ( $action ) :
</span><span class="cx"> case 'restore' :
</span><del>-        if ( !$revision = wp_get_post_revision( $revision_id ) )
</del><ins>+        if ( ! $revision = wp_get_post_revision( $revision_id ) )
</ins><span class="cx">                 break;
</span><del>-        if ( !current_user_can( 'edit_post', $revision->post_parent ) )
</del><ins>+        if ( ! current_user_can( 'edit_post', $revision->post_parent ) )
</ins><span class="cx">                 break;
</span><del>-        if ( !$post = get_post( $revision->post_parent ) )
</del><ins>+        if ( ! $post = get_post( $revision->post_parent ) )
</ins><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">         // Revisions disabled and we're not looking at an autosave
</span><del>-        if ( ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) && !wp_is_post_autosave( $revision ) ) {
</del><ins>+        if ( ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions' ) ) && ! wp_is_post_autosave( $revision ) ) {
</ins><span class="cx">                 $redirect = 'edit.php?post_type=' . $post->post_type;
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">         check_admin_referer( "restore-post_{$post->ID}|{$revision->ID}" );
</span><span class="cx">
</span><ins>+        //store revision event in post meta
+        $restore_details = array(
+                'restored_revision_id' => $revision->ID,
+                'restored_by_user' => get_current_user_id(),
+                'restored_time' => time()
+        );
+        update_post_meta( $post->ID, '_post_restored_from', $restore_details );
+
</ins><span class="cx">         wp_restore_post_revision( $revision->ID );
</span><span class="cx">         $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) );
</span><span class="cx">         break;
</span><span class="cx"> case 'view' :
</span><span class="cx"> case 'edit' :
</span><span class="cx"> default :
</span><del>-        if ( !$revision = wp_get_post_revision( $revision_id ) )
</del><ins>+        if ( ! $revision = wp_get_post_revision( $revision_id ) )
</ins><span class="cx">                 break;
</span><del>-        if ( !$post = get_post( $revision->post_parent ) )
</del><ins>+        if ( ! $post = get_post( $revision->post_parent ) )
</ins><span class="cx">                 break;
</span><span class="cx">
</span><del>-        if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) )
</del><ins>+        if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'read_post', $post->ID ) )
</ins><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">         // Revisions disabled and we're not looking at an autosave
</span><span class="lines">@@ -59,16 +67,16 @@
</span><span class="cx"> endswitch;
</span><span class="cx">
</span><span class="cx"> // Empty post_type means either malformed object found, or no valid parent was found.
</span><del>-if ( !$redirect && empty($post->post_type) )
</del><ins>+if ( ! $redirect && empty( $post->post_type ) )
</ins><span class="cx">         $redirect = 'edit.php';
</span><span class="cx">
</span><del>-if ( !empty($redirect) ) {
</del><ins>+if ( ! empty( $redirect ) ) {
</ins><span class="cx">         wp_redirect( $redirect );
</span><span class="cx">         exit;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // This is so that the correct "Edit" menu item is selected.
</span><del>-if ( !empty($post->post_type) && 'post' != $post->post_type )
</del><ins>+if ( ! empty( $post->post_type ) && 'post' != $post->post_type )
</ins><span class="cx">         $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type;
</span><span class="cx"> else
</span><span class="cx">         $parent_file = $submenu_file = 'edit.php';
</span><span class="lines">@@ -83,10 +91,11 @@
</span><span class="cx"> <script type="text/javascript">
</span><span class="cx"> var wpRevisionsSettings = <?php echo json_encode( array( 'post_id' => $post->ID, 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ) ) ); ?>;
</span><span class="cx"> </script>
</span><ins>+<?php
+        $comparetworevisionslink = get_edit_post_link( $revision->ID );
+?>
</ins><span class="cx">
</span><span class="cx"> <div id="backbonerevisionsoptions"></div>
</span><del>-
-<br class="clear"/>
</del><span class="cx"> <div class="wrap">
</span><span class="cx">         <div class="icon32 icon32-posts-post" id="icon-edit"><br></div>
</span><span class="cx">         <div class="revisiondiffcontainer diffsplit currentversion rightmodelloading">
</span><span class="lines">@@ -94,10 +103,7 @@
</span><span class="cx">                 <h2 class="long-header"><?php echo $h2; ?></h2>
</span><span class="cx">                 <div id="backbonerevisionsinteract"></div>
</span><span class="cx">                 <div id="backbonerevisionsdiff"></div>
</span><del>-<hr />
-<?php
-        $comparetworevisionslink = get_edit_post_link( $revision->ID );
-?>
</del><ins>+                <hr />
</ins><span class="cx">         </div>
</span><span class="cx"> </div>
</span><span class="cx">
</span><span class="lines">@@ -107,9 +113,8 @@
</span><span class="cx">                 <div id="difftitlefrom">{{{ data.revision_from_date_author }}} <?php _e( '- compared to -' ); ?></div>
</span><span class="cx">                 <div id="difftitle">{{{ data.revision_date_author }}}</div>
</span><span class="cx">                 <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>
</span><del>-                <div id="diffrestore"><input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore' )?>" /></div>
-                <div id="comparetworevisions"><input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> <?php esc_attr_e( 'Compare two revisions' )?></div>
-        </div>
</del><ins>+                <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>
+                <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>
</ins><span class="cx">         <div id="removedandadded">
</span><span class="cx">                 <div id="removed"><?php _e( 'Removed -' ); ?></div>
</span><span class="cx">                 <div id="added"><?php _e( 'Added +' ); ?></div>
</span><span class="lines">@@ -119,8 +124,8 @@
</span><span class="cx">
</span><span class="cx"> <script id="tmpl-revisionvinteract" type="text/html">
</span><span class="cx">         <div id="diffheader">
</span><del>-<div id="diffprevious"><input class="button" type="submit" id="previous" value="Previous" /></div>
-                        <div id="diffnext"><input class="button" type="submit" id="next" value="Next" /></div>
</del><ins>+<div id="diffprevious"><input class="button" type="submit" id="previous" value="<?php esc_attr_e( 'Previous' ); ?>" /></div>
+                        <div id="diffnext"><input class="button" type="submit" id="next" value="<?php esc_attr_e( 'Next' ); ?>" /></div>
</ins><span class="cx">                         <div id="diffslider">
</span><span class="cx">         <div id="revisioncount">
</span><span class="cx">                                         <?php _e( 'Comparing' ); ?>
</span></span></pre></div>
<a id="trunkwpincludespluggablephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/pluggable.php (23638 => 23639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/pluggable.php        2013-03-07 15:11:23 UTC (rev 23638)
+++ trunk/wp-includes/pluggable.php        2013-03-07 15:32:26 UTC (rev 23639)
</span><span class="lines">@@ -1719,7 +1719,7 @@
</span><span class="cx">
</span><span class="cx">         $r = "<table class='diff'>\n";
</span><span class="cx">
</span><del>-        if ( isset( $args[ 'showsplitview' ] ) && 'true' == $args[ 'showsplitview' ] ) {
</del><ins>+        if ( ! empty( $args[ 'show_split_view' ] ) ) {
</ins><span class="cx">                 $r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />";
</span><span class="cx">         } else {
</span><span class="cx">                 $r .= "<col class='content' />";
</span></span></pre></div>
<a id="trunkwpincludesposttemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/post-template.php (23638 => 23639)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/post-template.php        2013-03-07 15:11:23 UTC (rev 23638)
+++ trunk/wp-includes/post-template.php        2013-03-07 15:32:26 UTC (rev 23639)
</span><span class="lines">@@ -1468,7 +1468,32 @@
</span><span class="cx">         else :
</span><span class="cx">                 echo "<ul class='post-revisions'>\n";
</span><span class="cx">                 echo $rows;
</span><ins>+
+                //
+                // if the post was previously restored from a revision
+                // show the restore event details
+                //
+                if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) {
+                        $author = get_the_author_meta( 'display_name', $restored_from_meta[ 'restored_by_user' ] );
+                        /* translators: revision date format, see http://php.net/date */
+                        $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
+                        $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) );
+                        $timesince = human_time_diff( $restored_from_meta[ 'restored_time' ], current_time( 'timestamp' ) ) . __( ' ago ' );
+                        ?>
+                        <hr />
+                        <div id="revisions-meta-restored">
+                                <?php
+                                printf( 'Previously restored from Revision ID %d, %s by %s (%s)',
+                                $restored_from_meta[ 'restored_revision_id'],
+                                $timesince,
+                                $author,
+                                $date );
+                                ?>
+                        </div>
+                        <?php
</ins><span class="cx">                 echo "</ul>";
</span><ins>+                }
+
</ins><span class="cx">         endif;
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre>
</div>
</div>
</body>
</html>