Make WordPress Core


Ignore:
Timestamp:
05/08/2013 09:22:01 PM (12 years ago)
Author:
ocean90
Message:

Revisions UI: RTL support. (And inline docs.)

props DrewAPicture, adamsilverstein. fixes #23897.

File:
1 edited

Legend:

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

    r24192 r24205  
    21202120    $compare_two_mode = (bool) $post_id;
    21212121
    2122     //
    2123     //TODO: currently code returns all possible comparisons for the indicated 'compare_to' revision
    2124     //however, the front end prevents users from pulling the right handle past the left or the left pass the right,
    2125     //so only the possible diffs need be generated
    2126     //
    21272122    $all_the_revisions = array();
    21282123    if ( ! $post_id )
     
    21372132    $left_revision = get_post( $compare_to );
    21382133
    2139     //single model fetch mode
    2140     //return the diff of a single revision comparison
     2134    // single model fetch mode
     2135    // return the diff of a single revision comparison
    21412136    if ( $single_revision_id ) {
    21422137        $right_revision = get_post( $single_revision_id );
     
    21542149        $lines_added = $lines_deleted = 0;
    21552150        $content = '';
    2156         //compare from left to right, passed from application
     2151        // compare from left to right, passed from application
    21572152        foreach ( _wp_post_revision_fields() as $field => $field_value ) {
    21582153            $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' );
     
    21832178
    21842179        $all_the_revisions = array (
    2185             'diff'          => $content,
     2180            'diff'         => $content,
    21862181            'linesDeleted' => $lines_deleted,
    21872182            'linesAdded'   => $lines_added
     
    21902185        echo json_encode( $all_the_revisions );
    21912186        exit();
    2192     } //end single model fetch
     2187    } // end single model fetch
    21932188
    21942189    $count = -1;
    21952190
    2196     //reverse the list to start with oldes revision
     2191    // reverse the list to start with oldest revision
    21972192    $revisions = array_reverse( $revisions );
    21982193
     
    22092204        $is_current_revision = false;
    22102205        $count++;
    2211         // return blank data for diffs to the left of the left handle (for right handel model)
    2212         // or to the right of the right handle (for left handel model)
    2213         if ( ( 0 != $left_handle_at && $count < $left_handle_at ) ||
    2214              ( 0 != $right_handle_at && $count > ( $right_handle_at - 2 ) ) ) {
    2215             $all_the_revisions[] = array (
    2216                 'ID' => $revision->ID,
    2217             );
    2218             continue;
     2206
     2207        /**
     2208        * return blank data for diffs to the left of the left handle (for right handel model)
     2209        * or to the right of the right handle (for left handel model)
     2210        * and visa versa in RTL mode
     2211        */
     2212        if( ! is_rtl() ) {
     2213            if ( ( ( 0 != $left_handle_at && $count < $left_handle_at ) ||
     2214                 ( 0 != $right_handle_at && $count > ( $right_handle_at - 2 ) ) ) ) {
     2215                $all_the_revisions[] = array (
     2216                    'ID' => $revision->ID,
     2217                );
     2218                continue;
     2219            }
     2220        } else { // is_rtl
     2221            if ( ( 0 != $left_handle_at && $count > ( $left_handle_at - 1 ) ||
     2222                 ( 0 != $left_handle_at && $count < $right_handle_at ) ) ) {
     2223                $all_the_revisions[] = array (
     2224                    'ID' => $revision->ID,
     2225                );
     2226                continue;
     2227            }
    22192228        }
    22202229
     
    23082317    endforeach;
    23092318
     2319    // in RTL + single handle mode, reverse the revision direction
     2320    if ( is_rtl() && $compare_two_mode )
     2321        $all_the_revisions = array_reverse( $all_the_revisions );
     2322
    23102323    echo json_encode( $all_the_revisions );
    23112324    exit();
Note: See TracChangeset for help on using the changeset viewer.