Revisions changes.

* Eliminates the bloated Revisions meta box in favor of 'Revisions: #' in the publish box.
 * Adds ability to compare autosave to current post, when revisions are disabled.
 * Makes autosaves stand out visually, including "Restore This Autosave".

Also:
 * Adds missing capability check for restoring a revision.
 * When no revision matches the post's current modified time, avoid marking an autosave as 'current'.
 * Fixes wp_get_post_autosave() to return an autosave even when revisions are disabled.
 * Add 'check_enabled' arg to wp_get_post_revisions(); false avoids the wp_revisions_enabled() check.
 * Adds a responsive slider that is narrower for fewer versions. props markjaquith.

see #24804.



git-svn-id: https://develop.svn.wordpress.org/trunk@24790 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Nacin
2013-07-24 06:08:14 +00:00
parent 2b63b67768
commit 5ca8aa7447
8 changed files with 140 additions and 49 deletions

View File

@@ -31,7 +31,7 @@ case 'restore' :
if ( ! $post = get_post( $revision->post_parent ) )
break;
// Revisions disabled (previously checked autosavegs && ! wp_is_post_autosave( $revision ))
// Revisions disabled (previously checked autosaves && ! wp_is_post_autosave( $revision ))
if ( ! wp_revisions_enabled( $post ) ) {
$redirect = 'edit.php?post_type=' . $post->post_type;
break;
@@ -133,14 +133,23 @@ require_once( './admin-header.php' );
<script id="tmpl-revisions-tooltip" type="text/html">
<div class="author-card">
<# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
{{{ data.author.avatar }}}
<div class="author-info">
<span class="byline"><?php printf( __( 'Revision by %s' ),
'<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
<span class="time-ago">{{ data.timeAgo }}</span>
<span class="date">({{ data.dateShort }})</span>
</div>
<div class="author-card<# if ( data.autosave ) { #> autosave<# } #>">
{{{ data.author.avatar }}}
<div class="author-info">
<# if ( data.autosave ) { #>
<span class="byline"><?php printf( __( 'Autosave by %s' ),
'<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
<# } else if ( data.current ) { #>
<span class="byline"><?php printf( __( 'Current Revision by %s' ),
'<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
<# } else { #>
<span class="byline"><?php printf( __( 'Revision by %s' ),
'<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
<# } #>
<span class="time-ago">{{ data.timeAgo }}</span>
<span class="date">({{ data.dateShort }})</span>
</div>
</div>
<# } #>
</div>
<div class="revisions-tooltip-arrow"><span></span></div>
@@ -166,11 +175,19 @@ require_once( './admin-header.php' );
<div class="diff-title">
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
<# if ( 'undefined' !== typeof data.from ) { #>
<div class="author-card">
<div class="author-card<# if ( data.from.attributes.autosave ) { #> autosave<# } #>">
{{{ data.from.attributes.author.avatar }}}
<div class="author-info">
<# if ( data.from.attributes.autosave ) { #>
<span class="byline"><?php printf( __( 'Autosave by %s' ),
'<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
<# } else if ( data.from.attributes.current ) { #>
<span class="byline"><?php printf( __( 'Current Revision by %s' ),
'<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
<# } else { #>
<span class="byline"><?php printf( __( 'Revision by %s' ),
'<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
<# } #>
<span class="time-ago">{{ data.from.attributes.timeAgo }}</span>
<span class="date">({{ data.from.attributes.dateShort }})</span>
</div>
@@ -183,20 +200,34 @@ require_once( './admin-header.php' );
<div class="diff-title">
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
<# if ( 'undefined' !== typeof data.to ) { #>
<div class="author-card">
<div class="author-card<# if ( data.to.attributes.autosave ) { #> autosave<# } #>">
{{{ data.to.attributes.author.avatar }}}
<div class="author-info">
<# if ( data.to.attributes.autosave ) { #>
<span class="byline"><?php printf( __( 'Autosave by %s' ),
'<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
<# } else if ( data.to.attributes.current ) { #>
<span class="byline"><?php printf( __( 'Current Revision by %s' ),
'<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
<# } else { #>
<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>
<# } #>
<# if ( data.to.attributes.restoreUrl ) { #>
<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' ); ?>" />
<# if ( data.to.attributes.autosave ) { #>
type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" />
<# } else { #>
type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" />
<# } #>
<# } #>
</div>
</div>
</script>