@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Core |
11 | 11 | */ |
12 | 12 | |
13 | -if( ! class_exists('acf_ajax') ) : |
|
13 | +if ( ! class_exists('acf_ajax')) : |
|
14 | 14 | |
15 | 15 | class acf_ajax { |
16 | 16 | |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | function __construct() { |
32 | 32 | |
33 | 33 | // acf/update_user_setting |
34 | - add_action( 'wp_ajax_acf/update_user_setting', array($this, 'update_user_setting') ); |
|
35 | - add_action( 'wp_ajax_nopriv_acf/update_user_setting', array($this, 'update_user_setting') ); |
|
34 | + add_action('wp_ajax_acf/update_user_setting', array($this, 'update_user_setting')); |
|
35 | + add_action('wp_ajax_nopriv_acf/update_user_setting', array($this, 'update_user_setting')); |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | function update_user_setting() { |
54 | 54 | |
55 | 55 | // options |
56 | - $options = acf_parse_args( $_POST, array( |
|
56 | + $options = acf_parse_args($_POST, array( |
|
57 | 57 | 'name' => '', |
58 | 58 | 'value' => '', |
59 | 59 | 'nonce' => '', |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | |
63 | 63 | // validate |
64 | - if( ! wp_verify_nonce($options['nonce'], 'acf_nonce') || empty($options['name']) ) { |
|
64 | + if ( ! wp_verify_nonce($options['nonce'], 'acf_nonce') || empty($options['name'])) { |
|
65 | 65 | |
66 | 66 | die('0'); |
67 | 67 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | |
71 | 71 | // upadte setting |
72 | - acf_update_user_setting( $options['name'], $options['value'] ); |
|
72 | + acf_update_user_setting($options['name'], $options['value']); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | // return |
@@ -18,27 +18,27 @@ discard block |
||
18 | 18 | function __construct() { |
19 | 19 | |
20 | 20 | // fields |
21 | - add_filter('acf/get_valid_field', array($this, 'get_valid_field'), 20, 1); |
|
22 | - add_filter('acf/get_valid_field/type=textarea', array($this, 'get_valid_textarea_field'), 20, 1); |
|
23 | - add_filter('acf/get_valid_field/type=relationship', array($this, 'get_valid_relationship_field'), 20, 1); |
|
24 | - add_filter('acf/get_valid_field/type=post_object', array($this, 'get_valid_relationship_field'), 20, 1); |
|
25 | - add_filter('acf/get_valid_field/type=page_link', array($this, 'get_valid_relationship_field'), 20, 1); |
|
26 | - add_filter('acf/get_valid_field/type=image', array($this, 'get_valid_image_field'), 20, 1); |
|
27 | - add_filter('acf/get_valid_field/type=file', array($this, 'get_valid_image_field'), 20, 1); |
|
28 | - add_filter('acf/get_valid_field/type=wysiwyg', array($this, 'get_valid_wysiwyg_field'), 20, 1); |
|
29 | - add_filter('acf/get_valid_field/type=date_picker', array($this, 'get_valid_date_picker_field'), 20, 1); |
|
30 | - add_filter('acf/get_valid_field/type=taxonomy', array($this, 'get_valid_taxonomy_field'), 20, 1); |
|
21 | + add_filter('acf/get_valid_field', array($this, 'get_valid_field'), 20, 1); |
|
22 | + add_filter('acf/get_valid_field/type=textarea', array($this, 'get_valid_textarea_field'), 20, 1); |
|
23 | + add_filter('acf/get_valid_field/type=relationship', array($this, 'get_valid_relationship_field'), 20, 1); |
|
24 | + add_filter('acf/get_valid_field/type=post_object', array($this, 'get_valid_relationship_field'), 20, 1); |
|
25 | + add_filter('acf/get_valid_field/type=page_link', array($this, 'get_valid_relationship_field'), 20, 1); |
|
26 | + add_filter('acf/get_valid_field/type=image', array($this, 'get_valid_image_field'), 20, 1); |
|
27 | + add_filter('acf/get_valid_field/type=file', array($this, 'get_valid_image_field'), 20, 1); |
|
28 | + add_filter('acf/get_valid_field/type=wysiwyg', array($this, 'get_valid_wysiwyg_field'), 20, 1); |
|
29 | + add_filter('acf/get_valid_field/type=date_picker', array($this, 'get_valid_date_picker_field'), 20, 1); |
|
30 | + add_filter('acf/get_valid_field/type=taxonomy', array($this, 'get_valid_taxonomy_field'), 20, 1); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | // field groups |
34 | - add_filter('acf/get_valid_field_group', array($this, 'get_valid_field_group'), 20, 1); |
|
34 | + add_filter('acf/get_valid_field_group', array($this, 'get_valid_field_group'), 20, 1); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | // settings |
38 | - add_filter('acf/settings/show_admin', array($this, 'settings_acf_lite'), 5, 1); |
|
39 | - add_filter('acf/settings/l10n_textdomain', array($this, 'settings_export_textdomain'), 5, 1); |
|
40 | - add_filter('acf/settings/l10n_field', array($this, 'settings_export_translate'), 5, 1); |
|
41 | - add_filter('acf/settings/l10n_field_group', array($this, 'settings_export_translate'), 5, 1); |
|
38 | + add_filter('acf/settings/show_admin', array($this, 'settings_acf_lite'), 5, 1); |
|
39 | + add_filter('acf/settings/l10n_textdomain', array($this, 'settings_export_textdomain'), 5, 1); |
|
40 | + add_filter('acf/settings/l10n_field', array($this, 'settings_export_translate'), 5, 1); |
|
41 | + add_filter('acf/settings/l10n_field_group', array($this, 'settings_export_translate'), 5, 1); |
|
42 | 42 | |
43 | 43 | } |
44 | 44 | |
@@ -56,10 +56,10 @@ discard block |
||
56 | 56 | * @return $post_id (int) |
57 | 57 | */ |
58 | 58 | |
59 | - function settings_acf_lite( $setting ) { |
|
59 | + function settings_acf_lite($setting) { |
|
60 | 60 | |
61 | 61 | // 5.0.0 - removed ACF_LITE |
62 | - if( defined('ACF_LITE') && ACF_LITE ) { |
|
62 | + if (defined('ACF_LITE') && ACF_LITE) { |
|
63 | 63 | |
64 | 64 | $setting = false; |
65 | 65 | |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | |
72 | 72 | } |
73 | 73 | |
74 | - function settings_export_textdomain( $setting ) { |
|
74 | + function settings_export_textdomain($setting) { |
|
75 | 75 | |
76 | 76 | // 5.3.3 - changed filter name |
77 | - return acf_get_setting( 'export_textdomain', $setting ); |
|
77 | + return acf_get_setting('export_textdomain', $setting); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | - function settings_export_translate( $setting ) { |
|
81 | + function settings_export_translate($setting) { |
|
82 | 82 | |
83 | 83 | // 5.3.3 - changed filter name |
84 | - return acf_get_setting( 'export_translate', $setting ); |
|
84 | + return acf_get_setting('export_translate', $setting); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -99,17 +99,17 @@ discard block |
||
99 | 99 | * @return $field |
100 | 100 | */ |
101 | 101 | |
102 | - function get_valid_field( $field ) { |
|
102 | + function get_valid_field($field) { |
|
103 | 103 | |
104 | 104 | // conditional logic has changed |
105 | - if( isset($field['conditional_logic']['status']) ) { |
|
105 | + if (isset($field['conditional_logic']['status'])) { |
|
106 | 106 | |
107 | 107 | // extract logic |
108 | - $logic = acf_extract_var( $field, 'conditional_logic' ); |
|
108 | + $logic = acf_extract_var($field, 'conditional_logic'); |
|
109 | 109 | |
110 | 110 | |
111 | 111 | // disabled |
112 | - if( !empty($logic['status']) ) { |
|
112 | + if ( ! empty($logic['status'])) { |
|
113 | 113 | |
114 | 114 | // reset |
115 | 115 | $field['conditional_logic'] = array(); |
@@ -121,12 +121,12 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | // loop over rules |
124 | - if( !empty($logic['rules']) ) { |
|
124 | + if ( ! empty($logic['rules'])) { |
|
125 | 125 | |
126 | - foreach( $logic['rules'] as $rule ) { |
|
126 | + foreach ($logic['rules'] as $rule) { |
|
127 | 127 | |
128 | 128 | // sperate groups? |
129 | - if( $all_or_any == 'any' ) { |
|
129 | + if ($all_or_any == 'any') { |
|
130 | 130 | |
131 | 131 | $group++; |
132 | 132 | |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | // add to group |
137 | - $field['conditional_logic'][ $group ][] = $rule; |
|
137 | + $field['conditional_logic'][$group][] = $rule; |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | * @return $field |
174 | 174 | */ |
175 | 175 | |
176 | - function get_valid_relationship_field( $field ) { |
|
176 | + function get_valid_relationship_field($field) { |
|
177 | 177 | |
178 | 178 | // force array |
179 | 179 | $field['post_type'] = acf_get_array($field['post_type']); |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | |
183 | 183 | // remove 'all' from post_type |
184 | - if( acf_in_array('all', $field['post_type']) ) { |
|
184 | + if (acf_in_array('all', $field['post_type'])) { |
|
185 | 185 | |
186 | 186 | $field['post_type'] = array(); |
187 | 187 | |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | |
191 | 191 | // remove 'all' from taxonomy |
192 | - if( acf_in_array('all', $field['taxonomy']) ) { |
|
192 | + if (acf_in_array('all', $field['taxonomy'])) { |
|
193 | 193 | |
194 | 194 | $field['taxonomy'] = array(); |
195 | 195 | |
@@ -197,9 +197,9 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | // save_format is now return_format |
200 | - if( !empty($field['result_elements']) ) { |
|
200 | + if ( ! empty($field['result_elements'])) { |
|
201 | 201 | |
202 | - $field['elements'] = acf_extract_var( $field, 'result_elements' ); |
|
202 | + $field['elements'] = acf_extract_var($field, 'result_elements'); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | * @return $field |
224 | 224 | */ |
225 | 225 | |
226 | - function get_valid_textarea_field( $field ) { |
|
226 | + function get_valid_textarea_field($field) { |
|
227 | 227 | |
228 | 228 | // formatting has been removed |
229 | - $formatting = acf_extract_var( $field, 'formatting' ); |
|
229 | + $formatting = acf_extract_var($field, 'formatting'); |
|
230 | 230 | |
231 | - if( $formatting === 'br' ) { |
|
231 | + if ($formatting === 'br') { |
|
232 | 232 | |
233 | 233 | $field['new_lines'] = 'br'; |
234 | 234 | |
@@ -253,18 +253,18 @@ discard block |
||
253 | 253 | * @return $field |
254 | 254 | */ |
255 | 255 | |
256 | - function get_valid_image_field( $field ) { |
|
256 | + function get_valid_image_field($field) { |
|
257 | 257 | |
258 | 258 | // save_format is now return_format |
259 | - if( !empty($field['save_format']) ) { |
|
259 | + if ( ! empty($field['save_format'])) { |
|
260 | 260 | |
261 | - $field['return_format'] = acf_extract_var( $field, 'save_format' ); |
|
261 | + $field['return_format'] = acf_extract_var($field, 'save_format'); |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
265 | 265 | |
266 | 266 | // object is now array |
267 | - if( $field['return_format'] == 'object' ) { |
|
267 | + if ($field['return_format'] == 'object') { |
|
268 | 268 | |
269 | 269 | $field['return_format'] = 'array'; |
270 | 270 | |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | * @return $field |
290 | 290 | */ |
291 | 291 | |
292 | - function get_valid_wysiwyg_field( $field ) { |
|
292 | + function get_valid_wysiwyg_field($field) { |
|
293 | 293 | |
294 | 294 | // media_upload is now numeric |
295 | - if( $field['media_upload'] === 'yes' ) { |
|
295 | + if ($field['media_upload'] === 'yes') { |
|
296 | 296 | |
297 | 297 | $field['media_upload'] = 1; |
298 | 298 | |
299 | - } elseif( $field['media_upload'] === 'no' ) { |
|
299 | + } elseif ($field['media_upload'] === 'no') { |
|
300 | 300 | |
301 | 301 | $field['media_upload'] = 0; |
302 | 302 | |
@@ -321,19 +321,19 @@ discard block |
||
321 | 321 | * @return $field |
322 | 322 | */ |
323 | 323 | |
324 | - function get_valid_date_picker_field( $field ) { |
|
324 | + function get_valid_date_picker_field($field) { |
|
325 | 325 | |
326 | 326 | // v4 used date_format |
327 | - if( !empty($field['date_format']) ) { |
|
327 | + if ( ! empty($field['date_format'])) { |
|
328 | 328 | |
329 | 329 | // extract vars |
330 | - $date_format = acf_extract_var( $field, 'date_format' ); |
|
331 | - $display_format = acf_extract_var( $field, 'display_format' ); |
|
330 | + $date_format = acf_extract_var($field, 'date_format'); |
|
331 | + $display_format = acf_extract_var($field, 'display_format'); |
|
332 | 332 | |
333 | 333 | |
334 | 334 | // convert from js to php |
335 | - $date_format = acf_convert_date_to_php( $date_format ); |
|
336 | - $display_format = acf_convert_date_to_php( $display_format ); |
|
335 | + $date_format = acf_convert_date_to_php($date_format); |
|
336 | + $display_format = acf_convert_date_to_php($display_format); |
|
337 | 337 | |
338 | 338 | |
339 | 339 | // append settings |
@@ -362,10 +362,10 @@ discard block |
||
362 | 362 | * @return $field |
363 | 363 | */ |
364 | 364 | |
365 | - function get_valid_taxonomy_field( $field ) { |
|
365 | + function get_valid_taxonomy_field($field) { |
|
366 | 366 | |
367 | 367 | // 5.2.7 |
368 | - if( isset($field['load_save_terms']) ) { |
|
368 | + if (isset($field['load_save_terms'])) { |
|
369 | 369 | |
370 | 370 | $field['save_terms'] = $field['load_save_terms']; |
371 | 371 | |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | * @return $field_group |
392 | 392 | */ |
393 | 393 | |
394 | - function get_valid_field_group( $field_group ) { |
|
394 | + function get_valid_field_group($field_group) { |
|
395 | 395 | |
396 | 396 | // global |
397 | 397 | global $wpdb; |
@@ -402,20 +402,20 @@ discard block |
||
402 | 402 | |
403 | 403 | |
404 | 404 | // add missing 'key' (v5.0.0) |
405 | - if( empty($field_group['key']) ) { |
|
405 | + if (empty($field_group['key'])) { |
|
406 | 406 | |
407 | 407 | // update version |
408 | 408 | $v = 4; |
409 | 409 | |
410 | 410 | |
411 | 411 | // add missing key |
412 | - $field_group['key'] = empty($field_group['id']) ? uniqid('group_') : 'group_' . $field_group['id']; |
|
412 | + $field_group['key'] = empty($field_group['id']) ? uniqid('group_') : 'group_'.$field_group['id']; |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | 416 | |
417 | 417 | // extract options (v5.0.0) |
418 | - if( !empty($field_group['options']) ) { |
|
418 | + if ( ! empty($field_group['options'])) { |
|
419 | 419 | |
420 | 420 | $options = acf_extract_var($field_group, 'options'); |
421 | 421 | $field_group = array_merge($field_group, $options); |
@@ -424,10 +424,10 @@ discard block |
||
424 | 424 | |
425 | 425 | |
426 | 426 | // location rules changed to groups (v5.0.0) |
427 | - if( !empty($field_group['location']['rules']) ) { |
|
427 | + if ( ! empty($field_group['location']['rules'])) { |
|
428 | 428 | |
429 | 429 | // extract location |
430 | - $location = acf_extract_var( $field_group, 'location' ); |
|
430 | + $location = acf_extract_var($field_group, 'location'); |
|
431 | 431 | |
432 | 432 | |
433 | 433 | // reset location |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | |
441 | 441 | |
442 | 442 | // loop over rules |
443 | - if( !empty($location['rules']) ) { |
|
443 | + if ( ! empty($location['rules'])) { |
|
444 | 444 | |
445 | - foreach( $location['rules'] as $rule ) { |
|
445 | + foreach ($location['rules'] as $rule) { |
|
446 | 446 | |
447 | 447 | // sperate groups? |
448 | - if( $all_or_any == 'any' ) { |
|
448 | + if ($all_or_any == 'any') { |
|
449 | 449 | |
450 | 450 | $group++; |
451 | 451 | |
@@ -453,7 +453,7 @@ discard block |
||
453 | 453 | |
454 | 454 | |
455 | 455 | // add to group |
456 | - $field_group['location'][ $group ][] = $rule; |
|
456 | + $field_group['location'][$group][] = $rule; |
|
457 | 457 | |
458 | 458 | } |
459 | 459 | |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | |
468 | 468 | |
469 | 469 | // some location rules have changed (v5.0.0) |
470 | - if( !empty($field_group['location']) ) { |
|
470 | + if ( ! empty($field_group['location'])) { |
|
471 | 471 | |
472 | 472 | // param changes |
473 | 473 | $param_replace = array( |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | |
481 | 481 | |
482 | 482 | // remove conflicting param |
483 | - if( $v == 5 ) { |
|
483 | + if ($v == 5) { |
|
484 | 484 | |
485 | 485 | unset($param_replace['taxonomy']); |
486 | 486 | |
@@ -488,14 +488,14 @@ discard block |
||
488 | 488 | |
489 | 489 | |
490 | 490 | // loop over location groups |
491 | - foreach( array_keys($field_group['location']) as $i ) { |
|
491 | + foreach (array_keys($field_group['location']) as $i) { |
|
492 | 492 | |
493 | 493 | // extract group |
494 | - $group = acf_extract_var( $field_group['location'], $i ); |
|
494 | + $group = acf_extract_var($field_group['location'], $i); |
|
495 | 495 | |
496 | 496 | |
497 | 497 | // bail early if group is empty |
498 | - if( empty($group) ) { |
|
498 | + if (empty($group)) { |
|
499 | 499 | |
500 | 500 | continue; |
501 | 501 | |
@@ -503,28 +503,28 @@ discard block |
||
503 | 503 | |
504 | 504 | |
505 | 505 | // loop over group rules |
506 | - foreach( array_keys($group) as $j ) { |
|
506 | + foreach (array_keys($group) as $j) { |
|
507 | 507 | |
508 | 508 | // extract rule |
509 | - $rule = acf_extract_var( $group, $j ); |
|
509 | + $rule = acf_extract_var($group, $j); |
|
510 | 510 | |
511 | 511 | |
512 | 512 | // migrate param |
513 | - if( isset($param_replace[ $rule['param'] ]) ) { |
|
513 | + if (isset($param_replace[$rule['param']])) { |
|
514 | 514 | |
515 | - $rule['param'] = $param_replace[ $rule['param'] ]; |
|
515 | + $rule['param'] = $param_replace[$rule['param']]; |
|
516 | 516 | |
517 | 517 | } |
518 | 518 | |
519 | 519 | |
520 | 520 | // category / taxonomy terms are saved differently |
521 | - if( $rule['param'] == 'post_category' || $rule['param'] == 'post_taxonomy' ) { |
|
521 | + if ($rule['param'] == 'post_category' || $rule['param'] == 'post_taxonomy') { |
|
522 | 522 | |
523 | - if( is_numeric($rule['value']) ) { |
|
523 | + if (is_numeric($rule['value'])) { |
|
524 | 524 | |
525 | 525 | $term_id = $rule['value']; |
526 | - $taxonomy = $wpdb->get_var( $wpdb->prepare( "SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id) ); |
|
527 | - $term = get_term( $term_id, $taxonomy ); |
|
526 | + $taxonomy = $wpdb->get_var($wpdb->prepare("SELECT taxonomy FROM $wpdb->term_taxonomy WHERE term_id = %d LIMIT 1", $term_id)); |
|
527 | + $term = get_term($term_id, $taxonomy); |
|
528 | 528 | |
529 | 529 | // update rule value |
530 | 530 | $rule['value'] = "{$term->taxonomy}:{$term->slug}"; |
@@ -535,14 +535,14 @@ discard block |
||
535 | 535 | |
536 | 536 | |
537 | 537 | // append rule |
538 | - $group[ $j ] = $rule; |
|
538 | + $group[$j] = $rule; |
|
539 | 539 | |
540 | 540 | } |
541 | 541 | // foreach |
542 | 542 | |
543 | 543 | |
544 | 544 | // append group |
545 | - $field_group['location'][ $i ] = $group; |
|
545 | + $field_group['location'][$i] = $group; |
|
546 | 546 | |
547 | 547 | } |
548 | 548 | // foreach |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | |
553 | 553 | |
554 | 554 | // change layout to style (v5.0.0) |
555 | - if( !empty($field_group['layout']) ) { |
|
555 | + if ( ! empty($field_group['layout'])) { |
|
556 | 556 | |
557 | 557 | $field_group['style'] = acf_extract_var($field_group, 'layout'); |
558 | 558 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | |
561 | 561 | |
562 | 562 | // change no_box to seamless (v5.0.0) |
563 | - if( $field_group['style'] === 'no_box' ) { |
|
563 | + if ($field_group['style'] === 'no_box') { |
|
564 | 564 | |
565 | 565 | $field_group['style'] = 'seamless'; |
566 | 566 |
@@ -25,40 +25,40 @@ discard block |
||
25 | 25 | function __construct() { |
26 | 26 | |
27 | 27 | // register field |
28 | - add_filter("acf/get_field_types", array($this, 'get_field_types'), 10, 1); |
|
29 | - add_filter("acf/get_valid_field/type={$this->name}", array($this, 'get_valid_field'), 10, 1); |
|
28 | + add_filter("acf/get_field_types", array($this, 'get_field_types'), 10, 1); |
|
29 | + add_filter("acf/get_valid_field/type={$this->name}", array($this, 'get_valid_field'), 10, 1); |
|
30 | 30 | |
31 | 31 | |
32 | 32 | // value |
33 | - $this->add_filter("acf/load_value/type={$this->name}", array($this, 'load_value'), 10, 3); |
|
34 | - $this->add_filter("acf/update_value/type={$this->name}", array($this, 'update_value'), 10, 3); |
|
35 | - $this->add_filter("acf/format_value/type={$this->name}", array($this, 'format_value'), 10, 3); |
|
36 | - $this->add_filter("acf/validate_value/type={$this->name}", array($this, 'validate_value'), 10, 4); |
|
37 | - $this->add_action("acf/delete_value/type={$this->name}", array($this, 'delete_value'), 10, 3); |
|
33 | + $this->add_filter("acf/load_value/type={$this->name}", array($this, 'load_value'), 10, 3); |
|
34 | + $this->add_filter("acf/update_value/type={$this->name}", array($this, 'update_value'), 10, 3); |
|
35 | + $this->add_filter("acf/format_value/type={$this->name}", array($this, 'format_value'), 10, 3); |
|
36 | + $this->add_filter("acf/validate_value/type={$this->name}", array($this, 'validate_value'), 10, 4); |
|
37 | + $this->add_action("acf/delete_value/type={$this->name}", array($this, 'delete_value'), 10, 3); |
|
38 | 38 | |
39 | 39 | |
40 | 40 | // field |
41 | - $this->add_filter("acf/load_field/type={$this->name}", array($this, 'load_field'), 10, 1); |
|
42 | - $this->add_filter("acf/update_field/type={$this->name}", array($this, 'update_field'), 10, 1); |
|
43 | - $this->add_filter("acf/duplicate_field/type={$this->name}", array($this, 'duplicate_field'), 10, 1); |
|
44 | - $this->add_action("acf/delete_field/type={$this->name}", array($this, 'delete_field'), 10, 1); |
|
45 | - $this->add_action("acf/render_field/type={$this->name}", array($this, 'render_field'), 10, 1); |
|
46 | - $this->add_action("acf/render_field_settings/type={$this->name}", array($this, 'render_field_settings'), 10, 1); |
|
47 | - $this->add_action("acf/prepare_field/type={$this->name}", array($this, 'prepare_field'), 10, 1); |
|
41 | + $this->add_filter("acf/load_field/type={$this->name}", array($this, 'load_field'), 10, 1); |
|
42 | + $this->add_filter("acf/update_field/type={$this->name}", array($this, 'update_field'), 10, 1); |
|
43 | + $this->add_filter("acf/duplicate_field/type={$this->name}", array($this, 'duplicate_field'), 10, 1); |
|
44 | + $this->add_action("acf/delete_field/type={$this->name}", array($this, 'delete_field'), 10, 1); |
|
45 | + $this->add_action("acf/render_field/type={$this->name}", array($this, 'render_field'), 10, 1); |
|
46 | + $this->add_action("acf/render_field_settings/type={$this->name}", array($this, 'render_field_settings'), 10, 1); |
|
47 | + $this->add_action("acf/prepare_field/type={$this->name}", array($this, 'prepare_field'), 10, 1); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | // input actions |
51 | - $this->add_action("acf/input/admin_enqueue_scripts", array($this, 'input_admin_enqueue_scripts'), 10, 0); |
|
52 | - $this->add_action("acf/input/admin_head", array($this, 'input_admin_head'), 10, 0); |
|
53 | - $this->add_action("acf/input/form_data", array($this, 'input_form_data'), 10, 1); |
|
54 | - $this->add_filter("acf/input/admin_l10n", array($this, 'input_admin_l10n'), 10, 1); |
|
55 | - $this->add_action("acf/input/admin_footer", array($this, 'input_admin_footer'), 10, 1); |
|
51 | + $this->add_action("acf/input/admin_enqueue_scripts", array($this, 'input_admin_enqueue_scripts'), 10, 0); |
|
52 | + $this->add_action("acf/input/admin_head", array($this, 'input_admin_head'), 10, 0); |
|
53 | + $this->add_action("acf/input/form_data", array($this, 'input_form_data'), 10, 1); |
|
54 | + $this->add_filter("acf/input/admin_l10n", array($this, 'input_admin_l10n'), 10, 1); |
|
55 | + $this->add_action("acf/input/admin_footer", array($this, 'input_admin_footer'), 10, 1); |
|
56 | 56 | |
57 | 57 | |
58 | 58 | // field group actions |
59 | - $this->add_action("acf/field_group/admin_enqueue_scripts", array($this, 'field_group_admin_enqueue_scripts'), 10, 0); |
|
60 | - $this->add_action("acf/field_group/admin_head", array($this, 'field_group_admin_head'), 10, 0); |
|
61 | - $this->add_action("acf/field_group/admin_footer", array($this, 'field_group_admin_footer'), 10, 0); |
|
59 | + $this->add_action("acf/field_group/admin_enqueue_scripts", array($this, 'field_group_admin_enqueue_scripts'), 10, 0); |
|
60 | + $this->add_action("acf/field_group/admin_head", array($this, 'field_group_admin_head'), 10, 0); |
|
61 | + $this->add_action("acf/field_group/admin_footer", array($this, 'field_group_admin_footer'), 10, 0); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | |
81 | 81 | function add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) { |
82 | 82 | |
83 | - if( is_callable($function_to_add) ) |
|
83 | + if (is_callable($function_to_add)) |
|
84 | 84 | { |
85 | 85 | add_filter($tag, $function_to_add, $priority, $accepted_args); |
86 | 86 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { |
107 | 107 | |
108 | - if( is_callable($function_to_add) ) |
|
108 | + if (is_callable($function_to_add)) |
|
109 | 109 | { |
110 | 110 | add_action($tag, $function_to_add, $priority, $accepted_args); |
111 | 111 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return $fields |
126 | 126 | */ |
127 | 127 | |
128 | - function get_field_types( $fields ) { |
|
128 | + function get_field_types($fields) { |
|
129 | 129 | |
130 | 130 | $l10n = array( |
131 | 131 | 'basic' => __('Basic', 'acf'), |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | |
139 | 139 | |
140 | 140 | // defaults |
141 | - if( !$this->category ) |
|
141 | + if ( ! $this->category) |
|
142 | 142 | { |
143 | 143 | $this->category = 'basic'; |
144 | 144 | } |
145 | 145 | |
146 | 146 | |
147 | 147 | // cat |
148 | - if( isset($l10n[ $this->category ]) ) |
|
148 | + if (isset($l10n[$this->category])) |
|
149 | 149 | { |
150 | - $cat = $l10n[ $this->category ]; |
|
150 | + $cat = $l10n[$this->category]; |
|
151 | 151 | } |
152 | 152 | else |
153 | 153 | { |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | |
158 | 158 | // add to array |
159 | - $fields[ $cat ][ $this->name ] = $this->label; |
|
159 | + $fields[$cat][$this->name] = $this->label; |
|
160 | 160 | |
161 | 161 | |
162 | 162 | // return array |
@@ -177,15 +177,15 @@ discard block |
||
177 | 177 | * @return $field (array) |
178 | 178 | */ |
179 | 179 | |
180 | - function get_valid_field( $field ) { |
|
180 | + function get_valid_field($field) { |
|
181 | 181 | |
182 | - if( !empty($this->defaults) ) |
|
182 | + if ( ! empty($this->defaults)) |
|
183 | 183 | { |
184 | - foreach( $this->defaults as $k => $v ) |
|
184 | + foreach ($this->defaults as $k => $v) |
|
185 | 185 | { |
186 | - if( !isset($field[ $k ]) ) |
|
186 | + if ( ! isset($field[$k])) |
|
187 | 187 | { |
188 | - $field[ $k ] = $v; |
|
188 | + $field[$k] = $v; |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -207,11 +207,11 @@ discard block |
||
207 | 207 | * @return $l10n (array) |
208 | 208 | */ |
209 | 209 | |
210 | - function input_admin_l10n( $l10n ) { |
|
210 | + function input_admin_l10n($l10n) { |
|
211 | 211 | |
212 | - if( !empty($this->l10n) ) |
|
212 | + if ( ! empty($this->l10n)) |
|
213 | 213 | { |
214 | - $l10n[ $this->name ] = $this->l10n; |
|
214 | + $l10n[$this->name] = $this->l10n; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | return $l10n; |
@@ -148,8 +148,7 @@ |
||
148 | 148 | if( isset($l10n[ $this->category ]) ) |
149 | 149 | { |
150 | 150 | $cat = $l10n[ $this->category ]; |
151 | - } |
|
152 | - else |
|
151 | + } else |
|
153 | 152 | { |
154 | 153 | $cat = $this->category; |
155 | 154 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Core |
11 | 11 | */ |
12 | 12 | |
13 | -if( ! class_exists('acf_input') ) : |
|
13 | +if ( ! class_exists('acf_input')) : |
|
14 | 14 | |
15 | 15 | class acf_input { |
16 | 16 | |
@@ -36,14 +36,14 @@ discard block |
||
36 | 36 | |
37 | 37 | |
38 | 38 | // actions |
39 | - add_action('acf/save_post', array($this, 'save_post'), 10, 1); |
|
40 | - add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 10, 0); |
|
41 | - add_action('acf/input/admin_footer', array($this, 'admin_footer'), 10, 0); |
|
39 | + add_action('acf/save_post', array($this, 'save_post'), 10, 1); |
|
40 | + add_action('acf/input/admin_enqueue_scripts', array($this, 'admin_enqueue_scripts'), 10, 0); |
|
41 | + add_action('acf/input/admin_footer', array($this, 'admin_footer'), 10, 0); |
|
42 | 42 | |
43 | 43 | |
44 | 44 | // ajax |
45 | - add_action( 'wp_ajax_acf/validate_save_post', array($this, 'ajax_validate_save_post') ); |
|
46 | - add_action( 'wp_ajax_nopriv_acf/validate_save_post', array($this, 'ajax_validate_save_post') ); |
|
45 | + add_action('wp_ajax_acf/validate_save_post', array($this, 'ajax_validate_save_post')); |
|
46 | + add_action('wp_ajax_nopriv_acf/validate_save_post', array($this, 'ajax_validate_save_post')); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 | |
@@ -68,18 +68,18 @@ discard block |
||
68 | 68 | |
69 | 69 | |
70 | 70 | // determine action hooks |
71 | - if( $pagenow == 'customize.php' ) { |
|
71 | + if ($pagenow == 'customize.php') { |
|
72 | 72 | |
73 | 73 | $this->admin_head = 'customize_controls_print_scripts'; |
74 | 74 | $this->admin_footer = 'customize_controls_print_footer_scripts'; |
75 | 75 | |
76 | - } elseif( $pagenow == 'wp-login.php' ) { |
|
76 | + } elseif ($pagenow == 'wp-login.php') { |
|
77 | 77 | |
78 | 78 | $this->admin_enqueue_scripts = 'login_enqueue_scripts'; |
79 | 79 | $this->admin_head = 'login_head'; |
80 | 80 | $this->admin_footer = 'login_footer'; |
81 | 81 | |
82 | - } elseif( !is_admin() ) { |
|
82 | + } elseif ( ! is_admin()) { |
|
83 | 83 | |
84 | 84 | $this->admin_enqueue_scripts = 'wp_enqueue_scripts'; |
85 | 85 | $this->admin_head = 'wp_head'; |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | |
90 | 90 | |
91 | 91 | // actions |
92 | - acf_maybe_add_action($this->admin_enqueue_scripts, array($this, 'do_admin_enqueue_scripts'), 20 ); |
|
93 | - acf_maybe_add_action($this->admin_head, array($this, 'do_admin_head'), 20 ); |
|
94 | - acf_maybe_add_action($this->admin_footer, array($this, 'do_admin_footer'), 20 ); |
|
92 | + acf_maybe_add_action($this->admin_enqueue_scripts, array($this, 'do_admin_enqueue_scripts'), 20); |
|
93 | + acf_maybe_add_action($this->admin_head, array($this, 'do_admin_head'), 20); |
|
94 | + acf_maybe_add_action($this->admin_footer, array($this, 'do_admin_footer'), 20); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -127,25 +127,25 @@ discard block |
||
127 | 127 | * @return $post_id (int) |
128 | 128 | */ |
129 | 129 | |
130 | - function save_post( $post_id = 0 ) { |
|
130 | + function save_post($post_id = 0) { |
|
131 | 131 | |
132 | 132 | // bai learly if empty |
133 | - if( empty($_POST['acf']) ) return; |
|
133 | + if (empty($_POST['acf'])) return; |
|
134 | 134 | |
135 | 135 | |
136 | 136 | // save $_POST data |
137 | - foreach( $_POST['acf'] as $k => $v ) { |
|
137 | + foreach ($_POST['acf'] as $k => $v) { |
|
138 | 138 | |
139 | 139 | // get field |
140 | - $field = acf_get_field( $k ); |
|
140 | + $field = acf_get_field($k); |
|
141 | 141 | |
142 | 142 | |
143 | 143 | // continue if no field |
144 | - if( !$field ) continue; |
|
144 | + if ( ! $field) continue; |
|
145 | 145 | |
146 | 146 | |
147 | 147 | // update |
148 | - acf_update_value( $v, $post_id, $field ); |
|
148 | + acf_update_value($v, $post_id, $field); |
|
149 | 149 | |
150 | 150 | } |
151 | 151 | |
@@ -203,9 +203,9 @@ discard block |
||
203 | 203 | // options |
204 | 204 | $o = array( |
205 | 205 | 'post_id' => $args['post_id'], |
206 | - 'nonce' => wp_create_nonce( 'acf_nonce' ), |
|
206 | + 'nonce' => wp_create_nonce('acf_nonce'), |
|
207 | 207 | 'admin_url' => admin_url(), |
208 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), |
|
208 | + 'ajaxurl' => admin_url('admin-ajax.php'), |
|
209 | 209 | 'ajax' => $args['ajax'], |
210 | 210 | 'validation' => $args['validation'], |
211 | 211 | 'wp_version' => $wp_version |
@@ -213,15 +213,15 @@ discard block |
||
213 | 213 | |
214 | 214 | |
215 | 215 | // l10n |
216 | - $l10n = apply_filters( 'acf/input/admin_l10n', array( |
|
217 | - 'unload' => __('The changes you made will be lost if you navigate away from this page','acf'), |
|
218 | - 'expand_details' => __('Expand Details','acf'), |
|
219 | - 'collapse_details' => __('Collapse Details','acf'), |
|
216 | + $l10n = apply_filters('acf/input/admin_l10n', array( |
|
217 | + 'unload' => __('The changes you made will be lost if you navigate away from this page', 'acf'), |
|
218 | + 'expand_details' => __('Expand Details', 'acf'), |
|
219 | + 'collapse_details' => __('Collapse Details', 'acf'), |
|
220 | 220 | 'validation_successful' => __('Validation successful', 'acf'), |
221 | 221 | 'validation_failed' => __('Validation failed', 'acf'), |
222 | 222 | 'validation_failed_1' => __('1 field requires attention', 'acf'), |
223 | 223 | 'validation_failed_2' => __('%d fields require attention', 'acf'), |
224 | - 'restricted' => __('Restricted','acf') |
|
224 | + 'restricted' => __('Restricted', 'acf') |
|
225 | 225 | )); |
226 | 226 | |
227 | 227 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | function ajax_validate_save_post() { |
261 | 261 | |
262 | 262 | // bail early if _acfnonce is missing |
263 | - if( !isset($_POST['_acfnonce']) ) { |
|
263 | + if ( ! isset($_POST['_acfnonce'])) { |
|
264 | 264 | |
265 | 265 | wp_send_json_error(); |
266 | 266 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | |
277 | 277 | // success |
278 | - if( acf_validate_save_post() ) { |
|
278 | + if (acf_validate_save_post()) { |
|
279 | 279 | |
280 | 280 | wp_send_json_success($json); |
281 | 281 | |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | function acf_enqueue_uploader() { |
349 | 349 | |
350 | 350 | // bail early if doing ajax |
351 | - if( defined('DOING_AJAX') && DOING_AJAX ) return; |
|
351 | + if (defined('DOING_AJAX') && DOING_AJAX) return; |
|
352 | 352 | |
353 | 353 | |
354 | 354 | // bail ealry if already run |
355 | - if( acf_has_done('enqueue_uploader') ) return; |
|
355 | + if (acf_has_done('enqueue_uploader')) return; |
|
356 | 356 | |
357 | 357 | |
358 | 358 | // enqueue media if user can upload |
359 | - if( current_user_can('upload_files') ) { |
|
359 | + if (current_user_can('upload_files')) { |
|
360 | 360 | |
361 | 361 | wp_enqueue_media(); |
362 | 362 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | |
365 | 365 | |
366 | 366 | // create dummy editor |
367 | - ?><div class="acf-hidden"><?php wp_editor( '', 'acf_content' ); ?></div><?php |
|
367 | + ?><div class="acf-hidden"><?php wp_editor('', 'acf_content'); ?></div><?php |
|
368 | 368 | |
369 | 369 | } |
370 | 370 | |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | * @return $post_id (int) |
383 | 383 | */ |
384 | 384 | |
385 | -function acf_form_data( $args = array() ) { |
|
385 | +function acf_form_data($args = array()) { |
|
386 | 386 | |
387 | 387 | // make sure scripts and styles have been included |
388 | 388 | // case: front end bbPress edit user |
@@ -391,10 +391,10 @@ discard block |
||
391 | 391 | |
392 | 392 | // defaults |
393 | 393 | $args = acf_parse_args($args, array( |
394 | - 'post_id' => 0, // ID of current post |
|
395 | - 'nonce' => 'post', // nonce used for $_POST validation |
|
396 | - 'validation' => 1, // runs AJAX validation |
|
397 | - 'ajax' => 0, // fetches new field groups via AJAX |
|
394 | + 'post_id' => 0, // ID of current post |
|
395 | + 'nonce' => 'post', // nonce used for $_POST validation |
|
396 | + 'validation' => 1, // runs AJAX validation |
|
397 | + 'ajax' => 0, // fetches new field groups via AJAX |
|
398 | 398 | )); |
399 | 399 | |
400 | 400 | |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | |
404 | 404 | |
405 | 405 | // enqueue uploader if page allows AJAX fields to appear |
406 | - if( $args['ajax'] ) { |
|
406 | + if ($args['ajax']) { |
|
407 | 407 | |
408 | 408 | add_action('admin_footer', 'acf_enqueue_uploader', 1); |
409 | 409 | |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | |
412 | 412 | ?> |
413 | 413 | <div id="acf-form-data" class="acf-hidden"> |
414 | - <input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce( $args['nonce'] ); ?>" /> |
|
414 | + <input type="hidden" name="_acfnonce" value="<?php echo wp_create_nonce($args['nonce']); ?>" /> |
|
415 | 415 | <input type="hidden" name="_acfchanged" value="0" /> |
416 | 416 | <?php do_action('acf/input/form_data', $args); ?> |
417 | 417 | </div> |
@@ -433,10 +433,10 @@ discard block |
||
433 | 433 | * @return $post_id (int) |
434 | 434 | */ |
435 | 435 | |
436 | -function acf_save_post( $post_id = 0 ) { |
|
436 | +function acf_save_post($post_id = 0) { |
|
437 | 437 | |
438 | 438 | // bail early if no acf values |
439 | - if( empty($_POST['acf']) ) return false; |
|
439 | + if (empty($_POST['acf'])) return false; |
|
440 | 440 | |
441 | 441 | |
442 | 442 | // hook for 3rd party customization |
@@ -462,22 +462,22 @@ discard block |
||
462 | 462 | * @return (boolean) |
463 | 463 | */ |
464 | 464 | |
465 | -function acf_validate_save_post( $show_errors = false ) { |
|
465 | +function acf_validate_save_post($show_errors = false) { |
|
466 | 466 | |
467 | 467 | // validate required fields |
468 | - if( !empty($_POST['acf']) ) { |
|
468 | + if ( ! empty($_POST['acf'])) { |
|
469 | 469 | |
470 | 470 | $keys = array_keys($_POST['acf']); |
471 | 471 | |
472 | 472 | // loop through and save $_POST data |
473 | - foreach( $keys as $key ) { |
|
473 | + foreach ($keys as $key) { |
|
474 | 474 | |
475 | 475 | // get field |
476 | - $field = acf_get_field( $key ); |
|
476 | + $field = acf_get_field($key); |
|
477 | 477 | |
478 | 478 | |
479 | 479 | // validate |
480 | - acf_validate_value( $_POST['acf'][ $key ], $field, "acf[{$key}]" ); |
|
480 | + acf_validate_value($_POST['acf'][$key], $field, "acf[{$key}]"); |
|
481 | 481 | |
482 | 482 | } |
483 | 483 | // foreach($fields as $key => $value) |
@@ -490,21 +490,21 @@ discard block |
||
490 | 490 | |
491 | 491 | |
492 | 492 | // check errors |
493 | - if( $errors = acf_get_validation_errors() ) { |
|
493 | + if ($errors = acf_get_validation_errors()) { |
|
494 | 494 | |
495 | - if( $show_errors ) { |
|
495 | + if ($show_errors) { |
|
496 | 496 | |
497 | 497 | $message = '<h2>Validation failed</h2><ul>'; |
498 | 498 | |
499 | - foreach( $errors as $error ) { |
|
499 | + foreach ($errors as $error) { |
|
500 | 500 | |
501 | - $message .= '<li>' . $error['message'] . '</li>'; |
|
501 | + $message .= '<li>'.$error['message'].'</li>'; |
|
502 | 502 | |
503 | 503 | } |
504 | 504 | |
505 | 505 | $message .= '</ul>'; |
506 | 506 | |
507 | - wp_die( $message, 'Validation failed' ); |
|
507 | + wp_die($message, 'Validation failed'); |
|
508 | 508 | |
509 | 509 | } |
510 | 510 | |
@@ -534,18 +534,18 @@ discard block |
||
534 | 534 | * @return (boolean) |
535 | 535 | */ |
536 | 536 | |
537 | -function acf_validate_value( $value, $field, $input ) { |
|
537 | +function acf_validate_value($value, $field, $input) { |
|
538 | 538 | |
539 | 539 | // vars |
540 | 540 | $valid = true; |
541 | - $message = sprintf( __( '%s value is required', 'acf' ), $field['label'] ); |
|
541 | + $message = sprintf(__('%s value is required', 'acf'), $field['label']); |
|
542 | 542 | |
543 | 543 | |
544 | 544 | // valid |
545 | - if( $field['required'] ) { |
|
545 | + if ($field['required']) { |
|
546 | 546 | |
547 | 547 | // valid is set to false if the value is empty, but allow 0 as a valid value |
548 | - if( empty($value) && !is_numeric($value) ) { |
|
548 | + if (empty($value) && ! is_numeric($value)) { |
|
549 | 549 | |
550 | 550 | $valid = false; |
551 | 551 | |
@@ -555,14 +555,14 @@ discard block |
||
555 | 555 | |
556 | 556 | |
557 | 557 | // filter for 3rd party customization |
558 | - $valid = apply_filters( "acf/validate_value", $valid, $value, $field, $input ); |
|
559 | - $valid = apply_filters( "acf/validate_value/type={$field['type']}", $valid, $value, $field, $input ); |
|
560 | - $valid = apply_filters( "acf/validate_value/name={$field['name']}", $valid, $value, $field, $input ); |
|
561 | - $valid = apply_filters( "acf/validate_value/key={$field['key']}", $valid, $value, $field, $input ); |
|
558 | + $valid = apply_filters("acf/validate_value", $valid, $value, $field, $input); |
|
559 | + $valid = apply_filters("acf/validate_value/type={$field['type']}", $valid, $value, $field, $input); |
|
560 | + $valid = apply_filters("acf/validate_value/name={$field['name']}", $valid, $value, $field, $input); |
|
561 | + $valid = apply_filters("acf/validate_value/key={$field['key']}", $valid, $value, $field, $input); |
|
562 | 562 | |
563 | 563 | |
564 | 564 | // allow $valid to be a custom error message |
565 | - if( !empty($valid) && is_string($valid) ) { |
|
565 | + if ( ! empty($valid) && is_string($valid)) { |
|
566 | 566 | |
567 | 567 | $message = $valid; |
568 | 568 | $valid = false; |
@@ -570,9 +570,9 @@ discard block |
||
570 | 570 | } |
571 | 571 | |
572 | 572 | |
573 | - if( !$valid ) { |
|
573 | + if ( ! $valid) { |
|
574 | 574 | |
575 | - acf_add_validation_error( $input, $message ); |
|
575 | + acf_add_validation_error($input, $message); |
|
576 | 576 | return false; |
577 | 577 | |
578 | 578 | } |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | * @return $post_id (int) |
599 | 599 | */ |
600 | 600 | |
601 | -function acf_add_validation_error( $input, $message = '' ) { |
|
601 | +function acf_add_validation_error($input, $message = '') { |
|
602 | 602 | |
603 | 603 | // instantiate array if empty |
604 | - if( empty($GLOBALS['acf_validation_errors']) ) { |
|
604 | + if (empty($GLOBALS['acf_validation_errors'])) { |
|
605 | 605 | |
606 | 606 | $GLOBALS['acf_validation_errors'] = array(); |
607 | 607 | |
@@ -633,7 +633,7 @@ discard block |
||
633 | 633 | function acf_get_validation_errors() { |
634 | 634 | |
635 | 635 | // bail early if no errors |
636 | - if( empty($GLOBALS['acf_validation_errors']) ) return false; |
|
636 | + if (empty($GLOBALS['acf_validation_errors'])) return false; |
|
637 | 637 | |
638 | 638 | |
639 | 639 | // return |
@@ -130,7 +130,9 @@ discard block |
||
130 | 130 | function save_post( $post_id = 0 ) { |
131 | 131 | |
132 | 132 | // bai learly if empty |
133 | - if( empty($_POST['acf']) ) return; |
|
133 | + if( empty($_POST['acf']) ) { |
|
134 | + return; |
|
135 | + } |
|
134 | 136 | |
135 | 137 | |
136 | 138 | // save $_POST data |
@@ -141,7 +143,9 @@ discard block |
||
141 | 143 | |
142 | 144 | |
143 | 145 | // continue if no field |
144 | - if( !$field ) continue; |
|
146 | + if( !$field ) { |
|
147 | + continue; |
|
148 | + } |
|
145 | 149 | |
146 | 150 | |
147 | 151 | // update |
@@ -348,11 +352,15 @@ discard block |
||
348 | 352 | function acf_enqueue_uploader() { |
349 | 353 | |
350 | 354 | // bail early if doing ajax |
351 | - if( defined('DOING_AJAX') && DOING_AJAX ) return; |
|
355 | + if( defined('DOING_AJAX') && DOING_AJAX ) { |
|
356 | + return; |
|
357 | + } |
|
352 | 358 | |
353 | 359 | |
354 | 360 | // bail ealry if already run |
355 | - if( acf_has_done('enqueue_uploader') ) return; |
|
361 | + if( acf_has_done('enqueue_uploader') ) { |
|
362 | + return; |
|
363 | + } |
|
356 | 364 | |
357 | 365 | |
358 | 366 | // enqueue media if user can upload |
@@ -436,7 +444,9 @@ discard block |
||
436 | 444 | function acf_save_post( $post_id = 0 ) { |
437 | 445 | |
438 | 446 | // bail early if no acf values |
439 | - if( empty($_POST['acf']) ) return false; |
|
447 | + if( empty($_POST['acf']) ) { |
|
448 | + return false; |
|
449 | + } |
|
440 | 450 | |
441 | 451 | |
442 | 452 | // hook for 3rd party customization |
@@ -633,7 +643,9 @@ discard block |
||
633 | 643 | function acf_get_validation_errors() { |
634 | 644 | |
635 | 645 | // bail early if no errors |
636 | - if( empty($GLOBALS['acf_validation_errors']) ) return false; |
|
646 | + if( empty($GLOBALS['acf_validation_errors']) ) { |
|
647 | + return false; |
|
648 | + } |
|
637 | 649 | |
638 | 650 | |
639 | 651 | // return |
@@ -125,40 +125,40 @@ |
||
125 | 125 | |
126 | 126 | $dir = opendir( $path ); |
127 | 127 | |
128 | - while(false !== ( $file = readdir($dir)) ) { |
|
128 | + while(false !== ( $file = readdir($dir)) ) { |
|
129 | 129 | |
130 | - // only json files |
|
131 | - if( strpos($file, '.json') === false ) { |
|
130 | + // only json files |
|
131 | + if( strpos($file, '.json') === false ) { |
|
132 | 132 | |
133 | - continue; |
|
133 | + continue; |
|
134 | 134 | |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | 137 | |
138 | - // read json |
|
139 | - $json = file_get_contents("{$path}/{$file}"); |
|
138 | + // read json |
|
139 | + $json = file_get_contents("{$path}/{$file}"); |
|
140 | 140 | |
141 | 141 | |
142 | - // validate json |
|
143 | - if( empty($json) ) { |
|
142 | + // validate json |
|
143 | + if( empty($json) ) { |
|
144 | 144 | |
145 | - continue; |
|
145 | + continue; |
|
146 | 146 | |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | 149 | |
150 | - // decode |
|
151 | - $json = json_decode($json, true); |
|
150 | + // decode |
|
151 | + $json = json_decode($json, true); |
|
152 | 152 | |
153 | 153 | |
154 | - // add local |
|
155 | - $json['local'] = 'json'; |
|
154 | + // add local |
|
155 | + $json['local'] = 'json'; |
|
156 | 156 | |
157 | 157 | |
158 | - // add field group |
|
159 | - acf_add_local_field_group( $json ); |
|
158 | + // add field group |
|
159 | + acf_add_local_field_group( $json ); |
|
160 | 160 | |
161 | - } |
|
161 | + } |
|
162 | 162 | |
163 | 163 | } |
164 | 164 |
@@ -5,17 +5,17 @@ discard block |
||
5 | 5 | function __construct() { |
6 | 6 | |
7 | 7 | // update setting |
8 | - acf_update_setting('save_json', get_stylesheet_directory() . '/acf-json'); |
|
9 | - acf_append_setting('load_json', get_stylesheet_directory() . '/acf-json'); |
|
8 | + acf_update_setting('save_json', get_stylesheet_directory().'/acf-json'); |
|
9 | + acf_append_setting('load_json', get_stylesheet_directory().'/acf-json'); |
|
10 | 10 | |
11 | 11 | |
12 | 12 | // actions |
13 | - add_action('acf/update_field_group', array($this, 'update_field_group'), 10, 5); |
|
14 | - add_action('acf/duplicate_field_group', array($this, 'update_field_group'), 10, 5); |
|
15 | - add_action('acf/untrash_field_group', array($this, 'update_field_group'), 10, 5); |
|
16 | - add_action('acf/trash_field_group', array($this, 'delete_field_group'), 10, 5); |
|
17 | - add_action('acf/delete_field_group', array($this, 'delete_field_group'), 10, 5); |
|
18 | - add_action('acf/include_fields', array($this, 'include_fields'), 10, 5); |
|
13 | + add_action('acf/update_field_group', array($this, 'update_field_group'), 10, 5); |
|
14 | + add_action('acf/duplicate_field_group', array($this, 'update_field_group'), 10, 5); |
|
15 | + add_action('acf/untrash_field_group', array($this, 'update_field_group'), 10, 5); |
|
16 | + add_action('acf/trash_field_group', array($this, 'delete_field_group'), 10, 5); |
|
17 | + add_action('acf/delete_field_group', array($this, 'delete_field_group'), 10, 5); |
|
18 | + add_action('acf/include_fields', array($this, 'include_fields'), 10, 5); |
|
19 | 19 | |
20 | 20 | } |
21 | 21 | |
@@ -33,10 +33,10 @@ discard block |
||
33 | 33 | * @return n/a |
34 | 34 | */ |
35 | 35 | |
36 | - function update_field_group( $field_group ) { |
|
36 | + function update_field_group($field_group) { |
|
37 | 37 | |
38 | 38 | // validate |
39 | - if( !acf_get_setting('json') ) { |
|
39 | + if ( ! acf_get_setting('json')) { |
|
40 | 40 | |
41 | 41 | return; |
42 | 42 | |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | |
45 | 45 | |
46 | 46 | // get fields |
47 | - $field_group['fields'] = acf_get_fields( $field_group ); |
|
47 | + $field_group['fields'] = acf_get_fields($field_group); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | // save file |
51 | - acf_write_json_field_group( $field_group ); |
|
51 | + acf_write_json_field_group($field_group); |
|
52 | 52 | |
53 | 53 | } |
54 | 54 | |
@@ -66,17 +66,17 @@ discard block |
||
66 | 66 | * @return n/a |
67 | 67 | */ |
68 | 68 | |
69 | - function delete_field_group( $field_group ) { |
|
69 | + function delete_field_group($field_group) { |
|
70 | 70 | |
71 | 71 | // validate |
72 | - if( !acf_get_setting('json') ) { |
|
72 | + if ( ! acf_get_setting('json')) { |
|
73 | 73 | |
74 | 74 | return; |
75 | 75 | |
76 | 76 | } |
77 | 77 | |
78 | 78 | |
79 | - acf_delete_json_field_group( $field_group['key'] ); |
|
79 | + acf_delete_json_field_group($field_group['key']); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | function include_fields() { |
98 | 98 | |
99 | 99 | // validate |
100 | - if( !acf_get_setting('json') ) { |
|
100 | + if ( ! acf_get_setting('json')) { |
|
101 | 101 | |
102 | 102 | return; |
103 | 103 | |
@@ -109,26 +109,26 @@ discard block |
||
109 | 109 | |
110 | 110 | |
111 | 111 | // loop through and add to cache |
112 | - foreach( $paths as $path ) { |
|
112 | + foreach ($paths as $path) { |
|
113 | 113 | |
114 | 114 | // remove trailing slash |
115 | - $path = untrailingslashit( $path ); |
|
115 | + $path = untrailingslashit($path); |
|
116 | 116 | |
117 | 117 | |
118 | 118 | // check that path exists |
119 | - if( !file_exists( $path ) ) { |
|
119 | + if ( ! file_exists($path)) { |
|
120 | 120 | |
121 | 121 | continue; |
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | 125 | |
126 | - $dir = opendir( $path ); |
|
126 | + $dir = opendir($path); |
|
127 | 127 | |
128 | - while(false !== ( $file = readdir($dir)) ) { |
|
128 | + while (false !== ($file = readdir($dir))) { |
|
129 | 129 | |
130 | 130 | // only json files |
131 | - if( strpos($file, '.json') === false ) { |
|
131 | + if (strpos($file, '.json') === false) { |
|
132 | 132 | |
133 | 133 | continue; |
134 | 134 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | |
142 | 142 | // validate json |
143 | - if( empty($json) ) { |
|
143 | + if (empty($json)) { |
|
144 | 144 | |
145 | 145 | continue; |
146 | 146 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | |
158 | 158 | // add field group |
159 | - acf_add_local_field_group( $json ); |
|
159 | + acf_add_local_field_group($json); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
@@ -182,24 +182,24 @@ discard block |
||
182 | 182 | * @return (boolean) |
183 | 183 | */ |
184 | 184 | |
185 | -function acf_write_json_field_group( $field_group ) { |
|
185 | +function acf_write_json_field_group($field_group) { |
|
186 | 186 | |
187 | 187 | // vars |
188 | 188 | $path = acf_get_setting('save_json'); |
189 | - $file = $field_group['key'] . '.json'; |
|
189 | + $file = $field_group['key'].'.json'; |
|
190 | 190 | |
191 | 191 | |
192 | 192 | // remove trailing slash |
193 | - $path = untrailingslashit( $path ); |
|
193 | + $path = untrailingslashit($path); |
|
194 | 194 | |
195 | 195 | |
196 | 196 | // bail early if dir does not exist |
197 | - if( !is_writable($path) ) return false; |
|
197 | + if ( ! is_writable($path)) return false; |
|
198 | 198 | |
199 | 199 | |
200 | 200 | // prepare for export |
201 | - $id = acf_extract_var( $field_group, 'ID' ); |
|
202 | - $field_group = acf_prepare_field_group_for_export( $field_group ); |
|
201 | + $id = acf_extract_var($field_group, 'ID'); |
|
202 | + $field_group = acf_prepare_field_group_for_export($field_group); |
|
203 | 203 | |
204 | 204 | |
205 | 205 | // add modified time |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | |
209 | 209 | // write file |
210 | 210 | $f = fopen("{$path}/{$file}", 'w'); |
211 | - fwrite($f, acf_json_encode( $field_group )); |
|
211 | + fwrite($f, acf_json_encode($field_group)); |
|
212 | 212 | fclose($f); |
213 | 213 | |
214 | 214 | |
@@ -231,19 +231,19 @@ discard block |
||
231 | 231 | * @return (boolean) |
232 | 232 | */ |
233 | 233 | |
234 | -function acf_delete_json_field_group( $key ) { |
|
234 | +function acf_delete_json_field_group($key) { |
|
235 | 235 | |
236 | 236 | // vars |
237 | 237 | $path = acf_get_setting('save_json'); |
238 | - $file = $key . '.json'; |
|
238 | + $file = $key.'.json'; |
|
239 | 239 | |
240 | 240 | |
241 | 241 | // remove trailing slash |
242 | - $path = untrailingslashit( $path ); |
|
242 | + $path = untrailingslashit($path); |
|
243 | 243 | |
244 | 244 | |
245 | 245 | // bail early if file does not exist |
246 | - if( !is_readable("{$path}/{$file}") ) { |
|
246 | + if ( ! is_readable("{$path}/{$file}")) { |
|
247 | 247 | |
248 | 248 | return false; |
249 | 249 |
@@ -194,7 +194,9 @@ |
||
194 | 194 | |
195 | 195 | |
196 | 196 | // bail early if dir does not exist |
197 | - if( !is_writable($path) ) return false; |
|
197 | + if( !is_writable($path) ) { |
|
198 | + return false; |
|
199 | + } |
|
198 | 200 | |
199 | 201 | |
200 | 202 | // prepare for export |
@@ -85,8 +85,8 @@ |
||
85 | 85 | |
86 | 86 | foreach( $field_groups as $key => $row ) { |
87 | 87 | |
88 | - $menu_order[ $key ] = $row['menu_order']; |
|
89 | - $title[ $key ] = $row['title']; |
|
88 | + $menu_order[ $key ] = $row['menu_order']; |
|
89 | + $title[ $key ] = $row['title']; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 |
@@ -3,16 +3,16 @@ discard block |
||
3 | 3 | class acf_local { |
4 | 4 | |
5 | 5 | // vars |
6 | - var $enabled = true, |
|
6 | + var $enabled = true, |
|
7 | 7 | $groups = array(), |
8 | 8 | $fields = array(), |
9 | - $parents = array(); |
|
9 | + $parents = array(); |
|
10 | 10 | |
11 | 11 | |
12 | 12 | function __construct() { |
13 | 13 | |
14 | 14 | add_filter('acf/get_field_groups', array($this, 'get_field_groups'), 10, 1); |
15 | - add_action('acf/delete_field', array($this, 'delete_field'), 10, 1); |
|
15 | + add_action('acf/delete_field', array($this, 'delete_field'), 10, 1); |
|
16 | 16 | |
17 | 17 | } |
18 | 18 | |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | * @return $field_groups |
31 | 31 | */ |
32 | 32 | |
33 | - function get_field_groups( $field_groups ) { |
|
33 | + function get_field_groups($field_groups) { |
|
34 | 34 | |
35 | 35 | // validate |
36 | - if( !acf_have_local_field_groups() ) { |
|
36 | + if ( ! acf_have_local_field_groups()) { |
|
37 | 37 | |
38 | 38 | return $field_groups; |
39 | 39 | |
@@ -46,9 +46,9 @@ discard block |
||
46 | 46 | |
47 | 47 | |
48 | 48 | // populate ignore list |
49 | - if( !empty($field_groups) ) { |
|
49 | + if ( ! empty($field_groups)) { |
|
50 | 50 | |
51 | - foreach( $field_groups as $k => $group ) { |
|
51 | + foreach ($field_groups as $k => $group) { |
|
52 | 52 | |
53 | 53 | $ignore[] = $group['key']; |
54 | 54 | |
@@ -60,10 +60,10 @@ discard block |
||
60 | 60 | // append field groups |
61 | 61 | $groups = acf_get_local_field_groups(); |
62 | 62 | |
63 | - foreach( $groups as $group ) { |
|
63 | + foreach ($groups as $group) { |
|
64 | 64 | |
65 | 65 | // is ignore |
66 | - if( in_array($group['key'], $ignore) ) { |
|
66 | + if (in_array($group['key'], $ignore)) { |
|
67 | 67 | |
68 | 68 | continue; |
69 | 69 | |
@@ -78,20 +78,20 @@ discard block |
||
78 | 78 | |
79 | 79 | |
80 | 80 | // order field groups based on menu_order, title |
81 | - if( $added ) { |
|
81 | + if ($added) { |
|
82 | 82 | |
83 | 83 | $menu_order = array(); |
84 | 84 | $title = array(); |
85 | 85 | |
86 | - foreach( $field_groups as $key => $row ) { |
|
86 | + foreach ($field_groups as $key => $row) { |
|
87 | 87 | |
88 | - $menu_order[ $key ] = $row['menu_order']; |
|
89 | - $title[ $key ] = $row['title']; |
|
88 | + $menu_order[$key] = $row['menu_order']; |
|
89 | + $title[$key] = $row['title']; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | // sort the array with menu_order ascending |
94 | - array_multisort( $menu_order, SORT_ASC, $title, SORT_ASC, $field_groups ); |
|
94 | + array_multisort($menu_order, SORT_ASC, $title, SORT_ASC, $field_groups); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | * @return $post_id (int) |
116 | 116 | */ |
117 | 117 | |
118 | - function delete_field( $field ) { |
|
118 | + function delete_field($field) { |
|
119 | 119 | |
120 | - $this->remove_field( $field['key'] ); |
|
120 | + $this->remove_field($field['key']); |
|
121 | 121 | |
122 | 122 | } |
123 | 123 | |
@@ -135,14 +135,14 @@ discard block |
||
135 | 135 | * @return n/a |
136 | 136 | */ |
137 | 137 | |
138 | - function add_field_group( $field_group ) { |
|
138 | + function add_field_group($field_group) { |
|
139 | 139 | |
140 | 140 | // validate |
141 | 141 | $field_group = acf_get_valid_field_group($field_group); |
142 | 142 | |
143 | 143 | |
144 | 144 | // don't allow overrides |
145 | - if( acf_is_local_field_group($field_group['key']) ) { |
|
145 | + if (acf_is_local_field_group($field_group['key'])) { |
|
146 | 146 | |
147 | 147 | return; |
148 | 148 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | |
152 | 152 | // add local |
153 | - if( empty($field_group['local']) ) { |
|
153 | + if (empty($field_group['local'])) { |
|
154 | 154 | |
155 | 155 | $field_group['local'] = 'php'; |
156 | 156 | |
@@ -162,18 +162,18 @@ discard block |
||
162 | 162 | |
163 | 163 | |
164 | 164 | // format fields |
165 | - $fields = acf_prepare_fields_for_import( $fields ); |
|
165 | + $fields = acf_prepare_fields_for_import($fields); |
|
166 | 166 | |
167 | 167 | |
168 | 168 | // add field group |
169 | - $this->groups[ $field_group['key'] ] = $field_group; |
|
169 | + $this->groups[$field_group['key']] = $field_group; |
|
170 | 170 | |
171 | 171 | |
172 | 172 | // add fields |
173 | - foreach( $fields as $field ) { |
|
173 | + foreach ($fields as $field) { |
|
174 | 174 | |
175 | 175 | // add parent |
176 | - if( empty($field['parent']) ) { |
|
176 | + if (empty($field['parent'])) { |
|
177 | 177 | |
178 | 178 | $field['parent'] = $field_group['key']; |
179 | 179 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | |
182 | 182 | |
183 | 183 | // add field |
184 | - $this->add_field( $field ); |
|
184 | + $this->add_field($field); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @return n/a |
202 | 202 | */ |
203 | 203 | |
204 | - function add_field( $field ) { |
|
204 | + function add_field($field) { |
|
205 | 205 | |
206 | 206 | // vars |
207 | 207 | // - allow for the very unexpected case where no key or parent exist |
@@ -210,20 +210,20 @@ discard block |
||
210 | 210 | |
211 | 211 | |
212 | 212 | // add parent reference |
213 | - $this->add_parent_reference( $parent, $key ); |
|
213 | + $this->add_parent_reference($parent, $key); |
|
214 | 214 | |
215 | 215 | |
216 | 216 | // add in menu order |
217 | - $field['menu_order'] = count( $this->parents[ $parent ] ) - 1; |
|
217 | + $field['menu_order'] = count($this->parents[$parent]) - 1; |
|
218 | 218 | |
219 | 219 | |
220 | 220 | // add field |
221 | - $this->fields[ $key ] = $field; |
|
221 | + $this->fields[$key] = $field; |
|
222 | 222 | |
223 | 223 | |
224 | 224 | // clear cache |
225 | - wp_cache_delete( "get_field/key={$key}", 'acf' ); |
|
226 | - wp_cache_delete( "get_fields/parent={$parent}", 'acf' ); |
|
225 | + wp_cache_delete("get_field/key={$key}", 'acf'); |
|
226 | + wp_cache_delete("get_fields/parent={$parent}", 'acf'); |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
@@ -241,38 +241,38 @@ discard block |
||
241 | 241 | * @return n/a |
242 | 242 | */ |
243 | 243 | |
244 | - function remove_field( $key ) { |
|
244 | + function remove_field($key) { |
|
245 | 245 | |
246 | 246 | // get field |
247 | - $field = acf_get_field( $key ); |
|
247 | + $field = acf_get_field($key); |
|
248 | 248 | |
249 | 249 | |
250 | 250 | // remove parent reference |
251 | - $this->remove_parent_reference( $field['parent'], $field['key'] ); |
|
251 | + $this->remove_parent_reference($field['parent'], $field['key']); |
|
252 | 252 | |
253 | 253 | |
254 | 254 | // remove field |
255 | - unset( $this->fields[ $key ] ); |
|
255 | + unset($this->fields[$key]); |
|
256 | 256 | |
257 | 257 | |
258 | 258 | // remove children |
259 | - if( acf_have_local_fields( $key) ) { |
|
259 | + if (acf_have_local_fields($key)) { |
|
260 | 260 | |
261 | - acf_remove_local_fields( $key ); |
|
261 | + acf_remove_local_fields($key); |
|
262 | 262 | |
263 | 263 | } |
264 | 264 | |
265 | 265 | } |
266 | 266 | |
267 | 267 | |
268 | - function add_parent_reference( $parent_key, $field_key ) { |
|
268 | + function add_parent_reference($parent_key, $field_key) { |
|
269 | 269 | |
270 | 270 | // create array |
271 | - if( !isset($this->parents[ $parent_key ]) ) { |
|
271 | + if ( ! isset($this->parents[$parent_key])) { |
|
272 | 272 | |
273 | - $this->parents[ $parent_key ] = array(); |
|
273 | + $this->parents[$parent_key] = array(); |
|
274 | 274 | |
275 | - } elseif( in_array($field_key, $this->parents[ $parent_key ]) ) { |
|
275 | + } elseif (in_array($field_key, $this->parents[$parent_key])) { |
|
276 | 276 | |
277 | 277 | // bail early if already in array |
278 | 278 | return false; |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | |
283 | 283 | // append |
284 | - $this->parents[ $parent_key ][] = $field_key; |
|
284 | + $this->parents[$parent_key][] = $field_key; |
|
285 | 285 | |
286 | 286 | |
287 | 287 | // return |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | |
293 | - function remove_parent_reference( $parent_key, $field_key ) { |
|
293 | + function remove_parent_reference($parent_key, $field_key) { |
|
294 | 294 | |
295 | 295 | // bail early if no parent |
296 | - if( !isset($this->parents[ $parent_key ]) ) { |
|
296 | + if ( ! isset($this->parents[$parent_key])) { |
|
297 | 297 | |
298 | 298 | return false; |
299 | 299 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | |
303 | 303 | // remove |
304 | - $this->parents[ $parent_key ] = array_diff($this->parents[ $parent_key ], array($field_key)); |
|
304 | + $this->parents[$parent_key] = array_diff($this->parents[$parent_key], array($field_key)); |
|
305 | 305 | |
306 | 306 | |
307 | 307 | // return |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | |
334 | 334 | // instantiate |
335 | - if( !isset($acf_local) ) |
|
335 | + if ( ! isset($acf_local)) |
|
336 | 336 | { |
337 | 337 | $acf_local = new acf_local(); |
338 | 338 | } |
@@ -399,14 +399,14 @@ discard block |
||
399 | 399 | function acf_is_local_enabled() { |
400 | 400 | |
401 | 401 | // validate |
402 | - if( !acf_get_setting('local') ) { |
|
402 | + if ( ! acf_get_setting('local')) { |
|
403 | 403 | |
404 | 404 | return false; |
405 | 405 | |
406 | 406 | } |
407 | 407 | |
408 | 408 | |
409 | - if( !acf_local()->enabled ) { |
|
409 | + if ( ! acf_local()->enabled) { |
|
410 | 410 | |
411 | 411 | return false; |
412 | 412 | |
@@ -432,20 +432,20 @@ discard block |
||
432 | 432 | * @return (int) |
433 | 433 | */ |
434 | 434 | |
435 | -function acf_count_local_field_groups( $type = '' ) { |
|
435 | +function acf_count_local_field_groups($type = '') { |
|
436 | 436 | |
437 | 437 | // vars |
438 | 438 | $count = 0; |
439 | 439 | |
440 | 440 | |
441 | 441 | // check for groups |
442 | - if( !empty(acf_local()->groups) ) { |
|
442 | + if ( ! empty(acf_local()->groups)) { |
|
443 | 443 | |
444 | 444 | // acf_local |
445 | - foreach( acf_local()->groups as $group ) { |
|
445 | + foreach (acf_local()->groups as $group) { |
|
446 | 446 | |
447 | 447 | // ignore if not specific type |
448 | - if( $type && $group['local'] != $type ) { |
|
448 | + if ($type && $group['local'] != $type) { |
|
449 | 449 | |
450 | 450 | continue; |
451 | 451 | |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | function acf_have_local_field_groups() { |
481 | 481 | |
482 | 482 | // validate |
483 | - if( !acf_is_local_enabled() ) { |
|
483 | + if ( ! acf_is_local_enabled()) { |
|
484 | 484 | |
485 | 485 | return false; |
486 | 486 | |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | |
489 | 489 | |
490 | 490 | // check for groups |
491 | - if( !empty(acf_local()->groups) ) { |
|
491 | + if ( ! empty(acf_local()->groups)) { |
|
492 | 492 | |
493 | 493 | return true; |
494 | 494 | |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | function acf_get_local_field_groups() { |
518 | 518 | |
519 | 519 | // bail early if no groups |
520 | - if( !acf_have_local_field_groups() ) { |
|
520 | + if ( ! acf_have_local_field_groups()) { |
|
521 | 521 | |
522 | 522 | return false; |
523 | 523 | |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | |
530 | 530 | |
531 | 531 | // acf_local |
532 | - foreach( acf_local()->groups as $group ) { |
|
532 | + foreach (acf_local()->groups as $group) { |
|
533 | 533 | |
534 | 534 | $groups[] = $group; |
535 | 535 | |
@@ -555,9 +555,9 @@ discard block |
||
555 | 555 | * @return $post_id (int) |
556 | 556 | */ |
557 | 557 | |
558 | -function acf_add_local_field_group( $field_group ) { |
|
558 | +function acf_add_local_field_group($field_group) { |
|
559 | 559 | |
560 | - acf_local()->add_field_group( $field_group ); |
|
560 | + acf_local()->add_field_group($field_group); |
|
561 | 561 | |
562 | 562 | } |
563 | 563 | |
@@ -575,10 +575,10 @@ discard block |
||
575 | 575 | * @return (bolean) |
576 | 576 | */ |
577 | 577 | |
578 | -function acf_is_local_field_group( $key ) { |
|
578 | +function acf_is_local_field_group($key) { |
|
579 | 579 | |
580 | 580 | // validate |
581 | - if( !acf_is_local_enabled() ) { |
|
581 | + if ( ! acf_is_local_enabled()) { |
|
582 | 582 | |
583 | 583 | return false; |
584 | 584 | |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | |
587 | 587 | |
588 | 588 | // check groups |
589 | - if( isset( acf_local()->groups[ $key ] ) ) { |
|
589 | + if (isset(acf_local()->groups[$key])) { |
|
590 | 590 | |
591 | 591 | return true; |
592 | 592 | |
@@ -612,10 +612,10 @@ discard block |
||
612 | 612 | * @return (bolean) |
613 | 613 | */ |
614 | 614 | |
615 | -function acf_get_local_field_group( $key ) { |
|
615 | +function acf_get_local_field_group($key) { |
|
616 | 616 | |
617 | 617 | // bail early if no group |
618 | - if( !acf_is_local_field_group($key) ) { |
|
618 | + if ( ! acf_is_local_field_group($key)) { |
|
619 | 619 | |
620 | 620 | return false; |
621 | 621 | |
@@ -623,7 +623,7 @@ discard block |
||
623 | 623 | |
624 | 624 | |
625 | 625 | // return |
626 | - return acf_local()->groups[ $key ]; |
|
626 | + return acf_local()->groups[$key]; |
|
627 | 627 | |
628 | 628 | } |
629 | 629 | |
@@ -641,9 +641,9 @@ discard block |
||
641 | 641 | * @return $post_id (int) |
642 | 642 | */ |
643 | 643 | |
644 | -function acf_add_local_field( $field ) { |
|
644 | +function acf_add_local_field($field) { |
|
645 | 645 | |
646 | - acf_local()->add_field( $field ); |
|
646 | + acf_local()->add_field($field); |
|
647 | 647 | |
648 | 648 | } |
649 | 649 | |
@@ -661,9 +661,9 @@ discard block |
||
661 | 661 | * @return $post_id (int) |
662 | 662 | */ |
663 | 663 | |
664 | -function acf_remove_local_field( $key ) { |
|
664 | +function acf_remove_local_field($key) { |
|
665 | 665 | |
666 | - acf_local()->remove_field( $key ); |
|
666 | + acf_local()->remove_field($key); |
|
667 | 667 | |
668 | 668 | } |
669 | 669 | |
@@ -681,10 +681,10 @@ discard block |
||
681 | 681 | * @return (bolean) |
682 | 682 | */ |
683 | 683 | |
684 | -function acf_is_local_field( $key ) { |
|
684 | +function acf_is_local_field($key) { |
|
685 | 685 | |
686 | 686 | // validate |
687 | - if( !acf_is_local_enabled() ) { |
|
687 | + if ( ! acf_is_local_enabled()) { |
|
688 | 688 | |
689 | 689 | return false; |
690 | 690 | |
@@ -692,7 +692,7 @@ discard block |
||
692 | 692 | |
693 | 693 | |
694 | 694 | // check fields |
695 | - if( isset( acf_local()->fields[ $key ] ) ) { |
|
695 | + if (isset(acf_local()->fields[$key])) { |
|
696 | 696 | |
697 | 697 | return true; |
698 | 698 | |
@@ -718,10 +718,10 @@ discard block |
||
718 | 718 | * @return (bolean) |
719 | 719 | */ |
720 | 720 | |
721 | -function acf_get_local_field( $key ) { |
|
721 | +function acf_get_local_field($key) { |
|
722 | 722 | |
723 | 723 | // bail early if no field |
724 | - if( !acf_is_local_field($key) ) { |
|
724 | + if ( ! acf_is_local_field($key)) { |
|
725 | 725 | |
726 | 726 | return false; |
727 | 727 | |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | |
730 | 730 | |
731 | 731 | // return |
732 | - return acf_local()->fields[ $key ]; |
|
732 | + return acf_local()->fields[$key]; |
|
733 | 733 | |
734 | 734 | } |
735 | 735 | |
@@ -747,12 +747,12 @@ discard block |
||
747 | 747 | * @return (int) |
748 | 748 | */ |
749 | 749 | |
750 | -function acf_count_local_fields( $key ) { |
|
750 | +function acf_count_local_fields($key) { |
|
751 | 751 | |
752 | 752 | // check for fields |
753 | - if( !empty(acf_local()->parents[ $key ]) ) { |
|
753 | + if ( ! empty(acf_local()->parents[$key])) { |
|
754 | 754 | |
755 | - return count( acf_local()->parents[ $key ] ); |
|
755 | + return count(acf_local()->parents[$key]); |
|
756 | 756 | |
757 | 757 | } |
758 | 758 | |
@@ -776,10 +776,10 @@ discard block |
||
776 | 776 | * @return (bolean) |
777 | 777 | */ |
778 | 778 | |
779 | -function acf_have_local_fields( $key ) { |
|
779 | +function acf_have_local_fields($key) { |
|
780 | 780 | |
781 | 781 | // validate |
782 | - if( !acf_is_local_enabled() ) { |
|
782 | + if ( ! acf_is_local_enabled()) { |
|
783 | 783 | |
784 | 784 | return false; |
785 | 785 | |
@@ -787,7 +787,7 @@ discard block |
||
787 | 787 | |
788 | 788 | |
789 | 789 | // check parents |
790 | - if( isset( acf_local()->parents[ $key ] ) ) { |
|
790 | + if (isset(acf_local()->parents[$key])) { |
|
791 | 791 | |
792 | 792 | return true; |
793 | 793 | |
@@ -813,10 +813,10 @@ discard block |
||
813 | 813 | * @return (bolean) |
814 | 814 | */ |
815 | 815 | |
816 | -function acf_get_local_fields( $parent ) { |
|
816 | +function acf_get_local_fields($parent) { |
|
817 | 817 | |
818 | 818 | // bail early if no parent |
819 | - if( !acf_have_local_fields($parent) ) { |
|
819 | + if ( ! acf_have_local_fields($parent)) { |
|
820 | 820 | |
821 | 821 | return false; |
822 | 822 | |
@@ -828,9 +828,9 @@ discard block |
||
828 | 828 | |
829 | 829 | |
830 | 830 | // append |
831 | - foreach( acf_local()->parents[ $parent ] as $key ) { |
|
831 | + foreach (acf_local()->parents[$parent] as $key) { |
|
832 | 832 | |
833 | - $fields[] = acf_get_field( $key ); |
|
833 | + $fields[] = acf_get_field($key); |
|
834 | 834 | |
835 | 835 | } |
836 | 836 | |
@@ -854,19 +854,19 @@ discard block |
||
854 | 854 | * @return (bolean) |
855 | 855 | */ |
856 | 856 | |
857 | -function acf_remove_local_fields( $parent ) { |
|
857 | +function acf_remove_local_fields($parent) { |
|
858 | 858 | |
859 | 859 | // bail early if no reference |
860 | - if( empty( acf_local()->parents[ $parent ] ) ) { |
|
860 | + if (empty(acf_local()->parents[$parent])) { |
|
861 | 861 | |
862 | 862 | return false; |
863 | 863 | |
864 | 864 | } |
865 | 865 | |
866 | 866 | |
867 | - foreach( acf_local()->parents[ $parent ] as $key ) { |
|
867 | + foreach (acf_local()->parents[$parent] as $key) { |
|
868 | 868 | |
869 | - acf_remove_local_field( $key ); |
|
869 | + acf_remove_local_field($key); |
|
870 | 870 | |
871 | 871 | } |
872 | 872 |
@@ -83,15 +83,15 @@ discard block |
||
83 | 83 | |
84 | 84 | |
85 | 85 | // compare |
86 | - if( $rule['operator'] == "==" ) { |
|
86 | + if( $rule['operator'] == "==" ) { |
|
87 | 87 | |
88 | - $match = ( $post_type === $rule['value'] ); |
|
88 | + $match = ( $post_type === $rule['value'] ); |
|
89 | 89 | |
90 | - } elseif( $rule['operator'] == "!=" ) { |
|
90 | + } elseif( $rule['operator'] == "!=" ) { |
|
91 | 91 | |
92 | - $match = ( $post_type !== $rule['value'] ); |
|
92 | + $match = ( $post_type !== $rule['value'] ); |
|
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | 97 | // return |
@@ -169,13 +169,13 @@ discard block |
||
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | - // return |
|
173 | - return $match; |
|
172 | + // return |
|
173 | + return $match; |
|
174 | 174 | |
175 | - } |
|
175 | + } |
|
176 | 176 | |
177 | 177 | |
178 | - /* |
|
178 | + /* |
|
179 | 179 | * rule_match_current_user_role |
180 | 180 | * |
181 | 181 | * This function will match a location rule and return true or false |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | // compare |
207 | - if( $rule['operator'] == "==" ) { |
|
207 | + if( $rule['operator'] == "==" ) { |
|
208 | 208 | |
209 | 209 | if( $rule['value'] == 'super_admin' ) { |
210 | 210 | |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | |
234 | - // return |
|
235 | - return $match; |
|
234 | + // return |
|
235 | + return $match; |
|
236 | 236 | |
237 | - } |
|
237 | + } |
|
238 | 238 | |
239 | 239 | |
240 | 240 | /* |
@@ -274,19 +274,19 @@ discard block |
||
274 | 274 | |
275 | 275 | |
276 | 276 | // compare |
277 | - if( $rule['operator'] == "==") { |
|
277 | + if( $rule['operator'] == "==") { |
|
278 | 278 | |
279 | - $match = ( $options['post_id'] == $rule['value'] ); |
|
279 | + $match = ( $options['post_id'] == $rule['value'] ); |
|
280 | 280 | |
281 | - } elseif( $rule['operator'] == "!=") { |
|
281 | + } elseif( $rule['operator'] == "!=") { |
|
282 | 282 | |
283 | - $match = ( $options['post_id'] != $rule['value'] ); |
|
283 | + $match = ( $options['post_id'] != $rule['value'] ); |
|
284 | 284 | |
285 | - } |
|
285 | + } |
|
286 | 286 | |
287 | 287 | |
288 | - // return |
|
289 | - return $match; |
|
288 | + // return |
|
289 | + return $match; |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
@@ -371,21 +371,21 @@ discard block |
||
371 | 371 | |
372 | 372 | |
373 | 373 | // compare |
374 | - if( $rule['operator'] == "==") { |
|
374 | + if( $rule['operator'] == "==") { |
|
375 | 375 | |
376 | - $match = in_array($term->term_id, $terms); |
|
376 | + $match = in_array($term->term_id, $terms); |
|
377 | 377 | |
378 | - } elseif( $rule['operator'] == "!=") { |
|
378 | + } elseif( $rule['operator'] == "!=") { |
|
379 | 379 | |
380 | - $match = !in_array($term->term_id, $terms); |
|
380 | + $match = !in_array($term->term_id, $terms); |
|
381 | 381 | |
382 | - } |
|
382 | + } |
|
383 | 383 | |
384 | 384 | |
385 | - // return |
|
386 | - return $match; |
|
385 | + // return |
|
386 | + return $match; |
|
387 | 387 | |
388 | - } |
|
388 | + } |
|
389 | 389 | |
390 | 390 | |
391 | 391 | /* |
@@ -443,25 +443,25 @@ discard block |
||
443 | 443 | } |
444 | 444 | |
445 | 445 | |
446 | - // compare |
|
447 | - if( $rule['operator'] == "==") { |
|
446 | + // compare |
|
447 | + if( $rule['operator'] == "==") { |
|
448 | 448 | |
449 | - $match = ( $post_format === $rule['value'] ); |
|
449 | + $match = ( $post_format === $rule['value'] ); |
|
450 | 450 | |
451 | - } elseif( $rule['operator'] == "!=") { |
|
451 | + } elseif( $rule['operator'] == "!=") { |
|
452 | 452 | |
453 | - $match = ( $post_format !== $rule['value'] ); |
|
453 | + $match = ( $post_format !== $rule['value'] ); |
|
454 | 454 | |
455 | - } |
|
455 | + } |
|
456 | 456 | |
457 | 457 | |
458 | - // return |
|
459 | - return $match; |
|
458 | + // return |
|
459 | + return $match; |
|
460 | 460 | |
461 | - } |
|
461 | + } |
|
462 | 462 | |
463 | 463 | |
464 | - /* |
|
464 | + /* |
|
465 | 465 | * rule_match_post_status |
466 | 466 | * |
467 | 467 | * This function will match a location rule and return true or false |
@@ -489,30 +489,30 @@ discard block |
||
489 | 489 | $post_status = get_post_status( $options['post_id'] ); |
490 | 490 | |
491 | 491 | |
492 | - // auto-draft = draft |
|
493 | - if( $post_status == 'auto-draft' ) { |
|
492 | + // auto-draft = draft |
|
493 | + if( $post_status == 'auto-draft' ) { |
|
494 | 494 | |
495 | - $post_status = 'draft'; |
|
495 | + $post_status = 'draft'; |
|
496 | 496 | |
497 | - } |
|
497 | + } |
|
498 | 498 | |
499 | 499 | |
500 | - // compare |
|
501 | - if( $rule['operator'] == "==") { |
|
500 | + // compare |
|
501 | + if( $rule['operator'] == "==") { |
|
502 | 502 | |
503 | - $match = ( $post_status === $rule['value'] ); |
|
503 | + $match = ( $post_status === $rule['value'] ); |
|
504 | 504 | |
505 | - } elseif( $rule['operator'] == "!=") { |
|
505 | + } elseif( $rule['operator'] == "!=") { |
|
506 | 506 | |
507 | - $match = ( $post_status !== $rule['value'] ); |
|
507 | + $match = ( $post_status !== $rule['value'] ); |
|
508 | 508 | |
509 | - } |
|
509 | + } |
|
510 | 510 | |
511 | 511 | |
512 | - // return |
|
513 | - return $match; |
|
512 | + // return |
|
513 | + return $match; |
|
514 | 514 | |
515 | - } |
|
515 | + } |
|
516 | 516 | |
517 | 517 | |
518 | 518 | /* |
@@ -544,115 +544,115 @@ discard block |
||
544 | 544 | |
545 | 545 | |
546 | 546 | // compare |
547 | - if( $rule['value'] == 'front_page') { |
|
547 | + if( $rule['value'] == 'front_page') { |
|
548 | 548 | |
549 | - // vars |
|
550 | - $front_page = (int) get_option('page_on_front'); |
|
549 | + // vars |
|
550 | + $front_page = (int) get_option('page_on_front'); |
|
551 | 551 | |
552 | 552 | |
553 | - // compare |
|
554 | - if( $rule['operator'] == "==" ) { |
|
553 | + // compare |
|
554 | + if( $rule['operator'] == "==" ) { |
|
555 | 555 | |
556 | - $match = ( $front_page == $post->ID ); |
|
556 | + $match = ( $front_page == $post->ID ); |
|
557 | 557 | |
558 | - } elseif( $rule['operator'] == "!=" ) { |
|
558 | + } elseif( $rule['operator'] == "!=" ) { |
|
559 | 559 | |
560 | - $match = ( $front_page != $post->ID ); |
|
560 | + $match = ( $front_page != $post->ID ); |
|
561 | 561 | |
562 | - } |
|
562 | + } |
|
563 | 563 | |
564 | - } elseif( $rule['value'] == 'posts_page') { |
|
564 | + } elseif( $rule['value'] == 'posts_page') { |
|
565 | 565 | |
566 | - // vars |
|
567 | - $posts_page = (int) get_option('page_for_posts'); |
|
566 | + // vars |
|
567 | + $posts_page = (int) get_option('page_for_posts'); |
|
568 | 568 | |
569 | 569 | |
570 | - // compare |
|
571 | - if( $rule['operator'] == "==" ) { |
|
570 | + // compare |
|
571 | + if( $rule['operator'] == "==" ) { |
|
572 | 572 | |
573 | - $match = ( $posts_page == $post->ID ); |
|
573 | + $match = ( $posts_page == $post->ID ); |
|
574 | 574 | |
575 | - } elseif( $rule['operator'] == "!=" ) { |
|
575 | + } elseif( $rule['operator'] == "!=" ) { |
|
576 | 576 | |
577 | - $match = ( $posts_page != $post->ID ); |
|
577 | + $match = ( $posts_page != $post->ID ); |
|
578 | 578 | |
579 | - } |
|
579 | + } |
|
580 | 580 | |
581 | - } elseif( $rule['value'] == 'top_level') { |
|
581 | + } elseif( $rule['value'] == 'top_level') { |
|
582 | 582 | |
583 | - // vars |
|
584 | - $post_parent = $post->post_parent; |
|
583 | + // vars |
|
584 | + $post_parent = $post->post_parent; |
|
585 | 585 | |
586 | 586 | |
587 | - // override |
|
588 | - if( $options['page_parent'] ) { |
|
587 | + // override |
|
588 | + if( $options['page_parent'] ) { |
|
589 | 589 | |
590 | - $post_parent = $options['page_parent']; |
|
590 | + $post_parent = $options['page_parent']; |
|
591 | 591 | |
592 | - } |
|
592 | + } |
|
593 | 593 | |
594 | 594 | |
595 | - // compare |
|
596 | - if( $rule['operator'] == "==" ) { |
|
595 | + // compare |
|
596 | + if( $rule['operator'] == "==" ) { |
|
597 | 597 | |
598 | - $match = ( $post_parent == 0 ); |
|
598 | + $match = ( $post_parent == 0 ); |
|
599 | 599 | |
600 | - } elseif( $rule['operator'] == "!=" ) { |
|
600 | + } elseif( $rule['operator'] == "!=" ) { |
|
601 | 601 | |
602 | - $match = ( $post_parent != 0 ); |
|
602 | + $match = ( $post_parent != 0 ); |
|
603 | 603 | |
604 | - } |
|
604 | + } |
|
605 | 605 | |
606 | - } elseif( $rule['value'] == 'parent' ) { |
|
606 | + } elseif( $rule['value'] == 'parent' ) { |
|
607 | 607 | |
608 | - // get children |
|
609 | - $children = get_pages(array( |
|
610 | - 'post_type' => $post->post_type, |
|
611 | - 'child_of' => $post->ID, |
|
612 | - )); |
|
608 | + // get children |
|
609 | + $children = get_pages(array( |
|
610 | + 'post_type' => $post->post_type, |
|
611 | + 'child_of' => $post->ID, |
|
612 | + )); |
|
613 | 613 | |
614 | 614 | |
615 | - // compare |
|
616 | - if( $rule['operator'] == "==" ) { |
|
615 | + // compare |
|
616 | + if( $rule['operator'] == "==" ) { |
|
617 | 617 | |
618 | - $match = ( count($children) > 0 ); |
|
618 | + $match = ( count($children) > 0 ); |
|
619 | 619 | |
620 | - } elseif( $rule['operator'] == "!=" ) { |
|
620 | + } elseif( $rule['operator'] == "!=" ) { |
|
621 | 621 | |
622 | - $match = ( count($children) == 0 ); |
|
622 | + $match = ( count($children) == 0 ); |
|
623 | 623 | |
624 | - } |
|
624 | + } |
|
625 | 625 | |
626 | - } elseif( $rule['value'] == 'child') { |
|
626 | + } elseif( $rule['value'] == 'child') { |
|
627 | 627 | |
628 | - // vars |
|
629 | - $post_parent = $post->post_parent; |
|
628 | + // vars |
|
629 | + $post_parent = $post->post_parent; |
|
630 | 630 | |
631 | 631 | |
632 | - // override |
|
633 | - if( $options['page_parent'] ) { |
|
632 | + // override |
|
633 | + if( $options['page_parent'] ) { |
|
634 | 634 | |
635 | - $post_parent = $options['page_parent']; |
|
635 | + $post_parent = $options['page_parent']; |
|
636 | 636 | |
637 | - } |
|
637 | + } |
|
638 | 638 | |
639 | 639 | |
640 | - // compare |
|
641 | - if( $rule['operator'] == "==" ) { |
|
640 | + // compare |
|
641 | + if( $rule['operator'] == "==" ) { |
|
642 | 642 | |
643 | - $match = ( $post_parent != 0 ); |
|
643 | + $match = ( $post_parent != 0 ); |
|
644 | 644 | |
645 | - } elseif( $rule['operator'] == "!=" ) { |
|
645 | + } elseif( $rule['operator'] == "!=" ) { |
|
646 | 646 | |
647 | - $match = ( $post_parent == 0 ); |
|
647 | + $match = ( $post_parent == 0 ); |
|
648 | 648 | |
649 | - } |
|
649 | + } |
|
650 | 650 | |
651 | - } |
|
651 | + } |
|
652 | 652 | |
653 | 653 | |
654 | - // return |
|
655 | - return $match; |
|
654 | + // return |
|
655 | + return $match; |
|
656 | 656 | |
657 | 657 | } |
658 | 658 | |
@@ -687,27 +687,27 @@ discard block |
||
687 | 687 | |
688 | 688 | // post parent |
689 | 689 | $post_parent = $post->post_parent; |
690 | - if( $options['page_parent'] ) { |
|
690 | + if( $options['page_parent'] ) { |
|
691 | 691 | |
692 | - $post_parent = $options['page_parent']; |
|
692 | + $post_parent = $options['page_parent']; |
|
693 | 693 | |
694 | - } |
|
694 | + } |
|
695 | 695 | |
696 | 696 | |
697 | - // compare |
|
698 | - if( $rule['operator'] == "==" ) { |
|
697 | + // compare |
|
698 | + if( $rule['operator'] == "==" ) { |
|
699 | 699 | |
700 | - $match = ( $post_parent == $rule['value'] ); |
|
700 | + $match = ( $post_parent == $rule['value'] ); |
|
701 | 701 | |
702 | - } elseif( $rule['operator'] == "!=" ) { |
|
702 | + } elseif( $rule['operator'] == "!=" ) { |
|
703 | 703 | |
704 | - $match = ( $post_parent != $rule['value'] ); |
|
704 | + $match = ( $post_parent != $rule['value'] ); |
|
705 | 705 | |
706 | - } |
|
706 | + } |
|
707 | 707 | |
708 | 708 | |
709 | - // return |
|
710 | - return $match; |
|
709 | + // return |
|
710 | + return $match; |
|
711 | 711 | |
712 | 712 | } |
713 | 713 | |
@@ -760,24 +760,24 @@ discard block |
||
760 | 760 | |
761 | 761 | |
762 | 762 | // compare |
763 | - if( $rule['operator'] == "==" ) { |
|
763 | + if( $rule['operator'] == "==" ) { |
|
764 | 764 | |
765 | - $match = ( $page_template === $rule['value'] ); |
|
765 | + $match = ( $page_template === $rule['value'] ); |
|
766 | 766 | |
767 | - } elseif( $rule['operator'] == "!=" ) { |
|
767 | + } elseif( $rule['operator'] == "!=" ) { |
|
768 | 768 | |
769 | - $match = ( $page_template !== $rule['value'] ); |
|
769 | + $match = ( $page_template !== $rule['value'] ); |
|
770 | 770 | |
771 | - } |
|
771 | + } |
|
772 | 772 | |
773 | 773 | |
774 | - // return |
|
775 | - return $match; |
|
774 | + // return |
|
775 | + return $match; |
|
776 | 776 | |
777 | 777 | } |
778 | 778 | |
779 | 779 | |
780 | - /* |
|
780 | + /* |
|
781 | 781 | * rule_match_user_form |
782 | 782 | * |
783 | 783 | * This function will match a location rule and return true or false |
@@ -791,7 +791,7 @@ discard block |
||
791 | 791 | * @return $options (array) |
792 | 792 | */ |
793 | 793 | |
794 | - function rule_match_user_form( $match, $rule, $options ) { |
|
794 | + function rule_match_user_form( $match, $rule, $options ) { |
|
795 | 795 | |
796 | 796 | // vars |
797 | 797 | $user_form = $options['user_form']; |
@@ -810,39 +810,39 @@ discard block |
||
810 | 810 | |
811 | 811 | if( $rule['operator'] == "==" ) { |
812 | 812 | |
813 | - $match = ( $user_form == $rule['value'] ); |
|
813 | + $match = ( $user_form == $rule['value'] ); |
|
814 | 814 | |
815 | 815 | |
816 | - // override for "all" |
|
817 | - if( $rule['value'] === 'all' ) { |
|
816 | + // override for "all" |
|
817 | + if( $rule['value'] === 'all' ) { |
|
818 | 818 | |
819 | 819 | $match = true; |
820 | 820 | |
821 | 821 | } |
822 | 822 | |
823 | - } elseif( $rule['operator'] == "!=" ) { |
|
823 | + } elseif( $rule['operator'] == "!=" ) { |
|
824 | 824 | |
825 | - $match = ( $user_form != $rule['value'] ); |
|
825 | + $match = ( $user_form != $rule['value'] ); |
|
826 | 826 | |
827 | 827 | |
828 | - // override for "all" |
|
829 | - if( $rule['value'] === 'all' ) { |
|
828 | + // override for "all" |
|
829 | + if( $rule['value'] === 'all' ) { |
|
830 | 830 | |
831 | 831 | $match = false; |
832 | 832 | |
833 | 833 | } |
834 | 834 | |
835 | - } |
|
835 | + } |
|
836 | 836 | |
837 | 837 | } |
838 | 838 | |
839 | 839 | |
840 | - // return |
|
841 | - return $match; |
|
842 | - } |
|
840 | + // return |
|
841 | + return $match; |
|
842 | + } |
|
843 | 843 | |
844 | 844 | |
845 | - /* |
|
845 | + /* |
|
846 | 846 | * rule_match_user_role |
847 | 847 | * |
848 | 848 | * This function will match a location rule and return true or false |
@@ -868,97 +868,97 @@ discard block |
||
868 | 868 | |
869 | 869 | if( $rule['operator'] == "==" ) { |
870 | 870 | |
871 | - if( $user_role === $rule['value'] ) { |
|
871 | + if( $user_role === $rule['value'] ) { |
|
872 | 872 | |
873 | - $match = true; |
|
873 | + $match = true; |
|
874 | 874 | |
875 | - } |
|
875 | + } |
|
876 | 876 | |
877 | 877 | |
878 | - // override for "all" |
|
879 | - if( $rule['value'] === 'all' ) { |
|
878 | + // override for "all" |
|
879 | + if( $rule['value'] === 'all' ) { |
|
880 | 880 | |
881 | 881 | $match = true; |
882 | 882 | |
883 | 883 | } |
884 | 884 | |
885 | - } elseif( $rule['operator'] == "!=" ) { |
|
885 | + } elseif( $rule['operator'] == "!=" ) { |
|
886 | 886 | |
887 | - if( $user_role !== $rule['value'] ) { |
|
887 | + if( $user_role !== $rule['value'] ) { |
|
888 | 888 | |
889 | - $match = true; |
|
889 | + $match = true; |
|
890 | 890 | |
891 | - } |
|
891 | + } |
|
892 | 892 | |
893 | 893 | |
894 | - // override for "all" |
|
895 | - if( $rule['value'] === 'all' ) { |
|
894 | + // override for "all" |
|
895 | + if( $rule['value'] === 'all' ) { |
|
896 | 896 | |
897 | 897 | $match = false; |
898 | 898 | |
899 | 899 | } |
900 | 900 | |
901 | - } |
|
901 | + } |
|
902 | 902 | |
903 | 903 | } elseif( $user_id ) { |
904 | 904 | |
905 | 905 | if( $rule['operator'] == "==" ) { |
906 | 906 | |
907 | - if( $user_id === 'new' ) { |
|
907 | + if( $user_id === 'new' ) { |
|
908 | 908 | |
909 | - // case: add user |
|
910 | - $match = ( $rule['value'] == get_option('default_role') ); |
|
909 | + // case: add user |
|
910 | + $match = ( $rule['value'] == get_option('default_role') ); |
|
911 | 911 | |
912 | - } else { |
|
912 | + } else { |
|
913 | 913 | |
914 | - // case: edit user |
|
915 | - $match = ( user_can($user_id, $rule['value']) ); |
|
914 | + // case: edit user |
|
915 | + $match = ( user_can($user_id, $rule['value']) ); |
|
916 | 916 | |
917 | - } |
|
917 | + } |
|
918 | 918 | |
919 | 919 | |
920 | - // override for "all" |
|
921 | - if( $rule['value'] === 'all' ) { |
|
920 | + // override for "all" |
|
921 | + if( $rule['value'] === 'all' ) { |
|
922 | 922 | |
923 | 923 | $match = true; |
924 | 924 | |
925 | 925 | } |
926 | 926 | |
927 | - } elseif( $rule['operator'] == "!=" ) { |
|
927 | + } elseif( $rule['operator'] == "!=" ) { |
|
928 | 928 | |
929 | - if( $user_id === 'new' ) { |
|
929 | + if( $user_id === 'new' ) { |
|
930 | 930 | |
931 | - // case: add user |
|
932 | - $match = ( $rule['value'] != get_option('default_role') ); |
|
931 | + // case: add user |
|
932 | + $match = ( $rule['value'] != get_option('default_role') ); |
|
933 | 933 | |
934 | - } else { |
|
934 | + } else { |
|
935 | 935 | |
936 | - // case: edit user |
|
937 | - $match = ( !user_can($user_id, $rule['value']) ); |
|
936 | + // case: edit user |
|
937 | + $match = ( !user_can($user_id, $rule['value']) ); |
|
938 | 938 | |
939 | - } |
|
939 | + } |
|
940 | 940 | |
941 | 941 | |
942 | - // override for "all" |
|
943 | - if( $rule['value'] === 'all' ) { |
|
942 | + // override for "all" |
|
943 | + if( $rule['value'] === 'all' ) { |
|
944 | 944 | |
945 | 945 | $match = false; |
946 | 946 | |
947 | 947 | } |
948 | 948 | |
949 | - } |
|
949 | + } |
|
950 | 950 | |
951 | 951 | } |
952 | 952 | |
953 | 953 | |
954 | - // return |
|
955 | - return $match; |
|
954 | + // return |
|
955 | + return $match; |
|
956 | 956 | |
957 | - } |
|
957 | + } |
|
958 | 958 | |
959 | 959 | |
960 | 960 | |
961 | - /* |
|
961 | + /* |
|
962 | 962 | * rule_match_taxonomy |
963 | 963 | * |
964 | 964 | * This function will match a location rule and return true or false |
@@ -989,36 +989,36 @@ discard block |
||
989 | 989 | // compare |
990 | 990 | if( $rule['operator'] == "==" ) { |
991 | 991 | |
992 | - $match = ( $taxonomy == $rule['value'] ); |
|
992 | + $match = ( $taxonomy == $rule['value'] ); |
|
993 | 993 | |
994 | - // override for "all" |
|
995 | - if( $rule['value'] == "all" ) { |
|
994 | + // override for "all" |
|
995 | + if( $rule['value'] == "all" ) { |
|
996 | 996 | |
997 | 997 | $match = true; |
998 | 998 | |
999 | 999 | } |
1000 | 1000 | |
1001 | - } elseif( $rule['operator'] == "!=" ) { |
|
1001 | + } elseif( $rule['operator'] == "!=" ) { |
|
1002 | 1002 | |
1003 | - $match = ( $taxonomy != $rule['value'] ); |
|
1003 | + $match = ( $taxonomy != $rule['value'] ); |
|
1004 | 1004 | |
1005 | - // override for "all" |
|
1006 | - if( $rule['value'] == "all" ) { |
|
1005 | + // override for "all" |
|
1006 | + if( $rule['value'] == "all" ) { |
|
1007 | 1007 | |
1008 | 1008 | $match = false; |
1009 | 1009 | |
1010 | 1010 | } |
1011 | 1011 | |
1012 | - } |
|
1012 | + } |
|
1013 | 1013 | |
1014 | 1014 | |
1015 | - // return |
|
1016 | - return $match; |
|
1015 | + // return |
|
1016 | + return $match; |
|
1017 | 1017 | |
1018 | - } |
|
1018 | + } |
|
1019 | 1019 | |
1020 | 1020 | |
1021 | - /* |
|
1021 | + /* |
|
1022 | 1022 | * rule_match_attachment |
1023 | 1023 | * |
1024 | 1024 | * This function will match a location rule and return true or false |
@@ -1049,37 +1049,37 @@ discard block |
||
1049 | 1049 | // compare |
1050 | 1050 | if( $rule['operator'] == "==" ) { |
1051 | 1051 | |
1052 | - $match = ( $attachment == $rule['value'] ); |
|
1052 | + $match = ( $attachment == $rule['value'] ); |
|
1053 | 1053 | |
1054 | - // override for "all" |
|
1055 | - if( $rule['value'] == "all" ) { |
|
1054 | + // override for "all" |
|
1055 | + if( $rule['value'] == "all" ) { |
|
1056 | 1056 | |
1057 | 1057 | $match = true; |
1058 | 1058 | |
1059 | 1059 | } |
1060 | 1060 | |
1061 | - } elseif( $rule['operator'] == "!=" ) { |
|
1061 | + } elseif( $rule['operator'] == "!=" ) { |
|
1062 | 1062 | |
1063 | - $match = ( $attachment != $rule['value'] ); |
|
1063 | + $match = ( $attachment != $rule['value'] ); |
|
1064 | 1064 | |
1065 | - // override for "all" |
|
1066 | - if( $rule['value'] == "all" ) { |
|
1065 | + // override for "all" |
|
1066 | + if( $rule['value'] == "all" ) { |
|
1067 | 1067 | |
1068 | 1068 | $match = false; |
1069 | 1069 | |
1070 | 1070 | } |
1071 | 1071 | |
1072 | - } |
|
1072 | + } |
|
1073 | 1073 | |
1074 | 1074 | |
1075 | - // return |
|
1076 | - return $match; |
|
1075 | + // return |
|
1076 | + return $match; |
|
1077 | 1077 | |
1078 | - } |
|
1078 | + } |
|
1079 | 1079 | |
1080 | 1080 | |
1081 | 1081 | |
1082 | - /* |
|
1082 | + /* |
|
1083 | 1083 | * rule_match_comment |
1084 | 1084 | * |
1085 | 1085 | * This function will match a location rule and return true or false |
@@ -1110,36 +1110,36 @@ discard block |
||
1110 | 1110 | // compare |
1111 | 1111 | if( $rule['operator'] == "==" ) { |
1112 | 1112 | |
1113 | - $match = ( $comment == $rule['value'] ); |
|
1113 | + $match = ( $comment == $rule['value'] ); |
|
1114 | 1114 | |
1115 | - // override for "all" |
|
1116 | - if( $rule['value'] == "all" ) { |
|
1115 | + // override for "all" |
|
1116 | + if( $rule['value'] == "all" ) { |
|
1117 | 1117 | |
1118 | 1118 | $match = true; |
1119 | 1119 | |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - } elseif( $rule['operator'] == "!=" ) { |
|
1122 | + } elseif( $rule['operator'] == "!=" ) { |
|
1123 | 1123 | |
1124 | - $match = ( $comment != $rule['value'] ); |
|
1124 | + $match = ( $comment != $rule['value'] ); |
|
1125 | 1125 | |
1126 | - // override for "all" |
|
1127 | - if( $rule['value'] == "all" ) { |
|
1126 | + // override for "all" |
|
1127 | + if( $rule['value'] == "all" ) { |
|
1128 | 1128 | |
1129 | 1129 | $match = false; |
1130 | 1130 | |
1131 | 1131 | } |
1132 | 1132 | |
1133 | - } |
|
1133 | + } |
|
1134 | 1134 | |
1135 | 1135 | |
1136 | - // return |
|
1137 | - return $match; |
|
1136 | + // return |
|
1137 | + return $match; |
|
1138 | 1138 | |
1139 | - } |
|
1139 | + } |
|
1140 | 1140 | |
1141 | 1141 | |
1142 | - /* |
|
1142 | + /* |
|
1143 | 1143 | * rule_match_widget |
1144 | 1144 | * |
1145 | 1145 | * This function will match a location rule and return true or false |
@@ -1153,7 +1153,7 @@ discard block |
||
1153 | 1153 | * @return $options (array) |
1154 | 1154 | */ |
1155 | 1155 | |
1156 | - function rule_match_widget( $match, $rule, $options ) { |
|
1156 | + function rule_match_widget( $match, $rule, $options ) { |
|
1157 | 1157 | |
1158 | 1158 | // vars |
1159 | 1159 | $widget = $options['widget']; |
@@ -1170,32 +1170,32 @@ discard block |
||
1170 | 1170 | // compare |
1171 | 1171 | if( $rule['operator'] == "==" ) { |
1172 | 1172 | |
1173 | - $match = ( $widget == $rule['value'] ); |
|
1173 | + $match = ( $widget == $rule['value'] ); |
|
1174 | 1174 | |
1175 | - // override for "all" |
|
1176 | - if( $rule['value'] == "all" ) { |
|
1175 | + // override for "all" |
|
1176 | + if( $rule['value'] == "all" ) { |
|
1177 | 1177 | |
1178 | 1178 | $match = true; |
1179 | 1179 | |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - } elseif( $rule['operator'] == "!=" ) { |
|
1182 | + } elseif( $rule['operator'] == "!=" ) { |
|
1183 | 1183 | |
1184 | - $match = ( $widget != $rule['value'] ); |
|
1184 | + $match = ( $widget != $rule['value'] ); |
|
1185 | 1185 | |
1186 | - // override for "all" |
|
1187 | - if( $rule['value'] == "all" ) { |
|
1186 | + // override for "all" |
|
1187 | + if( $rule['value'] == "all" ) { |
|
1188 | 1188 | |
1189 | 1189 | $match = false; |
1190 | 1190 | |
1191 | 1191 | } |
1192 | 1192 | |
1193 | - } |
|
1193 | + } |
|
1194 | 1194 | |
1195 | 1195 | |
1196 | - // return |
|
1197 | - return $match; |
|
1198 | - } |
|
1196 | + // return |
|
1197 | + return $match; |
|
1198 | + } |
|
1199 | 1199 | |
1200 | 1200 | } |
1201 | 1201 |
@@ -18,33 +18,33 @@ discard block |
||
18 | 18 | function __construct() { |
19 | 19 | |
20 | 20 | // Post |
21 | - add_filter( 'acf/location/rule_match/post_type', array($this, 'rule_match_post_type'), 10, 3 ); |
|
22 | - add_filter( 'acf/location/rule_match/post', array($this, 'rule_match_post'), 10, 3 ); |
|
23 | - add_filter( 'acf/location/rule_match/post_category', array($this, 'rule_match_post_taxonomy'), 10, 3 ); |
|
24 | - add_filter( 'acf/location/rule_match/post_format', array($this, 'rule_match_post_format'), 10, 3 ); |
|
25 | - add_filter( 'acf/location/rule_match/post_status', array($this, 'rule_match_post_status'), 10, 3 ); |
|
26 | - add_filter( 'acf/location/rule_match/post_taxonomy', array($this, 'rule_match_post_taxonomy'), 10, 3 ); |
|
21 | + add_filter('acf/location/rule_match/post_type', array($this, 'rule_match_post_type'), 10, 3); |
|
22 | + add_filter('acf/location/rule_match/post', array($this, 'rule_match_post'), 10, 3); |
|
23 | + add_filter('acf/location/rule_match/post_category', array($this, 'rule_match_post_taxonomy'), 10, 3); |
|
24 | + add_filter('acf/location/rule_match/post_format', array($this, 'rule_match_post_format'), 10, 3); |
|
25 | + add_filter('acf/location/rule_match/post_status', array($this, 'rule_match_post_status'), 10, 3); |
|
26 | + add_filter('acf/location/rule_match/post_taxonomy', array($this, 'rule_match_post_taxonomy'), 10, 3); |
|
27 | 27 | |
28 | 28 | |
29 | 29 | // Page |
30 | - add_filter( 'acf/location/rule_match/page', array($this, 'rule_match_post'), 10, 3 ); |
|
31 | - add_filter( 'acf/location/rule_match/page_type', array($this, 'rule_match_page_type'), 10, 3 ); |
|
32 | - add_filter( 'acf/location/rule_match/page_parent', array($this, 'rule_match_page_parent'), 10, 3 ); |
|
33 | - add_filter( 'acf/location/rule_match/page_template', array($this, 'rule_match_page_template'), 10, 3 ); |
|
30 | + add_filter('acf/location/rule_match/page', array($this, 'rule_match_post'), 10, 3); |
|
31 | + add_filter('acf/location/rule_match/page_type', array($this, 'rule_match_page_type'), 10, 3); |
|
32 | + add_filter('acf/location/rule_match/page_parent', array($this, 'rule_match_page_parent'), 10, 3); |
|
33 | + add_filter('acf/location/rule_match/page_template', array($this, 'rule_match_page_template'), 10, 3); |
|
34 | 34 | |
35 | 35 | |
36 | 36 | // User |
37 | - add_filter( 'acf/location/rule_match/current_user', array($this, 'rule_match_current_user'), 10, 3 ); |
|
38 | - add_filter( 'acf/location/rule_match/current_user_role', array($this, 'rule_match_current_user_role'), 10, 3 ); |
|
39 | - add_filter( 'acf/location/rule_match/user_form', array($this, 'rule_match_user_form'), 10, 3 ); |
|
40 | - add_filter( 'acf/location/rule_match/user_role', array($this, 'rule_match_user_role'), 10, 3 ); |
|
37 | + add_filter('acf/location/rule_match/current_user', array($this, 'rule_match_current_user'), 10, 3); |
|
38 | + add_filter('acf/location/rule_match/current_user_role', array($this, 'rule_match_current_user_role'), 10, 3); |
|
39 | + add_filter('acf/location/rule_match/user_form', array($this, 'rule_match_user_form'), 10, 3); |
|
40 | + add_filter('acf/location/rule_match/user_role', array($this, 'rule_match_user_role'), 10, 3); |
|
41 | 41 | |
42 | 42 | |
43 | 43 | // Form |
44 | - add_filter( 'acf/location/rule_match/taxonomy', array($this, 'rule_match_taxonomy'), 10, 3 ); |
|
45 | - add_filter( 'acf/location/rule_match/attachment', array($this, 'rule_match_attachment'), 10, 3 ); |
|
46 | - add_filter( 'acf/location/rule_match/comment', array($this, 'rule_match_comment'), 10, 3 ); |
|
47 | - add_filter( 'acf/location/rule_match/widget', array($this, 'rule_match_widget'), 10, 3 ); |
|
44 | + add_filter('acf/location/rule_match/taxonomy', array($this, 'rule_match_taxonomy'), 10, 3); |
|
45 | + add_filter('acf/location/rule_match/attachment', array($this, 'rule_match_attachment'), 10, 3); |
|
46 | + add_filter('acf/location/rule_match/comment', array($this, 'rule_match_comment'), 10, 3); |
|
47 | + add_filter('acf/location/rule_match/widget', array($this, 'rule_match_widget'), 10, 3); |
|
48 | 48 | |
49 | 49 | } |
50 | 50 | |
@@ -63,33 +63,33 @@ discard block |
||
63 | 63 | * @return $options (array) |
64 | 64 | */ |
65 | 65 | |
66 | - function rule_match_post_type( $match, $rule, $options ) { |
|
66 | + function rule_match_post_type($match, $rule, $options) { |
|
67 | 67 | |
68 | 68 | // vars |
69 | 69 | $post_type = $options['post_type']; |
70 | 70 | |
71 | 71 | |
72 | 72 | // find post type for current post |
73 | - if( !$post_type ) { |
|
73 | + if ( ! $post_type) { |
|
74 | 74 | |
75 | - if( !$options['post_id'] ) { |
|
75 | + if ( ! $options['post_id']) { |
|
76 | 76 | |
77 | 77 | return false; |
78 | 78 | |
79 | 79 | } |
80 | 80 | |
81 | - $post_type = get_post_type( $options['post_id'] ); |
|
81 | + $post_type = get_post_type($options['post_id']); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | |
85 | 85 | // compare |
86 | - if( $rule['operator'] == "==" ) { |
|
86 | + if ($rule['operator'] == "==") { |
|
87 | 87 | |
88 | - $match = ( $post_type === $rule['value'] ); |
|
88 | + $match = ($post_type === $rule['value']); |
|
89 | 89 | |
90 | - } elseif( $rule['operator'] == "!=" ) { |
|
90 | + } elseif ($rule['operator'] == "!=") { |
|
91 | 91 | |
92 | - $match = ( $post_type !== $rule['value'] ); |
|
92 | + $match = ($post_type !== $rule['value']); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | * @return $options (array) |
114 | 114 | */ |
115 | 115 | |
116 | - function rule_match_current_user( $match, $rule, $options ) { |
|
116 | + function rule_match_current_user($match, $rule, $options) { |
|
117 | 117 | |
118 | 118 | // logged in |
119 | - if( $rule['value'] == 'logged_in' ) { |
|
119 | + if ($rule['value'] == 'logged_in') { |
|
120 | 120 | |
121 | - if( $rule['operator'] == "==" ) { |
|
121 | + if ($rule['operator'] == "==") { |
|
122 | 122 | |
123 | 123 | $match = is_user_logged_in(); |
124 | 124 | |
125 | - } elseif( $rule['operator'] == "!=" ) { |
|
125 | + } elseif ($rule['operator'] == "!=") { |
|
126 | 126 | |
127 | - $match = !is_user_logged_in(); |
|
127 | + $match = ! is_user_logged_in(); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | |
135 | 135 | |
136 | 136 | // front end |
137 | - if( $rule['value'] == 'viewing_front' ) { |
|
137 | + if ($rule['value'] == 'viewing_front') { |
|
138 | 138 | |
139 | - if( $rule['operator'] == "==" ) { |
|
139 | + if ($rule['operator'] == "==") { |
|
140 | 140 | |
141 | - $match = !is_admin(); |
|
141 | + $match = ! is_admin(); |
|
142 | 142 | |
143 | - } elseif( $rule['operator'] == "!=" ) { |
|
143 | + } elseif ($rule['operator'] == "!=") { |
|
144 | 144 | |
145 | 145 | $match = is_admin(); |
146 | 146 | |
@@ -152,15 +152,15 @@ discard block |
||
152 | 152 | |
153 | 153 | |
154 | 154 | // back end |
155 | - if( $rule['value'] == 'viewing_back' ) { |
|
155 | + if ($rule['value'] == 'viewing_back') { |
|
156 | 156 | |
157 | - if( $rule['operator'] == "==" ) { |
|
157 | + if ($rule['operator'] == "==") { |
|
158 | 158 | |
159 | 159 | $match = is_admin(); |
160 | 160 | |
161 | - } elseif( $rule['operator'] == "!=" ) { |
|
161 | + } elseif ($rule['operator'] == "!=") { |
|
162 | 162 | |
163 | - $match = !is_admin(); |
|
163 | + $match = ! is_admin(); |
|
164 | 164 | |
165 | 165 | } |
166 | 166 | |
@@ -189,10 +189,10 @@ discard block |
||
189 | 189 | * @return $options (array) |
190 | 190 | */ |
191 | 191 | |
192 | - function rule_match_current_user_role( $match, $rule, $options ) { |
|
192 | + function rule_match_current_user_role($match, $rule, $options) { |
|
193 | 193 | |
194 | 194 | // bail early if not logged in |
195 | - if( !is_user_logged_in() ) { |
|
195 | + if ( ! is_user_logged_in()) { |
|
196 | 196 | |
197 | 197 | return false; |
198 | 198 | |
@@ -204,27 +204,27 @@ discard block |
||
204 | 204 | |
205 | 205 | |
206 | 206 | // compare |
207 | - if( $rule['operator'] == "==" ) { |
|
207 | + if ($rule['operator'] == "==") { |
|
208 | 208 | |
209 | - if( $rule['value'] == 'super_admin' ) { |
|
209 | + if ($rule['value'] == 'super_admin') { |
|
210 | 210 | |
211 | - $match = is_super_admin( $user->ID ); |
|
211 | + $match = is_super_admin($user->ID); |
|
212 | 212 | |
213 | 213 | } else { |
214 | 214 | |
215 | - $match = in_array( $rule['value'], $user->roles ); |
|
215 | + $match = in_array($rule['value'], $user->roles); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
219 | - } elseif( $rule['operator'] == "!=" ) { |
|
219 | + } elseif ($rule['operator'] == "!=") { |
|
220 | 220 | |
221 | - if( $rule['value'] == 'super_admin' ) { |
|
221 | + if ($rule['value'] == 'super_admin') { |
|
222 | 222 | |
223 | - $match = !is_super_admin( $user->ID ); |
|
223 | + $match = ! is_super_admin($user->ID); |
|
224 | 224 | |
225 | 225 | } else { |
226 | 226 | |
227 | - $match = ( ! in_array( $rule['value'], $user->roles ) ); |
|
227 | + $match = ( ! in_array($rule['value'], $user->roles)); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -251,14 +251,14 @@ discard block |
||
251 | 251 | * @return $options (array) |
252 | 252 | */ |
253 | 253 | |
254 | - function rule_match_post( $match, $rule, $options ) { |
|
254 | + function rule_match_post($match, $rule, $options) { |
|
255 | 255 | |
256 | 256 | // vars |
257 | 257 | $post_id = $options['post_id']; |
258 | 258 | |
259 | 259 | |
260 | 260 | // validation |
261 | - if( !$post_id ) { |
|
261 | + if ( ! $post_id) { |
|
262 | 262 | |
263 | 263 | return false; |
264 | 264 | |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | |
275 | 275 | |
276 | 276 | // compare |
277 | - if( $rule['operator'] == "==") { |
|
277 | + if ($rule['operator'] == "==") { |
|
278 | 278 | |
279 | - $match = ( $options['post_id'] == $rule['value'] ); |
|
279 | + $match = ($options['post_id'] == $rule['value']); |
|
280 | 280 | |
281 | - } elseif( $rule['operator'] == "!=") { |
|
281 | + } elseif ($rule['operator'] == "!=") { |
|
282 | 282 | |
283 | - $match = ( $options['post_id'] != $rule['value'] ); |
|
283 | + $match = ($options['post_id'] != $rule['value']); |
|
284 | 284 | |
285 | 285 | } |
286 | 286 | |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | * @return $options (array) |
306 | 306 | */ |
307 | 307 | |
308 | - function rule_match_post_taxonomy( $match, $rule, $options ) { |
|
308 | + function rule_match_post_taxonomy($match, $rule, $options) { |
|
309 | 309 | |
310 | 310 | // validate |
311 | - if( !$options['post_id'] ) { |
|
311 | + if ( ! $options['post_id']) { |
|
312 | 312 | |
313 | 313 | return false; |
314 | 314 | |
@@ -321,20 +321,20 @@ discard block |
||
321 | 321 | |
322 | 322 | // get term data |
323 | 323 | // - selected term may have a numeric slug '123' (user reported on forum), so always check slug first |
324 | - $data = acf_decode_taxonomy_term( $rule['value'] ); |
|
325 | - $term = get_term_by( 'slug', $data['term'], $data['taxonomy'] ); |
|
324 | + $data = acf_decode_taxonomy_term($rule['value']); |
|
325 | + $term = get_term_by('slug', $data['term'], $data['taxonomy']); |
|
326 | 326 | |
327 | 327 | |
328 | 328 | // attempt get term via ID (ACF4 uses ID) |
329 | - if( !$term && is_numeric($data['term']) ) { |
|
329 | + if ( ! $term && is_numeric($data['term'])) { |
|
330 | 330 | |
331 | - $term = get_term_by( 'id', $data['term'], $data['taxonomy'] ); |
|
331 | + $term = get_term_by('id', $data['term'], $data['taxonomy']); |
|
332 | 332 | |
333 | 333 | } |
334 | 334 | |
335 | 335 | |
336 | 336 | // bail early if no term |
337 | - if( !$term ) { |
|
337 | + if ( ! $term) { |
|
338 | 338 | |
339 | 339 | return false; |
340 | 340 | |
@@ -342,28 +342,28 @@ discard block |
||
342 | 342 | |
343 | 343 | |
344 | 344 | // post type |
345 | - if( !$options['post_type'] ) { |
|
345 | + if ( ! $options['post_type']) { |
|
346 | 346 | |
347 | - $options['post_type'] = get_post_type( $options['post_id'] ); |
|
347 | + $options['post_type'] = get_post_type($options['post_id']); |
|
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | 351 | |
352 | 352 | // get terms |
353 | 353 | // - allow an empty array (sent via JS) to avoid loading the real post's terms |
354 | - if( !is_array($terms) ) { |
|
354 | + if ( ! is_array($terms)) { |
|
355 | 355 | |
356 | - $terms = wp_get_post_terms( $options['post_id'], $term->taxonomy, array('fields' => 'ids') ); |
|
356 | + $terms = wp_get_post_terms($options['post_id'], $term->taxonomy, array('fields' => 'ids')); |
|
357 | 357 | |
358 | 358 | } |
359 | 359 | |
360 | 360 | |
361 | 361 | // If no terms, this is a new post and should be treated as if it has the "Uncategorized" (1) category ticked |
362 | - if( empty($terms) ) { |
|
362 | + if (empty($terms)) { |
|
363 | 363 | |
364 | - if( is_object_in_taxonomy($options['post_type'], 'category') ) { |
|
364 | + if (is_object_in_taxonomy($options['post_type'], 'category')) { |
|
365 | 365 | |
366 | - $terms = array( 1 ); |
|
366 | + $terms = array(1); |
|
367 | 367 | |
368 | 368 | } |
369 | 369 | |
@@ -371,13 +371,13 @@ discard block |
||
371 | 371 | |
372 | 372 | |
373 | 373 | // compare |
374 | - if( $rule['operator'] == "==") { |
|
374 | + if ($rule['operator'] == "==") { |
|
375 | 375 | |
376 | 376 | $match = in_array($term->term_id, $terms); |
377 | 377 | |
378 | - } elseif( $rule['operator'] == "!=") { |
|
378 | + } elseif ($rule['operator'] == "!=") { |
|
379 | 379 | |
380 | - $match = !in_array($term->term_id, $terms); |
|
380 | + $match = ! in_array($term->term_id, $terms); |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | |
@@ -402,17 +402,17 @@ discard block |
||
402 | 402 | * @return $options (array) |
403 | 403 | */ |
404 | 404 | |
405 | - function rule_match_post_format( $match, $rule, $options ) { |
|
405 | + function rule_match_post_format($match, $rule, $options) { |
|
406 | 406 | |
407 | 407 | // vars |
408 | 408 | $post_format = $options['post_format']; |
409 | 409 | |
410 | 410 | |
411 | 411 | // new post format? |
412 | - if( !$post_format ) { |
|
412 | + if ( ! $post_format) { |
|
413 | 413 | |
414 | 414 | // validate |
415 | - if( !$options['post_id'] ) { |
|
415 | + if ( ! $options['post_id']) { |
|
416 | 416 | |
417 | 417 | return false; |
418 | 418 | |
@@ -420,19 +420,19 @@ discard block |
||
420 | 420 | |
421 | 421 | |
422 | 422 | // post type |
423 | - if( !$options['post_type'] ) { |
|
423 | + if ( ! $options['post_type']) { |
|
424 | 424 | |
425 | - $options['post_type'] = get_post_type( $options['post_id'] ); |
|
425 | + $options['post_type'] = get_post_type($options['post_id']); |
|
426 | 426 | |
427 | 427 | } |
428 | 428 | |
429 | 429 | |
430 | 430 | // does post_type support 'post-format' |
431 | - if( post_type_supports( $options['post_type'], 'post-formats' ) ) { |
|
431 | + if (post_type_supports($options['post_type'], 'post-formats')) { |
|
432 | 432 | |
433 | - $post_format = get_post_format( $options['post_id'] ); |
|
433 | + $post_format = get_post_format($options['post_id']); |
|
434 | 434 | |
435 | - if( $post_format === false ) { |
|
435 | + if ($post_format === false) { |
|
436 | 436 | |
437 | 437 | $post_format = 'standard'; |
438 | 438 | |
@@ -444,13 +444,13 @@ discard block |
||
444 | 444 | |
445 | 445 | |
446 | 446 | // compare |
447 | - if( $rule['operator'] == "==") { |
|
447 | + if ($rule['operator'] == "==") { |
|
448 | 448 | |
449 | - $match = ( $post_format === $rule['value'] ); |
|
449 | + $match = ($post_format === $rule['value']); |
|
450 | 450 | |
451 | - } elseif( $rule['operator'] == "!=") { |
|
451 | + } elseif ($rule['operator'] == "!=") { |
|
452 | 452 | |
453 | - $match = ( $post_format !== $rule['value'] ); |
|
453 | + $match = ($post_format !== $rule['value']); |
|
454 | 454 | |
455 | 455 | } |
456 | 456 | |
@@ -475,10 +475,10 @@ discard block |
||
475 | 475 | * @return $options (array) |
476 | 476 | */ |
477 | 477 | |
478 | - function rule_match_post_status( $match, $rule, $options ) { |
|
478 | + function rule_match_post_status($match, $rule, $options) { |
|
479 | 479 | |
480 | 480 | // validate |
481 | - if( !$options['post_id'] ) { |
|
481 | + if ( ! $options['post_id']) { |
|
482 | 482 | |
483 | 483 | return false; |
484 | 484 | |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | |
487 | 487 | |
488 | 488 | // vars |
489 | - $post_status = get_post_status( $options['post_id'] ); |
|
489 | + $post_status = get_post_status($options['post_id']); |
|
490 | 490 | |
491 | 491 | |
492 | 492 | // auto-draft = draft |
493 | - if( $post_status == 'auto-draft' ) { |
|
493 | + if ($post_status == 'auto-draft') { |
|
494 | 494 | |
495 | 495 | $post_status = 'draft'; |
496 | 496 | |
@@ -498,13 +498,13 @@ discard block |
||
498 | 498 | |
499 | 499 | |
500 | 500 | // compare |
501 | - if( $rule['operator'] == "==") { |
|
501 | + if ($rule['operator'] == "==") { |
|
502 | 502 | |
503 | - $match = ( $post_status === $rule['value'] ); |
|
503 | + $match = ($post_status === $rule['value']); |
|
504 | 504 | |
505 | - } elseif( $rule['operator'] == "!=") { |
|
505 | + } elseif ($rule['operator'] == "!=") { |
|
506 | 506 | |
507 | - $match = ( $post_status !== $rule['value'] ); |
|
507 | + $match = ($post_status !== $rule['value']); |
|
508 | 508 | |
509 | 509 | } |
510 | 510 | |
@@ -529,10 +529,10 @@ discard block |
||
529 | 529 | * @return $options (array) |
530 | 530 | */ |
531 | 531 | |
532 | - function rule_match_page_type( $match, $rule, $options ) { |
|
532 | + function rule_match_page_type($match, $rule, $options) { |
|
533 | 533 | |
534 | 534 | // validation |
535 | - if( !$options['post_id'] ) { |
|
535 | + if ( ! $options['post_id']) { |
|
536 | 536 | |
537 | 537 | return false; |
538 | 538 | |
@@ -540,52 +540,52 @@ discard block |
||
540 | 540 | |
541 | 541 | |
542 | 542 | // get post |
543 | - $post = get_post( $options['post_id'] ); |
|
543 | + $post = get_post($options['post_id']); |
|
544 | 544 | |
545 | 545 | |
546 | 546 | // compare |
547 | - if( $rule['value'] == 'front_page') { |
|
547 | + if ($rule['value'] == 'front_page') { |
|
548 | 548 | |
549 | 549 | // vars |
550 | 550 | $front_page = (int) get_option('page_on_front'); |
551 | 551 | |
552 | 552 | |
553 | 553 | // compare |
554 | - if( $rule['operator'] == "==" ) { |
|
554 | + if ($rule['operator'] == "==") { |
|
555 | 555 | |
556 | - $match = ( $front_page == $post->ID ); |
|
556 | + $match = ($front_page == $post->ID); |
|
557 | 557 | |
558 | - } elseif( $rule['operator'] == "!=" ) { |
|
558 | + } elseif ($rule['operator'] == "!=") { |
|
559 | 559 | |
560 | - $match = ( $front_page != $post->ID ); |
|
560 | + $match = ($front_page != $post->ID); |
|
561 | 561 | |
562 | 562 | } |
563 | 563 | |
564 | - } elseif( $rule['value'] == 'posts_page') { |
|
564 | + } elseif ($rule['value'] == 'posts_page') { |
|
565 | 565 | |
566 | 566 | // vars |
567 | 567 | $posts_page = (int) get_option('page_for_posts'); |
568 | 568 | |
569 | 569 | |
570 | 570 | // compare |
571 | - if( $rule['operator'] == "==" ) { |
|
571 | + if ($rule['operator'] == "==") { |
|
572 | 572 | |
573 | - $match = ( $posts_page == $post->ID ); |
|
573 | + $match = ($posts_page == $post->ID); |
|
574 | 574 | |
575 | - } elseif( $rule['operator'] == "!=" ) { |
|
575 | + } elseif ($rule['operator'] == "!=") { |
|
576 | 576 | |
577 | - $match = ( $posts_page != $post->ID ); |
|
577 | + $match = ($posts_page != $post->ID); |
|
578 | 578 | |
579 | 579 | } |
580 | 580 | |
581 | - } elseif( $rule['value'] == 'top_level') { |
|
581 | + } elseif ($rule['value'] == 'top_level') { |
|
582 | 582 | |
583 | 583 | // vars |
584 | 584 | $post_parent = $post->post_parent; |
585 | 585 | |
586 | 586 | |
587 | 587 | // override |
588 | - if( $options['page_parent'] ) { |
|
588 | + if ($options['page_parent']) { |
|
589 | 589 | |
590 | 590 | $post_parent = $options['page_parent']; |
591 | 591 | |
@@ -593,17 +593,17 @@ discard block |
||
593 | 593 | |
594 | 594 | |
595 | 595 | // compare |
596 | - if( $rule['operator'] == "==" ) { |
|
596 | + if ($rule['operator'] == "==") { |
|
597 | 597 | |
598 | - $match = ( $post_parent == 0 ); |
|
598 | + $match = ($post_parent == 0); |
|
599 | 599 | |
600 | - } elseif( $rule['operator'] == "!=" ) { |
|
600 | + } elseif ($rule['operator'] == "!=") { |
|
601 | 601 | |
602 | - $match = ( $post_parent != 0 ); |
|
602 | + $match = ($post_parent != 0); |
|
603 | 603 | |
604 | 604 | } |
605 | 605 | |
606 | - } elseif( $rule['value'] == 'parent' ) { |
|
606 | + } elseif ($rule['value'] == 'parent') { |
|
607 | 607 | |
608 | 608 | // get children |
609 | 609 | $children = get_pages(array( |
@@ -613,24 +613,24 @@ discard block |
||
613 | 613 | |
614 | 614 | |
615 | 615 | // compare |
616 | - if( $rule['operator'] == "==" ) { |
|
616 | + if ($rule['operator'] == "==") { |
|
617 | 617 | |
618 | - $match = ( count($children) > 0 ); |
|
618 | + $match = (count($children) > 0); |
|
619 | 619 | |
620 | - } elseif( $rule['operator'] == "!=" ) { |
|
620 | + } elseif ($rule['operator'] == "!=") { |
|
621 | 621 | |
622 | - $match = ( count($children) == 0 ); |
|
622 | + $match = (count($children) == 0); |
|
623 | 623 | |
624 | 624 | } |
625 | 625 | |
626 | - } elseif( $rule['value'] == 'child') { |
|
626 | + } elseif ($rule['value'] == 'child') { |
|
627 | 627 | |
628 | 628 | // vars |
629 | 629 | $post_parent = $post->post_parent; |
630 | 630 | |
631 | 631 | |
632 | 632 | // override |
633 | - if( $options['page_parent'] ) { |
|
633 | + if ($options['page_parent']) { |
|
634 | 634 | |
635 | 635 | $post_parent = $options['page_parent']; |
636 | 636 | |
@@ -638,13 +638,13 @@ discard block |
||
638 | 638 | |
639 | 639 | |
640 | 640 | // compare |
641 | - if( $rule['operator'] == "==" ) { |
|
641 | + if ($rule['operator'] == "==") { |
|
642 | 642 | |
643 | - $match = ( $post_parent != 0 ); |
|
643 | + $match = ($post_parent != 0); |
|
644 | 644 | |
645 | - } elseif( $rule['operator'] == "!=" ) { |
|
645 | + } elseif ($rule['operator'] == "!=") { |
|
646 | 646 | |
647 | - $match = ( $post_parent == 0 ); |
|
647 | + $match = ($post_parent == 0); |
|
648 | 648 | |
649 | 649 | } |
650 | 650 | |
@@ -671,10 +671,10 @@ discard block |
||
671 | 671 | * @return $options (array) |
672 | 672 | */ |
673 | 673 | |
674 | - function rule_match_page_parent( $match, $rule, $options ) { |
|
674 | + function rule_match_page_parent($match, $rule, $options) { |
|
675 | 675 | |
676 | 676 | // validation |
677 | - if( !$options['post_id'] ) { |
|
677 | + if ( ! $options['post_id']) { |
|
678 | 678 | |
679 | 679 | return false; |
680 | 680 | |
@@ -682,12 +682,12 @@ discard block |
||
682 | 682 | |
683 | 683 | |
684 | 684 | // vars |
685 | - $post = get_post( $options['post_id'] ); |
|
685 | + $post = get_post($options['post_id']); |
|
686 | 686 | |
687 | 687 | |
688 | 688 | // post parent |
689 | 689 | $post_parent = $post->post_parent; |
690 | - if( $options['page_parent'] ) { |
|
690 | + if ($options['page_parent']) { |
|
691 | 691 | |
692 | 692 | $post_parent = $options['page_parent']; |
693 | 693 | |
@@ -695,13 +695,13 @@ discard block |
||
695 | 695 | |
696 | 696 | |
697 | 697 | // compare |
698 | - if( $rule['operator'] == "==" ) { |
|
698 | + if ($rule['operator'] == "==") { |
|
699 | 699 | |
700 | - $match = ( $post_parent == $rule['value'] ); |
|
700 | + $match = ($post_parent == $rule['value']); |
|
701 | 701 | |
702 | - } elseif( $rule['operator'] == "!=" ) { |
|
702 | + } elseif ($rule['operator'] == "!=") { |
|
703 | 703 | |
704 | - $match = ( $post_parent != $rule['value'] ); |
|
704 | + $match = ($post_parent != $rule['value']); |
|
705 | 705 | |
706 | 706 | } |
707 | 707 | |
@@ -726,32 +726,32 @@ discard block |
||
726 | 726 | * @return $options (array) |
727 | 727 | */ |
728 | 728 | |
729 | - function rule_match_page_template( $match, $rule, $options ) { |
|
729 | + function rule_match_page_template($match, $rule, $options) { |
|
730 | 730 | |
731 | 731 | // vars |
732 | 732 | $page_template = $options['page_template']; |
733 | 733 | |
734 | 734 | |
735 | 735 | // get page template |
736 | - if( !$page_template && $options['post_id'] ) { |
|
736 | + if ( ! $page_template && $options['post_id']) { |
|
737 | 737 | |
738 | - $page_template = get_post_meta( $options['post_id'], '_wp_page_template', true ); |
|
738 | + $page_template = get_post_meta($options['post_id'], '_wp_page_template', true); |
|
739 | 739 | |
740 | 740 | } |
741 | 741 | |
742 | 742 | |
743 | 743 | // get page template again |
744 | - if( ! $page_template ) { |
|
744 | + if ( ! $page_template) { |
|
745 | 745 | |
746 | 746 | $post_type = $options['post_type']; |
747 | 747 | |
748 | - if( !$post_type && $options['post_id'] ) { |
|
748 | + if ( ! $post_type && $options['post_id']) { |
|
749 | 749 | |
750 | - $post_type = get_post_type( $options['post_id'] ); |
|
750 | + $post_type = get_post_type($options['post_id']); |
|
751 | 751 | |
752 | 752 | } |
753 | 753 | |
754 | - if( $post_type === 'page' ) { |
|
754 | + if ($post_type === 'page') { |
|
755 | 755 | |
756 | 756 | $page_template = "default"; |
757 | 757 | |
@@ -760,13 +760,13 @@ discard block |
||
760 | 760 | |
761 | 761 | |
762 | 762 | // compare |
763 | - if( $rule['operator'] == "==" ) { |
|
763 | + if ($rule['operator'] == "==") { |
|
764 | 764 | |
765 | - $match = ( $page_template === $rule['value'] ); |
|
765 | + $match = ($page_template === $rule['value']); |
|
766 | 766 | |
767 | - } elseif( $rule['operator'] == "!=" ) { |
|
767 | + } elseif ($rule['operator'] == "!=") { |
|
768 | 768 | |
769 | - $match = ( $page_template !== $rule['value'] ); |
|
769 | + $match = ($page_template !== $rule['value']); |
|
770 | 770 | |
771 | 771 | } |
772 | 772 | |
@@ -791,14 +791,14 @@ discard block |
||
791 | 791 | * @return $options (array) |
792 | 792 | */ |
793 | 793 | |
794 | - function rule_match_user_form( $match, $rule, $options ) { |
|
794 | + function rule_match_user_form($match, $rule, $options) { |
|
795 | 795 | |
796 | 796 | // vars |
797 | 797 | $user_form = $options['user_form']; |
798 | 798 | |
799 | 799 | |
800 | 800 | // add is treated the same as edit |
801 | - if( $user_form === 'add' ) { |
|
801 | + if ($user_form === 'add') { |
|
802 | 802 | |
803 | 803 | $user_form = 'edit'; |
804 | 804 | |
@@ -806,27 +806,27 @@ discard block |
||
806 | 806 | |
807 | 807 | |
808 | 808 | // compare |
809 | - if( $user_form ) { |
|
809 | + if ($user_form) { |
|
810 | 810 | |
811 | - if( $rule['operator'] == "==" ) { |
|
811 | + if ($rule['operator'] == "==") { |
|
812 | 812 | |
813 | - $match = ( $user_form == $rule['value'] ); |
|
813 | + $match = ($user_form == $rule['value']); |
|
814 | 814 | |
815 | 815 | |
816 | 816 | // override for "all" |
817 | - if( $rule['value'] === 'all' ) { |
|
817 | + if ($rule['value'] === 'all') { |
|
818 | 818 | |
819 | 819 | $match = true; |
820 | 820 | |
821 | 821 | } |
822 | 822 | |
823 | - } elseif( $rule['operator'] == "!=" ) { |
|
823 | + } elseif ($rule['operator'] == "!=") { |
|
824 | 824 | |
825 | - $match = ( $user_form != $rule['value'] ); |
|
825 | + $match = ($user_form != $rule['value']); |
|
826 | 826 | |
827 | 827 | |
828 | 828 | // override for "all" |
829 | - if( $rule['value'] === 'all' ) { |
|
829 | + if ($rule['value'] === 'all') { |
|
830 | 830 | |
831 | 831 | $match = false; |
832 | 832 | |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | * @return $options (array) |
857 | 857 | */ |
858 | 858 | |
859 | - function rule_match_user_role( $match, $rule, $options ) { |
|
859 | + function rule_match_user_role($match, $rule, $options) { |
|
860 | 860 | |
861 | 861 | // vars |
862 | 862 | $user_id = $options['user_id']; |
@@ -864,11 +864,11 @@ discard block |
||
864 | 864 | |
865 | 865 | |
866 | 866 | // user form AJAX will send through user_form |
867 | - if( $user_role ) { |
|
867 | + if ($user_role) { |
|
868 | 868 | |
869 | - if( $rule['operator'] == "==" ) { |
|
869 | + if ($rule['operator'] == "==") { |
|
870 | 870 | |
871 | - if( $user_role === $rule['value'] ) { |
|
871 | + if ($user_role === $rule['value']) { |
|
872 | 872 | |
873 | 873 | $match = true; |
874 | 874 | |
@@ -876,15 +876,15 @@ discard block |
||
876 | 876 | |
877 | 877 | |
878 | 878 | // override for "all" |
879 | - if( $rule['value'] === 'all' ) { |
|
879 | + if ($rule['value'] === 'all') { |
|
880 | 880 | |
881 | 881 | $match = true; |
882 | 882 | |
883 | 883 | } |
884 | 884 | |
885 | - } elseif( $rule['operator'] == "!=" ) { |
|
885 | + } elseif ($rule['operator'] == "!=") { |
|
886 | 886 | |
887 | - if( $user_role !== $rule['value'] ) { |
|
887 | + if ($user_role !== $rule['value']) { |
|
888 | 888 | |
889 | 889 | $match = true; |
890 | 890 | |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | |
893 | 893 | |
894 | 894 | // override for "all" |
895 | - if( $rule['value'] === 'all' ) { |
|
895 | + if ($rule['value'] === 'all') { |
|
896 | 896 | |
897 | 897 | $match = false; |
898 | 898 | |
@@ -900,47 +900,47 @@ discard block |
||
900 | 900 | |
901 | 901 | } |
902 | 902 | |
903 | - } elseif( $user_id ) { |
|
903 | + } elseif ($user_id) { |
|
904 | 904 | |
905 | - if( $rule['operator'] == "==" ) { |
|
905 | + if ($rule['operator'] == "==") { |
|
906 | 906 | |
907 | - if( $user_id === 'new' ) { |
|
907 | + if ($user_id === 'new') { |
|
908 | 908 | |
909 | 909 | // case: add user |
910 | - $match = ( $rule['value'] == get_option('default_role') ); |
|
910 | + $match = ($rule['value'] == get_option('default_role')); |
|
911 | 911 | |
912 | 912 | } else { |
913 | 913 | |
914 | 914 | // case: edit user |
915 | - $match = ( user_can($user_id, $rule['value']) ); |
|
915 | + $match = (user_can($user_id, $rule['value'])); |
|
916 | 916 | |
917 | 917 | } |
918 | 918 | |
919 | 919 | |
920 | 920 | // override for "all" |
921 | - if( $rule['value'] === 'all' ) { |
|
921 | + if ($rule['value'] === 'all') { |
|
922 | 922 | |
923 | 923 | $match = true; |
924 | 924 | |
925 | 925 | } |
926 | 926 | |
927 | - } elseif( $rule['operator'] == "!=" ) { |
|
927 | + } elseif ($rule['operator'] == "!=") { |
|
928 | 928 | |
929 | - if( $user_id === 'new' ) { |
|
929 | + if ($user_id === 'new') { |
|
930 | 930 | |
931 | 931 | // case: add user |
932 | - $match = ( $rule['value'] != get_option('default_role') ); |
|
932 | + $match = ($rule['value'] != get_option('default_role')); |
|
933 | 933 | |
934 | 934 | } else { |
935 | 935 | |
936 | 936 | // case: edit user |
937 | - $match = ( !user_can($user_id, $rule['value']) ); |
|
937 | + $match = ( ! user_can($user_id, $rule['value'])); |
|
938 | 938 | |
939 | 939 | } |
940 | 940 | |
941 | 941 | |
942 | 942 | // override for "all" |
943 | - if( $rule['value'] === 'all' ) { |
|
943 | + if ($rule['value'] === 'all') { |
|
944 | 944 | |
945 | 945 | $match = false; |
946 | 946 | |
@@ -972,14 +972,14 @@ discard block |
||
972 | 972 | * @return $options (array) |
973 | 973 | */ |
974 | 974 | |
975 | - function rule_match_taxonomy( $match, $rule, $options ) { |
|
975 | + function rule_match_taxonomy($match, $rule, $options) { |
|
976 | 976 | |
977 | 977 | // vars |
978 | 978 | $taxonomy = $options['taxonomy']; |
979 | 979 | |
980 | 980 | |
981 | 981 | // validate |
982 | - if( !$taxonomy ) { |
|
982 | + if ( ! $taxonomy) { |
|
983 | 983 | |
984 | 984 | return false; |
985 | 985 | |
@@ -987,23 +987,23 @@ discard block |
||
987 | 987 | |
988 | 988 | |
989 | 989 | // compare |
990 | - if( $rule['operator'] == "==" ) { |
|
990 | + if ($rule['operator'] == "==") { |
|
991 | 991 | |
992 | - $match = ( $taxonomy == $rule['value'] ); |
|
992 | + $match = ($taxonomy == $rule['value']); |
|
993 | 993 | |
994 | 994 | // override for "all" |
995 | - if( $rule['value'] == "all" ) { |
|
995 | + if ($rule['value'] == "all") { |
|
996 | 996 | |
997 | 997 | $match = true; |
998 | 998 | |
999 | 999 | } |
1000 | 1000 | |
1001 | - } elseif( $rule['operator'] == "!=" ) { |
|
1001 | + } elseif ($rule['operator'] == "!=") { |
|
1002 | 1002 | |
1003 | - $match = ( $taxonomy != $rule['value'] ); |
|
1003 | + $match = ($taxonomy != $rule['value']); |
|
1004 | 1004 | |
1005 | 1005 | // override for "all" |
1006 | - if( $rule['value'] == "all" ) { |
|
1006 | + if ($rule['value'] == "all") { |
|
1007 | 1007 | |
1008 | 1008 | $match = false; |
1009 | 1009 | |
@@ -1032,14 +1032,14 @@ discard block |
||
1032 | 1032 | * @return $options (array) |
1033 | 1033 | */ |
1034 | 1034 | |
1035 | - function rule_match_attachment( $match, $rule, $options ) { |
|
1035 | + function rule_match_attachment($match, $rule, $options) { |
|
1036 | 1036 | |
1037 | 1037 | // vars |
1038 | 1038 | $attachment = $options['attachment']; |
1039 | 1039 | |
1040 | 1040 | |
1041 | 1041 | // validate |
1042 | - if( ! $attachment ) { |
|
1042 | + if ( ! $attachment) { |
|
1043 | 1043 | |
1044 | 1044 | return false; |
1045 | 1045 | |
@@ -1047,23 +1047,23 @@ discard block |
||
1047 | 1047 | |
1048 | 1048 | |
1049 | 1049 | // compare |
1050 | - if( $rule['operator'] == "==" ) { |
|
1050 | + if ($rule['operator'] == "==") { |
|
1051 | 1051 | |
1052 | - $match = ( $attachment == $rule['value'] ); |
|
1052 | + $match = ($attachment == $rule['value']); |
|
1053 | 1053 | |
1054 | 1054 | // override for "all" |
1055 | - if( $rule['value'] == "all" ) { |
|
1055 | + if ($rule['value'] == "all") { |
|
1056 | 1056 | |
1057 | 1057 | $match = true; |
1058 | 1058 | |
1059 | 1059 | } |
1060 | 1060 | |
1061 | - } elseif( $rule['operator'] == "!=" ) { |
|
1061 | + } elseif ($rule['operator'] == "!=") { |
|
1062 | 1062 | |
1063 | - $match = ( $attachment != $rule['value'] ); |
|
1063 | + $match = ($attachment != $rule['value']); |
|
1064 | 1064 | |
1065 | 1065 | // override for "all" |
1066 | - if( $rule['value'] == "all" ) { |
|
1066 | + if ($rule['value'] == "all") { |
|
1067 | 1067 | |
1068 | 1068 | $match = false; |
1069 | 1069 | |
@@ -1093,14 +1093,14 @@ discard block |
||
1093 | 1093 | * @return $options (array) |
1094 | 1094 | */ |
1095 | 1095 | |
1096 | - function rule_match_comment( $match, $rule, $options ) { |
|
1096 | + function rule_match_comment($match, $rule, $options) { |
|
1097 | 1097 | |
1098 | 1098 | // vars |
1099 | 1099 | $comment = $options['comment']; |
1100 | 1100 | |
1101 | 1101 | |
1102 | 1102 | // validate |
1103 | - if( ! $comment ) { |
|
1103 | + if ( ! $comment) { |
|
1104 | 1104 | |
1105 | 1105 | return false; |
1106 | 1106 | |
@@ -1108,23 +1108,23 @@ discard block |
||
1108 | 1108 | |
1109 | 1109 | |
1110 | 1110 | // compare |
1111 | - if( $rule['operator'] == "==" ) { |
|
1111 | + if ($rule['operator'] == "==") { |
|
1112 | 1112 | |
1113 | - $match = ( $comment == $rule['value'] ); |
|
1113 | + $match = ($comment == $rule['value']); |
|
1114 | 1114 | |
1115 | 1115 | // override for "all" |
1116 | - if( $rule['value'] == "all" ) { |
|
1116 | + if ($rule['value'] == "all") { |
|
1117 | 1117 | |
1118 | 1118 | $match = true; |
1119 | 1119 | |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - } elseif( $rule['operator'] == "!=" ) { |
|
1122 | + } elseif ($rule['operator'] == "!=") { |
|
1123 | 1123 | |
1124 | - $match = ( $comment != $rule['value'] ); |
|
1124 | + $match = ($comment != $rule['value']); |
|
1125 | 1125 | |
1126 | 1126 | // override for "all" |
1127 | - if( $rule['value'] == "all" ) { |
|
1127 | + if ($rule['value'] == "all") { |
|
1128 | 1128 | |
1129 | 1129 | $match = false; |
1130 | 1130 | |
@@ -1153,14 +1153,14 @@ discard block |
||
1153 | 1153 | * @return $options (array) |
1154 | 1154 | */ |
1155 | 1155 | |
1156 | - function rule_match_widget( $match, $rule, $options ) { |
|
1156 | + function rule_match_widget($match, $rule, $options) { |
|
1157 | 1157 | |
1158 | 1158 | // vars |
1159 | 1159 | $widget = $options['widget']; |
1160 | 1160 | |
1161 | 1161 | |
1162 | 1162 | // validate |
1163 | - if( ! $widget ) { |
|
1163 | + if ( ! $widget) { |
|
1164 | 1164 | |
1165 | 1165 | return false; |
1166 | 1166 | |
@@ -1168,23 +1168,23 @@ discard block |
||
1168 | 1168 | |
1169 | 1169 | |
1170 | 1170 | // compare |
1171 | - if( $rule['operator'] == "==" ) { |
|
1171 | + if ($rule['operator'] == "==") { |
|
1172 | 1172 | |
1173 | - $match = ( $widget == $rule['value'] ); |
|
1173 | + $match = ($widget == $rule['value']); |
|
1174 | 1174 | |
1175 | 1175 | // override for "all" |
1176 | - if( $rule['value'] == "all" ) { |
|
1176 | + if ($rule['value'] == "all") { |
|
1177 | 1177 | |
1178 | 1178 | $match = true; |
1179 | 1179 | |
1180 | 1180 | } |
1181 | 1181 | |
1182 | - } elseif( $rule['operator'] == "!=" ) { |
|
1182 | + } elseif ($rule['operator'] == "!=") { |
|
1183 | 1183 | |
1184 | - $match = ( $widget != $rule['value'] ); |
|
1184 | + $match = ($widget != $rule['value']); |
|
1185 | 1185 | |
1186 | 1186 | // override for "all" |
1187 | - if( $rule['value'] == "all" ) { |
|
1187 | + if ($rule['value'] == "all") { |
|
1188 | 1188 | |
1189 | 1189 | $match = false; |
1190 | 1190 | |
@@ -1217,7 +1217,7 @@ discard block |
||
1217 | 1217 | * @return (boolean) |
1218 | 1218 | */ |
1219 | 1219 | |
1220 | -function acf_get_field_group_visibility( $field_group, $args = array() ) { |
|
1220 | +function acf_get_field_group_visibility($field_group, $args = array()) { |
|
1221 | 1221 | |
1222 | 1222 | // vars |
1223 | 1223 | $args = acf_parse_args($args, array( |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | |
1242 | 1242 | |
1243 | 1243 | // bail early if not active |
1244 | - if( !$field_group['active'] ) { |
|
1244 | + if ( ! $field_group['active']) { |
|
1245 | 1245 | |
1246 | 1246 | return false; |
1247 | 1247 | |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | |
1250 | 1250 | |
1251 | 1251 | // WPML |
1252 | - if( defined('ICL_LANGUAGE_CODE') ) { |
|
1252 | + if (defined('ICL_LANGUAGE_CODE')) { |
|
1253 | 1253 | |
1254 | 1254 | $args['lang'] = ICL_LANGUAGE_CODE; |
1255 | 1255 | |
@@ -1261,20 +1261,20 @@ discard block |
||
1261 | 1261 | |
1262 | 1262 | |
1263 | 1263 | // loop through location rules |
1264 | - foreach( $field_group['location'] as $group_id => $group ) { |
|
1264 | + foreach ($field_group['location'] as $group_id => $group) { |
|
1265 | 1265 | |
1266 | 1266 | // start of as true, this way, any rule that doesn't match will cause this varaible to false |
1267 | 1267 | $match_group = true; |
1268 | 1268 | |
1269 | 1269 | |
1270 | 1270 | // loop over group rules |
1271 | - if( !empty($group) ) { |
|
1271 | + if ( ! empty($group)) { |
|
1272 | 1272 | |
1273 | - foreach( $group as $rule_id => $rule ) { |
|
1273 | + foreach ($group as $rule_id => $rule) { |
|
1274 | 1274 | |
1275 | - $match = apply_filters( 'acf/location/rule_match/' . $rule['param'] , false, $rule, $args ); |
|
1275 | + $match = apply_filters('acf/location/rule_match/'.$rule['param'], false, $rule, $args); |
|
1276 | 1276 | |
1277 | - if( !$match ) { |
|
1277 | + if ( ! $match) { |
|
1278 | 1278 | |
1279 | 1279 | $match_group = false; |
1280 | 1280 | break; |
@@ -1287,7 +1287,7 @@ discard block |
||
1287 | 1287 | |
1288 | 1288 | |
1289 | 1289 | // all rules must havematched! |
1290 | - if( $match_group ) { |
|
1290 | + if ($match_group) { |
|
1291 | 1291 | |
1292 | 1292 | $visibility = true; |
1293 | 1293 |
@@ -19,16 +19,16 @@ discard block |
||
19 | 19 | function __construct() { |
20 | 20 | |
21 | 21 | // actions |
22 | - add_action('acf/save_post', array($this, 'save_files'), 5, 1); |
|
23 | - add_action('acf/input/admin_footer_js', array($this, 'admin_footer_js')); |
|
22 | + add_action('acf/save_post', array($this, 'save_files'), 5, 1); |
|
23 | + add_action('acf/input/admin_footer_js', array($this, 'admin_footer_js')); |
|
24 | 24 | |
25 | 25 | |
26 | 26 | // filters |
27 | - add_filter('wp_handle_upload_prefilter', array($this, 'handle_upload_prefilter'), 10, 1); |
|
27 | + add_filter('wp_handle_upload_prefilter', array($this, 'handle_upload_prefilter'), 10, 1); |
|
28 | 28 | |
29 | 29 | |
30 | 30 | // ajax |
31 | - add_action( 'wp_ajax_query-attachments', array($this, 'wp_ajax_query_attachments'), -1); |
|
31 | + add_action('wp_ajax_query-attachments', array($this, 'wp_ajax_query_attachments'), -1); |
|
32 | 32 | |
33 | 33 | } |
34 | 34 | |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | * @return $post_id (int) |
47 | 47 | */ |
48 | 48 | |
49 | - function handle_upload_prefilter( $file ) { |
|
49 | + function handle_upload_prefilter($file) { |
|
50 | 50 | |
51 | 51 | // bail early if no acf field |
52 | - if( empty($_POST['_acfuploader']) ) { |
|
52 | + if (empty($_POST['_acfuploader'])) { |
|
53 | 53 | |
54 | 54 | return $file; |
55 | 55 | |
@@ -57,9 +57,9 @@ discard block |
||
57 | 57 | |
58 | 58 | |
59 | 59 | // load field |
60 | - $field = acf_get_field( $_POST['_acfuploader'] ); |
|
60 | + $field = acf_get_field($_POST['_acfuploader']); |
|
61 | 61 | |
62 | - if( !$field ) { |
|
62 | + if ( ! $field) { |
|
63 | 63 | |
64 | 64 | return $file; |
65 | 65 | |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | |
68 | 68 | |
69 | 69 | // get errors |
70 | - $errors = acf_validate_attachment( $file, $field, 'upload' ); |
|
70 | + $errors = acf_validate_attachment($file, $field, 'upload'); |
|
71 | 71 | |
72 | 72 | |
73 | 73 | // filter for 3rd party customization |
74 | 74 | $errors = apply_filters("acf/upload_prefilter", $errors, $file, $field); |
75 | - $errors = apply_filters("acf/upload_prefilter/type={$field['type']}", $errors, $file, $field ); |
|
76 | - $errors = apply_filters("acf/upload_prefilter/name={$field['name']}", $errors, $file, $field ); |
|
77 | - $errors = apply_filters("acf/upload_prefilter/key={$field['key']}", $errors, $file, $field ); |
|
75 | + $errors = apply_filters("acf/upload_prefilter/type={$field['type']}", $errors, $file, $field); |
|
76 | + $errors = apply_filters("acf/upload_prefilter/name={$field['name']}", $errors, $file, $field); |
|
77 | + $errors = apply_filters("acf/upload_prefilter/key={$field['key']}", $errors, $file, $field); |
|
78 | 78 | |
79 | 79 | |
80 | 80 | // append error |
81 | - if( !empty($errors) ) { |
|
81 | + if ( ! empty($errors)) { |
|
82 | 82 | |
83 | 83 | $file['error'] = implode("\n", $errors); |
84 | 84 | |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | * @return $post_id (int) |
105 | 105 | */ |
106 | 106 | |
107 | - function save_files( $post_id = 0 ) { |
|
107 | + function save_files($post_id = 0) { |
|
108 | 108 | |
109 | 109 | // bail early if no $_FILES data |
110 | - if( empty($_FILES['acf']['name']) ) { |
|
110 | + if (empty($_FILES['acf']['name'])) { |
|
111 | 111 | |
112 | 112 | return; |
113 | 113 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | function admin_footer_js() { |
137 | 137 | |
138 | - ?>acf.media.mime_types = <?php echo json_encode( get_allowed_mime_types() ); ?>; |
|
138 | + ?>acf.media.mime_types = <?php echo json_encode(get_allowed_mime_types()); ?>; |
|
139 | 139 | <?php |
140 | 140 | |
141 | 141 | } |
@@ -156,18 +156,18 @@ discard block |
||
156 | 156 | |
157 | 157 | function wp_ajax_query_attachments() { |
158 | 158 | |
159 | - add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3); |
|
159 | + add_filter('wp_prepare_attachment_for_js', array($this, 'wp_prepare_attachment_for_js'), 10, 3); |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | - function wp_prepare_attachment_for_js( $response, $attachment, $meta ) { |
|
163 | + function wp_prepare_attachment_for_js($response, $attachment, $meta) { |
|
164 | 164 | |
165 | 165 | // append attribute |
166 | 166 | $response['acf_errors'] = false; |
167 | 167 | |
168 | 168 | |
169 | 169 | // bail early if no acf field |
170 | - if( empty($_POST['query']['_acfuploader']) ) { |
|
170 | + if (empty($_POST['query']['_acfuploader'])) { |
|
171 | 171 | |
172 | 172 | return $response; |
173 | 173 | |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | |
176 | 176 | |
177 | 177 | // load field |
178 | - $field = acf_get_field( $_POST['query']['_acfuploader'] ); |
|
178 | + $field = acf_get_field($_POST['query']['_acfuploader']); |
|
179 | 179 | |
180 | - if( !$field ) { |
|
180 | + if ( ! $field) { |
|
181 | 181 | |
182 | 182 | return $response; |
183 | 183 | |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | |
186 | 186 | |
187 | 187 | // get errors |
188 | - $errors = acf_validate_attachment( $response, $field, 'prepare' ); |
|
188 | + $errors = acf_validate_attachment($response, $field, 'prepare'); |
|
189 | 189 | |
190 | 190 | |
191 | 191 | // append errors |
192 | - if( !empty($errors) ) { |
|
192 | + if ( ! empty($errors)) { |
|
193 | 193 | |
194 | 194 | $response['acf_errors'] = implode('<br />', $errors); |
195 | 195 |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | function __construct() |
18 | 18 | { |
19 | 19 | // actions |
20 | - add_action('wp_restore_post_revision', array($this, 'wp_restore_post_revision'), 10, 2 ); |
|
20 | + add_action('wp_restore_post_revision', array($this, 'wp_restore_post_revision'), 10, 2); |
|
21 | 21 | |
22 | 22 | |
23 | 23 | // filters |
24 | - add_filter('_wp_post_revision_fields', array($this, 'wp_preview_post_fields') ); |
|
25 | - add_filter('_wp_post_revision_fields', array($this, 'wp_post_revision_fields') ); |
|
24 | + add_filter('_wp_post_revision_fields', array($this, 'wp_preview_post_fields')); |
|
25 | + add_filter('_wp_post_revision_fields', array($this, 'wp_post_revision_fields')); |
|
26 | 26 | add_filter('wp_save_post_revision_check_for_changes', array($this, 'force_save_revision'), 10, 3); |
27 | 27 | } |
28 | 28 | |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | * @return $fields |
43 | 43 | */ |
44 | 44 | |
45 | - function wp_preview_post_fields( $fields ) { |
|
45 | + function wp_preview_post_fields($fields) { |
|
46 | 46 | |
47 | 47 | // bail early if not previewing a post |
48 | - if( empty($_POST['wp-preview']) || $_POST['wp-preview'] != 'dopreview') { |
|
48 | + if (empty($_POST['wp-preview']) || $_POST['wp-preview'] != 'dopreview') { |
|
49 | 49 | |
50 | 50 | return $fields; |
51 | 51 | |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | |
55 | 55 | // add to fields if ACF has changed |
56 | - if( !empty($_POST['_acfchanged']) ) { |
|
56 | + if ( ! empty($_POST['_acfchanged'])) { |
|
57 | 57 | |
58 | 58 | $fields['_acfchanged'] = 'different than 1'; |
59 | 59 | |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * @return $return (boolean) |
82 | 82 | */ |
83 | 83 | |
84 | - function force_save_revision( $return, $last_revision, $post ) |
|
84 | + function force_save_revision($return, $last_revision, $post) |
|
85 | 85 | { |
86 | 86 | // preview hack |
87 | - if( isset($_POST['_acfchanged']) && $_POST['_acfchanged'] == '1' ) |
|
87 | + if (isset($_POST['_acfchanged']) && $_POST['_acfchanged'] == '1') |
|
88 | 88 | { |
89 | 89 | $return = false; |
90 | 90 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | * @return $post_id (int) |
110 | 110 | */ |
111 | 111 | |
112 | - function wp_post_revision_fields( $return ) { |
|
112 | + function wp_post_revision_fields($return) { |
|
113 | 113 | |
114 | 114 | |
115 | 115 | //globals |
@@ -121,21 +121,21 @@ discard block |
||
121 | 121 | |
122 | 122 | |
123 | 123 | // Normal revisions page |
124 | - if( $pagenow == 'revision.php' ) |
|
124 | + if ($pagenow == 'revision.php') |
|
125 | 125 | { |
126 | 126 | $allowed = true; |
127 | 127 | } |
128 | 128 | |
129 | 129 | |
130 | 130 | // WP 3.6 AJAX revision |
131 | - if( $pagenow == 'admin-ajax.php' && isset($_POST['action']) && $_POST['action'] == 'get-revision-diffs' ) |
|
131 | + if ($pagenow == 'admin-ajax.php' && isset($_POST['action']) && $_POST['action'] == 'get-revision-diffs') |
|
132 | 132 | { |
133 | 133 | $allowed = true; |
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | 137 | // bail |
138 | - if( !$allowed ) |
|
138 | + if ( ! $allowed) |
|
139 | 139 | { |
140 | 140 | return $return; |
141 | 141 | } |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | |
147 | 147 | |
148 | 148 | // determine $post_id |
149 | - if( isset($_POST['post_id']) ) |
|
149 | + if (isset($_POST['post_id'])) |
|
150 | 150 | { |
151 | 151 | $post_id = $_POST['post_id']; |
152 | 152 | } |
153 | - elseif( isset($post->ID) ) |
|
153 | + elseif (isset($post->ID)) |
|
154 | 154 | { |
155 | 155 | $post_id = $post->ID; |
156 | 156 | } |
@@ -165,20 +165,20 @@ discard block |
||
165 | 165 | |
166 | 166 | |
167 | 167 | // get field objects |
168 | - $custom_fields = get_post_custom( $post_id ); |
|
168 | + $custom_fields = get_post_custom($post_id); |
|
169 | 169 | |
170 | 170 | |
171 | 171 | // populate vars |
172 | - if( !empty($custom_fields) ) |
|
172 | + if ( ! empty($custom_fields)) |
|
173 | 173 | { |
174 | - foreach( $custom_fields as $k => $v ) |
|
174 | + foreach ($custom_fields as $k => $v) |
|
175 | 175 | { |
176 | 176 | // value is always an array |
177 | 177 | $v = $v[0]; |
178 | 178 | |
179 | 179 | |
180 | 180 | // bail early if $value is not is a field_key |
181 | - if( !acf_is_field_key($v) ) |
|
181 | + if ( ! acf_is_field_key($v)) |
|
182 | 182 | { |
183 | 183 | continue; |
184 | 184 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | |
194 | 194 | |
195 | 195 | // append to return |
196 | - $return[ $field_name ] = $field_name; |
|
196 | + $return[$field_name] = $field_name; |
|
197 | 197 | |
198 | 198 | |
199 | 199 | // load value |
@@ -202,12 +202,12 @@ discard block |
||
202 | 202 | |
203 | 203 | // WP 3.5: left vs right |
204 | 204 | // Add a value of the revision ID (as there is no way to determine this within the '_wp_post_revision_field_' filter!) |
205 | - if( isset($_GET['action'], $_GET['left'], $_GET['right']) && $_GET['action'] == 'diff' ) |
|
205 | + if (isset($_GET['action'], $_GET['left'], $_GET['right']) && $_GET['action'] == 'diff') |
|
206 | 206 | { |
207 | 207 | global $left_revision, $right_revision; |
208 | 208 | |
209 | - $left_revision->$field_name = 'revision_id=' . $_GET['left']; |
|
210 | - $right_revision->$field_name = 'revision_id=' . $_GET['right']; |
|
209 | + $left_revision->$field_name = 'revision_id='.$_GET['left']; |
|
210 | + $right_revision->$field_name = 'revision_id='.$_GET['right']; |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | } |
@@ -234,24 +234,24 @@ discard block |
||
234 | 234 | * @return $value (string) |
235 | 235 | */ |
236 | 236 | |
237 | - function wp_post_revision_field( $value, $field_name, $post = null, $direction = false) |
|
237 | + function wp_post_revision_field($value, $field_name, $post = null, $direction = false) |
|
238 | 238 | { |
239 | 239 | // vars |
240 | 240 | $post_id = 0; |
241 | 241 | |
242 | 242 | |
243 | 243 | // determine $post_id |
244 | - if( isset($post->ID) ) |
|
244 | + if (isset($post->ID)) |
|
245 | 245 | { |
246 | 246 | // WP 3.6 |
247 | 247 | $post_id = $post->ID; |
248 | 248 | } |
249 | - elseif( isset($_GET['revision']) ) |
|
249 | + elseif (isset($_GET['revision'])) |
|
250 | 250 | { |
251 | 251 | // WP 3.5 |
252 | 252 | $post_id = (int) $_GET['revision']; |
253 | 253 | } |
254 | - elseif( strpos($value, 'revision_id=') !== false ) |
|
254 | + elseif (strpos($value, 'revision_id=') !== false) |
|
255 | 255 | { |
256 | 256 | // WP 3.5 (left vs right) |
257 | 257 | $post_id = (int) str_replace('revision_id=', '', $value); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | |
261 | 261 | // load field |
262 | - $field = acf_maybe_get_field( $field_name, $post_id ); |
|
262 | + $field = acf_maybe_get_field($field_name, $post_id); |
|
263 | 263 | |
264 | 264 | |
265 | 265 | // update value |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | |
268 | 268 | |
269 | 269 | // default formatting |
270 | - if( is_array($value) ) { |
|
270 | + if (is_array($value)) { |
|
271 | 271 | |
272 | 272 | $value = implode(', ', $value); |
273 | 273 | |
@@ -275,13 +275,13 @@ discard block |
||
275 | 275 | |
276 | 276 | |
277 | 277 | // format |
278 | - if( !empty($value) ) |
|
278 | + if ( ! empty($value)) |
|
279 | 279 | { |
280 | 280 | // image || file? |
281 | - if( $field['type'] == 'image' || $field['type'] == 'file' ) |
|
281 | + if ($field['type'] == 'image' || $field['type'] == 'file') |
|
282 | 282 | { |
283 | 283 | $url = wp_get_attachment_url($value); |
284 | - $value = $value . ' (' . $url . ')'; |
|
284 | + $value = $value.' ('.$url.')'; |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -303,27 +303,27 @@ discard block |
||
303 | 303 | * @return $revision_id (int) the source post |
304 | 304 | */ |
305 | 305 | |
306 | - function wp_restore_post_revision( $post_id, $revision_id ) { |
|
306 | + function wp_restore_post_revision($post_id, $revision_id) { |
|
307 | 307 | |
308 | 308 | // global |
309 | 309 | global $wpdb; |
310 | 310 | |
311 | 311 | |
312 | 312 | // get field objects |
313 | - $custom_fields = get_post_custom( $revision_id ); |
|
313 | + $custom_fields = get_post_custom($revision_id); |
|
314 | 314 | |
315 | 315 | |
316 | 316 | // populate vars |
317 | - if( !empty($custom_fields) ) |
|
317 | + if ( ! empty($custom_fields)) |
|
318 | 318 | { |
319 | - foreach( $custom_fields as $k => $v ) |
|
319 | + foreach ($custom_fields as $k => $v) |
|
320 | 320 | { |
321 | 321 | // value is always an array |
322 | 322 | $v = $v[0]; |
323 | 323 | |
324 | 324 | |
325 | 325 | // bail early if $value is not is a field_key |
326 | - if( !acf_is_field_key($v) ) |
|
326 | + if ( ! acf_is_field_key($v)) |
|
327 | 327 | { |
328 | 328 | continue; |
329 | 329 | } |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | |
335 | 335 | |
336 | 336 | // bail early if value could not be found |
337 | - if( !isset($custom_fields[ $field_name ][0]) ) |
|
337 | + if ( ! isset($custom_fields[$field_name][0])) |
|
338 | 338 | { |
339 | 339 | continue; |
340 | 340 | } |
341 | 341 | |
342 | 342 | |
343 | - update_post_meta( $post_id, $field_name, $custom_fields[ $field_name ][0] ); |
|
343 | + update_post_meta($post_id, $field_name, $custom_fields[$field_name][0]); |
|
344 | 344 | |
345 | 345 | |
346 | 346 | } |
@@ -149,12 +149,10 @@ discard block |
||
149 | 149 | if( isset($_POST['post_id']) ) |
150 | 150 | { |
151 | 151 | $post_id = $_POST['post_id']; |
152 | - } |
|
153 | - elseif( isset($post->ID) ) |
|
152 | + } elseif( isset($post->ID) ) |
|
154 | 153 | { |
155 | 154 | $post_id = $post->ID; |
156 | - } |
|
157 | - else |
|
155 | + } else |
|
158 | 156 | { |
159 | 157 | return $return; |
160 | 158 | } |
@@ -245,13 +243,11 @@ discard block |
||
245 | 243 | { |
246 | 244 | // WP 3.6 |
247 | 245 | $post_id = $post->ID; |
248 | - } |
|
249 | - elseif( isset($_GET['revision']) ) |
|
246 | + } elseif( isset($_GET['revision']) ) |
|
250 | 247 | { |
251 | 248 | // WP 3.5 |
252 | 249 | $post_id = (int) $_GET['revision']; |
253 | - } |
|
254 | - elseif( strpos($value, 'revision_id=') !== false ) |
|
250 | + } elseif( strpos($value, 'revision_id=') !== false ) |
|
255 | 251 | { |
256 | 252 | // WP 3.5 (left vs right) |
257 | 253 | $post_id = (int) str_replace('revision_id=', '', $value); |