Make WordPress Core

Changeset 30353


Ignore:
Timestamp:
11/16/2014 03:35:37 AM (10 years ago)
Author:
johnbillion
Message:

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

Fixes #29044
Props adamsilverstein

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/revision.php

    r30129 r30353  
    187187            'restoreUrl' => $can_restore ? $restore_link : false,
    188188        );
     189    }
     190
     191    /**
     192     * If we only have one revision, the initial revision is missing; This happens
     193     * when we have an autsosave and the user has clicked 'View the Autosave'
     194     */
     195    if ( 1 === sizeof( $revisions ) ) {
     196        $revisions[ $post->ID ] = array(
     197            'id'         => $post->ID,
     198            'title'      => get_the_title( $post->ID ),
     199            'author'     => $authors[ $post->post_author ],
     200            'date'       => date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->modified ) ),
     201            'dateShort'  => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), strtotime( $post->modified ) ),
     202            'timeAgo'    => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ),
     203            'autosave'   => false,
     204            'current'    => true,
     205            'restoreUrl' => false,
     206        );
     207        $current_id = $post->ID;
    189208    }
    190209
Note: See TracChangeset for help on using the changeset viewer.