Changeset 24205 for trunk/wp-admin/includes/ajax-actions.php
- Timestamp:
- 05/08/2013 09:22:01 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ajax-actions.php
r24192 r24205 2120 2120 $compare_two_mode = (bool) $post_id; 2121 2121 2122 //2123 //TODO: currently code returns all possible comparisons for the indicated 'compare_to' revision2124 //however, the front end prevents users from pulling the right handle past the left or the left pass the right,2125 //so only the possible diffs need be generated2126 //2127 2122 $all_the_revisions = array(); 2128 2123 if ( ! $post_id ) … … 2137 2132 $left_revision = get_post( $compare_to ); 2138 2133 2139 // single model fetch mode2140 // return the diff of a single revision comparison2134 // single model fetch mode 2135 // return the diff of a single revision comparison 2141 2136 if ( $single_revision_id ) { 2142 2137 $right_revision = get_post( $single_revision_id ); … … 2154 2149 $lines_added = $lines_deleted = 0; 2155 2150 $content = ''; 2156 // compare from left to right, passed from application2151 // compare from left to right, passed from application 2157 2152 foreach ( _wp_post_revision_fields() as $field => $field_value ) { 2158 2153 $left_content = apply_filters( "_wp_post_revision_field_$field", $left_revision->$field, $field, $left_revision, 'left' ); … … 2183 2178 2184 2179 $all_the_revisions = array ( 2185 'diff' 2180 'diff' => $content, 2186 2181 'linesDeleted' => $lines_deleted, 2187 2182 'linesAdded' => $lines_added … … 2190 2185 echo json_encode( $all_the_revisions ); 2191 2186 exit(); 2192 } // end single model fetch2187 } // end single model fetch 2193 2188 2194 2189 $count = -1; 2195 2190 2196 // reverse the list to start with oldesrevision2191 // reverse the list to start with oldest revision 2197 2192 $revisions = array_reverse( $revisions ); 2198 2193 … … 2209 2204 $is_current_revision = false; 2210 2205 $count++; 2211 // return blank data for diffs to the left of the left handle (for right handel model) 2212 // or to the right of the right handle (for left handel model) 2213 if ( ( 0 != $left_handle_at && $count < $left_handle_at ) || 2214 ( 0 != $right_handle_at && $count > ( $right_handle_at - 2 ) ) ) { 2215 $all_the_revisions[] = array ( 2216 'ID' => $revision->ID, 2217 ); 2218 continue; 2206 2207 /** 2208 * return blank data for diffs to the left of the left handle (for right handel model) 2209 * or to the right of the right handle (for left handel model) 2210 * and visa versa in RTL mode 2211 */ 2212 if( ! is_rtl() ) { 2213 if ( ( ( 0 != $left_handle_at && $count < $left_handle_at ) || 2214 ( 0 != $right_handle_at && $count > ( $right_handle_at - 2 ) ) ) ) { 2215 $all_the_revisions[] = array ( 2216 'ID' => $revision->ID, 2217 ); 2218 continue; 2219 } 2220 } else { // is_rtl 2221 if ( ( 0 != $left_handle_at && $count > ( $left_handle_at - 1 ) || 2222 ( 0 != $left_handle_at && $count < $right_handle_at ) ) ) { 2223 $all_the_revisions[] = array ( 2224 'ID' => $revision->ID, 2225 ); 2226 continue; 2227 } 2219 2228 } 2220 2229 … … 2308 2317 endforeach; 2309 2318 2319 // in RTL + single handle mode, reverse the revision direction 2320 if ( is_rtl() && $compare_two_mode ) 2321 $all_the_revisions = array_reverse( $all_the_revisions ); 2322 2310 2323 echo json_encode( $all_the_revisions ); 2311 2324 exit();
Note: See TracChangeset
for help on using the changeset viewer.