-
+ AB05294A8821DA7F82349F947AC21A56DE3EAE223B7E8A010469805EDBE1F11B7B6B61DCCBA300AA0A39AB1B0E176DD91C9CCB15B2BD6DDF0152E3CDFC246D20
mp-wp/wp-admin/revision.php
(0 . 0)(1 . 220)
56317 <?php
56318 /**
56319 * Revisions administration panel.
56320 *
56321 * @package WordPress
56322 * @subpackage Administration
56323 */
56324
56325 /** WordPress Administration Bootstrap */
56326 require_once('admin.php');
56327
56328 wp_reset_vars(array('revision', 'left', 'right', 'diff', 'action'));
56329 $revision_id = absint($revision);
56330 $diff = absint($diff);
56331 $left = absint($left);
56332 $right = absint($right);
56333
56334 $parent_file = $redirect = 'edit.php';
56335
56336 switch ( $action ) :
56337 case 'delete' : // stubs
56338 case 'edit' :
56339 if ( constant('WP_POST_REVISIONS') ) // stub
56340 $redirect = remove_query_arg( 'action' );
56341 else // Revisions disabled
56342 $redirect = 'edit.php';
56343 break;
56344 case 'restore' :
56345 if ( !$revision = wp_get_post_revision( $revision_id ) )
56346 break;
56347 if ( !current_user_can( 'edit_post', $revision->post_parent ) )
56348 break;
56349 if ( !$post = get_post( $revision->post_parent ) )
56350 break;
56351
56352 if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
56353 break;
56354
56355 check_admin_referer( "restore-post_$post->ID|$revision->ID" );
56356
56357 wp_restore_post_revision( $revision->ID );
56358 $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) );
56359 break;
56360 case 'diff' :
56361 if ( !$left_revision = get_post( $left ) )
56362 break;
56363 if ( !$right_revision = get_post( $right ) )
56364 break;
56365
56366 if ( !current_user_can( 'read_post', $left_revision->ID ) || !current_user_can( 'read_post', $right_revision->ID ) )
56367 break;
56368
56369 // If we're comparing a revision to itself, redirect to the 'view' page for that revision or the edit page for that post
56370 if ( $left_revision->ID == $right_revision->ID ) {
56371 $redirect = get_edit_post_link( $left_revision->ID );
56372 include( 'js/revisions-js.php' );
56373 break;
56374 }
56375
56376 // Don't allow reverse diffs?
56377 if ( strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt) ) {
56378 $redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );
56379 break;
56380 }
56381
56382 if ( $left_revision->ID == $right_revision->post_parent ) // right is a revision of left
56383 $post =& $left_revision;
56384 elseif ( $left_revision->post_parent == $right_revision->ID ) // left is a revision of right
56385 $post =& $right_revision;
56386 elseif ( $left_revision->post_parent == $right_revision->post_parent ) // both are revisions of common parent
56387 $post = get_post( $left_revision->post_parent );
56388 else
56389 break; // Don't diff two unrelated revisions
56390
56391 if ( !constant('WP_POST_REVISIONS') ) { // Revisions disabled
56392 if (
56393 // we're not looking at an autosave
56394 ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) )
56395 ||
56396 // we're not comparing an autosave to the current post
56397 ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID )
56398 )
56399 break;
56400 }
56401
56402 if (
56403 // They're the same
56404 $left_revision->ID == $right_revision->ID
56405 ||
56406 // Neither is a revision
56407 ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )
56408 )
56409 break;
56410
56411 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
56412 $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title );
56413
56414 $left = $left_revision->ID;
56415 $right = $right_revision->ID;
56416
56417 $redirect = false;
56418 break;
56419 case 'view' :
56420 default :
56421 if ( !$revision = wp_get_post_revision( $revision_id ) )
56422 break;
56423 if ( !$post = get_post( $revision->post_parent ) )
56424 break;
56425
56426 if ( !current_user_can( 'read_post', $revision->ID ) || !current_user_can( 'read_post', $post->ID ) )
56427 break;
56428
56429 if ( !constant('WP_POST_REVISIONS') && !wp_is_post_autosave( $revision ) ) // Revisions disabled and we're not looking at an autosave
56430 break;
56431
56432 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
56433 $revision_title = wp_post_revision_title( $revision, false );
56434 $h2 = sprintf( __( 'Post Revision for “%1$s” created on %2$s' ), $post_title, $revision_title );
56435
56436 // Sets up the diff radio buttons
56437 $left = $revision->ID;
56438 $right = $post->ID;
56439
56440 $redirect = false;
56441 break;
56442 endswitch;
56443
56444 if ( !$redirect && !in_array( $post->post_type, array( 'post', 'page' ) ) )
56445 $redirect = 'edit.php';
56446
56447 if ( $redirect ) {
56448 wp_redirect( $redirect );
56449 exit;
56450 }
56451
56452 if ( 'page' == $post->post_type ) {
56453 $submenu_file = 'edit-pages.php';
56454 $title = __( 'Page Revisions' );
56455 } else {
56456 $submenu_file = 'edit.php';
56457 $title = __( 'Post Revisions' );
56458 }
56459
56460 require_once( 'admin-header.php' );
56461
56462 ?>
56463
56464 <div class="wrap">
56465
56466 <h2 class="long-header"><?php echo $h2; ?></h2>
56467
56468 <table class="form-table ie-fixed">
56469 <col class="th" />
56470 <?php if ( 'diff' == $action ) : ?>
56471 <tr id="revision">
56472 <th scope="row"></th>
56473 <th scope="col" class="th-full">
56474 <span class="alignleft"><?php printf( __('Older: %s'), wp_post_revision_title( $left_revision ) ); ?></span>
56475 <span class="alignright"><?php printf( __('Newer: %s'), wp_post_revision_title( $right_revision ) ); ?></span>
56476 </th>
56477 </tr>
56478 <?php endif;
56479
56480 // use get_post_to_edit filters?
56481 $identical = true;
56482 foreach ( _wp_post_revision_fields() as $field => $field_title ) :
56483 if ( 'diff' == $action ) {
56484 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field );
56485 $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field );
56486 if ( !$content = wp_text_diff( $left_content, $right_content ) )
56487 continue; // There is no difference between left and right
56488 $identical = false;
56489 } else {
56490 add_filter( "_wp_post_revision_field_$field", 'htmlspecialchars' );
56491 $content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field );
56492 }
56493 ?>
56494
56495 <tr id="revision-field-<?php echo $field; ?>">
56496 <th scope="row"><?php echo wp_specialchars( $field_title ); ?></th>
56497 <td><div class="pre"><?php echo $content; ?></div></td>
56498 </tr>
56499
56500 <?php
56501
56502 endforeach;
56503
56504 if ( 'diff' == $action && $identical ) :
56505
56506 ?>
56507
56508 <tr><td colspan="2"><div class="updated"><p><?php _e( 'These revisions are identical.' ); ?></p></div></td></tr>
56509
56510 <?php
56511
56512 endif;
56513
56514 ?>
56515
56516 </table>
56517
56518 <br class="clear" />
56519
56520 <h2><?php echo $title; ?></h2>
56521
56522 <?php
56523
56524 $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left );
56525 if ( !constant( 'WP_POST_REVISIONS' ) )
56526 $args['type'] = 'autosave';
56527
56528 wp_list_post_revisions( $post, $args );
56529
56530 ?>
56531
56532 </div>
56533
56534 <?php
56535
56536 require_once( 'admin-footer.php' );