Version Description
- Field: Advanced Link - Added instructions to add custom fields in the field administration
- Field: Advanced Link - Added filters
acfe/fields/advanced_link/fields/name=my_field
&acfe/fields/advanced_link/fields/key=field_xxxxxxx
- Field: Advanced Link - Changed values keys to:
type
,url
,post
,title
&target
- Field: Button - Updated JS hook
acf.doAction('acfe/fields/button/before_ajax', $el, data)
- Field: Button - Updated JS hook
acf.doAction('acfe/fields/button/ajax_success', response, $el, data)
- Field: Column - Fixed endpoint column not correctly closing the row
- Field: Flexible Content - Added JS hook
acf.doAction('acfe/fields/flexible_content/before_preview', $el, data)
- Field: Flexible Content - Added JS hook
acf.doAction('acfe/fields/flexible_content/preview', response, $el, data)
- Field: Flexible Content - Clone/Copy/Paste - Fixed a problem where new select option values weren't properly duplicated (thanks @chrisschrijver)
- Module: Dynamic Forms - Advanced settings: Fixed
prepare_field
on form front - Module: Dynamic Forms - Fixed a compatibility problem if a dynamic form was named
form
- Module: Dynamic Forms - Rename
field class
toinput class
- Module: Dynamic Forms - Fixed a problem where native ACF Form would not properly work (thanks @maximelessard)
- Module: Dynamic Forms - Added Javascript to avoid re-submission on page refresh when 'Hide form' is set to ON
Download this release
Release Info
Developer | hwk-fr |
Plugin | Advanced Custom Fields: Extended |
Version | 0.8.1 |
Comparing to | |
See all releases |
Code changes from version 0.8 to 0.8.1
- acf-extended.php +2 -2
- assets/acf-extended-fc-control.js +3 -3
- assets/acf-extended-fc.js +6 -0
- assets/acf-extended-fields.js +13 -12
- assets/acf-extended.css +1 -0
- includes/core/helpers.php +2 -2
- includes/fields/field-advanced-link.php +74 -23
- includes/fields/field-dynamic-message.php +1 -1
- includes/modules/form/field-group.php +1 -1
- includes/modules/form/form-front.php +35 -21
- readme.txt +17 -4
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 |
* 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';
|
20 |
|
21 |
// Settings
|
22 |
var $settings = array();
|
2 |
/**
|
3 |
* Plugin Name: Advanced Custom Fields: Extended
|
4 |
* Description: Enhancement Suite which improves Advanced Custom Fields administration
|
5 |
+
* Version: 0.8.1
|
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.1';
|
20 |
|
21 |
// Settings
|
22 |
var $settings = array();
|
assets/acf-extended-fc-control.js
CHANGED
@@ -164,10 +164,10 @@
|
|
164 |
|
165 |
}
|
166 |
|
167 |
-
var $_layout = $layout.clone();
|
168 |
-
|
169 |
// Fix inputs
|
170 |
-
flexible.acfeFixInputs($
|
|
|
|
|
171 |
|
172 |
// Clean Layout
|
173 |
flexible.acfeCleanLayouts($_layout);
|
164 |
|
165 |
}
|
166 |
|
|
|
|
|
167 |
// Fix inputs
|
168 |
+
flexible.acfeFixInputs($layout);
|
169 |
+
|
170 |
+
var $_layout = $layout.clone();
|
171 |
|
172 |
// Clean Layout
|
173 |
flexible.acfeCleanLayouts($_layout);
|
assets/acf-extended-fc.js
CHANGED
@@ -131,6 +131,8 @@
|
|
131 |
layout: $layout.data('layout'),
|
132 |
value: acf.serialize($layout, prefix)
|
133 |
};
|
|
|
|
|
134 |
|
135 |
// ajax
|
136 |
$.ajax({
|
@@ -139,6 +141,9 @@
|
|
139 |
dataType: 'html',
|
140 |
type: 'post',
|
141 |
success: function(response){
|
|
|
|
|
|
|
142 |
if(response){
|
143 |
|
144 |
$placeholder.find('> .acfe-flexible-placeholder').html(response);
|
@@ -148,6 +153,7 @@
|
|
148 |
$placeholder.removeClass('acfe-flexible-collapsed-preview');
|
149 |
|
150 |
}
|
|
|
151 |
},
|
152 |
complete: function(){
|
153 |
|
131 |
layout: $layout.data('layout'),
|
132 |
value: acf.serialize($layout, prefix)
|
133 |
};
|
134 |
+
|
135 |
+
acf.doAction('acfe/fields/flexible_content/before_preview', flexible.$el, ajaxData);
|
136 |
|
137 |
// ajax
|
138 |
$.ajax({
|
141 |
dataType: 'html',
|
142 |
type: 'post',
|
143 |
success: function(response){
|
144 |
+
|
145 |
+
acf.doAction('acfe/fields/flexible_content/preview', response, flexible.$el, ajaxData);
|
146 |
+
|
147 |
if(response){
|
148 |
|
149 |
$placeholder.find('> .acfe-flexible-placeholder').html(response);
|
153 |
$placeholder.removeClass('acfe-flexible-collapsed-preview');
|
154 |
|
155 |
}
|
156 |
+
|
157 |
},
|
158 |
complete: function(){
|
159 |
|
assets/acf-extended-fields.js
CHANGED
@@ -120,8 +120,6 @@
|
|
120 |
if(this.get('ajax')){
|
121 |
|
122 |
e.preventDefault();
|
123 |
-
|
124 |
-
acf.doAction('acfe/fields/button/before_ajax', this.$el);
|
125 |
|
126 |
// serialize form data
|
127 |
var data = {
|
@@ -130,6 +128,8 @@
|
|
130 |
field_key: this.get('key')
|
131 |
};
|
132 |
|
|
|
|
|
133 |
// ajax
|
134 |
$.ajax({
|
135 |
url: acf.get('ajaxurl'),
|
@@ -137,18 +137,16 @@
|
|
137 |
type: 'post',
|
138 |
dataType: 'json',
|
139 |
context: this,
|
140 |
-
success:
|
|
|
|
|
|
|
|
|
141 |
});
|
142 |
|
143 |
}
|
144 |
|
145 |
-
}
|
146 |
-
|
147 |
-
onAjaxSuccess: function(response){
|
148 |
-
|
149 |
-
acf.doAction('acfe/fields/button/ajax_success', response, this.$el);
|
150 |
-
|
151 |
-
},
|
152 |
|
153 |
});
|
154 |
|
@@ -396,9 +394,12 @@
|
|
396 |
|
397 |
}
|
398 |
|
399 |
-
|
400 |
|
401 |
-
|
|
|
|
|
|
|
402 |
|
403 |
}
|
404 |
|
120 |
if(this.get('ajax')){
|
121 |
|
122 |
e.preventDefault();
|
|
|
|
|
123 |
|
124 |
// serialize form data
|
125 |
var data = {
|
128 |
field_key: this.get('key')
|
129 |
};
|
130 |
|
131 |
+
acf.doAction('acfe/fields/button/before_ajax', this.$el, data);
|
132 |
+
|
133 |
// ajax
|
134 |
$.ajax({
|
135 |
url: acf.get('ajaxurl'),
|
137 |
type: 'post',
|
138 |
dataType: 'json',
|
139 |
context: this,
|
140 |
+
success: function(response){
|
141 |
+
|
142 |
+
acf.doAction('acfe/fields/button/ajax_success', response, this.$el, data);
|
143 |
+
|
144 |
+
}
|
145 |
});
|
146 |
|
147 |
}
|
148 |
|
149 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
});
|
152 |
|
394 |
|
395 |
}
|
396 |
|
397 |
+
if(this.get('endpoint')){
|
398 |
|
399 |
+
this.$el.find('> .acf-label').remove();
|
400 |
+
this.$el.find('> .acf-input').remove();
|
401 |
+
|
402 |
+
return;
|
403 |
|
404 |
}
|
405 |
|
assets/acf-extended.css
CHANGED
@@ -447,6 +447,7 @@ code, kbd, pre, samp{
|
|
447 |
.acf-fields > .acf-field.acf-field-acfe-column[data-endpoint="1"]{
|
448 |
clear: both;
|
449 |
border-top: 1px solid #eee;
|
|
|
450 |
}
|
451 |
|
452 |
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="1/6"] {
|
447 |
.acf-fields > .acf-field.acf-field-acfe-column[data-endpoint="1"]{
|
448 |
clear: both;
|
449 |
border-top: 1px solid #eee;
|
450 |
+
width:100%;
|
451 |
}
|
452 |
|
453 |
.acf-fields > .acf-field.acf-field-acfe-column[data-columns="1/6"] {
|
includes/core/helpers.php
CHANGED
@@ -597,7 +597,7 @@ if(function_exists('acf_add_filter_variations')){
|
|
597 |
|
598 |
function acfe_form_is_admin(){
|
599 |
|
600 |
-
if((is_admin() && !wp_doing_ajax()) || (is_admin() && wp_doing_ajax() && acf_maybe_get_POST('_acf_screen') !== '
|
601 |
return true;
|
602 |
|
603 |
return false;
|
@@ -606,7 +606,7 @@ function acfe_form_is_admin(){
|
|
606 |
|
607 |
function acfe_form_is_front(){
|
608 |
|
609 |
-
if(!is_admin() || (is_admin() && wp_doing_ajax() && acf_maybe_get_POST('_acf_screen') === '
|
610 |
return true;
|
611 |
|
612 |
return false;
|
597 |
|
598 |
function acfe_form_is_admin(){
|
599 |
|
600 |
+
if((is_admin() && !wp_doing_ajax()) || (is_admin() && wp_doing_ajax() && acf_maybe_get_POST('_acf_screen') !== 'acfe_form'))
|
601 |
return true;
|
602 |
|
603 |
return false;
|
606 |
|
607 |
function acfe_form_is_front(){
|
608 |
|
609 |
+
if(!is_admin() || (is_admin() && wp_doing_ajax() && acf_maybe_get_POST('_acf_screen') === 'acfe_form'))
|
610 |
return true;
|
611 |
|
612 |
return false;
|
includes/fields/field-advanced-link.php
CHANGED
@@ -15,7 +15,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
15 |
);
|
16 |
|
17 |
acf_add_local_field(array(
|
18 |
-
'key' => '
|
19 |
'label' => __('Post', 'acf'),
|
20 |
'type' => 'post_object',
|
21 |
'required' => false,
|
@@ -27,15 +27,64 @@ class acfe_field_advanced_link extends acf_field{
|
|
27 |
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
function get_link($value = ''){
|
31 |
|
32 |
// vars
|
33 |
$value = wp_parse_args($value, array(
|
34 |
-
|
35 |
-
|
36 |
-
'
|
37 |
-
'
|
38 |
-
'
|
39 |
));
|
40 |
|
41 |
$link = array(
|
@@ -47,24 +96,24 @@ class acfe_field_advanced_link extends acf_field{
|
|
47 |
);
|
48 |
|
49 |
|
50 |
-
$link['type'] = $value['
|
51 |
-
$link['title'] = $value['
|
52 |
-
if($value['
|
53 |
$link['target'] = '_blank';
|
54 |
|
55 |
// URL
|
56 |
-
if($value['
|
57 |
|
58 |
-
$link['url'] = $value['
|
59 |
|
60 |
// Post
|
61 |
-
}elseif($value['
|
62 |
|
63 |
-
$link['post'] = $value['
|
64 |
|
65 |
-
if(!empty($value['
|
66 |
|
67 |
-
$link['url'] = get_permalink($value['
|
68 |
|
69 |
}
|
70 |
|
@@ -116,7 +165,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
116 |
array(
|
117 |
'prefix' => $field['name'],
|
118 |
'name' => 'type',
|
119 |
-
'key' => '
|
120 |
'label' => __('Type', 'acf'),
|
121 |
'type' => 'radio',
|
122 |
'value' => $link['type'],
|
@@ -131,7 +180,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
131 |
array(
|
132 |
'prefix' => $field['name'],
|
133 |
'name' => 'url',
|
134 |
-
'key' => '
|
135 |
'label' => __('URL', 'acf'),
|
136 |
'type' => 'text',
|
137 |
'value' => $link['url'],
|
@@ -140,7 +189,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
140 |
'conditional_logic' => array(
|
141 |
array(
|
142 |
array(
|
143 |
-
'field' => '
|
144 |
'operator' => '==',
|
145 |
'value' => 'url',
|
146 |
)
|
@@ -152,7 +201,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
152 |
array(
|
153 |
'prefix' => $field['name'],
|
154 |
'name' => 'post',
|
155 |
-
'key' => '
|
156 |
'label' => __('Post', 'acf'),
|
157 |
'type' => 'post_object',
|
158 |
'value' => $link['post'],
|
@@ -162,7 +211,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
162 |
'conditional_logic' => array(
|
163 |
array(
|
164 |
array(
|
165 |
-
'field' => '
|
166 |
'operator' => '==',
|
167 |
'value' => 'post',
|
168 |
)
|
@@ -173,7 +222,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
173 |
array(
|
174 |
'prefix' => $field['name'],
|
175 |
'name' => 'title',
|
176 |
-
'key' => '
|
177 |
'label' => __('Link text', 'acf'),
|
178 |
'type' => 'text',
|
179 |
'value' => $link['title'],
|
@@ -184,7 +233,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
184 |
array(
|
185 |
'prefix' => $field['name'],
|
186 |
'name' => 'target',
|
187 |
-
'key' => '
|
188 |
'label' => __('Target', 'acf'),
|
189 |
'type' => 'true_false',
|
190 |
'value' => $link['target'],
|
@@ -196,6 +245,8 @@ class acfe_field_advanced_link extends acf_field{
|
|
196 |
);
|
197 |
|
198 |
$fields = apply_filters('acfe/fields/advanced_link/fields', $fields, $field, $link);
|
|
|
|
|
199 |
|
200 |
?>
|
201 |
|
@@ -251,7 +302,7 @@ class acfe_field_advanced_link extends acf_field{
|
|
251 |
return $valid;
|
252 |
|
253 |
// URL is required
|
254 |
-
if(empty($value) || (empty($value['
|
255 |
return false;
|
256 |
|
257 |
// return
|
15 |
);
|
16 |
|
17 |
acf_add_local_field(array(
|
18 |
+
'key' => 'post',
|
19 |
'label' => __('Post', 'acf'),
|
20 |
'type' => 'post_object',
|
21 |
'required' => false,
|
27 |
|
28 |
}
|
29 |
|
30 |
+
function render_field_settings($field){
|
31 |
+
|
32 |
+
$field_name = 'field_name';
|
33 |
+
if(acf_maybe_get($field, 'name'))
|
34 |
+
$field_name = $field['name'];
|
35 |
+
|
36 |
+
ob_start();
|
37 |
+
?>
|
38 |
+
Add your own fields using the following hook:<br /><br />
|
39 |
+
<pre>
|
40 |
+
add_filter('acfe/fields/advanced_link/fields/name=<?php echo $field_name; ?>', 'my_acf_advanced_link_fields', 10, 3);
|
41 |
+
function my_acf_advanced_link_fields($fields, $field, $value){
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @array $fields Sub fields array
|
45 |
+
* @array $field Advanced Link field
|
46 |
+
* @array $value The field values
|
47 |
+
*/
|
48 |
+
|
49 |
+
$fields[] = array(
|
50 |
+
'prefix' => $field['name'],
|
51 |
+
'name' => 'my_field',
|
52 |
+
'key' => 'acfe_advanced_link_my_field',
|
53 |
+
'label' => 'My field',
|
54 |
+
'type' => 'true_false',
|
55 |
+
'ui' => true,
|
56 |
+
'value' => isset($value['my_field']) ? $value['my_field'] : ''
|
57 |
+
);
|
58 |
+
|
59 |
+
return $fields;
|
60 |
+
|
61 |
+
}
|
62 |
+
</pre>
|
63 |
+
<?php
|
64 |
+
|
65 |
+
$message = ob_get_clean();
|
66 |
+
|
67 |
+
// field_type
|
68 |
+
acf_render_field_setting($field, array(
|
69 |
+
'label' => __('Instructions','acf'),
|
70 |
+
'instructions' => '',
|
71 |
+
'type' => 'message',
|
72 |
+
'name' => 'instructions',
|
73 |
+
'message' => $message,
|
74 |
+
'new_lines' => false
|
75 |
+
));
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
function get_link($value = ''){
|
80 |
|
81 |
// vars
|
82 |
$value = wp_parse_args($value, array(
|
83 |
+
'post' => '',
|
84 |
+
'type' => 'url',
|
85 |
+
'url' => '',
|
86 |
+
'title' => '',
|
87 |
+
'target' => false,
|
88 |
));
|
89 |
|
90 |
$link = array(
|
96 |
);
|
97 |
|
98 |
|
99 |
+
$link['type'] = $value['type'];
|
100 |
+
$link['title'] = $value['title'];
|
101 |
+
if($value['target'])
|
102 |
$link['target'] = '_blank';
|
103 |
|
104 |
// URL
|
105 |
+
if($value['type'] === 'url'){
|
106 |
|
107 |
+
$link['url'] = $value['url'];
|
108 |
|
109 |
// Post
|
110 |
+
}elseif($value['type'] === 'post'){
|
111 |
|
112 |
+
$link['post'] = $value['post'];
|
113 |
|
114 |
+
if(!empty($value['post'])){
|
115 |
|
116 |
+
$link['url'] = get_permalink($value['post']);
|
117 |
|
118 |
}
|
119 |
|
165 |
array(
|
166 |
'prefix' => $field['name'],
|
167 |
'name' => 'type',
|
168 |
+
'key' => 'type',
|
169 |
'label' => __('Type', 'acf'),
|
170 |
'type' => 'radio',
|
171 |
'value' => $link['type'],
|
180 |
array(
|
181 |
'prefix' => $field['name'],
|
182 |
'name' => 'url',
|
183 |
+
'key' => 'url',
|
184 |
'label' => __('URL', 'acf'),
|
185 |
'type' => 'text',
|
186 |
'value' => $link['url'],
|
189 |
'conditional_logic' => array(
|
190 |
array(
|
191 |
array(
|
192 |
+
'field' => 'type',
|
193 |
'operator' => '==',
|
194 |
'value' => 'url',
|
195 |
)
|
201 |
array(
|
202 |
'prefix' => $field['name'],
|
203 |
'name' => 'post',
|
204 |
+
'key' => 'post',
|
205 |
'label' => __('Post', 'acf'),
|
206 |
'type' => 'post_object',
|
207 |
'value' => $link['post'],
|
211 |
'conditional_logic' => array(
|
212 |
array(
|
213 |
array(
|
214 |
+
'field' => 'type',
|
215 |
'operator' => '==',
|
216 |
'value' => 'post',
|
217 |
)
|
222 |
array(
|
223 |
'prefix' => $field['name'],
|
224 |
'name' => 'title',
|
225 |
+
'key' => 'title',
|
226 |
'label' => __('Link text', 'acf'),
|
227 |
'type' => 'text',
|
228 |
'value' => $link['title'],
|
233 |
array(
|
234 |
'prefix' => $field['name'],
|
235 |
'name' => 'target',
|
236 |
+
'key' => 'target',
|
237 |
'label' => __('Target', 'acf'),
|
238 |
'type' => 'true_false',
|
239 |
'value' => $link['target'],
|
245 |
);
|
246 |
|
247 |
$fields = apply_filters('acfe/fields/advanced_link/fields', $fields, $field, $link);
|
248 |
+
$fields = apply_filters('acfe/fields/advanced_link/fields/name=' . $field['_name'], $fields, $field, $link);
|
249 |
+
$fields = apply_filters('acfe/fields/advanced_link/fields/key=' . $field['key'], $fields, $field, $link);
|
250 |
|
251 |
?>
|
252 |
|
302 |
return $valid;
|
303 |
|
304 |
// URL is required
|
305 |
+
if(empty($value) || (empty($value['url'] && empty($value['post']))))
|
306 |
return false;
|
307 |
|
308 |
// return
|
includes/fields/field-dynamic-message.php
CHANGED
@@ -18,7 +18,7 @@ class acfe_field_dynamic_message extends acf_field{
|
|
18 |
function render_field_settings($field){
|
19 |
|
20 |
$field_name = 'field_name';
|
21 |
-
if(
|
22 |
$field_name = $field['name'];
|
23 |
|
24 |
ob_start();
|
18 |
function render_field_settings($field){
|
19 |
|
20 |
$field_name = 'field_name';
|
21 |
+
if(acf_maybe_get($field, 'name'))
|
22 |
$field_name = $field['name'];
|
23 |
|
24 |
ob_start();
|
includes/modules/form/field-group.php
CHANGED
@@ -257,7 +257,7 @@ acf_add_local_field_group(array(
|
|
257 |
'acfe_permissions' => '',
|
258 |
'default_value' => '',
|
259 |
'placeholder' => '',
|
260 |
-
'prepend' => '
|
261 |
'append' => '',
|
262 |
'maxlength' => '',
|
263 |
),
|
257 |
'acfe_permissions' => '',
|
258 |
'default_value' => '',
|
259 |
'placeholder' => '',
|
260 |
+
'prepend' => 'input class',
|
261 |
'append' => '',
|
262 |
'maxlength' => '',
|
263 |
),
|
includes/modules/form/form-front.php
CHANGED
@@ -32,9 +32,9 @@ class acfe_form_front{
|
|
32 |
if(empty($form))
|
33 |
return;
|
34 |
|
|
|
35 |
$form_name = acf_maybe_get($form, 'form_name');
|
36 |
$form_id = acf_maybe_get($form, 'form_id');
|
37 |
-
$post_id = acf_maybe_get($form, '_acf_post_id');
|
38 |
|
39 |
if(!$form_name || !$form_id)
|
40 |
return;
|
@@ -60,17 +60,16 @@ class acfe_form_front{
|
|
60 |
function check_submit_form(){
|
61 |
|
62 |
// Verify nonce.
|
63 |
-
if(
|
64 |
-
return
|
65 |
-
|
66 |
-
// Confirm form has been submitted.
|
67 |
if(!acf_maybe_get_POST('_acf_form'))
|
68 |
return;
|
69 |
-
|
70 |
-
$form = json_decode(acf_decrypt($_POST['_acf_form']), true);
|
71 |
|
72 |
-
|
73 |
-
|
|
|
|
|
74 |
|
75 |
// ACF
|
76 |
$_POST['acf'] = isset($_POST['acf']) ? $_POST['acf'] : array();
|
@@ -93,7 +92,7 @@ class acfe_form_front{
|
|
93 |
function submit_form($form){
|
94 |
|
95 |
// vars
|
96 |
-
$post_id = acf_maybe_get($form, 'post_id',
|
97 |
$form_name = acf_maybe_get($form, 'form_name');
|
98 |
$form_id = acf_maybe_get($form, 'form_id');
|
99 |
|
@@ -148,15 +147,15 @@ class acfe_form_front{
|
|
148 |
|
149 |
}
|
150 |
|
151 |
-
function validate_form($
|
152 |
|
153 |
$form_name = false;
|
154 |
$form_id = false;
|
155 |
|
156 |
// String
|
157 |
-
if(is_string($
|
158 |
|
159 |
-
$form = get_page_by_path($
|
160 |
if(!$form)
|
161 |
return false;
|
162 |
|
@@ -167,13 +166,13 @@ class acfe_form_front{
|
|
167 |
}
|
168 |
|
169 |
// Int
|
170 |
-
elseif(is_int($
|
171 |
|
172 |
-
if(get_post_type($
|
173 |
return false;
|
174 |
|
175 |
// Form
|
176 |
-
$form_id = $
|
177 |
$form_name = get_field('acfe_form_name', $form_id);
|
178 |
|
179 |
}
|
@@ -290,7 +289,7 @@ class acfe_form_front{
|
|
290 |
$defaults['field_el'] = get_field('acf-field_acfe_form_form_field_el', $form_id);
|
291 |
$defaults['instruction_placement'] = get_field('acfe_form_instruction_placement', $form_id);
|
292 |
|
293 |
-
$args = wp_parse_args($
|
294 |
|
295 |
// Override
|
296 |
if(!empty($args['fields_attributes']['class']))
|
@@ -417,8 +416,19 @@ class acfe_form_front{
|
|
417 |
|
418 |
}
|
419 |
|
420 |
-
if($args['updated_hide_form'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
421 |
return;
|
|
|
|
|
422 |
|
423 |
}
|
424 |
|
@@ -428,6 +438,9 @@ class acfe_form_front{
|
|
428 |
|
429 |
add_filter('acf/prepare_field', function($field) use($args){
|
430 |
|
|
|
|
|
|
|
431 |
if(!empty($args['fields_attributes']['wrapper_class']))
|
432 |
$field['wrapper']['class'] .= ' ' . $args['fields_attributes']['wrapper_class'];
|
433 |
|
@@ -447,6 +460,9 @@ class acfe_form_front{
|
|
447 |
|
448 |
add_filter('acf/prepare_field/key=' . $field_key, function($field) use($array){
|
449 |
|
|
|
|
|
|
|
450 |
$field = array_merge($field, $array);
|
451 |
|
452 |
return $field;
|
@@ -469,7 +485,7 @@ class acfe_form_front{
|
|
469 |
|
470 |
// render post data
|
471 |
acf_form_data(array(
|
472 |
-
'screen' => '
|
473 |
'post_id' => $args['post_id'],
|
474 |
'form' => acf_encrypt(json_encode($args))
|
475 |
));
|
@@ -552,8 +568,6 @@ class acfe_form_front{
|
|
552 |
return ob_get_clean();
|
553 |
|
554 |
}
|
555 |
-
|
556 |
-
return;
|
557 |
|
558 |
}
|
559 |
|
32 |
if(empty($form))
|
33 |
return;
|
34 |
|
35 |
+
$post_id = acf_maybe_get($form, 'post_id', false);
|
36 |
$form_name = acf_maybe_get($form, 'form_name');
|
37 |
$form_id = acf_maybe_get($form, 'form_id');
|
|
|
38 |
|
39 |
if(!$form_name || !$form_id)
|
40 |
return;
|
60 |
function check_submit_form(){
|
61 |
|
62 |
// Verify nonce.
|
63 |
+
if(!acf_verify_nonce('acfe_form'))
|
64 |
+
return;
|
65 |
+
|
|
|
66 |
if(!acf_maybe_get_POST('_acf_form'))
|
67 |
return;
|
|
|
|
|
68 |
|
69 |
+
$form = json_decode(acf_decrypt($_POST['_acf_form']), true);
|
70 |
+
|
71 |
+
if(empty($form))
|
72 |
+
return;
|
73 |
|
74 |
// ACF
|
75 |
$_POST['acf'] = isset($_POST['acf']) ? $_POST['acf'] : array();
|
92 |
function submit_form($form){
|
93 |
|
94 |
// vars
|
95 |
+
$post_id = acf_maybe_get($form, 'post_id', false);
|
96 |
$form_name = acf_maybe_get($form, 'form_name');
|
97 |
$form_id = acf_maybe_get($form, 'form_id');
|
98 |
|
147 |
|
148 |
}
|
149 |
|
150 |
+
function validate_form($param){
|
151 |
|
152 |
$form_name = false;
|
153 |
$form_id = false;
|
154 |
|
155 |
// String
|
156 |
+
if(is_string($param)){
|
157 |
|
158 |
+
$form = get_page_by_path($param, OBJECT, 'acfe-form');
|
159 |
if(!$form)
|
160 |
return false;
|
161 |
|
166 |
}
|
167 |
|
168 |
// Int
|
169 |
+
elseif(is_int($param)){
|
170 |
|
171 |
+
if(get_post_type($param) !== 'acfe-form')
|
172 |
return false;
|
173 |
|
174 |
// Form
|
175 |
+
$form_id = $param;
|
176 |
$form_name = get_field('acfe_form_name', $form_id);
|
177 |
|
178 |
}
|
289 |
$defaults['field_el'] = get_field('acf-field_acfe_form_form_field_el', $form_id);
|
290 |
$defaults['instruction_placement'] = get_field('acfe_form_instruction_placement', $form_id);
|
291 |
|
292 |
+
$args = wp_parse_args($param, $defaults);
|
293 |
|
294 |
// Override
|
295 |
if(!empty($args['fields_attributes']['class']))
|
416 |
|
417 |
}
|
418 |
|
419 |
+
if($args['updated_hide_form']){
|
420 |
+
|
421 |
+
?>
|
422 |
+
<script>
|
423 |
+
if(window.history.replaceState){
|
424 |
+
window.history.replaceState( null, null, window.location.href );
|
425 |
+
}
|
426 |
+
</script>
|
427 |
+
<?php
|
428 |
+
|
429 |
return;
|
430 |
+
|
431 |
+
}
|
432 |
|
433 |
}
|
434 |
|
438 |
|
439 |
add_filter('acf/prepare_field', function($field) use($args){
|
440 |
|
441 |
+
if(!$field)
|
442 |
+
return $field;
|
443 |
+
|
444 |
if(!empty($args['fields_attributes']['wrapper_class']))
|
445 |
$field['wrapper']['class'] .= ' ' . $args['fields_attributes']['wrapper_class'];
|
446 |
|
460 |
|
461 |
add_filter('acf/prepare_field/key=' . $field_key, function($field) use($array){
|
462 |
|
463 |
+
if(!$field)
|
464 |
+
return $field;
|
465 |
+
|
466 |
$field = array_merge($field, $array);
|
467 |
|
468 |
return $field;
|
485 |
|
486 |
// render post data
|
487 |
acf_form_data(array(
|
488 |
+
'screen' => 'acfe_form',
|
489 |
'post_id' => $args['post_id'],
|
490 |
'form' => acf_encrypt(json_encode($args))
|
491 |
));
|
568 |
return ob_get_clean();
|
569 |
|
570 |
}
|
|
|
|
|
571 |
|
572 |
}
|
573 |
|
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.2
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 0.8
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -568,9 +568,6 @@ function my_acfe_modules(){
|
|
568 |
// Disable Forms
|
569 |
acf_update_setting('acfe/modules/dynamic_forms', false);
|
570 |
|
571 |
-
// Disable Forms: Submissions
|
572 |
-
acf_update_setting('acfe/modules/dynamic_forms_submissions', false);
|
573 |
-
|
574 |
// Disable Tools > Post Types
|
575 |
acf_update_setting('acfe/modules/dynamic_post_types', false);
|
576 |
|
@@ -604,6 +601,22 @@ function my_acfe_modules(){
|
|
604 |
|
605 |
== Changelog ==
|
606 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
607 |
= 0.8 =
|
608 |
* Module: Dynamic Forms - Added module. Forms UI available under ACF menu
|
609 |
* Module: Dynamic Forms - Added PHP helper `acfe_form('my_form_name')` & `acfe_form(188)` to display a form
|
5 |
Requires at least: 4.9
|
6 |
Tested up to: 5.2
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 0.8.1
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
568 |
// Disable Forms
|
569 |
acf_update_setting('acfe/modules/dynamic_forms', false);
|
570 |
|
|
|
|
|
|
|
571 |
// Disable Tools > Post Types
|
572 |
acf_update_setting('acfe/modules/dynamic_post_types', false);
|
573 |
|
601 |
|
602 |
== Changelog ==
|
603 |
|
604 |
+
= 0.8.1 =
|
605 |
+
* Field: Advanced Link - Added instructions to add custom fields in the field administration
|
606 |
+
* Field: Advanced Link - Added filters `acfe/fields/advanced_link/fields/name=my_field` & `acfe/fields/advanced_link/fields/key=field_xxxxxxx`
|
607 |
+
* Field: Advanced Link - Changed values keys to: `type`, `url`, `post`, `title` & `target`
|
608 |
+
* Field: Button - Updated JS hook `acf.doAction('acfe/fields/button/before_ajax', $el, data)`
|
609 |
+
* Field: Button - Updated JS hook `acf.doAction('acfe/fields/button/ajax_success', response, $el, data)`
|
610 |
+
* Field: Column - Fixed endpoint column not correctly closing the row
|
611 |
+
* Field: Flexible Content - Added JS hook `acf.doAction('acfe/fields/flexible_content/before_preview', $el, data)`
|
612 |
+
* Field: Flexible Content - Added JS hook `acf.doAction('acfe/fields/flexible_content/preview', response, $el, data)`
|
613 |
+
* Field: Flexible Content - Clone/Copy/Paste - Fixed a problem where new select option values weren't properly duplicated (thanks @chrisschrijver)
|
614 |
+
* Module: Dynamic Forms - Advanced settings: Fixed `prepare_field` on form front
|
615 |
+
* Module: Dynamic Forms - Fixed a compatibility problem if a dynamic form was named `form`
|
616 |
+
* Module: Dynamic Forms - Rename `field class` to `input class`
|
617 |
+
* Module: Dynamic Forms - Fixed a problem where native ACF Form would not properly work (thanks @maximelessard)
|
618 |
+
* Module: Dynamic Forms - Added Javascript to avoid re-submission on page refresh when 'Hide form' is set to ON
|
619 |
+
|
620 |
= 0.8 =
|
621 |
* Module: Dynamic Forms - Added module. Forms UI available under ACF menu
|
622 |
* Module: Dynamic Forms - Added PHP helper `acfe_form('my_form_name')` & `acfe_form(188)` to display a form
|