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.2.1 4.2.2 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.10 4.4.11 4.4.12 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 5.10 5.10.1 5.10.2 5.11 5.11.1 5.11.2 5.11.3 5.11.4 5.12 5.12.1 5.12.2 5.12.3 5.12.4 5.12.5 5.12.6 5.6.10 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 5.6.8 5.6.9 5.7.0 5.7.1 5.7.10 5.7.12 5.7.13 5.7.2 5.7.3 5.7.4 5.7.5 5.7.6 5.7.7 5.7.8 5.7.9 5.8.0 5.8.1 5.8.10 5.8.11 5.8.12 5.8.13 5.8.14 5.8.2 5.8.3 5.8.4
advanced-custom-fields / includes / compatibility.php
advanced-custom-fields / includes Last commit date
admin 1 month ago ajax 3 months ago api 4 weeks ago fields 4 weeks ago forms 4 weeks ago legacy 6 months ago locations 1 month ago post-types 5 months ago rest-api 4 weeks ago walkers 6 months ago acf-bidirectional-functions.php 6 months ago acf-field-functions.php 5 months ago acf-field-group-functions.php 6 months ago acf-form-functions.php 6 months ago acf-helper-functions.php 6 months ago acf-hook-functions.php 6 months ago acf-input-functions.php 6 months ago acf-internal-post-type-functions.php 6 months ago acf-meta-functions.php 2 months ago acf-post-functions.php 6 months ago acf-post-type-functions.php 6 months ago acf-taxonomy-functions.php 6 months ago acf-user-functions.php 6 months ago acf-utility-functions.php 6 months ago acf-value-functions.php 6 months ago acf-wp-functions.php 6 months ago assets.php 5 months ago class-acf-data.php 6 months ago class-acf-internal-post-type.php 6 months ago compatibility.php 6 months ago deprecated.php 6 months ago fields.php 6 months ago index.php 2 years ago l10n.php 6 months ago local-fields.php 6 months ago local-json.php 3 months ago local-meta.php 6 months ago locations.php 6 months ago loop.php 6 months ago media.php 6 months ago rest-api.php 6 months ago revisions.php 3 months ago third-party.php 6 months ago upgrades.php 2 months ago validation.php 6 months ago wpml.php 6 months ago
compatibility.php
492 lines
1 <?php
2 /**
3 * @package ACF
4 * @author WP Engine
5 *
6 * © 2026 Advanced Custom Fields (ACF®). All rights reserved.
7 * "ACF" is a trademark of WP Engine.
8 * Licensed under the GNU General Public License v2 or later.
9 * https://www.gnu.org/licenses/gpl-2.0.html
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly
14 }
15
16 if ( ! class_exists( 'ACF_Compatibility' ) ) :
17
18 class ACF_Compatibility {
19
20 /**
21 * __construct
22 *
23 * Sets up the class functionality.
24 *
25 * @date 30/04/2014
26 * @since 5.0.0
27 *
28 * @param void
29 * @return void
30 */
31 function __construct() {
32
33 // actions
34 add_filter( 'acf/validate_field', array( $this, 'validate_field' ), 20, 1 );
35 add_filter( 'acf/validate_field/type=textarea', array( $this, 'validate_textarea_field' ), 20, 1 );
36 add_filter( 'acf/validate_field/type=relationship', array( $this, 'validate_relationship_field' ), 20, 1 );
37 add_filter( 'acf/validate_field/type=post_object', array( $this, 'validate_relationship_field' ), 20, 1 );
38 add_filter( 'acf/validate_field/type=page_link', array( $this, 'validate_relationship_field' ), 20, 1 );
39 add_filter( 'acf/validate_field/type=image', array( $this, 'validate_image_field' ), 20, 1 );
40 add_filter( 'acf/validate_field/type=file', array( $this, 'validate_image_field' ), 20, 1 );
41 add_filter( 'acf/validate_field/type=wysiwyg', array( $this, 'validate_wysiwyg_field' ), 20, 1 );
42 add_filter( 'acf/validate_field/type=date_picker', array( $this, 'validate_date_picker_field' ), 20, 1 );
43 add_filter( 'acf/validate_field/type=taxonomy', array( $this, 'validate_taxonomy_field' ), 20, 1 );
44 add_filter( 'acf/validate_field/type=date_time_picker', array( $this, 'validate_date_time_picker_field' ), 20, 1 );
45 add_filter( 'acf/validate_field/type=user', array( $this, 'validate_user_field' ), 20, 1 );
46 add_filter( 'acf/validate_field_group', array( $this, 'validate_field_group' ), 20, 1 );
47
48 // Modify field wrapper attributes
49 add_filter( 'acf/field_wrapper_attributes', array( $this, 'field_wrapper_attributes' ), 20, 2 );
50
51 // location
52 add_filter( 'acf/location/validate_rule/type=post_taxonomy', array( $this, 'validate_post_taxonomy_location_rule' ), 20, 1 );
53 add_filter( 'acf/location/validate_rule/type=post_category', array( $this, 'validate_post_taxonomy_location_rule' ), 20, 1 );
54
55 // Update settings
56 add_action( 'acf/init', array( $this, 'init' ) );
57 }
58
59 /**
60 * init
61 *
62 * Adds compatibility for deprecated settings.
63 *
64 * @date 10/6/19
65 * @since 5.8.1
66 *
67 * @param void
68 * @return void
69 */
70 function init() {
71
72 // Update "show_admin" setting based on defined constant.
73 if ( defined( 'ACF_LITE' ) && ACF_LITE ) {
74 acf_update_setting( 'show_admin', false );
75 }
76 }
77
78 /**
79 * field_wrapper_attributes
80 *
81 * Adds compatibility with deprecated field wrap attributes.
82 *
83 * @date 21/1/19
84 * @since 5.7.10
85 *
86 * @param array $wrapper The wrapper attributes array.
87 * @param array $field The field array.
88 */
89 function field_wrapper_attributes( $wrapper, $field ) {
90
91 // Check compatibility setting.
92 if ( acf_get_compatibility( 'field_wrapper_class' ) ) {
93 $wrapper['class'] .= " field_type-{$field['type']}";
94 if ( $field['key'] ) {
95 $wrapper['class'] .= " field_key-{$field['key']}";
96 }
97 }
98
99 // Return wrapper.
100 return $wrapper;
101 }
102
103 /**
104 * validate_field
105 *
106 * Adds compatibility with deprecated settings
107 *
108 * @date 23/04/2014
109 * @since 5.0.0
110 *
111 * @param array $field The field array.
112 * @return array $field
113 */
114 function validate_field( $field ) {
115
116 // conditional logic data structure changed to groups in version 5.0.0
117 // convert previous data (status, rules, allorany) into groups
118 if ( isset( $field['conditional_logic']['status'] ) ) {
119
120 // check status
121 if ( $field['conditional_logic']['status'] ) {
122 $field['conditional_logic'] = acf_convert_rules_to_groups( $field['conditional_logic']['rules'], $field['conditional_logic']['allorany'] );
123 } else {
124 $field['conditional_logic'] = 0;
125 }
126 }
127
128 // return
129 return $field;
130 }
131
132 /**
133 * validate_textarea_field
134 *
135 * Adds compatibility with deprecated settings
136 *
137 * @date 23/04/2014
138 * @since 5.0.0
139 *
140 * @param array $field The field array.
141 * @return array $field
142 */
143 function validate_textarea_field( $field ) {
144
145 // formatting has been removed
146 $formatting = acf_extract_var( $field, 'formatting' );
147 if ( $formatting === 'br' ) {
148 $field['new_lines'] = 'br';
149 }
150
151 // return
152 return $field;
153 }
154
155 /**
156 * validate_relationship_field
157 *
158 * Adds compatibility with deprecated settings
159 *
160 * @date 23/04/2014
161 * @since 5.0.0
162 *
163 * @param array $field The field array.
164 * @return array $field
165 */
166 function validate_relationship_field( $field ) {
167
168 // remove 'all' from post_type
169 if ( acf_in_array( 'all', $field['post_type'] ) ) {
170 $field['post_type'] = array();
171 }
172
173 // remove 'all' from taxonomy
174 if ( acf_in_array( 'all', $field['taxonomy'] ) ) {
175 $field['taxonomy'] = array();
176 }
177
178 // result_elements is now elements
179 if ( isset( $field['result_elements'] ) ) {
180 $field['elements'] = acf_extract_var( $field, 'result_elements' );
181 }
182
183 // return
184 return $field;
185 }
186
187 /**
188 * validate_image_field
189 *
190 * Adds compatibility with deprecated settings
191 *
192 * @date 23/04/2014
193 * @since 5.0.0
194 *
195 * @param array $field The field array.
196 * @return array $field
197 */
198 function validate_image_field( $field ) {
199
200 // save_format is now return_format
201 if ( isset( $field['save_format'] ) ) {
202 $field['return_format'] = acf_extract_var( $field, 'save_format' );
203 }
204
205 // object is now array
206 if ( $field['return_format'] == 'object' ) {
207 $field['return_format'] = 'array';
208 }
209
210 // return
211 return $field;
212 }
213
214 /**
215 * validate_wysiwyg_field
216 *
217 * Adds compatibility with deprecated settings
218 *
219 * @date 23/04/2014
220 * @since 5.0.0
221 *
222 * @param array $field The field array.
223 * @return array $field
224 */
225 function validate_wysiwyg_field( $field ) {
226
227 // media_upload is now numeric
228 if ( $field['media_upload'] === 'yes' ) {
229 $field['media_upload'] = 1;
230 } elseif ( $field['media_upload'] === 'no' ) {
231 $field['media_upload'] = 0;
232 }
233
234 // return
235 return $field;
236 }
237
238 /**
239 * validate_date_picker_field
240 *
241 * Adds compatibility with deprecated settings
242 *
243 * @date 23/04/2014
244 * @since 5.0.0
245 *
246 * @param array $field The field array.
247 * @return array $field
248 */
249 function validate_date_picker_field( $field ) {
250
251 // date_format has changed to display_format
252 if ( isset( $field['date_format'] ) ) {
253
254 // extract vars
255 $date_format = $field['date_format'];
256 $display_format = $field['display_format'];
257
258 // convert from js to php
259 $display_format = acf_convert_date_to_php( $display_format );
260
261 // append settings
262 $field['display_format'] = $display_format;
263 $field['save_format'] = $date_format;
264
265 // clean up
266 unset( $field['date_format'] );
267 }
268
269 // return
270 return $field;
271 }
272
273 /**
274 * validate_taxonomy_field
275 *
276 * Adds compatibility with deprecated settings
277 *
278 * @date 23/04/2014
279 * @since 5.2.7
280 *
281 * @param array $field The field array.
282 * @return array $field
283 */
284 function validate_taxonomy_field( $field ) {
285
286 // load_save_terms deprecated in favour of separate save_terms
287 if ( isset( $field['load_save_terms'] ) ) {
288 $field['save_terms'] = acf_extract_var( $field, 'load_save_terms' );
289 }
290
291 // return
292 return $field;
293 }
294
295 /**
296 * validate_date_time_picker_field
297 *
298 * Adds compatibility with deprecated settings
299 *
300 * @date 23/04/2014
301 * @since 5.2.7
302 *
303 * @param array $field The field array.
304 * @return array $field
305 */
306 function validate_date_time_picker_field( $field ) {
307
308 // 3rd party date time picker
309 // https://github.com/soderlind/acf-field-date-time-picker
310 if ( ! empty( $field['time_format'] ) ) {
311
312 // extract vars
313 $time_format = acf_extract_var( $field, 'time_format' );
314 $date_format = acf_extract_var( $field, 'date_format' );
315 $get_as_timestamp = acf_extract_var( $field, 'get_as_timestamp' );
316
317 // convert from js to php
318 $time_format = acf_convert_time_to_php( $time_format );
319 $date_format = acf_convert_date_to_php( $date_format );
320
321 // append settings
322 $field['return_format'] = $date_format . ' ' . $time_format;
323 $field['display_format'] = $date_format . ' ' . $time_format;
324
325 // timestamp
326 if ( $get_as_timestamp === 'true' ) {
327 $field['return_format'] = 'U';
328 }
329 }
330
331 // return
332 return $field;
333 }
334
335 /**
336 * validate_user_field
337 *
338 * Adds compatibility with deprecated settings
339 *
340 * @date 23/04/2014
341 * @since 5.2.7
342 *
343 * @param array $field The field array.
344 * @return array $field
345 */
346 function validate_user_field( $field ) {
347
348 // remove 'all' from roles
349 if ( acf_in_array( 'all', $field['role'] ) ) {
350 $field['role'] = '';
351 }
352
353 // field_type removed in favour of multiple
354 if ( isset( $field['field_type'] ) ) {
355
356 // extract vars
357 $field_type = acf_extract_var( $field, 'field_type' );
358
359 // multiple
360 if ( $field_type === 'multi_select' ) {
361 $field['multiple'] = true;
362 }
363 }
364
365 // return
366 return $field;
367 }
368
369 /**
370 * This function will provide compatibility with ACF4 field groups
371 *
372 * @type function
373 * @date 23/04/2014
374 * @since 5.0.0
375 *
376 * @param $field_group (array)
377 * @return $field_group
378 */
379 function validate_field_group( $field_group ) {
380
381 // vars
382 $version = 5;
383
384 // field group key was added in version 5.0.0
385 // detect ACF4 data and generate key
386 if ( ! $field_group['key'] ) {
387 $version = 4;
388 $field_group['key'] = isset( $field_group['id'] ) ? "group_{$field_group['id']}" : uniqid( 'group_' );
389 }
390
391 // prior to version 5.0.0, settings were saved in an 'options' array
392 // extract and merge options into the field group
393 if ( isset( $field_group['options'] ) ) {
394 $options = acf_extract_var( $field_group, 'options' );
395 $field_group = array_merge( $field_group, $options );
396 }
397
398 // location data structure changed to groups in version 4.1.0
399 // convert previous data (rules, allorany) into groups
400 if ( isset( $field_group['location']['rules'] ) ) {
401 $field_group['location'] = acf_convert_rules_to_groups( $field_group['location']['rules'], $field_group['location']['allorany'] );
402 }
403
404 // some location rule names have changed in version 5.0.0
405 // loop over location data and modify rules
406 $replace = array(
407 'taxonomy' => 'post_taxonomy',
408 'ef_media' => 'attachment',
409 'ef_taxonomy' => 'taxonomy',
410 'ef_user' => 'user_role',
411 'user_type' => 'current_user_role', // 5.2.0
412 );
413
414 // only replace 'taxonomy' rule if is an ACF4 field group
415 if ( $version > 4 ) {
416 unset( $replace['taxonomy'] );
417 }
418
419 // loop over location groups
420 if ( $field_group['location'] ) {
421 foreach ( $field_group['location'] as $i => $group ) {
422
423 // loop over group rules
424 if ( $group ) {
425 foreach ( $group as $j => $rule ) {
426
427 // migrate param
428 if ( isset( $replace[ $rule['param'] ] ) ) {
429 $field_group['location'][ $i ][ $j ]['param'] = $replace[ $rule['param'] ];
430 }
431 }
432 }
433 }
434 }
435
436 // change layout to style (v5.0.0)
437 if ( isset( $field_group['layout'] ) ) {
438 $field_group['style'] = acf_extract_var( $field_group, 'layout' );
439 }
440
441 // change no_box to seamless (v5.0.0)
442 if ( $field_group['style'] === 'no_box' ) {
443 $field_group['style'] = 'seamless';
444 }
445
446 // return
447 return $field_group;
448 }
449
450 /**
451 * validate_post_taxonomy_location_rule
452 *
453 * description
454 *
455 * @date 27/8/18
456 * @since 5.7.4
457 *
458 * @param type $var Description. Default.
459 * @return type Description.
460 */
461 function validate_post_taxonomy_location_rule( $rule ) {
462
463 // previous versions of ACF (v4.4.12) saved value as term_id
464 // convert term_id into "taxonomy:slug" string
465 if ( is_numeric( $rule['value'] ) ) {
466 $term = acf_get_term( $rule['value'] );
467 if ( $term ) {
468 $rule['value'] = acf_encode_term( $term );
469 }
470 }
471
472 // return
473 return $rule;
474 }
475 }
476
477 acf_new_instance( 'ACF_Compatibility' );
478 endif; // class_exists check
479
480 /**
481 * Returns true if compatibility is enabled for the given component.
482 *
483 * @date 20/1/15
484 * @since 5.1.5
485 *
486 * @param string $name The name of the component to check.
487 * @return boolean
488 */
489 function acf_get_compatibility( $name ) {
490 return apply_filters( "acf/compatibility/{$name}", false );
491 }
492