@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @subpackage Fields |
12 | 12 | */ |
13 | 13 | |
14 | -if( ! class_exists('acf_field_user') ) : |
|
14 | +if ( ! class_exists('acf_field_user')) : |
|
15 | 15 | |
16 | 16 | class acf_field_user extends acf_field { |
17 | 17 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | // vars |
35 | 35 | $this->name = 'user'; |
36 | - $this->label = __("User",'acf'); |
|
36 | + $this->label = __("User", 'acf'); |
|
37 | 37 | $this->category = 'relational'; |
38 | 38 | $this->defaults = array( |
39 | 39 | 'role' => '', |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | |
44 | 44 | |
45 | 45 | // extra |
46 | - add_action('wp_ajax_acf/fields/user/query', array($this, 'ajax_query')); |
|
47 | - add_action('wp_ajax_nopriv_acf/fields/user/query', array($this, 'ajax_query')); |
|
46 | + add_action('wp_ajax_acf/fields/user/query', array($this, 'ajax_query')); |
|
47 | + add_action('wp_ajax_nopriv_acf/fields/user/query', array($this, 'ajax_query')); |
|
48 | 48 | |
49 | 49 | |
50 | 50 | // do not delete! |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return (array) |
67 | 67 | */ |
68 | 68 | |
69 | - function get_choices( $options = array() ) { |
|
69 | + function get_choices($options = array()) { |
|
70 | 70 | |
71 | 71 | // defaults |
72 | 72 | $options = acf_parse_args($options, array( |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | |
83 | 83 | |
84 | 84 | // load field |
85 | - $field = acf_get_field( $options['field_key'] ); |
|
85 | + $field = acf_get_field($options['field_key']); |
|
86 | 86 | |
87 | - if( !$field ) { |
|
87 | + if ( ! $field) { |
|
88 | 88 | |
89 | 89 | return false; |
90 | 90 | |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | // editable roles |
95 | 95 | $editable_roles = get_editable_roles(); |
96 | 96 | |
97 | - if( !empty($field['role']) ) { |
|
97 | + if ( ! empty($field['role'])) { |
|
98 | 98 | |
99 | - foreach( $editable_roles as $role => $role_info ) { |
|
99 | + foreach ($editable_roles as $role => $role_info) { |
|
100 | 100 | |
101 | - if( !in_array($role, $field['role']) ) { |
|
101 | + if ( ! in_array($role, $field['role'])) { |
|
102 | 102 | |
103 | - unset( $editable_roles[ $role ] ); |
|
103 | + unset($editable_roles[$role]); |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | |
@@ -110,10 +110,10 @@ discard block |
||
110 | 110 | |
111 | 111 | |
112 | 112 | // search |
113 | - if( $options['s'] ) { |
|
113 | + if ($options['s']) { |
|
114 | 114 | |
115 | 115 | // append to $args |
116 | - $args['search'] = '*' . $options['s'] . '*'; |
|
116 | + $args['search'] = '*'.$options['s'].'*'; |
|
117 | 117 | |
118 | 118 | |
119 | 119 | // add reference |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | // filters |
130 | - $args = apply_filters("acf/fields/user/query", $args, $field, $options['post_id']); |
|
131 | - $args = apply_filters("acf/fields/user/query/name={$field['_name']}", $args, $field, $options['post_id']); |
|
132 | - $args = apply_filters("acf/fields/user/query/key={$field['key']}", $args, $field, $options['post_id']); |
|
130 | + $args = apply_filters("acf/fields/user/query", $args, $field, $options['post_id']); |
|
131 | + $args = apply_filters("acf/fields/user/query/name={$field['_name']}", $args, $field, $options['post_id']); |
|
132 | + $args = apply_filters("acf/fields/user/query/key={$field['key']}", $args, $field, $options['post_id']); |
|
133 | 133 | |
134 | 134 | |
135 | 135 | // get users |
136 | - $users = get_users( $args ); |
|
136 | + $users = get_users($args); |
|
137 | 137 | |
138 | - if( !empty($users) && !empty($editable_roles) ) { |
|
138 | + if ( ! empty($users) && ! empty($editable_roles)) { |
|
139 | 139 | |
140 | - foreach( $editable_roles as $role => $role_info ) { |
|
140 | + foreach ($editable_roles as $role => $role_info) { |
|
141 | 141 | |
142 | 142 | // vars |
143 | 143 | $this_users = array(); |
@@ -145,16 +145,16 @@ discard block |
||
145 | 145 | |
146 | 146 | |
147 | 147 | // loop over users |
148 | - foreach( array_keys($users) as $key ) { |
|
148 | + foreach (array_keys($users) as $key) { |
|
149 | 149 | |
150 | - if( in_array($role, $users[ $key ]->roles) ) { |
|
150 | + if (in_array($role, $users[$key]->roles)) { |
|
151 | 151 | |
152 | 152 | // extract user |
153 | - $user = acf_extract_var( $users, $key ); |
|
153 | + $user = acf_extract_var($users, $key); |
|
154 | 154 | |
155 | 155 | |
156 | 156 | // append to $this_users |
157 | - $this_users[ $user->ID ] = $this->get_result( $user, $field, $options['post_id'] ); |
|
157 | + $this_users[$user->ID] = $this->get_result($user, $field, $options['post_id']); |
|
158 | 158 | |
159 | 159 | } |
160 | 160 | |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | |
164 | 164 | // bail early if no users for this role |
165 | - if( empty($this_users) ) { |
|
165 | + if (empty($this_users)) { |
|
166 | 166 | |
167 | 167 | continue; |
168 | 168 | |
@@ -170,34 +170,34 @@ discard block |
||
170 | 170 | |
171 | 171 | |
172 | 172 | // order by search |
173 | - if( !empty($args['s']) ) { |
|
173 | + if ( ! empty($args['s'])) { |
|
174 | 174 | |
175 | - $this_users = acf_order_by_search( $this_users, $args['s'] ); |
|
175 | + $this_users = acf_order_by_search($this_users, $args['s']); |
|
176 | 176 | |
177 | 177 | } |
178 | 178 | |
179 | 179 | |
180 | 180 | // append to json |
181 | - foreach( array_keys($this_users) as $user_id ) { |
|
181 | + foreach (array_keys($this_users) as $user_id) { |
|
182 | 182 | |
183 | 183 | // add to json |
184 | 184 | $this_json[] = array( |
185 | 185 | 'id' => $user_id, |
186 | - 'text' => $this_users[ $user_id ] |
|
186 | + 'text' => $this_users[$user_id] |
|
187 | 187 | ); |
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | 191 | |
192 | 192 | // add as optgroup or results |
193 | - if( count($editable_roles) == 1 ) { |
|
193 | + if (count($editable_roles) == 1) { |
|
194 | 194 | |
195 | 195 | $r = $this_json; |
196 | 196 | |
197 | 197 | } else { |
198 | 198 | |
199 | 199 | $r[] = array( |
200 | - 'text' => translate_user_role( $role_info['name'] ), |
|
200 | + 'text' => translate_user_role($role_info['name']), |
|
201 | 201 | 'children' => $this_json |
202 | 202 | ); |
203 | 203 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | function ajax_query() { |
231 | 231 | |
232 | 232 | // validate |
233 | - if( !acf_verify_ajax() ) { |
|
233 | + if ( ! acf_verify_ajax()) { |
|
234 | 234 | |
235 | 235 | die(); |
236 | 236 | |
@@ -238,11 +238,11 @@ discard block |
||
238 | 238 | |
239 | 239 | |
240 | 240 | // get choices |
241 | - $choices = $this->get_choices( $_POST ); |
|
241 | + $choices = $this->get_choices($_POST); |
|
242 | 242 | |
243 | 243 | |
244 | 244 | // validate |
245 | - if( !$choices ) { |
|
245 | + if ( ! $choices) { |
|
246 | 246 | |
247 | 247 | die(); |
248 | 248 | |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | |
251 | 251 | |
252 | 252 | // return JSON |
253 | - echo json_encode( $choices ); |
|
253 | + echo json_encode($choices); |
|
254 | 254 | die(); |
255 | 255 | |
256 | 256 | } |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | * @return (string) |
272 | 272 | */ |
273 | 273 | |
274 | - function get_result( $user, $field, $post_id = 0 ) { |
|
274 | + function get_result($user, $field, $post_id = 0) { |
|
275 | 275 | |
276 | 276 | // get post_id |
277 | - if( !$post_id ) { |
|
277 | + if ( ! $post_id) { |
|
278 | 278 | |
279 | 279 | $post_id = acf_get_setting('form_data/post_id', get_the_ID()); |
280 | 280 | |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | |
287 | 287 | |
288 | 288 | // append name |
289 | - if( $user->first_name ) { |
|
289 | + if ($user->first_name) { |
|
290 | 290 | |
291 | - $result .= ' (' . $user->first_name; |
|
291 | + $result .= ' ('.$user->first_name; |
|
292 | 292 | |
293 | - if( $user->last_name ) { |
|
293 | + if ($user->last_name) { |
|
294 | 294 | |
295 | - $result .= ' ' . $user->last_name; |
|
295 | + $result .= ' '.$user->last_name; |
|
296 | 296 | |
297 | 297 | } |
298 | 298 | |
@@ -302,9 +302,9 @@ discard block |
||
302 | 302 | |
303 | 303 | |
304 | 304 | // filters |
305 | - $result = apply_filters("acf/fields/user/result", $result, $user, $field, $post_id); |
|
306 | - $result = apply_filters("acf/fields/user/result/name={$field['_name']}", $result, $user, $field, $post_id); |
|
307 | - $result = apply_filters("acf/fields/user/result/key={$field['key']}", $result, $user, $field, $post_id); |
|
305 | + $result = apply_filters("acf/fields/user/result", $result, $user, $field, $post_id); |
|
306 | + $result = apply_filters("acf/fields/user/result/name={$field['_name']}", $result, $user, $field, $post_id); |
|
307 | + $result = apply_filters("acf/fields/user/result/key={$field['key']}", $result, $user, $field, $post_id); |
|
308 | 308 | |
309 | 309 | |
310 | 310 | // return |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | * @return $columns |
327 | 327 | */ |
328 | 328 | |
329 | - function user_search_columns( $columns, $search, $WP_User_Query ) { |
|
329 | + function user_search_columns($columns, $search, $WP_User_Query) { |
|
330 | 330 | |
331 | 331 | // bail early if no field |
332 | - if( empty($this->field) ) { |
|
332 | + if (empty($this->field)) { |
|
333 | 333 | |
334 | 334 | return $columns; |
335 | 335 | |
@@ -341,9 +341,9 @@ discard block |
||
341 | 341 | |
342 | 342 | |
343 | 343 | // filter for 3rd party customization |
344 | - $columns = apply_filters("acf/fields/user/search_columns", $columns, $search, $WP_User_Query, $field); |
|
345 | - $columns = apply_filters("acf/fields/user/search_columns/name={$field['_name']}", $columns, $search, $WP_User_Query, $field); |
|
346 | - $columns = apply_filters("acf/fields/user/search_columns/key={$field['key']}", $columns, $search, $WP_User_Query, $field); |
|
344 | + $columns = apply_filters("acf/fields/user/search_columns", $columns, $search, $WP_User_Query, $field); |
|
345 | + $columns = apply_filters("acf/fields/user/search_columns/name={$field['_name']}", $columns, $search, $WP_User_Query, $field); |
|
346 | + $columns = apply_filters("acf/fields/user/search_columns/key={$field['key']}", $columns, $search, $WP_User_Query, $field); |
|
347 | 347 | |
348 | 348 | |
349 | 349 | // return |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @param $field - an array holding all the field's data |
364 | 364 | */ |
365 | 365 | |
366 | - function render_field( $field ) { |
|
366 | + function render_field($field) { |
|
367 | 367 | |
368 | 368 | // Change Field into a select |
369 | 369 | $field['type'] = 'select'; |
@@ -373,10 +373,10 @@ discard block |
||
373 | 373 | |
374 | 374 | |
375 | 375 | // populate choices |
376 | - if( !empty($field['value']) ) { |
|
376 | + if ( ! empty($field['value'])) { |
|
377 | 377 | |
378 | 378 | // force value to array |
379 | - $field['value'] = acf_get_array( $field['value'] ); |
|
379 | + $field['value'] = acf_get_array($field['value']); |
|
380 | 380 | |
381 | 381 | |
382 | 382 | // convert values to int |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | )); |
389 | 389 | |
390 | 390 | |
391 | - if( !empty($users) ) { |
|
391 | + if ( ! empty($users)) { |
|
392 | 392 | |
393 | - foreach( $users as $user ) { |
|
393 | + foreach ($users as $user) { |
|
394 | 394 | |
395 | - $field['choices'][ $user->ID ] = $this->get_result( $user, $field ); |
|
395 | + $field['choices'][$user->ID] = $this->get_result($user, $field); |
|
396 | 396 | |
397 | 397 | } |
398 | 398 | |
@@ -402,7 +402,7 @@ discard block |
||
402 | 402 | |
403 | 403 | |
404 | 404 | // render |
405 | - acf_render_field( $field ); |
|
405 | + acf_render_field($field); |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
@@ -420,21 +420,21 @@ discard block |
||
420 | 420 | * @param $field - an array holding all the field's data |
421 | 421 | */ |
422 | 422 | |
423 | - function render_field_settings( $field ) { |
|
423 | + function render_field_settings($field) { |
|
424 | 424 | |
425 | 425 | // role |
426 | 426 | $choices = array(); |
427 | 427 | $editable_roles = get_editable_roles(); |
428 | 428 | |
429 | - foreach( $editable_roles as $role => $details ) { |
|
429 | + foreach ($editable_roles as $role => $details) { |
|
430 | 430 | |
431 | 431 | // only translate the output not the value |
432 | - $choices[ $role ] = translate_user_role( $details['name'] ); |
|
432 | + $choices[$role] = translate_user_role($details['name']); |
|
433 | 433 | |
434 | 434 | } |
435 | 435 | |
436 | - acf_render_field_setting( $field, array( |
|
437 | - 'label' => __('Filter by role','acf'), |
|
436 | + acf_render_field_setting($field, array( |
|
437 | + 'label' => __('Filter by role', 'acf'), |
|
438 | 438 | 'instructions' => '', |
439 | 439 | 'type' => 'select', |
440 | 440 | 'name' => 'role', |
@@ -442,34 +442,34 @@ discard block |
||
442 | 442 | 'multiple' => 1, |
443 | 443 | 'ui' => 1, |
444 | 444 | 'allow_null' => 1, |
445 | - 'placeholder' => __("All user roles",'acf'), |
|
445 | + 'placeholder' => __("All user roles", 'acf'), |
|
446 | 446 | )); |
447 | 447 | |
448 | 448 | |
449 | 449 | |
450 | 450 | // allow_null |
451 | - acf_render_field_setting( $field, array( |
|
452 | - 'label' => __('Allow Null?','acf'), |
|
451 | + acf_render_field_setting($field, array( |
|
452 | + 'label' => __('Allow Null?', 'acf'), |
|
453 | 453 | 'instructions' => '', |
454 | 454 | 'type' => 'radio', |
455 | 455 | 'name' => 'allow_null', |
456 | 456 | 'choices' => array( |
457 | - 1 => __("Yes",'acf'), |
|
458 | - 0 => __("No",'acf'), |
|
457 | + 1 => __("Yes", 'acf'), |
|
458 | + 0 => __("No", 'acf'), |
|
459 | 459 | ), |
460 | 460 | 'layout' => 'horizontal', |
461 | 461 | )); |
462 | 462 | |
463 | 463 | |
464 | 464 | // multiple |
465 | - acf_render_field_setting( $field, array( |
|
466 | - 'label' => __('Select multiple values?','acf'), |
|
465 | + acf_render_field_setting($field, array( |
|
466 | + 'label' => __('Select multiple values?', 'acf'), |
|
467 | 467 | 'instructions' => '', |
468 | 468 | 'type' => 'radio', |
469 | 469 | 'name' => 'multiple', |
470 | 470 | 'choices' => array( |
471 | - 1 => __("Yes",'acf'), |
|
472 | - 0 => __("No",'acf'), |
|
471 | + 1 => __("Yes", 'acf'), |
|
472 | + 0 => __("No", 'acf'), |
|
473 | 473 | ), |
474 | 474 | 'layout' => 'horizontal', |
475 | 475 | )); |
@@ -494,17 +494,17 @@ discard block |
||
494 | 494 | * @return $value - the modified value |
495 | 495 | */ |
496 | 496 | |
497 | - function update_value( $value, $post_id, $field ) { |
|
497 | + function update_value($value, $post_id, $field) { |
|
498 | 498 | |
499 | 499 | // array? |
500 | - if( is_array($value) && isset($value['ID']) ) { |
|
500 | + if (is_array($value) && isset($value['ID'])) { |
|
501 | 501 | |
502 | 502 | $value = $value['ID']; |
503 | 503 | |
504 | 504 | } |
505 | 505 | |
506 | 506 | // object? |
507 | - if( is_object($value) && isset($value->ID) ) { |
|
507 | + if (is_object($value) && isset($value->ID)) { |
|
508 | 508 | |
509 | 509 | $value = $value->ID; |
510 | 510 | |
@@ -531,10 +531,10 @@ discard block |
||
531 | 531 | * @return $value |
532 | 532 | */ |
533 | 533 | |
534 | - function load_value( $value, $post_id, $field ) { |
|
534 | + function load_value($value, $post_id, $field) { |
|
535 | 535 | |
536 | 536 | // ACF4 null |
537 | - if( $value === 'null' ) { |
|
537 | + if ($value === 'null') { |
|
538 | 538 | |
539 | 539 | return false; |
540 | 540 | |
@@ -562,10 +562,10 @@ discard block |
||
562 | 562 | * @return $value (mixed) the modified value |
563 | 563 | */ |
564 | 564 | |
565 | - function format_value( $value, $post_id, $field ) { |
|
565 | + function format_value($value, $post_id, $field) { |
|
566 | 566 | |
567 | 567 | // bail early if no value |
568 | - if( empty($value) ) { |
|
568 | + if (empty($value)) { |
|
569 | 569 | |
570 | 570 | return $value; |
571 | 571 | |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | |
574 | 574 | |
575 | 575 | // force value to array |
576 | - $value = acf_get_array( $value ); |
|
576 | + $value = acf_get_array($value); |
|
577 | 577 | |
578 | 578 | |
579 | 579 | // convert values to int |
@@ -581,41 +581,41 @@ discard block |
||
581 | 581 | |
582 | 582 | |
583 | 583 | // load users |
584 | - foreach( array_keys($value) as $i ) { |
|
584 | + foreach (array_keys($value) as $i) { |
|
585 | 585 | |
586 | 586 | // vars |
587 | - $user_id = $value[ $i ]; |
|
588 | - $user_data = get_userdata( $user_id ); |
|
587 | + $user_id = $value[$i]; |
|
588 | + $user_data = get_userdata($user_id); |
|
589 | 589 | |
590 | 590 | |
591 | 591 | //cope with deleted users by @adampope |
592 | - if( !is_object($user_data) ) { |
|
592 | + if ( ! is_object($user_data)) { |
|
593 | 593 | |
594 | - unset( $value[ $i ] ); |
|
594 | + unset($value[$i]); |
|
595 | 595 | continue; |
596 | 596 | |
597 | 597 | } |
598 | 598 | |
599 | 599 | |
600 | 600 | // append to array |
601 | - $value[ $i ] = array(); |
|
602 | - $value[ $i ]['ID'] = $user_id; |
|
603 | - $value[ $i ]['user_firstname'] = $user_data->user_firstname; |
|
604 | - $value[ $i ]['user_lastname'] = $user_data->user_lastname; |
|
605 | - $value[ $i ]['nickname'] = $user_data->nickname; |
|
606 | - $value[ $i ]['user_nicename'] = $user_data->user_nicename; |
|
607 | - $value[ $i ]['display_name'] = $user_data->display_name; |
|
608 | - $value[ $i ]['user_email'] = $user_data->user_email; |
|
609 | - $value[ $i ]['user_url'] = $user_data->user_url; |
|
610 | - $value[ $i ]['user_registered'] = $user_data->user_registered; |
|
611 | - $value[ $i ]['user_description'] = $user_data->user_description; |
|
612 | - $value[ $i ]['user_avatar'] = get_avatar( $user_id ); |
|
601 | + $value[$i] = array(); |
|
602 | + $value[$i]['ID'] = $user_id; |
|
603 | + $value[$i]['user_firstname'] = $user_data->user_firstname; |
|
604 | + $value[$i]['user_lastname'] = $user_data->user_lastname; |
|
605 | + $value[$i]['nickname'] = $user_data->nickname; |
|
606 | + $value[$i]['user_nicename'] = $user_data->user_nicename; |
|
607 | + $value[$i]['display_name'] = $user_data->display_name; |
|
608 | + $value[$i]['user_email'] = $user_data->user_email; |
|
609 | + $value[$i]['user_url'] = $user_data->user_url; |
|
610 | + $value[$i]['user_registered'] = $user_data->user_registered; |
|
611 | + $value[$i]['user_description'] = $user_data->user_description; |
|
612 | + $value[$i]['user_avatar'] = get_avatar($user_id); |
|
613 | 613 | |
614 | 614 | } |
615 | 615 | |
616 | 616 | |
617 | 617 | // convert back from array if neccessary |
618 | - if( !$field['multiple'] ) { |
|
618 | + if ( ! $field['multiple']) { |
|
619 | 619 | |
620 | 620 | $value = array_shift($value); |
621 | 621 |
@@ -44,7 +44,7 @@ |
||
44 | 44 | |
45 | 45 | |
46 | 46 | // do not delete! |
47 | - parent::__construct(); |
|
47 | + parent::__construct(); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | ); |
45 | 45 | |
46 | 46 | |
47 | - // Create an acf version of the_content filter (acf_the_content) |
|
47 | + // Create an acf version of the_content filter (acf_the_content) |
|
48 | 48 | if( !empty($GLOBALS['wp_embed']) ) { |
49 | 49 | |
50 | 50 | add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | |
75 | 75 | // do not delete! |
76 | - parent::__construct(); |
|
76 | + parent::__construct(); |
|
77 | 77 | |
78 | 78 | } |
79 | 79 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @subpackage Fields |
12 | 12 | */ |
13 | 13 | |
14 | -if( ! class_exists('acf_field_wysiwyg') ) : |
|
14 | +if ( ! class_exists('acf_field_wysiwyg')) : |
|
15 | 15 | |
16 | 16 | class acf_field_wysiwyg extends acf_field { |
17 | 17 | |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | // vars |
36 | 36 | $this->name = 'wysiwyg'; |
37 | - $this->label = __("Wysiwyg Editor",'acf'); |
|
37 | + $this->label = __("Wysiwyg Editor", 'acf'); |
|
38 | 38 | $this->category = 'content'; |
39 | 39 | $this->defaults = array( |
40 | 40 | 'tabs' => 'all', |
@@ -45,31 +45,31 @@ discard block |
||
45 | 45 | |
46 | 46 | |
47 | 47 | // Create an acf version of the_content filter (acf_the_content) |
48 | - if( !empty($GLOBALS['wp_embed']) ) { |
|
48 | + if ( ! empty($GLOBALS['wp_embed'])) { |
|
49 | 49 | |
50 | - add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'run_shortcode' ), 8 ); |
|
51 | - add_filter( 'acf_the_content', array( $GLOBALS['wp_embed'], 'autoembed' ), 8 ); |
|
50 | + add_filter('acf_the_content', array($GLOBALS['wp_embed'], 'run_shortcode'), 8); |
|
51 | + add_filter('acf_the_content', array($GLOBALS['wp_embed'], 'autoembed'), 8); |
|
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | - add_filter( 'acf_the_content', 'capital_P_dangit', 11 ); |
|
56 | - add_filter( 'acf_the_content', 'wptexturize' ); |
|
57 | - add_filter( 'acf_the_content', 'convert_smilies' ); |
|
58 | - add_filter( 'acf_the_content', 'convert_chars' ); // not found in WP 4.4 |
|
59 | - add_filter( 'acf_the_content', 'wpautop' ); |
|
60 | - add_filter( 'acf_the_content', 'shortcode_unautop' ); |
|
55 | + add_filter('acf_the_content', 'capital_P_dangit', 11); |
|
56 | + add_filter('acf_the_content', 'wptexturize'); |
|
57 | + add_filter('acf_the_content', 'convert_smilies'); |
|
58 | + add_filter('acf_the_content', 'convert_chars'); // not found in WP 4.4 |
|
59 | + add_filter('acf_the_content', 'wpautop'); |
|
60 | + add_filter('acf_the_content', 'shortcode_unautop'); |
|
61 | 61 | //add_filter( 'acf_the_content', 'prepend_attachment' ); should only be for the_content (causes double image on attachment page) |
62 | - if( function_exists('wp_make_content_images_responsive') ) { |
|
62 | + if (function_exists('wp_make_content_images_responsive')) { |
|
63 | 63 | |
64 | - add_filter( 'acf_the_content', 'wp_make_content_images_responsive' ); // added in WP 4.4 |
|
64 | + add_filter('acf_the_content', 'wp_make_content_images_responsive'); // added in WP 4.4 |
|
65 | 65 | |
66 | 66 | } |
67 | 67 | |
68 | - add_filter( 'acf_the_content', 'do_shortcode', 11); |
|
68 | + add_filter('acf_the_content', 'do_shortcode', 11); |
|
69 | 69 | |
70 | 70 | |
71 | 71 | // actions |
72 | - add_action('acf/input/admin_footer_js', array($this, 'input_admin_footer_js')); |
|
72 | + add_action('acf/input/admin_footer_js', array($this, 'input_admin_footer_js')); |
|
73 | 73 | |
74 | 74 | |
75 | 75 | // do not delete! |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | $editor_id = 'acf_content'; |
103 | 103 | |
104 | 104 | |
105 | - if( version_compare($wp_version, '3.9', '>=' ) ) { |
|
105 | + if (version_compare($wp_version, '3.9', '>=')) { |
|
106 | 106 | |
107 | 107 | // Full |
108 | 108 | $toolbars['Full'] = array( |
109 | 109 | |
110 | - 1 => apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id), |
|
110 | + 1 => apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'hr', 'alignleft', 'aligncenter', 'alignright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv'), $editor_id), |
|
111 | 111 | |
112 | - 2 => apply_filters('mce_buttons_2', array( 'formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' ), $editor_id), |
|
112 | + 2 => apply_filters('mce_buttons_2', array('formatselect', 'underline', 'alignjustify', 'forecolor', 'pastetext', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help'), $editor_id), |
|
113 | 113 | |
114 | 114 | 3 => apply_filters('mce_buttons_3', array(), $editor_id), |
115 | 115 | |
@@ -130,9 +130,9 @@ discard block |
||
130 | 130 | // Full |
131 | 131 | $toolbars['Full'] = array( |
132 | 132 | |
133 | - 1 => apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv' ), $editor_id), |
|
133 | + 1 => apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', 'bullist', 'numlist', 'blockquote', 'justifyleft', 'justifycenter', 'justifyright', 'link', 'unlink', 'wp_more', 'spellchecker', 'fullscreen', 'wp_adv'), $editor_id), |
|
134 | 134 | |
135 | - 2 => apply_filters('mce_buttons_2', array( 'formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help' ), $editor_id), |
|
135 | + 2 => apply_filters('mce_buttons_2', array('formatselect', 'underline', 'justifyfull', 'forecolor', 'pastetext', 'pasteword', 'removeformat', 'charmap', 'outdent', 'indent', 'undo', 'redo', 'wp_help'), $editor_id), |
|
136 | 136 | |
137 | 137 | 3 => apply_filters('mce_buttons_3', array(), $editor_id), |
138 | 138 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | // Basic |
145 | 145 | $toolbars['Basic'] = array( |
146 | 146 | |
147 | - 1 => apply_filters( 'teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id ), |
|
147 | + 1 => apply_filters('teeny_mce_buttons', array('bold', 'italic', 'underline', 'blockquote', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'undo', 'redo', 'link', 'unlink', 'fullscreen'), $editor_id), |
|
148 | 148 | |
149 | 149 | ); |
150 | 150 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | |
154 | 154 | // Filter for 3rd party |
155 | - $toolbars = apply_filters( 'acf/fields/wysiwyg/toolbars', $toolbars ); |
|
155 | + $toolbars = apply_filters('acf/fields/wysiwyg/toolbars', $toolbars); |
|
156 | 156 | |
157 | 157 | |
158 | 158 | // return |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | |
183 | 183 | |
184 | 184 | // bail ealry if no toolbars |
185 | - if( empty($toolbars) ) { |
|
185 | + if (empty($toolbars)) { |
|
186 | 186 | |
187 | 187 | return; |
188 | 188 | |
@@ -190,23 +190,23 @@ discard block |
||
190 | 190 | |
191 | 191 | |
192 | 192 | // loop through toolbars |
193 | - foreach( $toolbars as $label => $rows ) { |
|
193 | + foreach ($toolbars as $label => $rows) { |
|
194 | 194 | |
195 | 195 | // vars |
196 | - $label = sanitize_title( $label ); |
|
196 | + $label = sanitize_title($label); |
|
197 | 197 | $label = str_replace('-', '_', $label); |
198 | 198 | |
199 | 199 | |
200 | 200 | // append to $json |
201 | - $json[ $label ] = array(); |
|
201 | + $json[$label] = array(); |
|
202 | 202 | |
203 | 203 | |
204 | 204 | // convert to strings |
205 | - if( !empty($rows) ) { |
|
205 | + if ( ! empty($rows)) { |
|
206 | 206 | |
207 | - foreach( $rows as $i => $row ) { |
|
207 | + foreach ($rows as $i => $row) { |
|
208 | 208 | |
209 | - $json[ $label ][ $i ] = implode(',', $row); |
|
209 | + $json[$label][$i] = implode(',', $row); |
|
210 | 210 | |
211 | 211 | } |
212 | 212 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | * @date 23/01/13 |
234 | 234 | */ |
235 | 235 | |
236 | - function render_field( $field ) { |
|
236 | + function render_field($field) { |
|
237 | 237 | |
238 | 238 | // global |
239 | 239 | global $wp_version; |
@@ -252,22 +252,22 @@ discard block |
||
252 | 252 | |
253 | 253 | // get height |
254 | 254 | $height = acf_get_user_setting('wysiwyg_height', 300); |
255 | - $height = max( $height, 300 ); // minimum height is 300 |
|
255 | + $height = max($height, 300); // minimum height is 300 |
|
256 | 256 | |
257 | 257 | |
258 | 258 | // detect mode |
259 | - if( $field['tabs'] == 'visual' ) { |
|
259 | + if ($field['tabs'] == 'visual') { |
|
260 | 260 | |
261 | 261 | // case: visual tab only |
262 | 262 | $default_editor = 'tinymce'; |
263 | 263 | $show_tabs = false; |
264 | 264 | |
265 | - } elseif( $field['tabs'] == 'text' ) { |
|
265 | + } elseif ($field['tabs'] == 'text') { |
|
266 | 266 | |
267 | 267 | // case: text tab only |
268 | 268 | $show_tabs = false; |
269 | 269 | |
270 | - } elseif( wp_default_editor() == 'tinymce' ) { |
|
270 | + } elseif (wp_default_editor() == 'tinymce') { |
|
271 | 271 | |
272 | 272 | // case: both tabs |
273 | 273 | $default_editor = 'tinymce'; |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | |
277 | 277 | |
278 | 278 | // must be logged in tp upload |
279 | - if( !current_user_can('upload_files') ) { |
|
279 | + if ( ! current_user_can('upload_files')) { |
|
280 | 280 | |
281 | 281 | $field['media_upload'] = 0; |
282 | 282 | |
@@ -288,17 +288,17 @@ discard block |
||
288 | 288 | |
289 | 289 | |
290 | 290 | // filter value for editor |
291 | - remove_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 ); |
|
292 | - remove_filter( 'acf_the_editor_content', 'wp_htmledit_pre', 10, 1 ); |
|
293 | - remove_filter( 'acf_the_editor_content', 'wp_richedit_pre', 10, 1 ); |
|
291 | + remove_filter('acf_the_editor_content', 'format_for_editor', 10, 2); |
|
292 | + remove_filter('acf_the_editor_content', 'wp_htmledit_pre', 10, 1); |
|
293 | + remove_filter('acf_the_editor_content', 'wp_richedit_pre', 10, 1); |
|
294 | 294 | |
295 | 295 | |
296 | 296 | // WP 4.3 |
297 | - if( version_compare($wp_version, '4.3', '>=' ) ) { |
|
297 | + if (version_compare($wp_version, '4.3', '>=')) { |
|
298 | 298 | |
299 | - add_filter( 'acf_the_editor_content', 'format_for_editor', 10, 2 ); |
|
299 | + add_filter('acf_the_editor_content', 'format_for_editor', 10, 2); |
|
300 | 300 | |
301 | - $button = 'data-wp-editor-id="' . $id . '"'; |
|
301 | + $button = 'data-wp-editor-id="'.$id.'"'; |
|
302 | 302 | |
303 | 303 | // WP < 4.3 |
304 | 304 | } else { |
@@ -313,25 +313,25 @@ discard block |
||
313 | 313 | |
314 | 314 | |
315 | 315 | // filter |
316 | - $field['value'] = apply_filters( 'acf_the_editor_content', $field['value'], $default_editor ); |
|
316 | + $field['value'] = apply_filters('acf_the_editor_content', $field['value'], $default_editor); |
|
317 | 317 | |
318 | 318 | ?> |
319 | 319 | <div id="wp-<?php echo $id; ?>-wrap" class="acf-editor-wrap wp-core-ui wp-editor-wrap <?php echo $switch_class; ?>" data-toolbar="<?php echo $field['toolbar']; ?>" data-upload="<?php echo $field['media_upload']; ?>"> |
320 | 320 | <div id="wp-<?php echo $id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js"> |
321 | - <?php if( $field['media_upload'] ): ?> |
|
321 | + <?php if ($field['media_upload']): ?> |
|
322 | 322 | <div id="wp-<?php echo $id; ?>-media-buttons" class="wp-media-buttons"> |
323 | - <?php do_action( 'media_buttons', $id ); ?> |
|
323 | + <?php do_action('media_buttons', $id); ?> |
|
324 | 324 | </div> |
325 | 325 | <?php endif; ?> |
326 | - <?php if( user_can_richedit() && $show_tabs ): ?> |
|
326 | + <?php if (user_can_richedit() && $show_tabs): ?> |
|
327 | 327 | <div class="wp-editor-tabs"> |
328 | 328 | <button id="<?php echo $id; ?>-tmce" class="wp-switch-editor switch-tmce" <?php echo $button; ?> type="button"><?php echo __('Visual', 'acf'); ?></button> |
329 | - <button id="<?php echo $id; ?>-html" class="wp-switch-editor switch-html" <?php echo $button; ?> type="button"><?php echo _x( 'Text', 'Name for the Text editor tab (formerly HTML)', 'acf' ); ?></button> |
|
329 | + <button id="<?php echo $id; ?>-html" class="wp-switch-editor switch-html" <?php echo $button; ?> type="button"><?php echo _x('Text', 'Name for the Text editor tab (formerly HTML)', 'acf'); ?></button> |
|
330 | 330 | </div> |
331 | 331 | <?php endif; ?> |
332 | 332 | </div> |
333 | 333 | <div id="wp-<?php echo $id; ?>-editor-container" class="wp-editor-container"> |
334 | - <textarea id="<?php echo $id; ?>" class="wp-editor-area" name="<?php echo $field['name']; ?>" <?php if($height): ?>style="height:<?php echo $height; ?>px;"<?php endif; ?>><?php echo $field['value']; ?></textarea> |
|
334 | + <textarea id="<?php echo $id; ?>" class="wp-editor-area" name="<?php echo $field['name']; ?>" <?php if ($height): ?>style="height:<?php echo $height; ?>px;"<?php endif; ?>><?php echo $field['value']; ?></textarea> |
|
335 | 335 | </div> |
336 | 336 | </div> |
337 | 337 | <?php |
@@ -352,51 +352,51 @@ discard block |
||
352 | 352 | * @param $field - an array holding all the field's data |
353 | 353 | */ |
354 | 354 | |
355 | - function render_field_settings( $field ) { |
|
355 | + function render_field_settings($field) { |
|
356 | 356 | |
357 | 357 | // vars |
358 | 358 | $toolbars = $this->get_toolbars(); |
359 | 359 | $choices = array(); |
360 | 360 | |
361 | - if( !empty($toolbars) ) { |
|
361 | + if ( ! empty($toolbars)) { |
|
362 | 362 | |
363 | - foreach( $toolbars as $k => $v ) { |
|
363 | + foreach ($toolbars as $k => $v) { |
|
364 | 364 | |
365 | 365 | $label = $k; |
366 | - $name = sanitize_title( $label ); |
|
366 | + $name = sanitize_title($label); |
|
367 | 367 | $name = str_replace('-', '_', $name); |
368 | 368 | |
369 | - $choices[ $name ] = $label; |
|
369 | + $choices[$name] = $label; |
|
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | 373 | |
374 | 374 | // default_value |
375 | - acf_render_field_setting( $field, array( |
|
376 | - 'label' => __('Default Value','acf'), |
|
377 | - 'instructions' => __('Appears when creating a new post','acf'), |
|
375 | + acf_render_field_setting($field, array( |
|
376 | + 'label' => __('Default Value', 'acf'), |
|
377 | + 'instructions' => __('Appears when creating a new post', 'acf'), |
|
378 | 378 | 'type' => 'textarea', |
379 | 379 | 'name' => 'default_value', |
380 | 380 | )); |
381 | 381 | |
382 | 382 | |
383 | 383 | // tabs |
384 | - acf_render_field_setting( $field, array( |
|
385 | - 'label' => __('Tabs','acf'), |
|
384 | + acf_render_field_setting($field, array( |
|
385 | + 'label' => __('Tabs', 'acf'), |
|
386 | 386 | 'instructions' => '', |
387 | 387 | 'type' => 'select', |
388 | 388 | 'name' => 'tabs', |
389 | 389 | 'choices' => array( |
390 | - 'all' => __("Visual & Text",'acf'), |
|
391 | - 'visual' => __("Visual Only",'acf'), |
|
392 | - 'text' => __("Text Only",'acf'), |
|
390 | + 'all' => __("Visual & Text", 'acf'), |
|
391 | + 'visual' => __("Visual Only", 'acf'), |
|
392 | + 'text' => __("Text Only", 'acf'), |
|
393 | 393 | ) |
394 | 394 | )); |
395 | 395 | |
396 | 396 | |
397 | 397 | // toolbar |
398 | - acf_render_field_setting( $field, array( |
|
399 | - 'label' => __('Toolbar','acf'), |
|
398 | + acf_render_field_setting($field, array( |
|
399 | + 'label' => __('Toolbar', 'acf'), |
|
400 | 400 | 'instructions' => '', |
401 | 401 | 'type' => 'select', |
402 | 402 | 'name' => 'toolbar', |
@@ -405,15 +405,15 @@ discard block |
||
405 | 405 | |
406 | 406 | |
407 | 407 | // media_upload |
408 | - acf_render_field_setting( $field, array( |
|
409 | - 'label' => __('Show Media Upload Buttons?','acf'), |
|
408 | + acf_render_field_setting($field, array( |
|
409 | + 'label' => __('Show Media Upload Buttons?', 'acf'), |
|
410 | 410 | 'instructions' => '', |
411 | 411 | 'type' => 'radio', |
412 | 412 | 'name' => 'media_upload', |
413 | 413 | 'layout' => 'horizontal', |
414 | 414 | 'choices' => array( |
415 | - 1 => __("Yes",'acf'), |
|
416 | - 0 => __("No",'acf'), |
|
415 | + 1 => __("Yes", 'acf'), |
|
416 | + 0 => __("No", 'acf'), |
|
417 | 417 | ) |
418 | 418 | )); |
419 | 419 | |
@@ -436,10 +436,10 @@ discard block |
||
436 | 436 | * @return $value (mixed) the modified value |
437 | 437 | */ |
438 | 438 | |
439 | - function format_value( $value, $post_id, $field ) { |
|
439 | + function format_value($value, $post_id, $field) { |
|
440 | 440 | |
441 | 441 | // bail early if no value |
442 | - if( empty($value) ) { |
|
442 | + if (empty($value)) { |
|
443 | 443 | |
444 | 444 | return $value; |
445 | 445 | |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | |
448 | 448 | |
449 | 449 | // apply filters |
450 | - $value = apply_filters( 'acf_the_content', $value ); |
|
450 | + $value = apply_filters('acf_the_content', $value); |
|
451 | 451 | |
452 | 452 | |
453 | 453 | // follow the_content function in /wp-includes/post-template.php |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | |
248 | 248 | |
249 | 249 | $form_fields[ 'acf-form-data' ] = array( |
250 | - 'label' => '', |
|
250 | + 'label' => '', |
|
251 | 251 | 'input' => 'html', |
252 | 252 | 'html' => $html |
253 | 253 | ); |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | } |
285 | 285 | |
286 | 286 | |
287 | - // validate and save |
|
288 | - if( acf_validate_save_post(true) ) { |
|
287 | + // validate and save |
|
288 | + if( acf_validate_save_post(true) ) { |
|
289 | 289 | |
290 | 290 | acf_save_post( $post['ID'] ); |
291 | 291 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Forms |
11 | 11 | */ |
12 | 12 | |
13 | -if( ! class_exists('acf_form_attachment') ) : |
|
13 | +if ( ! class_exists('acf_form_attachment')) : |
|
14 | 14 | |
15 | 15 | class acf_form_attachment { |
16 | 16 | |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | function __construct() { |
32 | 32 | |
33 | 33 | // actions |
34 | - add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
34 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | // render |
38 | - add_filter('attachment_fields_to_edit', array($this, 'edit_attachment'), 10, 2); |
|
38 | + add_filter('attachment_fields_to_edit', array($this, 'edit_attachment'), 10, 2); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // save |
42 | - add_filter('attachment_fields_to_save', array($this, 'save_attachment'), 10, 2); |
|
42 | + add_filter('attachment_fields_to_save', array($this, 'save_attachment'), 10, 2); |
|
43 | 43 | |
44 | 44 | } |
45 | 45 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | |
65 | 65 | |
66 | 66 | // validate page |
67 | - if( $pagenow === 'post.php' && $typenow === 'attachment' ) { |
|
67 | + if ($pagenow === 'post.php' && $typenow === 'attachment') { |
|
68 | 68 | |
69 | 69 | return true; |
70 | 70 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | |
74 | 74 | // validate page |
75 | - if( $pagenow === 'upload.php' && version_compare($wp_version, '4.0', '>=') ) { |
|
75 | + if ($pagenow === 'upload.php' && version_compare($wp_version, '4.0', '>=')) { |
|
76 | 76 | |
77 | 77 | add_action('admin_footer', array($this, 'admin_footer'), 0); |
78 | 78 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | function admin_enqueue_scripts() { |
104 | 104 | |
105 | 105 | // bail early if not valid page |
106 | - if( !$this->validate_page() ) { |
|
106 | + if ( ! $this->validate_page()) { |
|
107 | 107 | |
108 | 108 | return; |
109 | 109 | |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | * @return $post_id (int) |
155 | 155 | */ |
156 | 156 | |
157 | - function edit_attachment( $form_fields, $post ) { |
|
157 | + function edit_attachment($form_fields, $post) { |
|
158 | 158 | |
159 | 159 | // vars |
160 | 160 | $el = 'tr'; |
@@ -165,18 +165,18 @@ discard block |
||
165 | 165 | |
166 | 166 | |
167 | 167 | // $el |
168 | - if( $this->validate_page() ) { |
|
168 | + if ($this->validate_page()) { |
|
169 | 169 | |
170 | 170 | //$el = 'div'; |
171 | 171 | |
172 | 172 | } |
173 | 173 | |
174 | 174 | // get field groups |
175 | - $field_groups = acf_get_field_groups( $args ); |
|
175 | + $field_groups = acf_get_field_groups($args); |
|
176 | 176 | |
177 | 177 | |
178 | 178 | // render |
179 | - if( !empty($field_groups) ) { |
|
179 | + if ( ! empty($field_groups)) { |
|
180 | 180 | |
181 | 181 | // get acf_form_data |
182 | 182 | ob_start(); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | )); |
189 | 189 | |
190 | 190 | |
191 | - if( $this->validate_page() ) { |
|
191 | + if ($this->validate_page()) { |
|
192 | 192 | |
193 | 193 | echo '<style type="text/css"> |
194 | 194 | .compat-attachment-fields, |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | //} |
224 | 224 | |
225 | 225 | |
226 | - foreach( $field_groups as $field_group ) { |
|
226 | + foreach ($field_groups as $field_group) { |
|
227 | 227 | |
228 | - $fields = acf_get_fields( $field_group ); |
|
228 | + $fields = acf_get_fields($field_group); |
|
229 | 229 | |
230 | - acf_render_fields( $post_id, $fields, $el, 'field' ); |
|
230 | + acf_render_fields($post_id, $fields, $el, 'field'); |
|
231 | 231 | |
232 | 232 | } |
233 | 233 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | ob_end_clean(); |
247 | 247 | |
248 | 248 | |
249 | - $form_fields[ 'acf-form-data' ] = array( |
|
249 | + $form_fields['acf-form-data'] = array( |
|
250 | 250 | 'label' => '', |
251 | 251 | 'input' => 'html', |
252 | 252 | 'html' => $html |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | * @return $post_id (int) |
275 | 275 | */ |
276 | 276 | |
277 | - function save_attachment( $post, $attachment ) { |
|
277 | + function save_attachment($post, $attachment) { |
|
278 | 278 | |
279 | 279 | // bail early if not valid nonce |
280 | - if( ! acf_verify_nonce('attachment') ) { |
|
280 | + if ( ! acf_verify_nonce('attachment')) { |
|
281 | 281 | |
282 | 282 | return $post; |
283 | 283 | |
@@ -285,9 +285,9 @@ discard block |
||
285 | 285 | |
286 | 286 | |
287 | 287 | // validate and save |
288 | - if( acf_validate_save_post(true) ) { |
|
288 | + if (acf_validate_save_post(true)) { |
|
289 | 289 | |
290 | - acf_save_post( $post['ID'] ); |
|
290 | + acf_save_post($post['ID']); |
|
291 | 291 | |
292 | 292 | } |
293 | 293 |
@@ -258,8 +258,8 @@ |
||
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | - // validate and save |
|
262 | - if( acf_validate_save_post(true) ) { |
|
261 | + // validate and save |
|
262 | + if( acf_validate_save_post(true) ) { |
|
263 | 263 | |
264 | 264 | acf_save_post( "comment_{$comment_id}" ); |
265 | 265 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Forms |
11 | 11 | */ |
12 | 12 | |
13 | -if( ! class_exists('acf_form_comment') ) : |
|
13 | +if ( ! class_exists('acf_form_comment')) : |
|
14 | 14 | |
15 | 15 | class acf_form_comment { |
16 | 16 | |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | function __construct() { |
32 | 32 | |
33 | 33 | // actions |
34 | - add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); |
|
34 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
35 | 35 | |
36 | 36 | |
37 | 37 | // render |
38 | - add_action( 'comment_form_logged_in_after', array( $this, 'add_comment') ); |
|
39 | - add_action( 'comment_form_after_fields', array( $this, 'add_comment') ); |
|
38 | + add_action('comment_form_logged_in_after', array($this, 'add_comment')); |
|
39 | + add_action('comment_form_after_fields', array($this, 'add_comment')); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | // save |
43 | - add_action( 'edit_comment', array( $this, 'save_comment' ), 10, 1 ); |
|
44 | - add_action( 'comment_post', array( $this, 'save_comment' ), 10, 1 ); |
|
43 | + add_action('edit_comment', array($this, 'save_comment'), 10, 1); |
|
44 | + add_action('comment_post', array($this, 'save_comment'), 10, 1); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | |
68 | 68 | // validate page |
69 | - if( $pagenow == 'comment.php' ) { |
|
69 | + if ($pagenow == 'comment.php') { |
|
70 | 70 | |
71 | 71 | return true; |
72 | 72 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | function admin_enqueue_scripts() { |
96 | 96 | |
97 | 97 | // validate page |
98 | - if( ! $this->validate_page() ) { |
|
98 | + if ( ! $this->validate_page()) { |
|
99 | 99 | |
100 | 100 | return; |
101 | 101 | |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | |
108 | 108 | |
109 | 109 | // actions |
110 | - add_action('admin_footer', array($this, 'admin_footer'), 10, 1); |
|
111 | - add_action('add_meta_boxes_comment', array($this, 'edit_comment'), 10, 1); |
|
110 | + add_action('admin_footer', array($this, 'admin_footer'), 10, 1); |
|
111 | + add_action('add_meta_boxes_comment', array($this, 'edit_comment'), 10, 1); |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return n/a |
127 | 127 | */ |
128 | 128 | |
129 | - function edit_comment( $comment ) { |
|
129 | + function edit_comment($comment) { |
|
130 | 130 | |
131 | 131 | // vars |
132 | 132 | $post_id = "comment_{$comment->comment_ID}"; |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | |
141 | 141 | // render |
142 | - if( !empty($field_groups) ) { |
|
142 | + if ( ! empty($field_groups)) { |
|
143 | 143 | |
144 | 144 | // render post data |
145 | 145 | acf_form_data(array( |
@@ -148,15 +148,15 @@ discard block |
||
148 | 148 | )); |
149 | 149 | |
150 | 150 | |
151 | - foreach( $field_groups as $field_group ) { |
|
151 | + foreach ($field_groups as $field_group) { |
|
152 | 152 | |
153 | 153 | // load fields |
154 | - $fields = acf_get_fields( $field_group ); |
|
154 | + $fields = acf_get_fields($field_group); |
|
155 | 155 | |
156 | 156 | |
157 | 157 | // vars |
158 | 158 | $o = array( |
159 | - 'id' => 'acf-' . $field_group['ID'], |
|
159 | + 'id' => 'acf-'.$field_group['ID'], |
|
160 | 160 | 'key' => $field_group['key'], |
161 | 161 | 'label' => $field_group['label_placement'] |
162 | 162 | ); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | <div id="acf-<?php echo $field_group['ID']; ?>" class="stuffbox"> |
166 | 166 | <h3 class="hndle"><?php echo $field_group['title']; ?></h3> |
167 | 167 | <div class="inside"> |
168 | - <?php acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] ); ?> |
|
168 | + <?php acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']); ?> |
|
169 | 169 | <script type="text/javascript"> |
170 | 170 | if( typeof acf !== 'undefined' ) { |
171 | 171 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | )); |
210 | 210 | |
211 | 211 | |
212 | - if( !empty($field_groups) ) { |
|
212 | + if ( ! empty($field_groups)) { |
|
213 | 213 | |
214 | 214 | // render post data |
215 | 215 | acf_form_data(array( |
@@ -218,13 +218,13 @@ discard block |
||
218 | 218 | )); |
219 | 219 | |
220 | 220 | |
221 | - foreach( $field_groups as $field_group ) { |
|
221 | + foreach ($field_groups as $field_group) { |
|
222 | 222 | |
223 | - $fields = acf_get_fields( $field_group ); |
|
223 | + $fields = acf_get_fields($field_group); |
|
224 | 224 | |
225 | 225 | ?> |
226 | 226 | <div class="acf-fields -<?php echo $field_group['label_placement']; ?>"> |
227 | - <?php acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] ); ?> |
|
227 | + <?php acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']); ?> |
|
228 | 228 | </div> |
229 | 229 | <?php |
230 | 230 | |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | * @return n/a |
249 | 249 | */ |
250 | 250 | |
251 | - function save_comment( $comment_id ) { |
|
251 | + function save_comment($comment_id) { |
|
252 | 252 | |
253 | 253 | // bail early if not valid nonce |
254 | - if( ! acf_verify_nonce('comment') ) { |
|
254 | + if ( ! acf_verify_nonce('comment')) { |
|
255 | 255 | |
256 | 256 | return $comment_id; |
257 | 257 | |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | |
260 | 260 | |
261 | 261 | // validate and save |
262 | - if( acf_validate_save_post(true) ) { |
|
262 | + if (acf_validate_save_post(true)) { |
|
263 | 263 | |
264 | - acf_save_post( "comment_{$comment_id}" ); |
|
264 | + acf_save_post("comment_{$comment_id}"); |
|
265 | 265 | |
266 | 266 | } |
267 | 267 |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | * @subpackage Forms |
11 | 11 | */ |
12 | 12 | |
13 | -if( ! class_exists('acf_form_post') ) : |
|
13 | +if ( ! class_exists('acf_form_post')) : |
|
14 | 14 | |
15 | 15 | class acf_form_post { |
16 | 16 | |
17 | - var $post_id = 0, |
|
18 | - $typenow = '', |
|
19 | - $style = ''; |
|
17 | + var $post_id = 0, |
|
18 | + $typenow = '', |
|
19 | + $style = ''; |
|
20 | 20 | |
21 | 21 | |
22 | 22 | /* |
@@ -35,16 +35,16 @@ discard block |
||
35 | 35 | function __construct() { |
36 | 36 | |
37 | 37 | // actions |
38 | - add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
38 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
39 | 39 | |
40 | 40 | |
41 | 41 | // save |
42 | - add_filter('wp_insert_post_empty_content', array($this, 'wp_insert_post_empty_content'), 10, 2); |
|
43 | - add_action('save_post', array($this, 'save_post'), 10, 2); |
|
42 | + add_filter('wp_insert_post_empty_content', array($this, 'wp_insert_post_empty_content'), 10, 2); |
|
43 | + add_action('save_post', array($this, 'save_post'), 10, 2); |
|
44 | 44 | |
45 | 45 | |
46 | 46 | // ajax |
47 | - add_action('wp_ajax_acf/post/get_field_groups', array($this, 'get_field_groups')); |
|
47 | + add_action('wp_ajax_acf/post/get_field_groups', array($this, 'get_field_groups')); |
|
48 | 48 | |
49 | 49 | } |
50 | 50 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | |
75 | 75 | // validate page |
76 | - if( in_array($pagenow, array('post.php', 'post-new.php')) ) { |
|
76 | + if (in_array($pagenow, array('post.php', 'post-new.php'))) { |
|
77 | 77 | |
78 | 78 | $return = true; |
79 | 79 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | |
82 | 82 | |
83 | 83 | // update vars |
84 | - if( !empty($post) ) { |
|
84 | + if ( ! empty($post)) { |
|
85 | 85 | |
86 | 86 | $this->post_id = $post->ID; |
87 | 87 | $this->typenow = $typenow; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | |
91 | 91 | |
92 | 92 | // validate post type |
93 | - if( in_array($typenow, array('acf-field-group', 'attachment')) ) { |
|
93 | + if (in_array($typenow, array('acf-field-group', 'attachment'))) { |
|
94 | 94 | |
95 | 95 | return false; |
96 | 96 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | |
99 | 99 | |
100 | 100 | // validate page (Shopp) |
101 | - if( $pagenow == "admin.php" && isset( $_GET['page'] ) && $_GET['page'] == "shopp-products" && isset( $_GET['id'] ) ) { |
|
101 | + if ($pagenow == "admin.php" && isset($_GET['page']) && $_GET['page'] == "shopp-products" && isset($_GET['id'])) { |
|
102 | 102 | |
103 | 103 | $return = true; |
104 | 104 | |
105 | - $this->post_id = absint( $_GET['id'] ); |
|
105 | + $this->post_id = absint($_GET['id']); |
|
106 | 106 | $this->typenow = 'shopp_product'; |
107 | 107 | |
108 | 108 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | function admin_enqueue_scripts() { |
131 | 131 | |
132 | 132 | // validate page |
133 | - if( !$this->validate_page() ) return; |
|
133 | + if ( ! $this->validate_page()) return; |
|
134 | 134 | |
135 | 135 | |
136 | 136 | // load acf scripts |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | |
139 | 139 | |
140 | 140 | // actions |
141 | - add_action('acf/input/admin_head', array($this,'admin_head')); |
|
142 | - add_action('acf/input/admin_footer', array($this,'admin_footer')); |
|
141 | + add_action('acf/input/admin_head', array($this, 'admin_head')); |
|
142 | + add_action('acf/input/admin_footer', array($this, 'admin_footer')); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -167,9 +167,9 @@ discard block |
||
167 | 167 | |
168 | 168 | |
169 | 169 | // add meta boxes |
170 | - if( !empty($field_groups) ) { |
|
170 | + if ( ! empty($field_groups)) { |
|
171 | 171 | |
172 | - foreach( $field_groups as $i => $field_group ) { |
|
172 | + foreach ($field_groups as $i => $field_group) { |
|
173 | 173 | |
174 | 174 | // vars |
175 | 175 | $id = "acf-{$field_group['key']}"; |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | |
185 | 185 | // tweaks to vars |
186 | - if( $context == 'side' ) { |
|
186 | + if ($context == 'side') { |
|
187 | 187 | |
188 | 188 | $priority = 'core'; |
189 | 189 | |
@@ -195,22 +195,22 @@ discard block |
||
195 | 195 | |
196 | 196 | |
197 | 197 | // visibility |
198 | - $args['visibility'] = acf_get_field_group_visibility( $field_group, array( |
|
198 | + $args['visibility'] = acf_get_field_group_visibility($field_group, array( |
|
199 | 199 | 'post_id' => $this->post_id, |
200 | 200 | 'post_type' => $this->typenow |
201 | 201 | )); |
202 | 202 | |
203 | 203 | |
204 | 204 | // add meta box |
205 | - add_meta_box( $id, $title, array($this, 'render_meta_box'), $this->typenow, $context, $priority, $args ); |
|
205 | + add_meta_box($id, $title, array($this, 'render_meta_box'), $this->typenow, $context, $priority, $args); |
|
206 | 206 | |
207 | 207 | |
208 | 208 | // update style |
209 | - if( !$style_found && $args['visibility'] ) { |
|
209 | + if ( ! $style_found && $args['visibility']) { |
|
210 | 210 | |
211 | 211 | $style_found = true; |
212 | 212 | |
213 | - $this->style = acf_get_field_group_style( $field_group ); |
|
213 | + $this->style = acf_get_field_group_style($field_group); |
|
214 | 214 | |
215 | 215 | } |
216 | 216 | |
@@ -255,11 +255,11 @@ discard block |
||
255 | 255 | |
256 | 256 | |
257 | 257 | // render |
258 | - do_meta_boxes( get_current_screen(), 'acf_after_title', $post); |
|
258 | + do_meta_boxes(get_current_screen(), 'acf_after_title', $post); |
|
259 | 259 | |
260 | 260 | |
261 | 261 | // clean up |
262 | - unset( $wp_meta_boxes['post']['acf_after_title'] ); |
|
262 | + unset($wp_meta_boxes['post']['acf_after_title']); |
|
263 | 263 | |
264 | 264 | } |
265 | 265 | |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | * @return $post_id (int) |
278 | 278 | */ |
279 | 279 | |
280 | - function render_meta_box( $post, $args ) { |
|
280 | + function render_meta_box($post, $args) { |
|
281 | 281 | |
282 | 282 | // extract args |
283 | - extract( $args ); // all variables from the add_meta_box function |
|
284 | - extract( $args ); // all variables from the args argument |
|
283 | + extract($args); // all variables from the add_meta_box function |
|
284 | + extract($args); // all variables from the args argument |
|
285 | 285 | |
286 | 286 | |
287 | 287 | // vars |
@@ -297,22 +297,22 @@ discard block |
||
297 | 297 | |
298 | 298 | |
299 | 299 | // edit_url |
300 | - if( $field_group['ID'] && acf_current_user_can_admin() ) { |
|
300 | + if ($field_group['ID'] && acf_current_user_can_admin()) { |
|
301 | 301 | |
302 | - $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit'); |
|
302 | + $o['edit_url'] = admin_url('post.php?post='.$field_group['ID'].'&action=edit'); |
|
303 | 303 | |
304 | 304 | } |
305 | 305 | |
306 | 306 | |
307 | 307 | // load and render fields |
308 | - if( $visibility ) { |
|
308 | + if ($visibility) { |
|
309 | 309 | |
310 | 310 | // load fields |
311 | - $fields = acf_get_fields( $field_group ); |
|
311 | + $fields = acf_get_fields($field_group); |
|
312 | 312 | |
313 | 313 | |
314 | 314 | // render |
315 | - acf_render_fields( $this->post_id, $fields, 'div', $field_group['instruction_placement'] ); |
|
315 | + acf_render_fields($this->post_id, $fields, 'div', $field_group['instruction_placement']); |
|
316 | 316 | |
317 | 317 | // render replace-me div |
318 | 318 | } else { |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | * @return $post_id (int) |
348 | 348 | */ |
349 | 349 | |
350 | - function admin_footer(){ |
|
350 | + function admin_footer() { |
|
351 | 351 | |
352 | 352 | // get style of first field group |
353 | - echo '<style type="text/css" id="acf-style">' . $this->style . '</style>'; |
|
353 | + echo '<style type="text/css" id="acf-style">'.$this->style.'</style>'; |
|
354 | 354 | |
355 | 355 | } |
356 | 356 | |
@@ -381,12 +381,12 @@ discard block |
||
381 | 381 | |
382 | 382 | // vars |
383 | 383 | $json = array(); |
384 | - $nonce = acf_extract_var( $options, 'nonce' ); |
|
385 | - $exists = acf_extract_var( $options, 'exists' ); |
|
384 | + $nonce = acf_extract_var($options, 'nonce'); |
|
385 | + $exists = acf_extract_var($options, 'exists'); |
|
386 | 386 | |
387 | 387 | |
388 | 388 | // verify nonce |
389 | - if( !wp_verify_nonce($nonce, 'acf_nonce') ) { |
|
389 | + if ( ! wp_verify_nonce($nonce, 'acf_nonce')) { |
|
390 | 390 | |
391 | 391 | die; |
392 | 392 | |
@@ -394,19 +394,19 @@ discard block |
||
394 | 394 | |
395 | 395 | |
396 | 396 | // get field groups |
397 | - $field_groups = acf_get_field_groups( $options ); |
|
397 | + $field_groups = acf_get_field_groups($options); |
|
398 | 398 | |
399 | 399 | |
400 | 400 | // bail early if no field groups |
401 | - if( empty($field_groups) ) { |
|
401 | + if (empty($field_groups)) { |
|
402 | 402 | |
403 | - wp_send_json_success( $json ); |
|
403 | + wp_send_json_success($json); |
|
404 | 404 | |
405 | 405 | } |
406 | 406 | |
407 | 407 | |
408 | 408 | // loop through field groups |
409 | - foreach( $field_groups as $i => $field_group ) { |
|
409 | + foreach ($field_groups as $i => $field_group) { |
|
410 | 410 | |
411 | 411 | // vars |
412 | 412 | $item = array( |
@@ -419,18 +419,18 @@ discard block |
||
419 | 419 | |
420 | 420 | |
421 | 421 | // style |
422 | - if( $i == 0 ) { |
|
422 | + if ($i == 0) { |
|
423 | 423 | |
424 | - $item['style'] = acf_get_field_group_style( $field_group ); |
|
424 | + $item['style'] = acf_get_field_group_style($field_group); |
|
425 | 425 | |
426 | 426 | } |
427 | 427 | |
428 | 428 | |
429 | 429 | // html |
430 | - if( !in_array($field_group['key'], $exists) ) { |
|
430 | + if ( ! in_array($field_group['key'], $exists)) { |
|
431 | 431 | |
432 | 432 | // load fields |
433 | - $fields = acf_get_fields( $field_group ); |
|
433 | + $fields = acf_get_fields($field_group); |
|
434 | 434 | |
435 | 435 | |
436 | 436 | // get field HTML |
@@ -438,7 +438,7 @@ discard block |
||
438 | 438 | |
439 | 439 | |
440 | 440 | // render |
441 | - acf_render_fields( $options['post_id'], $fields, 'div', $field_group['instruction_placement'] ); |
|
441 | + acf_render_fields($options['post_id'], $fields, 'div', $field_group['instruction_placement']); |
|
442 | 442 | |
443 | 443 | |
444 | 444 | $item['html'] = ob_get_clean(); |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | |
455 | 455 | |
456 | 456 | // return |
457 | - wp_send_json_success( $json ); |
|
457 | + wp_send_json_success($json); |
|
458 | 458 | |
459 | 459 | } |
460 | 460 | |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | * @return $maybe_empty |
474 | 474 | */ |
475 | 475 | |
476 | - function wp_insert_post_empty_content( $maybe_empty, $postarr ) { |
|
476 | + function wp_insert_post_empty_content($maybe_empty, $postarr) { |
|
477 | 477 | |
478 | - if( $maybe_empty && !empty($_POST['_acfchanged']) ) { |
|
478 | + if ($maybe_empty && ! empty($_POST['_acfchanged'])) { |
|
479 | 479 | |
480 | 480 | $maybe_empty = false; |
481 | 481 | |
@@ -500,10 +500,10 @@ discard block |
||
500 | 500 | * @return $post_id (int) |
501 | 501 | */ |
502 | 502 | |
503 | - function save_post( $post_id, $post ) { |
|
503 | + function save_post($post_id, $post) { |
|
504 | 504 | |
505 | 505 | // do not save if this is an auto save routine |
506 | - if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) { |
|
506 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
507 | 507 | |
508 | 508 | return $post_id; |
509 | 509 | |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | |
512 | 512 | |
513 | 513 | // bail early if is acf-field-group or acf-field |
514 | - if( in_array($post->post_type, array('acf-field', 'acf-field-group'))) { |
|
514 | + if (in_array($post->post_type, array('acf-field', 'acf-field-group'))) { |
|
515 | 515 | |
516 | 516 | return $post_id; |
517 | 517 | |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | |
520 | 520 | |
521 | 521 | // verify and remove nonce |
522 | - if( !acf_verify_nonce('post', $post_id) ) { |
|
522 | + if ( ! acf_verify_nonce('post', $post_id)) { |
|
523 | 523 | |
524 | 524 | return $post_id; |
525 | 525 | |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | |
528 | 528 | |
529 | 529 | // validate and save |
530 | - if( get_post_status($post_id) == 'publish' ) { |
|
530 | + if (get_post_status($post_id) == 'publish') { |
|
531 | 531 | |
532 | - if( acf_validate_save_post(true) ) { |
|
532 | + if (acf_validate_save_post(true)) { |
|
533 | 533 | |
534 | - acf_save_post( $post_id ); |
|
534 | + acf_save_post($post_id); |
|
535 | 535 | |
536 | 536 | } |
537 | 537 | |
538 | 538 | } else { |
539 | 539 | |
540 | - acf_save_post( $post_id ); |
|
540 | + acf_save_post($post_id); |
|
541 | 541 | |
542 | 542 | } |
543 | 543 | |
@@ -562,14 +562,14 @@ discard block |
||
562 | 562 | * @return $post_id (int) |
563 | 563 | */ |
564 | 564 | |
565 | - function is_protected_meta( $protected, $meta_key, $meta_type ) { |
|
565 | + function is_protected_meta($protected, $meta_key, $meta_type) { |
|
566 | 566 | |
567 | 567 | // if acf_get_field_reference returns a valid key, this is an acf value, so protect it! |
568 | - if( !$protected ) { |
|
568 | + if ( ! $protected) { |
|
569 | 569 | |
570 | - $reference = acf_get_field_reference( $meta_key, $this->post_id ); |
|
570 | + $reference = acf_get_field_reference($meta_key, $this->post_id); |
|
571 | 571 | |
572 | - if( acf_is_field_key($reference) ) { |
|
572 | + if (acf_is_field_key($reference)) { |
|
573 | 573 | |
574 | 574 | $protected = true; |
575 | 575 |
@@ -130,7 +130,9 @@ |
||
130 | 130 | function admin_enqueue_scripts() { |
131 | 131 | |
132 | 132 | // validate page |
133 | - if( !$this->validate_page() ) return; |
|
133 | + if( !$this->validate_page() ) { |
|
134 | + return; |
|
135 | + } |
|
134 | 136 | |
135 | 137 | |
136 | 138 | // load acf scripts |
@@ -395,8 +395,8 @@ |
||
395 | 395 | |
396 | 396 | |
397 | 397 | |
398 | - // save data |
|
399 | - if( acf_validate_save_post(true) ) { |
|
398 | + // save data |
|
399 | + if( acf_validate_save_post(true) ) { |
|
400 | 400 | |
401 | 401 | acf_save_post("{$taxonomy}_{$term_id}"); |
402 | 402 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Forms |
11 | 11 | */ |
12 | 12 | |
13 | -if( ! class_exists('acf_form_taxonomy') ) : |
|
13 | +if ( ! class_exists('acf_form_taxonomy')) : |
|
14 | 14 | |
15 | 15 | class acf_form_taxonomy { |
16 | 16 | |
@@ -33,16 +33,16 @@ discard block |
||
33 | 33 | function __construct() { |
34 | 34 | |
35 | 35 | // actions |
36 | - add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
36 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
37 | 37 | |
38 | 38 | |
39 | 39 | // save |
40 | - add_action('create_term', array($this, 'save_term'), 10, 3); |
|
41 | - add_action('edit_term', array($this, 'save_term'), 10, 3); |
|
40 | + add_action('create_term', array($this, 'save_term'), 10, 3); |
|
41 | + add_action('edit_term', array($this, 'save_term'), 10, 3); |
|
42 | 42 | |
43 | 43 | |
44 | 44 | // delete |
45 | - add_action('delete_term', array($this, 'delete_term'), 10, 4); |
|
45 | + add_action('delete_term', array($this, 'delete_term'), 10, 4); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | |
69 | 69 | // validate page |
70 | - if( $pagenow == 'edit-tags.php' ) { |
|
70 | + if ($pagenow == 'edit-tags.php') { |
|
71 | 71 | |
72 | 72 | return true; |
73 | 73 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | function admin_enqueue_scripts() { |
97 | 97 | |
98 | 98 | // validate page |
99 | - if( !$this->validate_page() ) { |
|
99 | + if ( ! $this->validate_page()) { |
|
100 | 100 | |
101 | 101 | return; |
102 | 102 | |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | |
114 | 114 | |
115 | 115 | // actions |
116 | - add_action('admin_footer', array($this, 'admin_footer'), 10, 1); |
|
117 | - add_action("{$taxonomy}_add_form_fields", array($this, 'add_term'), 10, 1); |
|
118 | - add_action("{$taxonomy}_edit_form", array($this, 'edit_term'), 10, 2); |
|
116 | + add_action('admin_footer', array($this, 'admin_footer'), 10, 1); |
|
117 | + add_action("{$taxonomy}_add_form_fields", array($this, 'add_term'), 10, 1); |
|
118 | + add_action("{$taxonomy}_edit_form", array($this, 'edit_term'), 10, 2); |
|
119 | 119 | |
120 | 120 | } |
121 | 121 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return $post_id (int) |
134 | 134 | */ |
135 | 135 | |
136 | - function add_term( $taxonomy ) { |
|
136 | + function add_term($taxonomy) { |
|
137 | 137 | |
138 | 138 | // vars |
139 | 139 | $post_id = "{$taxonomy}_0"; |
@@ -147,22 +147,22 @@ discard block |
||
147 | 147 | |
148 | 148 | |
149 | 149 | // get field groups |
150 | - $field_groups = acf_get_field_groups( $args ); |
|
150 | + $field_groups = acf_get_field_groups($args); |
|
151 | 151 | |
152 | 152 | |
153 | 153 | // render |
154 | - if( !empty($field_groups) ) { |
|
154 | + if ( ! empty($field_groups)) { |
|
155 | 155 | |
156 | 156 | acf_form_data(array( |
157 | 157 | 'post_id' => $post_id, |
158 | 158 | 'nonce' => 'taxonomy', |
159 | 159 | )); |
160 | 160 | |
161 | - foreach( $field_groups as $field_group ) { |
|
161 | + foreach ($field_groups as $field_group) { |
|
162 | 162 | |
163 | - $fields = acf_get_fields( $field_group ); |
|
163 | + $fields = acf_get_fields($field_group); |
|
164 | 164 | |
165 | - acf_render_fields( $post_id, $fields, 'div', 'field' ); |
|
165 | + acf_render_fields($post_id, $fields, 'div', 'field'); |
|
166 | 166 | |
167 | 167 | } |
168 | 168 | |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @return $post_id (int) |
185 | 185 | */ |
186 | 186 | |
187 | - function edit_term( $term, $taxonomy ) { |
|
187 | + function edit_term($term, $taxonomy) { |
|
188 | 188 | |
189 | 189 | // vars |
190 | 190 | $post_id = "{$taxonomy}_{$term->term_id}"; |
@@ -198,28 +198,28 @@ discard block |
||
198 | 198 | |
199 | 199 | |
200 | 200 | // get field groups |
201 | - $field_groups = acf_get_field_groups( $args ); |
|
201 | + $field_groups = acf_get_field_groups($args); |
|
202 | 202 | |
203 | 203 | |
204 | 204 | // render |
205 | - if( !empty($field_groups) ) { |
|
205 | + if ( ! empty($field_groups)) { |
|
206 | 206 | |
207 | 207 | acf_form_data(array( |
208 | 208 | 'post_id' => $post_id, |
209 | 209 | 'nonce' => 'taxonomy' |
210 | 210 | )); |
211 | 211 | |
212 | - foreach( $field_groups as $field_group ) { |
|
212 | + foreach ($field_groups as $field_group) { |
|
213 | 213 | |
214 | - $fields = acf_get_fields( $field_group ); |
|
214 | + $fields = acf_get_fields($field_group); |
|
215 | 215 | |
216 | 216 | ?> |
217 | - <?php if( $field_group['style'] == 'default' ): ?> |
|
217 | + <?php if ($field_group['style'] == 'default'): ?> |
|
218 | 218 | <h3><?php echo $field_group['title']; ?></h3> |
219 | 219 | <?php endif; ?> |
220 | 220 | <table class="form-table"> |
221 | 221 | <tbody> |
222 | - <?php acf_render_fields( $post_id, $fields, 'tr', 'field' ); ?> |
|
222 | + <?php acf_render_fields($post_id, $fields, 'tr', 'field'); ?> |
|
223 | 223 | </tbody> |
224 | 224 | </table> |
225 | 225 | <?php |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | acf.validation.error_class = 'form-invalid'; |
272 | 272 | |
273 | 273 | |
274 | -<?php if( $this->form == '#addtag' ): ?> |
|
274 | +<?php if ($this->form == '#addtag'): ?> |
|
275 | 275 | |
276 | 276 | // store origional HTML |
277 | 277 | var $orig = $('#addtag').children('.acf-field').clone(); |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | * @return $post_id (int) |
385 | 385 | */ |
386 | 386 | |
387 | - function save_term( $term_id, $tt_id, $taxonomy ) { |
|
387 | + function save_term($term_id, $tt_id, $taxonomy) { |
|
388 | 388 | |
389 | 389 | // verify and remove nonce |
390 | - if( ! acf_verify_nonce('taxonomy') ) { |
|
390 | + if ( ! acf_verify_nonce('taxonomy')) { |
|
391 | 391 | |
392 | 392 | return $term_id; |
393 | 393 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | |
397 | 397 | |
398 | 398 | // save data |
399 | - if( acf_validate_save_post(true) ) { |
|
399 | + if (acf_validate_save_post(true)) { |
|
400 | 400 | |
401 | 401 | acf_save_post("{$taxonomy}_{$term_id}"); |
402 | 402 | |
@@ -418,13 +418,13 @@ discard block |
||
418 | 418 | * @return $post_id (int) |
419 | 419 | */ |
420 | 420 | |
421 | - function delete_term( $term, $tt_id, $taxonomy, $deleted_term ) { |
|
421 | + function delete_term($term, $tt_id, $taxonomy, $deleted_term) { |
|
422 | 422 | |
423 | 423 | global $wpdb; |
424 | 424 | |
425 | 425 | $values = $wpdb->query($wpdb->prepare( |
426 | 426 | "DELETE FROM $wpdb->options WHERE option_name LIKE %s", |
427 | - '%' . $taxonomy . '_' . $term . '%' |
|
427 | + '%'.$taxonomy.'_'.$term.'%' |
|
428 | 428 | )); |
429 | 429 | |
430 | 430 | } |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | $id = acf_maybe_get($_POST, 'widget-id'); |
182 | 182 | |
183 | 183 | |
184 | - // save data |
|
185 | - if( $id && acf_validate_save_post() ) { |
|
184 | + // save data |
|
185 | + if( $id && acf_validate_save_post() ) { |
|
186 | 186 | |
187 | 187 | acf_save_post( "widget_{$id}" ); |
188 | 188 | |
@@ -218,8 +218,8 @@ discard block |
||
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | - // save |
|
222 | - if( acf_validate_save_post() ) { |
|
221 | + // save |
|
222 | + if( acf_validate_save_post() ) { |
|
223 | 223 | |
224 | 224 | acf_save_post( "widget_{$widget->id}" ); |
225 | 225 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @subpackage Forms |
11 | 11 | */ |
12 | 12 | |
13 | -if( ! class_exists('acf_form_widget') ) : |
|
13 | +if ( ! class_exists('acf_form_widget')) : |
|
14 | 14 | |
15 | 15 | class acf_form_widget { |
16 | 16 | |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | function __construct() { |
32 | 32 | |
33 | 33 | // actions |
34 | - add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
35 | - add_action('in_widget_form', array($this, 'edit_widget'), 10, 3); |
|
34 | + add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts')); |
|
35 | + add_action('in_widget_form', array($this, 'edit_widget'), 10, 3); |
|
36 | 36 | |
37 | 37 | |
38 | 38 | // filters |
39 | - add_filter('widget_update_callback', array($this, 'widget_update_callback'), 10, 4); |
|
39 | + add_filter('widget_update_callback', array($this, 'widget_update_callback'), 10, 4); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | // ajax |
43 | - add_action('wp_ajax_update-widget', array($this, 'ajax_update_widget'), 0, 1); |
|
43 | + add_action('wp_ajax_update-widget', array($this, 'ajax_update_widget'), 0, 1); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | function admin_enqueue_scripts() { |
63 | 63 | |
64 | 64 | // validate screen |
65 | - if( acf_is_screen('widgets') || acf_is_screen('customize') ) { |
|
65 | + if (acf_is_screen('widgets') || acf_is_screen('customize')) { |
|
66 | 66 | |
67 | 67 | // valid |
68 | 68 | |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | * @param $instance (object) |
98 | 98 | * @return $post_id (int) |
99 | 99 | */ |
100 | - function edit_widget( $widget, $return, $instance ) { |
|
100 | + function edit_widget($widget, $return, $instance) { |
|
101 | 101 | |
102 | 102 | // vars |
103 | 103 | $post_id = 0; |
104 | 104 | |
105 | 105 | |
106 | 106 | // get id |
107 | - if( $widget->number !== '__i__' ) { |
|
107 | + if ($widget->number !== '__i__') { |
|
108 | 108 | |
109 | 109 | $post_id = "widget_{$widget->id}"; |
110 | 110 | |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | |
120 | 120 | // render |
121 | - if( !empty($field_groups) ) { |
|
121 | + if ( ! empty($field_groups)) { |
|
122 | 122 | |
123 | 123 | // render post data |
124 | 124 | acf_form_data(array( |
@@ -127,15 +127,15 @@ discard block |
||
127 | 127 | )); |
128 | 128 | |
129 | 129 | |
130 | - foreach( $field_groups as $field_group ) { |
|
130 | + foreach ($field_groups as $field_group) { |
|
131 | 131 | |
132 | - $fields = acf_get_fields( $field_group ); |
|
132 | + $fields = acf_get_fields($field_group); |
|
133 | 133 | |
134 | - acf_render_fields( $post_id, $fields, 'div', 'field' ); |
|
134 | + acf_render_fields($post_id, $fields, 'div', 'field'); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
138 | - if( $widget->updated ): ?> |
|
138 | + if ($widget->updated): ?> |
|
139 | 139 | <script type="text/javascript"> |
140 | 140 | (function($) { |
141 | 141 | |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | |
171 | 171 | |
172 | 172 | // bail early if no nonce |
173 | - if( !acf_verify_nonce('widget') ) { |
|
173 | + if ( ! acf_verify_nonce('widget')) { |
|
174 | 174 | |
175 | 175 | return; |
176 | 176 | |
@@ -182,9 +182,9 @@ discard block |
||
182 | 182 | |
183 | 183 | |
184 | 184 | // save data |
185 | - if( $id && acf_validate_save_post() ) { |
|
185 | + if ($id && acf_validate_save_post()) { |
|
186 | 186 | |
187 | - acf_save_post( "widget_{$id}" ); |
|
187 | + acf_save_post("widget_{$id}"); |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
@@ -208,10 +208,10 @@ discard block |
||
208 | 208 | * @return $instance |
209 | 209 | */ |
210 | 210 | |
211 | - function widget_update_callback( $instance, $new_instance, $old_instance, $widget ) { |
|
211 | + function widget_update_callback($instance, $new_instance, $old_instance, $widget) { |
|
212 | 212 | |
213 | 213 | // bail early if no nonce |
214 | - if( !acf_verify_nonce('widget') ) { |
|
214 | + if ( ! acf_verify_nonce('widget')) { |
|
215 | 215 | |
216 | 216 | return $instance; |
217 | 217 | |
@@ -219,9 +219,9 @@ discard block |
||
219 | 219 | |
220 | 220 | |
221 | 221 | // save |
222 | - if( acf_validate_save_post() ) { |
|
222 | + if (acf_validate_save_post()) { |
|
223 | 223 | |
224 | - acf_save_post( "widget_{$widget->id}" ); |
|
224 | + acf_save_post("widget_{$widget->id}"); |
|
225 | 225 | |
226 | 226 | } |
227 | 227 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | }); |
351 | 351 | |
352 | - <?php if( acf_is_screen('customize') ): ?> |
|
352 | + <?php if (acf_is_screen('customize')): ?> |
|
353 | 353 | |
354 | 354 | // customizer saves widget on any input change, so unload is not needed |
355 | 355 | acf.unload.active = 0; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if( !class_exists('acf_pro') ): |
|
3 | +if ( ! class_exists('acf_pro')): |
|
4 | 4 | |
5 | 5 | class acf_pro { |
6 | 6 | |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | function __construct() { |
21 | 21 | |
22 | 22 | // update setting |
23 | - acf_update_setting( 'pro', true ); |
|
24 | - acf_update_setting( 'name', __('Advanced Custom Fields PRO', 'acf') ); |
|
23 | + acf_update_setting('pro', true); |
|
24 | + acf_update_setting('name', __('Advanced Custom Fields PRO', 'acf')); |
|
25 | 25 | |
26 | 26 | |
27 | 27 | // api |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | |
36 | 36 | // admin |
37 | - if( is_admin() ) { |
|
37 | + if (is_admin()) { |
|
38 | 38 | |
39 | 39 | // options page |
40 | 40 | acf_include('pro/admin/options-page.php'); |
@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | |
47 | 47 | |
48 | 48 | // actions |
49 | - add_action('init', array($this, 'register_assets')); |
|
50 | - add_action('acf/include_field_types', array($this, 'include_field_types'), 5); |
|
51 | - add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts')); |
|
52 | - add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts')); |
|
53 | - add_action('acf/field_group/admin_l10n', array($this, 'field_group_admin_l10n')); |
|
49 | + add_action('init', array($this, 'register_assets')); |
|
50 | + add_action('acf/include_field_types', array($this, 'include_field_types'), 5); |
|
51 | + add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts')); |
|
52 | + add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts')); |
|
53 | + add_action('acf/field_group/admin_l10n', array($this, 'field_group_admin_l10n')); |
|
54 | 54 | |
55 | 55 | |
56 | 56 | // filters |
57 | - add_filter('acf/get_valid_field', array($this, 'get_valid_field'), 11, 1); |
|
58 | - add_filter('acf/prepare_field_for_export', array($this, 'prepare_field_for_export')); |
|
59 | - add_filter('acf/prepare_field_for_import', array($this, 'prepare_field_for_import')); |
|
57 | + add_filter('acf/get_valid_field', array($this, 'get_valid_field'), 11, 1); |
|
58 | + add_filter('acf/prepare_field_for_export', array($this, 'prepare_field_for_export')); |
|
59 | + add_filter('acf/prepare_field_for_import', array($this, 'prepare_field_for_import')); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | * @return $field |
97 | 97 | */ |
98 | 98 | |
99 | - function get_valid_field( $field ) { |
|
99 | + function get_valid_field($field) { |
|
100 | 100 | |
101 | 101 | // extract old width |
102 | - $width = acf_extract_var( $field, 'column_width' ); |
|
102 | + $width = acf_extract_var($field, 'column_width'); |
|
103 | 103 | |
104 | 104 | |
105 | 105 | // if old width, update the new width |
106 | - if( $width ) { |
|
106 | + if ($width) { |
|
107 | 107 | |
108 | 108 | $field['wrapper']['width'] = $width; |
109 | 109 | } |
@@ -131,17 +131,17 @@ discard block |
||
131 | 131 | function register_assets() { |
132 | 132 | |
133 | 133 | // min |
134 | - $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
134 | + $min = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
135 | 135 | |
136 | 136 | |
137 | 137 | // register scripts |
138 | - wp_register_script( 'acf-pro-input', acf_get_dir( "pro/assets/js/acf-pro-input{$min}.js" ), false, acf_get_setting('version') ); |
|
139 | - wp_register_script( 'acf-pro-field-group', acf_get_dir( "pro/assets/js/acf-pro-field-group{$min}.js" ), false, acf_get_setting('version') ); |
|
138 | + wp_register_script('acf-pro-input', acf_get_dir("pro/assets/js/acf-pro-input{$min}.js"), false, acf_get_setting('version')); |
|
139 | + wp_register_script('acf-pro-field-group', acf_get_dir("pro/assets/js/acf-pro-field-group{$min}.js"), false, acf_get_setting('version')); |
|
140 | 140 | |
141 | 141 | |
142 | 142 | // register styles |
143 | - wp_register_style( 'acf-pro-input', acf_get_dir( 'pro/assets/css/acf-pro-input.css' ), false, acf_get_setting('version') ); |
|
144 | - wp_register_style( 'acf-pro-field-group', acf_get_dir( 'pro/assets/css/acf-pro-field-group.css' ), false, acf_get_setting('version') ); |
|
143 | + wp_register_style('acf-pro-input', acf_get_dir('pro/assets/css/acf-pro-input.css'), false, acf_get_setting('version')); |
|
144 | + wp_register_style('acf-pro-field-group', acf_get_dir('pro/assets/css/acf-pro-field-group.css'), false, acf_get_setting('version')); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | * @return $post_id (int) |
185 | 185 | */ |
186 | 186 | |
187 | - function field_group_admin_l10n( $l10n ) { |
|
187 | + function field_group_admin_l10n($l10n) { |
|
188 | 188 | |
189 | 189 | // append |
190 | 190 | $l10n['flexible_content'] = array( |
191 | - 'layout_warning' => __('Flexible Content requires at least 1 layout','acf') |
|
191 | + 'layout_warning' => __('Flexible Content requires at least 1 layout', 'acf') |
|
192 | 192 | ); |
193 | 193 | |
194 | 194 | |
@@ -236,23 +236,23 @@ discard block |
||
236 | 236 | * @return $post_id (int) |
237 | 237 | */ |
238 | 238 | |
239 | - function prepare_field_for_export( $field ) { |
|
239 | + function prepare_field_for_export($field) { |
|
240 | 240 | |
241 | 241 | // sub field (parent_layout) |
242 | - acf_extract_var( $field, 'parent_layout'); |
|
242 | + acf_extract_var($field, 'parent_layout'); |
|
243 | 243 | |
244 | 244 | |
245 | 245 | // repeater |
246 | - if( $field['type'] == 'repeater' ) { |
|
246 | + if ($field['type'] == 'repeater') { |
|
247 | 247 | |
248 | - $field['sub_fields'] = acf_prepare_fields_for_export( $field['sub_fields'] ); |
|
248 | + $field['sub_fields'] = acf_prepare_fields_for_export($field['sub_fields']); |
|
249 | 249 | |
250 | 250 | // flexible content |
251 | - } elseif( $field['type'] == 'flexible_content' ) { |
|
251 | + } elseif ($field['type'] == 'flexible_content') { |
|
252 | 252 | |
253 | - foreach( $field['layouts'] as $l => $layout ) { |
|
253 | + foreach ($field['layouts'] as $l => $layout) { |
|
254 | 254 | |
255 | - $field['layouts'][ $l ]['sub_fields'] = acf_prepare_fields_for_export( $layout['sub_fields'] ); |
|
255 | + $field['layouts'][$l]['sub_fields'] = acf_prepare_fields_for_export($layout['sub_fields']); |
|
256 | 256 | |
257 | 257 | } |
258 | 258 | |
@@ -278,29 +278,29 @@ discard block |
||
278 | 278 | * @return $post_id (int) |
279 | 279 | */ |
280 | 280 | |
281 | - function prepare_field_for_import( $field ) { |
|
281 | + function prepare_field_for_import($field) { |
|
282 | 282 | |
283 | 283 | // var |
284 | 284 | $extra = array(); |
285 | 285 | |
286 | 286 | |
287 | 287 | // sub fields |
288 | - if( $field['type'] == 'repeater' ) { |
|
288 | + if ($field['type'] == 'repeater') { |
|
289 | 289 | |
290 | 290 | // extract sub fields |
291 | - $sub_fields = acf_extract_var( $field, 'sub_fields'); |
|
291 | + $sub_fields = acf_extract_var($field, 'sub_fields'); |
|
292 | 292 | |
293 | 293 | |
294 | 294 | // reset field setting |
295 | 295 | $field['sub_fields'] = array(); |
296 | 296 | |
297 | 297 | |
298 | - if( !empty($sub_fields) ) { |
|
298 | + if ( ! empty($sub_fields)) { |
|
299 | 299 | |
300 | - foreach( array_keys($sub_fields) as $i ) { |
|
300 | + foreach (array_keys($sub_fields) as $i) { |
|
301 | 301 | |
302 | 302 | // extract sub field |
303 | - $sub_field = acf_extract_var( $sub_fields, $i ); |
|
303 | + $sub_field = acf_extract_var($sub_fields, $i); |
|
304 | 304 | |
305 | 305 | |
306 | 306 | // attributes |
@@ -314,10 +314,10 @@ discard block |
||
314 | 314 | |
315 | 315 | } |
316 | 316 | |
317 | - } elseif( $field['type'] == 'flexible_content' ) { |
|
317 | + } elseif ($field['type'] == 'flexible_content') { |
|
318 | 318 | |
319 | 319 | // extract layouts |
320 | - $layouts = acf_extract_var( $field, 'layouts'); |
|
320 | + $layouts = acf_extract_var($field, 'layouts'); |
|
321 | 321 | |
322 | 322 | |
323 | 323 | // reset field setting |
@@ -325,17 +325,17 @@ discard block |
||
325 | 325 | |
326 | 326 | |
327 | 327 | // validate layouts |
328 | - if( !empty($layouts) ) { |
|
328 | + if ( ! empty($layouts)) { |
|
329 | 329 | |
330 | 330 | // loop over layouts |
331 | - foreach( array_keys($layouts) as $i ) { |
|
331 | + foreach (array_keys($layouts) as $i) { |
|
332 | 332 | |
333 | 333 | // extract layout |
334 | - $layout = acf_extract_var( $layouts, $i ); |
|
334 | + $layout = acf_extract_var($layouts, $i); |
|
335 | 335 | |
336 | 336 | |
337 | 337 | // get valid layout (fixes ACF4 export code bug undefined index 'key') |
338 | - if( empty($layout['key']) ) { |
|
338 | + if (empty($layout['key'])) { |
|
339 | 339 | |
340 | 340 | $layout['key'] = uniqid(); |
341 | 341 | |
@@ -343,17 +343,17 @@ discard block |
||
343 | 343 | |
344 | 344 | |
345 | 345 | // extract sub fields |
346 | - $sub_fields = acf_extract_var( $layout, 'sub_fields'); |
|
346 | + $sub_fields = acf_extract_var($layout, 'sub_fields'); |
|
347 | 347 | |
348 | 348 | |
349 | 349 | // validate sub fields |
350 | - if( !empty($sub_fields) ) { |
|
350 | + if ( ! empty($sub_fields)) { |
|
351 | 351 | |
352 | 352 | // loop over sub fields |
353 | - foreach( array_keys($sub_fields) as $j ) { |
|
353 | + foreach (array_keys($sub_fields) as $j) { |
|
354 | 354 | |
355 | 355 | // extract sub field |
356 | - $sub_field = acf_extract_var( $sub_fields, $j ); |
|
356 | + $sub_field = acf_extract_var($sub_fields, $j); |
|
357 | 357 | |
358 | 358 | |
359 | 359 | // attributes |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | |
381 | 381 | |
382 | 382 | // extra |
383 | - if( !empty($extra) ) { |
|
383 | + if ( ! empty($extra)) { |
|
384 | 384 | |
385 | 385 | array_unshift($extra, $field); |
386 | 386 |
@@ -45,9 +45,9 @@ discard block |
||
45 | 45 | |
46 | 46 | function rule_types( $choices ) { |
47 | 47 | |
48 | - $choices[ __("Forms",'acf') ]['options_page'] = __("Options Page",'acf'); |
|
48 | + $choices[ __("Forms",'acf') ]['options_page'] = __("Options Page",'acf'); |
|
49 | 49 | |
50 | - return $choices; |
|
50 | + return $choices; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | |
88 | 88 | // return |
89 | - return $choices; |
|
89 | + return $choices; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
@@ -129,19 +129,19 @@ discard block |
||
129 | 129 | // match |
130 | 130 | if( $rule['operator'] == "==" ) { |
131 | 131 | |
132 | - $match = ( $options_page === $rule['value'] ); |
|
132 | + $match = ( $options_page === $rule['value'] ); |
|
133 | 133 | |
134 | - } elseif( $rule['operator'] == "!=" ) { |
|
134 | + } elseif( $rule['operator'] == "!=" ) { |
|
135 | 135 | |
136 | - $match = ( $options_page !== $rule['value'] ); |
|
136 | + $match = ( $options_page !== $rule['value'] ); |
|
137 | 137 | |
138 | - } |
|
138 | + } |
|
139 | 139 | |
140 | 140 | |
141 | - // return |
|
142 | - return $match; |
|
141 | + // return |
|
142 | + return $match; |
|
143 | 143 | |
144 | - } |
|
144 | + } |
|
145 | 145 | |
146 | 146 | |
147 | 147 | /* |
@@ -216,17 +216,17 @@ discard block |
||
216 | 216 | if( acf_verify_nonce('options') ) { |
217 | 217 | |
218 | 218 | // save data |
219 | - if( acf_validate_save_post(true) ) { |
|
219 | + if( acf_validate_save_post(true) ) { |
|
220 | 220 | |
221 | - // get post_id (allow lang modification) |
|
222 | - $post_id = acf_get_valid_post_id($this->page['post_id']); |
|
221 | + // get post_id (allow lang modification) |
|
222 | + $post_id = acf_get_valid_post_id($this->page['post_id']); |
|
223 | 223 | |
224 | 224 | |
225 | - // set autoload |
|
226 | - acf_update_setting('autoload', $this->page['autoload']); |
|
225 | + // set autoload |
|
226 | + acf_update_setting('autoload', $this->page['autoload']); |
|
227 | 227 | |
228 | 228 | |
229 | - // save |
|
229 | + // save |
|
230 | 230 | acf_save_post( $post_id ); |
231 | 231 | |
232 | 232 |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | function __construct() { |
22 | 22 | |
23 | 23 | // actions |
24 | - add_action('admin_menu', array($this,'admin_menu'), 99, 0); |
|
24 | + add_action('admin_menu', array($this, 'admin_menu'), 99, 0); |
|
25 | 25 | |
26 | 26 | |
27 | 27 | // filters |
28 | - add_filter( 'acf/location/rule_types', array($this, 'rule_types'), 10, 1 ); |
|
29 | - add_filter( 'acf/location/rule_values/options_page', array($this, 'rule_values'), 10, 1 ); |
|
30 | - add_filter( 'acf/location/rule_match/options_page', array($this, 'rule_match'), 10, 3 ); |
|
28 | + add_filter('acf/location/rule_types', array($this, 'rule_types'), 10, 1); |
|
29 | + add_filter('acf/location/rule_values/options_page', array($this, 'rule_values'), 10, 1); |
|
30 | + add_filter('acf/location/rule_match/options_page', array($this, 'rule_match'), 10, 3); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * @return {array} $choices |
44 | 44 | */ |
45 | 45 | |
46 | - function rule_types( $choices ) { |
|
46 | + function rule_types($choices) { |
|
47 | 47 | |
48 | - $choices[ __("Forms",'acf') ]['options_page'] = __("Options Page",'acf'); |
|
48 | + $choices[__("Forms", 'acf')]['options_page'] = __("Options Page", 'acf'); |
|
49 | 49 | |
50 | 50 | return $choices; |
51 | 51 | } |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | * @return {array} $choices |
64 | 64 | */ |
65 | 65 | |
66 | - function rule_values( $choices ) { |
|
66 | + function rule_values($choices) { |
|
67 | 67 | |
68 | 68 | // vars |
69 | 69 | $pages = acf_get_options_pages(); |
70 | 70 | |
71 | 71 | |
72 | 72 | // populate |
73 | - if( !empty($pages) ) { |
|
73 | + if ( ! empty($pages)) { |
|
74 | 74 | |
75 | - foreach( $pages as $page ) { |
|
75 | + foreach ($pages as $page) { |
|
76 | 76 | |
77 | - $choices[ $page['menu_slug'] ] = $page['menu_title']; |
|
77 | + $choices[$page['menu_slug']] = $page['menu_title']; |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | |
@@ -103,21 +103,21 @@ discard block |
||
103 | 103 | * @return $post_id (int) |
104 | 104 | */ |
105 | 105 | |
106 | - function rule_match( $match, $rule, $options ) { |
|
106 | + function rule_match($match, $rule, $options) { |
|
107 | 107 | |
108 | 108 | // vars |
109 | 109 | $options_page = false; |
110 | 110 | |
111 | 111 | |
112 | 112 | // $options does not contain a default for "options_page" |
113 | - if( isset($options['options_page']) ) { |
|
113 | + if (isset($options['options_page'])) { |
|
114 | 114 | |
115 | 115 | $options_page = $options['options_page']; |
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | 119 | |
120 | - if( !$options_page ) { |
|
120 | + if ( ! $options_page) { |
|
121 | 121 | |
122 | 122 | global $plugin_page; |
123 | 123 | |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | |
128 | 128 | |
129 | 129 | // match |
130 | - if( $rule['operator'] == "==" ) { |
|
130 | + if ($rule['operator'] == "==") { |
|
131 | 131 | |
132 | - $match = ( $options_page === $rule['value'] ); |
|
132 | + $match = ($options_page === $rule['value']); |
|
133 | 133 | |
134 | - } elseif( $rule['operator'] == "!=" ) { |
|
134 | + } elseif ($rule['operator'] == "!=") { |
|
135 | 135 | |
136 | - $match = ( $options_page !== $rule['value'] ); |
|
136 | + $match = ($options_page !== $rule['value']); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -164,29 +164,29 @@ discard block |
||
164 | 164 | |
165 | 165 | |
166 | 166 | // create pages |
167 | - if( !empty($pages) ) { |
|
167 | + if ( ! empty($pages)) { |
|
168 | 168 | |
169 | - foreach( $pages as $page ) { |
|
169 | + foreach ($pages as $page) { |
|
170 | 170 | |
171 | 171 | // vars |
172 | 172 | $slug = ''; |
173 | 173 | |
174 | 174 | |
175 | - if( empty($page['parent_slug']) ) { |
|
175 | + if (empty($page['parent_slug'])) { |
|
176 | 176 | |
177 | 177 | // add page |
178 | - $slug = add_menu_page( $page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], array($this, 'html'), $page['icon_url'], $page['position'] ); |
|
178 | + $slug = add_menu_page($page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], array($this, 'html'), $page['icon_url'], $page['position']); |
|
179 | 179 | |
180 | 180 | } else { |
181 | 181 | |
182 | 182 | // add page |
183 | - $slug = add_submenu_page( $page['parent_slug'], $page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], array($this, 'html') ); |
|
183 | + $slug = add_submenu_page($page['parent_slug'], $page['page_title'], $page['menu_title'], $page['capability'], $page['menu_slug'], array($this, 'html')); |
|
184 | 184 | |
185 | 185 | } |
186 | 186 | |
187 | 187 | |
188 | 188 | // actions |
189 | - add_action("load-{$slug}", array($this,'admin_load')); |
|
189 | + add_action("load-{$slug}", array($this, 'admin_load')); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | } |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | |
214 | 214 | |
215 | 215 | // verify and remove nonce |
216 | - if( acf_verify_nonce('options') ) { |
|
216 | + if (acf_verify_nonce('options')) { |
|
217 | 217 | |
218 | 218 | // save data |
219 | - if( acf_validate_save_post(true) ) { |
|
219 | + if (acf_validate_save_post(true)) { |
|
220 | 220 | |
221 | 221 | // get post_id (allow lang modification) |
222 | 222 | $post_id = acf_get_valid_post_id($this->page['post_id']); |
@@ -227,11 +227,11 @@ discard block |
||
227 | 227 | |
228 | 228 | |
229 | 229 | // save |
230 | - acf_save_post( $post_id ); |
|
230 | + acf_save_post($post_id); |
|
231 | 231 | |
232 | 232 | |
233 | 233 | // redirect |
234 | - wp_redirect( admin_url("admin.php?page={$plugin_page}&message=1") ); |
|
234 | + wp_redirect(admin_url("admin.php?page={$plugin_page}&message=1")); |
|
235 | 235 | exit; |
236 | 236 | |
237 | 237 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | |
246 | 246 | // actions |
247 | - add_action( 'acf/input/admin_head', array($this,'admin_head') ); |
|
247 | + add_action('acf/input/admin_head', array($this, 'admin_head')); |
|
248 | 248 | |
249 | 249 | } |
250 | 250 | |
@@ -271,34 +271,34 @@ discard block |
||
271 | 271 | |
272 | 272 | |
273 | 273 | // notices |
274 | - if( !empty($_GET['message']) && $_GET['message'] == '1' ) { |
|
274 | + if ( ! empty($_GET['message']) && $_GET['message'] == '1') { |
|
275 | 275 | |
276 | - acf_add_admin_notice( __("Options Updated",'acf') ); |
|
276 | + acf_add_admin_notice(__("Options Updated", 'acf')); |
|
277 | 277 | |
278 | 278 | } |
279 | 279 | |
280 | - if( empty($field_groups) ) { |
|
280 | + if (empty($field_groups)) { |
|
281 | 281 | |
282 | - acf_add_admin_notice(__("No Custom Field Groups found for this options page",'acf') . '. <a href="' . admin_url() . 'post-new.php?post_type=acf-field-group">' . __("Create a Custom Field Group",'acf') . '</a>', 'error'); |
|
282 | + acf_add_admin_notice(__("No Custom Field Groups found for this options page", 'acf').'. <a href="'.admin_url().'post-new.php?post_type=acf-field-group">'.__("Create a Custom Field Group", 'acf').'</a>', 'error'); |
|
283 | 283 | |
284 | 284 | } else { |
285 | 285 | |
286 | - foreach( $field_groups as $i => $field_group ) { |
|
286 | + foreach ($field_groups as $i => $field_group) { |
|
287 | 287 | |
288 | 288 | // vars |
289 | 289 | $id = "acf-{$field_group['key']}"; |
290 | 290 | $title = $field_group['title']; |
291 | 291 | $context = $field_group['position']; |
292 | 292 | $priority = 'high'; |
293 | - $args = array( 'field_group' => $field_group ); |
|
293 | + $args = array('field_group' => $field_group); |
|
294 | 294 | |
295 | 295 | |
296 | 296 | // tweaks to vars |
297 | - if( $context == 'acf_after_title' ) { |
|
297 | + if ($context == 'acf_after_title') { |
|
298 | 298 | |
299 | 299 | $context = 'normal'; |
300 | 300 | |
301 | - } elseif( $context == 'side' ) { |
|
301 | + } elseif ($context == 'side') { |
|
302 | 302 | |
303 | 303 | $priority = 'core'; |
304 | 304 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | |
311 | 311 | |
312 | 312 | // add meta box |
313 | - add_meta_box( $id, $title, array($this, 'render_meta_box'), 'acf_options_page', $context, $priority, $args ); |
|
313 | + add_meta_box($id, $title, array($this, 'render_meta_box'), 'acf_options_page', $context, $priority, $args); |
|
314 | 314 | |
315 | 315 | |
316 | 316 | } |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | * @return $post_id (int) |
336 | 336 | */ |
337 | 337 | |
338 | - function render_meta_box( $post, $args ) { |
|
338 | + function render_meta_box($post, $args) { |
|
339 | 339 | |
340 | 340 | // extract args |
341 | - extract( $args ); // all variables from the add_meta_box function |
|
342 | - extract( $args ); // all variables from the args argument |
|
341 | + extract($args); // all variables from the add_meta_box function |
|
342 | + extract($args); // all variables from the args argument |
|
343 | 343 | |
344 | 344 | |
345 | 345 | // vars |
@@ -360,19 +360,19 @@ discard block |
||
360 | 360 | |
361 | 361 | |
362 | 362 | // edit_url |
363 | - if( $field_group['ID'] && acf_current_user_can_admin() ) { |
|
363 | + if ($field_group['ID'] && acf_current_user_can_admin()) { |
|
364 | 364 | |
365 | - $o['edit_url'] = admin_url('post.php?post=' . $field_group['ID'] . '&action=edit'); |
|
365 | + $o['edit_url'] = admin_url('post.php?post='.$field_group['ID'].'&action=edit'); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | |
369 | 369 | |
370 | 370 | // load fields |
371 | - $fields = acf_get_fields( $field_group ); |
|
371 | + $fields = acf_get_fields($field_group); |
|
372 | 372 | |
373 | 373 | |
374 | 374 | // render |
375 | - acf_render_fields( $post_id, $fields, 'div', $field_group['instruction_placement'] ); |
|
375 | + acf_render_fields($post_id, $fields, 'div', $field_group['instruction_placement']); |
|
376 | 376 | |
377 | 377 | |
378 | 378 |