Advanced Custom Fields: Extended - Version 0.8.6.9

Version Description

  • Field: Flexible Content - Dynamic Render - External Layout Style & Script files now check for current domain before trying to automatically enqueue {file}-preview.css in Preview Mode
  • Field: Flexible Content - Dynamic Render - Fixed $field, $layout & $is_preview variables which weren't correctly passed to the Layout Template file
  • Field: Flexible Content - Dynamic Render - Fixed Layout Style & Script enqueue handles which weren't using the real Flexible Content field's name
  • Field: Radio / Checkbox - Added Group display settings. ## Group markup can be used in choices settings to create a new group
  • Field: Taxonomy Terms - Added "Radio Button" display type
Download this release

Release Info

Developer hwk-fr
Plugin Icon 128x128 Advanced Custom Fields: Extended
Version 0.8.6.9
Comparing to
See all releases

Code changes from version 0.8.6.8 to 0.8.6.9

acf-extended.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Advanced Custom Fields: Extended
4
  * Description: Enhancement Suite which improves Advanced Custom Fields administration
5
- * Version: 0.8.6.8
6
  * Author: ACF Extended
7
  * Author URI: https://www.acf-extended.com
8
  * Text Domain: acfe
@@ -16,7 +16,7 @@ if(!class_exists('ACFE')):
16
  class ACFE{
17
 
18
  // Version
19
- var $version = '0.8.6.8';
20
 
21
  // Settings
22
  var $settings = array();
@@ -152,6 +152,7 @@ class ACFE{
152
  /**
153
  * Fields
154
  */
 
155
  acfe_include('includes/fields/field-clone.php');
156
  acfe_include('includes/fields/field-file.php');
157
  acfe_include('includes/fields/field-flexible-content.php');
2
  /**
3
  * Plugin Name: Advanced Custom Fields: Extended
4
  * Description: Enhancement Suite which improves Advanced Custom Fields administration
5
+ * Version: 0.8.6.9
6
  * Author: ACF Extended
7
  * Author URI: https://www.acf-extended.com
8
  * Text Domain: acfe
16
  class ACFE{
17
 
18
  // Version
19
+ var $version = '0.8.6.9';
20
 
21
  // Settings
22
  var $settings = array();
152
  /**
153
  * Fields
154
  */
155
+ acfe_include('includes/fields/field-checkbox.php');
156
  acfe_include('includes/fields/field-clone.php');
157
  acfe_include('includes/fields/field-file.php');
158
  acfe_include('includes/fields/field-flexible-content.php');
assets/acf-extended-fields.js CHANGED
@@ -1387,4 +1387,36 @@ function acfe_recaptcha(){
1387
 
1388
  };
1389
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1390
  })(jQuery);
1387
 
1388
  };
1389
 
1390
+ /**
1391
+ * Field: Checkbox
1392
+ */
1393
+ acf.addAction('new_field/type=checkbox', function(field){
1394
+
1395
+ if(!field.has('acfeLabels'))
1396
+ return;
1397
+
1398
+ $.each(field.get('acfeLabels'), function(group, key){
1399
+
1400
+ field.$control().find('input[type=checkbox][value=' + key + ']').closest('ul').before('<strong>' + group + '</strong>');
1401
+
1402
+ });
1403
+
1404
+ });
1405
+
1406
+ /**
1407
+ * Field: Radio
1408
+ */
1409
+ acf.addAction('new_field/type=radio', function(field){
1410
+
1411
+ if(!field.has('acfeLabels'))
1412
+ return;
1413
+
1414
+ $.each(field.get('acfeLabels'), function(group, key){
1415
+
1416
+ field.$control().find('input[type=radio][value=' + key + ']').closest('li').prepend('<strong>' + group + '</strong>');
1417
+
1418
+ });
1419
+
1420
+ });
1421
+
1422
  })(jQuery);
assets/acf-extended.css CHANGED
@@ -316,6 +316,30 @@ tr.acf-field.acf-field-clone[data-acfe-clone-modal="1"] > .acf-input > .acfe-mod
316
  position:relative;
317
  }
318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
  /*
320
  * ACF Field: Google Map
321
  */
316
  position:relative;
317
  }
318
 
