Make WordPress Core

Ticket #24743: 24743.diff

File 24743.diff, 2.3 KB (added by nacin, 12 years ago)
  • wp-admin/includes/revision.php

     
    6363
    6464function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null ) {
    6565        $post = get_post( $post );
    66         $revisions = array();
     66        $revisions = $authors = array();
    6767        $now_gmt = time();
    6868
    6969        $revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC' ) );
     70        $show_avatars = get_option( 'show_avatars' );
    7071
    7172        cache_users( wp_list_pluck( $revisions, 'post_author' ) );
    7273
     
    8182                        ),
    8283                        "restore-post_{$revision->ID}"
    8384                );
     85
     86                if ( ! isset( $authors[ $revision->post_author ] ) ) {
     87                        $authors[ $revision->post_author ] = array(
     88                                'id' => (int) $revision->post_author,
     89                                'avatar' => $show_avatars ? get_avatar( $revision->post_author, 24 ) : '',
     90                                'name' => get_the_author_meta( 'display_name', $revision->post_author ),
     91                        );
     92                }
     93
    8494                $revisions[ $revision->ID ] = array(
    85                         'id'           => $revision->ID,
    86                         'title'        => get_the_title( $post->ID ),
    87                         'author' => array(
    88                                 'id'     => (int) $revision->post_author,
    89                                 'avatar' => get_avatar( $revision->post_author, 24 ),
    90                                 'name'   => get_the_author_meta( 'display_name', $revision->post_author ),
    91                         ),
    92                         'date'         => date_i18n( __( 'M j, Y @ G:i' ), $modified ),
    93                         'dateShort'    => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified ),
    94                         'timeAgo'      => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
    95                         'autosave'     => wp_is_post_autosave( $revision ),
    96                         'current'      => $revision->post_modified_gmt === $post->post_modified_gmt,
    97                         'restoreUrl'   => urldecode( $restore_link ),
     95                        'id'         => $revision->ID,
     96                        'title'      => get_the_title( $post->ID ),
     97                        'author'     => $authors[ $revision->post_author ],
     98                        'date'       => date_i18n( __( 'M j, Y @ G:i' ), $modified ),
     99                        'dateShort'  => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified ),
     100                        'timeAgo'    => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
     101                        'autosave'   => wp_is_post_autosave( $revision ),
     102                        'current'    => $revision->post_modified_gmt === $post->post_modified_gmt,
     103                        'restoreUrl' => urldecode( $restore_link ),
    98104                );
    99105        }
    100106