Make WordPress Core


Ignore:
Timestamp:
07/11/2013 10:56:48 PM (12 years ago)
Author:
markjaquith
Message:

Revisions: real URLs and preloading of the requested diff.

  • Real URLs are being used now, using pushState. ?revision={id} or ?from={from}&to={to}.
  • Drop the redundant action=edit from the URLs (this is the default).
  • The initial comparison is preloaded, whether a single revision or a compare-two situation.

See #24425.

File:
1 edited

Legend:

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

    r24663 r24664  
    6262}
    6363
    64 function wp_prepare_revisions_for_js( $post, $selected_revision_id ) {
     64function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null ) {
    6565    $post = get_post( $post );
    6666    $revisions = array();
     
    9999    }
    100100
     101    // 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    }
     109    $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] ),
     112    ));
     113
    101114    return array(
    102115        'postId'           => $post->ID,
    103116        'nonce'            => wp_create_nonce( 'revisions-ajax-nonce' ),
    104117        'revisionData'     => array_values( $revisions ),
    105         'selectedRevision' => $selected_revision_id,
     118        'to'               => $selected_revision_id,
     119        'from'             => $from,
     120        'diffData'         => $diffs,
     121        'baseUrl'          => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ),
     122        'compareTwoMode'   => absint( $compare_two_mode ), // Apparently booleans are not allowed
    106123    );
    107124}
Note: See TracChangeset for help on using the changeset viewer.