Make WordPress Core


Ignore:
Timestamp:
07/12/2013 05:11:56 AM (12 years ago)
Author:
markjaquith
Message:

Revisions: Loading indicator, cleanup, bug fixes.

  • Loading indicator when the user is waiting for a trip to the server.
  • Bug fixes for diff priming.
  • Fix the date display.
  • Forget about local comparator, instead order by modified on the server.
  • Initialize the frame model before the view (this was the source of a LOT of heartache).
File:
1 edited

Legend:

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

    r24664 r24667  
    6767    $now_gmt = time();
    6868
    69     $revisions = wp_get_post_revisions( $post->ID );
     69    $revisions = wp_get_post_revisions( $post->ID, array( 'order' => 'ASC', 'orderby' => 'modified' ) );
    7070
    7171    cache_users( wp_list_pluck( $revisions, 'post_author' ) );
    7272
    7373    foreach ( $revisions as $revision ) {
     74        $modified = strtotime( $revision->post_modified );
    7475        $modified_gmt = strtotime( $revision->post_modified_gmt );
    7576        $restore_link = wp_nonce_url(
     
    8990                'name'   => get_the_author_meta( 'display_name', $revision->post_author ),
    9091            ),
    91             'date'         => date_i18n( __( 'M j, Y @ G:i' ), $modified_gmt ),
    92             'dateShort'    => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified_gmt ),
    93             'dateUnix'     => $modified_gmt,
     92            'date'         => date_i18n( __( 'M j, Y @ G:i' ), $modified ),
     93            'dateShort'    => date_i18n( _x( 'j M @ G:i', 'revision date short format' ), $modified ),
    9494            'timeAgo'      => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ),
    9595            'autosave'     => wp_is_post_autosave( $revision ),
     
    100100
    101101    // Now, grab the initial diff
    102     if ( ! $from ) { // Single mode
    103         $initial_revisions = array_reverse( array_keys( array_slice( $revisions, array_search( $selected_revision_id, array_keys( $revisions ) ), 2, true ) ) );
    104         $compare_two_mode = false;
    105     } else { // Compare two
    106         $compare_two_mode = true;
    107         $initial_revisions = array( $from, $selected_revision_id );
    108     }
     102    $compare_two_mode = (bool) $from;
     103    if ( ! $from ) // Single mode
     104        $from = array_keys( array_slice( $revisions, array_search( $selected_revision_id, array_keys( $revisions ) ) - 1, 1, true ) )[0];
     105
    109106    $diffs = array( array(
    110         'id' => $initial_revisions[0] . ':' . $initial_revisions[1],
    111         'fields' => wp_get_revision_ui_diff( $post->ID, $initial_revisions[0], $initial_revisions[1] ),
     107        'id' => $from . ':' . $selected_revision_id,
     108        'fields' => wp_get_revision_ui_diff( $post->ID, $from, $selected_revision_id ),
    112109    ));
    113110
     
    121118        'baseUrl'          => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ),
    122119        'compareTwoMode'   => absint( $compare_two_mode ), // Apparently booleans are not allowed
     120        'revisionIds'      => array_keys( $revisions ),
    123121    );
    124122}
Note: See TracChangeset for help on using the changeset viewer.