wp/wp-admin/revision.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    19  * @global string $action   The action to take.
    19  * @global string $action   The action to take.
    20  *                          Accepts 'restore', 'view' or 'edit'.
    20  *                          Accepts 'restore', 'view' or 'edit'.
    21  * @global int    $from     The revision to compare from.
    21  * @global int    $from     The revision to compare from.
    22  * @global int    $to       Optional, required if revision missing. The revision to compare to.
    22  * @global int    $to       Optional, required if revision missing. The revision to compare to.
    23  */
    23  */
    24 wp_reset_vars( array( 'revision', 'action', 'from', 'to' ) );
       
    25 
    24 
    26 $revision_id = absint( $revision );
    25 $revision_id = ! empty( $_REQUEST['revision'] ) ? absint( $_REQUEST['revision'] ) : 0;
       
    26 $action      = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : '';
       
    27 $from        = ! empty( $_REQUEST['from'] ) && is_numeric( $_REQUEST['from'] ) ? absint( $_REQUEST['from'] ) : null;
       
    28 $to          = ! empty( $_REQUEST['to'] ) && is_numeric( $_REQUEST['to'] ) ? absint( $_REQUEST['to'] ) : null;
    27 
    29 
    28 $from = is_numeric( $from ) ? absint( $from ) : null;
       
    29 if ( ! $revision_id ) {
    30 if ( ! $revision_id ) {
    30 	$revision_id = absint( $to );
    31 	$revision_id = $to;
    31 }
    32 }
       
    33 
    32 $redirect = 'edit.php';
    34 $redirect = 'edit.php';
    33 
    35 
    34 switch ( $action ) {
    36 switch ( $action ) {
    35 	case 'restore':
    37 	case 'restore':
    36 		$revision = wp_get_post_revision( $revision_id );
    38 		$revision = wp_get_post_revision( $revision_id );
   102 			$redirect = 'edit.php?post_type=' . $post->post_type;
   104 			$redirect = 'edit.php?post_type=' . $post->post_type;
   103 			break;
   105 			break;
   104 		}
   106 		}
   105 
   107 
   106 		$post_edit_link = get_edit_post_link();
   108 		$post_edit_link = get_edit_post_link();
   107 		$post_title     = '<a href="' . $post_edit_link . '">' . _draft_or_post_title() . '</a>';
   109 		$post_title     = '<a href="' . esc_url( $post_edit_link ) . '">' . _draft_or_post_title() . '</a>';
   108 		/* translators: %s: Post title. */
   110 		/* translators: %s: Post title. */
   109 		$h1             = sprintf( __( 'Compare Revisions of &#8220;%s&#8221;' ), $post_title );
   111 		$h1             = sprintf( __( 'Compare Revisions of &#8220;%s&#8221;' ), $post_title );
   110 		$return_to_post = '<a href="' . $post_edit_link . '">' . __( '&larr; Go to editor' ) . '</a>';
   112 		$return_to_post = '<a href="' . esc_url( $post_edit_link ) . '">' . __( '&larr; Go to editor' ) . '</a>';
   111 		// Used in the HTML title tag.
   113 		// Used in the HTML title tag.
   112 		$title = __( 'Revisions' );
   114 		$title = __( 'Revisions' );
   113 
   115 
   114 		$redirect = false;
   116 		$redirect = false;
   115 		break;
   117 		break;
   152 		'content' => $revisions_overview,
   154 		'content' => $revisions_overview,
   153 	)
   155 	)
   154 );
   156 );
   155 
   157 
   156 $revisions_sidebar  = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
   158 $revisions_sidebar  = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
   157 $revisions_sidebar .= '<p>' . __( '<a href="https://wordpress.org/support/article/revisions/">Revisions Management</a>' ) . '</p>';
   159 $revisions_sidebar .= '<p>' . __( '<a href="https://wordpress.org/documentation/article/revisions/">Revisions Management</a>' ) . '</p>';
   158 $revisions_sidebar .= '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>';
   160 $revisions_sidebar .= '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>';
   159 
   161 
   160 get_current_screen()->set_help_sidebar( $revisions_sidebar );
   162 get_current_screen()->set_help_sidebar( $revisions_sidebar );
   161 
   163 
   162 require_once ABSPATH . 'wp-admin/admin-header.php';
   164 require_once ABSPATH . 'wp-admin/admin-header.php';
   163 
   165