Ticket #23497: 23497.20.diff
File 23497.20.diff, 53.1 KB (added by , 12 years ago) |
---|
-
wp-includes/revision.php
62 62 /** 63 63 * Saves an already existing post as a post revision. 64 64 * 65 * Typically used immediately prior to post updates. 65 * Typically used immediately prior and after post updates. 66 * Prior to update checks for old revision data (latest revision != current post before update) and adds a copy of the current post as a revision if missing 67 * After update adds a copy of the current post as a revision, so latest revision always matches current post 66 68 * 67 69 * @package WordPress 68 70 * @subpackage Post_Revisions 69 71 * @since 2.6.0 70 72 * 71 73 * @uses _wp_put_post_revision() 74 * @uses wp_first_revision_matches_current_version() 72 75 * 73 76 * @param int $post_id The ID of the post to save as a revision. 74 77 * @return mixed Null or 0 if error, new revision ID, if success. 75 78 */ 76 function wp_save_post_revision( $post_id, $new_data = null ) { 77 // We do autosaves manually with wp_create_post_autosave() 79 function wp_save_post_revision( $post_id ) { 80 //check to see if the post's first revision already matches the post data 81 //should be true before post update, _except_ for old data which 82 //doesn't include a copy of the current post data in revisions 83 if ( wp_first_revision_matches_current_version( $post_id ) ) 84 return; 85 78 86 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) 79 87 return; 80 88 … … 82 90 if ( ! WP_POST_REVISIONS ) 83 91 return; 84 92 85 if ( ! $post = get_post( $post_id, ARRAY_A ) )93 if ( ! $post = get_post( $post_id, ARRAY_A ) ) 86 94 return; 87 95 88 96 if ( 'auto-draft' == $post['post_status'] ) 89 97 return; 90 98 91 if ( ! post_type_supports($post['post_type'], 'revisions') )99 if ( ! post_type_supports( $post['post_type'], 'revisions' ) ) 92 100 return; 93 101 94 // if new data is supplied, check that it is different from last saved revision, unless a plugin tells us to always save regardless 95 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $post, $new_data ) && is_array( $new_data ) ) { 96 $post_has_changed = false; 97 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 98 if ( normalize_whitespace( $new_data[ $field ] ) != normalize_whitespace( $post[ $field ] ) ) { 99 $post_has_changed = true; 100 break; 102 // compare the proposed update with the last stored revision, verify 103 // different, unless a plugin tells us to always save regardless 104 if ( $revisions = wp_get_post_revisions( $post_id ) ) { // grab the last revision 105 $last_revision = array_shift( $revisions ); 106 107 if ( $last_revision_array = get_post( $last_revision->ID, ARRAY_A ) ) { //if no previous revisions, save one for sure 108 109 if ( apply_filters( 'wp_save_post_revision_check_for_changes', true, $last_revision_array, $post ) && is_array( $post ) ) { 110 $post_has_changed = false; 111 112 foreach ( array_keys( _wp_post_revision_fields() ) as $field ) { 113 114 if ( normalize_whitespace( $post[ $field ] ) != normalize_whitespace( $last_revision_array[ $field ] ) ) { 115 $post_has_changed = true; 116 break; 117 118 } 119 } 120 121 //don't save revision if post unchanged 122 if( ! $post_has_changed ) 123 return; 101 124 } 102 125 } 103 //don't save revision if post unchanged104 if( ! $post_has_changed )105 return;106 126 } 107 127 108 128 $return = _wp_put_post_revision( $post ); 109 129 110 130 // WP_POST_REVISIONS = true (default), -1 111 if ( ! is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 )131 if ( ! is_numeric( WP_POST_REVISIONS ) || WP_POST_REVISIONS < 0 ) 112 132 return $return; 113 133 114 134 // all revisions and (possibly) one autosave 115 135 $revisions = wp_get_post_revisions( $post_id, array( 'order' => 'ASC' ) ); 116 136 117 137 // WP_POST_REVISIONS = (int) (# of autosaves to save) 118 $delete = count( $revisions) - WP_POST_REVISIONS;138 $delete = count( $revisions ) - WP_POST_REVISIONS; 119 139 120 140 if ( $delete < 1 ) 121 141 return $return; … … 123 143 $revisions = array_slice( $revisions, 0, $delete ); 124 144 125 145 for ( $i = 0; isset($revisions[$i]); $i++ ) { 126 if ( false !== strpos( $revisions[ $i]->post_name, 'autosave' ) )146 if ( false !== strpos( $revisions[ $i ]->post_name, 'autosave' ) ) 127 147 continue; 128 wp_delete_post_revision( $revisions[ $i]->ID );148 wp_delete_post_revision( $revisions[ $i ]->ID ); 129 149 } 130 150 131 151 return $return; … … 418 438 add_filter('the_preview', '_set_preview'); 419 439 } 420 440 } 441 442 /** 443 * Determines if the specified post's most recent revision matches the post (by checking post_modified). 444 * 445 * @package WordPress 446 * @subpackage Post_Revisions 447 * @since 3.6.0 448 * 449 * @param int|object $post Post ID or post object. 450 * @return bool false if not a match, otherwise true. 451 */ 452 function wp_first_revision_matches_current_version( $post ) { 453 454 if ( ! $post = get_post( $post ) ) 455 return false; 456 457 if ( ! $revisions = wp_get_post_revisions( $post->ID ) ) 458 return false; 459 460 $last_revision = array_shift( $revisions ); 461 462 if ( ! ($last_revision->post_modified == $post->post_modified ) ) 463 return false; 464 465 return true; 466 } -
wp-includes/pluggable.php
257 257 list( $name, $content ) = explode( ':', trim( $header ), 2 ); 258 258 259 259 // Cleanup crew 260 $name = trim( $name);260 $name = trim( $name ); 261 261 $content = trim( $content ); 262 262 263 263 switch ( strtolower( $name ) ) { … … 337 337 } 338 338 339 339 // Plugin authors can override the potentially troublesome default 340 $phpmailer->From = apply_filters( 'wp_mail_from', $from_email );340 $phpmailer->From = apply_filters( 'wp_mail_from' , $from_email ); 341 341 $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name ); 342 342 343 343 // Set destination addresses … … 362 362 363 363 // Set mail's subject and body 364 364 $phpmailer->Subject = $subject; 365 $phpmailer->Body 365 $phpmailer->Body = $message; 366 366 367 367 // Add any CC and BCC recipients 368 368 if ( !empty( $cc ) ) { … … 619 619 $cookie_name = AUTH_COOKIE; 620 620 $scheme = 'auth'; 621 621 } 622 622 } 623 623 624 624 if ( empty($_COOKIE[$cookie_name]) ) 625 625 return false; … … 694 694 function wp_clear_auth_cookie() { 695 695 do_action('clear_auth_cookie'); 696 696 697 setcookie( AUTH_COOKIE, 697 setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN ); 698 698 setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN ); 699 setcookie( AUTH_COOKIE, 699 setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN ); 700 700 setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN ); 701 setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, 702 setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, 701 setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); 702 setcookie( LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); 703 703 704 704 // Old cookies 705 setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH,COOKIE_DOMAIN );706 setcookie( AUTH_COOKIE, 707 setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, 705 setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); 706 setcookie( AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); 707 setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); 708 708 setcookie( SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); 709 709 710 710 // Even older cookies 711 setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, 712 setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, 711 setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); 712 setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); 713 713 setcookie( USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); 714 714 setcookie( PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN ); 715 715 } … … 988 988 */ 989 989 function wp_notify_postauthor( $comment_id, $comment_type = '' ) { 990 990 $comment = get_comment( $comment_id ); 991 $post 991 $post = get_post( $comment->comment_post_ID ); 992 992 $author = get_userdata( $post->post_author ); 993 993 994 994 // The post author is no longer a member of the blog … … 1020 1020 /* translators: 1: comment author, 2: author IP, 3: author domain */ 1021 1021 $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 1022 1022 $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; 1023 $notify_message .= sprintf( __('URL 1023 $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; 1024 1024 $notify_message .= sprintf( __('Whois : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n"; 1025 1025 $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; 1026 1026 $notify_message .= __('You can see all comments on this post here: ') . "\r\n"; … … 1030 1030 $notify_message = sprintf( __( 'New trackback on your post "%s"' ), $post->post_title ) . "\r\n"; 1031 1031 /* translators: 1: website name, 2: author IP, 3: author domain */ 1032 1032 $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 1033 $notify_message .= sprintf( __('URL 1033 $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; 1034 1034 $notify_message .= __('Excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; 1035 1035 $notify_message .= __('You can see all trackbacks on this post here: ') . "\r\n"; 1036 1036 /* translators: 1: blog name, 2: post title */ … … 1039 1039 $notify_message = sprintf( __( 'New pingback on your post "%s"' ), $post->post_title ) . "\r\n"; 1040 1040 /* translators: 1: comment author, 2: author IP, 3: author domain */ 1041 1041 $notify_message .= sprintf( __('Website: %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 1042 $notify_message .= sprintf( __('URL 1042 $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; 1043 1043 $notify_message .= __('Excerpt: ') . "\r\n" . sprintf('[...] %s [...]', $comment->comment_content ) . "\r\n\r\n"; 1044 1044 $notify_message .= __('You can see all pingbacks on this post here: ') . "\r\n"; 1045 1045 /* translators: 1: blog name, 2: post title */ … … 1118 1118 $notify_message = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n"; 1119 1119 $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; 1120 1120 $notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 1121 $notify_message .= sprintf( __('URL 1121 $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; 1122 1122 $notify_message .= __('Trackback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; 1123 1123 break; 1124 1124 case 'pingback': 1125 1125 $notify_message = sprintf( __('A new pingback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n"; 1126 1126 $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; 1127 1127 $notify_message .= sprintf( __('Website : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 1128 $notify_message .= sprintf( __('URL 1128 $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; 1129 1129 $notify_message .= __('Pingback excerpt: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; 1130 1130 break; 1131 1131 default: //Comments … … 1133 1133 $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; 1134 1134 $notify_message .= sprintf( __('Author : %1$s (IP: %2$s , %3$s)'), $comment->comment_author, $comment->comment_author_IP, $comment_author_domain ) . "\r\n"; 1135 1135 $notify_message .= sprintf( __('E-mail : %s'), $comment->comment_author_email ) . "\r\n"; 1136 $notify_message .= sprintf( __('URL 1136 $notify_message .= sprintf( __('URL : %s'), $comment->comment_author_url ) . "\r\n"; 1137 1137 $notify_message .= sprintf( __('Whois : http://whois.arin.net/rest/ip/%s'), $comment->comment_author_IP ) . "\r\n"; 1138 1138 $notify_message .= __('Comment: ') . "\r\n" . $comment->comment_content . "\r\n\r\n"; 1139 1139 break; … … 1305 1305 * for you. 1306 1306 * 1307 1307 * <code> 1308 * define('AUTH_KEY', 1308 * define('AUTH_KEY', ' Xakm<o xQy rw4EMsLKM-?!T+,PFF})H4lzcW57AF0U@N@< >M%G4Yt>f`z]MON'); 1309 1309 * define('SECURE_AUTH_KEY', 'LzJ}op]mr|6+![P}Ak:uNdJCJZd>(Hx.-Mh#Tz)pCIU#uGEnfFz|f ;;eU%/U^O~'); 1310 * define('LOGGED_IN_KEY', 1311 * define('NONCE_KEY', 1312 * define('AUTH_SALT', 1310 * define('LOGGED_IN_KEY', '|i|Ux`9<p-h$aFf(qnT:sDO:D1P^wZ$$/Ra@miTJi9G;ddp_<q}6H1)o|a +&JCM'); 1311 * define('NONCE_KEY', '%:R{[P|,s.KuMltH5}cI;/k<Gx~j!f0I)m_sIyu+&NJZ)-iO>z7X>QYR0Z_XnZ@|'); 1312 * define('AUTH_SALT', 'eZyT)-Naw]F8CwA*VaW#q*|.)g@o}||wf~@C-YSt}(dh_r6EbI#A,y|nU2{B#JBW'); 1313 1313 * define('SECURE_AUTH_SALT', '!=oLUTXh,QW=H `}`L|9/^4-3 STz},T(w}W<I`.JjPi)<Bmf1v,HpGe}T1:Xt7n'); 1314 1314 * define('LOGGED_IN_SALT', '+XSqHc;@Q*K_b|Z?NC[3H!!EONbh.n<+=uKR:>*c(u`g~EJBf#8u#R{mUEZrozmm'); 1315 * define('NONCE_SALT', 1315 * define('NONCE_SALT', 'h`GXHhD>SLWVfg1(1(N{;.V!MoE(SfbA_ksP@&`+AycHcAV$+?@3q+rxV{%^VyKT'); 1316 1316 * </code> 1317 1317 * 1318 1318 * Salting passwords helps against tools which has stored hashed values of … … 1744 1744 return $r; 1745 1745 } 1746 1746 endif; 1747 1748 1749 if ( !function_exists( 'wp_text_diff_with_count' ) ) : 1750 /** 1751 * Displays a human readable HTML representation of the difference between two strings. 1752 * similar to wp_text_diff, but tracks and returns could of lines added and removed 1753 * 1754 * @since 3.6 1755 * @see wp_parse_args() Used to change defaults to user defined settings. 1756 * @uses Text_Diff 1757 * @uses WP_Text_Diff_Renderer_Table 1758 * 1759 * @param string $left_string "old" (left) version of string 1760 * @param string $right_string "new" (right) version of string 1761 * @param string|array $args Optional. Change 'title', 'title_left', and 'title_right' defaults. 1762 * @return array contains html, linesadded & linesdeletd, empty string if strings are equivalent. 1763 */ 1764 function wp_text_diff_with_count( $left_string, $right_string, $args = null ) { 1765 $defaults = array( 'title' => '', 'title_left' => '', 'title_right' => '' ); 1766 $args = wp_parse_args( $args, $defaults ); 1767 1768 if ( !class_exists( 'WP_Text_Diff_Renderer_Table' ) ) 1769 require( ABSPATH . WPINC . '/wp-diff.php' ); 1770 1771 $left_string = normalize_whitespace( $left_string ); 1772 $right_string = normalize_whitespace( $right_string ); 1773 1774 $left_lines = explode( "\n", $left_string ); 1775 $right_lines = explode( "\n", $right_string) ; 1776 1777 $text_diff = new Text_Diff($left_lines, $right_lines ); 1778 $linesadded = $text_diff->countAddedLines(); 1779 $linesdeleted = $text_diff->countDeletedLines(); 1780 1781 $renderer = new WP_Text_Diff_Renderer_Table(); 1782 $diff = $renderer->render( $text_diff ); 1783 1784 if ( !$diff ) 1785 return ''; 1786 1787 $r = "<table class='diff'>\n"; 1788 1789 if ( ! empty( $args[ 'show_split_view' ] ) ) { 1790 $r .= "<col class='content diffsplit left' /><col class='content diffsplit middle' /><col class='content diffsplit right' />"; 1791 } else { 1792 $r .= "<col class='content' />"; 1793 } 1794 1795 if ( $args['title'] || $args['title_left'] || $args['title_right'] ) 1796 $r .= "<thead>"; 1797 if ( $args['title'] ) 1798 $r .= "<tr class='diff-title'><th colspan='4'>$args[title]</th></tr>\n"; 1799 if ( $args['title_left'] || $args['title_right'] ) { 1800 $r .= "<tr class='diff-sub-title'>\n"; 1801 $r .= "\t<td></td><th>$args[title_left]</th>\n"; 1802 $r .= "\t<td></td><th>$args[title_right]</th>\n"; 1803 $r .= "</tr>\n"; 1804 } 1805 if ( $args['title'] || $args['title_left'] || $args['title_right'] ) 1806 $r .= "</thead>\n"; 1807 1808 $r .= "<tbody>\n$diff\n</tbody>\n"; 1809 $r .= "</table>"; 1810 1811 return array( 'html' => $r, 'linesadded' => $linesadded, 'linesdeleted' => $linesdeleted ); 1812 } 1813 endif; -
wp-includes/script-loader.php
273 273 $scripts->add( 'template', "/wp-includes/js/template$suffix.js", array('underscore'), '1.4.4', 1 ); 274 274 $scripts->add( 'backbone', '/wp-includes/js/backbone.min.js', array('underscore','jquery', 'template'), '0.9.10', 1 ); 275 275 276 $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'backbone', 'jquery-ui-slider' ), false, 1 );276 $scripts->add( 'revisions', "/wp-admin/js/revisions$suffix.js", array( 'backbone', 'jquery-ui-slider', 'jquery-ui-tooltip' ), false, 1 ); 277 277 278 278 $scripts->add( 'imgareaselect', "/wp-includes/js/imgareaselect/jquery.imgareaselect$suffix.js", array('jquery'), '0.9.8', 1 ); 279 279 -
wp-admin/includes/ajax-actions.php
2158 2158 /* translators: revision date format, see http://php.net/date */ 2159 2159 $datef = _x( 'j F, Y @ G:i:s', 'revision date format'); 2160 2160 2161 $left_revision = get_post( $compare_to ); 2162 2161 2163 //single model fetch mode 2162 2164 if ( 0 != $single_revision_id ) { 2163 $left_revision = get_post( $compare_to );2164 2165 $right_revision = get_post( $single_revision_id ); 2165 2166 2166 if ( $compare_two_mode ) {2167 $compare_to_gravatar = get_avatar( $left_revision->post_author, 18 );2168 $compare_to_author = get_the_author_meta( 'display_name', $left_revision->post_author );2169 $compare_to_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) );2170 2171 $revision_from_date_author = sprintf(2172 '%s %s, %s %s (%s)',2173 $compare_to_gravatar,2174 $compare_to_author,2175 human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ),2176 __( ' ago ' ),2177 $compare_to_date2178 );2179 }2180 2181 2167 // 2182 2168 //make sure the left revision is the most recent 2183 2169 // … … 2187 2173 $right_revision = $temp; 2188 2174 } 2189 2175 2176 $linesadded=0; 2177 $linesdeleted=0; 2178 2190 2179 // 2191 2180 //compare from left to right, passed from application 2192 2181 // … … 2202 2191 if ( ! empty( $show_split_view ) ) 2203 2192 $args = array( 'show_split_view' => true ); 2204 2193 2205 $content .= wp_text_diff( $left_content, $right_content, $args ); 2194 $diff = wp_text_diff_with_count( $left_content, $right_content, $args ); 2195 2196 if ( isset( $diff[ 'html' ] ) ) 2197 $content .= $diff[ 'html' ]; 2198 2199 if ( isset( $diff[ 'linesadded' ] ) ) 2200 $linesadded = $linesadded + $diff[ 'linesadded' ]; 2201 2202 if ( isset( $diff[ 'linesdeleted' ] ) ) 2203 $linesdeleted = $linesdeleted + $diff[ 'linesdeleted' ]; 2204 2205 2206 2206 } 2207 $content = '' == $content ? __( 'No difference' ) : $content; 2208 $alltherevisions = array ( 2209 'revisiondiff' => $content 2210 ); 2207 $content = '' == $content ? __( 'No difference' ) : $content; 2208 2209 $alltherevisions = array ( 2210 'revisiondiff' => $content, 2211 'lines_deleted' => $linesdeleted, 2212 'lines_added' => $linesadded 2213 ); 2211 2214 echo json_encode( $alltherevisions ); 2212 2215 exit(); 2213 } 2216 } //end single model fetch 2214 2217 2218 //fetch the list of revisions available 2219 2215 2220 //if we are comparing two revisions, the first 'revision' represented by the leftmost 2216 2221 //slider position is the current revision, prepend a comparison to this revision 2217 if ( $compare_two_mode )2222 if ( $compare_two_mode && ! wp_first_revision_matches_current_version( $post_id ) ) //revisions don't have current version 2218 2223 array_unshift( $revisions, get_post( $post_id ) ); 2219 2224 2225 if (! $compare_two_mode && wp_first_revision_matches_current_version( $post_id ) ) //revisions already include current version 2226 array_shift( $revisions ); //remove the extra current revisions (comparing to current in one handle mode) 2227 2228 2220 2229 $count = -1; 2221 2230 2231 $revisions = array_reverse( $revisions ); 2232 2222 2233 foreach ( $revisions as $revision ) : 2223 2234 if ( ! empty( $show_autosaves ) && wp_is_post_autosave( $revision ) ) 2224 2235 continue; … … 2227 2238 $count++; 2228 2239 // return blank data for diffs to the left of the left handle (for right handel model) 2229 2240 // or to the right of the right handle (for left handel model) 2230 if ( ( 0 != $left_handle_at && $count <= $left_handle_at ) || 2231 ( 0 != $right_handle_at && $count > $right_handle_at )) { 2241 if ( ( 0 != $left_handle_at && $count <= $left_handle_at ) || 2242 ( 0 != $right_handle_at && $count > $right_handle_at )) { 2232 2243 $alltherevisions[] = array ( 2233 2244 'ID' => $revision->ID, 2234 2245 ); 2235 2246 2236 2247 continue; 2237 2248 } 2238 2249 2239 $gravatar = get_avatar( $revision->post_author, 18 ); 2250 if ( $compare_two_mode ) { 2251 $compare_to_gravatar = get_avatar( $left_revision->post_author, 24 ); 2252 $compare_to_author = get_the_author_meta( 'display_name', $left_revision->post_author ); 2253 $compare_to_date = date_i18n( $datef, strtotime( $left_revision->post_modified ) ); 2254 2255 $revision_from_date_author = sprintf( 2256 '%s %s, %s %s (%s)', 2257 $compare_to_gravatar, 2258 $compare_to_author, 2259 human_time_diff( strtotime( $left_revision->post_modified ), current_time( 'timestamp' ) ), 2260 __( ' ago ' ), 2261 $compare_to_date 2262 ); 2263 } 2264 2265 $gravatar = get_avatar( $revision->post_author, 24 ); 2240 2266 $author = get_the_author_meta( 'display_name', $revision->post_author ); 2241 2267 $date = date_i18n( $datef, strtotime( $revision->post_modified ) ); 2242 2268 $revision_date_author = sprintf( … … 2247 2273 __( ' ago ' ), 2248 2274 $date 2249 2275 ); 2276 $datef2 = __( 'j M @ G:i' ); 2277 $date2 = date_i18n( $datef2, strtotime( $revision->post_modified ) ); 2250 2278 2279 $revision_date_author_short = sprintf( 2280 '%s <strong>%s</strong><br />%s', 2281 $gravatar, 2282 $author, 2283 $date2 2284 ); 2285 2251 2286 $restoreaction = wp_nonce_url( 2252 2287 add_query_arg( 2253 2288 array( 'revision' => $revision->ID, … … 2261 2296 'ID' => $revision->ID, 2262 2297 'revision_date_author' => $revision_date_author, 2263 2298 'revision_from_date_author' => $revision_from_date_author, 2299 'revision_date_author_short' => $revision_date_author_short, 2264 2300 'restoreaction' => urldecode( $restoreaction ), 2265 2301 'revision_toload' => true 2266 2302 ); -
wp-admin/js/revisions.js
8 8 Model : Backbone.Model.extend({ 9 9 idAttribute : 'ID', 10 10 urlRoot : ajaxurl + '?action=revisions-data&compare_to=' + wpRevisionsSettings.post_id + 11 '&show_autosaves= false&show_split_view=true&nonce=' + wpRevisionsSettings.nonce,11 '&show_autosaves=true&show_split_view=true&nonce=' + wpRevisionsSettings.nonce, 12 12 defaults: { 13 13 ID : 0, 14 14 revision_date_author : '', 15 revision_date_author_short: '', 15 16 revisiondiff : '<div class="diff-loading"><div class="spinner"></div></div>', 16 17 restoreaction : '', 17 18 revision_from_date_author : '', 18 revision_toload : false 19 revision_toload : false, 20 lines_added : 0, 21 lines_deleted : 0, 22 scope_of_changes : 'none' 19 23 }, 20 24 21 25 url : function() { … … 35 39 _revisionsOptions : null, 36 40 _left_diff : 0, 37 41 _right_diff : 1, 38 _autosaves : false,42 _autosaves : true, 39 43 _show_split_view : true, 40 44 _compareoneortwo : 1, 41 45 _left_model_loading : false, //keep track of model loads 42 46 _right_model_loading : false, //disallow slider interaction, also repeat loads, while loading 47 _tickmarkView : null, //the slider tickmarks 48 _keep_tooltip_open : false, 43 49 44 50 //TODO add ability to arrive on specific revision 45 51 routes : { … … 54 60 var revisions_to_load = model_collection.where( { revision_toload : true } ); 55 61 //console.log(revisions_to_load); 56 62 var delay=0; 57 _.each(revisions_to_load, function( the_model ) { 63 //match slider to passed revision_id 64 _.each( revisions_to_load, function( the_model ) { 65 if ( the_model.get( 'ID' ) == wpRevisionsSettings.revision_id ) { 66 //console.log ( the_model.get( 'ID' ) +'-' +wpRevisionsSettings.revision_id); 67 self._right_diff = self._revisions.indexOf( the_model ) + 1; 68 } 69 70 }); 71 _.each( revisions_to_load, function( the_model ) { 58 72 the_model.urlRoot = model_collection.url; 59 73 _.delay( function() { 60 74 the_model.fetch( { … … 63 77 remove : false, 64 78 //async : false, 65 79 success : function( model ) { 66 //console.log(model.get( 'ID' ) +'-'+self._revisions.at( self._right_diff ).get( 'ID' )); 67 if ( model.get( 'ID' ) === self._revisions.at( self._right_diff - 1 ).get( 'ID' ) ) { //reload if current model refreshed 68 //console.log('render'); 80 model.set( 'revision_toload', 'false' ); 81 //console.log(model_collection.where( { revision_toload : true } ).length); 82 if ( 0 === model_collection.where( { revision_toload : true } ).length ) 83 self.stop_model_loading_spinner(); 84 85 self._tickmarkView.render(); 86 87 var total_changes = model.get( 'lines_added' ) + model.get( 'lines_deleted'); 88 // console.log(total_changes); 89 var scope_of_changes = 'vsmall'; 90 if ( total_changes > 1 && total_changes <= 3 ) { 91 scope_of_changes = 'small'; 92 } else if(total_changes > 3 && total_changes <= 5 ) { 93 scope_of_changes = 'med'; 94 } else if(total_changes > 5 && total_changes <= 10 ) { 95 scope_of_changes = 'large'; 96 } else if(total_changes > 10 ) { 97 scope_of_changes = 'vlarge'; 98 } 99 model.set( 'scope_of_changes', scope_of_changes ); 100 101 if ( model.get( 'ID' ) === self._revisions.at( self._right_diff ).get( 'ID' ) ) { //reload if current model refreshed 69 102 self._revisionView.render(); 70 103 } 71 104 } 72 105 } ); 73 106 }, delay ) ; 74 delay = delay + 200; //stagger model loads by 200 ms to avoid hammering server with requests107 delay = delay + 150; //stagger model loads to avoid hammering server with requests 75 108 } 76 109 ); 77 110 }, … … 83 116 84 117 stop_left_model_loading : function() { 85 118 this._left_model_loading = false; 86 $('.revisiondiffcontainer').removeClass('leftmodelloading');87 119 }, 88 120 89 121 start_right_model_loading : function() { … … 93 125 94 126 stop_right_model_loading : function() { 95 127 this._right_model_loading = false; 128 }, 129 130 stop_model_loading_spinner : function() { 96 131 $('.revisiondiffcontainer').removeClass('rightmodelloading'); 132 $('.revisiondiffcontainer').removeClass('leftmodelloading'); 97 133 }, 98 134 99 135 reloadmodel : function() { … … 111 147 '&show_split_view=' + REVAPP._show_split_view + 112 148 '&nonce=' + wpRevisionsSettings.nonce; 113 149 self.start_right_model_loading(); 114 this._revisions.fetch({ //reload revision data150 self._revisions.fetch({ //reload revision data 115 151 success : function() { 116 152 self.stop_right_model_loading(); 117 153 var revisioncount = self._revisions.length; … … 122 158 self.reload_toload_revisions( self._revisions ); 123 159 124 160 $( '#slider' ).slider( 'option', 'max', revisioncount-1 ); //TODO test this, autsaves changed 161 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' ); 162 REVAPP._tickmarkView.model = self._revisions; 163 REVAPP._tickmarkView.render(); 125 164 }, 126 165 127 166 error : function () { … … 187 226 success : function(){ 188 227 self.stop_right_model_loading(); 189 228 self.reload_toload_revisions( self._right_handle_revisions ); 229 self._tickmarkView.model = self._right_handle_revisions; 230 190 231 }, 191 232 192 233 error : function ( response ) { … … 215 256 216 257 success : function() { 217 258 self.stop_right_model_loading(); 218 self. revisionDiffSetup();259 self.completeApplicationSetup(); 219 260 } 220 261 }); 221 262 } 222 263 return this; 223 264 }, 224 265 225 revisionDiffSetup : function() {266 completeApplicationSetup : function() { 226 267 this._revisionView = new wp.revisions.views.View({ 227 268 model : this._revisions 228 269 }); 229 270 this._revisionView.render(); 230 $( '#diff_max, #diff_maxof' ).html( this._revisions.length );231 $( '#diff_count' ).html( REVAPP._right_diff );232 271 $( '#slider' ).slider( 'option', 'max', this._revisions.length - 1 ); 233 272 234 273 this.reload_toload_revisions( this._revisions ); 274 235 275 this._revisionsInteractions = new wp.revisions.views.Interact({ 236 276 model : this._revisions 237 277 }); 238 278 this._revisionsInteractions.render(); 239 279 280 this._tickmarkView = new wp.revisions.views.Tickmarks({ 281 model : this._revisions 282 }); 283 this._tickmarkView.render(); 284 this._tickmarkView.resetticks(); 285 286 $( 'a.ui-slider-handle' ).attr( 'title', '' ).tooltip({ 287 track: false, 288 position: { 289 my: "top-80", 290 active: function( position, feedback ) { 291 $( this ).css( position ); 292 $( "<div>" ) 293 .addClass( "arrow" ) 294 .addClass( feedback.vertical ) 295 .addClass( feedback.horizontal ) 296 .appendTo( this ); 297 } 298 }, 299 show: false, 300 hide: false, 301 disabled: false 302 } ); 240 303 /* 304 .on( 'mouseup', function( event ) { 305 REVAPP._keep_tooltip_open = false; 306 $( this ).find('.ui-slider-tooltip').hide(); 307 } ).on( 'mousedown', function( event ) { 308 REVAPP._keep_tooltip_open = true; 309 } ).on( 'mouseout', function( event ) { 310 if ( REVAPP._keep_tooltip_open) 311 event.stopImmediatePropagation(); 312 }); 313 */ 314 /* 241 315 //Options hidden for now, moving to screen options 242 316 this._revisionsOptions = new wp.revisions.views.Options({ 243 317 model : this._revisions … … 259 333 } ); 260 334 261 335 _.extend(wp.revisions.views, { 336 337 //Ticks inside slider view 262 338 // 339 Tickmarks : Backbone.View.extend({ 340 el : $('#diff-slider-ticks')[0], 341 tagName : 'diff-slider-ticks-view', 342 className : 'diff-slider-ticks-container', 343 template : wp.template('revision-ticks'), 344 model : wp.revisions.Model, 345 346 resetticks : function() { 347 var slider_max = $( '#slider' ).slider( 'option', 'max'); 348 var slider_width = $( '#slider' ).width(); 349 var adjust_max = ( 2 === REVAPP._compareoneortwo ) ? 1 : 0; 350 var tick_width = Math.floor( slider_width / ( slider_max - adjust_max ) ); 351 352 //TODO: adjust right margins for wider ticks so they stay centered on handle stop point 353 354 tick_width = (tick_width > 50 ) ? 50 : tick_width; 355 slider_width = tick_width * (slider_max - adjust_max ) +1; 356 357 $( '#slider' ).width( slider_width ); 358 $( '.diff-slider-ticks-wrapper' ).width( slider_width ); 359 $( '#diffslider' ).width( slider_width ); 360 $( '#diff-slider-ticks' ).width( slider_width ); 361 362 var a_tick_width = $( '.revision-tick' ).width(); 363 364 if ( tick_width !== a_tick_width ) { // is the width already set correctly? 365 $( '.revision-tick' ).each( function( ) { 366 $(this).css( 'margin-right', tick_width - 1 + 'px'); //space the ticks out using right margin 367 }); 368 369 if( 2 === REVAPP._compareoneortwo ) { 370 $( '.revision-tick' ).first().remove(); //TODO - remove thie check 371 } 372 $( '.revision-tick' ).last().css( 'margin-right', '0' ); // last tick gets no right margin 373 } 374 375 }, 376 377 //render the options view 378 render : function() { 379 var self = this; 380 381 if ( null !== self.model ) { 382 //TODO remove this initial model when ticket #16215 rolls because 383 //revisions will then include current version 384 var add_placeholder = ( 2 === REVAPP._compareoneortwo ) ? self.template('') : ''; 385 386 var addhtml = "";//add_placeholder; 387 _.each ( self.model.models, function ( the_model ) { 388 389 addhtml = addhtml + self.template ( the_model.toJSON() ); 390 391 }); 392 self.$el.html( addhtml ); 393 394 } 395 self.resetticks(); 396 return self; 397 } 398 }), 399 400 // 263 401 //primary revision diff view 264 402 // 265 403 View : Backbone.View.extend({ … … 271 409 comparetwochecked : '', 272 410 draggingleft : false, 273 411 274 initialize : function(){275 },276 277 412 // 278 413 //render the revisions 279 414 // … … 329 464 if ( $( 'input#comparetwo' ).is( ':checked' ) ) { 330 465 REVAPP._compareoneortwo = 2 ; 331 466 REVAPP.reloadleftright(); 467 332 468 } else { 333 469 REVAPP._compareoneortwo = 1 ; 334 470 REVAPP._revisionView.draggingleft = false; … … 336 472 REVAPP.reloadmodelsingle(); 337 473 } 338 474 REVAPP._revisionsInteractions.render(); 475 REVAPP._tickmarkView.render(); 476 339 477 } 340 478 }), 341 479 342 480 // 343 481 //options view for show autosaves and show split view options 344 482 // 483 /* DISABLED for now 345 484 Options : Backbone.View.extend({ 346 485 el : $('#backbonerevisionsoptions')[0], 347 486 tagName : 'revisionoptionsview', 348 487 className : 'revisionoptions-container', 349 488 template : wp.template('revisionoptions'), 350 489 351 initialize : function() {352 },353 354 490 //render the options view 355 491 render : function() { 356 492 var addhtml = this.template; … … 396 532 REVAPP.reloadmodel(); 397 533 } 398 534 }), 399 535 */ 400 536 // 401 537 //main interactions view 402 538 // … … 405 541 tagName : 'revisionvinteract', 406 542 className : 'revisionvinteract-container', 407 543 template : wp.template('revisionvinteract'), 408 _restoreword : '',409 544 410 545 initialize : function() { 411 this._restoreword = $( 'input#restore' ).attr( 'value' );412 546 }, 413 547 414 reset_restore_button : function() {415 $( 'input#restore' ).attr( 'value', this._restoreword + ' ' + REVAPP._revisions.at( REVAPP._right_diff - 1 ).get( 'ID' ) );416 },417 418 548 render : function() { 419 549 var self = this; 420 550 421 551 var addhtml = this.template; 422 552 this.$el.html( addhtml ); 423 $( '#diff_max, #diff_maxof' ).html( this.model.length );424 $( '#diff_count' ).html( REVAPP._right_diff );425 $( '#diff_left_count_inner' ).html( 0 === REVAPP._left_diff ? '' : 'revision' + REVAPP._left_diff );426 self.reset_restore_button();427 553 428 554 var modelcount = REVAPP._revisions.length; 429 555 … … 431 557 if ( 1 === REVAPP._compareoneortwo ) { 432 558 //set up the slider with a single handle 433 559 slider.slider({ 434 value 435 min 436 max 437 step 560 value: REVAPP._right_diff-1, 561 min: 0, 562 max: modelcount-1, 563 step: 1, 438 564 565 439 566 //slide interactions for one handles slider 440 567 slide : function( event, ui ) { 441 if ( REVAPP._right_model_loading ) //left model stoll loading, prevent sliding left handle442 return false;443 568 444 569 REVAPP._right_diff =( ui.value+1 ); 445 $( '#diff_count' ).html( REVAPP._right_diff );446 570 REVAPP._revisionView.render(); 447 self.reset_restore_button(); 448 } 571 /* 572 $( 'a.ui-slider-handle' ).tooltip( { 573 content: REVAPP._revisions.at( ui.value ).get( 'revision_date_author_short' ), 574 position: { 575 my: "top-65", 576 using: function( position, feedback ) { 577 $( this ).css( position ); 578 $( "<div>" ) 579 .addClass( "arrow" ) 580 .addClass( feedback.vertical ) 581 .addClass( feedback.horizontal ) 582 .appendTo( this ); 583 } 584 } 585 });//.trigger( 'close' ).trigger( 'open' ); 586 */ 587 } 449 588 }); 450 589 $( '.revisiondiffcontainer' ).removeClass( 'comparetwo' ); 590 451 591 } else { //comparing more than one, eg 2 452 592 //set up the slider with two handles 453 593 slider.slider({ … … 467 607 return false; 468 608 469 609 if ( REVAPP._revisionView.model !== REVAPP._left_handle_revisions && 470 null !== REVAPP._left_handle_revisions ) 610 null !== REVAPP._left_handle_revisions ) { 471 611 REVAPP._revisionView.model = REVAPP._left_handle_revisions; 472 612 REVAPP._tickmarkView.model = REVAPP._left_handle_revisions; 613 REVAPP._tickmarkView.render(); 614 } 473 615 REVAPP._revisionView.draggingleft = true; 474 616 REVAPP._left_diff_start = ui.values[ 0 ]; 475 617 break; 476 618 477 619 case 2: //right 478 if ( REVAPP._right_model_loading ) //right model stoll loading, prevent sliding right handle479 return false;480 620 481 621 //one extra spot at left end when comparing two 482 622 if ( REVAPP._revisionView.model !== REVAPP._right_handle_revisions && 483 null !== REVAPP._right_handle_revisions ) 623 null !== REVAPP._right_handle_revisions ) { 484 624 REVAPP._revisionView.model = REVAPP._right_handle_revisions; 625 REVAPP._tickmarkView.model = REVAPP._right_handle_revisions; 626 REVAPP._tickmarkView.render(); 627 } 485 628 629 486 630 REVAPP._revisionView.draggingleft = false; 487 631 REVAPP._right_diff_start = ui.values[ 1 ]; 488 632 break; … … 505 649 break; 506 650 507 651 case 2: //right 508 if ( REVAPP._right_model_loading ) //right model still loading, prevent sliding right handle509 return false;510 511 652 REVAPP._right_diff = ui.values[ 1 ] - 1 ; 512 653 break; 513 654 } 514 655 515 $( '#diff_count' ).html( REVAPP._right_diff );516 517 656 if ( 0 === REVAPP._left_diff ) { 518 657 $( '.revisiondiffcontainer' ).addClass( 'currentversion' ); 519 658 520 659 } else { 521 660 $( '.revisiondiffcontainer' ).removeClass( 'currentversion' ); 522 $( '#diff_left_count_inner' ).html( REVAPP._left_diff );523 661 } 524 662 525 REVAPP._revisionView.render(); //render the diff view526 self.reset_restore_button(); 663 REVAPP._revisionView.render(); 664 527 665 }, 528 666 529 667 //when the user stops sliding in 2 handle mode, recalculate diffs … … 537 675 switch ( index ) { 538 676 case 1: //left 539 677 //left handle dragged & changed, reload right handle model 540 if ( ! ( REVAPP._left_diff_start === ui.values[ 0 ] || REVAPP._left_model_loading ))678 if ( REVAPP._left_diff_start !== ui.values[ 0 ] ) 541 679 REVAPP.reloadright(); 542 680 543 681 break; 544 682 545 683 case 2: //right 546 684 //right handle dragged & changed, reload left handle model if changed 547 if ( ! ( REVAPP._right_diff_start === ui.values[ 1 ] || REVAPP._right_model_loading ) ) {685 if ( REVAPP._right_diff_start !== ui.values[ 1 ] ) 548 686 REVAPP.reloadleft(); 549 } 687 550 688 break; 551 689 } 552 690 } … … 571 709 572 710 REVAPP._revisionView.render(); 573 711 574 $( '#diff_count' ).html( REVAPP._right_diff );575 712 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' ); 576 this.reset_restore_button();577 713 }, 578 714 579 715 //go the the previous revision … … 583 719 584 720 REVAPP._revisionView.render(); 585 721 586 $( '#diff_count' ).html( REVAPP._right_diff );587 722 $( '#slider' ).slider( 'value', REVAPP._right_diff - 1 ).trigger( 'slide' ); 588 this.reset_restore_button();589 723 } 590 724 }) 591 725 }); -
wp-admin/revision.php
80 80 $parent_file = $submenu_file = 'edit.php?post_type=' . $post->post_type; 81 81 else 82 82 $parent_file = $submenu_file = 'edit.php'; 83 84 83 wp_enqueue_script( 'revisions' ); 85 84 86 85 require_once( './admin-header.php' ); … … 89 88 //TODO can we pass the context in a better way 90 89 ?> 91 90 <script type="text/javascript"> 92 var wpRevisionsSettings = <?php echo json_encode( array( 'post_id' => $post->ID, 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ) ) ); ?>; 91 var wpRevisionsSettings = <?php echo json_encode( 92 array( 'post_id' => $post->ID, 93 'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ), 94 'revision_id' => $revision_id ) ); ?>; 93 95 </script> 94 96 <?php 95 97 $comparetworevisionslink = get_edit_post_link( $revision->ID ); 96 98 ?> 97 99 98 <div id="backbonerevisionsoptions"></div> 100 <div id="backbonerevisionsoptions"> 101 </div> 99 102 <div class="wrap"> 100 <div class="icon32 icon32-posts-post" id="icon-edit"><br></div> 103 <div class="icon32 icon32-posts-post" id="icon-edit"> 104 <br> 105 </div> 101 106 <div class="revisiondiffcontainer diffsplit currentversion rightmodelloading"> 102 <div id="modelsloading" class="updated message"><span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?></div> 107 <div id="modelsloading" class="updated message"> 108 <span class="spinner" ></span> <?php _e( 'Calculating revision diffs' ); ?> 109 </div> 103 110 <h2 class="long-header"><?php echo $h2; ?></h2> 104 <div id="backbonerevisionsinteract"></div> 105 <div id="backbonerevisionsdiff"></div> 111 <div class="diff-slider-ticks-wrapper"> 112 <div id="diff-slider-ticks"> 113 </div> 114 </div> 115 <div id="backbonerevisionsinteract"> 116 </div> 117 <div id="backbonerevisionsdiff"> 118 </div> 106 119 <hr /> 107 120 </div> 108 121 </div> 109 122 110 123 <script id="tmpl-revision" type="text/html"> 124 <div id="diffsubheader" class="diff-left-hand-meta-row"> 125 <div id="diff_from_current_revision"> 126 <b><?php _e( 'Comparing from:' ); ?></b> <?php _e( 'the current version' ); ?> 127 </div> 128 <div id="difftitlefrom"><b><?php _e( 'Comparing from:' ); ?></b> <?php _e( 'revision by' ); ?> {{{ data.revision_from_date_author }}} </div> 129 </div> 130 111 131 <div id="diffsubheader"> 112 <span id="diff_from_current_revision"><?php _e( 'Current version' ); ?><?php _e( '- compared to -' ); ?></span> 113 <div id="difftitlefrom">{{{ data.revision_from_date_author }}} <?php _e( '- compared to -' ); ?></div> 114 <div id="difftitle">{{{ data.revision_date_author }}}</div> 115 <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> 116 <div id="diffrestore"><input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore revision ID' )?>" /></div> 117 <div id="comparetworevisions"><input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> <label for="comparetwo"><?php esc_attr_e( 'Compare two revisions' ); ?></a></div> </div> 132 <div id="difftitle"> 133 <strong><?php _e( 'Comparing to:' ); ?></strong> <?php _e( 'revision by' ); ?> {{{ data.revision_date_author }}} 134 </div> 135 <div id="diffrestore"> 136 <input class="button button-primary" onClick="document.location='{{{ data.restoreaction }}}'" type="submit" id="restore" value="<?php esc_attr_e( 'Restore This Revision' )?>" /> 137 </div> 138 <div id="comparetworevisions"> 139 <input type="checkbox" id="comparetwo" value="comparetwo" {{{ data.comparetwochecked }}} name="comparetwo"/> 140 <label for="comparetwo"><?php esc_attr_e( 'Compare two revisions' ); ?></a></label> 141 </div> 142 </div> 143 118 144 <div id="removedandadded"> 119 145 <div id="removed"><?php _e( 'Removed -' ); ?></div> 120 146 <div id="added"><?php _e( 'Added +' ); ?></div> … … 124 150 125 151 <script id="tmpl-revisionvinteract" type="text/html"> 126 152 <div id="diffheader"> 127 <div id="diffprevious"><input class="button" type="submit" id="previous" value="<?php esc_attr_e( 'Previous' ); ?>" /></div> 128 <div id="diffnext"><input class="button" type="submit" id="next" value="<?php esc_attr_e( 'Next' ); ?>" /></div> 129 <div id="diffslider"> 130 <div id="revisioncount"> 131 <?php _e( 'Comparing' ); ?> 132 <span id="diff_left_count"> <?php _e( 'revision' ); ?></span> <span id="diff_left_count_inner"></span> 133 <span id="diff_left_current_revision"><?php _e( 'current version' ); ?></span> 134 <span id="diff_revision_from">{{{ data.diff_revision_from }}}</span> 135 <?php _e( ' to revision' ); ?> 136 <span id="diff_count">{{{ data.current_diff }}}</span> 137 <?php _e( ' of ' ); ?> 138 <span id="diff_max" ></span> 139 </div> 140 141 <div id="slider" class="wp-slider"></div> 153 <div id="diffprevious"><input class="button" type="submit" id="previous" value="<?php esc_attr_e( 'Previous' ); ?>" /> 142 154 </div> 155 <div id="diffnext"><input class="button" type="submit" id="next" value="<?php esc_attr_e( 'Next' ); ?>" /> 156 </div> 157 <div id="diffslider"> 158 <div id="slider" class="wp-slider"> 159 </div> 160 </div> 143 161 </div> 144 162 </script> 163 <script id="tmpl-revision-ticks" type="text/html"> 164 <div class="revision-tick revision-toload{{{ data.revision_toload }}} revision-scopeofchanges-{{{ data.scope_of_changes }}}"> 165 </div> 166 </script> 145 167 <?php 146 168 /* 147 169 TODO Convert these into screen options -
wp-admin/css/colors-fresh.css
175 175 .sidebar-name, 176 176 #nav-menu-header, 177 177 #nav-menu-footer, 178 .menu-item-handle, 179 .wp-slider .ui-slider-handle { 178 .menu-item-handle { 180 179 background: #f1f1f1; 181 180 background-image: -webkit-gradient(linear, left bottom, left top, from(#ececec), to(#f9f9f9)); 182 181 background-image: -webkit-linear-gradient(bottom, #ececec, #f9f9f9); … … 185 184 background-image: linear-gradient(to top, #ececec, #f9f9f9); 186 185 } 187 186 187 188 188 189 .widget .widget-top, 189 190 .postbox h3, 190 191 .stuffbox h3 { … … 1382 1383 background-color: #f7f7f7; 1383 1384 } 1384 1385 1386 .comparetwo#diffsubheader.diff-left-hand-meta-row { 1387 background-color: #fcfcfc; 1388 } 1389 1390 .revision-tick.revision-toloadtrue { 1391 background-color: #9999cc; 1392 background: url(../images/wpspin_light.gif) no-repeat; 1393 background-position: middle; 1394 background-size: 1px 10px; 1395 } 1396 1397 .revision-tick.revision-toloadfalse { 1398 background-color: #aaa; 1399 } 1400 1385 1401 #att-info { 1386 1402 background-color: #e4f2Fd; 1387 1403 } 1388 1404 1405 body .ui-tooltip { 1406 border-color: #d7d7d7; 1407 background-color: #fff; 1408 } 1409 1389 1410 /* jQuery UI Slider */ 1390 1411 .wp-slider.ui-slider { 1391 1412 border-color: #d7d7d7; … … 1393 1414 } 1394 1415 1395 1416 .wp-slider .ui-slider-handle { 1396 border-color: #d7d7d7;1417 border-color: none; 1397 1418 } 1398 1419 1420 .wp-slider .ui-slider-handle { 1421 /* Slider drag Triangle CSS */ 1422 background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAA3NCSVQICAjb4U/gAAAA8FBMVEU2dZipwNBJl8VGmcX///+EpLlBgqpymrNFjru3ydNWiKs6eZzY4uuRrL08faPL3OZBjLSBqsCTssRHlMJEf59cj657o7xKl8OEqsE9gag2dJtEkb+ct8iZs8BHmMePq8BejKZAiK5llK5FjrlJl8c6dZdGl8avxdBJlcZ4nbc6ep6XrbpKgZ+Lqr5KmcdIkbqsws1Gk8E+f6c4dptaiadFirRKl8V8pblImcNIl8eGpruVscZCh7BMlsdIlcFImchEkbs9eJpCjbdGjbk8fJ84dp02dpo8gatMlsM2dps8faVAg61Ej71Ek75IksFIlcOaLCw7AAAAUHRSTlP/////AP///////////////////////////////////////////////////////////////////////////////////////////////////xB6m5UAAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAUdEVYdENyZWF0aW9uIFRpbWUAMy85LzEzrdD8jAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAACaSURBVBiVVcxZD8FAGIXhjxzUVktQgqKmo7ZYhkgsiS1tQuj//zeomo736uS5OFSo2W6UXc/R5hxXW5foxDlXqUKZx0GFZpXynuM4kXhjgjgyJkGzQIjpvi9Fx1uQ0iQUh4GkR/Ini0CQ2IfQ24YC4X8T+Mn0zj8lO1IgnqZpzlxE0m4YhrFsKYJVn126UGV+W1wHf4LdpByuF0goFKI7tv/dAAAAAElFTkSuQmCC'); 1423 } 1424 1399 1425 .wp-slider .ui-slider-handle.ui-state-hover, 1400 1426 .wp-slider .ui-slider-handle.ui-state-focus { 1401 border-color: #aaa; 1427 border-color: none; 1428 outline: none; 1402 1429 } 1403 1430 1404 1431 .wp-slider .ui-slider-handle.ui-state-active { 1405 border-color: #aaa; 1406 background: #eee; 1407 background-image: -webkit-gradient(linear, left bottom, left top, from(#f9f9f9), to(#ececec)); 1408 background-image: -webkit-linear-gradient(bottom, #f9f9f9, #ececec); 1409 background-image: -moz-linear-gradient(bottom, #f9f9f9, #ececec); 1410 background-image: -o-linear-gradient(bottom, #f9f9f9, #ececec); 1411 background-image: linear-gradient(to top, #f9f9f9, #ececec); 1432 background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAARCAMAAAAMs7fIAAAAA3NCSVQICAjb4U/gAAAA51BMVEUgZpDkzc0yd6f///8mcqFJm8cjbZZzr80mg78lh8BDk8UngLl+s9AmfKk4hrGeweBaoMhNlMORwt4nd6Zdm8BAjMEnf7RYmsMkb50mhsFWlsYhZ5ImhbwocZg0f61Lk8E9i7twqNBgo8VSmMUofLBcm8o3faUpfK8mh8Aia5MgZpFMmcgpeapDmcJjo8sliMEmh70nhLkkcKAqgLF2sc8sc5ojbZsngrMkh8EnfKw1eaUjbpkkapImeKQgaJAohb0mh8MmhcMng7kkcKEpf68iZ48haJMmhb8kicEmc6MibJkia5UnhLsw1mWvAAAATXRSTlP/AP8A/////////////////////////////////////////////////////////////////////////////////////////////////9/iR18AAAAJcEhZcwAACxIAAAsSAdLdfvwAAAAUdEVYdENyZWF0aW9uIFRpbWUAMy85LzEzrdD8jAAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAACaSURBVBiVVc15D8FAEIfh+Ymj6761LIrSiCNVVyjbRGgifP/PQ6q22/evyZPJDNXzD6G0qNDq5PtO3DJDFyfRpk+po2Eo0h5Qx9U0LRa3SejdlR2rDMLI41yKh6/AtOSzUiuU4kvemSMUDBsRXGuRIHj/CvCXyTNcSXelQBQYY1uBWMY651xfK4KzbdgzqJI73LK7hGC6r0bTB5apIhqIH/YIAAAAAElFTkSuQmCC'); 1412 1433 } 1413 1434 1414 1435 /* edit image */ -
wp-admin/css/wp-admin.css
3554 3554 margin: 2px; 3555 3555 } 3556 3556 3557 #diffrestore, 3558 #diffnext, 3559 #diffcancel { 3557 #diffnext { 3560 3558 float: right; 3561 3559 margin-right: 5px; 3562 3560 } 3563 3561 3562 #diffrestore input{ 3563 margin-left: 10px; 3564 } 3565 3564 3566 #diffprevious, 3565 3567 #difftitle, 3566 3568 #difftitlefrom, … … 3572 3574 3573 3575 #diffprevious, 3574 3576 #diffnext { 3575 margin-top: 7px;3576 3577 height: 30px; 3577 3578 } 3578 3579 … … 3584 3585 #diffheader { 3585 3586 border-bottom: 1px solid #dfdfdf; 3586 3587 width: 100%; 3587 height: 4 5px;3588 line-height: 4 5px;3589 padding-top: 10px;3588 height: 40px; 3589 line-height: 40px; 3590 padding-top: 30px; 3590 3591 } 3591 3592 3592 #diffsubheader {3593 #diffsubheader,.diff-left-hand-meta-row { 3593 3594 border-bottom: 1px solid #dfdfdf; 3594 3595 width: 100%; 3595 3596 height:35px; 3596 3597 line-height: 35px; 3598 display: block; 3597 3599 } 3598 3600 3599 #diffslider 3601 #diffslider{ 3600 3602 width: 70%; 3601 3603 margin-left: auto; 3602 3604 margin-right: auto; 3603 3605 text-align: center; 3604 height: 3.5em; 3606 height: 0.8em; 3607 margin-top: 20px; 3605 3608 } 3606 3609 3610 .diff-slider-ticks-wrapper { 3611 margin-left: auto; 3612 margin-right: auto; 3613 text-align: center; 3614 } 3615 3616 #diff-slider-ticks { 3617 position: absolute; 3618 margin-top: 50px; 3619 z-index: 1; 3620 } 3621 3607 3622 #revisioncount { 3608 3623 width: 50%; 3609 3624 margin-left: auto; … … 3671 3686 3672 3687 #comparetworevisions { 3673 3688 float: right; 3689 position: absolute; 3690 top: 10px; 3691 right: 10px; 3674 3692 line-height: 35px; 3675 3693 padding-right: 5px; 3676 3694 } … … 3706 3724 .comparetwo #diffprevious, 3707 3725 .comparetwo #diffnext, 3708 3726 span#diff_left_current_revision, 3709 span#diff_from_current_revision,3727 #diff_from_current_revision, 3710 3728 .currentversion span#diff_left_count, 3711 3729 .currentversion span#diff_left_count_inner, 3712 .c urrentversion #difftitlefrom,3713 .comparetwo.currentversion #difftitlefrom{3730 .comparetwo.currentversion #difftitlefrom, 3731 #diffsubheader.diff-left-hand-meta-row { 3714 3732 display: none; 3715 3733 } 3716 3734 … … 3718 3736 span#diff_left_count, 3719 3737 span#diff_left_count_inner, 3720 3738 .comparetwo #difftitlefrom, 3721 .comparetwo.currentversion span#diff_from_current_revision,3739 .comparetwo.currentversion #diff_from_current_revision, 3722 3740 .leftmodelloading #modelsloading, 3723 3741 .rightmodelloading #modelsloading, 3724 3742 .leftmodelloading #modelsloading .spinner, 3725 3743 .rightmodelloading #modelsloading .spinner, 3726 {3727 display: inline;3744 .comparetwo #diffsubheader.diff-left-hand-meta-row { 3745 display: block; 3728 3746 } 3729 3747 3748 .revision-tick { 3749 width: 1px; 3750 float: left; 3751 margin-right: 15px; 3752 height: 11px; 3753 padding: 0; 3754 margin-left: 0px; 3755 } 3756 3757 .revision-tick.revision-scopeofchanges-vsmall { 3758 width: 1px; 3759 background-color: #aaa; 3760 } 3761 3762 .revision-tick.revision-scopeofchanges-small { 3763 width: 2px; 3764 background-color: #aaa; 3765 margin-left: -1px; 3766 } 3767 3768 .revision-tick.revision-scopeofchanges-med { 3769 width: 3px; 3770 margin-left: -2px; 3771 background-color: #666; 3772 } 3773 3774 .revision-tick.revision-scopeofchanges-large { 3775 width: 4px; 3776 margin-left: -3px; 3777 background-color: #333; 3778 } 3779 3780 .revision-tick.revision-scopeofchanges-vlarge { 3781 margin-left: -3px; 3782 width: 4px; 3783 background-color: #111; 3784 } 3785 3730 3786 .diff-loading { 3731 3787 margin-top: 50px; 3732 3788 width: 100%; … … 3741 3797 float: none; 3742 3798 } 3743 3799 3744 #difftitlefrom {3745 float: left;3746 display: none;3747 }3748 3749 3800 #modelsloading { 3750 3801 float: right; 3802 position: absolute; 3751 3803 line-height: 30px; 3752 3804 display: none; 3753 3805 clear: none; 3754 margin: 0;3806 right: 170px; 3755 3807 margin-top: -40px; 3756 3808 } 3757 3809 3758 3810 #modelsloading .spinner { 3759 3811 float: left; 3760 3812 } 3761 3813 3814 .ui-tooltip-content img { 3815 float: left; 3816 margin-right: 5px; 3817 } 3818 /* jQuery UI Tooltip 1.10.1 */ 3819 3820 .ui-tooltip { 3821 padding: 8px; 3822 position: absolute; 3823 z-index: 9999; 3824 max-width: 300px; 3825 min-width: 130px; 3826 } 3827 3828 body .ui-tooltip { 3829 border-width: 1px; 3830 } 3831 3832 .ui-tooltip, .arrow:after { 3833 border: 1px solid #d7d7d7; 3834 } 3835 3836 .ui-tooltip { 3837 padding: 5px 10px; 3838 } 3839 3840 .arrow { 3841 width: 70px; 3842 height: 16px; 3843 overflow: hidden; 3844 position: absolute; 3845 left: 50%; 3846 margin-left: -35px; 3847 bottom: -16px; 3848 z-index: 99999; 3849 3850 } 3851 3852 .arrow.top { 3853 top: -16px; 3854 bottom: auto; 3855 } 3856 3857 .arrow.left { 3858 left: 20%; 3859 } 3860 3861 .arrow:after { 3862 content: ""; 3863 position: absolute; 3864 left: 20px; 3865 top: -20px; 3866 width: 25px; 3867 height: 25px; 3868 background-color: #FFF; 3869 -webkit-transform: rotate(45deg); 3870 -moz-transform: rotate(45deg); 3871 -ms-transform: rotate(45deg); 3872 -o-transform: rotate(45deg); 3873 tranform: rotate(45deg); 3874 } 3875 3876 .arrow.top:after { 3877 bottom: -20px; 3878 top: auto; 3879 } 3880 3762 3881 /* jQuery UI Slider */ 3763 3882 3764 3883 .wp-slider.ui-slider { … … 3773 3892 .wp-slider .ui-slider-handle { 3774 3893 position: absolute; 3775 3894 z-index: 2; 3776 width: 1.2em; 3777 height: 1.2em; 3778 border-width: 1px; 3779 border-style: solid; 3780 border-radius: 3px; 3895 width: 17px; 3896 height: 17px; 3897 border: none; 3781 3898 } 3782 3899 3783 3900 .wp-slider .ui-slider-range {