Ticket #23396: version-1.diff
File version-1.diff, 17.4 KB (added by , 12 years ago) |
---|
-
wp-includes/post-template.php
1301 1301 return false; 1302 1302 1303 1303 /* 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' ); 1305 1305 /* translators: 1: date */ 1306 1306 $autosavef = __( '%1$s [Autosave]' ); 1307 1307 /* translators: 1: date */ 1308 1308 $currentf = __( '%1$s [Current Revision]' ); 1309 1309 1310 $author = get_the_author_meta( 'display_name', $revision->post_author ); 1311 1310 1312 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 1311 1313 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>"; 1313 1315 1314 1316 if ( !wp_is_post_revision( $revision ) ) 1315 1317 $date = sprintf( $currentf, $date ); … … 1386 1388 continue; 1387 1389 1388 1390 $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 ) ); 1390 1393 1394 $name = 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor.'; 1395 $avatar = get_avatar( $revision->post_author, 22 ); 1391 1396 if ( 'form-table' == $format ) { 1392 if ( $left )1393 $left_checked = $left == $revision->ID ? ' checked="checked"' : '';1394 else1395 $left_checked = $right_checked ? ' checked="checked"' : ''; // [sic] (the next one)1396 $right_checked = $right == $revision->ID ? ' checked="checked"' : '';1397 1397 1398 1398 $class = $class ? '' : " class='alternate'"; 1399 1399 1400 1400 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>'; 1402 1402 else 1403 1403 $actions = ''; 1404 1404 1405 1405 $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"; 1409 1408 $rows .= "\t<td>$name</td>\n"; 1410 $rows .= "\t<td class='action-links'>$actions</td>\n";1411 1409 $rows .= "</tr>\n"; 1412 1410 } else { 1413 $title = sprintf( $titlef, $date , $name );1411 $title = sprintf( $titlef, $datelinktodiff, $name ); 1414 1412 $rows .= "\t<li>$title</li>\n"; 1415 1413 } 1416 1414 } 1417 1415 1418 1416 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 /> 1422 1419 <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' ); ?>" /> 1425 1423 <input type="hidden" name="action" value="diff" /> 1426 1424 <input type="hidden" name="post_type" value="<?php echo esc_attr($post->post_type); ?>" /> 1427 1425 </div> 1428 1426 </div> 1429 1427 1430 <br class="clear" />1431 1432 1428 <table class="widefat post-revisions" cellspacing="0" id="post-revisions"> 1433 1429 <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%" /> 1447 1432 <tbody> 1448 1433 1449 1434 <?php echo $rows; ?> -
wp-includes/js/wp-list-revisions.js
6 6 var i, checkCount = 0, side; 7 7 for ( i = 0; i < inputs.length; i++ ) { 8 8 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';16 9 } 10 11 if ( 2 == checkCount ) { 12 document.getElementById('revision-list-form').submit(); 13 } 14 17 15 } 18 16 pr.onclick(); 19 17 } -
wp-includes/wp-diff.php
98 98 * @return string 99 99 */ 100 100 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>"; 102 102 } 103 103 104 104 /** … … 108 108 * @return string 109 109 */ 110 110 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>"; 112 112 } 113 113 114 114 /** … … 118 118 * @return string 119 119 */ 120 120 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>"; 122 122 } 123 123 124 124 /** … … 142 142 $r = ''; 143 143 foreach ($lines as $line) { 144 144 if ( $encode ) 145 $line = htmlspecialchars( $line );145 $line = wp_kses_post( $line ); 146 146 $r .= '<tr>' . $this->emptyLine() . $this->addedLine( $line ) . "</tr>\n"; 147 147 } 148 148 return $r; … … 160 160 $r = ''; 161 161 foreach ($lines as $line) { 162 162 if ( $encode ) 163 $line = htmlspecialchars( $line );163 $line = ( $line ); 164 164 $r .= '<tr>' . $this->deletedLine( $line ) . $this->emptyLine() . "</tr>\n"; 165 165 } 166 166 return $r; … … 178 178 $r = ''; 179 179 foreach ($lines as $line) { 180 180 if ( $encode ) 181 $line = htmlspecialchars( $line );181 $line = wp_kses_post( $line ); 182 182 $r .= '<tr>' . 183 183 $this->contextLine( $line ) . $this->contextLine( $line ) . "</tr>\n"; 184 184 } … … 248 248 if ( isset( $orig_diffs[$orig_rows[$row]] ) ) 249 249 $orig_line = $orig_diffs[$orig_rows[$row]]; 250 250 elseif ( isset( $orig[$orig_rows[$row]] ) ) 251 $orig_line = htmlspecialchars($orig[$orig_rows[$row]]);251 $orig_line = wp_kses_post($orig[$orig_rows[$row]]); 252 252 else 253 253 $orig_line = ''; 254 254 255 255 if ( isset( $final_diffs[$final_rows[$row]] ) ) 256 256 $final_line = $final_diffs[$final_rows[$row]]; 257 257 elseif ( isset( $final[$final_rows[$row]] ) ) 258 $final_line = htmlspecialchars($final[$final_rows[$row]]);258 $final_line = wp_kses_post($final[$final_rows[$row]]); 259 259 else 260 260 $final_line = ''; 261 261 -
wp-includes/pluggable.php
1743 1743 return $r; 1744 1744 } 1745 1745 endif; 1746 function 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
11 11 12 12 wp_enqueue_script('list-revisions'); 13 13 14 wp_reset_vars( array('revision', 'left', 'right', 'action'));14 wp_reset_vars( array( 'revision', 'left', 'right', 'action' ) ); 15 15 16 16 $revision_id = absint($revision); 17 17 $left = absint($left); … … 19 19 20 20 $redirect = 'edit.php'; 21 21 22 if ( isset( $_GET['revisionstocompare'] ) ) { 23 $revisionstocompare = $_GET['revisionstocompare']; 24 $left = absint( $revisionstocompare[1] ); 25 $right = absint( $revisionstocompare[0] ); 26 } 27 28 22 29 switch ( $action ) : 23 30 case 'restore' : 24 31 if ( !$revision = wp_get_post_revision( $revision_id ) ) … … 93 100 break; 94 101 95 102 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; 96 $h2 = sprintf( __( 'Compar e Revisions of “%1$s”' ), $post_title );103 $h2 = sprintf( __( 'Comparing revisions of %1$s' ), $post_title ); 97 104 $title = __( 'Revisions' ); 98 105 99 106 $left = $left_revision->ID; … … 135 142 $redirect = 'edit.php'; 136 143 137 144 if ( !empty($redirect) ) { 145 $redirect = remove_query_arg( 'revisionstocompare', $redirect ); 138 146 wp_redirect( $redirect ); 139 147 exit; 140 148 } … … 146 154 $parent_file = $submenu_file = 'edit.php'; 147 155 148 156 require_once( './admin-header.php' ); 149 150 157 ?> 151 158 152 159 <div class="wrap"> 153 154 160 <h2 class="long-header"><?php echo $h2; ?></h2> 155 161 <hr /> 162 <strong>Notes:</strong><br /> 163 Haddock rockfish pearleye; bowfin slender mola longnose lancetfish; North Pacific daggertooth swamp-eel brown trout lake chub. 164 Dottyback warmouth, California halibut rockfish pumpkinseed Pacific cod. 165 Hoodie ut cray kogi, blog craft beer odd future. Pork belly locavore cosby sweater, sustainable umami meh quinoa in master cleanse. 166 <hr /> 156 167 <table class="form-table ie-fixed"> 157 <col class="th" />158 168 <?php if ( 'diff' == $action ) : ?> 159 169 <tr id="revision"> 160 <th scope="row"></th>161 170 <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> 164 189 </th> 165 190 </tr> 166 191 <?php endif; 167 192 168 193 // use get_post_to_edit filters? 169 194 $identical = true; 195 $linesadded=0; 196 $linesdeleted=0; 170 197 foreach ( _wp_post_revision_fields() as $field => $field_title ) : 171 198 if ( 'diff' == $action ) { 172 199 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field ); 173 200 $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 ) ) 175 202 continue; // There is no difference between left and right 203 $htmlcontent = $content[ 'html' ]; 204 $linesadded += $content[ 'linesadded' ]; 205 $linesdeleted += $content[ 'linesdeleted' ]; 206 176 207 $identical = false; 177 208 } 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 ); 180 211 } 212 181 213 ?> 182 214 183 215 <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> 186 217 </tr> 187 218 188 219 <?php 189 220 190 221 endforeach; 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 191 228 192 229 if ( 'diff' == $action && $identical ) : 193 230 … … 205 242 206 243 <br class="clear" /> 207 244 208 <h3><?php echo $title; ?></h3>209 210 245 <?php 211 246 212 247 $args = array( 'format' => 'form-table', 'parent' => true, 'right' => $right, 'left' => $left ); -
wp-admin/css/colors-fresh.css
1350 1350 1351 1351 /* Diff */ 1352 1352 table.diff .diff-deletedline { 1353 background-color: # fdd;1353 background-color: #EC9898; 1354 1354 } 1355 1355 1356 table.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 1356 1379 table.diff .diff-deletedline del { 1357 1380 background-color: #f99; 1358 1381 } 1359 1382 1360 1383 table.diff .diff-addedline { 1361 background-color: # dfd;1384 background-color: #B5D8A6; 1362 1385 } 1363 1386 1387 table.diff .diff-addedline-indicator, .revisions-header-added { 1388 color: #00A100; /* dark green for + (added) symbol and header diffs */ 1389 } 1390 1391 table.diff li { 1392 margin-left: 12px; /*add some left margin to li's in the diff or they hand outside the box*/ 1393 } 1394 1364 1395 table.diff .diff-addedline ins { 1365 1396 background-color: #9f9; 1366 1397 } -
wp-admin/css/wp-admin.css
4411 4411 .form-table td { 4412 4412 margin-bottom: 9px; 4413 4413 padding: 8px 10px; 4414 line-height: 2 0px;4414 line-height: 24px; 4415 4415 font-size: 12px; 4416 4416 } 4417 4417 … … 8585 8585 .locale-lt-lt .inline-edit-row fieldset label span.input-text-wrap { 8586 8586 margin-left: 8em; 8587 8587 } 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 } 8657 table.post-revisions a { 8658 line-height: 24px; 8659 } 8660 table.post-revisions img { 8661 float: left; 8662 margin-right: 5px; 8663 }