mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-31 04:31:35 +01:00
Make sure the first revision is seen as coming from emptiness, so it can be restored.
props adamsilverstein. fixes #23898. git-svn-id: http://core.svn.wordpress.org/trunk@23872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8c4aeb9188
commit
925e7f5bd6
@ -2130,6 +2130,9 @@ function wp_ajax_revisions_data() {
|
|||||||
if ( 0 != $single_revision_id ) {
|
if ( 0 != $single_revision_id ) {
|
||||||
$right_revision = get_post( $single_revision_id );
|
$right_revision = get_post( $single_revision_id );
|
||||||
|
|
||||||
|
if ( 0 == $compare_to )
|
||||||
|
$left_revision = get_post( $post_id );
|
||||||
|
|
||||||
// make sure the right revision is the most recent
|
// make sure the right revision is the most recent
|
||||||
if ( $compare_two_mode && $right_revision->ID < $left_revision->ID ) {
|
if ( $compare_two_mode && $right_revision->ID < $left_revision->ID ) {
|
||||||
$temp = $left_revision;
|
$temp = $left_revision;
|
||||||
@ -2155,7 +2158,8 @@ function wp_ajax_revisions_data() {
|
|||||||
if ( ! empty( $show_split_view ) )
|
if ( ! empty( $show_split_view ) )
|
||||||
$args = array( 'show_split_view' => true );
|
$args = array( 'show_split_view' => true );
|
||||||
|
|
||||||
$diff = wp_text_diff_with_count( $left_content, $right_content, $args );
|
// compare_to == 0 means first revision, so compare to a blank field to show whats changed
|
||||||
|
$diff = wp_text_diff_with_count( ( 0 == $compare_to) ? '' : $left_content, $right_content, $args );
|
||||||
|
|
||||||
if ( isset( $diff[ 'html' ] ) )
|
if ( isset( $diff[ 'html' ] ) )
|
||||||
$content .= $diff[ 'html' ];
|
$content .= $diff[ 'html' ];
|
||||||
@ -2185,6 +2189,7 @@ function wp_ajax_revisions_data() {
|
|||||||
$revisions = array_reverse( $revisions );
|
$revisions = array_reverse( $revisions );
|
||||||
|
|
||||||
$previous_revision_id = 0;
|
$previous_revision_id = 0;
|
||||||
|
|
||||||
foreach ( $revisions as $revision ) :
|
foreach ( $revisions as $revision ) :
|
||||||
//error_log( ( $show_autosaves ));
|
//error_log( ( $show_autosaves ));
|
||||||
if ( empty( $show_autosaves ) && wp_is_post_autosave( $revision ) )
|
if ( empty( $show_autosaves ) && wp_is_post_autosave( $revision ) )
|
||||||
@ -2269,7 +2274,7 @@ function wp_ajax_revisions_data() {
|
|||||||
$revision_from_date_author = $revision_date_author;
|
$revision_from_date_author = $revision_date_author;
|
||||||
$revision_date_author = $tmp;
|
$revision_date_author = $tmp;
|
||||||
}
|
}
|
||||||
if ( ( $compare_two_mode || 0 !== $previous_revision_id ) ) {
|
if ( ( $compare_two_mode || -1 !== $previous_revision_id ) ) {
|
||||||
$alltherevisions[] = array (
|
$alltherevisions[] = array (
|
||||||
'ID' => $revision->ID,
|
'ID' => $revision->ID,
|
||||||
'revision_date_author' => $revision_date_author,
|
'revision_date_author' => $revision_date_author,
|
||||||
|
@ -424,19 +424,22 @@ window.wp = window.wp || {};
|
|||||||
// render the revisions
|
// render the revisions
|
||||||
render: function() {
|
render: function() {
|
||||||
var addHtml = '';
|
var addHtml = '';
|
||||||
|
var thediff;
|
||||||
// compare two revisions mode?
|
// compare two revisions mode?
|
||||||
|
|
||||||
if ( 2 === REVAPP._compareOneOrTwo ) {
|
if ( 2 === REVAPP._compareOneOrTwo ) {
|
||||||
|
|
||||||
this.comparetwochecked = 'checked';
|
this.comparetwochecked = 'checked';
|
||||||
if ( this.draggingLeft ) {
|
if ( this.draggingLeft ) {
|
||||||
if ( this.model.at( REVAPP._leftDiff ) ) {
|
thediff = REVAPP._leftDiff -1;
|
||||||
|
if ( this.model.at( thediff ) ) {
|
||||||
addHtml = this.template( _.extend(
|
addHtml = this.template( _.extend(
|
||||||
this.model.at( REVAPP._leftDiff ).toJSON(),
|
this.model.at( thediff ).toJSON(),
|
||||||
{ comparetwochecked: this.comparetwochecked } // keep the checkmark checked
|
{ comparetwochecked: this.comparetwochecked } // keep the checkmark checked
|
||||||
) );
|
) );
|
||||||
}
|
}
|
||||||
} else { // dragging right handle
|
} else { // dragging right handle
|
||||||
var thediff = REVAPP._rightDiff;
|
thediff = REVAPP._rightDiff -1;
|
||||||
if ( this.model.at( thediff ) ) {
|
if ( this.model.at( thediff ) ) {
|
||||||
addHtml = this.template( _.extend(
|
addHtml = this.template( _.extend(
|
||||||
this.model.at( thediff ).toJSON(),
|
this.model.at( thediff ).toJSON(),
|
||||||
|
@ -1426,7 +1426,7 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) {
|
|||||||
// The following removes that revision when $parent == false
|
// The following removes that revision when $parent == false
|
||||||
$parent_included = _wp_last_revision_matches_current_post( $post_id );
|
$parent_included = _wp_last_revision_matches_current_post( $post_id );
|
||||||
if ( $parent_included && ! $parent )
|
if ( $parent_included && ! $parent )
|
||||||
array_pop( $revisions );
|
array_shift( $revisions );
|
||||||
elseif ( ! $parent_included && $parent )
|
elseif ( ! $parent_included && $parent )
|
||||||
array_unshift( $revisions, $post );
|
array_unshift( $revisions, $post );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user