Ticket #23396: version-1.diff

File version-1.diff, 17.4 KB (added by adamsilverstein, 3 months ago)
  • wp-includes/post-template.php

     
    13011301                return false; 
    13021302 
    13031303        /* translators: revision date format, see http://php.net/date */ 
    1304         $datef = _x( 'j F, Y @ G:i', 'revision date format'); 
     1304        $datef = _x( 'D, M jS @ G:i a', 'revision date format' );  
    13051305        /* translators: 1: date */ 
    13061306        $autosavef = __( '%1$s [Autosave]' ); 
    13071307        /* translators: 1: date */ 
    13081308        $currentf  = __( '%1$s [Current Revision]' ); 
    13091309 
     1310        $author = get_the_author_meta( 'display_name', $revision->post_author ); 
     1311 
    13101312        $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 
    13111313        if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) 
    1312                 $date = "<a href='$link'>$date</a>"; 
     1314                $date = "<a href='$link'>$author : $date</a>"; 
    13131315 
    13141316        if ( !wp_is_post_revision( $revision ) ) 
    13151317                $date = sprintf( $currentf, $date ); 
     
    13861388                        continue; 
    13871389 
    13881390                $date = wp_post_revision_title( $revision ); 
    1389                 $name = get_the_author_meta( 'display_name', $revision->post_author ); 
     1391                $datelinktodiff = sprintf( '<a href="revision.php?action=diff&post_type=post&left=%d&right=%d">%s</a>',  
     1392                                                                        $revision->ID, $post->ID, wp_post_revision_title( $revision, false ) );  
    13901393 
     1394                $name = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.'; 
     1395                $avatar = get_avatar( $revision->post_author, 22 ); 
    13911396                if ( 'form-table' == $format ) { 
    1392                         if ( $left ) 
    1393                                 $left_checked = $left == $revision->ID ? ' checked="checked"' : ''; 
    1394                         else 
    1395                                 $left_checked = $right_checked ? ' checked="checked"' : ''; // [sic] (the next one) 
    1396                         $right_checked = $right == $revision->ID ? ' checked="checked"' : ''; 
    13971397 
    13981398                        $class = $class ? '' : " class='alternate'"; 
    13991399 
    14001400                        if ( $post->ID != $revision->ID && $can_edit_post ) 
    1401                                 $actions = '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'action' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>'; 
     1401                                $actions = '';// '<a href="' . wp_nonce_url( add_query_arg( array( 'revision' => $revision->ID, 'action' => 'restore' ) ), "restore-post_$post->ID|$revision->ID" ) . '">' . __( 'Restore' ) . '</a>'; 
    14021402                        else 
    14031403                                $actions = ''; 
    14041404 
    14051405                        $rows .= "<tr$class>\n"; 
    1406                         $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /></th>\n"; 
    1407                         $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n"; 
    1408                         $rows .= "\t<td>$date</td>\n"; 
     1406                        $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='checkbox' name='revisionstocompare[]' value='$revision->ID' /></th>\n"; 
     1407                        $rows .= "\t<td>$avatar $date</td>\n"; 
    14091408                        $rows .= "\t<td>$name</td>\n"; 
    1410                         $rows .= "\t<td class='action-links'>$actions</td>\n"; 
    14111409                        $rows .= "</tr>\n"; 
    14121410                } else { 
    1413                         $title = sprintf( $titlef, $date, $name ); 
     1411                        $title = sprintf( $titlef, $datelinktodiff, $name ); 
    14141412                        $rows .= "\t<li>$title</li>\n"; 
    14151413                } 
    14161414        } 
    14171415 
    14181416        if ( 'form-table' == $format ) : ?> 
    1419  
    1420 <form action="revision.php" method="get"> 
    1421  
     1417<form action="revision.php" method="get" id='revision-list-form'> 
     1418<hr /> 
    14221419<div class="tablenav"> 
    1423         <div class="alignleft"> 
    1424                 <input type="submit" class="button-secondary" value="<?php esc_attr_e( 'Compare Revisions' ); ?>" /> 
     1420        <div class='revision-post-list-title'><?php _e( 'Pick two revisions to compare' ) ?></div> 
     1421        <div class="alignright"> 
     1422                <input type="submit" class="button-secondary compare-revisions no-js" value="<?php esc_attr_e( 'Compare Revisions' ); ?>" /> 
    14251423                <input type="hidden" name="action" value="diff" /> 
    14261424                <input type="hidden" name="post_type" value="<?php echo esc_attr($post->post_type); ?>" /> 
    14271425        </div> 
    14281426</div> 
    14291427 
    1430 <br class="clear" /> 
    1431  
    14321428<table class="widefat post-revisions" cellspacing="0" id="post-revisions"> 
    14331429        <col /> 
    1434         <col /> 
    1435         <col style="width: 33%" /> 
    1436         <col style="width: 33%" /> 
    1437         <col style="width: 33%" /> 
    1438 <thead> 
    1439 <tr> 
    1440         <th scope="col"><?php /* translators: column name in revisions */ _ex( 'Old', 'revisions column name' ); ?></th> 
    1441         <th scope="col"><?php /* translators: column name in revisions */ _ex( 'New', 'revisions column name' ); ?></th> 
    1442         <th scope="col"><?php /* translators: column name in revisions */ _ex( 'Date Created', 'revisions column name' ); ?></th> 
    1443         <th scope="col"><?php _e( 'Author' ); ?></th> 
    1444         <th scope="col" class="action-links"><?php _e( 'Actions' ); ?></th> 
    1445 </tr> 
    1446 </thead> 
     1430        <col style="width: 40%" /> 
     1431        <col style="width: 59%" /> 
    14471432<tbody> 
    14481433 
    14491434<?php echo $rows; ?> 
  • wp-includes/js/wp-list-revisions.js

     
    66                        var i, checkCount = 0, side; 
    77                        for ( i = 0; i < inputs.length; i++ ) { 
    88                                checkCount += inputs[i].checked ? 1 : 0; 
    9                                 side = inputs[i].getAttribute('name'); 
    10                                 if ( ! inputs[i].checked && 
    11                                 ( 'left' == side && 1 > checkCount || 'right' == side && 1 < checkCount && ( ! inputs[i-1] || ! inputs[i-1].checked ) ) && 
    12                                 ! ( inputs[i+1] && inputs[i+1].checked && 'right' == inputs[i+1].getAttribute('name') ) ) 
    13                                         inputs[i].style.visibility = 'hidden'; 
    14                                 else if ( 'left' == side || 'right' == side ) 
    15                                         inputs[i].style.visibility = 'visible'; 
    169                        } 
     10 
     11                        if ( 2 == checkCount ) { 
     12                                document.getElementById('revision-list-form').submit(); 
     13                        } 
     14 
    1715                } 
    1816                pr.onclick(); 
    1917        } 
  • wp-includes/wp-diff.php

     
    9898         * @return string 
    9999         */ 
    100100        function addedLine( $line ) { 
    101                 return "<td>+</td><td class='diff-addedline'>{$line}</td>"; 
     101                return "<td class='diff-addedline-indicator'>+</td><td class='diff-addedline'>{$line}</td>"; 
    102102        } 
    103103 
    104104        /** 
     
    108108         * @return string 
    109109         */ 
    110110        function deletedLine( $line ) { 
    111                 return "<td>-</td><td class='diff-deletedline'>{$line}</td>"; 
     111                return "<td class='diff-deletedline-indicator'>-</td><td class='diff-deletedline'>{$line}</td>"; 
    112112        } 
    113113 
    114114        /** 
     
    118118         * @return string 
    119119         */ 
    120120        function contextLine( $line ) { 
    121                 return "<td> </td><td class='diff-context'>{$line}</td>"; 
     121                return "<td class='context-indicator'></td><td class='diff-context'>{$line}</td>"; 
    122122        } 
    123123 
    124124        /** 
     
    142142                $r = ''; 
    143143                foreach ($lines as $line) { 
    144144                        if ( $encode ) 
    145                                 $line = htmlspecialchars( $line ); 
     145                                $line = wp_kses_post( $line ); 
    146146                        $r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; 
    147147                } 
    148148                return $r; 
     
    160160                $r = ''; 
    161161                foreach ($lines as $line) { 
    162162                        if ( $encode ) 
    163                                 $line = htmlspecialchars( $line ); 
     163                                $line = ( $line ); 
    164164                        $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n"; 
    165165                } 
    166166                return $r; 
     
    178178                $r = ''; 
    179179                foreach ($lines as $line) { 
    180180                        if ( $encode ) 
    181                                 $line = htmlspecialchars( $line ); 
     181                                $line = wp_kses_post( $line ); 
    182182                        $r .= '<tr>' . 
    183183                                $this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n"; 
    184184                } 
     
    248248                        if ( isset( $orig_diffs[$orig_rows[$row]] ) ) 
    249249                                $orig_line = $orig_diffs[$orig_rows[$row]]; 
    250250                        elseif ( isset( $orig[$orig_rows[$row]] ) ) 
    251                                 $orig_line = htmlspecialchars($orig[$orig_rows[$row]]); 
     251                                $orig_line = wp_kses_post($orig[$orig_rows[$row]]); 
    252252                        else 
    253253                                $orig_line = ''; 
    254254 
    255255                        if ( isset( $final_diffs[$final_rows[$row]] ) ) 
    256256                                $final_line = $final_diffs[$final_rows[$row]]; 
    257257                        elseif ( isset( $final[$final_rows[$row]] ) ) 
    258                                 $final_line = htmlspecialchars($final[$final_rows[$row]]); 
     258                                $final_line = wp_kses_post($final[$final_rows[$row]]); 
    259259                        else 
    260260                                $final_line = ''; 
    261261 
  • wp-includes/pluggable.php

     
    17431743        return $r; 
    17441744} 
    17451745endif; 
     1746function wp_text_diff_with_count( $left_string, $right_string, $args = null ) { 
     1747        $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' ); 
     1748        $args = wp_parse_args( $args, $defaults ); 
     1749 
     1750        if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) ) 
     1751                require( ABSPATH . WPINC . '/wp-diff.php' ); 
     1752 
     1753        $left_string  = normalize_whitespace( $left_string ); 
     1754        $right_string = normalize_whitespace( $right_string ); 
     1755 
     1756        $left_lines  = explode( "\n", $left_string ); 
     1757        $right_lines = explode( "\n", $right_string) ; 
     1758 
     1759        $text_diff = new Text_Diff($left_lines, $right_lines  ); 
     1760        $linesadded = $text_diff->countAddedLines(); 
     1761        $linesdeleted = $text_diff->countDeletedLines(); 
     1762 
     1763        $renderer  = new WP_Text_Diff_Renderer_Table(); 
     1764        $diff = $renderer->render( $text_diff ); 
     1765 
     1766        if ( !$diff ) 
     1767                return ''; 
     1768 
     1769        $r  = "<table class='diff'>\n"; 
     1770        $r .= "<col class='ltype' /><col class='content' /><col class='ltype' /><col class='content' />"; 
     1771 
     1772        if ( $args['title'] || $args['title_left'] || $args['title_right'] ) 
     1773                $r .= "<thead>"; 
     1774        if ( $args['title'] ) 
     1775                $r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n"; 
     1776        if ( $args['title_left'] || $args['title_right'] ) { 
     1777                $r .= "<tr class='diff-sub-title'>\n"; 
     1778                $r .= "\t<td id=\"left\"></td><th>$args[title_left]</th>\n"; 
     1779                $r .= "\t<td id=\"right\"></td><th>$args[title_right]</th>\n"; 
     1780                $r .= "</tr>\n"; 
     1781        } 
     1782        if ( $args['title'] || $args['title_left'] || $args['title_right'] ) 
     1783                $r .= "</thead>\n"; 
     1784 
     1785        $r .= "<tbody>\n$diff\n</tbody>\n"; 
     1786        $r .= "</table>"; 
     1787 
     1788        return array( 'html' => $r, 'linesadded' => $linesadded, 'linesdeleted' => $linesdeleted ); 
     1789} 
     1790 No newline at end of file 
  • wp-admin/revision.php

     
    1111 
    1212wp_enqueue_script('list-revisions'); 
    1313 
    14 wp_reset_vars(array('revision', 'left', 'right', 'action')); 
     14wp_reset_vars( array( 'revision', 'left', 'right', 'action' ) ); 
    1515 
    1616$revision_id = absint($revision); 
    1717$left        = absint($left); 
     
    1919 
    2020$redirect = 'edit.php'; 
    2121 
     22if ( isset( $_GET['revisionstocompare'] ) ) { 
     23        $revisionstocompare = $_GET['revisionstocompare']; 
     24        $left        = absint( $revisionstocompare[1] ); 
     25        $right       = absint( $revisionstocompare[0] ); 
     26} 
     27 
     28 
    2229switch ( $action ) : 
    2330case 'restore' : 
    2431        if ( !$revision = wp_get_post_revision( $revision_id ) ) 
     
    93100                break; 
    94101 
    95102        $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; 
    96         $h2 = sprintf( __( 'Compare Revisions of &#8220;%1$s&#8221;' ), $post_title ); 
     103        $h2 = sprintf( __( 'Comparing revisions of %1$s' ), $post_title ); 
    97104        $title = __( 'Revisions' ); 
    98105 
    99106        $left  = $left_revision->ID; 
     
    135142        $redirect = 'edit.php'; 
    136143 
    137144if ( !empty($redirect) ) { 
     145        $redirect = remove_query_arg( 'revisionstocompare', $redirect ); 
    138146        wp_redirect( $redirect ); 
    139147        exit; 
    140148} 
     
    146154        $parent_file = $submenu_file = 'edit.php'; 
    147155 
    148156require_once( './admin-header.php' ); 
    149  
    150157?> 
    151158 
    152159<div class="wrap"> 
    153  
    154160<h2 class="long-header"><?php echo $h2; ?></h2> 
    155  
     161<hr /> 
     162<strong>Notes:</strong><br /> 
     163Haddock rockfish pearleye; bowfin slender mola longnose lancetfish; North Pacific daggertooth swamp-eel brown trout lake chub.  
     164Dottyback warmouth, California halibut rockfish pumpkinseed Pacific cod. 
     165Hoodie ut cray kogi, blog craft beer odd future. Pork belly locavore cosby sweater, sustainable umami meh quinoa in master cleanse. 
     166<hr /> 
    156167<table class="form-table ie-fixed"> 
    157         <col class="th" /> 
    158168<?php if ( 'diff' == $action ) : ?> 
    159169<tr id="revision"> 
    160         <th scope="row"></th> 
    161170        <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> 
     171                <table width="100%" cellspacing="0" cellpadding="0">  
     172                        <tr> 
     173                                <td width="50%"> 
     174                                        <?php printf('<div class="revision-type-left">%s</div><div class="revision-avatar-left">%s</div><div class="revision-title-left">%s</div>', 
     175                                                                        __('Older'),  
     176                                                                        get_avatar( $left_revision->post_author, 22 ), 
     177                                                                        wp_post_revision_title( $left_revision ) 
     178                                                                 ); ?> 
     179                                </td> 
     180                                <td width="50%"> 
     181                                        <?php printf('<div class="revision-type-right">%s</div><div class="revision-avatar-right">%s</div><div class="revision-title-right">%s</div>', 
     182                                                                        __('Newer'),  
     183                                                                        get_avatar( $right_revision->post_author, 22 ), 
     184                                                                        wp_post_revision_title( $right_revision ) 
     185                                                                 ); ?> 
     186                                </td> 
     187                        </tr> 
     188                </table> 
    164189        </th> 
    165190</tr> 
    166191<?php endif; 
    167192 
    168193// use get_post_to_edit filters? 
    169194$identical = true; 
     195$linesadded=0; 
     196$linesdeleted=0; 
    170197foreach ( _wp_post_revision_fields() as $field => $field_title ) : 
    171198        if ( 'diff' == $action ) { 
    172199                $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field ); 
    173200                $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field ); 
    174                 if ( !$content = wp_text_diff( $left_content, $right_content ) ) 
     201                if ( !$content = wp_text_diff_with_count( $left_content, $right_content ) ) 
    175202                        continue; // There is no difference between left and right 
     203                $htmlcontent = $content[ 'html' ]; 
     204                $linesadded += $content[ 'linesadded' ]; 
     205                $linesdeleted += $content[ 'linesdeleted' ]; 
     206 
    176207                $identical = false; 
    177208        } else { 
    178                 add_filter( "_wp_post_revision_field_$field", 'htmlspecialchars' ); 
    179                 $content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field ); 
     209                add_filter( "_wp_post_revision_field_$field", 'wp_kses_post' ); 
     210                $htmlcontent = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field ); 
    180211        } 
     212 
    181213        ?> 
    182214 
    183215        <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> 
     216                <td><div class="pre"><?php echo $htmlcontent; ?></div></td> 
    186217        </tr> 
    187218 
    188219        <?php 
    189220 
    190221endforeach; 
     222?> 
     223<div class="revision-summary-area"> 
     224        <div class="revisions-header-deleted"><?php echo (0 != $linesdeleted ? '-' : '' ) . $linesdeleted; ?></div> 
     225        <div class="revisions-header-added"><?php echo (0 != $linesadded ? '+' : '' ) . $linesadded; ?></div> 
     226</div> 
     227<?php 
    191228 
    192229if ( 'diff' == $action && $identical ) : 
    193230 
     
    205242 
    206243<br class="clear" /> 
    207244 
    208 <h3><?php echo $title; ?></h3> 
    209  
    210245<?php 
    211246 
    212247$args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); 
  • wp-admin/css/colors-fresh.css

     
    13501350 
    13511351/* Diff */ 
    13521352table.diff .diff-deletedline { 
    1353         background-color: #fdd; 
     1353        background-color: #EC9898; 
    13541354} 
    13551355 
     1356table.diff .diff-deletedline-indicator, .revisions-header-deleted { 
     1357        color: #D4362F; /* dark red for - (deleted) symbol and header diffs*/ 
     1358} 
     1359.revision-summary-area { /*move the diff summary to the upper right*/ 
     1360        position: absolute; 
     1361        top: 20px; 
     1362        right: 20px; 
     1363} 
     1364.revisions-header-deleted, .revisions-header-added { 
     1365        float: right; 
     1366        font-size: 1.6em; 
     1367        font-weight: bold; 
     1368        padding: 3px; 
     1369} 
     1370 
     1371.revision-post-list-title { 
     1372        float: left; 
     1373        font-weight: bold; 
     1374        font-size: 16px; 
     1375        line-height: 24px; 
     1376        color: #676767; 
     1377} 
     1378 
    13561379table.diff .diff-deletedline del { 
    13571380        background-color: #f99; 
    13581381} 
    13591382 
    13601383table.diff .diff-addedline { 
    1361         background-color: #dfd; 
     1384        background-color: #B5D8A6; 
    13621385} 
    13631386 
     1387table.diff .diff-addedline-indicator, .revisions-header-added { 
     1388        color: #00A100; /* dark green for + (added) symbol and header diffs */ 
     1389} 
     1390 
     1391table.diff li {  
     1392        margin-left: 12px; /*add some left margin to li's in the diff or they hand outside the box*/ 
     1393} 
     1394 
    13641395table.diff .diff-addedline ins { 
    13651396        background-color: #9f9; 
    13661397} 
  • wp-admin/css/wp-admin.css

     
    44114411.form-table td { 
    44124412        margin-bottom: 9px; 
    44134413        padding: 8px 10px; 
    4414         line-height: 20px; 
     4414        line-height: 24px; 
    44154415        font-size: 12px; 
    44164416} 
    44174417 
     
    85858585.locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap { 
    85868586        margin-left: 8em; 
    85878587} 
     8588.revision-title-left { 
     8589        float: right; 
     8590        font-size: 1.1em; 
     8591} 
     8592 
     8593.revision-title-right { 
     8594        float: left; 
     8595        font-size: 1.1em; 
     8596} 
     8597 
     8598.revision-type-left { 
     8599        float: left; 
     8600        font-size: 1.4em; 
     8601        color: #999; 
     8602} 
     8603 
     8604.revision-type-right { 
     8605        float: right; 
     8606        font-size: 1.4em; 
     8607        color: #999; 
     8608} 
     8609 
     8610.revision-avatar-left { 
     8611        float: right; 
     8612        margin-left: 5px; 
     8613} 
     8614 
     8615.revision-avatar-right { 
     8616        float: left; 
     8617        margin-right: 5px; 
     8618        margin-left: 30px; 
     8619} 
     8620 
     8621.form-table tr#revision th { 
     8622        vertical-align: top; 
     8623        text-align: left; 
     8624        padding-top: 10px; 
     8625        padding-bottom: 10px; 
     8626        padding-right: 10px; 
     8627        padding-left: 0; 
     8628        width: 200px; 
     8629} 
     8630 
     8631.form-table tr#revision td { 
     8632        font-size: 12px; 
     8633        line-height: 24px; 
     8634        margin-bottom: 9px; 
     8635        padding-top: 8px; 
     8636        padding-bottom: 8px; 
     8637        padding-right: 10px; 
     8638        padding-left: 0; 
     8639} 
     8640 
     8641.form-table tr#revision-field-post_content .pre { 
     8642        margin: 0; 
     8643        padding: 0; 
     8644} 
     8645 
     8646.form-table  tr#revision-field-post_content td { 
     8647        font-size: 12px; 
     8648        line-height: 24px; 
     8649        margin-bottom: 9px; 
     8650        padding: 8px 10px; 
     8651} 
     8652 
     8653 
     8654.form-table tr#revision-field-post_content td.diff-addedline-indicator { 
     8655        padding-left: 30px; 
     8656} 
     8657table.post-revisions a { 
     8658        line-height: 24px; 
     8659} 
     8660table.post-revisions img { 
     8661        float: left; 
     8662        margin-right: 5px; 
     8663}