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