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: http://core.svn.wordpress.org/trunk@24790 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
290d61138c
commit
c8fe64a602
|
@ -3539,7 +3539,7 @@ td.plugin-title p {
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
height: 0.8em;
|
height: 0.8em;
|
||||||
top: 7px;
|
top: 7px;
|
||||||
width: 70%;
|
max-width: 70%;
|
||||||
-moz-box-sizing: border-box;
|
-moz-box-sizing: border-box;
|
||||||
-webkit-box-sizing: border-box;
|
-webkit-box-sizing: border-box;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -3641,6 +3641,11 @@ body.folded .revisions .loading-indicator {
|
||||||
.revisions-controls .author-card .date {
|
.revisions-controls .author-card .date {
|
||||||
color: #777;
|
color: #777;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.revisions-controls .author-card.autosave {
|
||||||
|
color: #d54e21;
|
||||||
|
}
|
||||||
|
|
||||||
.revisions-controls .author-card .author-name {
|
.revisions-controls .author-card .author-name {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
@ -3663,8 +3668,8 @@ body.folded .revisions .loading-indicator {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wp-slider {
|
.revisions-controls .wp-slider {
|
||||||
width: 70%;
|
max-width: 70%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
top: -3px;
|
top: -3px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,13 +109,30 @@ $post_type_object = get_post_type_object($post_type);
|
||||||
// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
|
// All meta boxes should be defined and added before the first do_meta_boxes() call (or potentially during the do_meta_boxes action).
|
||||||
require_once('./includes/meta-boxes.php');
|
require_once('./includes/meta-boxes.php');
|
||||||
|
|
||||||
|
|
||||||
|
$publish_callback_args = null;
|
||||||
|
if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
|
||||||
|
$revisions = wp_get_post_revisions( $post_ID );
|
||||||
|
|
||||||
|
// Check if the revisions have been upgraded
|
||||||
|
if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 )
|
||||||
|
_wp_upgrade_revisions_of_post( $post, $revisions );
|
||||||
|
|
||||||
|
// We should aim to show the revisions metabox only when there are revisions.
|
||||||
|
if ( count( $revisions ) > 1 ) {
|
||||||
|
reset( $revisions ); // Reset pointer for key()
|
||||||
|
$publish_callback_args = array( 'revisions_count' => count( $revisions ), 'revision_id' => key( $revisions ) );
|
||||||
|
// add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( 'attachment' == $post_type ) {
|
if ( 'attachment' == $post_type ) {
|
||||||
wp_enqueue_script( 'image-edit' );
|
wp_enqueue_script( 'image-edit' );
|
||||||
wp_enqueue_style( 'imgareaselect' );
|
wp_enqueue_style( 'imgareaselect' );
|
||||||
add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
|
add_meta_box( 'submitdiv', __('Save'), 'attachment_submit_meta_box', null, 'side', 'core' );
|
||||||
add_action( 'edit_form_after_title', 'edit_form_image_editor' );
|
add_action( 'edit_form_after_title', 'edit_form_image_editor' );
|
||||||
} else {
|
} else {
|
||||||
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core' );
|
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', null, 'side', 'core', $publish_callback_args );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
|
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) )
|
||||||
|
@ -172,18 +189,6 @@ if ( post_type_supports($post_type, 'author') ) {
|
||||||
add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
|
add_meta_box('authordiv', __('Author'), 'post_author_meta_box', null, 'normal', 'core');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( post_type_supports($post_type, 'revisions') && 'auto-draft' != $post->post_status ) {
|
|
||||||
$revisions = wp_get_post_revisions( $post_ID );
|
|
||||||
|
|
||||||
// Check if the revisions have been upgraded
|
|
||||||
if ( ! empty( $revisions ) && _wp_get_post_revision_version( end( $revisions ) ) < 1 )
|
|
||||||
_wp_upgrade_revisions_of_post( $post, $revisions );
|
|
||||||
|
|
||||||
// We should aim to show the revisions metabox only when there are revisions.
|
|
||||||
if ( count( $revisions ) > 1 )
|
|
||||||
add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
|
|
||||||
}
|
|
||||||
|
|
||||||
do_action('add_meta_boxes', $post_type, $post);
|
do_action('add_meta_boxes', $post_type, $post);
|
||||||
do_action('add_meta_boxes_' . $post_type, $post);
|
do_action('add_meta_boxes_' . $post_type, $post);
|
||||||
|
|
||||||
|
|
|
@ -2099,7 +2099,7 @@ function wp_ajax_get_revision_diffs() {
|
||||||
wp_send_json_error();
|
wp_send_json_error();
|
||||||
|
|
||||||
// Really just pre-loading the cache here.
|
// Really just pre-loading the cache here.
|
||||||
if ( ! $revisions = wp_get_post_revisions( $post->ID ) )
|
if ( ! $revisions = wp_get_post_revisions( $post->ID, array( 'check_enabled' => false ) ) )
|
||||||
wp_send_json_error();
|
wp_send_json_error();
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
* @param object $post
|
* @param object $post
|
||||||
*/
|
*/
|
||||||
function post_submit_meta_box($post) {
|
function post_submit_meta_box($post, $args = array() ) {
|
||||||
global $action;
|
global $action;
|
||||||
|
|
||||||
$post_type = $post->post_type;
|
$post_type = $post->post_type;
|
||||||
|
@ -171,6 +171,24 @@ if ( 0 != $post->ID ) {
|
||||||
$date = date_i18n( $datef, strtotime( current_time('mysql') ) );
|
$date = date_i18n( $datef, strtotime( current_time('mysql') ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $args['args']['revisions_count'] ) ) :
|
||||||
|
$revisions_to_keep = wp_revisions_to_keep( $post );
|
||||||
|
?>
|
||||||
|
<div class="misc-pub-section num-revisions">
|
||||||
|
<?php
|
||||||
|
if ( $revisions_to_keep > 0 && $revisions_to_keep <= $args['args']['revisions_count'] ) {
|
||||||
|
echo '<span title="' . esc_attr( sprintf( __( 'Your site is configured to keep only the last %s revisions.' ),
|
||||||
|
number_format_i18n( $revisions_to_keep ) ) ) . '">';
|
||||||
|
printf( __( 'Revisions: %s' ), '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '+</b>' );
|
||||||
|
echo '</span>';
|
||||||
|
} else {
|
||||||
|
printf( 'Revisions: %s', '<b>' . number_format_i18n( $args['args']['revisions_count'] ) . '</b>' );
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<a class="hide-if-no-js" href="<?php echo esc_url( get_edit_post_link( $args['args']['revision_id'] ) ); ?>"><?php _ex( 'Browse', 'revisions' ); ?></a>
|
||||||
|
</div>
|
||||||
|
<?php endif;
|
||||||
|
|
||||||
if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
|
if ( $can_publish ) : // Contributors don't get to choose the date of publish ?>
|
||||||
<div class="misc-pub-section curtime">
|
<div class="misc-pub-section curtime">
|
||||||
<span id="timestamp">
|
<span id="timestamp">
|
||||||
|
|
|
@ -32,9 +32,10 @@ function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// If comparing revisions, make sure we're dealing with the right post parent.
|
// If comparing revisions, make sure we're dealing with the right post parent.
|
||||||
if ( $compare_from && $compare_from->post_parent !== $post->ID )
|
// The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves.
|
||||||
|
if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID )
|
||||||
return false;
|
return false;
|
||||||
if ( $compare_to->post_parent !== $post->ID )
|
if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) {
|
if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) {
|
||||||
|
@ -91,22 +92,35 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||||
$revisions = $authors = array();
|
$revisions = $authors = array();
|
||||||
$now_gmt = time();
|
$now_gmt = time();
|
||||||
|
|
||||||
$revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC' ) );
|
$revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC', 'check_enabled' => false ) );
|
||||||
|
// If revisions are disabled, we only want autosaves and the current post.
|
||||||
|
if ( ! wp_revisions_enabled( $post ) ) {
|
||||||
|
foreach ( $revisions as $revision_id => $revision ) {
|
||||||
|
if ( ! wp_is_post_autosave( $revision ) )
|
||||||
|
unset( $revisions[ $revision_id ] );
|
||||||
|
}
|
||||||
|
$revisions = array( $post->ID => $post ) + $revisions;
|
||||||
|
}
|
||||||
|
|
||||||
$show_avatars = get_option( 'show_avatars' );
|
$show_avatars = get_option( 'show_avatars' );
|
||||||
|
|
||||||
cache_users( wp_list_pluck( $revisions, 'post_author' ) );
|
cache_users( wp_list_pluck( $revisions, 'post_author' ) );
|
||||||
|
|
||||||
|
$can_restore = current_user_can( 'edit_post', $post->ID );
|
||||||
|
|
||||||
foreach ( $revisions as $revision ) {
|
foreach ( $revisions as $revision ) {
|
||||||
$modified = strtotime( $revision->post_modified );
|
$modified = strtotime( $revision->post_modified );
|
||||||
$modified_gmt = strtotime( $revision->post_modified_gmt );
|
$modified_gmt = strtotime( $revision->post_modified_gmt );
|
||||||
$restore_link = str_replace( '&', '&', wp_nonce_url(
|
if ( $can_restore ) {
|
||||||
add_query_arg(
|
$restore_link = str_replace( '&', '&', wp_nonce_url(
|
||||||
array( 'revision' => $revision->ID,
|
add_query_arg(
|
||||||
'action' => 'restore' ),
|
array( 'revision' => $revision->ID,
|
||||||
admin_url( 'revision.php' )
|
'action' => 'restore' ),
|
||||||
),
|
admin_url( 'revision.php' )
|
||||||
"restore-post_{$revision->ID}"
|
),
|
||||||
) );
|
"restore-post_{$revision->ID}"
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! isset( $authors[ $revision->post_author ] ) ) {
|
if ( ! isset( $authors[ $revision->post_author ] ) ) {
|
||||||
$authors[ $revision->post_author ] = array(
|
$authors[ $revision->post_author ] = array(
|
||||||
|
@ -116,9 +130,10 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$autosave = wp_is_post_autosave( $revision );
|
$autosave = (bool) wp_is_post_autosave( $revision );
|
||||||
$current = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt;
|
$current = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt;
|
||||||
if ( $current && ! empty( $current_id ) ) {
|
if ( $current && ! empty( $current_id ) ) {
|
||||||
|
// If multiple revisions have the same post_modified_gmt, highest ID is current.
|
||||||
if ( $current_id < $revision->ID ) {
|
if ( $current_id < $revision->ID ) {
|
||||||
$revisions[ $current_id ]['current'] = false;
|
$revisions[ $current_id ]['current'] = false;
|
||||||
$current_id = $revision->ID;
|
$current_id = $revision->ID;
|
||||||
|
@ -138,14 +153,24 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
|
||||||
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
|
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
|
||||||
'autosave' => $autosave,
|
'autosave' => $autosave,
|
||||||
'current' => $current,
|
'current' => $current,
|
||||||
'restoreUrl' => urldecode( $restore_link ),
|
'restoreUrl' => $can_restore ? $restore_link : false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a post has been saved since the last revision (no revisioned fields were changed)
|
// If a post has been saved since the last revision (no revisioned fields were changed)
|
||||||
// we may not have a "current" revision. Mark the latest revision as "current".
|
// we may not have a "current" revision. Mark the latest revision as "current".
|
||||||
if ( empty( $current_id ) )
|
if ( empty( $current_id ) ) {
|
||||||
$revisions[ $revision->ID ]['current'] = true;
|
if ( $revisions[ $revision->ID ]['autosave'] ) {
|
||||||
|
$revision = end( $revisions );
|
||||||
|
while ( $revision['autosave'] ) {
|
||||||
|
$revision = prev( $revisions );
|
||||||
|
}
|
||||||
|
$current_id = $revision['id'];
|
||||||
|
} else {
|
||||||
|
$current_id = $revision->ID;
|
||||||
|
}
|
||||||
|
$revisions[ $current_id ]['current'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Now, grab the initial diff
|
// Now, grab the initial diff
|
||||||
$compare_two_mode = is_numeric( $from );
|
$compare_two_mode = is_numeric( $from );
|
||||||
|
|
|
@ -651,9 +651,11 @@ window.wp = window.wp || {};
|
||||||
var tickCount, tickWidth;
|
var tickCount, tickWidth;
|
||||||
tickCount = this.model.revisions.length - 1;
|
tickCount = this.model.revisions.length - 1;
|
||||||
tickWidth = 1 / tickCount;
|
tickWidth = 1 / tickCount;
|
||||||
|
this.$el.css('width', ( this.model.revisions.length * 50 ) + 'px');
|
||||||
|
|
||||||
_(tickCount).times( function( index ){
|
_(tickCount).times( function( index ){
|
||||||
this.$el.append( '<div style="' + this.direction + ': ' + ( 100 * tickWidth * index ) + '%"></div>' ); }, this );
|
this.$el.append( '<div style="' + this.direction + ': ' + ( 100 * tickWidth * index ) + '%"></div>' );
|
||||||
|
}, this );
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -831,6 +833,7 @@ window.wp = window.wp || {};
|
||||||
},
|
},
|
||||||
|
|
||||||
ready: function() {
|
ready: function() {
|
||||||
|
this.$el.css('width', ( this.model.revisions.length * 50 ) + 'px');
|
||||||
this.$el.slider( _.extend( this.model.toJSON(), {
|
this.$el.slider( _.extend( this.model.toJSON(), {
|
||||||
start: this.start,
|
start: this.start,
|
||||||
slide: this.slide,
|
slide: this.slide,
|
||||||
|
|
|
@ -31,7 +31,7 @@ case 'restore' :
|
||||||
if ( ! $post = get_post( $revision->post_parent ) )
|
if ( ! $post = get_post( $revision->post_parent ) )
|
||||||
break;
|
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 ) ) {
|
if ( ! wp_revisions_enabled( $post ) ) {
|
||||||
$redirect = 'edit.php?post_type=' . $post->post_type;
|
$redirect = 'edit.php?post_type=' . $post->post_type;
|
||||||
break;
|
break;
|
||||||
|
@ -133,14 +133,23 @@ require_once( './admin-header.php' );
|
||||||
<script id="tmpl-revisions-tooltip" type="text/html">
|
<script id="tmpl-revisions-tooltip" type="text/html">
|
||||||
<div class="author-card">
|
<div class="author-card">
|
||||||
<# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
|
<# if ( 'undefined' !== typeof data && 'undefined' !== typeof data.author ) { #>
|
||||||
{{{ data.author.avatar }}}
|
<div class="author-card<# if ( data.autosave ) { #> autosave<# } #>">
|
||||||
<div class="author-info">
|
{{{ data.author.avatar }}}
|
||||||
|
<div class="author-info">
|
||||||
<span class="byline"><?php printf( __( 'Revision by %s' ),
|
<# if ( data.autosave ) { #>
|
||||||
'<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
|
<span class="byline"><?php printf( __( 'Autosave by %s' ),
|
||||||
<span class="time-ago">{{ data.timeAgo }}</span>
|
'<span class="author-name">{{ data.author.name }}</span>' ); ?></span>
|
||||||
<span class="date">({{ data.dateShort }})</span>
|
<# } else if ( data.current ) { #>
|
||||||
</div>
|
<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>
|
||||||
<div class="revisions-tooltip-arrow"><span></span></div>
|
<div class="revisions-tooltip-arrow"><span></span></div>
|
||||||
|
@ -166,11 +175,19 @@ require_once( './admin-header.php' );
|
||||||
<div class="diff-title">
|
<div class="diff-title">
|
||||||
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
|
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong>
|
||||||
<# if ( 'undefined' !== typeof data.from ) { #>
|
<# if ( 'undefined' !== typeof data.from ) { #>
|
||||||
<div class="author-card">
|
<div class="author-card<# if ( data.from.attributes.autosave ) { #> autosave<# } #>">
|
||||||
{{{ data.from.attributes.author.avatar }}}
|
{{{ data.from.attributes.author.avatar }}}
|
||||||
<div class="author-info">
|
<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="byline"><?php printf( __( 'Revision by %s' ),
|
||||||
'<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
|
'<span class="author-name">{{ data.from.attributes.author.name }}</span>' ); ?></span>
|
||||||
|
<# } #>
|
||||||
<span class="time-ago">{{ data.from.attributes.timeAgo }}</span>
|
<span class="time-ago">{{ data.from.attributes.timeAgo }}</span>
|
||||||
<span class="date">({{ data.from.attributes.dateShort }})</span>
|
<span class="date">({{ data.from.attributes.dateShort }})</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -183,20 +200,34 @@ require_once( './admin-header.php' );
|
||||||
<div class="diff-title">
|
<div class="diff-title">
|
||||||
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
|
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong>
|
||||||
<# if ( 'undefined' !== typeof data.to ) { #>
|
<# if ( 'undefined' !== typeof data.to ) { #>
|
||||||
<div class="author-card">
|
<div class="author-card<# if ( data.to.attributes.autosave ) { #> autosave<# } #>">
|
||||||
{{{ data.to.attributes.author.avatar }}}
|
{{{ data.to.attributes.author.avatar }}}
|
||||||
<div class="author-info">
|
<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="byline"><?php printf( __( 'Revision by %s' ),
|
||||||
'<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
|
'<span class="author-name">{{ data.to.attributes.author.name }}</span>' ); ?></span>
|
||||||
|
<# } #>
|
||||||
<span class="time-ago">{{ data.to.attributes.timeAgo }}</span>
|
<span class="time-ago">{{ data.to.attributes.timeAgo }}</span>
|
||||||
<span class="date">({{ data.to.attributes.dateShort }})</span>
|
<span class="date">({{ data.to.attributes.dateShort }})</span>
|
||||||
</div>
|
</div>
|
||||||
<# } #>
|
<# } #>
|
||||||
|
<# if ( data.to.attributes.restoreUrl ) { #>
|
||||||
<input
|
<input
|
||||||
<# if ( data.to.attributes.current ) { #>
|
<# if ( data.to.attributes.current ) { #>
|
||||||
disabled="disabled"
|
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>
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -157,7 +157,7 @@ function wp_save_post_revision( $post_id ) {
|
||||||
* @return object|bool The autosaved data or false on failure or when no autosave exists.
|
* @return object|bool The autosaved data or false on failure or when no autosave exists.
|
||||||
*/
|
*/
|
||||||
function wp_get_post_autosave( $post_id, $user_id = 0 ) {
|
function wp_get_post_autosave( $post_id, $user_id = 0 ) {
|
||||||
$revisions = wp_get_post_revisions($post_id);
|
$revisions = wp_get_post_revisions( $post_id, array( 'check_enabled' => false ) );
|
||||||
|
|
||||||
foreach ( $revisions as $revision ) {
|
foreach ( $revisions as $revision ) {
|
||||||
if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) {
|
if ( false !== strpos( $revision->post_name, "{$post_id}-autosave" ) ) {
|
||||||
|
@ -369,11 +369,15 @@ function wp_delete_post_revision( $revision_id ) {
|
||||||
*/
|
*/
|
||||||
function wp_get_post_revisions( $post_id = 0, $args = null ) {
|
function wp_get_post_revisions( $post_id = 0, $args = null ) {
|
||||||
$post = get_post( $post_id );
|
$post = get_post( $post_id );
|
||||||
if ( ! $post || empty( $post->ID ) || ! wp_revisions_enabled( $post ) )
|
if ( ! $post || empty( $post->ID ) )
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
$defaults = array( 'order' => 'DESC', 'orderby' => 'date' );
|
$defaults = array( 'order' => 'DESC', 'orderby' => 'date', 'check_enabled' => true );
|
||||||
$args = wp_parse_args( $args, $defaults );
|
$args = wp_parse_args( $args, $defaults );
|
||||||
|
|
||||||
|
if ( $args['check_enabled'] && ! wp_revisions_enabled( $post ) )
|
||||||
|
return array();
|
||||||
|
|
||||||
$args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) );
|
$args = array_merge( $args, array( 'post_parent' => $post->ID, 'post_type' => 'revision', 'post_status' => 'inherit' ) );
|
||||||
|
|
||||||
if ( ! $revisions = get_children( $args ) )
|
if ( ! $revisions = get_children( $args ) )
|
||||||
|
|
Loading…
Reference in New Issue