Display a faux revision when a post only has one revision but has an autosave.

Fixes #29044
Props adamsilverstein

Built from https://develop.svn.wordpress.org/trunk@30353


git-svn-id: http://core.svn.wordpress.org/trunk@30352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2014-11-16 03:36:23 +00:00
parent afd0dd5ece
commit a005e0b11b
1 changed files with 19 additions and 0 deletions

View File

@ -188,6 +188,25 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
);
}
/**
* 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 ],
'date' => date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->modified ) ),
'dateShort' => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), strtotime( $post->modified ) ),
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ),
'autosave' => false,
'current' => true,
'restoreUrl' => false,
);
$current_id = $post->ID;
}
/*
* 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