Ticket #23497: 23497.15.diff
File 23497.15.diff, 24.6 KB (added by , 12 years ago) |
---|
-
wp-includes/post-template.php
1468 1468 else : 1469 1469 echo "<ul class='post-revisions'>\n"; 1470 1470 echo $rows; 1471 if ( $restored_from_meta = get_post_meta( $post->ID, '_post_restored_from', true ) ) { 1472 $author = get_the_author_meta( 'display_name', $restored_from_meta[ 'restored_by_user' ] ); 1473 /* translators: revision date format, see http://php.net/date */ 1474 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 1475 $date = date_i18n( $datef, strtotime( $restored_from_meta[ 'restored_time' ] ) ); 1476 $timesince = human_time_diff( $restored_from_meta[ 'restored_time' ], current_time( 'timestamp' ) ) . __( ' ago ' ); 1477 ?> 1478 <hr /> 1479 <div id="revisions-meta-restored"> 1480 <?php 1481 printf( 'Previously restored from Revision ID %d, %s by %s (%s)', 1482 $restored_from_meta[ 'restored_revision_id'], 1483 $timesince, 1484 $author, 1485 $date ); 1486 ?> 1487 </div> 1488 <?php 1471 1489 echo "</ul>"; 1490 } 1491 1472 1492 endif; 1473 1493 1474 1494 } -
wp-includes/pluggable.php
1722 1722 1723 1723 $r = "<table class='diff'>\n"; 1724 1724 1725 if ( isset( $args[ 'showsplitview' ] ) && 'true' == $args[ 'showsplitview' ]) {1725 if ( ! empty( $args[ 'show_split_view' ] ) ) { 1726 1726 $r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />"; 1727 1727 } else { 1728 1728 $r .= "<col class='content' />"; -
wp-admin/includes/ajax-actions.php
2131 2131 function wp_ajax_revisions_data() { 2132 2132 check_ajax_referer( 'revisions-ajax-nonce', 'nonce' ); 2133 2133 2134 $compareto = isset( $_GET['compareto'] ) ? absint( $_GET['compareto'] ) : 0; 2135 $showautosaves = isset( $_GET['showautosaves'] ) ? $_GET['showautosaves'] : ''; 2136 $showsplitview = isset( $_GET['showsplitview'] ) ? $_GET['showsplitview'] : ''; 2137 $postid = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : ''; 2134 $compare_to = isset( $_GET['compare_to'] ) ? absint( $_GET['compare_to'] ) : 0; 2135 $show_autosaves = isset( $_GET['show_autosaves'] ) ? $_GET['show_autosaves'] : ''; 2136 $show_split_view = isset( $_GET['show_split_view'] ) ? $_GET['show_split_view'] : ''; 2137 $post_id = isset( $_GET['post_id'] ) ? absint( $_GET['post_id'] ) : ''; 2138 $right_handle_at = isset( $_GET['right_handle_at'] ) ? $_GET['right_handle_at'] : 0; 2139 $left_handle_at = isset( $_GET['left_handle_at'] ) ? $_GET['left_handle_at'] : 0; 2138 2140 2139 $compare twomode = ( '' == $postid ) ? false : true;2141 $compare_two_mode = ( '' == $post_id ) ? false : true; 2140 2142 // 2141 //TODO: currently code returns all possible comparisons for the indicated 'compare to' revision2143 //TODO: currently code returns all possible comparisons for the indicated 'compare_to' revision 2142 2144 //however, the front end prevents users from pulling the right handle past the left or the left pass the right, 2143 2145 //so only the possible diffs need be generated 2144 2146 // 2145 2147 $alltherevisions = array(); 2146 if ( '' == $post id )2147 $post id = $compareto;2148 if ( '' == $post_id ) 2149 $post_id = $compare_to; 2148 2150 2149 if ( ! current_user_can( 'read_post', $post id ) )2151 if ( ! current_user_can( 'read_post', $post_id ) ) 2150 2152 continue; 2151 2153 2152 if ( ! $revisions = wp_get_post_revisions( $post id ) )2154 if ( ! $revisions = wp_get_post_revisions( $post_id ) ) 2153 2155 return; 2154 2156 2155 2157 2156 2158 //if we are comparing two revisions, the first 'revision' represented by the leftmost 2157 2159 //slider position is the current revision, prepend a comparison to this revision 2158 if ( $compare twomode )2159 array_unshift( $revisions, get_post( $post id ) );2160 if ( $compare_two_mode ) 2161 array_unshift( $revisions, get_post( $post_id ) ); 2160 2162 2161 $count = 1;2163 $count = -1; 2162 2164 foreach ( $revisions as $revision ) : 2163 if ( 'true' != $showautosaves && wp_is_post_autosave( $revision ) ) 2165 if ( ! empty( $show_autosaves ) && wp_is_post_autosave( $revision ) ) 2166 continue; 2167 2168 $revision_from_date_author = ''; 2169 $count++; 2170 // return blank data for diffs to the left of the left handle (for right handel model) 2171 // or to the right of the right handle (for left handel model) 2172 if ( ( 0 != $left_handle_at && $count <= $left_handle_at ) || 2173 ( 0 != $right_handle_at && $count > $right_handle_at )) { 2174 $alltherevisions[] = array ( 2175 'ID' => $revision->ID, 2176 'revision_date_author' => '', 2177 'revisiondiff' => '', 2178 'restoreaction' => '', 2179 'revision_from_date_author' => '' 2180 ); 2181 2164 2182 continue; 2183 } 2184 2165 2185 2166 $revision_from_date_author = ''; 2186 $left_revision = get_post( $compare_to ); 2187 $right_revision = get_post( $revision ); 2167 2188 2189 $author = get_the_author_meta( 'display_name', $revision->post_author ); 2190 /* translators: revision date format, see http://php.net/date */ 2191 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 2168 2192 2169 $left_revision = get_post( $compareto ); 2170 $right_revision = get_post( $revision ); 2193 $gravatar = get_avatar( $revision->post_author, 18 ); 2171 2194 2172 $author = get_the_author_meta( 'display_name', $revision->post_author ); 2173 /* translators: revision date format, see http://php.net/date */ 2174 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 2195 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 2196 $revision_date_author = sprintf( 2197 '%s %s, %s %s (%s)', 2198 $gravatar, 2199 $author, 2200 human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ), 2201 __( ' ago ' ), 2202 $date 2203 ); 2175 2204 2176 $gravatar = get_avatar( $revision->post_author, 18 ); 2205 if ( $compare_two_mode ) { 2206 $compare_to_gravatar = get_avatar( $left_revision->post_author, 18 ); 2207 $compare_to_author = get_the_author_meta( 'display_name', $left_revision->post_author ); 2208 $compare_to_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) ); 2177 2209 2178 $date = date_i18n( $datef, strtotime( $revision->post_modified ) );2179 $revision_date_author = sprintf(2180 '%s %s, %s %s (%s)',2181 $gravatar,2182 $author,2183 human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' )),2184 __( ' ago ' ),2185 $date2186 );2210 $revision_from_date_author = sprintf( 2211 '%s %s, %s %s (%s)', 2212 $compare_to_gravatar, 2213 $compare_to_author, 2214 human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ), 2215 __( ' ago ' ), 2216 $compare_to_date 2217 ); 2218 } 2187 2219 2188 if ( $comparetwomode ) { 2189 $compareto_gravatar = get_avatar( $left_revision->post_author, 18 ); 2190 $compareto_author = get_the_author_meta( 'display_name', $left_revision->post_author ); 2191 $compareto_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) ); 2192 2193 $revision_from_date_author = sprintf( 2194 '%s %s, %s %s (%s)', 2195 $compareto_gravatar, 2196 $compareto_author, 2197 human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ), 2198 __( ' ago ' ), 2199 $compareto_date 2220 $restoreaction = wp_nonce_url( 2221 add_query_arg( 2222 array( 'revision' => $revision->ID, 2223 'action' => 'restore' ), 2224 '/wp-admin/revision.php' 2225 ), 2226 "restore-post_{$compare_to}|{$revision->ID}" 2200 2227 ); 2201 }2202 2228 2203 $restoreaction = wp_nonce_url(2204 add_query_arg(2205 array( 'revision' => $revision->ID,2206 'action' => 'restore' ),2207 '/wp-admin/revision.php'2208 ),2209 "restore-post_{$compareto}|{$revision->ID}"2210 );2229 // 2230 //make sure the left revision is the most recent 2231 // 2232 if ( strtotime( $right_revision->post_modified_gmt ) < strtotime( $left_revision->post_modified_gmt ) ) { 2233 $temp = $left_revision; 2234 $left_revision = $right_revision; 2235 $right_revision = $temp; 2236 } 2211 2237 2212 // 2213 //make sure the left revision is the most recent 2214 // 2215 if ( strtotime( $right_revision->post_modified_gmt ) < strtotime( $left_revision->post_modified_gmt ) ) { 2216 $temp = $left_revision; 2217 $left_revision = $right_revision; 2218 $right_revision = $temp; 2219 } 2238 // 2239 //compare from left to right, passed from application 2240 // 2241 $content=''; 2242 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 2243 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' ); 2244 $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' ); 2220 2245 2221 // 2222 //compare from left to right, passed from application 2223 // 2224 $content=''; 2225 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 2226 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' ); 2227 $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' ); 2246 add_filter( "_wp_post_revision_field_$field", 'wp_kses_post' ); 2228 2247 2229 add_filter( "_wp_post_revision_field_$field", 'wp_kses_post');2248 $args = array(); 2230 2249 2231 $args = array(); 2250 if ( ! empty( $show_split_view ) ) 2251 $args = array( 'show_split_view' => true ); 2232 2252 2233 if ( 'true' == $showsplitview )2234 $args = array( 'showsplitview' => 'true' );2253 $content .= wp_text_diff( $left_content, $right_content, $args ); 2254 } 2235 2255 2236 $content .= wp_text_diff( $left_content, $right_content, $args ); 2237 } 2256 //if we are comparing two revisions 2257 //and we are on the matching revision 2258 //add an error revision indicating unable to compare to self 2259 if ( $compare_two_mode && $compare_to == $revision->ID ) 2260 $alltherevisions[] = array ( 2261 'ID' => $revision->ID, 2262 'revision_date_author' => $revision_date_author, 2263 'revisiondiff' => sprintf('<div id="selfcomparisonerror">%s</div>', __( 'Cannot compare revision to itself' ) ), 2264 'restoreaction' => urldecode( $restoreaction ), 2265 'revision_from_date_author' => '' 2266 ); 2238 2267 2239 //if we are comparing two revisions 2240 //and we are on the matching revision 2241 //add an error revision indicating unable to compare to self 2242 if ( $comparetwomode && $compareto == $revision->ID ) 2243 $alltherevisions[] = array ( 2244 'ID' => $revision->ID, 2245 'revision_date_author' => $revision_date_author, 2246 'revisiondiff' => sprintf('<div id="selfcomparisonerror">%s</div>', __( 'Cannot compare revision to itself' ) ), 2247 'restoreaction' => urldecode( $restoreaction ), 2248 'revision_from_date_author' => '' 2249 ); 2268 //add to the return data only if there is a difference 2269 if ( '' != $content ) 2270 $alltherevisions[] = array ( 2271 'ID' => $revision->ID, 2272 'revision_date_author' => $revision_date_author, 2273 'revisiondiff' => $content, 2274 'restoreaction' => urldecode( $restoreaction ), 2275 'revision_from_date_author' => $revision_from_date_author 2276 ); 2250 2277 2251 //add to the return data only if there is a difference2252 if ( '' != $content )2253 $alltherevisions[] = array (2254 'ID' => $revision->ID,2255 'revision_date_author' => $revision_date_author,2256 'revisiondiff' => $content,2257 'restoreaction' => urldecode( $restoreaction ),2258 'revision_from_date_author' => $revision_from_date_author2259 );2260 2261 2278 endforeach; 2262 2279 2263 2280 echo json_encode( $alltherevisions ); -
wp-admin/js/revisions.js
30 30 _left_diff : 0, 31 31 _right_diff : 1, 32 32 _autosaves : false, 33 _show splitview : true,33 _show_split_view : true, 34 34 _compareoneortwo : 1, 35 35 left_model_loading : false, //keep track of model loads 36 36 right_model_loading : false, //disallow slider interaction, also repeat loads, while loading … … 74 74 75 75 reloadmodelsingle : function() { 76 76 var self = this; 77 self._revisions.url = ajaxurl + '?action=revisions-data&compare to=' + wpRevisionsSettings.post_id +78 '&show autosaves=' + self.self_autosaves +79 '&show splitview=' + REVAPP._showsplitview +77 self._revisions.url = ajaxurl + '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id + 78 '&show_autosaves=' + self._autosaves + 79 '&show_split_view=' + REVAPP._show_split_view + 80 80 '&nonce=' + wpRevisionsSettings.nonce; 81 81 self.start_right_model_loading(); 82 82 this._revisions.fetch({ //reload revision data … … 108 108 self._left_handle_revisions = new wp.revisions.Collection(); 109 109 self._right_handle_revisions = new wp.revisions.Collection(); 110 110 111 if ( 0 == self._left_diff ) { 111 if ( 0 == self._left_diff ) { 112 112 self._right_handle_revisions.url = 113 113 ajaxurl + 114 '?action=revisions-data&compare to=' + wpRevisionsSettings.post_id +114 '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id + 115 115 '&post_id=' + wpRevisionsSettings.post_id + 116 '&show autosaves=' + self._autosaves +117 '&show splitview=' + self._showsplitview +116 '&show_autosaves=' + self._autosaves + 117 '&show_split_view=' + self._show_split_view + 118 118 '&nonce=' + wpRevisionsSettings.nonce; 119 119 } else { 120 120 self._right_handle_revisions.url = 121 121 ajaxurl + 122 '?action=revisions-data&compare to=' + self._revisions.at( self._left_diff - 1 ).get( 'ID' ) +122 '?action=revisions-data&compare_to=' + self._revisions.at( self._left_diff - 1 ).get( 'ID' ) + 123 123 '&post_id=' + wpRevisionsSettings.post_id + 124 '&showautosaves=' + self._autosaves + 125 '&showsplitview=' + self._showsplitview + 126 '&nonce=' + wpRevisionsSettings.nonce; 124 '&show_autosaves=' + self._autosaves + 125 '&show_split_view=' + self._show_split_view + 126 '&nonce=' + wpRevisionsSettings.nonce + 127 '&left_handle_at=' + (self._left_diff ) ; 127 128 } 128 129 129 130 self._left_handle_revisions.url = 130 131 ajaxurl + 131 '?action=revisions-data&compare to=' + self._revisions.at( self._right_diff - 1 ).get( 'ID' ) +132 '?action=revisions-data&compare_to=' + self._revisions.at( self._right_diff - 1 ).get( 'ID' ) + 132 133 '&post_id=' + wpRevisionsSettings.post_id + 133 '&showautosaves=' + self._autosaves + 134 '&showsplitview=' + self._showsplitview + 135 '&nonce=' + wpRevisionsSettings.nonce; 134 '&show_autosaves=' + self._autosaves + 135 '&show_split_view=' + self._show_split_view + 136 '&nonce=' + wpRevisionsSettings.nonce + 137 '&right_handle_at=' + (self._right_diff - 1); 138 //console.log (self._left_handle_revisions.url); 136 139 137 140 self._left_handle_revisions.fetch({ 138 141 142 /* 143 //TODO - add a load progress bar for fetch 144 // 139 145 xhr: function() { 140 146 var xhr = $.ajaxSettings.xhr(); 141 147 xhr.onprogress = self.handleProgress; … … 149 155 window.console && console.log( Math.round( percentComplete * 100) + "%" ); 150 156 } 151 157 }, 152 158 */ 153 159 success : function(){ 154 160 self.stop_left_model_loading(); 155 161 }, … … 166 172 self.stop_right_model_loading(); 167 173 }, 168 174 169 error : function ( ) {170 window.console && console.log( 'Error loading revision data ');175 error : function ( response ) { 176 window.console && console.log( 'Error loading revision data - ' + response.toSource() ); 171 177 self.stop_right_model_loading(); 172 178 } 173 179 }); … … 195 201 196 202 revisionDiffSetup : function() { 197 203 var self = this, slider; 198 199 204 this._revisionView = new wp.revisions.views.View({ 200 205 model : this._revisions 201 206 }); … … 206 211 }); 207 212 this._revisionsInteractions.render(); 208 213 214 /* 215 //Options hidden for now, moving to screen options 209 216 this._revisionsOptions = new wp.revisions.views.Options({ 210 217 model : this._revisions 211 218 }); 212 219 this._revisionsOptions.render(); 220 */ 213 221 214 222 } 215 223 }) … … 217 225 218 226 wp.revisions.Collection = Backbone.Collection.extend({ 219 227 model : wp.revisions.Model, 220 url : ajaxurl + '?action=revisions-data&compareto=' + wpRevisionsSettings.post_id + '&showautosaves=false&showsplitview=true&nonce=' + wpRevisionsSettings.nonce 228 url : ajaxurl + '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id + 229 '&show_autosaves=false&show_split_view=true&nonce=' + wpRevisionsSettings.nonce 221 230 }); 222 231 223 232 _.extend(wp.revisions.views, { … … 260 269 ) ); 261 270 } 262 271 } 263 } else { //end compare two revisions mode, eg only one slider hand el272 } else { //end compare two revisions mode, eg only one slider handle 264 273 this.comparetwochecked = ''; 265 274 if ( this.model.at( REVAPP._right_diff - 1 ) ) { 266 275 addhtml = this.template( _.extend( 267 this.model.at( REVAPP._right_diff -1 ).toJSON(),268 { comparetwochecked : this.comparetwochecked } //keep the checkmark checked276 this.model.at( REVAPP._right_diff - 1 ).toJSON(), 277 { comparetwochecked : this.comparetwochecked } //keep the checkmark unchecked 269 278 ) ); 270 279 } 271 280 } … … 345 354 var self = this; 346 355 347 356 if ( $( 'input#showsplitview' ).is( ':checked' ) ) { 348 REVAPP._show splitview = 'true';357 REVAPP._show_split_view = 'true'; 349 358 $('.revisiondiffcontainer').addClass('diffsplit'); 350 359 } else { 351 REVAPP._show splitview = '';360 REVAPP._show_split_view = ''; 352 361 $('.revisiondiffcontainer').removeClass('diffsplit'); 353 362 } 354 363 … … 364 373 tagName : 'revisionvinteract', 365 374 className : 'revisionvinteract-container', 366 375 template : wp.template('revisionvinteract'), 376 _restoreword : '', 367 377 368 378 initialize : function() { 379 this._restoreword = $( 'input#restore' ).attr( 'value' ); 369 380 }, 370 381 382 reset_restore_button : function() { 383 $( 'input#restore' ).attr( 'value', this._restoreword + ' ' + REVAPP._revisions.at( REVAPP._right_diff - 1 ).get( 'ID' ) ); 384 }, 385 371 386 render : function() { 372 387 var self = this; 373 388 … … 376 391 $( '#diff_max, #diff_maxof' ).html( this.model.length ); 377 392 $( '#diff_count' ).html( REVAPP._right_diff ); 378 393 $( '#diff_left_count_inner' ).html( 0 == REVAPP._left_diff ? '' : 'revision' + REVAPP._left_diff ); 394 self.reset_restore_button(); 379 395 380 396 var modelcount = REVAPP._revisions.length; 381 397 382 slider = $( "#slider");398 slider = $( "#slider" ); 383 399 if ( 1 == REVAPP._compareoneortwo ) { 384 400 //set up the slider with a single handle 385 401 slider.slider({ … … 396 412 REVAPP._right_diff =( ui.value+1 ); 397 413 $( '#diff_count' ).html( REVAPP._right_diff ); 398 414 REVAPP._revisionView.render(); 415 self.reset_restore_button(); 399 416 } 400 417 }); 401 418 $( '.revisiondiffcontainer' ).removeClass( 'comparetwo' ); … … 473 490 } 474 491 475 492 REVAPP._revisionView.render(); //render the diff view 493 self.reset_restore_button(); 476 494 }, 477 495 478 496 //when the user stops sliding in 2 handle mode, recalculate diffs … … 480 498 if ( 2 == REVAPP._compareoneortwo ) { 481 499 //calculate and generate a diff for comparing to the left handle 482 500 //and the right handle, swap out when dragging 483 if ( ! ( REVAPP.left_model_loading && REVAPP.right_model.loading ) ) {501 if ( ! ( REVAPP.left_model_loading && REVAPP.right_model_loading ) ) { 484 502 REVAPP.reloadleftright(); 485 503 } 486 504 } … … 507 525 508 526 $( '#diff_count' ).html( REVAPP._right_diff ); 509 527 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' ); 528 this.reset_restore_button(); 510 529 }, 511 530 512 531 //go the the previous revision … … 518 537 519 538 $( '#diff_count' ).html( REVAPP._right_diff ); 520 539 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' ); 540 this.reset_restore_button(); 521 541 } 522 542 }) 523 543 }); -
wp-admin/revision.php
10 10 require_once('./admin.php'); 11 11 wp_reset_vars( array( 'revision', 'action' ) ); 12 12 13 $revision_id = absint( $revision);13 $revision_id = absint( $revision ); 14 14 $redirect = 'edit.php'; 15 15 16 16 switch ( $action ) : 17 17 case 'restore' : 18 if ( ! $revision = wp_get_post_revision( $revision_id ) )18 if ( ! $revision = wp_get_post_revision( $revision_id ) ) 19 19 break; 20 if ( ! current_user_can( 'edit_post', $revision->post_parent ) )20 if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) 21 21 break; 22 if ( ! $post = get_post( $revision->post_parent ) )22 if ( ! $post = get_post( $revision->post_parent ) ) 23 23 break; 24 24 25 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 ) ) {26 if ( ( ! WP_POST_REVISIONS || ! post_type_supports( $post->post_type, 'revisions' ) ) && ! wp_is_post_autosave( $revision ) ) { 27 27 $redirect = 'edit.php?post_type=' . $post->post_type; 28 28 break; 29 29 } 30 30 check_admin_referer( "restore-post_{$post->ID}|{$revision->ID}" ); 31 31 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 wp_update_post_meta( $post->ID, '_post_restored_from', $restore_details ); 39 32 40 wp_restore_post_revision( $revision->ID ); 33 41 $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) ); 34 42 break; 35 43 case 'view' : 36 44 case 'edit' : 37 45 default : 38 if ( ! $revision = wp_get_post_revision( $revision_id ) )46 if ( ! $revision = wp_get_post_revision( $revision_id ) ) 39 47 break; 40 if ( ! $post = get_post( $revision->post_parent ) )48 if ( ! $post = get_post( $revision->post_parent ) ) 41 49 break; 42 50 43 if ( ! current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) )51 if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'read_post', $post->ID ) ) 44 52 break; 45 53 46 54 // Revisions disabled and we're not looking at an autosave … … 59 67 endswitch; 60 68 61 69 // Empty post_type means either malformed object found, or no valid parent was found. 62 if ( ! $redirect && empty($post->post_type) )70 if ( ! $redirect && empty( $post->post_type ) ) 63 71 $redirect = 'edit.php'; 64 72 65 if ( ! empty($redirect) ) {73 if ( ! empty( $redirect ) ) { 66 74 wp_redirect( $redirect ); 67 75 exit; 68 76 } 69 77 70 78 // This is so that the correct "Edit" menu item is selected. 71 if ( ! empty($post->post_type) && 'post' != $post->post_type )79 if ( ! empty( $post->post_type ) && 'post' != $post->post_type ) 72 80 $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type; 73 81 else 74 82 $parent_file = $submenu_file = 'edit.php'; … … 83 91 <script type="text/javascript"> 84 92 var wpRevisionsSettings = <?php echo json_encode( array( 'post_id' => $post->ID, 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ) ) ); ?>; 85 93 </script> 94 <?php 95 $comparetworevisionslink = get_edit_post_link( $revision->ID ); 96 ?> 86 97 87 98 <div id="backbonerevisionsoptions"></div> 88 89 <br class="clear"/>90 99 <div class="wrap"> 91 100 <div class="icon32 icon32-posts-post" id="icon-edit"><br></div> 92 101 <div class="revisiondiffcontainer diffsplit currentversion rightmodelloading"> … … 94 103 <h2 class="long-header"><?php echo $h2; ?></h2> 95 104 <div id="backbonerevisionsinteract"></div> 96 105 <div id="backbonerevisionsdiff"></div> 97 <hr /> 98 <?php 99 $comparetworevisionslink = get_edit_post_link( $revision->ID ); 100 ?> 106 <hr /> 101 107 </div> 102 108 </div> 103 109 … … 107 113 <div id="difftitlefrom">{{{ data.revision_from_date_author }}} <?php _e( '- compared to -' ); ?></div> 108 114 <div id="difftitle">{{{ data.revision_date_author }}}</div> 109 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> 110 <div id="diffrestore"><input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore ' )?>" /></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> 111 117 <div id="comparetworevisions"><input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> <?php esc_attr_e( 'Compare two revisions' )?></div> 112 118 </div> 113 119 <div id="removedandadded"> … … 119 125 120 126 <script id="tmpl-revisionvinteract" type="text/html"> 121 127 <div id="diffheader"> 122 <div id="diffprevious"><input class="button" type="submit" id="previous" value=" Previous" /></div>123 <div id="diffnext"><input class="button" type="submit" id="next" value=" Next" /></div>128 <div id="diffprevious"><input class="button" type="submit" id="previous" value="<?php esc_attr_e( 'Previous' ); ?>" /></div> 129 <div id="diffnext"><input class="button" type="submit" id="next" value="<?php esc_attr_e( 'Next' ); ?>" /></div> 124 130 <div id="diffslider"> 125 131 <div id="revisioncount"> 126 132 <?php _e( 'Comparing' ); ?>