PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.8.8.9
Advanced Custom Fields: Extended v0.8.8.9
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 / modules / forms.php
acf-extended / includes / modules Last commit date
author.php 3 years ago autosync.php 3 years ago block-types.php 3 years ago dev-clean-meta.php 3 years ago dev-delete-meta.php 3 years ago dev.php 3 years ago forms-action-custom.php 3 years ago forms-action-email.php 3 years ago forms-action-post.php 3 years ago forms-action-redirect.php 3 years ago forms-action-term.php 3 years ago forms-action-user.php 3 years ago forms-cheatsheet.php 3 years ago forms-front.php 3 years ago forms-helpers.php 3 years ago forms-hooks.php 3 years ago forms-shortcode.php 3 years ago forms.php 3 years ago module.php 3 years ago options-pages.php 3 years ago options.class.php 3 years ago options.php 3 years ago post-types.php 3 years ago single-meta.php 3 years ago taxonomies.php 3 years ago ui-attachment.php 3 years ago ui-settings.php 3 years ago ui-term.php 3 years ago ui-user.php 3 years ago ui.php 3 years ago
forms.php
1925 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_dynamic_forms')):
8
9 class acfe_dynamic_forms extends acfe_dynamic_module{
10
11 // vars
12 public $field_groups = array();
13
14 /*
15 * Initialize
16 */
17 function initialize(){
18
19 $this->name = 'form';
20 $this->active = acf_get_setting('acfe/modules/forms');
21 $this->post_type = 'acfe-form';
22 $this->label = 'Form Title';
23
24 $this->tool = 'acfe_dynamic_forms_export';
25 $this->tools = array('json');
26 $this->columns = array(
27 'name' => __('Name', 'acf'),
28 'field_groups' => __('Field groups', 'acf'),
29 'actions' => __('Actions', 'acf'),
30 'shortcode' => __('Shortcode', 'acf'),
31 );
32
33 }
34
35 /*
36 * Actions
37 */
38 function actions(){
39
40 // TinyMCE
41 add_filter('mce_external_plugins', array($this, 'mce_plugins'));
42
43 // Validate
44 add_filter('acf/validate_value/name=acfe_form_name', array($this, 'validate_name'), 10, 4);
45
46 // Save
47 add_action('acfe/form/save', array($this, 'save'), 10, 2);
48
49 // Import
50 add_action('acfe/form/import_fields', array($this, 'import_fields'), 10, 3);
51
52 // Includes
53 acfe_include('includes/modules/forms-cheatsheet.php');
54 acfe_include('includes/modules/forms-front.php');
55 acfe_include('includes/modules/forms-helpers.php');
56 acfe_include('includes/modules/forms-hooks.php');
57 acfe_include('includes/modules/forms-shortcode.php');
58
59 acfe_include('includes/modules/forms-action-custom.php');
60 acfe_include('includes/modules/forms-action-email.php');
61 acfe_include('includes/modules/forms-action-post.php');
62 acfe_include('includes/modules/forms-action-redirect.php');
63 acfe_include('includes/modules/forms-action-term.php');
64 acfe_include('includes/modules/forms-action-user.php');
65
66 do_action('acfe/include_form_actions');
67
68 }
69
70 /*
71 * TinyMCE Plugin JS
72 */
73 function mce_plugins($plugins){
74
75 $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
76
77 $plugins['acfe_form'] = acfe_get_url('assets/inc/tinymce/acfe-form' . $suffix . '.js');
78
79 return $plugins;
80
81 }
82
83 /*
84 * Get Name
85 */
86 function get_name($post_id){
87
88 return get_field('acfe_form_name', $post_id);
89
90 }
91
92 /*
93 * Init
94 */
95 function init(){
96
97 $capability = acf_get_setting('capability');
98
99 if(!acf_get_setting('show_admin'))
100 $capability = false;
101
102 register_post_type($this->post_type, array(
103 'label' => __('Forms', 'acf'),
104 'description' => __('Forms', 'acf'),
105 'labels' => array(
106 'name' => __('Forms', 'acf'),
107 'singular_name' => __('Form', 'acf'),
108 'menu_name' => __('Forms', 'acf'),
109 'edit_item' => 'Edit Form',
110 'add_new_item' => 'New Form',
111 ),
112 'supports' => array('title'),
113 'hierarchical' => false,
114 'public' => false,
115 'show_ui' => true,
116 'show_in_menu' => 'edit.php?post_type=acf-field-group',
117 'menu_icon' => 'dashicons-feedback',
118 'show_in_admin_bar' => false,
119 'show_in_nav_menus' => false,
120 'can_export' => false,
121 'has_archive' => false,
122 'rewrite' => false,
123 'exclude_from_search' => true,
124 'publicly_queryable' => false,
125 'capabilities' => array(
126 'publish_posts' => $capability,
127 'edit_posts' => $capability,
128 'edit_others_posts' => $capability,
129 'delete_posts' => $capability,
130 'delete_others_posts' => $capability,
131 'read_private_posts' => $capability,
132 'edit_post' => $capability,
133 'delete_post' => $capability,
134 'read_post' => $capability,
135 ),
136 'acfe_admin_ppp' => 999,
137 'acfe_admin_orderby' => 'title',
138 'acfe_admin_order' => 'ASC',
139 ));
140
141 }
142
143 /*
144 * Post Head
145 */
146 function post_head(){
147
148 global $pagenow;
149
150 if($pagenow === 'post-new.php')
151 return;
152
153 $this->field_groups = acf_get_instance('acfe_dynamic_forms_helpers')->get_field_groups();
154
155 // Add Instructions
156 add_meta_box('acfe-form-integration', 'Integration', array($this, 'meta_box_side'), $this->post_type,'side', 'core');
157
158 if($this->field_groups){
159 add_meta_box('acfe-form-details', __('Fields', 'acf'), array($this, 'meta_box_field_groups'), $this->post_type, 'normal');
160 }
161
162 }
163
164 /*
165 * Metabox: Sidebar
166 */
167 function meta_box_side($post){
168
169 $form_id = $post->ID;
170 $form_name = $this->get_name($form_id);
171
172 ?>
173
174 <div class="acf-field">
175
176 <div class="acf-label">
177 <label><?php _e('Documentation', 'acfe'); ?>:</label>
178 </div>
179
180 <div class="acf-input">
181
182 <ul style="list-style:inside;">
183 <li><a href="https://www.acf-extended.com/features/modules/dynamic-forms" target="_blank"><?php _e('Forms', 'acfe'); ?></a></li>
184 <li><a href="https://www.acf-extended.com/features/modules/dynamic-forms/form-cheatsheet" target="_blank"><?php _e('Cheatsheet', 'acfe'); ?></a></li>
185 <li><a href="https://www.acf-extended.com/features/modules/dynamic-forms/form-hooks" target="_blank"><?php _e('Hooks', 'acfe'); ?></a></li>
186 <li><a href="https://www.acf-extended.com/features/modules/dynamic-forms/form-helpers" target="_blank"><?php _e('Helpers', 'acfe'); ?></a></li>
187 </ul>
188
189 </div>
190
191 </div>
192
193 <div class="acf-field">
194
195 <div class="acf-label">
196 <label><?php _e('Shortcodes', 'acfe'); ?>:</label>
197 </div>
198
199 <div class="acf-input">
200
201 <code>[acfe_form ID="<?php echo $form_id; ?>"]</code><br /><br />
202 <code>[acfe_form name="<?php echo $form_name; ?>"]</code>
203
204 </div>
205
206 </div>
207
208 <div class="acf-field">
209
210 <div class="acf-label">
211 <label><?php _e('PHP code', 'acfe'); ?>:</label>
212 </div>
213
214 <div class="acf-input">
215
216 <pre>&lt;?php get_header(); ?&gt;
217
218 &lt;!-- <?php echo get_the_title($form_id); ?> --&gt;
219 &lt;?php acfe_form(&apos;<?php echo $form_name; ?>&apos;); ?&gt;
220
221 &lt;?php get_footer(); ?&gt;</pre>
222
223 </div>
224
225 </div>
226
227 <script type="text/javascript">
228 if(typeof acf !== 'undefined'){
229
230 acf.newPostbox(<?php echo wp_json_encode(array(
231 'id' => 'acfe-form-integration',
232 'key' => '',
233 'style' => 'default',
234 'label' => 'top',
235 'edit' => false
236 )); ?>);
237
238 }
239 </script>
240 <?php
241 }
242
243 /*
244 * Metabox: Field Groups
245 */
246 function meta_box_field_groups(){
247
248 foreach($this->field_groups as $field_group){ ?>
249
250 <div class="acf-field">
251
252 <div class="acf-label">
253 <label><a href="<?php echo admin_url("post.php?post={$field_group['ID']}&action=edit"); ?>"><?php echo $field_group['title']; ?></a></label>
254 <p class="description"><?php echo $field_group['key']; ?></p>
255 </div>
256
257 <div class="acf-input">
258
259 <?php if(acf_maybe_get($field_group, 'fields')){ ?>
260
261 <table class="acf-table">
262 <thead>
263 <th class="acf-th" width="25%"><strong>Label</strong></th>
264 <th class="acf-th" width="25%"><strong>Name</strong></th>
265 <th class="acf-th" width="25%"><strong>Key</strong></th>
266 <th class="acf-th" width="25%"><strong>Type</strong></th>
267 </thead>
268
269 <tbody>
270 <?php
271
272 $array = array();
273 foreach($field_group['fields'] as $field){
274
275 $this->get_fields_labels_recursive($array, $field);
276
277 }
278
279 foreach($array as $field_key => $field_label){
280
281 $field = acf_get_field($field_key);
282 $type = acf_get_field_type($field['type']);
283 $type_label = '-';
284 if(isset($type->label))
285 $type_label = $type->label;
286 ?>
287
288 <tr class="acf-row">
289 <td width="25%"><?php echo $field_label; ?></td>
290 <td width="25%"><code style="font-size:12px;"><?php echo $field['name']; ?></code></td>
291 <td width="25%"><code style="font-size:12px;"><?php echo $field_key; ?></code></td>
292 <td width="25%"><?php echo $type_label; ?></td>
293 </tr>
294
295 <?php } ?>
296 </tbody>
297 </table>
298
299 <?php } ?>
300 </div>
301
302 </div>
303
304 <?php } ?>
305
306 <script type="text/javascript">
307 if(typeof acf !== 'undefined'){
308
309 acf.newPostbox(<?php echo wp_json_encode(array(
310 'id' => 'acfe-form-details',
311 'key' => '',
312 'style' => 'default',
313 'label' => 'left',
314 'edit' => false
315 )); ?>);
316
317 }
318 </script>
319 <?php
320
321 }
322
323 /*
324 * Edit Columns HTML
325 */
326 function edit_columns_html($column, $post_id){
327
328 switch($column){
329
330 // Name
331 case 'name':
332
333 echo '<code style="font-size: 12px;">' . $this->get_name($post_id) . '</code>';
334 break;
335
336 // Field Groups
337 case 'field_groups':
338
339 $return = '';
340
341 $field_groups = acf_get_array(get_field('acfe_form_field_groups', $post_id));
342
343 if(!empty($field_groups)){
344
345 $links = array();
346
347 foreach($field_groups as $key){
348
349 $field_group = acf_get_field_group($key);
350
351 if(!$field_group)
352 continue;
353
354 if(acf_maybe_get($field_group, 'ID')){
355
356 $links[] = '<a href="' . admin_url("post.php?post={$field_group['ID']}&action=edit") . '">' . $field_group['title'] . '</a>';
357
358 }else{
359
360 $links[] = $field_group['title'];
361
362 }
363
364 }
365
366 $return = implode(', ', $links);
367
368 }
369
370 echo $return;
371 break;
372
373 // Actions
374 case 'actions':
375
376 $return = '';
377
378 $icons = array();
379
380 if(have_rows('acfe_form_actions', $post_id)):
381 while(have_rows('acfe_form_actions', $post_id)): the_row();
382
383 // Custom
384 if(get_row_layout() === 'custom'){
385
386 $action_name = get_sub_field('acfe_form_custom_action');
387
388 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-editor-code" title="Custom action: ' . $action_name . '"></span>';
389
390 }
391
392 // E-mail
393 elseif(get_row_layout() === 'email'){
394 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-email" title="E-mail"></span>';
395 }
396
397 // Post
398 elseif(get_row_layout() === 'post'){
399
400 $action = get_sub_field('acfe_form_post_action');
401
402 // Insert
403 if($action === 'insert_post'){
404 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-edit" title="Create post"></span>';
405 }
406
407 // Update
408 elseif($action === 'update_post'){
409 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-update" title="Update post"></span>';
410 }
411
412 }
413
414 // Term
415 elseif(get_row_layout() === 'term'){
416
417 $action = get_sub_field('acfe_form_term_action');
418
419 // Insert
420 if($action === 'insert_term'){
421 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-category" title="Create term"></span>';
422 }
423
424 // Update
425 elseif($action === 'update_term'){
426 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-category" title="Update term"></span>';
427 }
428
429 }
430
431 // User
432 elseif(get_row_layout() === 'user'){
433
434 $action = get_sub_field('acfe_form_user_action');
435
436 // Insert
437 if($action === 'insert_user'){
438 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-admin-users" title="Create user"></span>';
439 }
440
441 // Update
442 elseif($action === 'update_user'){
443 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-admin-users" title="Update user"></span>';
444 }
445
446 // Update
447 elseif($action === 'log_user'){
448 $icons[] = '<span class="acf-js-tooltip dashicons dashicons-migrate" title="Log user"></span>';
449 }
450
451 }
452
453 endwhile;
454 endif;
455
456 if(!empty($icons)){
457 $return = implode('', $icons);
458 }
459
460 echo $return;
461 break;
462
463 // Shortcode
464 case 'shortcode':
465
466 echo '<code style="font-size: 12px;">[acfe_form name="' . $this->get_name($post_id) . '"]</code>';
467 break;
468
469 }
470
471 }
472
473 /*
474 * ACF Save post
475 */
476 function save_post($post_id){
477
478 // Get Post
479 $name = $this->get_name($post_id);
480
481 // Actions
482 do_action("acfe/form/save", $name, $post_id);
483 do_action("acfe/form/save/name={$name}", $name, $post_id);
484 do_action("acfe/form/save/id={$post_id}", $name, $post_id);
485
486 }
487
488 /*
489 * Save
490 */
491 function save($name, $post_id){
492
493 // Update post
494 wp_update_post(array(
495 'ID' => $post_id,
496 'post_name' => $name,
497 'post_status' => 'publish',
498 ));
499
500 // Get generated post name (possible name-2)
501 $_name = get_post_field('post_name', $post_id);
502
503 // Update the meta if different
504 if($_name !== $name)
505 update_field('acfe_form_name', $_name, $post_id);
506
507 }
508
509 /*
510 * Validate Name
511 */
512 function validate_name($valid, $value, $field, $input){
513
514 if($valid !== true)
515 return $valid;
516
517 // Check current name
518 $post_id = acfe_get_post_id();
519
520 if(empty($post_id))
521 return $valid;
522
523 $name = get_field($field['name'], $post_id);
524
525 if($value === $name)
526 return $valid;
527
528 $get_posts = get_posts(array(
529 'post_type' => $this->post_type,
530 'name' => $value,
531 'post__not_in' => array($post_id),
532 'fields' => 'ids',
533 'post_status' => array('publish', 'acf-disabled'),
534 'posts_per_page' => 1
535 ));
536
537 if(!empty($get_posts))
538 $valid = 'This form name already exists';
539
540 return $valid;
541
542 }
543
544 /*
545 * Import
546 */
547 function import($name, $args){
548
549 // Vars
550 $title = acf_extract_var($args, 'title');
551 $name = $args['acfe_form_name'];
552
553 // Already exists
554 if(get_page_by_path($name, OBJECT, $this->post_type)){
555 return new WP_Error('acfe_form_import_already_exists', __("Form \"{$title}\" already exists. Import aborted."));
556 }
557
558 // Import Post
559 $post_id = false;
560
561 $post = array(
562 'post_title' => $title,
563 'post_name' => $name,
564 'post_type' => $this->post_type,
565 'post_status' => 'publish'
566 );
567
568 $post = apply_filters("acfe/form/import_post", $post, $name);
569 $post = apply_filters("acfe/form/import_post/name={$name}", $post, $name);
570
571 if($post !== false){
572 $post_id = wp_insert_post($post);
573 }
574
575 if(!$post_id || is_wp_error($post_id)){
576 return new WP_Error('acfe_form_import_error', __("Something went wrong with the form \"{$title}\". Import aborted."));
577 }
578
579 // Import Args
580 $args = apply_filters("acfe/form/import_args", $args, $name, $post_id);
581 $args = apply_filters("acfe/form/import_args/name={$name}", $args, $name, $post_id);
582 $args = apply_filters("acfe/form/import_args/id={$post_id}", $args, $name, $post_id);
583
584 if($args === false)
585 return $post_id;
586
587 // Import Fields
588 acf_enable_filter('local');
589
590 do_action("acfe/form/import_fields", $name, $args, $post_id);
591 do_action("acfe/form/import_fields/name={$name}", $name, $args, $post_id);
592 do_action("acfe/form/import_fields/id={$post_id}", $name, $args, $post_id);
593
594 acf_disable_filter('local');
595
596 // Save
597 $this->save_post($post_id);
598
599 return $post_id;
600
601 }
602
603 /*
604 * Import Fields
605 */
606 function import_fields($name, $args, $post_id){
607
608 // Update
609 acf_update_values($args, $post_id);
610
611 }
612
613 /*
614 * Export: Choices
615 */
616 function export_choices(){
617
618 $choices = array();
619
620 $get_posts = get_posts(array(
621 'post_type' => 'acfe-form',
622 'posts_per_page' => -1,
623 'fields' => 'ids'
624 ));
625
626 if(!$get_posts)
627 return $choices;
628
629 foreach($get_posts as $post_id){
630
631 $name = $this->get_name($post_id);
632 $choices[$name] = esc_html(get_the_title($post_id));
633
634 }
635
636 return $choices;
637
638 }
639
640 /*
641 * Export: Data
642 */
643 function export_data($name){
644
645 if(!$form = get_page_by_path($name, OBJECT, $this->post_type))
646 return false;
647
648 acf_enable_filter('local');
649
650 $args = array_merge(array('title' => get_the_title($form->ID)), get_fields($form->ID, false));
651
652 // Filters
653 $args = apply_filters("acfe/form/export_args", $args, $name);
654 $args = apply_filters("acfe/form/export_args/name={$name}", $args, $name);
655
656 acf_disable_filter('local');
657
658 return $args;
659
660 }
661
662 /*
663 * Add Local Field Group
664 */
665 function add_local_field_group(){
666
667 $actions_layouts = apply_filters('acfe/form/actions', array());
668 ksort($actions_layouts);
669
670 acf_add_local_field_group(array(
671 'key' => 'group_acfe_dynamic_form',
672 'title' => 'Dynamic Form',
673 'acfe_display_title' => '',
674 'fields' => array(
675
676 /*
677 * Actions
678 */
679 array(
680 'key' => 'field_acfe_form_tab_general',
681 'label' => 'General',
682 'name' => '',
683 'type' => 'tab',
684 'instructions' => '',
685 'required' => 0,
686 'conditional_logic' => 0,
687 'wrapper' => array(
688 'width' => '',
689 'class' => '',
690 'id' => '',
691 'data-no-preference' => true,
692 ),
693 'acfe_permissions' => '',
694 'placement' => 'top',
695 'endpoint' => 0,
696 ),
697 array(
698 'key' => 'field_acfe_form_name',
699 'label' => 'Form name',
700 'name' => 'acfe_form_name',
701 'type' => 'acfe_slug',
702 'instructions' => 'The unique form slug',
703 'required' => 1,
704 'conditional_logic' => 0,
705 'wrapper' => array(
706 'width' => '',
707 'class' => '',
708 'id' => '',
709 ),
710 'acfe_permissions' => '',
711 'default_value' => '',
712 'placeholder' => '',
713 'prepend' => '',
714 'append' => '',
715 'maxlength' => '',
716 ),
717 array(
718 'key' => 'field_acfe_form_field_groups',
719 'label' => 'Field groups',
720 'name' => 'acfe_form_field_groups',
721 'type' => 'select',
722 'instructions' => 'Render & map fields of the following field groups',
723 'required' => 0,
724 'conditional_logic' => 0,
725 'wrapper' => array(
726 'width' => '',
727 'class' => '',
728 'id' => '',
729 ),
730 'acfe_permissions' => '',
731 'choices' => array(
732 ),
733 'default_value' => array(
734 ),
735 'allow_null' => 0,
736 'multiple' => 1,
737 'ui' => 1,
738 'ajax' => 0,
739 'return_format' => 'value',
740 'placeholder' => '',
741 ),
742 array(
743 'key' => 'field_acfe_form_actions',
744 'label' => 'Actions',
745 'name' => 'acfe_form_actions',
746 'type' => 'flexible_content',
747 'instructions' => 'Add actions on form submission',
748 'required' => 0,
749 'conditional_logic' => 0,
750 'wrapper' => array(
751 'width' => '',
752 'class' => '',
753 'id' => '',
754 ),
755 'acfe_flexible_stylised_button' => 1,
756 'layouts' => $actions_layouts,
757 'button_label' => 'Add action',
758 'min' => '',
759 'max' => '',
760 ),
761
762 /*
763 * Settings
764 */
765 array(
766 'key' => 'field_acfe_form_tab_settings',
767 'label' => 'Settings',
768 'name' => '',
769 'type' => 'tab',
770 'instructions' => '',
771 'required' => 0,
772 'conditional_logic' => 0,
773 'wrapper' => array(
774 'width' => '',
775 'class' => '',
776 'id' => '',
777 ),
778 'acfe_permissions' => '',
779 'placement' => 'top',
780 'endpoint' => 0,
781 ),
782 array(
783 'key' => 'field_acfe_form_field_groups_rules',
784 'label' => 'Field groups locations rules',
785 'name' => 'acfe_form_field_groups_rules',
786 'type' => 'true_false',
787 'instructions' => 'Apply field groups locations rules for front-end display',
788 'required' => 0,
789 'wrapper' => array(
790 'width' => '',
791 'class' => '',
792 'id' => '',
793 ),
794 'acfe_permissions' => '',
795 'message' => '',
796 'default_value' => 0,
797 'ui' => 1,
798 'ui_on_text' => '',
799 'ui_off_text' => '',
800 ),
801 array(
802 'key' => 'field_acfe_form_form_element',
803 'label' => 'Form element',
804 'name' => 'acfe_form_form_element',
805 'type' => 'true_false',
806 'instructions' => 'Whether or not to create a <code>&lt;form&gt;</code> element',
807 'required' => 0,
808 'conditional_logic' => 0,
809 'wrapper' => array(
810 'width' => '',
811 'class' => '',
812 'id' => '',
813 ),
814 'acfe_permissions' => '',
815 'message' => '',
816 'default_value' => 1,
817 'ui' => 1,
818 'ui_on_text' => '',
819 'ui_off_text' => '',
820 ),
821 array(
822 'key' => 'field_acfe_form_attributes',
823 'label' => 'Form attributes',
824 'name' => 'acfe_form_attributes',
825 'type' => 'group',
826 'instructions' => 'Form class and id',
827 'required' => 0,
828 'wrapper' => array(
829 'width' => '',
830 'class' => '',
831 'id' => '',
832 ),
833 'acfe_permissions' => '',
834 'layout' => 'block',
835 'acfe_seamless_style' => true,
836 'acfe_group_modal' => 0,
837 'conditional_logic' => array(
838 array(
839 array(
840 'field' => 'field_acfe_form_form_element',
841 'operator' => '==',
842 'value' => '1',
843 ),
844 ),
845 ),
846 'sub_fields' => array(
847 array(
848 'key' => 'field_acfe_form_attributes_class',
849 'label' => '',
850 'name' => 'acfe_form_attributes_class',
851 'type' => 'text',
852 'instructions' => '',
853 'required' => 0,
854 'conditional_logic' => array(),
855 'wrapper' => array(
856 'width' => '33',
857 'class' => '',
858 'id' => '',
859 ),
860 'acfe_permissions' => '',
861 'default_value' => 'acf-form',
862 'placeholder' => '',
863 'prepend' => 'class',
864 'append' => '',
865 'maxlength' => '',
866 ),
867 array(
868 'key' => 'field_acfe_form_attributes_id',
869 'label' => '',
870 'name' => 'acfe_form_attributes_id',
871 'type' => 'text',
872 'instructions' => '',
873 'required' => 0,
874 'conditional_logic' => array(),
875 'wrapper' => array(
876 'width' => '33',
877 'class' => '',
878 'id' => '',
879 ),
880 'acfe_permissions' => '',
881 'default_value' => '',
882 'placeholder' => '',
883 'prepend' => 'id',
884 'append' => '',
885 'maxlength' => '',
886 ),
887
888 ),
889 ),
890 array(
891 'key' => 'field_acfe_form_fields_attributes',
892 'label' => 'Fields class',
893 'name' => 'acfe_form_fields_attributes',
894 'type' => 'group',
895 'instructions' => 'Add class to all fields',
896 'required' => 0,
897 'wrapper' => array(
898 'width' => '',
899 'class' => '',
900 'id' => '',
901 ),
902 'acfe_permissions' => '',
903 'layout' => 'block',
904 'acfe_seamless_style' => true,
905 'acfe_group_modal' => 0,
906 'conditional_logic' => array(),
907 'sub_fields' => array(
908 array(
909 'key' => 'field_acfe_form_fields_wrapper_class',
910 'label' => '',
911 'name' => 'acfe_form_fields_wrapper_class',
912 'type' => 'text',
913 'instructions' => '',
914 'required' => 0,
915 'conditional_logic' => array(),
916 'wrapper' => array(
917 'width' => '33',
918 'class' => '',
919 'id' => '',
920 ),
921 'acfe_permissions' => '',
922 'default_value' => '',
923 'placeholder' => '',
924 'prepend' => 'wrapper class',
925 'append' => '',
926 'maxlength' => '',
927 ),
928 array(
929 'key' => 'field_acfe_form_fields_class',
930 'label' => '',
931 'name' => 'acfe_form_fields_class',
932 'type' => 'text',
933 'instructions' => '',
934 'required' => 0,
935 'conditional_logic' => array(),
936 'wrapper' => array(
937 'width' => '33',
938 'class' => '',
939 'id' => '',
940 ),
941 'acfe_permissions' => '',
942 'default_value' => '',
943 'placeholder' => '',
944 'prepend' => 'input class',
945 'append' => '',
946 'maxlength' => '',
947 ),
948 ),
949 ),
950 array(
951 'key' => 'field_acfe_form_form_submit',
952 'label' => 'Submit button',
953 'name' => 'acfe_form_form_submit',
954 'type' => 'true_false',
955 'instructions' => 'Whether or not to create a form submit button. Defaults to true',
956 'required' => 0,
957 'conditional_logic' => 0,
958 'wrapper' => array(
959 'width' => '',
960 'class' => '',
961 'id' => '',
962 ),
963 'acfe_permissions' => '',
964 'message' => '',
965 'default_value' => 1,
966 'ui' => 1,
967 'ui_on_text' => '',
968 'ui_off_text' => '',
969 ),
970 array(
971 'key' => 'field_acfe_form_submit_value',
972 'label' => 'Submit value',
973 'name' => 'acfe_form_submit_value',
974 'type' => 'text',
975 'instructions' => 'The text displayed on the submit button',
976 'required' => 0,
977 'conditional_logic' => array(
978 array(
979 array(
980 'field' => 'field_acfe_form_form_submit',
981 'operator' => '==',
982 'value' => '1',
983 ),
984 ),
985 ),
986 'wrapper' => array(
987 'width' => '',
988 'class' => '',
989 'id' => '',
990 ),
991 'acfe_permissions' => '',
992 'default_value' => 'Submit',
993 'placeholder' => '',
994 'prepend' => '',
995 'append' => '',
996 'maxlength' => '',
997 ),
998 array(
999 'key' => 'field_acfe_form_html_submit_button',
1000 'label' => 'Submit button',
1001 'name' => 'acfe_form_html_submit_button',
1002 'type' => 'acfe_code_editor',
1003 'instructions' => 'HTML used to render the submit button.',
1004 'required' => 0,
1005 'conditional_logic' => array(
1006 array(
1007 array(
1008 'field' => 'field_acfe_form_form_submit',
1009 'operator' => '==',
1010 'value' => '1',
1011 ),
1012 ),
1013 ),
1014 'wrapper' => array(
1015 'width' => '',
1016 'class' => '',
1017 'id' => '',
1018 ),
1019 'acfe_permissions' => '',
1020 'default_value' => '<input type="submit" class="acf-button button button-primary button-large" value="%s" />',
1021 'placeholder' => '',
1022 'maxlength' => '',
1023 'rows' => 2,
1024 ),
1025 array(
1026 'key' => 'field_acfe_form_html_submit_spinner',
1027 'label' => 'Submit spinner',
1028 'name' => 'acfe_form_html_submit_spinner',
1029 'type' => 'acfe_code_editor',
1030 'instructions' => 'HTML used to render the submit button loading spinner.',
1031 'required' => 0,
1032 'conditional_logic' => array(
1033 array(
1034 array(
1035 'field' => 'field_acfe_form_form_submit',
1036 'operator' => '==',
1037 'value' => '1',
1038 ),
1039 ),
1040 ),
1041 'wrapper' => array(
1042 'width' => '',
1043 'class' => '',
1044 'id' => '',
1045 ),
1046 'acfe_permissions' => '',
1047 'default_value' => '<span class="acf-spinner"></span>',
1048 'placeholder' => '',
1049 'maxlength' => '',
1050 'rows' => 2,
1051 ),
1052 array(
1053 'key' => 'field_acfe_form_honeypot',
1054 'label' => 'Honeypot',
1055 'name' => 'acfe_form_honeypot',
1056 'type' => 'true_false',
1057 'instructions' => 'Whether to include a hidden input field to capture non human form submission. Defaults to true.',
1058 'required' => 0,
1059 'conditional_logic' => 0,
1060 'wrapper' => array(
1061 'width' => '',
1062 'class' => '',
1063 'id' => '',
1064 ),
1065 'acfe_permissions' => '',
1066 'message' => '',
1067 'default_value' => 1,
1068 'ui' => 1,
1069 'ui_on_text' => '',
1070 'ui_off_text' => '',
1071 ),
1072 array(
1073 'key' => 'field_acfe_form_kses',
1074 'label' => 'Kses',
1075 'name' => 'acfe_form_kses',
1076 'type' => 'true_false',
1077 'instructions' => 'Whether or not to sanitize all $_POST data with the wp_kses_post() function. Defaults to true.',
1078 'required' => 0,
1079 'conditional_logic' => 0,
1080 'wrapper' => array(
1081 'width' => '',
1082 'class' => '',
1083 'id' => '',
1084 ),
1085 'acfe_permissions' => '',
1086 'message' => '',
1087 'default_value' => 1,
1088 'ui' => 1,
1089 'ui_on_text' => '',
1090 'ui_off_text' => '',
1091 ),
1092 array(
1093 'key' => 'field_acfe_form_uploader',
1094 'label' => 'Uploader',
1095 'name' => 'acfe_form_uploader',
1096 'type' => 'radio',
1097 'instructions' => 'Whether to use the WP uploader or a basic input for image and file fields. Defaults to \'wp\'
1098 Choices of \'wp\' or \'basic\'.',
1099 'required' => 0,
1100 'conditional_logic' => 0,
1101 'wrapper' => array(
1102 'width' => '',
1103 'class' => '',
1104 'id' => '',
1105 ),
1106 'acfe_permissions' => '',
1107 'choices' => array(
1108 'default' => 'Default',
1109 'wp' => 'WordPress',
1110 'basic' => 'Browser',
1111 ),
1112 'allow_null' => 0,
1113 'other_choice' => 0,
1114 'default_value' => 'default',
1115 'layout' => 'vertical',
1116 'return_format' => 'value',
1117 'save_other_choice' => 0,
1118 ),
1119 array(
1120 'key' => 'field_acfe_form_form_field_el',
1121 'label' => 'Field element',
1122 'name' => 'acfe_form_form_field_el',
1123 'type' => 'radio',
1124 'instructions' => 'Determines element used to wrap a field. Defaults to \'div\'',
1125 'required' => 0,
1126 'conditional_logic' => 0,
1127 'wrapper' => array(
1128 'width' => '',
1129 'class' => '',
1130 'id' => '',
1131 ),
1132 'acfe_permissions' => '',
1133 'choices' => array(
1134 'div' => '&lt;div&gt;',
1135 'tr' => '&lt;tr&gt;',
1136 'td' => '&lt;td&gt;',
1137 'ul' => '&lt;ul&gt;',
1138 'ol' => '&lt;ol&gt;',
1139 'dl' => '&lt;dl&gt;',
1140 ),
1141 'allow_null' => 0,
1142 'other_choice' => 0,
1143 'default_value' => 'div',
1144 'layout' => 'vertical',
1145 'return_format' => 'value',
1146 'save_other_choice' => 0,
1147 ),
1148 array(
1149 'key' => 'field_acfe_form_label_placement',
1150 'label' => 'Label placement',
1151 'name' => 'acfe_form_label_placement',
1152 'type' => 'radio',
1153 'instructions' => 'Determines where field labels are places in relation to fields. Defaults to \'top\'. <br />
1154 Choices of \'top\' (Above fields) or \'left\' (Beside fields)',
1155 'required' => 0,
1156 'conditional_logic' => 0,
1157 'wrapper' => array(
1158 'width' => '',
1159 'class' => '',
1160 'id' => '',
1161 ),
1162 'acfe_permissions' => '',
1163 'choices' => array(
1164 'top' => 'Top',
1165 'left' => 'Left',
1166 'hidden' => 'Hidden',
1167 ),
1168 'allow_null' => 0,
1169 'other_choice' => 0,
1170 'default_value' => 'top',
1171 'layout' => 'vertical',
1172 'return_format' => 'value',
1173 'save_other_choice' => 0,
1174 ),
1175 array(
1176 'key' => 'field_acfe_form_instruction_placement',
1177 'label' => 'Instruction placement',
1178 'name' => 'acfe_form_instruction_placement',
1179 'type' => 'radio',
1180 'instructions' => 'Determines where field instructions are places in relation to fields. Defaults to \'label\'. <br />
1181 Choices of \'label\' (Below labels) or \'field\' (Below fields)',
1182 'required' => 0,
1183 'conditional_logic' => 0,
1184 'wrapper' => array(
1185 'width' => '',
1186 'class' => '',
1187 'id' => '',
1188 ),
1189 'acfe_permissions' => '',
1190 'choices' => array(
1191 'label' => 'Label',
1192 'field' => 'Field',
1193 ),
1194 'allow_null' => 0,
1195 'other_choice' => 0,
1196 'default_value' => 'label',
1197 'layout' => 'vertical',
1198 'return_format' => 'value',
1199 'save_other_choice' => 0,
1200 ),
1201
1202 /*
1203 * HTML
1204 */
1205 array(
1206 'key' => 'field_acfe_form_tab_html',
1207 'label' => 'HTML',
1208 'name' => '',
1209 'type' => 'tab',
1210 'instructions' => '',
1211 'required' => 0,
1212 'conditional_logic' => 0,
1213 'wrapper' => array(
1214 'width' => '',
1215 'class' => '',
1216 'id' => '',
1217 ),
1218 'acfe_permissions' => '',
1219 'placement' => 'top',
1220 'endpoint' => 0,
1221 ),
1222 array(
1223 'key' => 'field_acfe_form_custom_html_enable',
1224 'label' => 'Override Form render',
1225 'name' => 'acfe_form_custom_html_enable',
1226 'type' => 'true_false',
1227 'instructions' => 'Override the native field groups HTML render',
1228 'required' => 0,
1229 'conditional_logic' => 0,
1230 'wrapper' => array(
1231 'width' => '',
1232 'class' => '',
1233 'id' => '',
1234 ),
1235 'acfe_permissions' => '',
1236 'message' => '',
1237 'default_value' => false,
1238 'ui' => 1,
1239 'ui_on_text' => '',
1240 'ui_off_text' => '',
1241 ),
1242 array(
1243 'key' => 'field_acfe_form_html_before_fields',
1244 'label' => 'HTML Before render',
1245 'name' => 'acfe_form_html_before_fields',
1246 'type' => 'acfe_code_editor',
1247 'instructions' => 'Extra HTML to add before the fields',
1248 'required' => 0,
1249 'conditional_logic' => 0,
1250 'wrapper' => array(
1251 'width' => '',
1252 'class' => '',
1253 'id' => '',
1254 ),
1255 'acfe_permissions' => '',
1256 'default_value' => '',
1257 'placeholder' => '',
1258 'maxlength' => '',
1259 'rows' => 2,
1260 ),
1261 array(
1262 'key' => 'field_acfe_form_custom_html',
1263 'label' => 'HTML Form render',
1264 'name' => 'acfe_form_custom_html',
1265 'type' => 'acfe_code_editor',
1266 'instructions' => 'Render your own customized HTML.<br /><br />
1267 Field groups may be included using <code>{field_group:group_key}</code><br/><code>{field_group:Group title}</code><br/><br/>
1268 Fields may be included using <code>{field:field_key}</code><br/><code>{field:field_name}</code>',
1269 'required' => 0,
1270 'wrapper' => array(
1271 'width' => '',
1272 'class' => '',
1273 'id' => '',
1274 ),
1275 'acfe_permissions' => '',
1276 'default_value' => '',
1277 'placeholder' => '',
1278 'maxlength' => '',
1279 'rows' => 12,
1280 'conditional_logic' => array(
1281 array(
1282 array(
1283 'field' => 'field_acfe_form_custom_html_enable',
1284 'operator' => '==',
1285 'value' => '1',
1286 ),
1287 ),
1288 ),
1289 ),
1290 array(
1291 'key' => 'field_acfe_form_html_after_fields',
1292 'label' => 'HTML After render',
1293 'name' => 'acfe_form_html_after_fields',
1294 'type' => 'acfe_code_editor',
1295 'instructions' => 'Extra HTML to add after the fields',
1296 'required' => 0,
1297 'conditional_logic' => 0,
1298 'wrapper' => array(
1299 'width' => '',
1300 'class' => '',
1301 'id' => '',
1302 ),
1303 'acfe_permissions' => '',
1304 'default_value' => '',
1305 'placeholder' => '',
1306 'maxlength' => '',
1307 'rows' => 2,
1308 ),
1309
1310 /*
1311 * Validation
1312 */
1313 array(
1314 'key' => 'field_acfe_form_tab_validation',
1315 'label' => 'Validation',
1316 'name' => '',
1317 'type' => 'tab',
1318 'instructions' => '',
1319 'required' => 0,
1320 'conditional_logic' => 0,
1321 'wrapper' => array(
1322 'width' => '',
1323 'class' => '',
1324 'id' => '',
1325 ),
1326 'acfe_permissions' => '',
1327 'placement' => 'top',
1328 'endpoint' => 0,
1329 ),
1330 array(
1331 'key' => 'field_acfe_form_hide_error',
1332 'label' => 'Hide general error',
1333 'name' => 'acfe_form_hide_error',
1334 'type' => 'true_false',
1335 'instructions' => 'Hide the general error message: "Validation failed. 1 field requires attention"',
1336 'required' => 0,
1337 'conditional_logic' => 0,
1338 'wrapper' => array(
1339 'width' => '',
1340 'class' => '',
1341 'id' => '',
1342 ),
1343 'acfe_permissions' => '',
1344 'message' => '',
1345 'default_value' => 0,
1346 'ui' => 1,
1347 'ui_on_text' => '',
1348 'ui_off_text' => '',
1349 ),
1350 array(
1351 'key' => 'field_acfe_form_hide_revalidation',
1352 'label' => 'Hide successful re-validation',
1353 'name' => 'acfe_form_hide_revalidation',
1354 'type' => 'true_false',
1355 'instructions' => 'Hide the successful notice when an error has been thrown',
1356 'required' => 0,
1357 'conditional_logic' => 0,
1358 'wrapper' => array(
1359 'width' => '',
1360 'class' => '',
1361 'id' => '',
1362 ),
1363 'acfe_permissions' => '',
1364 'message' => '',
1365 'default_value' => 0,
1366 'ui' => 1,
1367 'ui_on_text' => '',
1368 'ui_off_text' => '',
1369 ),
1370 array(
1371 'key' => 'field_acfe_form_hide_unload',
1372 'label' => 'Hide confirmation on exit',
1373 'name' => 'acfe_form_hide_unload',
1374 'type' => 'true_false',
1375 'instructions' => 'Do not prompt user on page refresh',
1376 'required' => 0,
1377 'conditional_logic' => 0,
1378 'wrapper' => array(
1379 'width' => '',
1380 'class' => '',
1381 'id' => '',
1382 ),
1383 'acfe_permissions' => '',
1384 'message' => '',
1385 'default_value' => 0,
1386 'ui' => 1,
1387 'ui_on_text' => '',
1388 'ui_off_text' => '',
1389 ),
1390 array(
1391 'key' => 'field_acfe_form_errors_position',
1392 'label' => 'Fields errors position',
1393 'name' => 'acfe_form_errors_position',
1394 'type' => 'radio',
1395 'instructions' => 'Choose where to display field errors',
1396 'required' => 0,
1397 'conditional_logic' => 0,
1398 'wrapper' => array(
1399 'width' => '',
1400 'class' => '',
1401 'id' => '',
1402 ),
1403 'acfe_permissions' => '',
1404 'choices' => array(
1405 'above' => 'Above fields',
1406 'below' => 'Below fields',
1407 'group' => 'Group errors',
1408 'hide' => 'Hide errors',
1409 ),
1410 'allow_null' => 0,
1411 'other_choice' => 0,
1412 'default_value' => 'above',
1413 'layout' => 'vertical',
1414 'return_format' => 'value',
1415 'save_other_choice' => 0,
1416 ),
1417 array(
1418 'key' => 'field_acfe_form_errors_class',
1419 'label' => 'Fields errors class',
1420 'name' => 'acfe_form_errors_class',
1421 'type' => 'text',
1422 'instructions' => 'Add class to error message',
1423 'required' => 0,
1424 'conditional_logic' => array(
1425 array(
1426 array(
1427 'field' => 'field_acfe_form_errors_position',
1428 'operator' => '!=',
1429 'value' => 'group',
1430 ),
1431 array(
1432 'field' => 'field_acfe_form_errors_position',
1433 'operator' => '!=',
1434 'value' => 'hide',
1435 ),
1436 )
1437 ),
1438 'wrapper' => array(
1439 'width' => '',
1440 'class' => '',
1441 'id' => '',
1442 ),
1443 'acfe_permissions' => '',
1444 'default_value' => '',
1445 'placeholder' => '',
1446 'prepend' => '',
1447 'append' => '',
1448 'maxlength' => '',
1449 ),
1450
1451 /*
1452 * Submission
1453 */
1454 array(
1455 'key' => 'field_acfe_form_tab_submission',
1456 'label' => 'Success Page',
1457 'name' => '',
1458 'type' => 'tab',
1459 'instructions' => '',
1460 'required' => 0,
1461 'conditional_logic' => 0,
1462 'wrapper' => array(
1463 'width' => '',
1464 'class' => '',
1465 'id' => '',
1466 ),
1467 'acfe_permissions' => '',
1468 'placement' => 'top',
1469 'endpoint' => 0,
1470 ),
1471 array(
1472 'key' => 'field_acfe_form_return',
1473 'label' => 'Redirection',
1474 'name' => 'acfe_form_return',
1475 'type' => 'text',
1476 'instructions' => 'The URL to be redirected to after the form is submitted. See "Cheatsheet" tab for all available template tags.<br/><br/><u>This setting is deprecated, use the new "Redirect Action" instead.</u>',
1477 'required' => 0,
1478 'conditional_logic' => 0,
1479 'wrapper' => array(
1480 'width' => '',
1481 'class' => '',
1482 'id' => '',
1483 'data-enable-switch' => true
1484 ),
1485 'acfe_permissions' => '',
1486 'default_value' => '',
1487 'placeholder' => '',
1488 'prepend' => '',
1489 'append' => '',
1490 'maxlength' => '',
1491 ),
1492 array(
1493 'key' => 'field_acfe_form_updated_hide_form',
1494 'label' => 'Hide form',
1495 'name' => 'acfe_form_updated_hide_form',
1496 'type' => 'true_false',
1497 'instructions' => 'Hide form on successful submission',
1498 'conditional_logic' => array(
1499 array(
1500 array(
1501 'field' => 'field_acfe_form_return',
1502 'operator' => '==',
1503 'value' => '',
1504 ),
1505 ),
1506 ),
1507 'wrapper' => array(
1508 'width' => '',
1509 'class' => '',
1510 'id' => '',
1511 ),
1512 'acfe_permissions' => '',
1513 'message' => '',
1514 'default_value' => 0,
1515 'ui' => 1,
1516 'ui_on_text' => '',
1517 'ui_off_text' => '',
1518 ),
1519 array(
1520 'key' => 'field_acfe_form_updated_message',
1521 'label' => 'Success message',
1522 'name' => 'acfe_form_updated_message',
1523 'type' => 'wysiwyg',
1524 'instructions' => 'A message displayed above the form after being redirected. See "Cheatsheet" tab for all available template tags.',
1525 'required' => 0,
1526 'conditional_logic' => array(
1527 array(
1528 array(
1529 'field' => 'field_acfe_form_return',
1530 'operator' => '==',
1531 'value' => '',
1532 ),
1533 ),
1534 ),
1535 'wrapper' => array(
1536 'width' => '',
1537 'class' => '',
1538 'id' => '',
1539 'data-instruction-placement' => 'field'
1540 ),
1541 'acfe_permissions' => '',
1542 'default_value' => __('Post updated', 'acf'),
1543 'tabs' => 'all',
1544 'toolbar' => 'full',
1545 'media_upload' => 1,
1546 'delay' => 0,
1547 ),
1548 array(
1549 'key' => 'field_acfe_form_html_updated_message',
1550 'label' => 'Success wrapper HTML',
1551 'name' => 'acfe_form_html_updated_message',
1552 'type' => 'acfe_code_editor',
1553 'instructions' => 'HTML used to render the updated message.<br />
1554 If used, you have to include the following code <code>%s</code> to print the actual "Success message" above.',
1555 'required' => 0,
1556 'conditional_logic' => array(
1557 array(
1558 array(
1559 'field' => 'field_acfe_form_return',
1560 'operator' => '==',
1561 'value' => '',
1562 ),
1563 ),
1564 ),
1565 'wrapper' => array(
1566 'width' => '',
1567 'class' => '',
1568 'id' => '',
1569 'data-instruction-placement' => 'field'
1570 ),
1571 'acfe_permissions' => '',
1572 'default_value' => '<div id="message" class="updated">%s</div>',
1573 'placeholder' => '',
1574 'maxlength' => '',
1575 'rows' => 2,
1576 ),
1577
1578 /*
1579 * Cheatsheet
1580 */
1581 array(
1582 'key' => 'field_acfe_form_tab_cheatsheet',
1583 'label' => 'Cheatsheet',
1584 'name' => '',
1585 'type' => 'tab',
1586 'instructions' => '',
1587 'required' => 0,
1588 'conditional_logic' => 0,
1589 'wrapper' => array(
1590 'width' => '',
1591 'class' => '',
1592 'id' => '',
1593 ),
1594 'acfe_permissions' => '',
1595 'placement' => 'top',
1596 'endpoint' => 0,
1597 ),
1598
1599 array(
1600 'key' => 'field_acfe_form_cheatsheet_field',
1601 'label' => 'Field',
1602 'name' => 'acfe_form_cheatsheet_field',
1603 'type' => 'acfe_dynamic_render',
1604 'instructions' => 'Retrieve user input from the current form',
1605 'required' => 0,
1606 'conditional_logic' => 0,
1607 'wrapper' => array(
1608 'width' => '',
1609 'class' => '',
1610 'id' => '',
1611 ),
1612 ),
1613 array(
1614 'key' => 'field_acfe_form_cheatsheet_fields',
1615 'label' => 'Fields',
1616 'name' => 'acfe_form_cheatsheet_fields',
1617 'type' => 'acfe_dynamic_render',
1618 'instructions' => 'Retrieve all user inputs from the current form',
1619 'required' => 0,
1620 'conditional_logic' => 0,
1621 'wrapper' => array(
1622 'width' => '',
1623 'class' => '',
1624 'id' => '',
1625 ),
1626 ),
1627 array(
1628 'key' => 'field_acfe_form_cheatsheet_get_field',
1629 'label' => 'Get Field',
1630 'name' => 'acfe_form_cheatsheet_get_field',
1631 'type' => 'acfe_dynamic_render',
1632 'instructions' => 'Retrieve ACF field value from database',
1633 'required' => 0,
1634 'conditional_logic' => 0,
1635 'wrapper' => array(
1636 'width' => '',
1637 'class' => '',
1638 'id' => '',
1639 ),
1640 ),
1641 array(
1642 'key' => 'field_acfe_form_cheatsheet_get_option',
1643 'label' => 'Get Option',
1644 'name' => 'acfe_form_cheatsheet_get_option',
1645 'type' => 'acfe_dynamic_render',
1646 'value' => '',
1647 'instructions' => 'Retrieve option value from database',
1648 'required' => 0,
1649 'conditional_logic' => 0,
1650 'wrapper' => array(
1651 'width' => '',
1652 'class' => '',
1653 'id' => '',
1654 ),
1655 ),
1656 array(
1657 'key' => 'field_acfe_form_cheatsheet_request',
1658 'label' => 'Request',
1659 'name' => 'acfe_form_cheatsheet_request',
1660 'type' => 'acfe_dynamic_render',
1661 'value' => '',
1662 'instructions' => 'Retrieve <code>$_REQUEST</code> value',
1663 'required' => 0,
1664 'conditional_logic' => 0,
1665 'wrapper' => array(
1666 'width' => '',
1667 'class' => '',
1668 'id' => '',
1669 ),
1670 ),
1671 array(
1672 'key' => 'field_acfe_form_cheatsheet_query_var',
1673 'label' => 'Query Var',
1674 'name' => 'acfe_form_cheatsheet_query_var',
1675 'type' => 'acfe_dynamic_render',
1676 'instructions' => 'Retrieve query var values. Can be used to get data from previous action',
1677 'required' => 0,
1678 'conditional_logic' => 0,
1679 'wrapper' => array(
1680 'width' => '',
1681 'class' => '',
1682 'id' => '',
1683 ),
1684 ),
1685 array(
1686 'key' => 'field_acfe_form_cheatsheet_current_form',
1687 'label' => 'Form Settings',
1688 'name' => 'acfe_form_cheatsheet_current_form',
1689 'type' => 'acfe_dynamic_render',
1690 'instructions' => 'Retrieve current Dynamic Form data',
1691 'required' => 0,
1692 'conditional_logic' => 0,
1693 'wrapper' => array(
1694 'width' => '',
1695 'class' => '',
1696 'id' => '',
1697 ),
1698 ),
1699 array(
1700 'key' => 'field_acfe_form_cheatsheet_actions_post',
1701 'label' => 'Action Output: Post',
1702 'name' => 'acfe_form_cheatsheet_actions_post',
1703 'type' => 'acfe_dynamic_render',
1704 'instructions' => 'Retrieve actions output',
1705 'required' => 0,
1706 'conditional_logic' => 0,
1707 'wrapper' => array(
1708 'width' => '',
1709 'class' => '',
1710 'id' => '',
1711 ),
1712 ),
1713 array(
1714 'key' => 'acfe_form_cheatsheet_actions_term',
1715 'label' => 'Action Output: Term',
1716 'name' => 'acfe_form_cheatsheet_actions_term',
1717 'type' => 'acfe_dynamic_render',
1718 'instructions' => 'Retrieve actions output',
1719 'required' => 0,
1720 'conditional_logic' => 0,
1721 'wrapper' => array(
1722 'width' => '',
1723 'class' => '',
1724 'id' => '',
1725 ),
1726 ),
1727 array(
1728 'key' => 'acfe_form_cheatsheet_actions_user',
1729 'label' => 'Action Output: User',
1730 'name' => 'acfe_form_cheatsheet_actions_user',
1731 'type' => 'acfe_dynamic_render',
1732 'instructions' => 'Retrieve actions output',
1733 'required' => 0,
1734 'conditional_logic' => 0,
1735 'wrapper' => array(
1736 'width' => '',
1737 'class' => '',
1738 'id' => '',
1739 ),
1740 ),
1741 array(
1742 'key' => 'acfe_form_cheatsheet_actions_email',
1743 'label' => 'Action Output: Email',
1744 'name' => 'acfe_form_cheatsheet_actions_email',
1745 'type' => 'acfe_dynamic_render',
1746 'instructions' => 'Retrieve actions output',
1747 'required' => 0,
1748 'conditional_logic' => 0,
1749 'wrapper' => array(
1750 'width' => '',
1751 'class' => '',
1752 'id' => '',
1753 ),
1754 ),
1755 array(
1756 'key' => 'field_acfe_form_cheatsheet_current_post',
1757 'label' => 'Current Post',
1758 'name' => 'acfe_form_cheatsheet_current_post',
1759 'type' => 'acfe_dynamic_render',
1760 'instructions' => 'Retrieve current post data (where the form is being printed)',
1761 'required' => 0,
1762 'conditional_logic' => 0,
1763 'wrapper' => array(
1764 'width' => '',
1765 'class' => '',
1766 'id' => '',
1767 ),
1768 ),
1769 array(
1770 'key' => 'field_acfe_form_cheatsheet_current_term',
1771 'label' => 'Current Term',
1772 'name' => 'acfe_form_cheatsheet_current_term',
1773 'type' => 'acfe_dynamic_render',
1774 'instructions' => 'Retrieve current term data (where the form is being printed)',
1775 'required' => 0,
1776 'conditional_logic' => 0,
1777 'wrapper' => array(
1778 'width' => '',
1779 'class' => '',
1780 'id' => '',
1781 ),
1782 ),
1783 array(
1784 'key' => 'field_acfe_form_cheatsheet_current_user',
1785 'label' => 'Current User',
1786 'name' => 'acfe_form_cheatsheet_current_user',
1787 'type' => 'acfe_dynamic_render',
1788 'instructions' => 'Retrieve currently logged user data',
1789 'required' => 0,
1790 'conditional_logic' => 0,
1791 'wrapper' => array(
1792 'width' => '',
1793 'class' => '',
1794 'id' => '',
1795 ),
1796 ),
1797 array(
1798 'key' => 'field_acfe_form_cheatsheet_current_author',
1799 'label' => 'Current Author',
1800 'name' => 'acfe_form_cheatsheet_current_author',
1801 'type' => 'acfe_dynamic_render',
1802 'instructions' => 'Retrieve current post author data (where the form is being printed)',
1803 'required' => 0,
1804 'conditional_logic' => 0,
1805 'wrapper' => array(
1806 'width' => '',
1807 'class' => '',
1808 'id' => '',
1809 ),
1810 ),
1811 ),
1812 'location' => array(
1813 array(
1814 array(
1815 'param' => 'post_type',
1816 'operator' => '==',
1817 'value' => $this->post_type,
1818 ),
1819 ),
1820 ),
1821 'menu_order' => 0,
1822 'position' => 'acf_after_title',
1823 'style' => 'default',
1824 'label_placement' => 'left',
1825 'instruction_placement' => 'label',
1826 'hide_on_screen' => '',
1827 'active' => true,
1828 'description' => '',
1829 'acfe_permissions' => '',
1830 'acfe_form' => 0,
1831 'acfe_meta' => '',
1832 'acfe_note' => '',
1833 ));
1834
1835 }
1836
1837 }
1838
1839 acf_new_instance('acfe_dynamic_forms');
1840
1841 endif;
1842
1843 /*
1844 * ACFE: Import Form
1845 */
1846 function acfe_import_form($args){
1847
1848 // json
1849 if(is_string($args))
1850 $args = json_decode($args, true);
1851
1852 if(!is_array($args) || empty($args))
1853 return new WP_Error('acfe_import_form_invalid_input', __("Input is invalid: Must be a json string or an array."));
1854
1855 // Instance
1856 $instance = acf_get_instance('acfe_dynamic_forms');
1857
1858 // Single
1859 if(acf_maybe_get($args, 'title')){
1860
1861 $name = acf_maybe_get($args, 'acfe_form_name');
1862
1863 $args = array(
1864 $name => $args
1865 );
1866
1867 }
1868
1869 $result = array();
1870
1871 foreach($args as $name => $data){
1872
1873 // Import
1874 $post_id = $instance->import($name, $data);
1875
1876 $return = array(
1877 'success' => true,
1878 'post_id' => $post_id,
1879 'message' => 'Form "' . acf_maybe_get($data, 'title') . '" successfully imported.',
1880 );
1881
1882 // Error
1883 if(is_wp_error($post_id)){
1884
1885 $return['post_id'] = 0;
1886 $return['success'] = false;
1887 $return['message'] = $post_id->get_error_message();
1888
1889 if($post_id->get_error_code() === 'acfe_form_import_already_exists'){
1890
1891 $get_post = get_page_by_path($name, OBJECT, $instance->post_type);
1892
1893 if($get_post){
1894 $return['post_id'] = $get_post->ID;
1895 }
1896
1897 }
1898
1899 }
1900
1901 $result[] = $return;
1902
1903 }
1904
1905 if(count($result) === 1){
1906 $result = $result[0];
1907 }
1908
1909 return $result;
1910
1911 }
1912
1913 /*
1914 * Deprecated ACFE: Import Forms
1915 */
1916 function acfe_import_forms($forms){
1917 return acfe_import_form($forms);
1918 }
1919
1920 /*
1921 * Deprecated ACFE: Import Dynamic Form
1922 */
1923 function acfe_import_dynamic_form($forms = false){
1924 return acfe_import_form($forms);
1925 }