1 | <?php |
||
3 | class acf_revisions { |
||
4 | |||
5 | /* |
||
6 | * __construct |
||
7 | * |
||
8 | * A good place to add actions / filters |
||
9 | * |
||
10 | * @type function |
||
11 | * @date 11/08/13 |
||
12 | * |
||
13 | * @param N/A |
||
14 | * @return N/A |
||
15 | */ |
||
|
|||
16 | |||
17 | function __construct() |
||
28 | |||
29 | |||
30 | /* |
||
31 | * wp_preview_post_fields |
||
32 | * |
||
33 | * This function is used to trick WP into thinking that one of the $post's fields has changed and |
||
34 | * will allow an autosave to be updated. |
||
35 | * Fixes an odd bug causing the preview page to render the non autosave post data on every odd attempt |
||
36 | * |
||
37 | * @type function |
||
38 | * @date 21/10/2014 |
||
39 | * @since 5.1.0 |
||
40 | * |
||
41 | * @param $fields (array) |
||
42 | * @return $fields |
||
43 | */ |
||
44 | |||
45 | function wp_preview_post_fields( $fields ) { |
||
67 | |||
68 | |||
69 | /* |
||
70 | * force_save_revision |
||
71 | * |
||
72 | * This filter will return false and force WP to save a revision. This is required due to |
||
73 | * WP checking only post_title, post_excerpt and post_content values, not custom fields. |
||
74 | * |
||
75 | * @type filter |
||
76 | * @date 19/09/13 |
||
77 | * |
||
78 | * @param $return (boolean) defaults to true |
||
79 | * @param $last_revision (object) the last revision that WP will compare against |
||
80 | * @param $post (object) the $post that WP will compare against |
||
81 | * @return $return (boolean) |
||
82 | */ |
||
83 | |||
84 | function force_save_revision( $return, $last_revision, $post ) |
||
96 | |||
97 | |||
98 | /* |
||
99 | * wp_post_revision_fields |
||
100 | * |
||
101 | * This filter will add the ACF fields to the returned array |
||
102 | * Versions 3.5 and 3.6 of WP feature different uses of the revisions filters, so there are |
||
103 | * some hacks to allow both versions to work correctly |
||
104 | * |
||
105 | * @type filter |
||
106 | * @date 11/08/13 |
||
107 | * |
||
108 | * @param $post_id (int) |
||
109 | * @return $post_id (int) |
||
110 | */ |
||
111 | |||
112 | function wp_post_revision_fields( $return ) { |
||
220 | |||
221 | |||
222 | /* |
||
223 | * wp_post_revision_field |
||
224 | * |
||
225 | * This filter will load the value for the given field and return it for rendering |
||
226 | * |
||
227 | * @type filter |
||
228 | * @date 11/08/13 |
||
229 | * |
||
230 | * @param $value (mixed) should be false as it has not yet been loaded |
||
231 | * @param $field_name (string) The name of the field |
||
232 | * @param $post (mixed) Holds the $post object to load from - in WP 3.5, this is not passed! |
||
233 | * @param $direction (string) to / from - not used |
||
234 | * @return $value (string) |
||
235 | */ |
||
236 | |||
237 | function wp_post_revision_field( $value, $field_name, $post = null, $direction = false) |
||
292 | |||
293 | |||
294 | /* |
||
295 | * wp_restore_post_revision |
||
296 | * |
||
297 | * This action will copy and paste the metadata from a revision to the post |
||
298 | * |
||
299 | * @type action |
||
300 | * @date 11/08/13 |
||
301 | * |
||
302 | * @param $parent_id (int) the destination post |
||
303 | * @return $revision_id (int) the source post |
||
304 | */ |
||
305 | |||
306 | function wp_restore_post_revision( $post_id, $revision_id ) { |
||
352 | |||
353 | |||
354 | } |
||
355 | |||
359 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.