wp/wp-admin/revision.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    27 $from = is_numeric( $from ) ? absint( $from ) : null;
    27 $from = is_numeric( $from ) ? absint( $from ) : null;
    28 if ( ! $revision_id )
    28 if ( ! $revision_id )
    29 	$revision_id = absint( $to );
    29 	$revision_id = absint( $to );
    30 $redirect = 'edit.php';
    30 $redirect = 'edit.php';
    31 
    31 
    32 switch ( $action ) :
    32 switch ( $action ) {
    33 case 'restore' :
    33 case 'restore' :
    34 	if ( ! $revision = wp_get_post_revision( $revision_id ) )
    34 	if ( ! $revision = wp_get_post_revision( $revision_id ) )
    35 		break;
    35 		break;
    36 
    36 
    37 	if ( ! current_user_can( 'edit_post', $revision->post_parent ) )
    37 	if ( ! current_user_can( 'edit_post', $revision->post_parent ) )
    70 	if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) {
    70 	if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) {
    71 		$redirect = 'edit.php?post_type=' . $post->post_type;
    71 		$redirect = 'edit.php?post_type=' . $post->post_type;
    72 		break;
    72 		break;
    73 	}
    73 	}
    74 
    74 
    75 	$post_title = '<a href="' . get_edit_post_link() . '">' . _draft_or_post_title() . '</a>';
    75 	$post_edit_link = get_edit_post_link();
    76 	$h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
    76 	$post_title     = '<a href="' . $post_edit_link . '">' . _draft_or_post_title() . '</a>';
    77 	$title = __( 'Revisions' );
    77 	$h2             = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
       
    78 	$return_to_post = '<a href="' . $post_edit_link . '">' . __( '&larr; Return to post editor' ) . '</a>';
       
    79 	$title          = __( 'Revisions' );
    78 
    80 
    79 	$redirect = false;
    81 	$redirect = false;
    80 	break;
    82 	break;
    81 endswitch;
    83 }
    82 
    84 
    83 // Empty post_type means either malformed object found, or no valid parent was found.
    85 // Empty post_type means either malformed object found, or no valid parent was found.
    84 if ( ! $redirect && empty( $post->post_type ) )
    86 if ( ! $redirect && empty( $post->post_type ) )
    85 	$redirect = 'edit.php';
    87 	$redirect = 'edit.php';
    86 
    88 
   112 	'title'   => __( 'Overview' ),
   114 	'title'   => __( 'Overview' ),
   113 	'content' => $revisions_overview
   115 	'content' => $revisions_overview
   114 ) );
   116 ) );
   115 
   117 
   116 $revisions_sidebar  = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
   118 $revisions_sidebar  = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
   117 $revisions_sidebar .= '<p>' . __( '<a href="http://codex.wordpress.org/Revision_Management" target="_blank">Revisions Management</a>' ) . '</p>';
   119 $revisions_sidebar .= '<p>' . __( '<a href="https://codex.wordpress.org/Revision_Management" target="_blank">Revisions Management</a>' ) . '</p>';
   118 $revisions_sidebar .= '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>';
   120 $revisions_sidebar .= '<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>';
   119 
   121 
   120 get_current_screen()->set_help_sidebar( $revisions_sidebar );
   122 get_current_screen()->set_help_sidebar( $revisions_sidebar );
   121 
   123 
   122 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   124 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   123 
   125 
   124 ?>
   126 ?>
   125 
   127 
   126 <div class="wrap">
   128 <div class="wrap">
   127 	<?php screen_icon(); ?>
       
   128 	<h2 class="long-header"><?php echo $h2; ?></h2>
   129 	<h2 class="long-header"><?php echo $h2; ?></h2>
       
   130 	<?php echo $return_to_post; ?>
   129 </div>
   131 </div>
       
   132 <?php
       
   133 wp_print_revision_templates();
   130 
   134 
   131 <script id="tmpl-revisions-frame" type="text/html">
       
   132 	<div class="revisions-control-frame"></div>
       
   133 	<div class="revisions-diff-frame"></div>
       
   134 </script>
       
   135 
       
   136 <script id="tmpl-revisions-buttons" type="text/html">
       
   137 	<div class="revisions-previous">
       
   138 		<input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" />
       
   139 	</div>
       
   140 
       
   141 	<div class="revisions-next">
       
   142 		<input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
       
   143 	</div>
       
   144 </script>
       
   145 
       
   146 <script id="tmpl-revisions-checkbox" type="text/html">
       
   147 	<div class="revision-toggle-compare-mode">
       
   148 		<label>
       
   149 			<input type="checkbox" class="compare-two-revisions"
       
   150 			<#
       
   151 			if ( 'undefined' !== typeof data && data.model.attributes.compareTwoMode ) {
       
   152 			 	#> checked="checked"<#
       
   153 			}
       
   154 			#>
       
   155 			/>
       
   156 			<?php esc_attr_e( 'Compare any two revisions' ); ?>
       
   157 		</label>
       
   158 	</div>
       
   159 </script>
       
   160 
       
   161 <script id="tmpl-revisions-meta" type="text/html">
       
   162 	<# if ( ! _.isUndefined( data.attributes ) ) { #>
       
   163 		<div class="diff-title">
       
   164 			<# if ( 'from' === data.type ) { #>
       
   165 				<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
       
   166 			<# } else if ( 'to' === data.type ) { #>
       
   167 				<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
       
   168 			<# } #>
       
   169 			<div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
       
   170 				{{{ data.attributes.author.avatar }}}
       
   171 				<div class="author-info">
       
   172 				<# if ( data.attributes.autosave ) { #>
       
   173 					<span class="byline"><?php printf( __( 'Autosave by %s' ),
       
   174 						'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
       
   175 				<# } else if ( data.attributes.current ) { #>
       
   176 					<span class="byline"><?php printf( __( 'Current Revision by %s' ),
       
   177 						'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
       
   178 				<# } else { #>
       
   179 					<span class="byline"><?php printf( __( 'Revision by %s' ),
       
   180 						'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
       
   181 				<# } #>
       
   182 					<span class="time-ago">{{ data.attributes.timeAgo }}</span>
       
   183 					<span class="date">({{ data.attributes.dateShort }})</span>
       
   184 				</div>
       
   185 			<# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
       
   186 				<input  <?php if ( wp_check_post_lock( $post->ID ) ) { ?>
       
   187 					disabled="disabled"
       
   188 				<?php } else { ?>
       
   189 					<# if ( data.attributes.current ) { #>
       
   190 						disabled="disabled"
       
   191 					<# } #>
       
   192 				<?php } ?>
       
   193 				<# if ( data.attributes.autosave ) { #>
       
   194 					type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
       
   195 				<# } else { #>
       
   196 					type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
       
   197 				<# } #>
       
   198 			<# } #>
       
   199 		</div>
       
   200 	<# if ( 'tooltip' === data.type ) { #>
       
   201 		<div class="revisions-tooltip-arrow"><span></span></div>
       
   202 	<# } #>
       
   203 <# } #>
       
   204 </script>
       
   205 
       
   206 <script id="tmpl-revisions-diff" type="text/html">
       
   207 	<div class="loading-indicator"><span class="spinner"></span></div>
       
   208 	<div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div>
       
   209 	<div class="diff">
       
   210 	<# _.each( data.fields, function( field ) { #>
       
   211 		<h3>{{ field.name }}</h3>
       
   212 		{{{ field.diff }}}
       
   213 	<# }); #>
       
   214 	</div>
       
   215 </script>
       
   216 
       
   217 
       
   218 <?php
       
   219 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
   135 require_once( ABSPATH . 'wp-admin/admin-footer.php' );