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:
parent
afd0dd5ece
commit
a005e0b11b
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue