PluginProbe
Advanced Custom Fields: Extended / 0.8.8.1
Advanced Custom Fields: Extended v0.8.8.1
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,884 lines 70.3 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 ));
460
461 // Get generated post name (possible name-2)
462 $_name = get_post_field('post_name', $post_id);
463
464 // Update the meta if different
465 if($_name !== $name)
466 update_field('acfe_form_name', $_name, $post_id);
467
468 }
469
470 /*
471 * Validate Name
472 */
473 function validate_name($valid, $value, $field, $input){
474
475 if($valid !== true)
476 return $valid;
477
478 // Check current name
479 $post_id = acfe_get_post_id();
480
481 if(empty($post_id))
482 return $valid;
483
484 $name = get_field($field['name'], $post_id);
485
486 if($value === $name)
487 return $valid;
488
489 $get_posts = get_posts(array(
490 'post_type' => $this->post_type,
491 'name' => $value,
492 'post__not_in' => array($post_id),
493 'fields' => 'ids',
494 'post_status' => array('publish', 'acf-disabled'),
495 'posts_per_page' => 1
496 ));
497
498 if(!empty($get_posts))
499 $valid = 'This form name already exists';
500
501 return $valid;
502
503 }
504
505 /*
506 * Import
507 */
508 function import($name, $args){
509
510 // Vars
511 $title = acf_extract_var($args, 'title');
512 $name = $args['acfe_form_name'];
513
514 // Already exists
515 if(get_page_by_path($name, OBJECT, $this->post_type)){
516 return new WP_Error('acfe_form_import_already_exists', __("Form \"{$title}\" already exists. Import aborted."));
517 }
518
519 // Import Post
520 $post_id = false;
521
522 $post = array(
523 'post_title' => $title,
524 'post_name' => $name,
525 'post_type' => $this->post_type,
526 'post_status' => 'publish'
527 );
528
529 $post = apply_filters("acfe/form/import_post", $post, $name);
530 $post = apply_filters("acfe/form/import_post/name={$name}", $post, $name);
531
532 if($post !== false){
533 $post_id = wp_insert_post($post);
534 }
535
536 if(!$post_id || is_wp_error($post_id)){
537 return new WP_Error('acfe_form_import_error', __("Something went wrong with the form \"{$title}\". Import aborted."));
538 }
539
540 // Import Args
541 $args = apply_filters("acfe/form/import_args", $args, $name, $post_id);
542 $args = apply_filters("acfe/form/import_args/name={$name}", $args, $name, $post_id);
543 $args = apply_filters("acfe/form/import_args/id={$post_id}", $args, $name, $post_id);
544
545 if($args === false)
546 return $post_id;
547
548 // Import Fields
549 acf_enable_filter('local');
550
551 do_action("acfe/form/import_fields", $name, $args, $post_id);
552 do_action("acfe/form/import_fields/name={$name}", $name, $args, $post_id);
553 do_action("acfe/form/import_fields/id={$post_id}", $name, $args, $post_id);
554
555 acf_disable_filter('local');
556
557 // Save
558 $this->save_post($post_id);
559
560 return $post_id;
561
562 }
563
564 /*
565 * Import Fields
566 */
567 function import_fields($name, $args, $post_id){
568
569 // Update
570 acf_update_values($args, $post_id);
571
572 }
573
574 /*
575 * Export: Choices
576 */
577 function export_choices(){
578
579 $choices = array();
580
581 $get_posts = get_posts(array(
582 'post_type' => 'acfe-form',
583 'posts_per_page' => -1,
584 'fields' => 'ids'
585 ));
586
587 if(!$get_posts)
588 return $choices;
589
590 foreach($get_posts as $post_id){
591
592 $name = $this->get_name($post_id);
593 $choices[$name] = esc_html(get_the_title($post_id));
594
595 }
596
597 return $choices;
598
599 }
600
601 /*
602 * Export: Data
603 */
604 function export_data($name){
605
606 if(!$form = get_page_by_path($name, OBJECT, $this->post_type))
607 return false;
608
609 acf_enable_filter('local');
610
611 $args = array_merge(array('title' => get_the_title($form->ID)), get_fields($form->ID, false));
612
613 // Filters
614 $args = apply_filters("acfe/form/export_args", $args, $name);
615 $args = apply_filters("acfe/form/export_args/name={$name}", $args, $name);
616
617 acf_disable_filter('local');
618
619 return $args;
620
621 }
622
623 /*
624 * Add Local Field Group
625 */
626 function add_local_field_group(){
627
628 $actions_layouts = apply_filters('acfe/form/actions', array());
629 ksort($actions_layouts);
630
631 acf_add_local_field_group(array(
632 'key' => 'group_acfe_dynamic_form',
633 'title' => 'Dynamic Form',
634 'acfe_display_title' => '',
635 'fields' => array(
636
637 /*
638 * Actions
639 */
640 array(
641 'key' => 'field_acfe_form_tab_general',
642 'label' => 'General',
643 'name' => '',
644 'type' => 'tab',
645 'instructions' => '',
646 'required' => 0,
647 'conditional_logic' => 0,
648 'wrapper' => array(
649 'width' => '',
650 'class' => '',
651 'id' => '',
652 'data-no-preference' => true,
653 ),
654 'acfe_permissions' => '',
655 'placement' => 'top',
656 'endpoint' => 0,
657 ),
658 array(
659 'key' => 'field_acfe_form_name',
660 'label' => 'Form name',
661 'name' => 'acfe_form_name',
662 'type' => 'acfe_slug',
663 'instructions' => 'The unique form slug',
664 'required' => 1,
665 'conditional_logic' => 0,
666 'wrapper' => array(
667 'width' => '',
668 'class' => '',
669 'id' => '',
670 ),
671 'acfe_permissions' => '',
672 'default_value' => '',
673 'placeholder' => '',
674 'prepend' => '',
675 'append' => '',
676 'maxlength' => '',
677 ),
678 array(
679 'key' => 'field_acfe_form_field_groups',
680 'label' => 'Field groups',
681 'name' => 'acfe_form_field_groups',
682 'type' => 'select',
683 'instructions' => 'Render & map fields of the following field groups',
684 'required' => 0,
685 'conditional_logic' => 0,
686 'wrapper' => array(
687 'width' => '',
688 'class' => '',
689 'id' => '',
690 ),
691 'acfe_permissions' => '',
692 'choices' => array(
693 ),
694 'default_value' => array(
695 ),
696 'allow_null' => 0,
697 'multiple' => 1,
698 'ui' => 1,
699 'ajax' => 0,
700 'return_format' => 'value',
701 'placeholder' => '',
702 ),
703 array(
704 'key' => 'field_acfe_form_actions',
705 'label' => 'Actions',
706 'name' => 'acfe_form_actions',
707 'type' => 'flexible_content',
708 'instructions' => 'Add actions on form submission',
709 'required' => 0,
710 'conditional_logic' => 0,
711 'wrapper' => array(
712 'width' => '',
713 'class' => '',
714 'id' => '',
715 ),
716 'acfe_flexible_stylised_button' => 1,
717 'layouts' => $actions_layouts,
718 'button_label' => 'Add action',
719 'min' => '',
720 'max' => '',
721 ),
722
723 /*
724 * Settings
725 */
726 array(
727 'key' => 'field_acfe_form_tab_settings',
728 'label' => 'Settings',
729 'name' => '',
730 'type' => 'tab',
731 'instructions' => '',
732 'required' => 0,
733 'conditional_logic' => 0,
734 'wrapper' => array(
735 'width' => '',
736 'class' => '',
737 'id' => '',
738 ),
739 'acfe_permissions' => '',
740 'placement' => 'top',
741 'endpoint' => 0,
742 ),
743 array(
744 'key' => 'field_acfe_form_field_groups_rules',
745 'label' => 'Field groups locations rules',
746 'name' => 'acfe_form_field_groups_rules',
747 'type' => 'true_false',
748 'instructions' => 'Apply field groups locations rules for front-end display',
749 'required' => 0,
750 'wrapper' => array(
751 'width' => '',
752 'class' => '',
753 'id' => '',
754 ),
755 'acfe_permissions' => '',
756 'message' => '',
757 'default_value' => 0,
758 'ui' => 1,
759 'ui_on_text' => '',
760 'ui_off_text' => '',
761 ),
762 array(
763 'key' => 'field_acfe_form_form_element',
764 'label' => 'Form element',
765 'name' => 'acfe_form_form_element',
766 'type' => 'true_false',
767 'instructions' => 'Whether or not to create a <code>&lt;form&gt;</code> element',
768 'required' => 0,
769 'conditional_logic' => 0,
770 'wrapper' => array(
771 'width' => '',
772 'class' => '',
773 'id' => '',
774 ),
775 'acfe_permissions' => '',
776 'message' => '',
777 'default_value' => 1,
778 'ui' => 1,
779 'ui_on_text' => '',
780 'ui_off_text' => '',
781 ),
782 array(
783 'key' => 'field_acfe_form_attributes',
784 'label' => 'Form attributes',
785 'name' => 'acfe_form_attributes',
786 'type' => 'group',
787 'instructions' => 'Form class and id',
788 'required' => 0,
789 'wrapper' => array(
790 'width' => '',
791 'class' => '',
792 'id' => '',
793 ),
794 'acfe_permissions' => '',
795 'layout' => 'block',
796 'acfe_seamless_style' => true,
797 'acfe_group_modal' => 0,
798 'conditional_logic' => array(
799 array(
800 array(
801 'field' => 'field_acfe_form_form_element',
802 'operator' => '==',
803 'value' => '1',
804 ),
805 ),
806 ),
807 'sub_fields' => array(
808 array(
809 'key' => 'field_acfe_form_attributes_class',
810 'label' => '',
811 'name' => 'acfe_form_attributes_class',
812 'type' => 'text',
813 'instructions' => '',
814 'required' => 0,
815 'conditional_logic' => array(),
816 'wrapper' => array(
817 'width' => '33',
818 'class' => '',
819 'id' => '',
820 ),
821 'acfe_permissions' => '',
822 'default_value' => 'acf-form',
823 'placeholder' => '',
824 'prepend' => 'class',
825 'append' => '',
826 'maxlength' => '',
827 ),
828 array(
829 'key' => 'field_acfe_form_attributes_id',
830 'label' => '',
831 'name' => 'acfe_form_attributes_id',
832 'type' => 'text',
833 'instructions' => '',
834 'required' => 0,
835 'conditional_logic' => array(),
836 'wrapper' => array(
837 'width' => '33',
838 'class' => '',
839 'id' => '',
840 ),
841 'acfe_permissions' => '',
842 'default_value' => '',
843 'placeholder' => '',
844 'prepend' => 'id',
845 'append' => '',
846 'maxlength' => '',
847 ),
848
849 ),
850 ),
851 array(
852 'key' => 'field_acfe_form_fields_attributes',
853 'label' => 'Fields class',
854 'name' => 'acfe_form_fields_attributes',
855 'type' => 'group',
856 'instructions' => 'Add class to all fields',
857 'required' => 0,
858 'wrapper' => array(
859 'width' => '',
860 'class' => '',
861 'id' => '',
862 ),
863 'acfe_permissions' => '',
864 'layout' => 'block',
865 'acfe_seamless_style' => true,
866 'acfe_group_modal' => 0,
867 'conditional_logic' => array(),
868 'sub_fields' => array(
869 array(
870 'key' => 'field_acfe_form_fields_wrapper_class',
871 'label' => '',
872 'name' => 'acfe_form_fields_wrapper_class',
873 'type' => 'text',
874 'instructions' => '',
875 'required' => 0,
876 'conditional_logic' => array(),
877 'wrapper' => array(
878 'width' => '33',
879 'class' => '',
880 'id' => '',
881 ),
882 'acfe_permissions' => '',
883 'default_value' => '',
884 'placeholder' => '',
885 'prepend' => 'wrapper class',
886 'append' => '',
887 'maxlength' => '',
888 ),
889 array(
890 'key' => 'field_acfe_form_fields_class',
891 'label' => '',
892 'name' => 'acfe_form_fields_class',
893 'type' => 'text',
894 'instructions' => '',
895 'required' => 0,
896 'conditional_logic' => array(),
897 'wrapper' => array(
898 'width' => '33',
899 'class' => '',
900 'id' => '',
901 ),
902 'acfe_permissions' => '',
903 'default_value' => '',
904 'placeholder' => '',
905 'prepend' => 'input class',
906 'append' => '',
907 'maxlength' => '',
908 ),
909 ),
910 ),
911 array(
912 'key' => 'field_acfe_form_form_submit',
913 'label' => 'Submit button',
914 'name' => 'acfe_form_form_submit',
915 'type' => 'true_false',
916 'instructions' => 'Whether or not to create a form submit button. Defaults to true',
917 'required' => 0,
918 'conditional_logic' => 0,
919 'wrapper' => array(
920 'width' => '',
921 'class' => '',
922 'id' => '',
923 ),
924 'acfe_permissions' => '',
925 'message' => '',
926 'default_value' => 1,
927 'ui' => 1,
928 'ui_on_text' => '',
929 'ui_off_text' => '',
930 ),
931 array(
932 'key' => 'field_acfe_form_submit_value',
933 'label' => 'Submit value',
934 'name' => 'acfe_form_submit_value',
935 'type' => 'text',
936 'instructions' => 'The text displayed on the submit button',
937 'required' => 0,
938 'conditional_logic' => array(
939 array(
940 array(
941 'field' => 'field_acfe_form_form_submit',
942 'operator' => '==',
943 'value' => '1',
944 ),
945 ),
946 ),
947 'wrapper' => array(
948 'width' => '',
949 'class' => '',
950 'id' => '',
951 ),
952 'acfe_permissions' => '',
953 'default_value' => 'Submit',
954 'placeholder' => '',
955 'prepend' => '',
956 'append' => '',
957 'maxlength' => '',
958 ),
959 array(
960 'key' => 'field_acfe_form_html_submit_button',
961 'label' => 'Submit button',
962 'name' => 'acfe_form_html_submit_button',
963 'type' => 'acfe_code_editor',
964 'instructions' => 'HTML used to render the submit button.',
965 'required' => 0,
966 'conditional_logic' => array(
967 array(
968 array(
969 'field' => 'field_acfe_form_form_submit',
970 'operator' => '==',
971 'value' => '1',
972 ),
973 ),
974 ),
975 'wrapper' => array(
976 'width' => '',
977 'class' => '',
978 'id' => '',
979 ),
980 'acfe_permissions' => '',
981 'default_value' => '<input type="submit" class="acf-button button button-primary button-large" value="%s" />',
982 'placeholder' => '',
983 'maxlength' => '',
984 'rows' => 2,
985 ),
986 array(
987 'key' => 'field_acfe_form_html_submit_spinner',
988 'label' => 'Submit spinner',
989 'name' => 'acfe_form_html_submit_spinner',
990 'type' => 'acfe_code_editor',
991 'instructions' => 'HTML used to render the submit button loading spinner.',
992 'required' => 0,
993 'conditional_logic' => array(
994 array(
995 array(
996 'field' => 'field_acfe_form_form_submit',
997 'operator' => '==',
998 'value' => '1',
999 ),
1000 ),
1001 ),
1002 'wrapper' => array(
1003 'width' => '',
1004 'class' => '',
1005 'id' => '',
1006 ),
1007 'acfe_permissions' => '',
1008 'default_value' => '<span class="acf-spinner"></span>',
1009 'placeholder' => '',
1010 'maxlength' => '',
1011 'rows' => 2,
1012 ),
1013 array(
1014 'key' => 'field_acfe_form_honeypot',
1015 'label' => 'Honeypot',
1016 'name' => 'acfe_form_honeypot',
1017 'type' => 'true_false',
1018 'instructions' => 'Whether to include a hidden input field to capture non human form submission. Defaults to true.',
1019 'required' => 0,
1020 'conditional_logic' => 0,
1021 'wrapper' => array(
1022 'width' => '',
1023 'class' => '',
1024 'id' => '',
1025 ),
1026 'acfe_permissions' => '',
1027 'message' => '',
1028 'default_value' => 1,
1029 'ui' => 1,
1030 'ui_on_text' => '',
1031 'ui_off_text' => '',
1032 ),
1033 array(
1034 'key' => 'field_acfe_form_kses',
1035 'label' => 'Kses',
1036 'name' => 'acfe_form_kses',
1037 'type' => 'true_false',
1038 'instructions' => 'Whether or not to sanitize all $_POST data with the wp_kses_post() function. Defaults to true.',
1039 'required' => 0,
1040 'conditional_logic' => 0,
1041 'wrapper' => array(
1042 'width' => '',
1043 'class' => '',
1044 'id' => '',
1045 ),
1046 'acfe_permissions' => '',
1047 'message' => '',
1048 'default_value' => 1,
1049 'ui' => 1,
1050 'ui_on_text' => '',
1051 'ui_off_text' => '',
1052 ),
1053 array(
1054 'key' => 'field_acfe_form_uploader',
1055 'label' => 'Uploader',
1056 'name' => 'acfe_form_uploader',
1057 'type' => 'radio',
1058 'instructions' => 'Whether to use the WP uploader or a basic input for image and file fields. Defaults to \'wp\'
1059 Choices of \'wp\' or \'basic\'.',
1060 'required' => 0,
1061 'conditional_logic' => 0,
1062 'wrapper' => array(
1063 'width' => '',
1064 'class' => '',
1065 'id' => '',
1066 ),
1067 'acfe_permissions' => '',
1068 'choices' => array(
1069 'default' => 'Default',
1070 'wp' => 'WordPress',
1071 'basic' => 'Browser',
1072 ),
1073 'allow_null' => 0,
1074 'other_choice' => 0,
1075 'default_value' => 'default',
1076 'layout' => 'vertical',
1077 'return_format' => 'value',
1078 'save_other_choice' => 0,
1079 ),
1080 array(
1081 'key' => 'field_acfe_form_form_field_el',
1082 'label' => 'Field element',
1083 'name' => 'acfe_form_form_field_el',
1084 'type' => 'radio',
1085 'instructions' => 'Determines element used to wrap a field. Defaults to \'div\'',
1086 'required' => 0,
1087 'conditional_logic' => 0,
1088 'wrapper' => array(
1089 'width' => '',
1090 'class' => '',
1091 'id' => '',
1092 ),
1093 'acfe_permissions' => '',
1094 'choices' => array(
1095 'div' => '&lt;div&gt;',
1096 'tr' => '&lt;tr&gt;',
1097 'td' => '&lt;td&gt;',
1098 'ul' => '&lt;ul&gt;',
1099 'ol' => '&lt;ol&gt;',
1100 'dl' => '&lt;dl&gt;',
1101 ),
1102 'allow_null' => 0,
1103 'other_choice' => 0,
1104 'default_value' => 'div',
1105 'layout' => 'vertical',
1106 'return_format' => 'value',
1107 'save_other_choice' => 0,
1108 ),
1109 array(
1110 'key' => 'field_acfe_form_label_placement',
1111 'label' => 'Label placement',
1112 'name' => 'acfe_form_label_placement',
1113 'type' => 'radio',
1114 'instructions' => 'Determines where field labels are places in relation to fields. Defaults to \'top\'. <br />
1115 Choices of \'top\' (Above fields) or \'left\' (Beside fields)',
1116 'required' => 0,
1117 'conditional_logic' => 0,
1118 'wrapper' => array(
1119 'width' => '',
1120 'class' => '',
1121 'id' => '',
1122 ),
1123 'acfe_permissions' => '',
1124 'choices' => array(
1125 'top' => 'Top',
1126 'left' => 'Left',
1127 'hidden' => 'Hidden',
1128 ),
1129 'allow_null' => 0,
1130 'other_choice' => 0,
1131 'default_value' => 'top',
1132 'layout' => 'vertical',
1133 'return_format' => 'value',
1134 'save_other_choice' => 0,
1135 ),
1136 array(
1137 'key' => 'field_acfe_form_instruction_placement',
1138 'label' => 'Instruction placement',
1139 'name' => 'acfe_form_instruction_placement',
1140 'type' => 'radio',
1141 'instructions' => 'Determines where field instructions are places in relation to fields. Defaults to \'label\'. <br />
1142 Choices of \'label\' (Below labels) or \'field\' (Below fields)',
1143 'required' => 0,
1144 'conditional_logic' => 0,
1145 'wrapper' => array(
1146 'width' => '',
1147 'class' => '',
1148 'id' => '',
1149 ),
1150 'acfe_permissions' => '',
1151 'choices' => array(
1152 'label' => 'Label',
1153 'field' => 'Field',
1154 ),
1155 'allow_null' => 0,
1156 'other_choice' => 0,
1157 'default_value' => 'label',
1158 'layout' => 'vertical',
1159 'return_format' => 'value',
1160 'save_other_choice' => 0,
1161 ),
1162
1163 /*
1164 * HTML
1165 */
1166 array(
1167 'key' => 'field_acfe_form_tab_html',
1168 'label' => 'HTML',
1169 'name' => '',
1170 'type' => 'tab',
1171 'instructions' => '',
1172 'required' => 0,
1173 'conditional_logic' => 0,
1174 'wrapper' => array(
1175 'width' => '',
1176 'class' => '',
1177 'id' => '',
1178 ),
1179 'acfe_permissions' => '',
1180 'placement' => 'top',
1181 'endpoint' => 0,
1182 ),
1183 array(
1184 'key' => 'field_acfe_form_custom_html_enable',
1185 'label' => 'Override Form render',
1186 'name' => 'acfe_form_custom_html_enable',
1187 'type' => 'true_false',
1188 'instructions' => 'Override the native field groups HTML render',
1189 'required' => 0,
1190 'conditional_logic' => 0,
1191 'wrapper' => array(
1192 'width' => '',
1193 'class' => '',
1194 'id' => '',
1195 ),
1196 'acfe_permissions' => '',
1197 'message' => '',
1198 'default_value' => false,
1199 'ui' => 1,
1200 'ui_on_text' => '',
1201 'ui_off_text' => '',
1202 ),
1203 array(
1204 'key' => 'field_acfe_form_html_before_fields',
1205 'label' => 'HTML Before render',
1206 'name' => 'acfe_form_html_before_fields',
1207 'type' => 'acfe_code_editor',
1208 'instructions' => 'Extra HTML to add before the fields',
1209 'required' => 0,
1210 'conditional_logic' => 0,
1211 'wrapper' => array(
1212 'width' => '',
1213 'class' => '',
1214 'id' => '',
1215 ),
1216 'acfe_permissions' => '',
1217 'default_value' => '',
1218 'placeholder' => '',
1219 'maxlength' => '',
1220 'rows' => 2,
1221 ),
1222 array(
1223 'key' => 'field_acfe_form_custom_html',
1224 'label' => 'HTML Form render',
1225 'name' => 'acfe_form_custom_html',
1226 'type' => 'acfe_code_editor',
1227 'instructions' => 'Render your own customized HTML.<br /><br />
1228 Field groups may be included using <code>{field_group:group_key}</code><br/><code>{field_group:Group title}</code><br/><br/>
1229 Fields may be included using <code>{field:field_key}</code><br/><code>{field:field_name}</code>',
1230 'required' => 0,
1231 'wrapper' => array(
1232 'width' => '',
1233 'class' => '',
1234 'id' => '',
1235 ),
1236 'acfe_permissions' => '',
1237 'default_value' => '',
1238 'placeholder' => '',
1239 'maxlength' => '',
1240 'rows' => 12,
1241 'conditional_logic' => array(
1242 array(
1243 array(
1244 'field' => 'field_acfe_form_custom_html_enable',
1245 'operator' => '==',
1246 'value' => '1',
1247 ),
1248 ),
1249 ),
1250 ),
1251 array(
1252 'key' => 'field_acfe_form_html_after_fields',
1253 'label' => 'HTML After render',
1254 'name' => 'acfe_form_html_after_fields',
1255 'type' => 'acfe_code_editor',
1256 'instructions' => 'Extra HTML to add after the fields',
1257 'required' => 0,
1258 'conditional_logic' => 0,
1259 'wrapper' => array(
1260 'width' => '',
1261 'class' => '',
1262 'id' => '',
1263 ),
1264 'acfe_permissions' => '',
1265 'default_value' => '',
1266 'placeholder' => '',
1267 'maxlength' => '',
1268 'rows' => 2,
1269 ),
1270
1271 /*
1272 * Validation
1273 */
1274 array(
1275 'key' => 'field_acfe_form_tab_validation',
1276 'label' => 'Validation',
1277 'name' => '',
1278 'type' => 'tab',
1279 'instructions' => '',
1280 'required' => 0,
1281 'conditional_logic' => 0,
1282 'wrapper' => array(
1283 'width' => '',
1284 'class' => '',
1285 'id' => '',
1286 ),
1287 'acfe_permissions' => '',
1288 'placement' => 'top',
1289 'endpoint' => 0,
1290 ),
1291 array(
1292 'key' => 'field_acfe_form_hide_error',
1293 'label' => 'Hide general error',
1294 'name' => 'acfe_form_hide_error',
1295 'type' => 'true_false',
1296 'instructions' => 'Hide the general error message: "Validation failed. 1 field requires attention"',
1297 'required' => 0,
1298 'conditional_logic' => 0,
1299 'wrapper' => array(
1300 'width' => '',
1301 'class' => '',
1302 'id' => '',
1303 ),
1304 'acfe_permissions' => '',
1305 'message' => '',
1306 'default_value' => 0,
1307 'ui' => 1,
1308 'ui_on_text' => '',
1309 'ui_off_text' => '',
1310 ),
1311 array(
1312 'key' => 'field_acfe_form_hide_revalidation',
1313 'label' => 'Hide successful re-validation',
1314 'name' => 'acfe_form_hide_revalidation',
1315 'type' => 'true_false',
1316 'instructions' => 'Hide the successful notice when an error has been thrown',
1317 'required' => 0,
1318 'conditional_logic' => 0,
1319 'wrapper' => array(
1320 'width' => '',
1321 'class' => '',
1322 'id' => '',
1323 ),
1324 'acfe_permissions' => '',
1325 'message' => '',
1326 'default_value' => 0,
1327 'ui' => 1,
1328 'ui_on_text' => '',
1329 'ui_off_text' => '',
1330 ),
1331 array(
1332 'key' => 'field_acfe_form_hide_unload',
1333 'label' => 'Hide confirmation on exit',
1334 'name' => 'acfe_form_hide_unload',
1335 'type' => 'true_false',
1336 'instructions' => 'Do not prompt user on page refresh',
1337 'required' => 0,
1338 'conditional_logic' => 0,
1339 'wrapper' => array(
1340 'width' => '',
1341 'class' => '',
1342 'id' => '',
1343 ),
1344 'acfe_permissions' => '',
1345 'message' => '',
1346 'default_value' => 0,
1347 'ui' => 1,
1348 'ui_on_text' => '',
1349 'ui_off_text' => '',
1350 ),
1351 array(
1352 'key' => 'field_acfe_form_errors_position',
1353 'label' => 'Fields errors position',
1354 'name' => 'acfe_form_errors_position',
1355 'type' => 'radio',
1356 'instructions' => 'Choose where to display field errors',
1357 'required' => 0,
1358 'conditional_logic' => 0,
1359 'wrapper' => array(
1360 'width' => '',
1361 'class' => '',
1362 'id' => '',
1363 ),
1364 'acfe_permissions' => '',
1365 'choices' => array(
1366 'above' => 'Above fields',
1367 'below' => 'Below fields',
1368 'group' => 'Group errors',
1369 'hide' => 'Hide errors',
1370 ),
1371 'allow_null' => 0,
1372 'other_choice' => 0,
1373 'default_value' => 'above',
1374 'layout' => 'vertical',
1375 'return_format' => 'value',
1376 'save_other_choice' => 0,
1377 ),
1378 array(
1379 'key' => 'field_acfe_form_errors_class',
1380 'label' => 'Fields errors class',
1381 'name' => 'acfe_form_errors_class',
1382 'type' => 'text',
1383 'instructions' => 'Add class to error message',
1384 'required' => 0,
1385 'conditional_logic' => array(
1386 array(
1387 array(
1388 'field' => 'field_acfe_form_errors_position',
1389 'operator' => '!=',
1390 'value' => 'group',
1391 ),
1392 array(
1393 'field' => 'field_acfe_form_errors_position',
1394 'operator' => '!=',
1395 'value' => 'hide',
1396 ),
1397 )
1398 ),
1399 'wrapper' => array(
1400 'width' => '',
1401 'class' => '',
1402 'id' => '',
1403 ),
1404 'acfe_permissions' => '',
1405 'default_value' => '',
1406 'placeholder' => '',
1407 'prepend' => '',
1408 'append' => '',
1409 'maxlength' => '',
1410 ),
1411
1412 /*
1413 * Submission
1414 */
1415 array(
1416 'key' => 'field_acfe_form_tab_submission',
1417 'label' => 'Success Page',
1418 'name' => '',
1419 'type' => 'tab',
1420 'instructions' => '',
1421 'required' => 0,
1422 'conditional_logic' => 0,
1423 'wrapper' => array(
1424 'width' => '',
1425 'class' => '',
1426 'id' => '',
1427 ),
1428 'acfe_permissions' => '',
1429 'placement' => 'top',
1430 'endpoint' => 0,
1431 ),
1432 array(
1433 'key' => 'field_acfe_form_return',
1434 'label' => 'Redirection',
1435 'name' => 'acfe_form_return',
1436 'type' => 'text',
1437 '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>',
1438 'required' => 0,
1439 'conditional_logic' => 0,
1440 'wrapper' => array(
1441 'width' => '',
1442 'class' => '',
1443 'id' => '',
1444 'data-enable-switch' => true
1445 ),
1446 'acfe_permissions' => '',
1447 'default_value' => '',
1448 'placeholder' => '',
1449 'prepend' => '',
1450 'append' => '',
1451 'maxlength' => '',
1452 ),
1453 array(
1454 'key' => 'field_acfe_form_updated_hide_form',
1455 'label' => 'Hide form',
1456 'name' => 'acfe_form_updated_hide_form',
1457 'type' => 'true_false',
1458 'instructions' => 'Hide form on successful submission',
1459 'conditional_logic' => array(
1460 array(
1461 array(
1462 'field' => 'field_acfe_form_return',
1463 'operator' => '==',
1464 'value' => '',
1465 ),
1466 ),
1467 ),
1468 'wrapper' => array(
1469 'width' => '',
1470 'class' => '',
1471 'id' => '',
1472 ),
1473 'acfe_permissions' => '',
1474 'message' => '',
1475 'default_value' => 0,
1476 'ui' => 1,
1477 'ui_on_text' => '',
1478 'ui_off_text' => '',
1479 ),
1480 array(
1481 'key' => 'field_acfe_form_updated_message',
1482 'label' => 'Success message',
1483 'name' => 'acfe_form_updated_message',
1484 'type' => 'wysiwyg',
1485 'instructions' => 'A message displayed above the form after being redirected. See "Cheatsheet" tab for all available template tags.',
1486 'required' => 0,
1487 'conditional_logic' => array(
1488 array(
1489 array(
1490 'field' => 'field_acfe_form_return',
1491 'operator' => '==',
1492 'value' => '',
1493 ),
1494 ),
1495 ),
1496 'wrapper' => array(
1497 'width' => '',
1498 'class' => '',
1499 'id' => '',
1500 'data-instruction-placement' => 'field'
1501 ),
1502 'acfe_permissions' => '',
1503 'default_value' => __('Post updated', 'acf'),
1504 'tabs' => 'all',
1505 'toolbar' => 'full',
1506 'media_upload' => 1,
1507 'delay' => 0,
1508 ),
1509 array(
1510 'key' => 'field_acfe_form_html_updated_message',
1511 'label' => 'Success wrapper HTML',
1512 'name' => 'acfe_form_html_updated_message',
1513 'type' => 'acfe_code_editor',
1514 'instructions' => 'HTML used to render the updated message.<br />
1515 If used, you have to include the following code <code>%s</code> to print the actual "Success message" above.',
1516 'required' => 0,
1517 'conditional_logic' => array(
1518 array(
1519 array(
1520 'field' => 'field_acfe_form_return',
1521 'operator' => '==',
1522 'value' => '',
1523 ),
1524 ),
1525 ),
1526 'wrapper' => array(
1527 'width' => '',
1528 'class' => '',
1529 'id' => '',
1530 'data-instruction-placement' => 'field'
1531 ),
1532 'acfe_permissions' => '',
1533 'default_value' => '<div id="message" class="updated">%s</div>',
1534 'placeholder' => '',
1535 'maxlength' => '',
1536 'rows' => 2,
1537 ),
1538
1539 /*
1540 * Cheatsheet
1541 */
1542 array(
1543 'key' => 'field_acfe_form_tab_cheatsheet',
1544 'label' => 'Cheatsheet',
1545 'name' => '',
1546 'type' => 'tab',
1547 'instructions' => '',
1548 'required' => 0,
1549 'conditional_logic' => 0,
1550 'wrapper' => array(
1551 'width' => '',
1552 'class' => '',
1553 'id' => '',
1554 ),
1555 'acfe_permissions' => '',
1556 'placement' => 'top',
1557 'endpoint' => 0,
1558 ),
1559
1560 array(
1561 'key' => 'field_acfe_form_cheatsheet_field',
1562 'label' => 'Field',
1563 'name' => 'acfe_form_cheatsheet_field',
1564 'type' => 'acfe_dynamic_message',
1565 'instructions' => 'Retrieve user input from the current form',
1566 'required' => 0,
1567 'conditional_logic' => 0,
1568 'wrapper' => array(
1569 'width' => '',
1570 'class' => '',
1571 'id' => '',
1572 ),
1573 ),
1574 array(
1575 'key' => 'field_acfe_form_cheatsheet_fields',
1576 'label' => 'Fields',
1577 'name' => 'acfe_form_cheatsheet_fields',
1578 'type' => 'acfe_dynamic_message',
1579 'instructions' => 'Retrieve all user inputs from the current form',
1580 'required' => 0,
1581 'conditional_logic' => 0,
1582 'wrapper' => array(
1583 'width' => '',
1584 'class' => '',
1585 'id' => '',
1586 ),
1587 ),
1588 array(
1589 'key' => 'field_acfe_form_cheatsheet_get_field',
1590 'label' => 'Get Field',
1591 'name' => 'acfe_form_cheatsheet_get_field',
1592 'type' => 'acfe_dynamic_message',
1593 'instructions' => 'Retrieve ACF field value from database',
1594 'required' => 0,
1595 'conditional_logic' => 0,
1596 'wrapper' => array(
1597 'width' => '',
1598 'class' => '',
1599 'id' => '',
1600 ),
1601 ),
1602 array(
1603 'key' => 'field_acfe_form_cheatsheet_get_option',
1604 'label' => 'Get Option',
1605 'name' => 'acfe_form_cheatsheet_get_option',
1606 'type' => 'acfe_dynamic_message',
1607 'value' => '',
1608 'instructions' => 'Retrieve option value from database',
1609 'required' => 0,
1610 'conditional_logic' => 0,
1611 'wrapper' => array(
1612 'width' => '',
1613 'class' => '',
1614 'id' => '',
1615 ),
1616 ),
1617 array(
1618 'key' => 'field_acfe_form_cheatsheet_request',
1619 'label' => 'Request',
1620 'name' => 'acfe_form_cheatsheet_request',
1621 'type' => 'acfe_dynamic_message',
1622 'value' => '',
1623 'instructions' => 'Retrieve <code>$_REQUEST</code> value',
1624 'required' => 0,
1625 'conditional_logic' => 0,
1626 'wrapper' => array(
1627 'width' => '',
1628 'class' => '',
1629 'id' => '',
1630 ),
1631 ),
1632 array(
1633 'key' => 'field_acfe_form_cheatsheet_query_var',
1634 'label' => 'Query Var',
1635 'name' => 'acfe_form_cheatsheet_query_var',
1636 'type' => 'acfe_dynamic_message',
1637 'instructions' => 'Retrieve query var values. Can be used to get data from previous action',
1638 'required' => 0,
1639 'conditional_logic' => 0,
1640 'wrapper' => array(
1641 'width' => '',
1642 'class' => '',
1643 'id' => '',
1644 ),
1645 ),
1646 array(
1647 'key' => 'field_acfe_form_cheatsheet_current_form',
1648 'label' => 'Form Settings',
1649 'name' => 'acfe_form_cheatsheet_current_form',
1650 'type' => 'acfe_dynamic_message',
1651 'instructions' => 'Retrieve current Dynamic Form data',
1652 'required' => 0,
1653 'conditional_logic' => 0,
1654 'wrapper' => array(
1655 'width' => '',
1656 'class' => '',
1657 'id' => '',
1658 ),
1659 ),
1660 array(
1661 'key' => 'field_acfe_form_cheatsheet_actions_post',
1662 'label' => 'Action Output: Post',
1663 'name' => 'acfe_form_cheatsheet_actions_post',
1664 'type' => 'acfe_dynamic_message',
1665 'instructions' => 'Retrieve actions output',
1666 'required' => 0,
1667 'conditional_logic' => 0,
1668 'wrapper' => array(
1669 'width' => '',
1670 'class' => '',
1671 'id' => '',
1672 ),
1673 ),
1674 array(
1675 'key' => 'acfe_form_cheatsheet_actions_term',
1676 'label' => 'Action Output: Term',
1677 'name' => 'acfe_form_cheatsheet_actions_term',
1678 'type' => 'acfe_dynamic_message',
1679 'instructions' => 'Retrieve actions output',
1680 'required' => 0,
1681 'conditional_logic' => 0,
1682 'wrapper' => array(
1683 'width' => '',
1684 'class' => '',
1685 'id' => '',
1686 ),
1687 ),
1688 array(
1689 'key' => 'acfe_form_cheatsheet_actions_user',
1690 'label' => 'Action Output: User',
1691 'name' => 'acfe_form_cheatsheet_actions_user',
1692 'type' => 'acfe_dynamic_message',
1693 'instructions' => 'Retrieve actions output',
1694 'required' => 0,
1695 'conditional_logic' => 0,
1696 'wrapper' => array(
1697 'width' => '',
1698 'class' => '',
1699 'id' => '',
1700 ),
1701 ),
1702 array(
1703 'key' => 'acfe_form_cheatsheet_actions_email',
1704 'label' => 'Action Output: Email',
1705 'name' => 'acfe_form_cheatsheet_actions_email',
1706 'type' => 'acfe_dynamic_message',
1707 'instructions' => 'Retrieve actions output',
1708 'required' => 0,
1709 'conditional_logic' => 0,
1710 'wrapper' => array(
1711 'width' => '',
1712 'class' => '',
1713 'id' => '',
1714 ),
1715 ),
1716 array(
1717 'key' => 'field_acfe_form_cheatsheet_current_post',
1718 'label' => 'Current Post',
1719 'name' => 'acfe_form_cheatsheet_current_post',
1720 'type' => 'acfe_dynamic_message',
1721 'instructions' => 'Retrieve current post data (where the form is being printed)',
1722 'required' => 0,
1723 'conditional_logic' => 0,
1724 'wrapper' => array(
1725 'width' => '',
1726 'class' => '',
1727 'id' => '',
1728 ),
1729 ),
1730 array(
1731 'key' => 'field_acfe_form_cheatsheet_current_term',
1732 'label' => 'Current Term',
1733 'name' => 'acfe_form_cheatsheet_current_term',
1734 'type' => 'acfe_dynamic_message',
1735 'instructions' => 'Retrieve current term data (where the form is being printed)',
1736 'required' => 0,
1737 'conditional_logic' => 0,
1738 'wrapper' => array(
1739 'width' => '',
1740 'class' => '',
1741 'id' => '',
1742 ),
1743 ),
1744 array(
1745 'key' => 'field_acfe_form_cheatsheet_current_user',
1746 'label' => 'Current User',
1747 'name' => 'acfe_form_cheatsheet_current_user',
1748 'type' => 'acfe_dynamic_message',
1749 'instructions' => 'Retrieve currently logged user data',
1750 'required' => 0,
1751 'conditional_logic' => 0,
1752 'wrapper' => array(
1753 'width' => '',
1754 'class' => '',
1755 'id' => '',
1756 ),
1757 ),
1758 array(
1759 'key' => 'field_acfe_form_cheatsheet_current_author',
1760 'label' => 'Current Author',
1761 'name' => 'acfe_form_cheatsheet_current_author',
1762 'type' => 'acfe_dynamic_message',
1763 'instructions' => 'Retrieve current post author data (where the form is being printed)',
1764 'required' => 0,
1765 'conditional_logic' => 0,
1766 'wrapper' => array(
1767 'width' => '',
1768 'class' => '',
1769 'id' => '',
1770 ),
1771 ),
1772 ),
1773 'location' => array(
1774 array(
1775 array(
1776 'param' => 'post_type',
1777 'operator' => '==',
1778 'value' => $this->post_type,
1779 ),
1780 ),
1781 ),
1782 'menu_order' => 0,
1783 'position' => 'acf_after_title',
1784 'style' => 'default',
1785 'label_placement' => 'left',
1786 'instruction_placement' => 'label',
1787 'hide_on_screen' => '',
1788 'active' => true,
1789 'description' => '',
1790 'acfe_permissions' => '',
1791 'acfe_form' => 0,
1792 'acfe_meta' => '',
1793 'acfe_note' => '',
1794 ));
1795
1796 }
1797
1798 }
1799
1800 acf_new_instance('acfe_dynamic_forms');
1801
1802 endif;
1803
1804 /*
1805 * ACFE: Import Forms
1806 */
1807 function acfe_import_forms($forms){
1808
1809 // json
1810 if(is_string($forms))
1811 $forms = json_decode($forms, true);
1812
1813 if(!is_array($forms) || empty($forms))
1814 return new WP_Error('acfe_import_forms_invalid_input', __("Input is invalid"));
1815
1816 if(!acf_is_sequential_array($forms))
1817 return new WP_Error('acfe_import_forms_invalid_array', __("Array is not sequential"));
1818
1819 $return = array();
1820
1821 // Loop over args
1822 foreach($forms as $args){
1823
1824 $message = acfe_import_form($args);
1825
1826 if(is_wp_error($message))
1827 return $message;
1828
1829 $return[] = $message;
1830
1831 }
1832
1833 return $return;
1834
1835 }
1836
1837 /*
1838 * ACFE: Import Form
1839 */
1840 function acfe_import_form($args){
1841
1842 // json
1843 if(is_string($args))
1844 $args = json_decode($args, true);
1845
1846 if(!is_array($args) || empty($args))
1847 return new WP_Error('acfe_import_form_invalid_input', __("Input is invalid"));
1848
1849 if(!acf_is_associative_array($args))
1850 return new WP_Error('acfe_import_form_invalid_array', __("Array is not associative"));
1851
1852 // Import
1853 $instance = acf_get_instance('acfe_dynamic_forms');
1854 $post_id = $instance->import($args);
1855
1856 $return = array(
1857 'success' => true,
1858 'message' => '',
1859 'post_id' => 0,
1860 'title' => acf_maybe_get($args, 'title'),
1861 'name' => acf_maybe_get($args, 'acfe_form_name')
1862 );
1863
1864 if(is_wp_error($post_id)){
1865
1866 $return['success'] = false;
1867 $return['message'] = $post_id->get_error_message();
1868
1869 }else{
1870
1871 $return['post_id'] = $post_id;
1872
1873 }
1874
1875 return $return;
1876
1877 }
1878
1879 /*
1880 * Deprecated ACFE: Import Dynamic Form
1881 */
1882 function acfe_import_dynamic_form($forms = false){
1883 return acfe_import_forms($forms);
1884 }