2008-04-19 01:38:21 +02:00
< ? php
2008-08-16 09:27:34 +02:00
/**
* Revisions administration panel .
*
* @ package WordPress
* @ subpackage Administration
*/
2008-04-19 01:38:21 +02:00
2008-08-16 09:27:34 +02:00
/** WordPress Administration Bootstrap */
2010-04-18 08:14:45 +02:00
require_once ( './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-03-21 16:54:11 +01:00
// Revisions disabled (previously checked autosavegs && ! 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-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-05-04 01:00:14 +02:00
$revisions_overview .= '<li>' . __ ( 'Compare two different revisions by <strong>selecting the “Compare two revisions” box</strong> to the side.' ) . '</li>' ;
$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-04-04 17:49:28 +02:00
require_once ( './admin-header.php' );
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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
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-tooltip " type = " text/html " >
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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
2013-07-22 07:05:45 +02:00
< div class = " author-card " >
2013-07-03 22:27:19 +02:00
< # if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
2013-07-22 07:05:45 +02:00
{{{ data . author . avatar }}}
< div class = " author-info " >
2013-07-22 07:32:14 +02:00
< span class = " byline " >< ? php printf ( __ ( 'Revision by %s' ),
'<span class="author-name">{{ data.author.name }}</span>' ); ?> </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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
2013-07-22 07:05:45 +02:00
< span class = " time-ago " > {{ data . timeAgo }} </ span >
< span class = " date " > ({{ data . dateShort }}) </ span >
</ div >
2013-07-03 22:27:19 +02:00
< # } #>
2013-02-28 16:14:34 +01:00
</ div >
2013-07-19 15:49:15 +02:00
< div class = " revisions-tooltip-arrow " >< span ></ span ></ div >
2013-06-26 23:06:50 +02:00
</ script >
2008-05-30 01:16:11 +02:00
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-04-04 09:53:49 +02:00
< ? php esc_attr_e ( 'Compare two revisions' ); ?>
</ 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 " >
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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
2013-07-22 07:05:45 +02:00
< div class = " diff-meta diff-meta-from " >
< div class = " diff-title " >
< strong >< ? php _ex ( 'From:' , 'Followed by post revision info' ); ?> </strong>
< # if ( 'undefined' !== typeof data.from ) { #>
< div class = " author-card " >
{{{ data . from . attributes . author . avatar }}}
< div class = " author-info " >
< span class = " byline " >< ? php printf ( __ ( 'Revision by %s' ),
2013-07-22 07:32:14 +02:00
'<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?> </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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
2013-07-22 07:05:45 +02:00
< span class = " time-ago " > {{ data . from . attributes . timeAgo }} </ span >
< span class = " date " > ({{ data . from . attributes . dateShort }}) </ span >
</ div >
2013-04-28 12:56:57 +02:00
</ div >
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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
2013-07-22 07:05:45 +02:00
< # } #>
2013-03-21 16:54:11 +01:00
</ div >
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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
2013-07-22 07:05:45 +02:00
</ div >
2013-03-21 16:54:11 +01: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: https://develop.svn.wordpress.org/trunk@24761 602fd350-edb4-49c9-b593-d223f7449a82
2013-07-22 07:05:45 +02:00
< div class = " diff-meta diff-meta-to " >
< div class = " diff-title " >
< strong >< ? php _ex ( 'To:' , 'Followed by post revision info' ); ?> </strong>
< # if ( 'undefined' !== typeof data.to ) { #>
< div class = " author-card " >
{{{ data . to . attributes . author . avatar }}}
< div class = " author-info " >
< span class = " byline " >< ? php printf ( __ ( 'Revision by %s' ),
'<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?> </span>
< span class = " time-ago " > {{ data . to . attributes . timeAgo }} </ span >
< span class = " date " > ({{ data . to . attributes . dateShort }}) </ span >
</ div >
< # } #>
< input
< # if ( data.to.attributes.current ) { #>
disabled = " disabled "
< # } #>
type = " button " class = " restore-revision button button-primary " data - restore - link = " { { { data.restoreLink }}} " value = " <?php esc_attr_e( 'Restore This Revision' ); ?> " />
2013-03-21 16:54:11 +01:00
</ div >
2013-04-28 12:56:57 +02:00
</ 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-04-04 09:53:49 +02:00
require_once ( './admin-footer.php' );