319
+ /*
320
+ * ACF Field: Checkbox
321
+ */
322
+ .acf-field-checkbox .acf-input .acf-checkbox-list.acf-bl li + li > strong{
323
+ margin-top:15px;
324
+ display:inline-block;
325
+ }
326
+
327
+ /*
328
+ * ACF Field: Radio
329
+ */
330
+ .acf-field-radio .acf-input .acf-radio-list.acf-hl li > strong{
331
+ vertical-align: middle;
332
+ margin-right: 20px;
333
+ }
334
+
335
+ .acf-field-radio .acf-input .acf-radio-list.acf-bl li > strong{
336
+ display:block;
337
+ }
338
+
339
+ .acf-field-radio .acf-input .acf-radio-list.acf-bl li + li > strong{
340
+ margin-top:15px;
341
+ }
342
+
343
  /*
344
  * ACF Field: Google Map
345
  */
includes/core/helpers.php CHANGED
@@ -249,7 +249,7 @@ function acfe_flexible_render_layout_template($layout, $field){
249
  if(!$is_preview){
250
 
251
  // Include
252
- load_template($file_found, false);
253
 
254
  // Preview
255
  }else{
@@ -265,11 +265,11 @@ function acfe_flexible_render_layout_template($layout, $field){
265
  // Include
266
  if(!empty($file_preview)){
267
 
268
- load_template($file_preview, false);
269
 
270
  }else{
271
 
272
- load_template($file_found, false);
273
 
274
  }
275
 
@@ -296,6 +296,9 @@ function acfe_flexible_render_layout_template($layout, $field){
296
 
297
  /**
298
  * ACFE Flexible: Render Enqueue
 
 
 
299
  */
300
  function acfe_flexible_render_layout_enqueue($layout, $field){
301
 
@@ -306,7 +309,7 @@ function acfe_flexible_render_layout_enqueue($layout, $field){
306
  $name = $field['_name'];
307
  $key = $field['key'];
308
  $l_name = $layout['name'];
309
- $handle = acf_slugify($field['name']) . '-layout-' . acf_slugify($l_name);
310
 
311
  // Files
312
  $style = acf_maybe_get($layout, 'acfe_flexible_render_style');
@@ -342,37 +345,43 @@ function acfe_flexible_render_layout_enqueue($layout, $field){
342
  // Check
343
  if(!empty($style)){
344
 
 
 
 
 
 
 
 
345
  // Locate
346
  $style_file = acfe_locate_file_url($style);
347
 
348
- // Enqueue
349
  if(!empty($style_file)){
350
 
351
- // Front-end
352
  wp_enqueue_style($handle, $style_file, array(), false, 'all');
353
 
354
  }
355
-
356
- // Preview
357
- if($is_preview){
358
 
 
 
 
359
  $path = pathinfo($style);
360
  $extension = $path['extension'];
361
-
362
  $style_preview = substr($style,0, -strlen($extension)-1);
363
  $style_preview .= '-preview.' . $extension;
364
-
365
  $style_preview = acfe_locate_file_url($style_preview);
366
-
367
  // Enqueue
368
  if(!empty($style_preview)){
369
-
370
  wp_enqueue_style($handle . '-preview', $style_preview, array(), false, 'all');
371
-
372
  }
373
-
374
  }
375
-
376
  }
377
 
378
  /**
@@ -393,12 +402,24 @@ function acfe_flexible_render_layout_enqueue($layout, $field){
393
  // Check
394
  if(!empty($script)){
395
 
396
- if(!$is_preview){
397
-
398
- $script_file = acfe_locate_file_url($script);
 
 
 
 
 
 
 
 
 
 
 
399
 
400
- if(!empty($script_file))
401
  wp_enqueue_script($handle, $script_file, array(), false, true);
 
 
402
 
403
  }else{
404
 
@@ -415,13 +436,10 @@ function acfe_flexible_render_layout_enqueue($layout, $field){
415
 
416
  wp_enqueue_script($handle . '-preview', $script_preview, array(), false, true);
417
 
418
- }else{
419
-
420
- $script_file = acfe_locate_file_url($script);
421
-
422
- if(!empty($script_file))
423
- wp_enqueue_script($handle, $script_file, array(), false, true);
424
-
425
  }
426
 
427
  }
@@ -628,7 +646,7 @@ function acfe_locate_file_url($filenames){
628
  * Locate File Path
629
  * Based on wp-includes\template.php:653
630
  */
631
- function acfe_locate_file_path($filenames, $load = false, $require_once = true){
632
 
633
  $located = '';
634
 
@@ -682,12 +700,6 @@ function acfe_locate_file_path($filenames, $load = false, $require_once = true){
682
 
683
  }
684
 
685
- if($load && $located != ''){
686
-
687
- load_template($located, $require_once);
688
-
689
- }
690
-
691
  return $located;
692
 
693
  }
249
  if(!$is_preview){
250
 
251
  // Include
252
+ include($file_found);
253
 
254
  // Preview
255
  }else{
265
  // Include
266
  if(!empty($file_preview)){
267
 
268
+ include($file_preview);
269
 
270
  }else{
271
 
272
+ include($file_found);
273
 
274
  }
275
 
296
 
297
  /**
298
  * ACFE Flexible: Render Enqueue
299
+ *
300
+ * @param $layout
301
+ * @param $field
302
  */
303
  function acfe_flexible_render_layout_enqueue($layout, $field){
304
 
309
  $name = $field['_name'];
310
  $key = $field['key'];
311
  $l_name = $layout['name'];
312
+ $handle = acf_slugify($name) . '-layout-' . acf_slugify($l_name);
313
 
314
  // Files
315
  $style = acf_maybe_get($layout, 'acfe_flexible_render_style');
345
  // Check
346
  if(!empty($style)){
347
 
348
+ // URL starting with current domain
349
+ if(stripos($style, home_url()) === 0){
350
+
351
+ $style = str_replace(home_url(), '', $style);
352
+
353
+ }
354
+
355
  // Locate
356
  $style_file = acfe_locate_file_url($style);
357
 
358
+ // Front-end
359
  if(!empty($style_file)){
360
 
 
361
  wp_enqueue_style($handle, $style_file, array(), false, 'all');
362
 
363
  }
 
 
 
364
 
365
+ // Preview
366
+ if($is_preview && stripos($style, 'http://') !== 0 && stripos($style, 'https://') !== 0 && stripos($style, '//') !== 0){
367
+
368
  $path = pathinfo($style);
369
  $extension = $path['extension'];
370
+
371
  $style_preview = substr($style,0, -strlen($extension)-1);
372
  $style_preview .= '-preview.' . $extension;
373
+
374
  $style_preview = acfe_locate_file_url($style_preview);
375
+
376
  // Enqueue
377
  if(!empty($style_preview)){
378
+
379
  wp_enqueue_style($handle . '-preview', $style_preview, array(), false, 'all');
380
+
381
  }
382
+
383
  }
384
+
385
  }
386
 
387
  /**
402
  // Check
403
  if(!empty($script)){
404
 
405
+ // URL starting with current domain
406
+ if(stripos($script, home_url()) === 0){
407
+
408
+ $script = str_replace(home_url(), '', $script);
409
+
410
+ }
411
+
412
+ // Locate
413
+ $script_file = acfe_locate_file_url($script);
414
+
415
+ // Front-end
416
+ if(!$is_preview || (stripos($script, 'http://') === 0 || stripos($script, 'https://') === 0 || stripos($script, '//') === 0)){
417
+
418
+ if(!empty($script_file)){
419
 
 
420
  wp_enqueue_script($handle, $script_file, array(), false, true);
421
+
422
+ }
423
 
424
  }else{
425
 
436
 
437
  wp_enqueue_script($handle . '-preview', $script_preview, array(), false, true);
438
 
439
+ }elseif(!empty($script_file)){
440
+
441
+ wp_enqueue_script($handle, $script_file, array(), false, true);
442
+
 
 
 
443
  }
444
 
445
  }
646
  * Locate File Path
647
  * Based on wp-includes\template.php:653
648
  */
649
+ function acfe_locate_file_path($filenames){
650
 
651
  $located = '';
652
 
700
 
701
  }
702
 
 
 
 
 
 
 
703
  return $located;
704
 
705
  }
includes/fields/field-checkbox.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if(!defined('ABSPATH'))
4
+ exit;
5
+
6
+ if(!class_exists('acfe_field_checkbox')):
7
+
8
+ class acfe_field_checkbox{
9
+
10
+ function __construct(){
11
+
12
+ add_action('current_screen', array($this, 'current_screen'));
13
+
14
+ }
15
+
16
+ function current_screen(){
17
+
18
+ // Field Group UI
19
+ if(acfe_is_admin_screen()){
20
+
21
+ add_filter('acf/prepare_field/name=choices', array($this, 'prepare_field_choices'), 5);
22
+
23
+ }else{
24
+
25
+ // Filters
26
+ add_filter('acf/prepare_field/type=acfe_taxonomy_terms', array($this, 'prepare_checkbox'), 20);
27
+ add_filter('acf/prepare_field/type=radio', array($this, 'prepare_checkbox'), 20);
28
+ add_filter('acf/prepare_field/type=checkbox', array($this, 'prepare_checkbox'), 20);
29
+
30
+ add_filter('acf/prepare_field/type=radio', array($this, 'prepare_radio'), 20);
31
+ add_filter('acf/prepare_field/type=acfe_taxonomy_terms', array($this, 'prepare_radio'), 20);
32
+
33
+ add_filter('acfe/field_wrapper_attributes/type=radio', array($this, 'field_wrapper'), 10, 2);
34
+ add_filter('acfe/field_wrapper_attributes/type=checkbox', array($this, 'field_wrapper'), 10, 2);
35
+
36
+ }
37
+
38
+
39
+
40
+ }
41
+
42
+ function prepare_field_choices($field){
43
+
44
+ $wrapper = $field['wrapper'];
45
+
46
+ if(acf_maybe_get($wrapper, 'data-setting') !== 'radio' && acf_maybe_get($wrapper, 'data-setting') !== 'checkbox')
47
+ return $field;
48
+
49
+ $field['instructions'] .= '<br/><br/>You may use "## Title" to create a group of options.';
50
+
51
+ return $field;
52
+
53
+ }
54
+
55
+ function prepare_checkbox($field){
56
+
57
+ if(empty($field['choices']))
58
+ return $field;
59
+
60
+ // Map '## Group'
61
+ if(is_array($field['choices'])){
62
+
63
+ $found = false;
64
+ $found_array = array();
65
+
66
+ foreach($field['choices'] as $k => $choice){
67
+
68
+ if(is_string($choice)){
69
+
70
+ $choice = trim($choice);
71
+
72
+ if(strpos($choice, '##') === 0){
73
+
74
+ $choice = substr($choice, 2);
75
+ $choice = trim($choice);
76
+
77
+ $found = $choice;
78
+ $found_array[$choice] = array();
79
+
80
+ }elseif(!empty($found)){
81
+
82
+ $found_array[$found][$k] = $choice;
83
+
84
+ }
85
+
86
+ }
87
+
88
+ }
89
+
90
+ if(!empty($found_array)){
91
+
92
+ $field['choices'] = $found_array;
93
+
94
+ }
95
+
96
+ }
97
+
98
+ // Labels
99
+ $labels = $this->walk($field['choices']);
100
+
101
+ if(!empty($labels)){
102
+
103
+ $field['acfe_labels'] = $labels;
104
+
105
+ }
106
+
107
+ return $field;
108
+
109
+ }
110
+
111
+ function walk($choices = array(), $depth = 1, $labels = array()){
112
+
113
+ // bail early if no choices
114
+ if(empty($choices))
115
+ return $labels;
116
+
117
+ foreach($choices as $value => $label){
118
+
119
+ // optgroup
120
+ if(is_array($label)){
121
+
122
+ reset($label);
123
+ $key = key($label);
124
+
125
+ if(!is_numeric($value))
126
+ $labels = array_merge($labels, array($value => $key));
127
+
128
+ $labels = $this->walk($label, $depth+1, $labels);
129
+
130
+ }
131
+
132
+ }
133
+
134
+ return $labels;
135
+
136
+ }
137
+
138
+ function prepare_radio($field){
139
+
140
+ if($field['type'] !== 'radio' && $field['field_type'] !== 'radio')
141
+ return $field;
142
+
143
+ if(empty($field['choices']))
144
+ return $field;
145
+
146
+ $choices = array();
147
+
148
+ foreach($field['choices'] as $value => $label){
149
+
150
+ if(is_array($label)){
151
+
152
+ $choices = $choices + $label;
153
+
154
+ }else{
155
+
156
+ $choices = $choices + array($value => $label);
157
+
158
+ }
159
+
160
+ }
161
+
162
+ $field['choices'] = $choices;
163
+
164
+ return $field;
165
+
166
+ }
167
+
168
+ function field_wrapper($wrapper, $field){
169
+
170
+ $labels = acf_maybe_get($field, 'acfe_labels');
171
+
172
+ if(empty($labels))
173
+ return $wrapper;
174
+
175
+ $wrapper['data-acfe-labels'] = $labels;
176
+
177
+ return $wrapper;
178
+
179
+ }
180
+
181
+ }
182
+
183
+ new acfe_field_checkbox();
184
+
185
+ endif;
includes/fields/field-taxonomy-terms.php CHANGED
@@ -32,6 +32,7 @@ class acfe_field_taxonomy_terms extends acf_field{
32
  'load_terms' => 0,
33
  'save_terms' => 0,
34
  'allow_custom' => 0,
 
35
  );
36
 
37
  // ajax
@@ -761,6 +762,7 @@ class acfe_field_taxonomy_terms extends acf_field{
761
  'optgroup' => true,
762
  'choices' => array(
763
  'checkbox' => __('Checkbox', 'acf'),
 
764
  'select' => _x('Select', 'noun', 'acf')
765
  )
766
  ));
@@ -820,6 +822,13 @@ class acfe_field_taxonomy_terms extends acf_field{
820
  'value' => 'select',
821
  ),
822
  ),
 
 
 
 
 
 
 
823
  )
824
  ));
825
 
@@ -920,6 +929,13 @@ class acfe_field_taxonomy_terms extends acf_field{
920
  'value' => 'checkbox',
921
  ),
922
  ),
 
 
 
 
 
 
 
923
  )
924
  ));
