PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.7
Advanced Custom Fields: Extended v0.9.2.7
0.9.2.7 0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / field-extend.php
acf-extended / includes Last commit date
admin 3 months ago field-groups 3 months ago fields 1 week ago fields-settings 3 months ago forms 3 months ago locations 3 months ago modules 1 week ago screens 3 months ago acfe-deprecated-functions.php 2 years ago acfe-field-functions.php 3 months ago acfe-field-group-functions.php 3 months ago acfe-file-functions.php 1 year ago acfe-form-functions.php 3 months ago acfe-helper-array-functions.php 3 months ago acfe-helper-functions.php 3 months ago acfe-helper-multi-functions.php 3 months ago acfe-helper-string-functions.php 3 months ago acfe-meta-functions.php 3 months ago acfe-post-functions.php 3 months ago acfe-screen-functions.php 3 months ago acfe-template-functions.php 3 months ago acfe-term-functions.php 3 months ago acfe-user-functions.php 3 months ago acfe-wp-functions.php 3 years ago assets.php 3 months ago compatibility-acf-5.8.php 4 months ago compatibility-acf-5.9.php 3 months ago compatibility-acf-6.5.php 3 months ago compatibility-acf-6.8.6.php 1 week ago compatibility.php 3 months ago field-extend.php 4 months ago field.php 4 months ago hooks.php 3 months ago init.php 3 months ago local-meta.php 3 years ago media.php 3 months ago module-acf.php 3 months ago module-db.php 3 months ago module-l10n.php 3 months ago module-legacy.php 3 years ago module-manager.php 4 months ago module-post.php 3 months ago module-posts.php 4 months ago module-upgrades.php 3 years ago module.php 3 months ago multilang.php 3 months ago revisions.php 4 months ago screen.php 3 months ago settings.php 3 months ago template-tags.php 3 months ago third-party.php 3 years ago upgrades.php 3 months ago
field-extend.php
422 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_field_extend')):
8
9 class acfe_field_extend{
10
11 var $name = '',
12 $replace = array(),
13 $defaults = array(),
14 $instance = '';
15
16 /**
17 * construct
18 */
19 function __construct(){
20
21 // initialize
22 $this->initialize();
23
24 // field instance
25 $this->instance = $this->get_field_type();
26
27 // defaults
28 if($this->defaults){
29 $this->instance->defaults = array_merge($this->instance->defaults, $this->defaults);
30 }
31
32 // field actions
33 $actions = array(
34
35 // value
36 array('filter', 'acf/load_value', array($this, 'load_value'), 10, 3),
37 array('filter', 'acf/update_value', array($this, 'update_value'), 10, 3),
38 array('filter', 'acf/format_value', array($this, 'format_value'), 10, 3),
39 array('filter', 'acf/validate_value', array($this, 'validate_value'), 10, 4),
40 array('action', 'acf/delete_value', array($this, 'delete_value'), 10, 3),
41
42 // field
43 array('filter', 'acf/validate_rest_value', array($this, 'validate_rest_value'), 10, 3),
44 array('filter', 'acf/validate_field', array($this, 'validate_field'), 10, 1),
45 array('filter', 'acf/load_field', array($this, 'load_field'), 10, 1),
46 array('filter', 'acf/update_field', array($this, 'update_field'), 10, 1),
47 array('filter', 'acf/duplicate_field', array($this, 'duplicate_field'), 10, 1),
48 array('action', 'acf/delete_field', array($this, 'delete_field'), 10, 1),
49 array('action', 'acf/render_field', array($this, 'render_field'), 9, 1),
50 array('action', 'acf/render_field_settings', array($this, 'render_field_settings'), 9, 1),
51 array('filter', 'acf/prepare_field', array($this, 'prepare_field'), 10, 1),
52 array('filter', 'acf/translate_field', array($this, 'translate_field'), 10, 1),
53
54 // acfe
55 array('filter', 'acfe/form/format_value', array($this, 'format_front_value'), 10, 5),
56 array('filter', 'acfe/form/validate_value', array($this, 'validate_front_value'), 10, 5),
57 array('filter', 'acfe/field_wrapper_attributes', array($this, 'field_wrapper_attributes'), 10, 2),
58 array('filter', 'acfe/load_fields', array($this, 'load_fields'), 10, 2),
59 );
60
61 // loop
62 foreach($actions as $row){
63
64 // vars
65 list($type, $hook, $function, $priority, $args) = $row;
66
67 // get method
68 $method = $type === 'filter' ? 'add_field_filter' : 'add_field_action';
69
70 // use replace method
71 if(in_array($function[1], $this->replace)){
72 $method = $type === 'filter' ? 'replace_field_filter' : 'replace_field_action';
73 }
74
75 // call method
76 $this->{$method}($hook, $function, $priority, $args);
77
78 }
79
80 // input actions
81 $this->add_action('acf/input/admin_enqueue_scripts', array($this, 'input_admin_enqueue_scripts'), 10, 0);
82 $this->add_action('acf/input/admin_head', array($this, 'input_admin_head'), 10, 0);
83 $this->add_action('acf/input/form_data', array($this, 'input_form_data'), 10, 1);
84 $this->add_filter('acf/input/admin_l10n', array($this, 'input_admin_l10n'), 10, 1);
85 $this->add_action('acf/input/admin_footer', array($this, 'input_admin_footer'), 10, 1);
86
87 // field group actions
88 $this->add_action('acf/field_group/admin_enqueue_scripts', array($this, 'field_group_admin_enqueue_scripts'), 10, 0);
89 $this->add_action('acf/field_group/admin_head', array($this, 'field_group_admin_head'), 10, 0);
90 $this->add_action('acf/field_group/admin_footer', array($this, 'field_group_admin_footer'), 10, 0);
91
92 }
93
94
95 /**
96 * initialize
97 */
98 function initialize(){
99 // ...
100 }
101
102
103 /**
104 * get_field_type
105 *
106 * @return mixed
107 */
108 function get_field_type(){
109 return acf_get_field_type($this->name);
110 }
111
112
113 /**
114 * pre_validate_front_value
115 *
116 * @param $valid
117 * @param $value
118 * @param $field
119 * @param $form
120 *
121 * @return mixed|null
122 */
123 function pre_validate_front_value($valid, $value, $field, $form){
124
125 // already invalid
126 if(!$valid || (is_string($valid) && !empty($valid))){
127 return false;
128 }
129
130 // empty value
131 if(empty($value)){
132 return false;
133 }
134
135 // default validation
136 $validate = true;
137
138 // variations
139 $validate = apply_filters("acfe/form/pre_validate_value/form={$form['name']}", $validate, $field, $form);
140 $validate = apply_filters("acfe/form/pre_validate_value/type={$field['type']}", $validate, $field, $form);
141 $validate = apply_filters("acfe/form/pre_validate_value/name={$field['_name']}", $validate, $field, $form);
142 $validate = apply_filters("acfe/form/pre_validate_value/key={$field['key']}", $validate, $field, $form);
143
144 // return
145 return $validate;
146
147 }
148
149
150 /**
151 * add_filter
152 *
153 * @param $tag
154 * @param $function_to_add
155 * @param $priority
156 * @param $accepted_args
157 */
158 function add_filter($tag = '', $function_to_add = '', $priority = 10, $accepted_args = 1){
159
160 // bail early if no callable
161 if(!is_callable($function_to_add)){
162 return;
163 }
164
165 // add
166 add_filter($tag, $function_to_add, $priority, $accepted_args);
167
168 }
169
170
171 /**
172 * remove_filter
173 *
174 * @param $tag
175 * @param $function_to_remove
176 * @param $priority
177 */
178 function remove_filter($tag = '', $function_to_remove = '', $priority = 10){
179
180 // bail early if no callable
181 if(!is_callable($function_to_remove)){
182 return;
183 }
184
185 // remove
186 remove_filter($tag, $function_to_remove, $priority);
187
188 }
189
190
191 /**
192 * replace_filter
193 *
194 * @param $tag
195 * @param $function_to_replace
196 * @param $priority
197 * @param $accepted_args
198 */
199 function replace_filter($tag = '', $function_to_replace = '', $priority = 10, $accepted_args = 1){
200
201 // check instance
202 if(!$this->instance){
203 $this->instance = $this->get_field_type();
204 }
205
206 // array
207 if(is_array($function_to_replace)){
208 $function_to_remove = array($this->instance, $function_to_replace[1]);
209 $function_to_add = $function_to_replace;
210
211 // string
212 }else{
213 $function_to_remove = array($this->instance, $function_to_replace);
214 $function_to_add = array($this, $function_to_replace);
215
216 }
217
218 // bail early if no callable
219 if(!is_callable($function_to_add)){
220 return;
221 }
222
223 // replace
224 $this->remove_filter($tag, $function_to_remove, $priority);
225 $this->add_filter($tag, $function_to_add, $priority, $accepted_args);
226
227 }
228
229
230 /**
231 * add_field_filter
232 *
233 * @param $tag
234 * @param $function_to_add
235 * @param $priority
236 * @param $accepted_args
237 */
238 function add_field_filter($tag = '', $function_to_add = '', $priority = 10, $accepted_args = 1){
239
240 // append
241 $tag .= '/type=' . $this->name;
242
243 // add
244 $this->add_filter($tag, $function_to_add, $priority, $accepted_args);
245
246 }
247
248
249 /**
250 * remove_field_filter
251 *
252 * @param $tag
253 * @param $function_to_remove
254 * @param $priority
255 */
256 function remove_field_filter($tag = '', $function_to_remove = '', $priority = 10){
257
258 // append
259 $tag .= '/type=' . $this->name;
260
261 // remove
262 $this->remove_filter($tag, $function_to_remove, $priority);
263
264 }
265
266
267 /**
268 * replace_field_filter
269 *
270 * @param $tag
271 * @param $function_to_add
272 * @param $priority
273 * @param $accepted_args
274 */
275 function replace_field_filter($tag = '', $function_to_replace = '', $priority = 10, $accepted_args = 1){
276
277 // append
278 $tag .= '/type=' . $this->name;
279
280 // replace
281 $this->replace_filter($tag, $function_to_replace, $priority, $accepted_args);
282
283 }
284
285
286 /**
287 * add_action
288 *
289 * @param $tag
290 * @param $function_to_add
291 * @param $priority
292 * @param $accepted_args
293 */
294 function add_action($tag = '', $function_to_add = '', $priority = 10, $accepted_args = 1){
295
296 // bail early if no callable
297 if(!is_callable($function_to_add)){
298 return;
299 }
300
301 // add
302 add_action($tag, $function_to_add, $priority, $accepted_args);
303
304 }
305
306
307 /**
308 * remove_action
309 *
310 * @param $tag
311 * @param $function_to_remove
312 * @param $priority
313 */
314 function remove_action($tag = '', $function_to_remove = '', $priority = 10){
315
316 // bail early if no callable
317 if(!is_callable($function_to_remove)){
318 return;
319 }
320
321 // remove
322 remove_action($tag, $function_to_remove, $priority);
323
324 }
325
326
327 /**
328 * replace_action
329 *
330 * @param $tag
331 * @param $function_to_replace
332 * @param $priority
333 * @param $accepted_args
334 */
335 function replace_action($tag = '', $function_to_replace = '', $priority = 10, $accepted_args = 1){
336
337 // check instance
338 if(!$this->instance){
339 $this->instance = $this->get_field_type();
340 }
341
342 // array
343 if(is_array($function_to_replace)){
344 $function_to_remove = array($this->instance, $function_to_replace[1]);
345 $function_to_add = $function_to_replace;
346
347 // string
348 }else{
349 $function_to_remove = array($this->instance, $function_to_replace);
350 $function_to_add = array($this, $function_to_replace);
351
352 }
353
354 // bail early if no callable
355 if(!is_callable($function_to_add)){
356 return;
357 }
358
359 // replace
360 $this->remove_action($tag, $function_to_remove, $priority);
361 $this->add_action($tag, $function_to_add, $priority, $accepted_args);
362
363 }
364
365 /**
366 * add_field_action
367 *
368 * @param $tag
369 * @param $function_to_add
370 * @param $priority
371 * @param $accepted_args
372 */
373 function add_field_action($tag = '', $function_to_add = '', $priority = 10, $accepted_args = 1){
374
375 // append
376 $tag .= '/type=' . $this->name;
377
378 // add
379 $this->add_action($tag, $function_to_add, $priority, $accepted_args);
380
381 }
382
383
384 /**
385 * remove_field_action
386 *
387 * @param $tag
388 * @param $function_to_remove
389 * @param $priority
390 */
391 function remove_field_action($tag = '', $function_to_remove = '', $priority = 10){
392
393 // append
394 $tag .= '/type=' . $this->name;
395
396 // remove
397 $this->remove_action($tag, $function_to_remove, $priority);
398
399 }
400
401
402 /**
403 * replace_field_action
404 *
405 * @param $tag
406 * @param $function_to_replace
407 * @param $priority
408 * @param $accepted_args
409 */
410 function replace_field_action($tag = '', $function_to_replace = '', $priority = 10, $accepted_args = 1){
411
412 // append
413 $tag .= '/type=' . $this->name;
414
415 // replace
416 $this->replace_action($tag, $function_to_replace, $priority, $accepted_args);
417
418 }
419
420 }
421
422 endif;