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