mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 20:30:23 +00:00
Move autosave to post revisions. Props mdawaffe. see #6775
git-svn-id: https://develop.svn.wordpress.org/trunk@7907 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -566,27 +566,39 @@ function is_page_template($template = '') {
|
||||
}
|
||||
|
||||
/**
|
||||
* wp_post_revision_time() - returns formatted datetimestamp of a revision
|
||||
* wp_post_revision_title() - returns formatted datetimestamp of a revision (linked to that revisions's page)
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Post Revisions
|
||||
* @since 2.6
|
||||
*
|
||||
* @uses wp_get_revision()
|
||||
* @uses date_i18n()
|
||||
*
|
||||
* @param int|object $revision revision ID or revision object
|
||||
* @param bool $link optional Link to revisions's page?
|
||||
* @return string i18n formatted datetimestamp or localized 'Corrent Revision'
|
||||
*/
|
||||
function wp_post_revision_time( $revision ) {
|
||||
if ( !$revision = wp_get_revision( $revision ) ) {
|
||||
if ( $revision = get_post( $revision ) )
|
||||
return __( 'Current Revision' );
|
||||
function wp_post_revision_title( $revision, $link = true ) {
|
||||
if ( !$revision = get_post( $revision ) )
|
||||
return $revision;
|
||||
}
|
||||
|
||||
$datef = _c( 'j F, Y @ G:i|revision date format');
|
||||
return date_i18n( $datef, strtotime( $revision->post_date_gmt . ' +0000' ) );
|
||||
if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) )
|
||||
return false;
|
||||
|
||||
$datef = _c( 'j F, Y @ G:i|revision date format');
|
||||
$autosavef = __( '%s [Autosave]' );
|
||||
$currentf = __( '%s [Current Revision]' );
|
||||
|
||||
$date = date_i18n( $datef, strtotime( $revision->post_modified_gmt . ' +0000' ) );
|
||||
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
|
||||
$date = "<a href='$link'>$date</a>";
|
||||
|
||||
if ( 'revision' != $revision->post_type )
|
||||
$date = sprintf( $currentf, $date );
|
||||
elseif ( "{$revision->post_parent}-autosave" == $revision->post_name )
|
||||
$date = sprintf( $autosavef, $date );
|
||||
|
||||
return $date;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -605,7 +617,7 @@ function wp_post_revision_time( $revision ) {
|
||||
* @since 2.6
|
||||
*
|
||||
* @uses wp_get_post_revisions()
|
||||
* @uses wp_post_revision_time()
|
||||
* @uses wp_post_revision_title()
|
||||
* @uses get_edit_post_link()
|
||||
* @uses get_author_name()
|
||||
*
|
||||
@@ -630,33 +642,32 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) { // TODO? split i
|
||||
$rows = '';
|
||||
$class = false;
|
||||
foreach ( $revisions as $revision ) {
|
||||
$date = wp_post_revision_time( $revision );
|
||||
if ( $link = get_edit_post_link( $revision->ID ) )
|
||||
$date = "<a href='$link'>$date</a>";
|
||||
$date = wp_post_revision_title( $revision );
|
||||
$name = get_author_name( $revision->post_author );
|
||||
|
||||
if ( 'form-table' == $format ) {
|
||||
if ( $left )
|
||||
$old_checked = $left == $revision->ID ? ' checked="checked"' : '';
|
||||
$left_checked = $left == $revision->ID ? ' checked="checked"' : '';
|
||||
else
|
||||
$old_checked = $new_checked ? ' checked="checked"' : '';
|
||||
$new_checked = $right == $revision->ID ? ' checked="checked"' : '';
|
||||
$left_checked = $right_checked ? ' checked="checked"' : ''; // [sic] (the next one)
|
||||
$right_checked = $right == $revision->ID ? ' checked="checked"' : '';
|
||||
|
||||
$class = $class ? '' : " class='alternate'";
|
||||
|
||||
if ( $post->ID != $revision->ID && current_user_can( 'edit_post', $post->ID ) )
|
||||
$actions = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'diff' => false, 'restore' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>';
|
||||
$actions = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'diff' => false, 'action' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>';
|
||||
else
|
||||
$actions = '';
|
||||
|
||||
$rows .= "<tr$class>\n";
|
||||
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='diff' value='$revision->ID'$old_checked /><input type='radio' name='revision' value='$revision->ID'$new_checked />\n";
|
||||
$rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /><input type='radio' name='right' value='$revision->ID'$right_checked />\n";
|
||||
$rows .= "\t<td>$date</td>\n";
|
||||
$rows .= "\t<td>$name</td>\n";
|
||||
$rows .= "\t<td class='action-links'>$actions</td>\n";
|
||||
$rows .= "</tr>\n";
|
||||
} else {
|
||||
$rows .= "\t<li>" . sprintf( $titlef, $date, $name ). "</li>\n";
|
||||
$title = sprintf( $titlef, $date, $name );
|
||||
$rows .= "\t<li>$title</li>\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,6 +678,7 @@ function wp_list_post_revisions( $post_id = 0, $args = null ) { // TODO? split i
|
||||
<div class="tablenav">
|
||||
<div class="alignleft">
|
||||
<input type="submit" class="button-secondary" value="<?php _e( 'Compare Revisions' ); ?>" />
|
||||
<input type="hidden" name="action" value="diff" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user