2008-04-19 01:38:21 +02:00
< ? php
2008-08-16 09:27:34 +02:00
/**
2013-09-13 00:59:08 +02:00
* Revisions administration panel
2013-10-23 16:40:10 +02:00
*
2013-09-13 00:59:08 +02:00
* Requires wp - admin / includes / revision . php .
2008-08-16 09:27:34 +02:00
*
* @ package WordPress
* @ subpackage Administration
2013-09-13 00:59:08 +02:00
* @ since 2.6 . 0
2013-10-23 16:40:10 +02:00
*
2013-09-13 00:59:08 +02:00
* @ param int revision Optional . The revision ID .
* @ param string action The action to take .
2013-10-23 16:40:10 +02:00
* Accepts 'restore' , 'view' or 'edit' .
2013-09-13 00:59:08 +02:00
* @ param int from The revision to compare from .
* @ param int to Optional , required if revision missing . The revision to compare to .
2008-08-16 09:27:34 +02:00
*/
2008-04-19 01:38:21 +02:00
2008-08-16 09:27:34 +02:00
/** WordPress Administration Bootstrap */
2013-09-25 02:18:11 +02:00
require_once ( dirname ( __FILE__ ) . '/admin.php' );
2013-06-26 23:06:50 +02:00
require ABSPATH . 'wp-admin/includes/revision.php' ;
2013-07-12 00:56:48 +02:00
wp_reset_vars ( array ( 'revision' , 'action' , 'from' , 'to' ) );
2010-01-18 12:44:51 +01:00
2013-03-07 16:32:26 +01:00
$revision_id = absint ( $revision );
2013-07-12 16:01:39 +02:00
$from = is_numeric ( $from ) ? absint ( $from ) : null ;
2013-07-12 00:56:48 +02:00
if ( ! $revision_id )
$revision_id = absint ( $to );
2010-01-18 12:44:51 +01:00
$redirect = 'edit.php' ;
2008-04-19 01:38:21 +02:00
2008-05-08 19:25:07 +02:00
switch ( $action ) :
case 'restore' :
2013-03-07 16:32:26 +01:00
if ( ! $revision = wp_get_post_revision ( $revision_id ) )
2008-05-08 19:25:07 +02:00
break ;
2013-03-21 16:54:11 +01:00
2013-03-07 16:32:26 +01:00
if ( ! current_user_can ( 'edit_post' , $revision -> post_parent ) )
2008-05-08 19:25:07 +02:00
break ;
2013-03-21 16:54:11 +01:00
2013-03-07 16:32:26 +01:00
if ( ! $post = get_post ( $revision -> post_parent ) )
2008-05-08 19:25:07 +02:00
break ;
2008-04-19 01:38:21 +02:00
2013-07-24 08:08:14 +02:00
// Revisions disabled (previously checked autosaves && ! wp_is_post_autosave( $revision ))
2013-06-07 04:06:22 +02:00
if ( ! wp_revisions_enabled ( $post ) ) {
2010-05-19 20:36:52 +02:00
$redirect = 'edit.php?post_type=' . $post -> post_type ;
2008-05-30 00:21:36 +02:00
break ;
2010-05-19 20:36:52 +02:00
}
2008-05-08 19:25:07 +02:00
2013-07-28 23:51:44 +02:00
// Don't allow revision restore when post is locked
if ( wp_check_post_lock ( $post -> ID ) )
break ;
2013-03-21 16:54:11 +01:00
check_admin_referer ( " restore-post_ { $revision -> ID } " );
2013-03-07 16:32:26 +01:00
2008-05-30 00:21:36 +02:00
wp_restore_post_revision ( $revision -> ID );
2008-05-08 19:25:07 +02:00
$redirect = add_query_arg ( array ( 'message' => 5 , 'revision' => $revision -> ID ), get_edit_post_link ( $post -> ID , 'url' ) );
break ;
case 'view' :
2013-02-28 16:14:34 +01:00
case 'edit' :
2008-05-08 19:25:07 +02:00
default :
2013-03-07 16:32:26 +01:00
if ( ! $revision = wp_get_post_revision ( $revision_id ) )
2008-05-08 19:25:07 +02:00
break ;
2013-03-07 16:32:26 +01:00
if ( ! $post = get_post ( $revision -> post_parent ) )
2008-05-08 19:25:07 +02:00
break ;
2013-03-07 16:32:26 +01:00
if ( ! current_user_can ( 'read_post' , $revision -> ID ) || ! current_user_can ( 'read_post' , $post -> ID ) )
2008-05-08 19:25:07 +02:00
break ;
2010-05-19 20:36:52 +02:00
// Revisions disabled and we're not looking at an autosave
2013-03-27 19:11:56 +01:00
if ( ! wp_revisions_enabled ( $post ) && ! wp_is_post_autosave ( $revision ) ) {
2010-05-19 20:36:52 +02:00
$redirect = 'edit.php?post_type=' . $post -> post_type ;
2008-05-30 00:21:36 +02:00
break ;
2010-05-19 20:36:52 +02:00
}
2010-01-18 12:44:51 +01:00
2013-07-06 12:48:14 +02:00
$post_title = '<a href="' . get_edit_post_link () . '">' . _draft_or_post_title () . '</a>' ;
2013-02-28 16:14:34 +01:00
$h2 = sprintf ( __ ( 'Compare Revisions of “%1$s”' ), $post_title );
2010-01-18 12:44:51 +01:00
$title = __ ( 'Revisions' );
2008-05-08 19:25:07 +02:00
$redirect = false ;
break ;
endswitch ;
2008-04-19 01:38:21 +02:00
2010-05-19 20:36:52 +02:00
// Empty post_type means either malformed object found, or no valid parent was found.
2013-03-07 16:32:26 +01:00
if ( ! $redirect && empty ( $post -> post_type ) )
2010-05-19 20:36:52 +02:00
$redirect = 'edit.php' ;
2008-05-09 17:59:17 +02:00
2013-03-07 16:32:26 +01:00
if ( ! empty ( $redirect ) ) {
2008-05-08 19:25:07 +02:00
wp_redirect ( $redirect );
2008-04-19 01:38:21 +02:00
exit ;
}
2010-01-18 12:44:51 +01:00
// This is so that the correct "Edit" menu item is selected.
2013-03-07 16:32:26 +01:00
if ( ! empty ( $post -> post_type ) && 'post' != $post -> post_type )
2010-01-18 12:44:51 +01:00
$parent_file = $submenu_file = 'edit.php?post_type=' . $post -> post_type ;
else
$parent_file = $submenu_file = 'edit.php' ;
2008-04-19 01:38:21 +02:00
2013-04-04 17:49:28 +02:00
wp_enqueue_script ( 'revisions' );
2013-07-12 00:56:48 +02:00
wp_localize_script ( 'revisions' , '_wpRevisionsSettings' , wp_prepare_revisions_for_js ( $post , $revision_id , $from ) );
2013-03-21 16:54:11 +01:00
2013-05-04 01:00:14 +02:00
/* Revisions Help Tab */
$revisions_overview = '<p>' . __ ( 'This screen is used for managing your content revisions.' ) . '</p>' ;
$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>' ;
$revisions_overview .= '<p>' . __ ( 'From this screen you can review, compare, and restore revisions:' ) . '</p>' ;
2013-05-09 12:07:26 +02:00
$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>' ;
2013-07-31 17:27:02 +02:00
$revisions_overview .= '<li>' . __ ( 'Compare two different revisions by <strong>selecting the “Compare any two revisions” box</strong> to the side.' ) . '</li>' ;
2013-05-04 01:00:14 +02:00
$revisions_overview .= '<li>' . __ ( 'To restore a revision, <strong>click Restore This Revision</strong>.' ) . '</li></ul>' ;
get_current_screen () -> add_help_tab ( array (
'id' => 'revisions-overview' ,
'title' => __ ( 'Overview' ),
'content' => $revisions_overview
) );
$revisions_sidebar = '<p><strong>' . __ ( 'For more information:' ) . '</strong></p>' ;
$revisions_sidebar .= '<p>' . __ ( '<a href="http://codex.wordpress.org/Revision_Management" target="_blank">Revisions Management</a>' ) . '</p>' ;
$revisions_sidebar .= '<p>' . __ ( '<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>' ;
get_current_screen () -> set_help_sidebar ( $revisions_sidebar );
2013-09-25 02:18:11 +02:00
require_once ( ABSPATH . 'wp-admin/admin-header.php' );
2013-04-04 17:49:28 +02:00
2013-03-07 16:32:26 +01:00
?>
2008-04-19 01:38:21 +02:00
2013-02-28 16:14:34 +01:00
< div class = " wrap " >
2013-04-04 17:49:28 +02:00
< ? php screen_icon (); ?>
2013-06-26 23:06:50 +02:00
< h2 class = " long-header " >< ? php echo $h2 ; ?> </h2>
</ div >
2013-04-28 12:56:57 +02:00
2013-06-26 23:06:50 +02:00
< script id = " tmpl-revisions-frame " type = " text/html " >
< div class = " revisions-control-frame " ></ div >
< div class = " revisions-diff-frame " ></ div >
</ script >
2013-07-03 22:27:19 +02:00
< script id = " tmpl-revisions-buttons " type = " text/html " >
2013-06-26 23:06:50 +02:00
< div class = " revisions-previous " >
Revisions: Pinned controls, layout tweaks, copy tweaks, misc.
* When you scroll down the diff view, the controls will pin to the top.
* The revisions meta view was cleaned up. Copy changes.
* Loading indicator in the center of the screen (so it follows as you scroll).
* Tooltips "flip" when you cross the center line, so that they don't hit the container edge and wrap for later revisions.
* The "Restore" button's inactive state is handled on render, instead of after.
* Make sure we always have a current revision, even if the timestamp doesn't work out on the most recent one.
See #24804. Props markjaquith, nacin, ocean90, aaroncampbell.
git-svn-id: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 07:05:45 +02:00
< input class = " button " type = " button " value = " <?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?> " />
2013-06-26 23:06:50 +02:00
</ div >
< div class = " revisions-next " >
Revisions: Pinned controls, layout tweaks, copy tweaks, misc.
* When you scroll down the diff view, the controls will pin to the top.
* The revisions meta view was cleaned up. Copy changes.
* Loading indicator in the center of the screen (so it follows as you scroll).
* Tooltips "flip" when you cross the center line, so that they don't hit the container edge and wrap for later revisions.
* The "Restore" button's inactive state is handled on render, instead of after.
* Make sure we always have a current revision, even if the timestamp doesn't work out on the most recent one.
See #24804. Props markjaquith, nacin, ocean90, aaroncampbell.
git-svn-id: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 07:05:45 +02:00
< input class = " button " type = " button " value = " <?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?> " />
2013-06-26 23:06:50 +02:00
</ div >
</ script >
2013-07-03 22:27:19 +02:00
< script id = " tmpl-revisions-checkbox " type = " text/html " >
< div class = " revision-toggle-compare-mode " >
2013-04-04 09:53:49 +02:00
< label >
2013-07-03 22:27:19 +02:00
< input type = " checkbox " class = " compare-two-revisions "
< #
if ( 'undefined' !== typeof data && data . model . attributes . compareTwoMode ) {
#> checked="checked"<#
}
#>
/>
2013-07-29 08:56:49 +02:00
< ? php esc_attr_e ( 'Compare any two revisions' ); ?>
2013-04-04 09:53:49 +02:00
</ label >
</ div >
2013-07-03 22:27:19 +02:00
</ script >
2013-04-04 09:53:49 +02:00
2013-07-03 22:27:19 +02:00
< script id = " tmpl-revisions-meta " type = " text/html " >
2013-07-28 22:15:28 +02:00
< # if ( ! _.isUndefined( data.attributes ) ) { #>
Revisions: Pinned controls, layout tweaks, copy tweaks, misc.
* When you scroll down the diff view, the controls will pin to the top.
* The revisions meta view was cleaned up. Copy changes.
* Loading indicator in the center of the screen (so it follows as you scroll).
* Tooltips "flip" when you cross the center line, so that they don't hit the container edge and wrap for later revisions.
* The "Restore" button's inactive state is handled on render, instead of after.
* Make sure we always have a current revision, even if the timestamp doesn't work out on the most recent one.
See #24804. Props markjaquith, nacin, ocean90, aaroncampbell.
git-svn-id: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 07:05:45 +02:00
< div class = " diff-title " >
2013-07-28 22:15:28 +02:00
< # if ( 'from' === data.type ) { #>
< strong >< ? php _ex ( 'From:' , 'Followed by post revision info' ); ?> </strong>
< # } else if ( 'to' === data.type ) { #>
< strong >< ? php _ex ( 'To:' , 'Followed by post revision info' ); ?> </strong>
< # } #>
< div class = " author-card<# if ( data.attributes.autosave ) { #> autosave<# } #> " >
{{{ data . attributes . author . avatar }}}
Revisions: Pinned controls, layout tweaks, copy tweaks, misc.
* When you scroll down the diff view, the controls will pin to the top.
* The revisions meta view was cleaned up. Copy changes.
* Loading indicator in the center of the screen (so it follows as you scroll).
* Tooltips "flip" when you cross the center line, so that they don't hit the container edge and wrap for later revisions.
* The "Restore" button's inactive state is handled on render, instead of after.
* Make sure we always have a current revision, even if the timestamp doesn't work out on the most recent one.
See #24804. Props markjaquith, nacin, ocean90, aaroncampbell.
git-svn-id: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 07:05:45 +02:00
< div class = " author-info " >
2013-07-28 22:15:28 +02:00
< # if ( data.attributes.autosave ) { #>
2013-07-24 08:08:14 +02:00
< span class = " byline " >< ? php printf ( __ ( 'Autosave by %s' ),
2013-07-28 22:15:28 +02:00
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?> </span>
< # } else if ( data.attributes.current ) { #>
2013-07-24 08:08:14 +02:00
< span class = " byline " >< ? php printf ( __ ( 'Current Revision by %s' ),
2013-07-28 22:15:28 +02:00
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?> </span>
2013-07-24 08:08:14 +02:00
< # } else { #>
Revisions: Pinned controls, layout tweaks, copy tweaks, misc.
* When you scroll down the diff view, the controls will pin to the top.
* The revisions meta view was cleaned up. Copy changes.
* Loading indicator in the center of the screen (so it follows as you scroll).
* Tooltips "flip" when you cross the center line, so that they don't hit the container edge and wrap for later revisions.
* The "Restore" button's inactive state is handled on render, instead of after.
* Make sure we always have a current revision, even if the timestamp doesn't work out on the most recent one.
See #24804. Props markjaquith, nacin, ocean90, aaroncampbell.
git-svn-id: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 07:05:45 +02:00
< span class = " byline " >< ? php printf ( __ ( 'Revision by %s' ),
2013-07-28 22:15:28 +02:00
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?> </span>
2013-07-24 08:08:14 +02:00
< # } #>
2013-07-28 22:15:28 +02:00
< span class = " time-ago " > {{ data . attributes . timeAgo }} </ span >
< span class = " date " > ({{ data . attributes . dateShort }}) </ span >
Revisions: Pinned controls, layout tweaks, copy tweaks, misc.
* When you scroll down the diff view, the controls will pin to the top.
* The revisions meta view was cleaned up. Copy changes.
* Loading indicator in the center of the screen (so it follows as you scroll).
* Tooltips "flip" when you cross the center line, so that they don't hit the container edge and wrap for later revisions.
* The "Restore" button's inactive state is handled on render, instead of after.
* Make sure we always have a current revision, even if the timestamp doesn't work out on the most recent one.
See #24804. Props markjaquith, nacin, ocean90, aaroncampbell.
git-svn-id: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 07:05:45 +02:00
</ div >
2013-07-28 22:15:28 +02:00
< # if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
2013-07-28 23:51:44 +02:00
< input < ? php if ( wp_check_post_lock ( $post -> ID ) ) { ?>
2013-07-28 22:15:28 +02:00
disabled = " disabled "
2013-07-28 23:51:44 +02:00
< ? php } else { ?>
< # if ( data.attributes.current ) { #>
disabled = " disabled "
< # } #>
< ? php } ?>
2013-07-28 22:15:28 +02:00
< # if ( data.attributes.autosave ) { #>
type = " button " class = " restore-revision button button-primary " value = " <?php esc_attr_e( 'Restore This Autosave' ); ?> " />
2013-07-24 08:08:14 +02:00
< # } else { #>
2013-07-28 22:15:28 +02:00
type = " button " class = " restore-revision button button-primary " value = " <?php esc_attr_e( 'Restore This Revision' ); ?> " />
2013-07-24 08:08:14 +02:00
< # } #>
Revisions: Pinned controls, layout tweaks, copy tweaks, misc.
* When you scroll down the diff view, the controls will pin to the top.
* The revisions meta view was cleaned up. Copy changes.
* Loading indicator in the center of the screen (so it follows as you scroll).
* Tooltips "flip" when you cross the center line, so that they don't hit the container edge and wrap for later revisions.
* The "Restore" button's inactive state is handled on render, instead of after.
* Make sure we always have a current revision, even if the timestamp doesn't work out on the most recent one.
See #24804. Props markjaquith, nacin, ocean90, aaroncampbell.
git-svn-id: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 07:05:45 +02:00
< # } #>
2013-03-21 16:54:11 +01:00
</ div >
2013-07-28 22:15:28 +02:00
< # if ( 'tooltip' === data.type ) { #>
< div class = " revisions-tooltip-arrow " >< span ></ span ></ div >
< # } #>
< # } #>
2013-02-28 16:14:34 +01:00
</ script >
2013-07-03 22:27:19 +02:00
< script id = " tmpl-revisions-diff " type = " text/html " >
2013-07-18 18:35:19 +02:00
< div class = " loading-indicator " >< span class = " spinner " ></ span ></ div >
< div class = " diff-error " >< ? php _e ( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?> </div>
2013-07-12 07:11:56 +02:00
< div class = " diff " >
2013-07-03 22:27:19 +02:00
< # _.each( data.fields, function( field ) { #>
2013-07-18 16:01:58 +02:00
< h3 > {{ field . name }} </ h3 >
2013-07-03 22:27:19 +02:00
{{{ field . diff }}}
< # }); #>
2013-07-12 07:11:56 +02:00
</ div >
2013-03-21 16:54:11 +01:00
</ script >
2013-04-04 09:53:49 +02:00
2013-07-03 22:27:19 +02:00
2008-05-30 01:16:11 +02:00
< ? php
2013-09-25 02:18:11 +02:00
require_once ( ABSPATH . 'wp-admin/admin-footer.php' );