Ticket #18733: Qucik Revision.patch
| File Qucik Revision.patch, 8.3 KB (added by , 13 years ago) |
|---|
-
wp-admin/revision.php
117 117 break; 118 118 } 119 119 120 $revision_num = wp_post_revision_num( $revision, false ); 120 121 $post_title = '<a href="' . get_edit_post_link() . '">' . get_the_title() . '</a>'; 121 122 $revision_title = wp_post_revision_title( $revision, false ); 122 $h2 = sprintf( __( 'Revision for “%1$s” created on %2$s' ), $post_title, $revision_title );123 $h2 = sprintf( __( 'Revision %1$s for “%2$s” created on %3$s' ), $revision_num, $post_title, $revision_title ); 123 124 $title = __( 'Revisions' ); 124 125 125 126 // Sets up the diff radio buttons … … 155 156 156 157 <table class="form-table ie-fixed"> 157 158 <col class="th" /> 158 <?php if ( 'diff' == $action ) : ?> 159 <?php if ( 'diff' == $action ) : 160 $left_revision_num = wp_post_revision_num( $left_revision, true ); 161 $right_revision_num = wp_post_revision_num( $right_revision, true ); 162 ?> 159 163 <tr id="revision"> 160 164 <th scope="row"></th> 161 165 <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>166 <span class="alignleft"><?php printf( __('Older: %s'), wp_post_revision_title( $left_revision ) ); ?> <?php echo $left_revision_num; ?></span> 167 <span class="alignright"><?php printf( __('Newer: %s'), wp_post_revision_title( $right_revision ) ); ?> <?php echo $right_revision_num; ?></span> 164 168 </th> 165 169 </tr> 166 170 <?php endif; … … 171 175 if ( 'diff' == $action ) { 172 176 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field ); 173 177 $right_content = apply_filters( "_wp_post_revision_field_$field", $right_revision->$field, $field ); 178 174 179 if ( !$content = wp_text_diff( $left_content, $right_content ) ) 175 180 continue; // There is no difference between left and right 176 181 $identical = false; … … 188 193 <?php 189 194 190 195 endforeach; 191 192 196 if ( 'diff' == $action && $identical ) : 193 197 194 198 ?> -
wp-includes/pluggable.php
1743 1743 return $r; 1744 1744 } 1745 1745 endif; 1746 1747 1748 1749 function wp_text_diff1( $left_string, $right_string, $args = null ) { 1750 $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' ); 1751 $args = wp_parse_args( $args, $defaults ); 1752 1753 if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) ) 1754 require( ABSPATH . WPINC . '/wp-diff.php' ); 1755 1756 $left_string = normalize_whitespace($left_string); 1757 $right_string = normalize_whitespace($right_string); 1758 1759 $left_lines = explode("\n", $left_string); 1760 $right_lines = explode("\n", $right_string); 1761 1762 $text_diff = new Text_Diff($left_lines, $right_lines); 1763 $renderer = new Text_Diff_Renderer_inline(); 1764 $diff = $renderer->render($text_diff); 1765 1766 if ( !$diff ) 1767 return ''; 1768 1769 $r = "$diff"; 1770 return $r; 1771 } -
wp-includes/post-template.php
1319 1319 return $date; 1320 1320 } 1321 1321 1322 /** 1323 * Retrieve revision id of a revision (linked to that revisions's page). 1324 * 1325 * @package WordPress 1326 * @subpackage Post_Revisions 1327 * @since 3.6 1328 * 1329 * @param int|object $revision Revision ID or revision object. 1330 * @param bool $link Optional, default is true. Link to revisions's page? 1331 * @return string revision number or link to revision page. 1332 */ 1333 1334 function wp_post_revision_num($revision, $link = true) { 1335 if ( !$revision = get_post( $revision ) ) 1336 return $revision; 1337 1338 if ( !in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) 1339 return false; 1340 1341 if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) 1342 $revision_num = "<a href='$link'>#$revision->ID</a>"; 1343 else 1344 $revision_num = "#$revision->ID"; 1345 1346 return $revision_num; 1347 } 1348 1322 1349 /** 1323 1350 * Display list of a post's revisions. 1324 1351 * … … 1369 1396 return; 1370 1397 break; 1371 1398 } 1372 1399 1373 1400 /* translators: post revision: 1: when, 2: author name */ 1374 1401 $titlef = _x( '%1$s by %2$s', 'post revision' ); 1375 1402 … … 1379 1406 $rows = $right_checked = ''; 1380 1407 $class = false; 1381 1408 $can_edit_post = current_user_can( 'edit_post', $post->ID ); 1409 $pre_revision = $post; 1382 1410 foreach ( $revisions as $revision ) { 1383 1411 if ( !current_user_can( 'read_post', $revision->ID ) ) 1384 1412 continue; 1385 1413 if ( 'revision' === $type && wp_is_post_autosave( $revision ) ) 1386 1414 continue; 1387 1415 $revision_num = wp_post_revision_num( $revision ); 1388 1416 $date = wp_post_revision_title( $revision ); 1389 1417 $name = get_the_author_meta( 'display_name', $revision->post_author ); 1390 1418 … … 1405 1433 $rows .= "<tr$class>\n"; 1406 1434 $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='left' value='$revision->ID'$left_checked /></th>\n"; 1407 1435 $rows .= "\t<th style='white-space: nowrap' scope='row'><input type='radio' name='right' value='$revision->ID'$right_checked /></th>\n"; 1436 $rows .= "\t<td>$revision_num</td>\n"; 1408 1437 $rows .= "\t<td>$date</td>\n"; 1409 1438 $rows .= "\t<td>$name</td>\n"; 1410 1439 $rows .= "\t<td class='action-links'>$actions</td>\n"; 1411 1440 $rows .= "</tr>\n"; 1412 1441 } else { 1413 1442 $title = sprintf( $titlef, $date, $name ); 1414 $rows .= "\t<li>$title</li>\n"; 1443 $rows1 = "<ul class='revision-changes'>"; 1444 foreach ( _wp_post_revision_fields() as $field => $field_title ) : 1445 1446 $left_content = apply_filters( "_wp_post_revision_field_$field", $revision->$field, $field ); 1447 $right_content = apply_filters( "_wp_post_revision_field_$field", $pre_revision->$field, $field ); 1448 if ( !$content = wp_text_diff1( $left_content, $right_content ) ) 1449 continue; // There is no difference between left and right 1450 1451 $rows1 .= '<li class="revision-change"> 1452 '.esc_html( $field_title ).' 1453 <div class="pre">'. $content .'</div> 1454 </li>'; 1455 1456 endforeach; 1457 $rows1 .= "</ul>"; 1458 $pre_revision = $revision; 1459 $rows .= "\t<li>$title $revision_num 1460 <div class='show-rev-changes'> 1461 <a href='javascript:void(0);' class='show-changes'>Show Changes</a> 1462 <a href='javascript:void(0);'>< Prev</a> 1463 <a href='javascript:void(0);'>Next ></a> 1464 </div> 1465 <div class='revision-change-sets'>$rows1</div> 1466 </li>\n"; 1415 1467 } 1416 1468 } 1417 1469 … … 1432 1484 <table class="widefat post-revisions" cellspacing="0" id="post-revisions"> 1433 1485 <col /> 1434 1486 <col /> 1487 <col /> 1435 1488 <col style="width: 33%" /> 1436 1489 <col style="width: 33%" /> 1437 1490 <col style="width: 33%" /> … … 1439 1492 <tr> 1440 1493 <th scope="col"><?php /* translators: column name in revisions */ _ex( 'Old', 'revisions column name' ); ?></th> 1441 1494 <th scope="col"><?php /* translators: column name in revisions */ _ex( 'New', 'revisions column name' ); ?></th> 1495 <th scope="col"><?php /* translators: column name in revisons */ _ex( 'Revision', 'revisions column name' ); ?></th> 1442 1496 <th scope="col"><?php /* translators: column name in revisions */ _ex( 'Date Created', 'revisions column name' ); ?></th> 1443 1497 <th scope="col"><?php _e( 'Author' ); ?></th> 1444 1498 <th scope="col" class="action-links"><?php _e( 'Actions' ); ?></th> … … 1455 1509 1456 1510 <?php 1457 1511 else : 1458 echo "<ul class='post-revisions'>\n";1512 echo "<ul id='post-revisions'>\n"; 1459 1513 echo $rows; 1460 1514 echo "</ul>"; 1515 echo "<script> 1516 jQuery(document).ready(function() { 1517 jQuery('.show-changes').click(function() { 1518 var changesetsDiv = jQuery(this).parent().next(); 1519 console.log(changesetsDiv.children().eq(0).children().show()); 1520 changesetsDiv.toggle(); 1521 }); 1522 }); 1523 </script>"; 1524 1525 echo "<style> 1526 1527 .revision-change-sets { 1528 border:1px solid #DFDFDF; 1529 display: none; 1530 } 1531 .show-rev-changes {float: right;} 1532 .revision-change { 1533 display:none; 1534 } 1535 #post-revisions li { 1536 clear: both; 1537 } 1538 #post-revisions li{background: #F9F9F9} 1539 #post-revisions li:nth-child(2n+1) {background: #FCFCFC} 1540 #post-revisions del { 1541 background: #FF8888; 1542 } 1543 #post-revisions ins { 1544 background: #BBFFBB; 1545 text-decoration: none; 1546 } 1547 </style>"; 1461 1548 endif; 1462 1549 1463 1550 }