925
 
32
  'load_terms' => 0,
33
  'save_terms' => 0,
34
  'allow_custom' => 0,
35
+ 'other_choice' => 0,
36
  );
37
 
38
  // ajax
762
  'optgroup' => true,
763
  'choices' => array(
764
  'checkbox' => __('Checkbox', 'acf'),
765
+ 'radio' => __('Radio Buttons', 'acf'),
766
  'select' => _x('Select', 'noun', 'acf')
767
  )
768
  ));
822
  'value' => 'select',
823
  ),
824
  ),
825
+ array(
826
+ array(
827
+ 'field' => 'field_type',
828
+ 'operator' => '==',
829
+ 'value' => 'radio',
830
+ ),
831
+ ),
832
  )
833
  ));
834
 
929
  'value' => 'checkbox',
930
  ),
931
  ),
932
+ array(
933
+ array(
934
+ 'field' => 'field_type',
935
+ 'operator' => '==',
936
+ 'value' => 'radio',
937
+ ),
938
+ ),
939
  )
940
  ));
941
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: acf, custom fields, meta, admin, fields, form, repeater, content
5
  Requires at least: 4.9
6
  Tested up to: 5.4
7
  Requires PHP: 5.6
8
- Stable tag: 0.8.6.8
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -866,6 +866,13 @@ function my_acfe_modules(){
866
 
867
  == Changelog ==
868
 
 
 
 
 
 
 
 
869
  = 0.8.6.8 =
870
  * Field: Flexible Content - Enhanced Code Base
871
  * Field: Flexible Content - Dynamic Render - Enhanced `get_flexible()` & `the_flexible()` functions logic
5
  Requires at least: 4.9
6
  Tested up to: 5.4
7
  Requires PHP: 5.6
8
+ Stable tag: 0.8.6.9
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
866
 
867
  == Changelog ==
868
 
869
+ = 0.8.6.9 =
870
+ * Field: Flexible Content - Dynamic Render - External Layout Style & Script files now check for current domain before trying to automatically enqueue `{file}-preview.css` in Preview Mode
871
+ * Field: Flexible Content - Dynamic Render - Fixed `$field`, `$layout` & `$is_preview` variables which weren't correctly passed to the Layout Template file
872
+ * Field: Flexible Content - Dynamic Render - Fixed Layout Style & Script enqueue handles which weren't using the real Flexible Content field's name
873
+ * Field: Radio / Checkbox - Added Group display settings. `## Group` markup can be used in choices settings to create a new group
874
+ * Field: Taxonomy Terms - Added "Radio Button" display type
875
+
876
  = 0.8.6.8 =
877
  * Field: Flexible Content - Enhanced Code Base
878
  * Field: Flexible Content - Dynamic Render - Enhanced `get_flexible()` & `the_flexible()` functions logic