3 * Revisions administration panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once('./admin.php');
12 require ABSPATH . 'wp-admin/includes/revision.php';
14 wp_reset_vars( array( 'revision', 'action', 'from', 'to' ) );
16 $revision_id = absint( $revision );
18 $from = is_numeric( $from ) ? absint( $from ) : null;
20 $revision_id = absint( $to );
21 $redirect = 'edit.php';
25 if ( ! $revision = wp_get_post_revision( $revision_id ) )
28 if ( ! current_user_can( 'edit_post', $revision->post_parent ) )
31 if ( ! $post = get_post( $revision->post_parent ) )
34 // Revisions disabled (previously checked autosaves && ! wp_is_post_autosave( $revision ))
35 if ( ! wp_revisions_enabled( $post ) ) {
36 $redirect = 'edit.php?post_type=' . $post->post_type;
40 // Don't allow revision restore when post is locked
41 if ( wp_check_post_lock( $post->ID ) )
44 check_admin_referer( "restore-post_{$revision->ID}" );
46 wp_restore_post_revision( $revision->ID );
47 $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) );
52 if ( ! $revision = wp_get_post_revision( $revision_id ) )
54 if ( ! $post = get_post( $revision->post_parent ) )
57 if ( ! current_user_can( 'read_post', $revision->ID ) || ! current_user_can( 'read_post', $post->ID ) )
60 // Revisions disabled and we're not looking at an autosave
61 if ( ! wp_revisions_enabled( $post ) && ! wp_is_post_autosave( $revision ) ) {
62 $redirect = 'edit.php?post_type=' . $post->post_type;
66 $post_title = '<a href="' . get_edit_post_link() . '">' . _draft_or_post_title() . '</a>';
67 $h2 = sprintf( __( 'Compare Revisions of “%1$s”' ), $post_title );
68 $title = __( 'Revisions' );
74 // Empty post_type means either malformed object found, or no valid parent was found.
75 if ( ! $redirect && empty( $post->post_type ) )
76 $redirect = 'edit.php';
78 if ( ! empty( $redirect ) ) {
79 wp_redirect( $redirect );
83 // This is so that the correct "Edit" menu item is selected.
84 if ( ! empty( $post->post_type ) && 'post' != $post->post_type )
85 $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type;
87 $parent_file = $submenu_file = 'edit.php';
89 wp_enqueue_script( 'revisions' );
90 wp_localize_script( 'revisions', '_wpRevisionsSettings', wp_prepare_revisions_for_js( $post, $revision_id, $from ) );
92 /* Revisions Help Tab */
94 $revisions_overview = '<p>' . __( 'This screen is used for managing your content revisions.' ) . '</p>';
95 $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>';
96 $revisions_overview .= '<p>' . __( 'From this screen you can review, compare, and restore revisions:' ) . '</p>';
97 $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>';
98 $revisions_overview .= '<li>' . __( 'Compare two different revisions by <strong>selecting the “Compare any two revisions” box</strong> to the side.' ) . '</li>';
99 $revisions_overview .= '<li>' . __( 'To restore a revision, <strong>click Restore This Revision</strong>.' ) . '</li></ul>';
101 get_current_screen()->add_help_tab( array(
102 'id' => 'revisions-overview',
103 'title' => __( 'Overview' ),
104 'content' => $revisions_overview
107 $revisions_sidebar = '<p><strong>' . __( 'For more information:' ) . '</strong></p>';
108 $revisions_sidebar .= '<p>' . __( '<a href="http://codex.wordpress.org/Revision_Management" target="_blank">Revisions Management</a>' ) . '</p>';
109 $revisions_sidebar .= '<p>' . __( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>';
111 get_current_screen()->set_help_sidebar( $revisions_sidebar );
113 require_once( './admin-header.php' );
118 <?php screen_icon(); ?>
119 <h2 class="long-header"><?php echo $h2; ?></h2>
122 <script id="tmpl-revisions-frame" type="text/html">
123 <div class="revisions-control-frame"></div>
124 <div class="revisions-diff-frame"></div>
127 <script id="tmpl-revisions-buttons" type="text/html">
128 <div class="revisions-previous">
129 <input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" />
132 <div class="revisions-next">
133 <input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
137 <script id="tmpl-revisions-checkbox" type="text/html">
138 <div class="revision-toggle-compare-mode">
140 <input type="checkbox" class="compare-two-revisions"
142 if ( 'undefined' !== typeof data && data.model.attributes.compareTwoMode ) {
143 #> checked="checked"<#
147 <?php esc_attr_e( 'Compare any two revisions' ); ?>
152 <script id="tmpl-revisions-meta" type="text/html">
153 <# if ( ! _.isUndefined( data.attributes ) ) { #>
154 <div class="diff-title">
155 <# if ( 'from' === data.type ) { #>
156 <strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
157 <# } else if ( 'to' === data.type ) { #>
158 <strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
160 <div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>">
161 {{{ data.attributes.author.avatar }}}
162 <div class="author-info">
163 <# if ( data.attributes.autosave ) { #>
164 <span class="byline"><?php printf( __( 'Autosave by %s' ),
165 '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
166 <# } else if ( data.attributes.current ) { #>
167 <span class="byline"><?php printf( __( 'Current Revision by %s' ),
168 '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
170 <span class="byline"><?php printf( __( 'Revision by %s' ),
171 '<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
173 <span class="time-ago">{{ data.attributes.timeAgo }}</span>
174 <span class="date">({{ data.attributes.dateShort }})</span>
176 <# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
177 <input <?php if ( wp_check_post_lock( $post->ID ) ) { ?>
180 <# if ( data.attributes.current ) { #>
184 <# if ( data.attributes.autosave ) { #>
185 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
187 type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
191 <# if ( 'tooltip' === data.type ) { #>
192 <div class="revisions-tooltip-arrow"><span></span></div>
197 <script id="tmpl-revisions-diff" type="text/html">
198 <div class="loading-indicator"><span class="spinner"></span></div>
199 <div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div>
201 <# _.each( data.fields, function( field ) { #>
202 <h3>{{ field.name }}</h3>
210 require_once( './admin-footer.php' );