WordPress.org

Make WordPress Core

Changeset 23506


Ignore:
Timestamp:
02/28/2013 03:14:34 PM (7 years ago)
Author:
westi
Message:

Revisions: First pass an implementing a new UI/UX for reviewing the revisions of posts. See #23497 props adamsilverstein for the initial patch.

This implements a new revisions ui using Backbone and preserves all the old methods of "integration" so the change should be transparent to plugins using revisi
ons with CPTs.

This is the first pass and so there are a number of things still to be resolved, more details in the ticket. Feedback welcomed.

Location:
trunk
Files:
8 added
10 edited

Legend:

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

    r23481 r23506  
    4343$core_actions_get = array(
    4444    'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
    45     'autocomplete-user', 'dashboard-widgets', 'logged-in',
     45    'autocomplete-user', 'dashboard-widgets', 'logged-in', 'revisions-data'
    4646);
    4747
     
    5757    'wp-remove-post-lock', 'dismiss-wp-pointer', 'upload-attachment', 'get-attachment',
    5858    'query-attachments', 'save-attachment', 'save-attachment-compat', 'send-link-to-editor',
    59     'send-attachment-to-editor', 'save-attachment-order', 'heartbeat',
     59    'send-attachment-to-editor', 'save-attachment-order', 'heartbeat'
    6060);
    6161
  • trunk/wp-admin/css/colors-fresh.css

    r23501 r23506  
    13521352/* Diff */
    13531353table.diff .diff-deletedline {
    1354     background-color: #fdd;
     1354    background-color: #ffe5e6;
     1355    color: #f2001f;
     1356    text-decoration: line-through;
    13551357}
    13561358
     
    13591361}
    13601362
     1363table.diff .diff-deletedline-symbol {
     1364    color: #f2001f;
     1365}
     1366
    13611367table.diff .diff-addedline {
    1362     background-color: #dfd;
     1368    background-color: #e9f6ea;
     1369    color: #00a500;
     1370}
     1371
     1372table.diff .diff-addedline-symbol {
     1373    color: #00a500;
    13631374}
    13641375
  • trunk/wp-admin/css/wp-admin.css

    r23504 r23506  
    35053505
    35063506table.diff col.content {
    3507     width: 50%;
     3507    width: auto;
     3508}
     3509
     3510table.diff col.content.diffsplit {
     3511    width: 48%;
     3512}
     3513
     3514table.diff col.diffsplit.middle {
     3515    width: 4%;
     3516}
     3517
     3518table.diff col.ltype {
     3519    width: 30px;
    35083520}
    35093521
     
    88098821    margin-left: 8em;
    88108822}
     8823
     8824#revisions-meta-mostrecent,
     8825#revisions-meta-stored,
     8826#revisions-meta-oldest,
     8827#revisions-meta-link {
     8828    line-height: 30px;
     8829    height: 30px;
     8830    vertical-align: middle;
     8831    padding-right: 10px;
     8832}
     8833#revisions-meta-mostrecent img,
     8834#revisions-meta-oldest img {
     8835vertical-align: middle;
     8836}
  • trunk/wp-admin/edit-form-advanced.php

    r23456 r23506  
    169169}
    170170
    171 if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && wp_get_post_revisions( $post_ID ) )
     171// TODO review this count() - why do we need to add it?
     172if ( post_type_supports($post_type, 'revisions') && 0 < $post_ID && count ( wp_get_post_revisions( $post_ID ) ) > 1  )
    172173    add_meta_box('revisionsdiv', __('Revisions'), 'post_revisions_meta_box', null, 'normal', 'core');
    173174
  • trunk/wp-admin/includes/ajax-actions.php

    r23484 r23506  
    13801380
    13811381    check_ajax_referer( 'taxinlineeditnonce', '_inline_edit' );
    1382    
     1382
    13831383    $post_data = wp_unslash( $_POST );
    13841384
     
    21352135}
    21362136
     2137function wp_ajax_revisions_data() {
     2138    check_ajax_referer( 'revisions-ajax-nonce', 'nonce' );
     2139
     2140    $compareto = isset( $_GET['compareto'] ) ? absint( $_GET['compareto'] ) : 0;
     2141    $showautosaves = isset( $_GET['showautosaves'] ) ? $_GET['showautosaves'] : '';
     2142    $show_split_view = isset( $_GET['show_split_view'] ) ? $_GET['show_split_view'] : '';
     2143    $postid = isset( $_GET['postid'] ) ? absint( $_GET['postid'] ) : '';
     2144
     2145    $comparetwomode = ( '' == $postid ) ? false : true;
     2146    //
     2147    //TODO: currently code returns all possible comparisons for the indicated 'compareto' revision
     2148    //however, the front end prevents users from pulling the right handle past the left or the left pass the right,
     2149    //so only the possible diffs need be generated
     2150    //
     2151    $alltherevisions = array();
     2152
     2153    if ( '' == $postid )
     2154        $postid = $compareto;
     2155
     2156    if ( ! current_user_can( 'read_post', $postid ) )
     2157        continue;
     2158
     2159    if ( ! $revisions = wp_get_post_revisions( $postid ) )
     2160        return;
     2161
     2162    //if we are comparing two revisions, the first 'revision' represented by the leftmost
     2163    //slider position is the current revision, prepend a comparison to this revision
     2164    if ( $comparetwomode )
     2165        array_unshift( $revisions, get_post( $postid ) );
     2166
     2167    $count = 1;
     2168    foreach ( $revisions as $revision ) :
     2169    if ( 'true' != $showautosaves && wp_is_post_autosave( $revision ) )
     2170            continue;
     2171
     2172    $revision_from_date_author = '';
     2173
     2174
     2175    $left_revision = get_post( $compareto );
     2176    $right_revision = get_post( $revision );
     2177
     2178    $author = get_the_author_meta( 'display_name', $revision->post_author );
     2179    /* translators: revision date format, see http://php.net/date */
     2180    $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
     2181
     2182    $gravatar = get_avatar( $revision->post_author, 18 );
     2183
     2184    $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
     2185    $revision_date_author = sprintf(
     2186        '%s %s, %s %s (%s)',
     2187        $gravatar,
     2188        $author,
     2189        human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ),
     2190        __( ' ago ' ),
     2191        $date
     2192    );
     2193
     2194    if ( $comparetwomode ) {
     2195        $compareto_gravatar = get_avatar( $left_revision->post_author, 18 );
     2196        $compareto_author = get_the_author_meta( 'display_name', $left_revision->post_author );
     2197        $compareto_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) );
     2198
     2199        $revision_from_date_author = sprintf(
     2200            '%s %s, %s %s (%s)',
     2201            $compareto_gravatar,
     2202            $compareto_author,
     2203            human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ),
     2204            __( ' ago ' ),
     2205            $compareto_date
     2206        );
     2207    }
     2208
     2209    $restoreaction = wp_nonce_url(
     2210        add_query_arg(
     2211            array( 'revision' => $revision->ID,
     2212                'action' => 'restore' ),
     2213                '/wp-admin/revision.php'
     2214        ),
     2215        "restore-post_{$compareto}|{$revision->ID}"
     2216    );
     2217
     2218    //
     2219    //make sure the left revision is the most recent
     2220    //
     2221    if ( strtotime( $right_revision->post_modified_gmt ) < strtotime( $left_revision->post_modified_gmt ) ) {
     2222        $temp = $left_revision;
     2223        $left_revision = $right_revision;
     2224        $right_revision = $temp;
     2225    }
     2226
     2227    //
     2228    //compare from left to right, passed from application
     2229    //
     2230    $content='';
     2231    foreach ( array_keys( _wp_post_revision_fields() ) as $field ) {
     2232        $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' );
     2233        $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' );
     2234
     2235        add_filter( "_wp_post_revision_field_$field", 'wp_kses_post' );
     2236
     2237        $args = array();
     2238
     2239        if ( 'true' == $show_split_view )
     2240             $args = array( 'show_split_view' => 'true' );
     2241
     2242        $content .= wp_text_diff( $left_content, $right_content, $args );
     2243    }
     2244
     2245    //if we are comparing two revisions
     2246    //and we are on the matching revision
     2247    //add an error revision indicating unable to compare to self
     2248    if ( $comparetwomode && $compareto == $revision->ID )
     2249        $alltherevisions[] = array (
     2250            'ID' => $revision->ID,
     2251            'revision_date_author' => $revision_date_author,
     2252            'revisiondiff' => sprintf('<div id="selfcomparisonerror">%s</div>', __( 'Cannot compare revision to itself' ) ),
     2253            'restoreaction' => urldecode( $restoreaction ),
     2254            'revision_from_date_author' => ''
     2255        );
     2256
     2257    //add to the return data only if there is a difference
     2258    if ( '' != $content )
     2259        $alltherevisions[] = array (
     2260            'ID' => $revision->ID,
     2261            'revision_date_author' => $revision_date_author,
     2262            'revisiondiff' => $content,
     2263            'restoreaction' => urldecode( $restoreaction ),
     2264            'revision_from_date_author' => $revision_from_date_author
     2265        );
     2266
     2267    endforeach;
     2268
     2269    echo json_encode( $alltherevisions );
     2270    exit();
     2271}
  • trunk/wp-admin/revision.php

    r23404 r23506  
    99/** WordPress Administration Bootstrap */
    1010require_once('./admin.php');
    11 
    12 wp_enqueue_script('list-revisions');
    13 
    14 wp_reset_vars(array('revision', 'left', 'right', 'action'));
     11wp_reset_vars( array( 'revision', 'action' ) );
    1512
    1613$revision_id = absint($revision);
    17 $left        = absint($left);
    18 $right       = absint($right);
    19 
    2014$redirect = 'edit.php';
    2115
     
    3428        break;
    3529    }
    36 
    37     check_admin_referer( "restore-post_$post->ID|$revision->ID" );
     30    check_admin_referer( "restore-post_{$post->ID}|{$revision->ID}" );
    3831
    3932    wp_restore_post_revision( $revision->ID );
    4033    $redirect = add_query_arg( array( 'message' => 5, 'revision' => $revision->ID ), get_edit_post_link( $post->ID, 'url' ) );
    4134    break;
    42 case 'diff' :
    43     if ( !$left_revision  = get_post( $left ) )
    44         break;
    45     if ( !$right_revision = get_post( $right ) )
    46         break;
    47 
    48     if ( !current_user_can( 'read_post', $left_revision->ID ) || !current_user_can( 'read_post', $right_revision->ID ) )
    49         break;
    50 
    51     // If we're comparing a revision to itself, redirect to the 'view' page for that revision or the edit page for that post
    52     if ( $left_revision->ID == $right_revision->ID ) {
    53         $redirect = get_edit_post_link( $left_revision->ID );
    54         include( './js/revisions-js.php' );
    55         break;
    56     }
    57 
    58     // Don't allow reverse diffs?
    59     if ( strtotime($right_revision->post_modified_gmt) < strtotime($left_revision->post_modified_gmt) ) {
    60         $redirect = add_query_arg( array( 'left' => $right, 'right' => $left ) );
    61         break;
    62     }
    63 
    64     if ( $left_revision->ID == $right_revision->post_parent ) // right is a revision of left
    65         $post =& $left_revision;
    66     elseif ( $left_revision->post_parent == $right_revision->ID ) // left is a revision of right
    67         $post =& $right_revision;
    68     elseif ( $left_revision->post_parent == $right_revision->post_parent ) // both are revisions of common parent
    69         $post = get_post( $left_revision->post_parent );
    70     else
    71         break; // Don't diff two unrelated revisions
    72 
    73     if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') ) { // Revisions disabled
    74         if (
    75             // we're not looking at an autosave
    76             ( !wp_is_post_autosave( $left_revision ) && !wp_is_post_autosave( $right_revision ) )
    77         ||
    78             // we're not comparing an autosave to the current post
    79             ( $post->ID !== $left_revision->ID && $post->ID !== $right_revision->ID )
    80         ) {
    81             $redirect = 'edit.php?post_type=' . $post->post_type;
    82             break;
    83         }
    84     }
    85 
    86     if (
    87         // They're the same
    88         $left_revision->ID == $right_revision->ID
    89     ||
    90         // Neither is a revision
    91         ( !wp_get_post_revision( $left_revision->ID ) && !wp_get_post_revision( $right_revision->ID ) )
    92     )
    93         break;
    94 
    95     $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
    96     $h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
    97     $title = __( 'Revisions' );
    98 
    99     $left  = $left_revision->ID;
    100     $right = $right_revision->ID;
    101 
    102     $redirect = false;
    103     break;
    10435case 'view' :
     36case 'edit' :
    10537default :
    10638    if ( !$revision = wp_get_post_revision( $revision_id ) )
     
    12052    $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>';
    12153    $revision_title = wp_post_revision_title( $revision, false );
    122     $h2 = sprintf( __( 'Revision for &#8220;%1$s&#8221; created on %2$s' ), $post_title, $revision_title );
     54    $h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title );
    12355    $title = __( 'Revisions' );
    124 
    125     // Sets up the diff radio buttons
    126     $left  = $revision->ID;
    127     $right = $post->ID;
    12856
    12957    $redirect = false;
     
    14674    $parent_file = $submenu_file = 'edit.php';
    14775
     76wp_enqueue_style( 'revisions' );
     77wp_enqueue_script( 'revisions' );
     78
    14879require_once( './admin-header.php' );
    14980
     81//TODO - Some of the translations below split things into multiple strings that are contextually related and this makes it pretty impossible for RTL translation.
     82//TODO can we pass the context in a better way
    15083?>
     84<script type="text/javascript">
     85var wpRevisionsSettings = <?php echo json_encode( array( 'post_id' => $post->ID, 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ) ) ); ?>;
     86</script>
    15187
     88<div id="backbonerevisionsoptions"></div>
     89
     90<br class="clear"/>
    15291<div class="wrap">
    153 
    154 <h2 class="long-header"><?php echo $h2; ?></h2>
    155 
    156 <table class="form-table ie-fixed">
    157     <col class="th" />
    158 <?php if ( 'diff' == $action ) : ?>
    159 <tr id="revision">
    160     <th scope="row"></th>
    161     <th scope="col" class="th-full">
    162         <span class="alignleft"><?php printf( __('Older: %s'), wp_post_revision_title( $left_revision ) ); ?></span>
    163         <span class="alignright"><?php printf( __('Newer: %s'), wp_post_revision_title( $right_revision ) ); ?></span>
    164     </th>
    165 </tr>
    166 <?php endif;
    167 
    168 // use get_post_to_edit filters?
    169 $identical = true;
    170 foreach ( _wp_post_revision_fields() as $field => $field_title ) :
    171     if ( 'diff' == $action ) {
    172         $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' );
    173         $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field, $right_revision, 'right' );
    174         if ( !$content = wp_text_diff( $left_content, $right_content ) )
    175             continue; // There is no difference between left and right
    176         $identical = false;
    177     } else {
    178         add_filter( "_wp_post_revision_field_$field", 'htmlspecialchars' );
    179         $content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field, $revision, '' );
    180     }
    181     ?>
    182 
    183     <tr id="revision-field-<?php echo $field; ?>">
    184         <th scope="row"><?php echo esc_html( $field_title ); ?></th>
    185         <td><div class="pre"><?php echo $content; ?></div></td>
    186     </tr>
    187 
    188     <?php
    189 
    190 endforeach;
    191 
    192 if ( 'diff' == $action && $identical ) :
    193 
    194     ?>
    195 
    196     <tr><td colspan="2"><div class="updated"><p><?php _e( 'These revisions are identical.' ); ?></p></div></td></tr>
    197 
    198     <?php
    199 
    200 endif;
    201 
     92    <div class="icon32 icon32-posts-post" id="icon-edit"><br></div>
     93    <div class="revisiondiffcontainer diffsplit currentversion rightmodelloading">
     94        <div id="modelsloading" class="updated message"><span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?></div>
     95        <h2 class="long-header"><?php echo $h2; ?></h2>
     96        <div id="backbonerevisionsinteract"></div>
     97        <div id="backbonerevisionsdiff"></div>
     98<hr />
     99<?php
     100    $comparetworevisionslink = get_edit_post_link( $revision->ID );
    202101?>
    203 
    204 </table>
    205 
    206 <br class="clear" />
    207 
    208 <h3><?php echo $title; ?></h3>
    209 
    210 <?php
    211 
    212 $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left );
    213 if ( ! WP_POST_REVISIONS || !post_type_supports($post->post_type, 'revisions') )
    214     $args['type'] = 'autosave';
    215 
    216 wp_list_post_revisions( $post, $args );
    217 
    218 ?>
    219 
     102    </div>
    220103</div>
    221104
     105<script id="tmpl-revision" type="text/html">
     106    <div id="diffsubheader">
     107        <span id="diff_from_current_revision"><?php _e( 'Current version' ); ?><?php _e( '- compared to -' ); ?></span>
     108        <div id="difftitlefrom">{{{ data.revision_from_date_author }}} <?php _e( '- compared to -' ); ?></div>
     109        <div id="difftitle">{{{ data.revision_date_author }}}</div>
     110        <div id="diffcancel"><input class="button" onClick="document.location='<?php echo get_edit_post_link( $post->ID ); ?>'" type="submit" id="cancel" value="<?php esc_attr_e( 'Cancel' )?>" /></div>
     111        <div id="diffrestore"><input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore' )?>" /></div>
     112        <div id="comparetworevisions"><input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> <?php esc_attr_e( 'Compare two revisions' )?></div>
     113    </div>
     114    <div id="removedandadded">
     115        <div id="removed"><?php _e( 'Removed -' ); ?></div>
     116        <div id="added"><?php _e( 'Added +' ); ?></div>
     117    </div
     118    <div>{{{ data.revisiondiff }}}</div>
     119</script>
     120
     121<script id="tmpl-revisionvinteract" type="text/html">
     122    <div id="diffheader">
     123<div id="diffprevious"><input class="button" type="submit" id="previous" value="Previous" /></div>
     124            <div id="diffnext"><input class="button" type="submit" id="next" value="Next" /></div>
     125            <div id="diffslider">
     126    <div id="revisioncount">
     127                    <?php _e( 'Comparing' ); ?>
     128                    <span id="diff_left_count"> <?php _e( 'revision' ); ?></span> <span id="diff_left_count_inner"></span>
     129                    <span id="diff_left_current_revision"><?php _e( 'current version' ); ?></span>
     130                    <span id="diff_revision_from">{{{ data.diff_revision_from }}}</span>
     131                    <?php _e( ' to revision' ); ?>
     132                    <span id="diff_count">{{{ data.current_diff }}}</span>
     133                    <?php _e( ' of ' ); ?>
     134                    <span id="diff_max" ></span>
     135                </div>
     136
     137            <div id="slider"></div>
     138        </div>
     139    </div>
     140</script>
    222141<?php
     142/*
     143TODO Convert these into screen options
     144<script id="tmpl-revisionoptions" type="text/html">
     145    <div id="revisionoptions">
     146        <div id="showsplitviewoption">
     147            <input type='checkbox' id="show_split_view" checked="checked" value="1" /> <?php _e( 'Show split diff view' ); ?>
     148        </div>
     149        <div id="toggleshowautosavesoption">
     150            <input type='checkbox' id="toggleshowautosaves" value="1" /> <?php _e( 'Show autosaves' ); ?>
     151        </div>
     152    </div>
     153</script>
     154*/
    223155require_once( './admin-footer.php' );
  • trunk/wp-includes/pluggable.php

    r23416 r23506  
    17141714    $left_lines  = explode("\n", $left_string);
    17151715    $right_lines = explode("\n", $right_string);
    1716 
    17171716    $text_diff = new Text_Diff($left_lines, $right_lines);
    1718     $renderer  = new WP_Text_Diff_Renderer_Table();
     1717    $renderer  = new WP_Text_Diff_Renderer_Table( $args );
    17191718    $diff = $renderer->render($text_diff);
    17201719
     
    17231722
    17241723    $r  = "<table class='diff'>\n";
    1725     $r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />";
     1724
     1725    if ( isset( $args[ 'showsplitview' ] ) && 'true' == $args[ 'showsplitview' ] ) {
     1726        $r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />";
     1727    } else {
     1728        $r .= "<col class='content' />";
     1729    }
    17261730
    17271731    if ( $args['title'] || $args['title_left'] || $args['title_right'] )
  • trunk/wp-includes/post-template.php

    r23416 r23506  
    13011301        return false;
    13021302
     1303    $author = get_the_author_meta( 'display_name', $revision->post_author );
    13031304    /* translators: revision date format, see http://php.net/date */
    1304     $datef = _x( 'j F, Y @ G:i', 'revision date format');
    1305     /* translators: 1: date */
    1306     $autosavef = __( '%1$s [Autosave]' );
    1307     /* translators: 1: date */
    1308     $currentf  = __( '%1$s [Current Revision]' );
     1305    $datef = _x( 'j F, Y @ G:i:s', 'revision date format');
     1306
     1307    $gravatar = get_avatar( $revision->post_author, 18 );
    13091308
    13101309    $date = date_i18n( $datef, strtotime( $revision->post_modified ) );
    13111310    if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) )
    13121311        $date = "<a href='$link'>$date</a>";
     1312   
     1313    $revision_date_author = sprintf(
     1314        '%s %s, %s %s (%s)',
     1315        $gravatar,
     1316        $author,
     1317        human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ),
     1318        __( 'ago' ),
     1319        $date
     1320    );
     1321
     1322    $autosavef = __( '%1$s [Autosave]' );
     1323    $currentf  = __( '%1$s [Current Revision]' );
    13131324
    13141325    if ( !wp_is_post_revision( $revision ) )
    1315         $date = sprintf( $currentf, $date );
     1326        $revision_date_author = sprintf( $currentf, $revision_date_author );
    13161327    elseif ( wp_is_post_autosave( $revision ) )
    1317         $date = sprintf( $autosavef, $date );
    1318 
    1319     return $date;
     1328        $revision_date_author = sprintf( $autosavef, $revision_date_author );
     1329
     1330    return $revision_date_author;
    13201331}
    13211332
  • trunk/wp-includes/script-loader.php

    r23487 r23506  
    271271
    272272    $scripts->add( 'underscore', '/wp-includes/js/underscore.min.js', array(), '1.4.4', 1 );
    273     $scripts->add( 'backbone', '/wp-includes/js/backbone.min.js', array('underscore','jquery'), '0.9.2', 1 );
     273    $scripts->add( 'template', "/wp-includes/js/template$suffix.js", array('underscore'), '1.4.4', 1 );
     274    $scripts->add( 'backbone', '/wp-includes/js/backbone.min.js', array('underscore','jquery', 'template'), '0.9.2', 1 );
     275
     276    $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'backbone', 'jquery-ui-slider' ), false, 1 );
    274277
    275278    $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 );
     
    540543    $styles->add( 'media-views', "/wp-includes/css/media-views$suffix.css", array( 'buttons' ) );
    541544    $styles->add( 'buttons', "/wp-includes/css/buttons$suffix.css" );
     545    $styles->add( 'wp-jquery-ui-slider', "/wp-includes/css/jquery-ui-slider$suffix.css" );
     546    $styles->add( 'revisions', "/wp-admin/css/revisions$suffix.css", array( 'wp-jquery-ui-slider' ) );
    542547
    543548    foreach ( $rtl_styles as $rtl_style ) {
  • trunk/wp-includes/wp-diff.php

    r22118 r23506  
    6161
    6262    /**
     63     * Should we show the split view or not
     64     *
     65     * @var string
     66     * @access protected
     67     * @since 3.6.0
     68     */
     69    var $_show_split_view = true;
     70
     71    /**
    6372     * Constructor - Call parent constructor with params array.
    6473     *
     
    7180    function __construct( $params = array() ) {
    7281        parent::__construct( $params );
     82        if ( isset( $params[ 'show_split_view' ] ) )
     83            $this->_show_split_view = $params[ 'show_split_view' ];
    7384    }
    7485
     
    99110     */
    100111    function addedLine( $line ) {
    101         return "<td>+</td><td class='diff-addedline'>{$line}</td>";
     112        return "<td class='diff-addedline'>{$line}</td>";
     113
    102114    }
    103115
     
    109121     */
    110122    function deletedLine( $line ) {
    111         return "<td>-</td><td class='diff-deletedline'>{$line}</td>";
     123        return "<td class='diff-deletedline'>{$line}</td>";
    112124    }
    113125
     
    119131     */
    120132    function contextLine( $line ) {
    121         return "<td> </td><td class='diff-context'>{$line}</td>";
     133        return "<td class='diff-context'>{$line}</td>";
    122134    }
    123135
     
    128140     */
    129141    function emptyLine() {
    130         return '<td colspan="2">&nbsp;</td>';
     142        return '<td>&nbsp;</td>';
    131143    }
    132144
     
    143155        foreach ($lines as $line) {
    144156            if ( $encode )
    145                 $line = htmlspecialchars( $line );
    146             $r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
     157                $line = wp_kses_post( $line );
     158            if ( $this->_show_split_view ) {
     159                $r .= '<tr>' . $this->emptyLine() . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n";
     160            } else {
     161                $r .= '<tr>' . $this->addedLine( $line ) . "</tr>\n";
     162            }
    147163        }
    148164        return $r;
     
    161177        foreach ($lines as $line) {
    162178            if ( $encode )
    163                 $line = htmlspecialchars( $line );
    164             $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n";
     179                $line = wp_kses_post( $line );
     180            if ( $this->_show_split_view ) {
     181                $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . $this->emptyLine() . "</tr>\n";
     182            } else {
     183                $r .= '<tr>' . $this->deletedLine( $line ) . "</tr>\n";
     184            }
     185
    165186        }
    166187        return $r;
     
    179200        foreach ($lines as $line) {
    180201            if ( $encode )
    181                 $line = htmlspecialchars( $line );
    182             $r .= '<tr>' .
    183                 $this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n";
     202                $line = wp_kses_post( $line );
     203            if (  $this->_show_split_view ) {
     204                $r .= '<tr>' . $this->contextLine( $line ) . $this->emptyLine() . $this->contextLine( $line )  . "</tr>\n";
     205            } else {
     206                $r .= '<tr>' . $this->contextLine( $line ) . "</tr>\n";
     207            }
    184208        }
    185209        return $r;
     
    265289                $r .= $this->_deleted( array($orig_line), false );
    266290            } else { // A true changed row.
    267                 $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->addedLine( $final_line ) . "</tr>\n";
     291                if ( $this->_show_split_view ) {
     292                    $r .= '<tr>' . $this->deletedLine( $orig_line ) . $this->emptyLine() . $this->addedLine( $final_line ) . "</tr>\n";
     293                } else {
     294                    $r .= '<tr>' . $this->deletedLine( $orig_line ) . "</tr><tr>" . $this->addedLine( $final_line ) . "</tr>\n";
     295                }
    268296            }
    269297        }
Note: See TracChangeset for help on using the changeset viewer.