author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:28:13 +0200 | |
changeset 9 | 177826044cd9 |
parent 7 | cf61fcea0001 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress Administration Revisions API |
|
4 |
* |
|
5 |
* @package WordPress |
|
6 |
* @subpackage Administration |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
7 |
* @since 3.6.0 |
0 | 8 |
*/ |
9 |
||
10 |
/** |
|
11 |
* Get the revision UI diff. |
|
12 |
* |
|
13 |
* @since 3.6.0 |
|
14 |
* |
|
15 |
* @param object|int $post The post object. Also accepts a post ID. |
|
16 |
* @param int $compare_from The revision ID to compare from. |
|
17 |
* @param int $compare_to The revision ID to come to. |
|
18 |
* |
|
19 |
* @return array|bool Associative array of a post's revisioned fields and their diffs. |
|
20 |
* Or, false on failure. |
|
21 |
*/ |
|
22 |
function wp_get_revision_ui_diff( $post, $compare_from, $compare_to ) { |
|
9 | 23 |
if ( ! $post = get_post( $post ) ) { |
0 | 24 |
return false; |
9 | 25 |
} |
0 | 26 |
|
27 |
if ( $compare_from ) { |
|
9 | 28 |
if ( ! $compare_from = get_post( $compare_from ) ) { |
0 | 29 |
return false; |
9 | 30 |
} |
0 | 31 |
} else { |
32 |
// If we're dealing with the first revision... |
|
33 |
$compare_from = false; |
|
34 |
} |
|
35 |
||
9 | 36 |
if ( ! $compare_to = get_post( $compare_to ) ) { |
0 | 37 |
return false; |
9 | 38 |
} |
0 | 39 |
|
40 |
// If comparing revisions, make sure we're dealing with the right post parent. |
|
41 |
// The parent post may be a 'revision' when revisions are disabled and we're looking at autosaves. |
|
9 | 42 |
if ( $compare_from && $compare_from->post_parent !== $post->ID && $compare_from->ID !== $post->ID ) { |
0 | 43 |
return false; |
9 | 44 |
} |
45 |
if ( $compare_to->post_parent !== $post->ID && $compare_to->ID !== $post->ID ) { |
|
0 | 46 |
return false; |
9 | 47 |
} |
0 | 48 |
|
49 |
if ( $compare_from && strtotime( $compare_from->post_date_gmt ) > strtotime( $compare_to->post_date_gmt ) ) { |
|
9 | 50 |
$temp = $compare_from; |
0 | 51 |
$compare_from = $compare_to; |
9 | 52 |
$compare_to = $temp; |
0 | 53 |
} |
54 |
||
55 |
// Add default title if title field is empty |
|
9 | 56 |
if ( $compare_from && empty( $compare_from->post_title ) ) { |
0 | 57 |
$compare_from->post_title = __( '(no title)' ); |
9 | 58 |
} |
59 |
if ( empty( $compare_to->post_title ) ) { |
|
0 | 60 |
$compare_to->post_title = __( '(no title)' ); |
9 | 61 |
} |
0 | 62 |
|
63 |
$return = array(); |
|
64 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
foreach ( _wp_post_revision_fields( $post ) as $field => $name ) { |
0 | 66 |
/** |
67 |
* Contextually filter a post revision field. |
|
68 |
* |
|
5 | 69 |
* The dynamic portion of the hook name, `$field`, corresponds to each of the post |
0 | 70 |
* fields of the revision object being iterated over in a foreach statement. |
71 |
* |
|
72 |
* @since 3.6.0 |
|
73 |
* |
|
74 |
* @param string $compare_from->$field The current revision field to compare to or from. |
|
75 |
* @param string $field The current revision field. |
|
76 |
* @param WP_Post $compare_from The revision post object to compare to or from. |
|
5 | 77 |
* @param string null The context of whether the current revision is the old |
78 |
* or the new one. Values are 'to' or 'from'. |
|
0 | 79 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
$content_from = $compare_from ? apply_filters( "_wp_post_revision_field_{$field}", $compare_from->$field, $field, $compare_from, 'from' ) : ''; |
0 | 81 |
|
82 |
/** This filter is documented in wp-admin/includes/revision.php */ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
$content_to = apply_filters( "_wp_post_revision_field_{$field}", $compare_to->$field, $field, $compare_to, 'to' ); |
0 | 84 |
|
5 | 85 |
$args = array( |
9 | 86 |
'show_split_view' => true, |
5 | 87 |
); |
88 |
||
89 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
* Filters revisions text diff options. |
5 | 91 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
* Filters the options passed to wp_text_diff() when viewing a post revision. |
5 | 93 |
* |
94 |
* @since 4.1.0 |
|
95 |
* |
|
96 |
* @param array $args { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
* Associative array of options to pass to wp_text_diff(). |
5 | 98 |
* |
99 |
* @type bool $show_split_view True for split view (two columns), false for |
|
100 |
* un-split view (single column). Default true. |
|
101 |
* } |
|
102 |
* @param string $field The current revision field. |
|
103 |
* @param WP_Post $compare_from The revision post to compare from. |
|
104 |
* @param WP_Post $compare_to The revision post to compare to. |
|
105 |
*/ |
|
106 |
$args = apply_filters( 'revision_text_diff_options', $args, $field, $compare_from, $compare_to ); |
|
107 |
||
108 |
$diff = wp_text_diff( $content_from, $content_to, $args ); |
|
0 | 109 |
|
110 |
if ( ! $diff && 'post_title' === $field ) { |
|
111 |
// It's a better user experience to still show the Title, even if it didn't change. |
|
112 |
// No, you didn't see this. |
|
113 |
$diff = '<table class="diff"><colgroup><col class="content diffsplit left"><col class="content diffsplit middle"><col class="content diffsplit right"></colgroup><tbody><tr>'; |
|
9 | 114 |
|
115 |
// In split screen mode, show the title before/after side by side. |
|
116 |
if ( true === $args['show_split_view'] ) { |
|
117 |
$diff .= '<td>' . esc_html( $compare_from->post_title ) . '</td><td></td><td>' . esc_html( $compare_to->post_title ) . '</td>'; |
|
118 |
} else { |
|
119 |
$diff .= '<td>' . esc_html( $compare_from->post_title ) . '</td>'; |
|
120 |
||
121 |
// In single column mode, only show the title once if unchanged. |
|
122 |
if ( $compare_from->post_title !== $compare_to->post_title ) { |
|
123 |
$diff .= '</tr><tr><td>' . esc_html( $compare_to->post_title ) . '</td>'; |
|
124 |
} |
|
125 |
} |
|
126 |
||
0 | 127 |
$diff .= '</tr></tbody>'; |
128 |
$diff .= '</table>'; |
|
129 |
} |
|
130 |
||
131 |
if ( $diff ) { |
|
132 |
$return[] = array( |
|
9 | 133 |
'id' => $field, |
0 | 134 |
'name' => $name, |
135 |
'diff' => $diff, |
|
136 |
); |
|
137 |
} |
|
138 |
} |
|
5 | 139 |
|
140 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
* Filters the fields displayed in the post revision diff UI. |
5 | 142 |
* |
143 |
* @since 4.1.0 |
|
144 |
* |
|
9 | 145 |
* @param array[] $return Array of revision UI fields. Each item is an array of id, name, and diff. |
5 | 146 |
* @param WP_Post $compare_from The revision post to compare from. |
147 |
* @param WP_Post $compare_to The revision post to compare to. |
|
148 |
*/ |
|
149 |
return apply_filters( 'wp_get_revision_ui_diff', $return, $compare_from, $compare_to ); |
|
150 |
||
0 | 151 |
} |
152 |
||
153 |
/** |
|
154 |
* Prepare revisions for JavaScript. |
|
155 |
* |
|
156 |
* @since 3.6.0 |
|
157 |
* |
|
158 |
* @param object|int $post The post object. Also accepts a post ID. |
|
159 |
* @param int $selected_revision_id The selected revision ID. |
|
160 |
* @param int $from Optional. The revision ID to compare from. |
|
161 |
* |
|
162 |
* @return array An associative array of revision data and related settings. |
|
163 |
*/ |
|
164 |
function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null ) { |
|
9 | 165 |
$post = get_post( $post ); |
5 | 166 |
$authors = array(); |
0 | 167 |
$now_gmt = time(); |
168 |
||
9 | 169 |
$revisions = wp_get_post_revisions( |
170 |
$post->ID, |
|
171 |
array( |
|
172 |
'order' => 'ASC', |
|
173 |
'check_enabled' => false, |
|
174 |
) |
|
175 |
); |
|
0 | 176 |
// If revisions are disabled, we only want autosaves and the current post. |
177 |
if ( ! wp_revisions_enabled( $post ) ) { |
|
178 |
foreach ( $revisions as $revision_id => $revision ) { |
|
9 | 179 |
if ( ! wp_is_post_autosave( $revision ) ) { |
0 | 180 |
unset( $revisions[ $revision_id ] ); |
9 | 181 |
} |
0 | 182 |
} |
183 |
$revisions = array( $post->ID => $post ) + $revisions; |
|
184 |
} |
|
185 |
||
186 |
$show_avatars = get_option( 'show_avatars' ); |
|
187 |
||
188 |
cache_users( wp_list_pluck( $revisions, 'post_author' ) ); |
|
189 |
||
190 |
$can_restore = current_user_can( 'edit_post', $post->ID ); |
|
9 | 191 |
$current_id = false; |
0 | 192 |
|
193 |
foreach ( $revisions as $revision ) { |
|
9 | 194 |
$modified = strtotime( $revision->post_modified ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
$modified_gmt = strtotime( $revision->post_modified_gmt . ' +0000' ); |
0 | 196 |
if ( $can_restore ) { |
9 | 197 |
$restore_link = str_replace( |
198 |
'&', |
|
199 |
'&', |
|
200 |
wp_nonce_url( |
|
201 |
add_query_arg( |
|
202 |
array( |
|
203 |
'revision' => $revision->ID, |
|
204 |
'action' => 'restore', |
|
205 |
), |
|
0 | 206 |
admin_url( 'revision.php' ) |
9 | 207 |
), |
208 |
"restore-post_{$revision->ID}" |
|
209 |
) |
|
210 |
); |
|
0 | 211 |
} |
212 |
||
213 |
if ( ! isset( $authors[ $revision->post_author ] ) ) { |
|
214 |
$authors[ $revision->post_author ] = array( |
|
9 | 215 |
'id' => (int) $revision->post_author, |
0 | 216 |
'avatar' => $show_avatars ? get_avatar( $revision->post_author, 32 ) : '', |
9 | 217 |
'name' => get_the_author_meta( 'display_name', $revision->post_author ), |
0 | 218 |
); |
219 |
} |
|
220 |
||
221 |
$autosave = (bool) wp_is_post_autosave( $revision ); |
|
9 | 222 |
$current = ! $autosave && $revision->post_modified_gmt === $post->post_modified_gmt; |
0 | 223 |
if ( $current && ! empty( $current_id ) ) { |
224 |
// If multiple revisions have the same post_modified_gmt, highest ID is current. |
|
225 |
if ( $current_id < $revision->ID ) { |
|
226 |
$revisions[ $current_id ]['current'] = false; |
|
9 | 227 |
$current_id = $revision->ID; |
0 | 228 |
} else { |
229 |
$current = false; |
|
230 |
} |
|
231 |
} elseif ( $current ) { |
|
232 |
$current_id = $revision->ID; |
|
233 |
} |
|
234 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
$revisions_data = array( |
0 | 236 |
'id' => $revision->ID, |
237 |
'title' => get_the_title( $post->ID ), |
|
238 |
'author' => $authors[ $revision->post_author ], |
|
5 | 239 |
'date' => date_i18n( __( 'M j, Y @ H:i' ), $modified ), |
240 |
'dateShort' => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), $modified ), |
|
0 | 241 |
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( $modified_gmt, $now_gmt ) ), |
242 |
'autosave' => $autosave, |
|
243 |
'current' => $current, |
|
244 |
'restoreUrl' => $can_restore ? $restore_link : false, |
|
245 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
247 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
* Filters the array of revisions used on the revisions screen. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
* @param array $revisions_data { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
* The bootstrapped data for the revisions screen. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
254 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
* @type int $id Revision ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
* @type string $title Title for the revision's parent WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
* @type int $author Revision post author ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
* @type string $date Date the revision was modified. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
* @type string $dateShort Short-form version of the date the revision was modified. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
* @type string $timeAgo GMT-aware amount of time ago the revision was modified. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
* @type bool $autosave Whether the revision is an autosave. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
262 |
* @type bool $current Whether the revision is both not an autosave and the post |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
* modified date matches the revision modified date (GMT-aware). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
* @type bool|false $restoreUrl URL if the revision can be restored, false otherwise. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
265 |
* } |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
* @param WP_Post $revision The revision's WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
* @param WP_Post $post The revision's parent WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
$revisions[ $revision->ID ] = apply_filters( 'wp_prepare_revision_for_js', $revisions_data, $revision, $post ); |
0 | 270 |
} |
271 |
||
5 | 272 |
/** |
273 |
* If we only have one revision, the initial revision is missing; This happens |
|
274 |
* when we have an autsosave and the user has clicked 'View the Autosave' |
|
275 |
*/ |
|
276 |
if ( 1 === sizeof( $revisions ) ) { |
|
277 |
$revisions[ $post->ID ] = array( |
|
278 |
'id' => $post->ID, |
|
279 |
'title' => get_the_title( $post->ID ), |
|
280 |
'author' => $authors[ $post->post_author ], |
|
281 |
'date' => date_i18n( __( 'M j, Y @ H:i' ), strtotime( $post->post_modified ) ), |
|
282 |
'dateShort' => date_i18n( _x( 'j M @ H:i', 'revision date short format' ), strtotime( $post->post_modified ) ), |
|
283 |
'timeAgo' => sprintf( __( '%s ago' ), human_time_diff( strtotime( $post->post_modified_gmt ), $now_gmt ) ), |
|
284 |
'autosave' => false, |
|
285 |
'current' => true, |
|
286 |
'restoreUrl' => false, |
|
287 |
); |
|
9 | 288 |
$current_id = $post->ID; |
5 | 289 |
} |
290 |
||
291 |
/* |
|
292 |
* If a post has been saved since the last revision (no revisioned fields |
|
293 |
* were changed), we may not have a "current" revision. Mark the latest |
|
294 |
* revision as "current". |
|
295 |
*/ |
|
0 | 296 |
if ( empty( $current_id ) ) { |
297 |
if ( $revisions[ $revision->ID ]['autosave'] ) { |
|
298 |
$revision = end( $revisions ); |
|
299 |
while ( $revision['autosave'] ) { |
|
300 |
$revision = prev( $revisions ); |
|
301 |
} |
|
302 |
$current_id = $revision['id']; |
|
303 |
} else { |
|
304 |
$current_id = $revision->ID; |
|
305 |
} |
|
306 |
$revisions[ $current_id ]['current'] = true; |
|
307 |
} |
|
308 |
||
5 | 309 |
// Now, grab the initial diff. |
0 | 310 |
$compare_two_mode = is_numeric( $from ); |
311 |
if ( ! $compare_two_mode ) { |
|
312 |
$found = array_search( $selected_revision_id, array_keys( $revisions ) ); |
|
313 |
if ( $found ) { |
|
314 |
$from = array_keys( array_slice( $revisions, $found - 1, 1, true ) ); |
|
315 |
$from = reset( $from ); |
|
316 |
} else { |
|
317 |
$from = 0; |
|
318 |
} |
|
319 |
} |
|
320 |
||
321 |
$from = absint( $from ); |
|
322 |
||
9 | 323 |
$diffs = array( |
324 |
array( |
|
325 |
'id' => $from . ':' . $selected_revision_id, |
|
326 |
'fields' => wp_get_revision_ui_diff( $post->ID, $from, $selected_revision_id ), |
|
327 |
), |
|
328 |
); |
|
0 | 329 |
|
330 |
return array( |
|
9 | 331 |
'postId' => $post->ID, |
332 |
'nonce' => wp_create_nonce( 'revisions-ajax-nonce' ), |
|
333 |
'revisionData' => array_values( $revisions ), |
|
334 |
'to' => $selected_revision_id, |
|
335 |
'from' => $from, |
|
336 |
'diffData' => $diffs, |
|
337 |
'baseUrl' => parse_url( admin_url( 'revision.php' ), PHP_URL_PATH ), |
|
338 |
'compareTwoMode' => absint( $compare_two_mode ), // Apparently booleans are not allowed |
|
339 |
'revisionIds' => array_keys( $revisions ), |
|
0 | 340 |
); |
341 |
} |
|
5 | 342 |
|
343 |
/** |
|
344 |
* Print JavaScript templates required for the revisions experience. |
|
345 |
* |
|
346 |
* @since 4.1.0 |
|
347 |
* |
|
348 |
* @global WP_Post $post The global `$post` object. |
|
349 |
*/ |
|
350 |
function wp_print_revision_templates() { |
|
351 |
global $post; |
|
352 |
?><script id="tmpl-revisions-frame" type="text/html"> |
|
353 |
<div class="revisions-control-frame"></div> |
|
354 |
<div class="revisions-diff-frame"></div> |
|
355 |
</script> |
|
356 |
||
357 |
<script id="tmpl-revisions-buttons" type="text/html"> |
|
358 |
<div class="revisions-previous"> |
|
359 |
<input class="button" type="button" value="<?php echo esc_attr_x( 'Previous', 'Button label for a previous revision' ); ?>" /> |
|
360 |
</div> |
|
361 |
||
362 |
<div class="revisions-next"> |
|
363 |
<input class="button" type="button" value="<?php echo esc_attr_x( 'Next', 'Button label for a next revision' ); ?>" /> |
|
364 |
</div> |
|
365 |
</script> |
|
366 |
||
367 |
<script id="tmpl-revisions-checkbox" type="text/html"> |
|
368 |
<div class="revision-toggle-compare-mode"> |
|
369 |
<label> |
|
370 |
<input type="checkbox" class="compare-two-revisions" |
|
371 |
<# |
|
372 |
if ( 'undefined' !== typeof data && data.model.attributes.compareTwoMode ) { |
|
373 |
#> checked="checked"<# |
|
374 |
} |
|
375 |
#> |
|
376 |
/> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
<?php esc_html_e( 'Compare any two revisions' ); ?> |
5 | 378 |
</label> |
379 |
</div> |
|
380 |
</script> |
|
381 |
||
382 |
<script id="tmpl-revisions-meta" type="text/html"> |
|
383 |
<# if ( ! _.isUndefined( data.attributes ) ) { #> |
|
384 |
<div class="diff-title"> |
|
385 |
<# if ( 'from' === data.type ) { #> |
|
386 |
<strong><?php _ex( 'From:', 'Followed by post revision info' ); ?></strong> |
|
387 |
<# } else if ( 'to' === data.type ) { #> |
|
388 |
<strong><?php _ex( 'To:', 'Followed by post revision info' ); ?></strong> |
|
389 |
<# } #> |
|
390 |
<div class="author-card<# if ( data.attributes.autosave ) { #> autosave<# } #>"> |
|
391 |
{{{ data.attributes.author.avatar }}} |
|
392 |
<div class="author-info"> |
|
393 |
<# if ( data.attributes.autosave ) { #> |
|
9 | 394 |
<span class="byline"> |
395 |
<?php |
|
396 |
printf( |
|
397 |
__( 'Autosave by %s' ), |
|
398 |
'<span class="author-name">{{ data.attributes.author.name }}</span>' |
|
399 |
); |
|
400 |
?> |
|
401 |
</span> |
|
5 | 402 |
<# } else if ( data.attributes.current ) { #> |
9 | 403 |
<span class="byline"> |
404 |
<?php |
|
405 |
printf( |
|
406 |
__( 'Current Revision by %s' ), |
|
407 |
'<span class="author-name">{{ data.attributes.author.name }}</span>' |
|
408 |
); |
|
409 |
?> |
|
410 |
</span> |
|
5 | 411 |
<# } else { #> |
9 | 412 |
<span class="byline"> |
413 |
<?php |
|
414 |
printf( |
|
415 |
__( 'Revision by %s' ), |
|
416 |
'<span class="author-name">{{ data.attributes.author.name }}</span>' |
|
417 |
); |
|
418 |
?> |
|
419 |
</span> |
|
5 | 420 |
<# } #> |
421 |
<span class="time-ago">{{ data.attributes.timeAgo }}</span> |
|
422 |
<span class="date">({{ data.attributes.dateShort }})</span> |
|
423 |
</div> |
|
424 |
<# if ( 'to' === data.type && data.attributes.restoreUrl ) { #> |
|
425 |
<input <?php if ( wp_check_post_lock( $post->ID ) ) { ?> |
|
426 |
disabled="disabled" |
|
427 |
<?php } else { ?> |
|
428 |
<# if ( data.attributes.current ) { #> |
|
429 |
disabled="disabled" |
|
430 |
<# } #> |
|
431 |
<?php } ?> |
|
432 |
<# if ( data.attributes.autosave ) { #> |
|
433 |
type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Autosave' ); ?>" /> |
|
434 |
<# } else { #> |
|
435 |
type="button" class="restore-revision button button-primary" value="<?php esc_attr_e( 'Restore This Revision' ); ?>" /> |
|
436 |
<# } #> |
|
437 |
<# } #> |
|
438 |
</div> |
|
439 |
<# if ( 'tooltip' === data.type ) { #> |
|
440 |
<div class="revisions-tooltip-arrow"><span></span></div> |
|
441 |
<# } #> |
|
442 |
<# } #> |
|
443 |
</script> |
|
444 |
||
445 |
<script id="tmpl-revisions-diff" type="text/html"> |
|
446 |
<div class="loading-indicator"><span class="spinner"></span></div> |
|
447 |
<div class="diff-error"><?php _e( 'Sorry, something went wrong. The requested comparison could not be loaded.' ); ?></div> |
|
448 |
<div class="diff"> |
|
449 |
<# _.each( data.fields, function( field ) { #> |
|
450 |
<h3>{{ field.name }}</h3> |
|
451 |
{{{ field.diff }}} |
|
452 |
<# }); #> |
|
453 |
</div> |
|
9 | 454 |
</script> |
455 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
} |