2013-06-26 17:06:50 -04:00
|
|
|
<?php
|
2013-07-17 16:39:35 -04:00
|
|
|
/**
|
2013-09-12 18:59:08 -04:00
|
|
|
* WordPress Administration Revisions API
|
2013-07-17 16:39:35 -04:00
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
*/
|
2013-06-26 17:06:50 -04:00
|
|
|
|
2013-07-17 16:39:35 -04:00
|
|
|
/**
|
|
|
|
* Get the revision UI diff.
|
|
|
|
*
|
2013-07-27 19:11:03 -04:00
|
|
|
* @since 3.6.0
|
|
|
|
*
|
2013-09-12 18:59:08 -04:00
|
|
|
* @param object|int $post The post object. Also accepts a post ID.
|
|
|
|
* @param int $compare_from The revision ID to compare from.
|
|
|
|
* @param int $compare_to The revision ID to come to.
|
2013-07-17 16:39:35 -04:00
|
|
|
*
|
|
|
|
* @return array|bool Associative array of a post's revisioned fields and their diffs.
|
2013-09-12 18:59:08 -04:00
|
|
|
* Or, false on failure.
|
2013-07-17 16:39:35 -04:00
|
|
|
*/
|
2013-06-26 17:06:50 -04:00
|
|
|
function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) {
|
|
|
|
if ( ! $post = get_post( $post ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( $compare_from ) {
|
|
|
|
if ( ! $compare_from = get_post( $compare_from ) )
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
// If we're dealing with the first revision...
|
|
|
|
$compare_from = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! $compare_to = get_post( $compare_to ) )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// If comparing revisions, make sure we're dealing with the right post parent.
|
2013-07-24 02:08:14 -04:00
|
|
|
// 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 )
|
2013-06-26 17:06:50 -04:00
|
|
|
return false;
|
2013-07-24 02:08:14 -04:00
|
|
|
if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID )
|
2013-06-26 17:06:50 -04:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) {
|
|
|
|
$temp = $compare_from;
|
|
|
|
$compare_from = $compare_to;
|
|
|
|
$compare_to = $temp;
|
|
|
|
}
|
|
|
|
|
2013-07-06 06:48:14 -04:00
|
|
|
// Add default title if title field is empty
|
|
|
|
if ( $compare_from && empty( $compare_from->post_title ) )
|
|
|
|
$compare_from->post_title = __( '(no title)' );
|
|
|
|
if ( empty( $compare_to->post_title ) )
|
|
|
|
$compare_to->post_title = __( '(no title)' );
|
|
|
|
|
2013-06-26 17:06:50 -04:00
|
|
|
$return = array();
|
|
|
|
|
|
|
|
foreach ( _wp_post_revision_fields() as $field => $name ) {
|
2013-09-23 18:45:10 -04:00
|
|
|
/**
|
|
|
|
* Contextually filter a post revision field.
|
|
|
|
*
|
2014-11-30 06:28:24 -05:00
|
|
|
* The dynamic portion of the hook name, `$field`, corresponds to each of the post
|
2013-09-23 18:45:10 -04:00
|
|
|
* fields of the revision object being iterated over in a foreach statement.
|
|
|
|
*
|
|
|
|
* @since 3.6.0
|
|
|
|
*
|
|
|
|
* @param string $compare_from->$field The current revision field to compare to or from.
|
|
|
|
* @param string $field The current revision field.
|
|
|
|
* @param WP_Post $compare_from The revision post object to compare to or from.
|
2014-11-30 06:28:24 -05:00
|
|
|
* @param string null The context of whether the current revision is the old
|
|
|
|
* or the new one. Values are 'to' or 'from'.
|
2013-09-23 18:45:10 -04:00
|
|
|
*/
|
2013-07-28 19:28:21 -04:00
|
|
|
$content_from = $compare_from ? apply_filters( "_wp_post_revision_field_$field", $compare_from->$field, $field, $compare_from, 'from' ) : '';
|
2013-09-23 18:45:10 -04:00
|
|
|
|
2013-10-24 18:59:20 -04:00
|
|
|
/** This filter is documented in wp-admin/includes/revision.php */
|
2013-07-28 19:28:21 -04:00
|
|
|
$content_to = apply_filters( "_wp_post_revision_field_$field", $compare_to->$field, $field, $compare_to, 'to' );
|
2013-06-26 17:06:50 -04:00
|
|
|
|
2014-11-19 18:21:23 -05:00
|
|
|
$args = array(
|
2014-12-04 09:36:24 -05:00
|
|
|
'show_split_view' => true
|
2014-11-19 18:21:23 -05:00
|
|
|
);
|
2014-11-20 22:50:24 -05:00
|
|
|
|
2014-11-19 18:21:23 -05:00
|
|
|
/**
|
|
|
|
* Filter revisions text diff options.
|
|
|
|
*
|
2014-11-20 22:50:24 -05:00
|
|
|
* Filter the options passed to {@see wp_text_diff()} when viewing a post revision.
|
2014-11-19 18:21:23 -05:00
|
|
|
*
|
|
|
|
* @since 4.1.0
|
|
|
|
*
|
|
|
|
* @param array $args {
|
2014-11-20 22:50:24 -05:00
|
|
|
* Associative array of options to pass to {@see wp_text_diff()}.
|
2014-11-19 18:21:23 -05:00
|
|
|
*
|
2014-12-04 09:36:24 -05:00
|
|
|
* @type bool $show_split_view True for split view (two columns), false for
|
|
|
|
* un-split view (single column). Default true.
|
2014-11-19 18:21:23 -05:00
|
|
|
* }
|
|
|
|
* @param string $field The current revision field.
|
|
|
|
* @param WP_Post $compare_from The revision post to compare from.
|
|
|
|
* @param WP_Post $compare_to The revision post to compare to.
|
|
|
|
*/
|
|
|
|
$args = apply_filters( 'revision_text_diff_options', $args, $field, $compare_from, $compare_to );
|
2014-11-20 22:50:24 -05:00
|
|
|
|
2014-11-19 18:21:23 -05:00
|
|
|
$diff = wp_text_diff( $content_from, $content_to, $args );
|
2013-06-26 17:06:50 -04:00
|
|
|
|
|
|
|
if ( ! $diff && 'post_title' === $field ) {
|
|
|
|
// It's a better user experience to still show the Title, even if it didn't change.
|
|
|
|
// No, you didn't see this.
|
2013-06-29 13:45:02 -04:00
|
|
|
$diff = '<table class="diff"><colgroup><col class="content diffsplit left"><col class="content diffsplit middle"><col class="content diffsplit right"></colgroup><tbody><tr>';
|
2013-06-26 17:06:50 -04:00
|
|
|
$diff .= '<td>' . esc_html( $compare_from->post_title ) . '</td><td></td><td>' . esc_html( $compare_to->post_title ) . '</td>';
|
|
|
|
$diff .= '</tr></tbody>';
|
|
|
|
$diff .= '</table>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $diff ) {
|
|
|
|
$return[] = array(
|
|
|
|
'id' => $field,
|
|
|
|
'name' => $name,
|
|
|
|
'diff' => $diff,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2014-10-29 15:02:21 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter the fields displayed in the post revision diff UI.
|
|
|
|
*
|
|
|
|
* @since 4.1.0
|
|
|
|
*
|
|
|
|
* @param array $return Revision UI fields. Each item is an array of id, name and diff.
|
|
|
|
* @param WP_Post $compare_from The revision post to compare from.
|
|
|
|
* @param WP_Post $compare_to The revision post to compare to.
|
|
|
|
*/
|
|
|
|
return apply_filters( 'wp_get_revision_ui_diff', $return, $compare_from, $compare_to );
|
|
|
|
|
2013-06-26 17:06:50 -04:00
|
|
|
}
|
|
|
|
|
2013-07-17 16:39:35 -04:00
|
|
|
/**
|
|
|
|
* Prepare revisions for JavaScript.
|
|
|
|
*
|
2013-07-27 19:11:03 -04:00
|
|
|
* @since 3.6.0
|
|
|
|
*
|
2013-09-12 19:15:10 -04:00
|
|
|
* @param object|int $post The post object. Also accepts a post ID.
|
|
|
|
* @param int $selected_revision_id The selected revision ID.
|
|
|
|
* @param int $from Optional. The revision ID to compare from.
|
2013-07-17 16:39:35 -04:00
|
|
|
*
|
2013-07-17 17:09:14 -04:00
|
|
|
* @return array An associative array of revision data and related settings.
|
2013-07-17 16:39:35 -04:00
|
|
|
*/
|
2013-07-11 18:56:48 -04:00
|
|
|
function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null ) {
|
2013-06-26 17:06:50 -04:00
|
|
|
$post = get_post( $post );
|
2014-05-05 23:45:14 -04:00
|
|
|
$authors = array();
|
2013-07-11 16:57:47 -04:00
|
|
|
$now_gmt = time();
|
2013-06-26 17:06:50 -04:00
|
|
|
|
2013-07-24 02:08:14 -04:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2013-07-15 19:01:27 -04:00
|
|
|
$show_avatars = get_option( 'show_avatars' );
|
2013-06-26 17:06:50 -04:00
|
|
|
|
|
|
|
cache_users( wp_list_pluck( $revisions, 'post_author' ) );
|
|
|
|
|
2013-07-24 02:08:14 -04:00
|
|
|
$can_restore = current_user_can( 'edit_post', $post->ID );
|
2014-05-19 01:04:16 -04:00
|
|
|
$current_id = false;
|
2013-07-24 02:08:14 -04:00
|
|
|
|
2013-06-26 17:06:50 -04:00
|
|
|
foreach ( $revisions as $revision ) {
|
2013-07-12 01:11:56 -04:00
|
|
|
$modified = strtotime( $revision->post_modified );
|
2013-06-26 17:06:50 -04:00
|
|
|
$modified_gmt = strtotime( $revision->post_modified_gmt );
|
2013-07-24 02:08:14 -04:00
|
|
|
if ( $can_restore ) {
|
|
|
|
$restore_link = str_replace( '&', '&', wp_nonce_url(
|
|
|
|
add_query_arg(
|
|
|
|
array( 'revision' => $revision->ID,
|
|
|
|
'action' => 'restore' ),
|
|
|
|
admin_url( 'revision.php' )
|
|
|
|
),
|
|
|
|
"restore-post_{$revision->ID}"
|
|
|
|
) );
|
|
|
|
}
|
2013-07-15 19:01:27 -04:00
|
|
|
|
|
|
|
if ( ! isset( $authors[ $revision->post_author ] ) ) {
|
|
|
|
$authors[ $revision->post_author ] = array(
|
|
|
|
'id' => (int) $revision->post_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: http://core.svn.wordpress.org/trunk@24761 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-22 01:05:45 -04:00
|
|
|
'avatar' => $show_avatars ? get_avatar( $revision->post_author, 32 ) : '',
|
2013-07-15 19:01:27 -04:00
|
|
|
'name' => get_the_author_meta( 'display_name', $revision->post_author ),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2013-07-24 02:08:14 -04:00
|
|
|
$autosave = (bool) wp_is_post_autosave( $revision );
|
2013-07-18 10:10:33 -04:00
|
|
|
$current = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt;
|
|
|
|
if ( $current && ! empty( $current_id ) ) {
|
2013-07-24 02:08:14 -04:00
|
|
|
// If multiple revisions have the same post_modified_gmt, highest ID is current.
|
2013-07-18 10:10:33 -04:00
|
|
|
if ( $current_id < $revision->ID ) {
|
|
|
|
$revisions[ $current_id ]['current'] = false;
|
|
|
|
$current_id = $revision->ID;
|
|
|
|
} else {
|
|
|
|
$current = false;
|
|
|
|
}
|
|
|
|
} elseif ( $current ) {
|
|
|
|
$current_id = $revision->ID;
|
|
|
|
}
|
|
|
|
|
2013-06-26 17:06:50 -04:00
|
|
|
$revisions[ $revision->ID ] = array(
|
2013-07-15 19:01:27 -04:00
|
|
|
'id' => $revision->ID,
|
|
|
|
'title' => get_the_title( $post->ID ),
|
|
|
|
'author' => $authors[ $revision->post_author ],
|
|
|
|
'date' => date_i18n( __( 'M j, Y @ G:i' ), $modified ),
|
|
|
|
'dateShort' => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified ),
|
|
|
|
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
|
2013-07-18 10:10:33 -04:00
|
|
|
'autosave' => $autosave,
|
|
|
|
'current' => $current,
|
2013-07-24 02:08:14 -04:00
|
|
|
'restoreUrl' => $can_restore ? $restore_link : false,
|
2013-06-26 17:06:50 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-11-15 22:36:23 -05:00
|
|
|
/**
|
|
|
|
* If we only have one revision, the initial revision is missing; This happens
|
|
|
|
* when we have an autsosave and the user has clicked 'View the Autosave'
|
|
|
|
*/
|
|
|
|
if ( 1 === sizeof( $revisions ) ) {
|
|
|
|
$revisions[ $post->ID ] = array(
|
|
|
|
'id' => $post->ID,
|
|
|
|
'title' => get_the_title( $post->ID ),
|
|
|
|
'author' => $authors[ $post->post_author ],
|
2015-01-10 00:50:22 -05:00
|
|
|
'date' => date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_modified ) ),
|
|
|
|
'dateShort' => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), strtotime( $post->post_modified ) ),
|
2014-11-15 22:36:23 -05:00
|
|
|
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ),
|
|
|
|
'autosave' => false,
|
|
|
|
'current' => true,
|
|
|
|
'restoreUrl' => false,
|
|
|
|
);
|
|
|
|
$current_id = $post->ID;
|
|
|
|
}
|
|
|
|
|
2014-07-17 05:14:16 -04:00
|
|
|
/*
|
|
|
|
* 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".
|
|
|
|
*/
|
2013-07-24 02:08:14 -04:00
|
|
|
if ( empty( $current_id ) ) {
|
|
|
|
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;
|
|
|
|
}
|
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 01:05:45 -04:00
|
|
|
|
2014-07-17 05:14:16 -04:00
|
|
|
// Now, grab the initial diff.
|
2013-07-12 10:01:39 -04:00
|
|
|
$compare_two_mode = is_numeric( $from );
|
|
|
|
if ( ! $compare_two_mode ) {
|
2013-07-29 13:26:03 -04:00
|
|
|
$found = array_search( $selected_revision_id, array_keys( $revisions ) );
|
2013-07-29 13:53:24 -04:00
|
|
|
if ( $found ) {
|
|
|
|
$from = array_keys( array_slice( $revisions, $found - 1, 1, true ) );
|
|
|
|
$from = reset( $from );
|
|
|
|
} else {
|
2013-07-29 13:26:03 -04:00
|
|
|
$from = 0;
|
2013-07-29 13:53:24 -04:00
|
|
|
}
|
2013-07-12 10:01:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$from = absint( $from );
|
2013-07-12 01:11:56 -04:00
|
|
|
|
2013-07-11 18:56:48 -04:00
|
|
|
$diffs = array( array(
|
2013-07-12 01:11:56 -04:00
|
|
|
'id' => $from . ':' . $selected_revision_id,
|
|
|
|
'fields' => wp_get_revision_ui_diff( $post->ID, $from, $selected_revision_id ),
|
2013-07-11 18:56:48 -04:00
|
|
|
));
|
|
|
|
|
2013-06-26 17:06:50 -04:00
|
|
|
return array(
|
|
|
|
'postId' => $post->ID,
|
|
|
|
'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ),
|
|
|
|
'revisionData' => array_values( $revisions ),
|
2013-07-11 18:56:48 -04:00
|
|
|
'to' => $selected_revision_id,
|
|
|
|
'from' => $from,
|
|
|
|
'diffData' => $diffs,
|
|
|
|
'baseUrl' => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ),
|
|
|
|
'compareTwoMode' => absint( $compare_two_mode ), // Apparently booleans are not allowed
|
2013-07-12 01:11:56 -04:00
|
|
|
'revisionIds' => array_keys( $revisions ),
|
2013-06-26 17:06:50 -04:00
|
|
|
);
|
2013-06-29 13:45:02 -04:00
|
|
|
}
|
2014-10-31 20:15:24 -04:00
|
|
|
|
|
|
|
/**
|
2014-12-01 19:31:22 -05:00
|
|
|
* Print JavaScript templates required for the revisions experience.
|
2014-10-31 20:15:24 -04:00
|
|
|
*
|
|
|
|
* @since 4.1.0
|
2014-11-28 04:05:23 -05:00
|
|
|
*
|
|
|
|
* @global WP_Post $post The global `$post` object.
|
2014-10-31 20:15:24 -04:00
|
|
|
*/
|
|
|
|
function wp_print_revision_templates() {
|
|
|
|
global $post;
|
|
|
|
?><script id="tmpl-revisions-frame" type="text/html">
|
|
|
|
<div class="revisions-control-frame"></div>
|
|
|
|
<div class="revisions-diff-frame"></div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script id="tmpl-revisions-buttons" type="text/html">
|
|
|
|
<div class="revisions-previous">
|
|
|
|
<input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="revisions-next">
|
|
|
|
<input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" />
|
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script id="tmpl-revisions-checkbox" type="text/html">
|
|
|
|
<div class="revision-toggle-compare-mode">
|
|
|
|
<label>
|
|
|
|
<input type="checkbox" class="compare-two-revisions"
|
|
|
|
<#
|
|
|
|
if ( 'undefined' !== typeof data && data.model.attributes.compareTwoMode ) {
|
|
|
|
#> checked="checked"<#
|
|
|
|
}
|
|
|
|
#>
|
|
|
|
/>
|
|
|
|
<?php esc_attr_e( 'Compare any two revisions' ); ?>
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script id="tmpl-revisions-meta" type="text/html">
|
|
|
|
<# if ( ! _.isUndefined( data.attributes ) ) { #>
|
|
|
|
<div class="diff-title">
|
|
|
|
<# 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 }}}
|
|
|
|
<div class="author-info">
|
|
|
|
<# if ( data.attributes.autosave ) { #>
|
|
|
|
<span class="byline"><?php printf( __( 'Autosave by %s' ),
|
|
|
|
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
|
|
|
|
<# } else if ( data.attributes.current ) { #>
|
|
|
|
<span class="byline"><?php printf( __( 'Current Revision by %s' ),
|
|
|
|
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
|
|
|
|
<# } else { #>
|
|
|
|
<span class="byline"><?php printf( __( 'Revision by %s' ),
|
|
|
|
'<span class="author-name">{{ data.attributes.author.name }}</span>' ); ?></span>
|
|
|
|
<# } #>
|
|
|
|
<span class="time-ago">{{ data.attributes.timeAgo }}</span>
|
|
|
|
<span class="date">({{ data.attributes.dateShort }})</span>
|
|
|
|
</div>
|
|
|
|
<# if ( 'to' === data.type && data.attributes.restoreUrl ) { #>
|
|
|
|
<input <?php if ( wp_check_post_lock( $post->ID ) ) { ?>
|
|
|
|
disabled="disabled"
|
|
|
|
<?php } else { ?>
|
|
|
|
<# if ( data.attributes.current ) { #>
|
|
|
|
disabled="disabled"
|
|
|
|
<# } #>
|
|
|
|
<?php } ?>
|
|
|
|
<# if ( data.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>
|
|
|
|
<# if ( 'tooltip' === data.type ) { #>
|
|
|
|
<div class="revisions-tooltip-arrow"><span></span></div>
|
|
|
|
<# } #>
|
|
|
|
<# } #>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script id="tmpl-revisions-diff" type="text/html">
|
|
|
|
<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>
|
|
|
|
<div class="diff">
|
|
|
|
<# _.each( data.fields, function( field ) { #>
|
|
|
|
<h3>{{ field.name }}</h3>
|
|
|
|
{{{ field.diff }}}
|
|
|
|
<# }); #>
|
|
|
|
</div>
|
|
|
|
</script><?php
|
|
|
|
}
|