Edit File by line
/home/barbar84/www/wp-admin
File: revision.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Revisions administration panel
[2] Fix | Delete
*
[3] Fix | Delete
* Requires wp-admin/includes/revision.php.
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Administration
[7] Fix | Delete
* @since 2.6.0
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
/** WordPress Administration Bootstrap */
[11] Fix | Delete
require_once __DIR__ . '/admin.php';
[12] Fix | Delete
[13] Fix | Delete
require ABSPATH . 'wp-admin/includes/revision.php';
[14] Fix | Delete
[15] Fix | Delete
/**
[16] Fix | Delete
* @global int $revision Optional. The revision ID.
[17] Fix | Delete
* @global string $action The action to take.
[18] Fix | Delete
* Accepts 'restore', 'view' or 'edit'.
[19] Fix | Delete
* @global int $from The revision to compare from.
[20] Fix | Delete
* @global int $to Optional, required if revision missing. The revision to compare to.
[21] Fix | Delete
*/
[22] Fix | Delete
wp_reset_vars( array( 'revision', 'action', 'from', 'to' ) );
[23] Fix | Delete
[24] Fix | Delete
$revision_id = absint( $revision );
[25] Fix | Delete
[26] Fix | Delete
$from = is_numeric( $from ) ? absint( $from ) : null;
[27] Fix | Delete
if ( ! $revision_id ) {
[28] Fix | Delete
$revision_id = absint( $to );
[29] Fix | Delete
}
[30] Fix | Delete
$redirect = 'edit.php';
[31] Fix | Delete
[32] Fix | Delete
switch ( $action ) {
[33] Fix | Delete
case 'restore':
[34] Fix | Delete
$revision = wp_get_post_revision( $revision_id );
[35] Fix | Delete
if ( ! $revision ) {
[36] Fix | Delete
break;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
if ( ! current_user_can( 'edit_post', $revision->post_parent ) ) {
[40] Fix | Delete
break;
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
$post = get_post( $revision->post_parent );
[44] Fix | Delete
if ( ! $post ) {
[45] Fix | Delete
break;
[46] Fix | Delete
}
[47] Fix | Delete
[48] Fix | Delete
// Don't restore if revisions are disabled and this is not an autosave.
[49] Fix | Delete
if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) {
[50] Fix | Delete
$redirect = 'edit.php?post_type=' . $post->post_type;
[51] Fix | Delete
break;
[52] Fix | Delete
}
[53] Fix | Delete
[54] Fix | Delete
// Don't restore if the post is locked.
[55] Fix | Delete
if ( wp_check_post_lock( $post->ID ) ) {
[56] Fix | Delete
break;
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
check_admin_referer( "restore-post_{$revision->ID}" );
[60] Fix | Delete
[61] Fix | Delete
/*
[62] Fix | Delete
* Ensure the global $post remains the same after revision is restored.
[63] Fix | Delete
* Because wp_insert_post() and wp_transition_post_status() are called
[64] Fix | Delete
* during the process, plugins can unexpectedly modify $post.
[65] Fix | Delete
*/
[66] Fix | Delete
$backup_global_post = clone $post;
[67] Fix | Delete
[68] Fix | Delete
wp_restore_post_revision( $revision->ID );
[69] Fix | Delete
[70] Fix | Delete
// Restore the global $post as it was before.
[71] Fix | Delete
$post = $backup_global_post;
[72] Fix | Delete
[73] Fix | Delete
$redirect = add_query_arg(
[74] Fix | Delete
array(
[75] Fix | Delete
'message' => 5,
[76] Fix | Delete
'revision' => $revision->ID,
[77] Fix | Delete
),
[78] Fix | Delete
get_edit_post_link( $post->ID, 'url' )
[79] Fix | Delete
);
[80] Fix | Delete
break;
[81] Fix | Delete
case 'view':
[82] Fix | Delete
case 'edit':
[83] Fix | Delete
default:
[84] Fix | Delete
$revision = wp_get_post_revision( $revision_id );
[85] Fix | Delete
if ( ! $revision ) {
[86] Fix | Delete
break;
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$post = get_post( $revision->post_parent );
[90] Fix | Delete
if ( ! $post ) {
[91] Fix | Delete
break;
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'edit_post', $revision->post_parent ) ) {
[95] Fix | Delete
break;
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
// Bail if revisions are disabled and this is not an autosave.
[99] Fix | Delete
if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) {
[100] Fix | Delete
$redirect = 'edit.php?post_type=' . $post->post_type;
[101] Fix | Delete
break;
[102] Fix | Delete
}
[103] Fix | Delete
[104] Fix | Delete
$post_edit_link = get_edit_post_link();
[105] Fix | Delete
$post_title = '<a href="' . $post_edit_link . '">' . _draft_or_post_title() . '</a>';
[106] Fix | Delete
/* translators: %s: Post title. */
[107] Fix | Delete
$h1 = sprintf( __( 'Compare Revisions of &#8220;%s&#8221;' ), $post_title );
[108] Fix | Delete
$return_to_post = '<a href="' . $post_edit_link . '">' . __( '&larr; Go to editor' ) . '</a>';
[109] Fix | Delete
$title = __( 'Revisions' );
[110] Fix | Delete
[111] Fix | Delete
$redirect = false;
[112] Fix | Delete
break;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
// Empty post_type means either malformed object found, or no valid parent was found.
[116] Fix | Delete
if ( ! $redirect && empty( $post->post_type ) ) {
[117] Fix | Delete
$redirect = 'edit.php';
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
if ( ! empty( $redirect ) ) {
[121] Fix | Delete
wp_redirect( $redirect );
[122] Fix | Delete
exit;
[123] Fix | Delete
}
[124] Fix | Delete
[125] Fix | Delete
// This is so that the correct "Edit" menu item is selected.
[126] Fix | Delete
if ( ! empty( $post->post_type ) && 'post' != $post->post_type ) {
[127] Fix | Delete
$parent_file = 'edit.php?post_type=' . $post->post_type;
[128] Fix | Delete
} else {
[129] Fix | Delete
$parent_file = 'edit.php';
[130] Fix | Delete
}
[131] Fix | Delete
$submenu_file = $parent_file;
[132] Fix | Delete
[133] Fix | Delete
wp_enqueue_script( 'revisions' );
[134] Fix | Delete
wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $post, $revision_id, $from ) );
[135] Fix | Delete
[136] Fix | Delete
/* Revisions Help Tab */
[137] Fix | Delete
[138] Fix | Delete
$revisions_overview = '<p>' . __( 'This screen is used for managing your content revisions.' ) . '</p>';
[139] Fix | Delete
$revisions_overview .= '<p>' . __( 'Revisions are saved copies of your post or page, which are periodically created as you update your content. The red text on the left shows the content that was removed. The green text on the right shows the content that was added.' ) . '</p>';
[140] Fix | Delete
$revisions_overview .= '<p>' . __( 'From this screen you can review, compare, and restore revisions:' ) . '</p>';
[141] Fix | Delete
$revisions_overview .= '<ul><li>' . __( 'To navigate between revisions, <strong>drag the slider handle left or right</strong> or <strong>use the Previous or Next buttons</strong>.' ) . '</li>';
[142] Fix | Delete
$revisions_overview .= '<li>' . __( 'Compare two different revisions by <strong>selecting the &#8220;Compare any two revisions&#8221; box</strong> to the side.' ) . '</li>';
[143] Fix | Delete
$revisions_overview .= '<li>' . __( 'To restore a revision, <strong>click Restore This Revision</strong>.' ) . '</li></ul>';
[144] Fix | Delete
[145] Fix | Delete
get_current_screen()->add_help_tab(
[146] Fix | Delete
array(
[147] Fix | Delete
'id' => 'revisions-overview',
[148] Fix | Delete
'title' => __( 'Overview' ),
[149] Fix | Delete
'content' => $revisions_overview,
[150] Fix | Delete
)
[151] Fix | Delete
);
[152] Fix | Delete
[153] Fix | Delete
$revisions_sidebar = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
[154] Fix | Delete
$revisions_sidebar .= '<p>' . __( '<a href="https://wordpress.org/support/article/revisions/">Revisions Management</a>' ) . '</p>';
[155] Fix | Delete
$revisions_sidebar .= '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>';
[156] Fix | Delete
[157] Fix | Delete
get_current_screen()->set_help_sidebar( $revisions_sidebar );
[158] Fix | Delete
[159] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[160] Fix | Delete
[161] Fix | Delete
?>
[162] Fix | Delete
[163] Fix | Delete
<div class="wrap">
[164] Fix | Delete
<h1 class="long-header"><?php echo $h1; ?></h1>
[165] Fix | Delete
<?php echo $return_to_post; ?>
[166] Fix | Delete
</div>
[167] Fix | Delete
<?php
[168] Fix | Delete
wp_print_revision_templates();
[169] Fix | Delete
[170] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-footer.php';
[171] Fix | Delete
[172] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function