module-form-action-custom.php
9 months ago
module-form-action-email.php
1 week ago
module-form-action-post.php
3 months ago
module-form-action-redirect.php
9 months ago
module-form-action-term.php
3 months ago
module-form-action-user.php
1 week ago
module-form-action.php
3 months ago
module-form-compatibility.php
3 months ago
module-form-deprecated.php
1 year ago
module-form-fields.php
3 months ago
module-form-front-hooks.php
3 months ago
module-form-front-render.php
1 week ago
module-form-front.php
3 months ago
module-form-shortcode.php
1 week ago
module-form-upgrades.php
3 months ago
module-form.php
3 months ago
module-form-fields.php
2182 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_module_form_field_groups')): |
| 8 | |
| 9 | class acfe_module_form_field_groups{ |
| 10 | |
| 11 | /* |
| 12 | * Construct |
| 13 | */ |
| 14 | function __construct(){ |
| 15 | |
| 16 | // register field groups |
| 17 | add_filter('acfe/module/register_field_groups/module=form', array($this, 'register_field_groups'), 10, 2); |
| 18 | |
| 19 | // deprecated |
| 20 | add_filter('acf/prepare_field/key=field_success_return', array($this, 'prepare_success_return')); |
| 21 | |
| 22 | // checkbox choices |
| 23 | // todo: use attribute instead? |
| 24 | add_filter('acf/prepare_field/key=field_option_action_save_acf_fields', array($this, 'checkbox_choices')); |
| 25 | add_filter('acf/prepare_field/key=field_option_action_load_acf_fields', array($this, 'checkbox_choices')); |
| 26 | add_filter('acf/prepare_field/key=field_post_action_save_acf_fields', array($this, 'checkbox_choices')); |
| 27 | add_filter('acf/prepare_field/key=field_post_action_load_acf_fields', array($this, 'checkbox_choices')); |
| 28 | add_filter('acf/prepare_field/key=field_term_action_save_acf_fields', array($this, 'checkbox_choices')); |
| 29 | add_filter('acf/prepare_field/key=field_term_action_load_acf_fields', array($this, 'checkbox_choices')); |
| 30 | add_filter('acf/prepare_field/key=field_user_action_save_acf_fields', array($this, 'checkbox_choices')); |
| 31 | add_filter('acf/prepare_field/key=field_user_action_load_acf_fields', array($this, 'checkbox_choices')); |
| 32 | add_action('wp_ajax_acfe/form/map_checkbox_ajax', array($this, 'ajax_checkbox_choices')); |
| 33 | add_action('wp_ajax_acfe/form/field_groups_metabox', array($this, 'ajax_field_groups_metabox')); |
| 34 | |
| 35 | // select choices |
| 36 | add_filter('acf/prepare_field/type=select', array($this, 'select_choices'), 15); |
| 37 | add_filter('acf/prepare_field/type=acfe_post_types', array($this, 'select_choices'), 15); |
| 38 | add_filter('acf/prepare_field/type=acfe_post_statuses', array($this, 'select_choices'), 15); |
| 39 | add_filter('acf/prepare_field/type=acfe_taxonomy_terms', array($this, 'select_choices'), 15); |
| 40 | add_filter('acf/prepare_field/type=acfe_taxonomies', array($this, 'select_choices'), 15); |
| 41 | add_filter('acf/prepare_field/type=acfe_user_roles', array($this, 'select_choices'), 15); |
| 42 | add_action('wp_ajax_acfe/form/map_field_ajax', array($this, 'ajax_select_choices')); |
| 43 | |
| 44 | // field groups choices |
| 45 | add_filter('acf/prepare_field/key=field_field_groups', array($this, 'field_groups_choices'), 15); |
| 46 | add_action('wp_ajax_acfe/form/map_field_groups_ajax', array($this, 'ajax_field_groups_choices')); |
| 47 | |
| 48 | // post object |
| 49 | add_action('wp_ajax_acf/fields/post_object/query', array($this, 'ajax_post_object_choices'), 5); |
| 50 | add_action('wp_ajax_acf/fields/acfe_taxonomy_terms/query', array($this, 'ajax_taxonomy_terms_choices'), 5); |
| 51 | add_action('wp_ajax_acf/fields/user/query', array($this, 'ajax_post_author_choices'), 5); |
| 52 | |
| 53 | |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * ajax_post_object_choices |
| 59 | */ |
| 60 | function ajax_post_object_choices(){ |
| 61 | |
| 62 | // added in js |
| 63 | if(!acf_maybe_get_POST('is_form') || !acf_maybe_get_POST('field_key')){ |
| 64 | return; |
| 65 | } |
| 66 | |
| 67 | acf_add_local_field(array( |
| 68 | 'key' => acf_maybe_get_POST('field_key'), |
| 69 | 'label' => '', |
| 70 | 'name' => '', |
| 71 | 'type' => 'post_object', |
| 72 | 'instructions' => '', |
| 73 | 'required' => 0, |
| 74 | 'conditional_logic' => array(), |
| 75 | 'wrapper' => array( |
| 76 | 'width' => '', |
| 77 | 'class' => '', |
| 78 | 'id' => '', |
| 79 | ), |
| 80 | 'return_format' => 'id', |
| 81 | 'default_value' => '', |
| 82 | )); |
| 83 | |
| 84 | } |
| 85 | |
| 86 | |
| 87 | /** |
| 88 | * ajax_taxonomy_terms_choices |
| 89 | */ |
| 90 | function ajax_taxonomy_terms_choices(){ |
| 91 | |
| 92 | // added in js |
| 93 | if(!acf_maybe_get_POST('is_form') || !acf_maybe_get_POST('field_key')){ |
| 94 | return; |
| 95 | } |
| 96 | |
| 97 | acf_add_local_field(array( |
| 98 | 'key' => acf_maybe_get_POST('field_key'), |
| 99 | 'label' => '', |
| 100 | 'name' => 'target_custom', |
| 101 | 'type' => 'acfe_taxonomy_terms', |
| 102 | 'instructions' => '', |
| 103 | 'required' => 0, |
| 104 | 'conditional_logic' => array(), |
| 105 | 'wrapper' => array( |
| 106 | 'width' => '', |
| 107 | 'class' => '', |
| 108 | 'id' => '', |
| 109 | ), |
| 110 | 'field_type' => 'select', |
| 111 | 'return_format' => 'id', |
| 112 | 'ui' => true, |
| 113 | 'ajax' => true, |
| 114 | 'default_value' => '', |
| 115 | )); |
| 116 | |
| 117 | } |
| 118 | |
| 119 | |
| 120 | /** |
| 121 | * ajax_post_author_choices |
| 122 | */ |
| 123 | function ajax_post_author_choices(){ |
| 124 | |
| 125 | // added in js |
| 126 | if(!acf_maybe_get_POST('is_form') || !acf_maybe_get_POST('field_key')){ |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | acf_add_local_field(array( |
| 131 | 'key' => acf_maybe_get_POST('field_key'), |
| 132 | 'label' => '', |
| 133 | 'name' => '', |
| 134 | 'type' => 'user', |
| 135 | 'instructions' => '', |
| 136 | 'required' => 0, |
| 137 | 'conditional_logic' => array(), |
| 138 | 'wrapper' => array( |
| 139 | 'width' => '', |
| 140 | 'class' => '', |
| 141 | 'id' => '', |
| 142 | ), |
| 143 | 'return_format' => 'id', |
| 144 | 'default_value' => '', |
| 145 | )); |
| 146 | |
| 147 | } |
| 148 | |
| 149 | |
| 150 | /** |
| 151 | * checkbox_choices |
| 152 | * |
| 153 | * @param $field |
| 154 | * |
| 155 | * @return mixed |
| 156 | */ |
| 157 | function checkbox_choices($field){ |
| 158 | |
| 159 | // global |
| 160 | global $item; |
| 161 | |
| 162 | // prepare field groups |
| 163 | $field_groups = $item['field_groups']; |
| 164 | $field_groups = array_filter($field_groups, 'acf_get_field_group'); |
| 165 | $field_groups = array_unique($field_groups); |
| 166 | |
| 167 | // vars |
| 168 | $choices = array(); |
| 169 | |
| 170 | // loop |
| 171 | foreach($field_groups as $field_group){ |
| 172 | |
| 173 | // field group |
| 174 | $field_group_obj = acf_get_field_group($field_group); |
| 175 | |
| 176 | // get fields |
| 177 | $fields = $this->get_fields($field_group, true); |
| 178 | |
| 179 | // append |
| 180 | foreach($fields as $_field){ |
| 181 | $choices[ $field_group_obj['title'] ][ $_field['key'] ] = $_field['label']; |
| 182 | } |
| 183 | |
| 184 | } |
| 185 | |
| 186 | $field['choices'] = $choices; |
| 187 | |
| 188 | return $field; |
| 189 | |
| 190 | } |
| 191 | |
| 192 | |
| 193 | /** |
| 194 | * ajax_field_groups_metabox |
| 195 | */ |
| 196 | function ajax_field_groups_metabox(){ |
| 197 | |
| 198 | // validate |
| 199 | if(!acf_verify_ajax()){ |
| 200 | die(); |
| 201 | } |
| 202 | |
| 203 | // default options |
| 204 | $options = acf_parse_args($_POST, array( |
| 205 | 'field_groups' => array(), |
| 206 | )); |
| 207 | |
| 208 | $field_groups = array(); |
| 209 | |
| 210 | // loop field groups |
| 211 | foreach($options['field_groups'] as $key){ |
| 212 | |
| 213 | // get local field group if any |
| 214 | $field_group = acf_get_field_group($key); |
| 215 | |
| 216 | if($field_group){ |
| 217 | |
| 218 | // store |
| 219 | $field_groups[] = $field_group; |
| 220 | |
| 221 | } |
| 222 | |
| 223 | } |
| 224 | |
| 225 | if($field_groups){ |
| 226 | |
| 227 | acf_disable_filter('clone'); |
| 228 | |
| 229 | acfe_render_field_groups_details($field_groups); |
| 230 | |
| 231 | } |
| 232 | |
| 233 | die; |
| 234 | |
| 235 | } |
| 236 | |
| 237 | |
| 238 | /** |
| 239 | * ajax_checkbox_choices |
| 240 | */ |
| 241 | function ajax_checkbox_choices(){ |
| 242 | |
| 243 | // validate |
| 244 | if(!acf_verify_ajax()){ |
| 245 | die(); |
| 246 | } |
| 247 | |
| 248 | // default options |
| 249 | $options = acf_parse_args($_POST, array( |
| 250 | 'post_id' => 0, |
| 251 | 'name' => '', |
| 252 | '_name' => '', |
| 253 | 'key' => '', |
| 254 | 'value' => array(), |
| 255 | 'field_groups' => array(), |
| 256 | )); |
| 257 | |
| 258 | $field = array( |
| 259 | 'key' => $options['key'], |
| 260 | 'label' => 'Save ACF fields', |
| 261 | 'name' => $options['name'], |
| 262 | 'type' => 'checkbox', |
| 263 | 'instructions' => __('Which ACF fields should be saved as metadata', 'acfe'), |
| 264 | 'required' => 0, |
| 265 | 'conditional_logic' => 0, |
| 266 | 'wrapper' => array( |
| 267 | 'width' => '', |
| 268 | 'class' => '', |
| 269 | 'id' => '', |
| 270 | ), |
| 271 | 'choices' => array(), |
| 272 | 'allow_custom' => 0, |
| 273 | 'default_value' => array(), |
| 274 | 'value' => $options['value'], |
| 275 | 'class' => '', |
| 276 | 'layout' => 'vertical', |
| 277 | 'toggle' => 0, |
| 278 | 'return_format' => 'value', |
| 279 | 'save_custom' => 0, |
| 280 | '_name' => $options['_name'], |
| 281 | ); |
| 282 | |
| 283 | // prepare field groups |
| 284 | $field_groups = $options['field_groups']; |
| 285 | $field_groups = array_filter($field_groups, 'acf_get_field_group'); |
| 286 | $field_groups = array_unique($field_groups); |
| 287 | |
| 288 | $choices = array(); |
| 289 | $labels = array(); |
| 290 | |
| 291 | foreach($field_groups as $field_group){ |
| 292 | |
| 293 | // field group |
| 294 | $field_group_obj = acf_get_field_group($field_group); |
| 295 | |
| 296 | // get fields |
| 297 | $fields = $this->get_fields($field_group, true); |
| 298 | |
| 299 | if(!empty($fields)){ |
| 300 | |
| 301 | // append |
| 302 | foreach($fields as $_field){ |
| 303 | $choices[ $field_group_obj['title'] ][ $_field['key'] ] = $_field['label']; |
| 304 | } |
| 305 | |
| 306 | $labels[] = $field_group_obj['title']; |
| 307 | |
| 308 | } |
| 309 | |
| 310 | } |
| 311 | |
| 312 | $field['choices'] = $choices; |
| 313 | |
| 314 | $attrs = array('data-labels' => $labels); |
| 315 | echo '<div ' . acf_esc_attrs($attrs) . '></div>'; |
| 316 | |
| 317 | acf_get_field_type('checkbox')->render_field($field); |
| 318 | |
| 319 | die; |
| 320 | |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * field_groups_choices |
| 325 | * |
| 326 | * acf/prepare_field/key=field_field_groups |
| 327 | * |
| 328 | * @param $field |
| 329 | * |
| 330 | * @return mixed |
| 331 | */ |
| 332 | function field_groups_choices($field){ |
| 333 | |
| 334 | // validate |
| 335 | if(acfe_get($field, 'ajax_action') !== 'acfe/form/map_field_groups_ajax'){ |
| 336 | return $field; |
| 337 | } |
| 338 | |
| 339 | // fix nonce with acf 6.3.10 |
| 340 | $field['nonce'] = wp_create_nonce($field['key']); |
| 341 | |
| 342 | // append to choices |
| 343 | foreach(acf_get_field_groups() as $field_group){ |
| 344 | $field['choices'][ $field_group['key'] ] = $field_group['key']; |
| 345 | } |
| 346 | |
| 347 | // loop choices |
| 348 | foreach(array_keys($field['choices']) as $key){ |
| 349 | |
| 350 | // get value |
| 351 | $value = $field['choices'][ $key ]; |
| 352 | |
| 353 | // check field key |
| 354 | if(is_string($value) && acf_is_field_group_key($value)){ |
| 355 | |
| 356 | // get field group |
| 357 | $choice_field_group = acf_get_field_group($value); |
| 358 | |
| 359 | // update title |
| 360 | if($choice_field_group){ |
| 361 | $field['choices'][ $key ] = $choice_field_group['title']; |
| 362 | } |
| 363 | |
| 364 | } |
| 365 | |
| 366 | } |
| 367 | |
| 368 | // encode custom choices |
| 369 | if(isset($field['custom_choices'])){ |
| 370 | |
| 371 | // remove custom choice if already in choices |
| 372 | foreach(array_keys($field['custom_choices']) as $key){ |
| 373 | if(isset($field['choices'][ $key ])){ |
| 374 | unset($field['custom_choices'][ $key ]); |
| 375 | } |
| 376 | } |
| 377 | |
| 378 | $field['wrapper']['data-custom-choices'] = json_encode($field['custom_choices']); |
| 379 | |
| 380 | } |
| 381 | |
| 382 | return $field; |
| 383 | |
| 384 | } |
| 385 | |
| 386 | |
| 387 | /** |
| 388 | * ajax_field_groups_choices |
| 389 | * |
| 390 | * wp_ajax_acfe/form/map_field_groups_ajax |
| 391 | */ |
| 392 | function ajax_field_groups_choices(){ |
| 393 | |
| 394 | $nonce = acf_request_arg('nonce', ''); |
| 395 | $key = acf_request_arg('field_key', ''); |
| 396 | |
| 397 | // Back-compat for field settings. |
| 398 | if(!acf_is_field_key($key)){ |
| 399 | $nonce = ''; |
| 400 | $key = ''; |
| 401 | } |
| 402 | |
| 403 | // validate |
| 404 | if(!acf_verify_ajax($nonce, $key)){ |
| 405 | die(); |
| 406 | } |
| 407 | |
| 408 | // default options |
| 409 | $options = acf_parse_args($_POST, array( |
| 410 | 'post_id' => 0, |
| 411 | 's' => '', |
| 412 | 'value' => '', |
| 413 | 'choices' => array(), |
| 414 | 'custom_choices' => array(), |
| 415 | 'field_key' => '', |
| 416 | 'paged' => 1, |
| 417 | )); |
| 418 | |
| 419 | // vars |
| 420 | $results = array(); |
| 421 | $values = array(); |
| 422 | $search = null; |
| 423 | |
| 424 | // search |
| 425 | if($options['s'] !== ''){ |
| 426 | |
| 427 | // strip slashes (search may be integer) |
| 428 | $search = strval($options['s']); |
| 429 | $search = wp_unslash($search); |
| 430 | |
| 431 | } |
| 432 | |
| 433 | // custom choices |
| 434 | if($options['custom_choices']){ |
| 435 | |
| 436 | $children = array(); |
| 437 | |
| 438 | foreach($options['custom_choices'] as $key => $value){ |
| 439 | |
| 440 | // ensure value is a string |
| 441 | $value = strval($value); |
| 442 | |
| 443 | // append to collection |
| 444 | $values[] = $key; |
| 445 | |
| 446 | // if searching, but doesn't exist |
| 447 | if(is_string($search) && stripos($value, $search) === false && stripos($key, $search) === false){ |
| 448 | continue; |
| 449 | } |
| 450 | |
| 451 | $children[] = array( |
| 452 | 'id' => $key, |
| 453 | 'text' => $value, |
| 454 | ); |
| 455 | |
| 456 | } |
| 457 | |
| 458 | if($children){ |
| 459 | $results[] = array( |
| 460 | 'text' => __('Custom', 'acfe'), |
| 461 | 'children' => $children |
| 462 | ); |
| 463 | } |
| 464 | |
| 465 | } |
| 466 | |
| 467 | // field groups |
| 468 | $children = array(); |
| 469 | |
| 470 | foreach(acf_get_field_groups() as $field_group){ |
| 471 | |
| 472 | // vars |
| 473 | $key = $field_group['key']; |
| 474 | $value = $field_group['title']; |
| 475 | |
| 476 | // ensure value is a string |
| 477 | $value = strval($value); |
| 478 | |
| 479 | // append to collection |
| 480 | $values[] = $key; |
| 481 | |
| 482 | // if searching, but doesn't exist |
| 483 | if(is_string($search) && stripos($value, $search) === false && stripos($key, $search) === false){ |
| 484 | continue; |
| 485 | } |
| 486 | |
| 487 | $children[] = array( |
| 488 | 'id' => $key, |
| 489 | 'text' => $value, |
| 490 | ); |
| 491 | |
| 492 | } |
| 493 | |
| 494 | if($children){ |
| 495 | $results[] = array( |
| 496 | 'text' => 'Field Groups', |
| 497 | 'children' => $children |
| 498 | ); |
| 499 | } |
| 500 | |
| 501 | // custom value |
| 502 | $children = array(); |
| 503 | $value_array = acfe_as_array($options['value']); |
| 504 | $value_array[] = ''; |
| 505 | |
| 506 | foreach($value_array as $value){ |
| 507 | |
| 508 | $key = $value; |
| 509 | $value = strval($value); |
| 510 | |
| 511 | // if search |
| 512 | if(is_string($search)){ |
| 513 | |
| 514 | // search already exists in custom values |
| 515 | if($search === $value && !in_array($value, $values)){ |
| 516 | |
| 517 | $children[] = array( |
| 518 | 'id' => $key, |
| 519 | 'text' => $this->get_field_label($value) |
| 520 | ); |
| 521 | |
| 522 | // search not found in any value, generate choice |
| 523 | }elseif(!in_array($search, $values)){ |
| 524 | |
| 525 | $_key = $search; |
| 526 | $_value = $search; |
| 527 | |
| 528 | // reset children to avoid duplicate append |
| 529 | $children = array(); |
| 530 | $children[] = array( |
| 531 | 'id' => $_key, |
| 532 | 'text' => $this->get_field_label($_value) |
| 533 | ); |
| 534 | |
| 535 | } |
| 536 | |
| 537 | // no search and value not found in choices, generate custom choice |
| 538 | }elseif($value && !in_array($value, $values)){ |
| 539 | |
| 540 | $children[] = array( |
| 541 | 'id' => $key, |
| 542 | 'text' => $this->get_field_label($value) |
| 543 | ); |
| 544 | |
| 545 | } |
| 546 | |
| 547 | } |
| 548 | |
| 549 | if($children){ |
| 550 | array_unshift($results, array( |
| 551 | 'text' => __('Custom', 'acfe'), |
| 552 | 'children' => $children |
| 553 | )); |
| 554 | } |
| 555 | |
| 556 | // response |
| 557 | $response = array( |
| 558 | 'results' => $results, |
| 559 | ); |
| 560 | |
| 561 | // return |
| 562 | acf_send_ajax_results($response); |
| 563 | |
| 564 | } |
| 565 | |
| 566 | |
| 567 | /** |
| 568 | * select_choices |
| 569 | * |
| 570 | * acf/prepare_field/type=select |
| 571 | * |
| 572 | * @param $field |
| 573 | * |
| 574 | * @return mixed |
| 575 | */ |
| 576 | function select_choices($field){ |
| 577 | |
| 578 | // validate |
| 579 | if(acfe_get($field, 'ajax_action') !== 'acfe/form/map_field_ajax'){ |
| 580 | return $field; |
| 581 | } |
| 582 | |
| 583 | // is load |
| 584 | $is_load = isset($field['wrapper']['data-related-field']) && !empty($field['wrapper']['data-related-field']); |
| 585 | |
| 586 | // fix nonce with acf 6.3.10 |
| 587 | $field['nonce'] = wp_create_nonce($field['key']); |
| 588 | |
| 589 | // global |
| 590 | global $item; |
| 591 | |
| 592 | // prepare field groups |
| 593 | $field_groups = $item['field_groups']; |
| 594 | $field_groups = array_filter($field_groups, 'acf_get_field_group'); |
| 595 | $field_groups = array_unique($field_groups); |
| 596 | |
| 597 | // loop field groups |
| 598 | foreach($field_groups as $field_group){ |
| 599 | |
| 600 | // get fields |
| 601 | $fields = $this->get_fields($field_group); |
| 602 | |
| 603 | // append |
| 604 | foreach($fields as $_field){ |
| 605 | |
| 606 | $key = $is_load ? $_field['key'] : "{field:{$_field['key']}}"; |
| 607 | |
| 608 | $field['choices'][ $key ] = $_field['label']; |
| 609 | |
| 610 | } |
| 611 | |
| 612 | } |
| 613 | |
| 614 | $ajax_choices = array(); |
| 615 | |
| 616 | // loop choices |
| 617 | foreach(array_keys($field['choices']) as $key){ |
| 618 | |
| 619 | // get value |
| 620 | $value = $field['choices'][ $key ]; |
| 621 | |
| 622 | // check field key |
| 623 | if(is_string($key) && $this->is_field_key_tag($key, $is_load)){ |
| 624 | |
| 625 | if(is_string($value) && acf_is_field_key($value)){ |
| 626 | $field['choices'][ $key ] = $this->get_field_label($value); |
| 627 | } |
| 628 | |
| 629 | continue; |
| 630 | |
| 631 | } |
| 632 | |
| 633 | $ajax_choices[ $key ] = $value; |
| 634 | |
| 635 | } |
| 636 | |
| 637 | // encode choices |
| 638 | if($ajax_choices){ |
| 639 | |
| 640 | // remove custom choices from choice |
| 641 | if(isset($field['custom_choices'])){ |
| 642 | foreach(array_keys($ajax_choices) as $key){ |
| 643 | if(isset($field['custom_choices'][ $key ])){ |
| 644 | unset($ajax_choices[ $key ]); |
| 645 | } |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | $field['wrapper']['data-choices'] = json_encode($ajax_choices); |
| 650 | |
| 651 | } |
| 652 | |
| 653 | // encode custom choices |
| 654 | if(isset($field['custom_choices'])){ |
| 655 | |
| 656 | // remove custom choice if already in choices |
| 657 | foreach(array_keys($field['custom_choices']) as $key){ |
| 658 | if(isset($field['choices'][ $key ])){ |
| 659 | unset($field['custom_choices'][ $key ]); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | $field['wrapper']['data-custom-choices'] = json_encode($field['custom_choices']); |
| 664 | |
| 665 | } |
| 666 | |
| 667 | // todo: remove exception here |
| 668 | if($field['_name'] === 'save_post_terms'){ |
| 669 | |
| 670 | foreach(array_keys($field['choices']) as $taxonomy){ |
| 671 | |
| 672 | $terms = $field['choices'][ $taxonomy ]; |
| 673 | if(is_array($terms)){ |
| 674 | |
| 675 | unset($field['choices'][ $taxonomy ]); |
| 676 | |
| 677 | foreach($terms as $key => $value){ |
| 678 | $field['choices'][ $key ] = $value; |
| 679 | } |
| 680 | |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | } |
| 685 | |
| 686 | // return |
| 687 | return $field; |
| 688 | |
| 689 | } |
| 690 | |
| 691 | |
| 692 | /** |
| 693 | * ajax_select_choices |
| 694 | * |
| 695 | * wp_ajax_acfe/form/map_field_ajax |
| 696 | */ |
| 697 | function ajax_select_choices(){ |
| 698 | |
| 699 | $nonce = acf_request_arg('nonce', ''); |
| 700 | $key = acf_request_arg('field_key', ''); |
| 701 | |
| 702 | // Back-compat for field settings. |
| 703 | if(!acf_is_field_key($key)){ |
| 704 | $nonce = ''; |
| 705 | $key = ''; |
| 706 | } |
| 707 | |
| 708 | // validate |
| 709 | if(!acf_verify_ajax($nonce, $key)){ |
| 710 | die(); |
| 711 | } |
| 712 | |
| 713 | // default options |
| 714 | $options = acf_parse_args($_POST, array( |
| 715 | 'post_id' => 0, |
| 716 | 's' => '', |
| 717 | 'value' => '', |
| 718 | 'choices' => array(), |
| 719 | 'custom_choices' => array(), |
| 720 | 'field_key' => '', |
| 721 | 'field_label' => '', |
| 722 | 'field_groups' => array(), |
| 723 | 'is_load' => false, |
| 724 | 'paged' => 1, |
| 725 | )); |
| 726 | |
| 727 | // vars |
| 728 | $is_load = (bool) $options['is_load']; |
| 729 | $results = array(); |
| 730 | $values = array(); |
| 731 | $search = null; |
| 732 | |
| 733 | // search |
| 734 | if($options['s'] !== ''){ |
| 735 | |
| 736 | // strip slashes (search may be integer) |
| 737 | $search = strval($options['s']); |
| 738 | $search = wp_unslash($search); |
| 739 | |
| 740 | } |
| 741 | |
| 742 | // custom choices |
| 743 | if($options['custom_choices']){ |
| 744 | |
| 745 | $children = array(); |
| 746 | |
| 747 | foreach($options['custom_choices'] as $key => $value){ |
| 748 | |
| 749 | // ensure value is a string |
| 750 | $value = strval($value); |
| 751 | |
| 752 | // append to collection |
| 753 | $values[] = $key; |
| 754 | |
| 755 | // if searching, but doesn't exist |
| 756 | if(is_string($search) && stripos($value, $search) === false && stripos($key, $search) === false){ |
| 757 | continue; |
| 758 | } |
| 759 | |
| 760 | $children[] = array( |
| 761 | 'id' => $key, |
| 762 | 'text' => $value, |
| 763 | ); |
| 764 | |
| 765 | } |
| 766 | |
| 767 | if($children){ |
| 768 | $results[] = array( |
| 769 | 'text' => __('Custom', 'acfe'), |
| 770 | 'children' => $children |
| 771 | ); |
| 772 | } |
| 773 | |
| 774 | } |
| 775 | |
| 776 | // generic choices |
| 777 | if($options['choices']){ |
| 778 | |
| 779 | $children = array(); |
| 780 | $is_array = false; |
| 781 | |
| 782 | foreach($options['choices'] as $key => $value){ |
| 783 | |
| 784 | // value is array (multi dimentional choices) |
| 785 | if(is_array($value)){ |
| 786 | |
| 787 | $is_array = true; |
| 788 | $sub_children = array(); |
| 789 | |
| 790 | foreach($value as $sub_key => $sub_value){ |
| 791 | |
| 792 | // ensure value is a string |
| 793 | $sub_value = strval($sub_value); |
| 794 | |
| 795 | // append to collection |
| 796 | $values[] = $sub_key; |
| 797 | |
| 798 | // if searching, but doesn't exist |
| 799 | if(is_string($search) && stripos($sub_value, $search) === false && stripos($sub_key, $search) === false){ |
| 800 | continue; |
| 801 | } |
| 802 | |
| 803 | $sub_children[] = array( |
| 804 | 'id' => $sub_key, |
| 805 | 'text' => $sub_value, |
| 806 | ); |
| 807 | |
| 808 | } |
| 809 | |
| 810 | if($sub_children){ |
| 811 | $results[] = array( |
| 812 | 'text' => $key, |
| 813 | 'children' => $sub_children |
| 814 | ); |
| 815 | } |
| 816 | |
| 817 | // normal value |
| 818 | }else{ |
| 819 | |
| 820 | // ensure value is a string |
| 821 | $value = strval($value); |
| 822 | |
| 823 | // append to collection |
| 824 | $values[] = $key; |
| 825 | |
| 826 | // if searching, but doesn't exist |
| 827 | if(is_string($search) && stripos($value, $search) === false && stripos($key, $search) === false){ |
| 828 | continue; |
| 829 | } |
| 830 | |
| 831 | $children[] = array( |
| 832 | 'id' => $key, |
| 833 | 'text' => $value, |
| 834 | ); |
| 835 | |
| 836 | } |
| 837 | |
| 838 | } |
| 839 | |
| 840 | if(!$is_array && $children){ |
| 841 | $results[] = array( |
| 842 | 'text' => $options['field_label'], |
| 843 | 'children' => $children |
| 844 | ); |
| 845 | } |
| 846 | |
| 847 | } |
| 848 | |
| 849 | // field groups fields |
| 850 | foreach($options['field_groups'] as $field_group_key){ |
| 851 | |
| 852 | // vars |
| 853 | $field_group = acf_get_field_group($field_group_key); |
| 854 | |
| 855 | // get fields |
| 856 | $fields = $this->get_fields($field_group_key); |
| 857 | |
| 858 | $children = array(); |
| 859 | foreach($fields as $field){ |
| 860 | |
| 861 | $key = $is_load ? $field['key'] : "{field:{$field['key']}}"; |
| 862 | $value = $field['field']['label']; |
| 863 | |
| 864 | // ensure value is a string |
| 865 | $value = strval($value); |
| 866 | $value = empty($value) ? $field['key'] : "{$value} ({$field['key']})"; |
| 867 | |
| 868 | // append to collection |
| 869 | $values[] = $key; |
| 870 | |
| 871 | // if searching, but doesn't exist |
| 872 | if(is_string($search) && stripos($value, $search) === false && stripos($key, $search) === false){ |
| 873 | continue; |
| 874 | } |
| 875 | |
| 876 | $children[] = array( |
| 877 | 'id' => $key, |
| 878 | 'text' => $field['label'], |
| 879 | ); |
| 880 | |
| 881 | } |
| 882 | |
| 883 | if($children){ |
| 884 | $results[] = array( |
| 885 | 'text' => $field_group['title'], |
| 886 | 'children' => $children |
| 887 | ); |
| 888 | } |
| 889 | |
| 890 | } |
| 891 | |
| 892 | // custom value |
| 893 | $children = array(); |
| 894 | $value_array = acfe_as_array($options['value']); |
| 895 | $value_array[] = ''; // we must append empty string to let search being a custom value (in case a value was never selected before) |
| 896 | |
| 897 | foreach($value_array as $value){ |
| 898 | |
| 899 | $key = $value; |
| 900 | $value = strval($value); |
| 901 | |
| 902 | // if search |
| 903 | if(is_string($search)){ |
| 904 | |
| 905 | // search already exists in custom values |
| 906 | if($search === $value && !in_array($value, $values)){ |
| 907 | |
| 908 | $children[] = array( |
| 909 | 'id' => $key, |
| 910 | 'text' => $this->get_field_label($value) |
| 911 | ); |
| 912 | |
| 913 | // search not found in any value, generate choice |
| 914 | }elseif(!in_array($search, $values)){ |
| 915 | |
| 916 | $_key = $search; |
| 917 | $_value = $search; |
| 918 | |
| 919 | // reset children to avoid duplicate append |
| 920 | $children = array(); |
| 921 | $children[] = array( |
| 922 | 'id' => $_key, |
| 923 | 'text' => $this->get_field_label($_value) |
| 924 | ); |
| 925 | |
| 926 | } |
| 927 | |
| 928 | // no search and value not found in choices, generate custom choice |
| 929 | }elseif($value && !in_array($value, $values)){ |
| 930 | |
| 931 | $children[] = array( |
| 932 | 'id' => $key, |
| 933 | 'text' => $this->get_field_label($value) |
| 934 | ); |
| 935 | |
| 936 | } |
| 937 | |
| 938 | } |
| 939 | |
| 940 | if($children){ |
| 941 | array_unshift($results, array( |
| 942 | 'text' => __('Custom', 'acfe'), |
| 943 | 'children' => $children |
| 944 | )); |
| 945 | } |
| 946 | |
| 947 | // response |
| 948 | $response = array( |
| 949 | 'results' => $results, |
| 950 | ); |
| 951 | |
| 952 | // return |
| 953 | acf_send_ajax_results($response); |
| 954 | |
| 955 | } |
| 956 | |
| 957 | |
| 958 | /** |
| 959 | * get_field_label |
| 960 | * |
| 961 | * @param $value |
| 962 | * |
| 963 | * @return mixed|string |
| 964 | */ |
| 965 | function get_field_label($value){ |
| 966 | |
| 967 | if(is_string($value) && acf_is_field_key($value)){ |
| 968 | |
| 969 | $field = acf_get_field($value); |
| 970 | |
| 971 | if($field){ |
| 972 | |
| 973 | $ancestors = isset($field['ancestors']) ? $field['ancestors'] : count(acf_get_field_ancestors($field)); |
| 974 | |
| 975 | $label = ''; |
| 976 | $label = str_repeat('- ', $ancestors) . $label; |
| 977 | $label .= !empty($field['label']) ? $field['label'] : '(' . __('no label', 'acf') . ')'; |
| 978 | $label .= $field['required'] ? ' *' : ''; |
| 979 | |
| 980 | $value = "{$label} ({$value})"; |
| 981 | |
| 982 | } |
| 983 | |
| 984 | } |
| 985 | |
| 986 | return $value; |
| 987 | |
| 988 | } |
| 989 | |
| 990 | |
| 991 | /** |
| 992 | * get_fields_details |
| 993 | * |
| 994 | * @param $field |
| 995 | * |
| 996 | * @return mixed |
| 997 | */ |
| 998 | function get_fields_details($field){ |
| 999 | |
| 1000 | // disallow tab, message, accordion |
| 1001 | if(in_array($field['type'], array('tab', 'message', 'accordion'))){ |
| 1002 | return false; |
| 1003 | } |
| 1004 | |
| 1005 | // disallow subfields for repeater/flexible content |
| 1006 | if(in_array($field['type'], array('repeater', 'flexible_content'))){ |
| 1007 | $field['sub_fields'] = array(); |
| 1008 | } |
| 1009 | |
| 1010 | // get parent field |
| 1011 | if(is_string($field['parent']) && acf_is_field_key($field['parent'])){ |
| 1012 | |
| 1013 | // get field |
| 1014 | $parent = acf_get_field($field['parent']); |
| 1015 | |
| 1016 | // parent = group |
| 1017 | if($parent && $parent['type'] === 'group' && !empty($parent['label'])){ |
| 1018 | |
| 1019 | // prepend with group label |
| 1020 | $field['label'] = "{$parent['label']}: {$field['label']}"; |
| 1021 | |
| 1022 | } |
| 1023 | |
| 1024 | } |
| 1025 | |
| 1026 | return $field; |
| 1027 | |
| 1028 | } |
| 1029 | |
| 1030 | |
| 1031 | /** |
| 1032 | * get_fields |
| 1033 | * |
| 1034 | * @param $field_group |
| 1035 | * |
| 1036 | * @return array|string[] |
| 1037 | */ |
| 1038 | function get_fields($field_group, $show_top_level = false){ |
| 1039 | |
| 1040 | acf_disable_filter('clone'); |
| 1041 | |
| 1042 | $fields = acf_get_fields($field_group); |
| 1043 | |
| 1044 | if(!empty($fields)){ |
| 1045 | |
| 1046 | // vars |
| 1047 | $all_fields = acfe_get_fields_details_recursive($fields, array($this, 'get_fields_details')); |
| 1048 | $fields = array(); |
| 1049 | |
| 1050 | // check the first field is a child of the field group |
| 1051 | // this fix an issue where acf_get_fields($field_group) return orphan fields in ajax query |
| 1052 | // if field group has no fields and is local field group |
| 1053 | if(!empty($all_fields) && acf_is_local_field_group($field_group)){ |
| 1054 | if(isset($all_fields[0]['field']) && acfe_get($all_fields[0]['field'], 'parent') !== $field_group){ |
| 1055 | return $fields; |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | // filtered fields |
| 1060 | foreach($all_fields as $field){ |
| 1061 | |
| 1062 | // do not show group, clone |
| 1063 | if(in_array($field['field']['type'], array('group'))){ |
| 1064 | continue; |
| 1065 | } |
| 1066 | |
| 1067 | // do not show top level (repeater, flexible content) |
| 1068 | if(!$show_top_level){ |
| 1069 | if(in_array($field['field']['type'], array('clone', 'repeater', 'flexible_content'))){ |
| 1070 | continue; |
| 1071 | } |
| 1072 | } |
| 1073 | |
| 1074 | // filtered |
| 1075 | $fields[] = $field; |
| 1076 | |
| 1077 | } |
| 1078 | |
| 1079 | // loop fields |
| 1080 | foreach(array_keys($fields) as $key){ |
| 1081 | |
| 1082 | $field = $fields[ $key ]; |
| 1083 | |
| 1084 | // add (field_abcdef123456) to field label |
| 1085 | $fields[ $key ]['label'] = "{$field['label']} ({$field['key']})"; |
| 1086 | |
| 1087 | } |
| 1088 | |
| 1089 | } |
| 1090 | |
| 1091 | // return |
| 1092 | return $fields; |
| 1093 | |
| 1094 | } |
| 1095 | |
| 1096 | |
| 1097 | /** |
| 1098 | * is_field_key_tag |
| 1099 | * |
| 1100 | * @param $key |
| 1101 | * @param $is_load |
| 1102 | * |
| 1103 | * @return bool |
| 1104 | */ |
| 1105 | function is_field_key_tag($key, $is_load = false){ |
| 1106 | |
| 1107 | if($is_load){ |
| 1108 | return is_string($key) && !empty($key) && acf_is_field_key($key); |
| 1109 | } |
| 1110 | |
| 1111 | return is_string($key) && !empty($key) && preg_match('/^{field:field_[a-zA-Z0-9_]+}$/', $key); |
| 1112 | |
| 1113 | } |
| 1114 | |
| 1115 | |
| 1116 | /** |
| 1117 | * prepare_success_return |
| 1118 | * |
| 1119 | * @param $field |
| 1120 | * |
| 1121 | * @return false|mixed |
| 1122 | */ |
| 1123 | function prepare_success_return($field){ |
| 1124 | |
| 1125 | if(empty($field['value'])){ |
| 1126 | return false; |
| 1127 | } |
| 1128 | |
| 1129 | _deprecated_function('ACF Extended: "Redirection" Forms setting', '0.8.7.5', "the Redirect Action (See documentation: https://www.acf-extended.com/features/modules/dynamic-forms)"); |
| 1130 | |
| 1131 | return $field; |
| 1132 | |
| 1133 | } |
| 1134 | |
| 1135 | |
| 1136 | /* |
| 1137 | * Register Field Groups |
| 1138 | */ |
| 1139 | function register_field_groups($field_groups, $module){ |
| 1140 | |
| 1141 | $layouts = array(); |
| 1142 | $actions = acfe_get_form_action_types(); |
| 1143 | |
| 1144 | foreach($actions as $action){ |
| 1145 | |
| 1146 | $layout = $action->get_layout(); |
| 1147 | $layouts[ $layout['key'] ] = $layout; |
| 1148 | |
| 1149 | } |
| 1150 | |
| 1151 | $field_groups[] = array( |
| 1152 | 'key' => 'group_acfe_form', |
| 1153 | 'title' => __('Form', 'acfe'), |
| 1154 | |
| 1155 | 'location' => array( |
| 1156 | array( |
| 1157 | array( |
| 1158 | 'param' => 'post_type', |
| 1159 | 'operator' => '==', |
| 1160 | 'value' => $module->post_type, |
| 1161 | ), |
| 1162 | ), |
| 1163 | ), |
| 1164 | |
| 1165 | 'menu_order' => 0, |
| 1166 | 'position' => 'normal', |
| 1167 | 'style' => 'default', |
| 1168 | 'label_placement' => 'left', |
| 1169 | 'instruction_placement' => 'label', |
| 1170 | 'hide_on_screen' => '', |
| 1171 | 'active' => 1, |
| 1172 | 'description' => '', |
| 1173 | |
| 1174 | 'fields' => array( |
| 1175 | |
| 1176 | /** |
| 1177 | * general |
| 1178 | */ |
| 1179 | array( |
| 1180 | 'key' => 'field_tab_general', |
| 1181 | 'label' => __('General', 'acfe'), |
| 1182 | 'name' => '', |
| 1183 | 'type' => 'tab', |
| 1184 | 'instructions' => '', |
| 1185 | 'required' => 0, |
| 1186 | 'conditional_logic' => 0, |
| 1187 | 'wrapper' => array( |
| 1188 | 'width' => '', |
| 1189 | 'class' => '', |
| 1190 | 'id' => '', |
| 1191 | 'data-no-preference' => true, |
| 1192 | ), |
| 1193 | 'placement' => 'top', |
| 1194 | 'endpoint' => 0, |
| 1195 | ), |
| 1196 | array( |
| 1197 | 'key' => 'field_name', |
| 1198 | 'label' => __('Name', 'acfe'), |
| 1199 | 'name' => 'name', |
| 1200 | 'type' => 'acfe_slug', |
| 1201 | 'instructions' => '', |
| 1202 | 'required' => 1, |
| 1203 | 'conditional_logic' => 0, |
| 1204 | 'wrapper' => array( |
| 1205 | 'width' => '', |
| 1206 | 'class' => '', |
| 1207 | 'id' => '', |
| 1208 | ), |
| 1209 | 'default_value' => '', |
| 1210 | 'placeholder' => '', |
| 1211 | 'prepend' => '', |
| 1212 | 'append' => '', |
| 1213 | 'maxlength' => '', |
| 1214 | ), |
| 1215 | array( |
| 1216 | 'key' => 'field_field_groups', |
| 1217 | 'label' => __('Field Groups', 'acfe'), |
| 1218 | 'name' => 'field_groups', |
| 1219 | 'type' => 'select', |
| 1220 | 'instructions' => '', |
| 1221 | 'required' => 0, |
| 1222 | 'conditional_logic' => 0, |
| 1223 | 'wrapper' => array( |
| 1224 | 'width' => '', |
| 1225 | 'class' => '', |
| 1226 | 'id' => '', |
| 1227 | ), |
| 1228 | 'choices' => array(), |
| 1229 | 'default_value' => array(), |
| 1230 | 'allow_null' => 1, |
| 1231 | 'multiple' => 1, |
| 1232 | 'ui' => 1, |
| 1233 | 'ajax' => 1, |
| 1234 | 'return_format' => 'value', |
| 1235 | 'allow_custom' => 1, |
| 1236 | 'placeholder' => '', |
| 1237 | 'ajax_action' => 'acfe/form/map_field_groups_ajax' |
| 1238 | ), |
| 1239 | array( |
| 1240 | 'key' => 'field_actions', |
| 1241 | 'label' => __('Actions', 'acfe'), |
| 1242 | 'name' => 'actions', |
| 1243 | 'type' => 'flexible_content', |
| 1244 | 'instructions' => __('Add actions on form submission', 'acfe'), |
| 1245 | 'required' => 0, |
| 1246 | 'conditional_logic' => 0, |
| 1247 | 'wrapper' => array( |
| 1248 | 'width' => '', |
| 1249 | 'class' => '', |
| 1250 | 'id' => '', |
| 1251 | ), |
| 1252 | 'acfe_flexible_stylised_button' => 1, |
| 1253 | 'layouts' => $layouts, |
| 1254 | 'button_label' => __('Add action', 'acfe'), |
| 1255 | 'min' => '', |
| 1256 | 'max' => '', |
| 1257 | ), |
| 1258 | |
| 1259 | /** |
| 1260 | * settings |
| 1261 | */ |
| 1262 | array( |
| 1263 | 'key' => 'field_tab_settings', |
| 1264 | 'label' => __('Settings', 'acfe'), |
| 1265 | 'name' => '', |
| 1266 | 'type' => 'tab', |
| 1267 | 'instructions' => '', |
| 1268 | 'required' => 0, |
| 1269 | 'conditional_logic' => 0, |
| 1270 | 'wrapper' => array( |
| 1271 | 'width' => '', |
| 1272 | 'class' => '', |
| 1273 | 'id' => '', |
| 1274 | ), |
| 1275 | 'placement' => 'top', |
| 1276 | 'endpoint' => 0, |
| 1277 | ), |
| 1278 | array( |
| 1279 | 'key' => 'field_location', |
| 1280 | 'label' => __('Field groups locations rules', 'acfe'), |
| 1281 | 'name' => 'location', |
| 1282 | 'type' => 'true_false', |
| 1283 | 'instructions' => __('Apply field groups locations rules on front-end display', 'acfe'), |
| 1284 | 'required' => 0, |
| 1285 | 'wrapper' => array( |
| 1286 | 'width' => '', |
| 1287 | 'class' => '', |
| 1288 | 'id' => '', |
| 1289 | ), |
| 1290 | 'message' => '', |
| 1291 | 'default_value' => 0, |
| 1292 | 'ui' => 1, |
| 1293 | 'ui_on_text' => '', |
| 1294 | 'ui_off_text' => '', |
| 1295 | 'group_with' => 'settings', |
| 1296 | ), |
| 1297 | array( |
| 1298 | 'key' => 'field_honeypot', |
| 1299 | 'label' => __('Honeypot', 'acfe'), |
| 1300 | 'name' => 'honeypot', |
| 1301 | 'type' => 'true_false', |
| 1302 | 'instructions' => __('Whether to include a hidden input field to capture non human form submission. Defaults to true.', 'acfe'), |
| 1303 | 'required' => 0, |
| 1304 | 'conditional_logic' => 0, |
| 1305 | 'wrapper' => array( |
| 1306 | 'width' => '', |
| 1307 | 'class' => '', |
| 1308 | 'id' => '', |
| 1309 | ), |
| 1310 | 'message' => '', |
| 1311 | 'default_value' => 1, |
| 1312 | 'ui' => 1, |
| 1313 | 'ui_on_text' => '', |
| 1314 | 'ui_off_text' => '', |
| 1315 | 'group_with' => 'settings', |
| 1316 | ), |
| 1317 | array( |
| 1318 | 'key' => 'field_kses', |
| 1319 | 'label' => __('Kses', 'acfe'), |
| 1320 | 'name' => 'kses', |
| 1321 | 'type' => 'true_false', |
| 1322 | 'instructions' => __('Whether or not to sanitize all $_POST data with the wp_kses_post() function. Defaults to true.', 'acfe'), |
| 1323 | 'required' => 0, |
| 1324 | 'conditional_logic' => 0, |
| 1325 | 'wrapper' => array( |
| 1326 | 'width' => '', |
| 1327 | 'class' => '', |
| 1328 | 'id' => '', |
| 1329 | ), |
| 1330 | 'message' => '', |
| 1331 | 'default_value' => 1, |
| 1332 | 'ui' => 1, |
| 1333 | 'ui_on_text' => '', |
| 1334 | 'ui_off_text' => '', |
| 1335 | 'group_with' => 'settings', |
| 1336 | ), |
| 1337 | array( |
| 1338 | 'key' => 'field_uploader', |
| 1339 | 'label' => __('Uploader', 'acfe'), |
| 1340 | 'name' => 'uploader', |
| 1341 | 'type' => 'radio', |
| 1342 | 'instructions' => __('Whether to use the WP uploader or a basic input for image and file fields. Defaults to \'wp\'.', 'acfe'), |
| 1343 | 'required' => 0, |
| 1344 | 'conditional_logic' => 0, |
| 1345 | 'wrapper' => array( |
| 1346 | 'width' => '', |
| 1347 | 'class' => '', |
| 1348 | 'id' => '', |
| 1349 | ), |
| 1350 | 'choices' => array( |
| 1351 | 'default' => __('Default', 'acfe'), |
| 1352 | 'wp' => __('WordPress', 'acfe'), |
| 1353 | 'basic' => __('Browser', 'acfe'), |
| 1354 | ), |
| 1355 | 'allow_null' => 0, |
| 1356 | 'other_choice' => 0, |
| 1357 | 'default_value' => 'default', |
| 1358 | 'layout' => 'vertical', |
| 1359 | 'return_format' => 'value', |
| 1360 | 'save_other_choice' => 0, |
| 1361 | 'group_with' => 'settings', |
| 1362 | ), |
| 1363 | |
| 1364 | /** |
| 1365 | * attributes |
| 1366 | */ |
| 1367 | array( |
| 1368 | 'key' => 'field_tab_attributes', |
| 1369 | 'label' => __('Attributes', 'acfe'), |
| 1370 | 'name' => '', |
| 1371 | 'type' => 'tab', |
| 1372 | 'instructions' => '', |
| 1373 | 'required' => 0, |
| 1374 | 'conditional_logic' => 0, |
| 1375 | 'wrapper' => array( |
| 1376 | 'width' => '', |
| 1377 | 'class' => '', |
| 1378 | 'id' => '', |
| 1379 | ), |
| 1380 | 'placement' => 'top', |
| 1381 | 'endpoint' => 0, |
| 1382 | ), |
| 1383 | array( |
| 1384 | 'key' => 'field_form', |
| 1385 | 'label' => __('Form attributes', 'acfe'), |
| 1386 | 'name' => 'form', |
| 1387 | 'type' => 'group', |
| 1388 | 'instructions' => __('Attributes settings related to the form.', 'acfe'), |
| 1389 | 'required' => 0, |
| 1390 | 'wrapper' => array( |
| 1391 | 'width' => '', |
| 1392 | 'class' => '', |
| 1393 | 'id' => '', |
| 1394 | ), |
| 1395 | 'layout' => 'block', |
| 1396 | 'acfe_seamless_style' => true, |
| 1397 | 'acfe_group_modal' => 0, |
| 1398 | 'conditional_logic' => array(), |
| 1399 | 'group_with' => 'attributes', |
| 1400 | 'sub_fields' => array( |
| 1401 | array( |
| 1402 | 'key' => 'field_form_element', |
| 1403 | 'label' => '', |
| 1404 | 'name' => 'element', |
| 1405 | 'type' => 'select', |
| 1406 | 'instructions' => '', |
| 1407 | 'required' => 0, |
| 1408 | 'conditional_logic' => array(), |
| 1409 | 'wrapper' => array( |
| 1410 | 'width' => '33.33', |
| 1411 | 'class' => '', |
| 1412 | 'id' => '', |
| 1413 | ), |
| 1414 | 'default_value' => 'form', |
| 1415 | 'placeholder' => '', |
| 1416 | 'prepend' => 'element', |
| 1417 | 'choices' => array( |
| 1418 | 'form' => '<form>', |
| 1419 | 'div' => '<div>', |
| 1420 | ) |
| 1421 | ), |
| 1422 | array( |
| 1423 | 'key' => 'field_form_class', |
| 1424 | 'label' => '', |
| 1425 | 'name' => 'class', |
| 1426 | 'type' => 'text', |
| 1427 | 'instructions' => '', |
| 1428 | 'required' => 0, |
| 1429 | 'conditional_logic' => array(), |
| 1430 | 'wrapper' => array( |
| 1431 | 'width' => '33.33', |
| 1432 | 'class' => '', |
| 1433 | 'id' => '', |
| 1434 | ), |
| 1435 | 'default_value' => '', |
| 1436 | 'placeholder' => '', |
| 1437 | 'prepend' => 'form class', |
| 1438 | 'append' => '', |
| 1439 | 'maxlength' => '', |
| 1440 | ), |
| 1441 | array( |
| 1442 | 'key' => 'field_form_id', |
| 1443 | 'label' => '', |
| 1444 | 'name' => 'id', |
| 1445 | 'type' => 'text', |
| 1446 | 'instructions' => '', |
| 1447 | 'required' => 0, |
| 1448 | 'conditional_logic' => array(), |
| 1449 | 'wrapper' => array( |
| 1450 | 'width' => '33.33', |
| 1451 | 'class' => '', |
| 1452 | 'id' => '', |
| 1453 | ), |
| 1454 | 'default_value' => '', |
| 1455 | 'placeholder' => '', |
| 1456 | 'prepend' => 'form id', |
| 1457 | 'append' => '', |
| 1458 | 'maxlength' => '', |
| 1459 | ), |
| 1460 | |
| 1461 | ), |
| 1462 | ), |
| 1463 | array( |
| 1464 | 'key' => 'field_fields', |
| 1465 | 'label' => __('Fields attributes', 'acfe'), |
| 1466 | 'name' => 'fields', |
| 1467 | 'type' => 'group', |
| 1468 | 'instructions' => __('Attributes settings related to the fields.', 'acfe'), |
| 1469 | 'required' => 0, |
| 1470 | 'wrapper' => array( |
| 1471 | 'width' => '', |
| 1472 | 'class' => '', |
| 1473 | 'id' => '', |
| 1474 | ), |
| 1475 | 'layout' => 'block', |
| 1476 | 'acfe_seamless_style' => true, |
| 1477 | 'acfe_group_modal' => 0, |
| 1478 | 'conditional_logic' => array(), |
| 1479 | 'group_with' => 'attributes', |
| 1480 | 'sub_fields' => array( |
| 1481 | array( |
| 1482 | 'key' => 'field_fields_element', |
| 1483 | 'label' => '', |
| 1484 | 'name' => 'element', |
| 1485 | 'type' => 'select', |
| 1486 | 'required' => 0, |
| 1487 | 'conditional_logic' => 0, |
| 1488 | 'wrapper' => array( |
| 1489 | 'width' => '33.33', |
| 1490 | 'class' => '', |
| 1491 | 'id' => '', |
| 1492 | ), |
| 1493 | 'prepend' => 'element', |
| 1494 | 'choices' => array( |
| 1495 | 'div' => '<div>', |
| 1496 | 'tr' => '<tr>', |
| 1497 | 'td' => '<td>', |
| 1498 | 'ul' => '<ul>', |
| 1499 | 'ol' => '<ol>', |
| 1500 | 'dl' => '<dl>', |
| 1501 | ), |
| 1502 | 'allow_null' => 0, |
| 1503 | 'other_choice' => 0, |
| 1504 | 'default_value' => 'div', |
| 1505 | 'return_format' => 'value', |
| 1506 | 'save_other_choice' => 0, |
| 1507 | ), |
| 1508 | array( |
| 1509 | 'key' => 'field_fields_wrapper_class', |
| 1510 | 'label' => '', |
| 1511 | 'name' => 'wrapper_class', |
| 1512 | 'type' => 'text', |
| 1513 | 'instructions' => '', |
| 1514 | 'required' => 0, |
| 1515 | 'conditional_logic' => array(), |
| 1516 | 'wrapper' => array( |
| 1517 | 'width' => '33.33', |
| 1518 | 'class' => '', |
| 1519 | 'id' => '', |
| 1520 | ), |
| 1521 | 'default_value' => '', |
| 1522 | 'placeholder' => '', |
| 1523 | 'prepend' => 'wrap class', |
| 1524 | 'append' => '', |
| 1525 | 'maxlength' => '', |
| 1526 | ), |
| 1527 | array( |
| 1528 | 'key' => 'field_fields_class', |
| 1529 | 'label' => '', |
| 1530 | 'name' => 'class', |
| 1531 | 'type' => 'text', |
| 1532 | 'instructions' => '', |
| 1533 | 'required' => 0, |
| 1534 | 'conditional_logic' => array(), |
| 1535 | 'wrapper' => array( |
| 1536 | 'width' => '33.33', |
| 1537 | 'class' => '', |
| 1538 | 'id' => '', |
| 1539 | ), |
| 1540 | 'default_value' => '', |
| 1541 | 'placeholder' => '', |
| 1542 | 'prepend' => 'field class', |
| 1543 | 'append' => '', |
| 1544 | 'maxlength' => '', |
| 1545 | ), |
| 1546 | array( |
| 1547 | 'key' => 'field_fields_label', |
| 1548 | 'label' => '', |
| 1549 | 'name' => 'label', |
| 1550 | 'type' => 'select', |
| 1551 | 'instructions' => '', |
| 1552 | 'required' => 0, |
| 1553 | 'conditional_logic' => 0, |
| 1554 | 'wrapper' => array( |
| 1555 | 'width' => '33.33', |
| 1556 | 'class' => '', |
| 1557 | 'id' => '', |
| 1558 | ), |
| 1559 | 'choices' => array( |
| 1560 | 'top' => __('Top', 'acfe'), |
| 1561 | 'left' => __('Left', 'acfe'), |
| 1562 | 'hidden' => __('Hidden', 'acfe'), |
| 1563 | ), |
| 1564 | 'allow_null' => 0, |
| 1565 | 'other_choice' => 0, |
| 1566 | 'default_value' => 'top', |
| 1567 | 'return_format' => 'value', |
| 1568 | 'prepend' => 'label', |
| 1569 | ), |
| 1570 | array( |
| 1571 | 'key' => 'field_fields_instruction', |
| 1572 | 'label' => '', |
| 1573 | 'name' => 'instruction', |
| 1574 | 'type' => 'select', |
| 1575 | 'instructions' => '', |
| 1576 | 'required' => 0, |
| 1577 | 'conditional_logic' => 0, |
| 1578 | 'wrapper' => array( |
| 1579 | 'width' => '33.33', |
| 1580 | 'class' => '', |
| 1581 | 'id' => '', |
| 1582 | ), |
| 1583 | 'choices' => array( |
| 1584 | 'label' => __('Label', 'acfe'), |
| 1585 | 'field' => __('Field', 'acfe'), |
| 1586 | 'above_field' => __('Above field', 'acfe'), |
| 1587 | 'tooltip' => __('Tooltip', 'acfe'), |
| 1588 | ), |
| 1589 | 'allow_null' => 0, |
| 1590 | 'other_choice' => 0, |
| 1591 | 'default_value' => 'label', |
| 1592 | 'return_format' => 'value', |
| 1593 | 'prepend' => 'instruction', |
| 1594 | ), |
| 1595 | ), |
| 1596 | ), |
| 1597 | array( |
| 1598 | 'key' => 'field_submit', |
| 1599 | 'label' => __('Submit button', 'acfe'), |
| 1600 | 'name' => 'submit', |
| 1601 | 'type' => 'true_false', |
| 1602 | 'instructions' => __('Whether or not to create a form submit button. Defaults to true', 'acfe'), |
| 1603 | 'required' => 0, |
| 1604 | 'conditional_logic' => 0, |
| 1605 | 'wrapper' => array( |
| 1606 | 'width' => '', |
| 1607 | 'class' => '', |
| 1608 | 'id' => '', |
| 1609 | ), |
| 1610 | 'message' => '', |
| 1611 | 'default_value' => 1, |
| 1612 | 'ui' => 1, |
| 1613 | 'ui_on_text' => '', |
| 1614 | 'ui_off_text' => '', |
| 1615 | 'group_with' => 'attributes', |
| 1616 | ), |
| 1617 | array( |
| 1618 | 'key' => 'field_submit_value', |
| 1619 | 'label' => __('Submit value', 'acfe'), |
| 1620 | 'name' => 'submit_value', |
| 1621 | 'type' => 'text', |
| 1622 | 'instructions' => __('The text displayed on the submit button', 'acfe'), |
| 1623 | 'required' => 0, |
| 1624 | 'conditional_logic' => array( |
| 1625 | array( |
| 1626 | array( |
| 1627 | 'field' => 'field_submit', |
| 1628 | 'operator' => '==', |
| 1629 | 'value' => '1', |
| 1630 | ), |
| 1631 | ), |
| 1632 | ), |
| 1633 | 'wrapper' => array( |
| 1634 | 'width' => '', |
| 1635 | 'class' => '', |
| 1636 | 'id' => '', |
| 1637 | ), |
| 1638 | 'default_value' => 'Submit', |
| 1639 | 'placeholder' => '', |
| 1640 | 'prepend' => '', |
| 1641 | 'append' => '', |
| 1642 | 'maxlength' => '', |
| 1643 | 'group_with' => 'attributes', |
| 1644 | ), |
| 1645 | array( |
| 1646 | 'key' => 'field_submit_button', |
| 1647 | 'label' => __('Submit button', 'acfe'), |
| 1648 | 'name' => 'submit_button', |
| 1649 | 'type' => 'acfe_code_editor', |
| 1650 | 'instructions' => __('HTML used to render the submit button.', 'acfe'), |
| 1651 | 'required' => 0, |
| 1652 | 'conditional_logic' => array( |
| 1653 | array( |
| 1654 | array( |
| 1655 | 'field' => 'field_submit', |
| 1656 | 'operator' => '==', |
| 1657 | 'value' => '1', |
| 1658 | ), |
| 1659 | ), |
| 1660 | ), |
| 1661 | 'wrapper' => array( |
| 1662 | 'width' => '', |
| 1663 | 'class' => '', |
| 1664 | 'id' => '', |
| 1665 | ), |
| 1666 | 'default_value' => '<input type="submit" class="acf-button button button-primary button-large" value="%s" />', |
| 1667 | 'placeholder' => '', |
| 1668 | 'maxlength' => '', |
| 1669 | 'rows' => 2, |
| 1670 | 'group_with' => 'attributes', |
| 1671 | ), |
| 1672 | array( |
| 1673 | 'key' => 'field_submit_spinner', |
| 1674 | 'label' => __('Submit spinner', 'acfe'), |
| 1675 | 'name' => 'submit_spinner', |
| 1676 | 'type' => 'acfe_code_editor', |
| 1677 | 'instructions' => __('HTML used to render the submit button loading spinner.', 'acfe'), |
| 1678 | 'required' => 0, |
| 1679 | 'conditional_logic' => array( |
| 1680 | array( |
| 1681 | array( |
| 1682 | 'field' => 'field_submit', |
| 1683 | 'operator' => '==', |
| 1684 | 'value' => '1', |
| 1685 | ), |
| 1686 | ), |
| 1687 | ), |
| 1688 | 'wrapper' => array( |
| 1689 | 'width' => '', |
| 1690 | 'class' => '', |
| 1691 | 'id' => '', |
| 1692 | ), |
| 1693 | 'default_value' => '<span class="acf-spinner"></span>', |
| 1694 | 'placeholder' => '', |
| 1695 | 'maxlength' => '', |
| 1696 | 'rows' => 2, |
| 1697 | 'group_with' => 'attributes', |
| 1698 | ), |
| 1699 | |
| 1700 | /** |
| 1701 | * render |
| 1702 | */ |
| 1703 | array( |
| 1704 | 'key' => 'field_tab_render', |
| 1705 | 'label' => __('Render', 'acfe'), |
| 1706 | 'name' => '', |
| 1707 | 'type' => 'tab', |
| 1708 | 'instructions' => '', |
| 1709 | 'required' => 0, |
| 1710 | 'conditional_logic' => 0, |
| 1711 | 'wrapper' => array( |
| 1712 | 'width' => '', |
| 1713 | 'class' => '', |
| 1714 | 'id' => '', |
| 1715 | ), |
| 1716 | 'placement' => 'top', |
| 1717 | 'endpoint' => 0, |
| 1718 | ), |
| 1719 | array( |
| 1720 | 'key' => 'field_render', |
| 1721 | 'label' => __('Form render', 'acfe'), |
| 1722 | 'name' => 'render', |
| 1723 | 'type' => 'acfe_code_editor', |
| 1724 | 'instructions' => __('Render customized form HTML. Leave empty to render form normally.', 'acfe') . '<br /><br />' . |
| 1725 | __('Render field group:', 'acfe') . '<br /><code>{render:group_abc123}</code><br/><br/>' . |
| 1726 | __('Render field:', 'acfe') . '<br /><code>{render:field_abc123}</code><br/><code>{render:my_field}</code><br/><br/>' . |
| 1727 | __('Render all fields:' ,'acfe') . '<br /><code>{render:fields}</code><br/><br/>' . |
| 1728 | __('Render submit button:', 'acfe') . '<br /><code>{render:submit}</code>', |
| 1729 | 'required' => 0, |
| 1730 | 'wrapper' => array( |
| 1731 | 'width' => '', |
| 1732 | 'class' => '', |
| 1733 | 'id' => '', |
| 1734 | ), |
| 1735 | 'default_value' => '', |
| 1736 | 'placeholder' => '', |
| 1737 | 'maxlength' => '', |
| 1738 | 'rows' => 18, |
| 1739 | 'conditional_logic' => array(), |
| 1740 | ), |
| 1741 | |
| 1742 | /** |
| 1743 | * validation |
| 1744 | */ |
| 1745 | array( |
| 1746 | 'key' => 'field_tab_validation', |
| 1747 | 'label' => __('Validation', 'acfe'), |
| 1748 | 'name' => '', |
| 1749 | 'type' => 'tab', |
| 1750 | 'instructions' => '', |
| 1751 | 'required' => 0, |
| 1752 | 'conditional_logic' => 0, |
| 1753 | 'wrapper' => array( |
| 1754 | 'width' => '', |
| 1755 | 'class' => '', |
| 1756 | 'id' => '', |
| 1757 | ), |
| 1758 | 'placement' => 'top', |
| 1759 | 'endpoint' => 0, |
| 1760 | 'group_with' => 'validation', |
| 1761 | ), |
| 1762 | array( |
| 1763 | 'key' => 'field_hide_error', |
| 1764 | 'label' => __('Hide general error', 'acfe'), |
| 1765 | 'name' => 'hide_error', |
| 1766 | 'type' => 'true_false', |
| 1767 | 'instructions' => __('Hide the general error message: "Validation failed. 1 field requires attention"', 'acfe'), |
| 1768 | 'required' => 0, |
| 1769 | 'conditional_logic' => 0, |
| 1770 | 'wrapper' => array( |
| 1771 | 'width' => '', |
| 1772 | 'class' => '', |
| 1773 | 'id' => '', |
| 1774 | ), |
| 1775 | 'message' => '', |
| 1776 | 'default_value' => 0, |
| 1777 | 'ui' => 1, |
| 1778 | 'ui_on_text' => '', |
| 1779 | 'ui_off_text' => '', |
| 1780 | 'group_with' => 'validation', |
| 1781 | ), |
| 1782 | array( |
| 1783 | 'key' => 'field_hide_revalidation', |
| 1784 | 'label' => __('Hide successful re-validation', 'acfe'), |
| 1785 | 'name' => 'hide_revalidation', |
| 1786 | 'type' => 'true_false', |
| 1787 | 'instructions' => __('Hide "Validation successful" notice when an error has been previously thrown', 'acfe'), |
| 1788 | 'required' => 0, |
| 1789 | 'conditional_logic' => array( |
| 1790 | array( |
| 1791 | array( |
| 1792 | 'field' => 'field_hide_error', |
| 1793 | 'operator' => '!=', |
| 1794 | 'value' => '1', |
| 1795 | ), |
| 1796 | ) |
| 1797 | ), |
| 1798 | 'wrapper' => array( |
| 1799 | 'width' => '', |
| 1800 | 'class' => '', |
| 1801 | 'id' => '', |
| 1802 | ), |
| 1803 | 'message' => '', |
| 1804 | 'default_value' => 0, |
| 1805 | 'ui' => 1, |
| 1806 | 'ui_on_text' => '', |
| 1807 | 'ui_off_text' => '', |
| 1808 | 'group_with' => 'validation', |
| 1809 | ), |
| 1810 | array( |
| 1811 | 'key' => 'field_hide_unload', |
| 1812 | 'label' => __('Hide confirmation on exit', 'acfe'), |
| 1813 | 'name' => 'hide_unload', |
| 1814 | 'type' => 'true_false', |
| 1815 | 'instructions' => __('Do not prompt user on page refresh', 'acfe'), |
| 1816 | 'required' => 0, |
| 1817 | 'conditional_logic' => 0, |
| 1818 | 'wrapper' => array( |
| 1819 | 'width' => '', |
| 1820 | 'class' => '', |
| 1821 | 'id' => '', |
| 1822 | ), |
| 1823 | 'message' => '', |
| 1824 | 'default_value' => 0, |
| 1825 | 'ui' => 1, |
| 1826 | 'ui_on_text' => '', |
| 1827 | 'ui_off_text' => '', |
| 1828 | 'group_with' => 'validation', |
| 1829 | ), |
| 1830 | array( |
| 1831 | 'key' => 'field_messages', |
| 1832 | 'label' => __('General error messages', 'acfe'), |
| 1833 | 'name' => 'messages', |
| 1834 | 'type' => 'group', |
| 1835 | 'instructions' => __('Customize general error messages.', 'acfe'), |
| 1836 | 'required' => 0, |
| 1837 | 'wrapper' => array( |
| 1838 | 'width' => '', |
| 1839 | 'class' => '', |
| 1840 | 'id' => '', |
| 1841 | ), |
| 1842 | 'layout' => 'block', |
| 1843 | 'acfe_seamless_style' => true, |
| 1844 | 'acfe_group_modal' => 0, |
| 1845 | 'conditional_logic' => array( |
| 1846 | array( |
| 1847 | array( |
| 1848 | 'field' => 'field_hide_error', |
| 1849 | 'operator' => '!=', |
| 1850 | 'value' => '1', |
| 1851 | ), |
| 1852 | ) |
| 1853 | ), |
| 1854 | 'group_with' => 'validation', |
| 1855 | 'sub_fields' => array( |
| 1856 | array( |
| 1857 | 'key' => 'field_messages_failure', |
| 1858 | 'label' => '', |
| 1859 | 'name' => 'failure', |
| 1860 | 'type' => 'text', |
| 1861 | 'instructions' => '', |
| 1862 | 'required' => 0, |
| 1863 | 'conditional_logic' => array(), |
| 1864 | 'wrapper' => array( |
| 1865 | 'width' => '50', |
| 1866 | 'class' => '', |
| 1867 | 'id' => '', |
| 1868 | ), |
| 1869 | 'default_value' => 'Validation failed', |
| 1870 | 'placeholder' => '', |
| 1871 | 'prepend' => 'failure', |
| 1872 | 'append' => '', |
| 1873 | 'maxlength' => '', |
| 1874 | ), |
| 1875 | array( |
| 1876 | 'key' => 'field_messages_error', |
| 1877 | 'label' => '', |
| 1878 | 'name' => 'error', |
| 1879 | 'type' => 'text', |
| 1880 | 'instructions' => '', |
| 1881 | 'required' => 0, |
| 1882 | 'conditional_logic' => array(), |
| 1883 | 'wrapper' => array( |
| 1884 | 'width' => '50', |
| 1885 | 'class' => '', |
| 1886 | 'id' => '', |
| 1887 | ), |
| 1888 | 'default_value' => '1 field requires attention', |
| 1889 | 'placeholder' => '', |
| 1890 | 'prepend' => 'error', |
| 1891 | 'append' => '', |
| 1892 | 'maxlength' => '', |
| 1893 | ), |
| 1894 | array( |
| 1895 | 'key' => 'field_messages_success', |
| 1896 | 'label' => '', |
| 1897 | 'name' => 'success', |
| 1898 | 'type' => 'text', |
| 1899 | 'instructions' => '', |
| 1900 | 'required' => 0, |
| 1901 | 'conditional_logic' => array(), |
| 1902 | 'wrapper' => array( |
| 1903 | 'width' => '50', |
| 1904 | 'class' => '', |
| 1905 | 'id' => '', |
| 1906 | ), |
| 1907 | 'default_value' => 'Validation successful', |
| 1908 | 'placeholder' => '', |
| 1909 | 'prepend' => 'success', |
| 1910 | 'append' => '', |
| 1911 | 'maxlength' => '', |
| 1912 | ), |
| 1913 | array( |
| 1914 | 'key' => 'field_messages_errors', |
| 1915 | 'label' => '', |
| 1916 | 'name' => 'errors', |
| 1917 | 'type' => 'text', |
| 1918 | 'instructions' => '', |
| 1919 | 'required' => 0, |
| 1920 | 'conditional_logic' => array(), |
| 1921 | 'wrapper' => array( |
| 1922 | 'width' => '50', |
| 1923 | 'class' => '', |
| 1924 | 'id' => '', |
| 1925 | ), |
| 1926 | 'default_value' => '%d fields require attention', |
| 1927 | 'placeholder' => '', |
| 1928 | 'prepend' => 'errors', |
| 1929 | 'append' => '', |
| 1930 | 'maxlength' => '', |
| 1931 | ), |
| 1932 | |
| 1933 | ), |
| 1934 | ), |
| 1935 | array( |
| 1936 | 'key' => 'field_errors_position', |
| 1937 | 'label' => __('Fields errors position', 'acfe'), |
| 1938 | 'name' => 'errors_position', |
| 1939 | 'type' => 'radio', |
| 1940 | 'instructions' => __('Choose where to display field errors', 'acfe'), |
| 1941 | 'required' => 0, |
| 1942 | 'conditional_logic' => 0, |
| 1943 | 'wrapper' => array( |
| 1944 | 'width' => '', |
| 1945 | 'class' => '', |
| 1946 | 'id' => '', |
| 1947 | ), |
| 1948 | 'choices' => array( |
| 1949 | 'above' => __('Above fields', 'acfe'), |
| 1950 | 'below' => __('Below fields', 'acfe'), |
| 1951 | 'group' => __('Group errors', 'acfe'), |
| 1952 | 'hide' => __('Hide errors', 'acfe'), |
| 1953 | ), |
| 1954 | 'allow_null' => 0, |
| 1955 | 'other_choice' => 0, |
| 1956 | 'default_value' => 'above', |
| 1957 | 'layout' => 'vertical', |
| 1958 | 'return_format' => 'value', |
| 1959 | 'save_other_choice' => 0, |
| 1960 | 'group_with' => 'validation', |
| 1961 | ), |
| 1962 | array( |
| 1963 | 'key' => 'field_errors_class', |
| 1964 | 'label' => __('Fields errors class', 'acfe'), |
| 1965 | 'name' => 'errors_class', |
| 1966 | 'type' => 'text', |
| 1967 | 'instructions' => __('Add class to the error message', 'acfe'), |
| 1968 | 'required' => 0, |
| 1969 | 'conditional_logic' => array( |
| 1970 | array( |
| 1971 | array( |
| 1972 | 'field' => 'field_errors_position', |
| 1973 | 'operator' => '!=', |
| 1974 | 'value' => 'hide', |
| 1975 | ), |
| 1976 | ) |
| 1977 | ), |
| 1978 | 'wrapper' => array( |
| 1979 | 'width' => '', |
| 1980 | 'class' => '', |
| 1981 | 'id' => '', |
| 1982 | ), |
| 1983 | 'default_value' => '', |
| 1984 | 'placeholder' => '', |
| 1985 | 'prepend' => '', |
| 1986 | 'append' => '', |
| 1987 | 'maxlength' => '', |
| 1988 | 'group_with' => 'validation', |
| 1989 | ), |
| 1990 | |
| 1991 | /** |
| 1992 | * success |
| 1993 | */ |
| 1994 | array( |
| 1995 | 'key' => 'field_tab_success', |
| 1996 | 'label' => __('Success', 'acfe'), |
| 1997 | 'name' => '', |
| 1998 | 'type' => 'tab', |
| 1999 | 'instructions' => '', |
| 2000 | 'required' => 0, |
| 2001 | 'conditional_logic' => 0, |
| 2002 | 'wrapper' => array( |
| 2003 | 'width' => '', |
| 2004 | 'class' => '', |
| 2005 | 'id' => '', |
| 2006 | ), |
| 2007 | 'placement' => 'top', |
| 2008 | 'endpoint' => 0, |
| 2009 | ), |
| 2010 | array( |
| 2011 | 'key' => 'field_success_return', |
| 2012 | 'label' => __('Redirection', 'acfe'), |
| 2013 | 'name' => 'success_return', |
| 2014 | 'type' => 'text', |
| 2015 | 'instructions' => __('The URL to be redirected to after the form is submitted.', 'acfe') . '<br/><br/><u>' . __('This setting is deprecated, use the new "Redirect Action" instead.', 'acfe') . '</u>', |
| 2016 | 'required' => 0, |
| 2017 | 'conditional_logic' => 0, |
| 2018 | 'wrapper' => array( |
| 2019 | 'width' => '', |
| 2020 | 'class' => '', |
| 2021 | 'id' => '', |
| 2022 | 'data-enable-switch' => true |
| 2023 | ), |
| 2024 | 'default_value' => '', |
| 2025 | 'placeholder' => '', |
| 2026 | 'prepend' => '', |
| 2027 | 'append' => '', |
| 2028 | 'maxlength' => '', |
| 2029 | 'group_with' => 'success', |
| 2030 | ), |
| 2031 | array( |
| 2032 | 'key' => 'field_success_hide_form', |
| 2033 | 'label' => __('Hide form', 'acfe'), |
| 2034 | 'name' => 'success_hide_form', |
| 2035 | 'type' => 'true_false', |
| 2036 | 'instructions' => __('Hide form on successful submission', 'acfe'), |
| 2037 | 'conditional_logic' => array( |
| 2038 | array( |
| 2039 | array( |
| 2040 | 'field' => 'field_success_return', |
| 2041 | 'operator' => '==', |
| 2042 | 'value' => '', |
| 2043 | ), |
| 2044 | ), |
| 2045 | ), |
| 2046 | 'wrapper' => array( |
| 2047 | 'width' => '', |
| 2048 | 'class' => '', |
| 2049 | 'id' => '', |
| 2050 | ), |
| 2051 | 'message' => '', |
| 2052 | 'default_value' => 0, |
| 2053 | 'ui' => 1, |
| 2054 | 'ui_on_text' => '', |
| 2055 | 'ui_off_text' => '', |
| 2056 | 'group_with' => 'success', |
| 2057 | ), |
| 2058 | array( |
| 2059 | 'key' => 'field_success_scroll', |
| 2060 | 'label' => __('Scroll to message', 'acfe'), |
| 2061 | 'name' => 'success_scroll', |
| 2062 | 'type' => 'true_false', |
| 2063 | 'instructions' => __('Scroll to message on success', 'acfe'), |
| 2064 | 'conditional_logic' => array( |
| 2065 | array( |
| 2066 | array( |
| 2067 | 'field' => 'field_success_return', |
| 2068 | 'operator' => '==', |
| 2069 | 'value' => '', |
| 2070 | ), |
| 2071 | ), |
| 2072 | ), |
| 2073 | 'wrapper' => array( |
| 2074 | 'width' => '', |
| 2075 | 'class' => '', |
| 2076 | 'id' => '', |
| 2077 | ), |
| 2078 | 'message' => '', |
| 2079 | 'default_value' => 0, |
| 2080 | 'ui' => 1, |
| 2081 | 'ui_on_text' => '', |
| 2082 | 'ui_off_text' => '', |
| 2083 | 'group_with' => 'success', |
| 2084 | ), |
| 2085 | array( |
| 2086 | 'key' => 'field_success_shortcode', |
| 2087 | 'label' => __('Apply shortcodes', 'acfe'), |
| 2088 | 'name' => 'success_shortcode', |
| 2089 | 'type' => 'true_false', |
| 2090 | 'instructions' => __('Apply shortcodes to success message', 'acfe'), |
| 2091 | 'conditional_logic' => array( |
| 2092 | array( |
| 2093 | array( |
| 2094 | 'field' => 'field_success_return', |
| 2095 | 'operator' => '==', |
| 2096 | 'value' => '', |
| 2097 | ), |
| 2098 | ), |
| 2099 | ), |
| 2100 | 'wrapper' => array( |
| 2101 | 'width' => '', |
| 2102 | 'class' => '', |
| 2103 | 'id' => '', |
| 2104 | ), |
| 2105 | 'message' => '', |
| 2106 | 'default_value' => 0, |
| 2107 | 'ui' => 1, |
| 2108 | 'ui_on_text' => '', |
| 2109 | 'ui_off_text' => '', |
| 2110 | 'group_with' => 'success', |
| 2111 | ), |
| 2112 | array( |
| 2113 | 'key' => 'field_success_message', |
| 2114 | 'label' => __('Success message', 'acfe'), |
| 2115 | 'name' => 'success_message', |
| 2116 | 'type' => 'wysiwyg', |
| 2117 | 'instructions' => __('The message displayed above the form after the submission.', 'acfe'), |
| 2118 | 'required' => 0, |
| 2119 | 'conditional_logic' => array( |
| 2120 | array( |
| 2121 | array( |
| 2122 | 'field' => 'field_success_return', |
| 2123 | 'operator' => '==', |
| 2124 | 'value' => '', |
| 2125 | ), |
| 2126 | ), |
| 2127 | ), |
| 2128 | 'wrapper' => array( |
| 2129 | 'width' => '', |
| 2130 | 'class' => '', |
| 2131 | 'id' => '', |
| 2132 | 'data-instruction-placement' => 'field' |
| 2133 | ), |
| 2134 | 'default_value' => __('Form updated', 'acfe'), |
| 2135 | 'tabs' => 'all', |
| 2136 | 'toolbar' => 'full', |
| 2137 | 'media_upload' => 1, |
| 2138 | 'delay' => 0, |
| 2139 | 'group_with' => 'success', |
| 2140 | ), |
| 2141 | array( |
| 2142 | 'key' => 'field_success_wrapper', |
| 2143 | 'label' => __('Success wrapper HTML', 'acfe'), |
| 2144 | 'name' => 'success_wrapper', |
| 2145 | 'type' => 'acfe_code_editor', |
| 2146 | 'instructions' => __('HTML used to render the updated message.', 'acfe') . '<br />' . |
| 2147 | __('If used, you have to include the following code <code>%s</code> to print the actual "Success message" above.', 'acfe'), |
| 2148 | 'required' => 0, |
| 2149 | 'conditional_logic' => array( |
| 2150 | array( |
| 2151 | array( |
| 2152 | 'field' => 'field_success_return', |
| 2153 | 'operator' => '==', |
| 2154 | 'value' => '', |
| 2155 | ), |
| 2156 | ), |
| 2157 | ), |
| 2158 | 'wrapper' => array( |
| 2159 | 'width' => '', |
| 2160 | 'class' => '', |
| 2161 | 'id' => '', |
| 2162 | 'data-instruction-placement' => 'field' |
| 2163 | ), |
| 2164 | 'default_value' => '<div id="message" class="updated">%s</div>', |
| 2165 | 'placeholder' => '', |
| 2166 | 'maxlength' => '', |
| 2167 | 'rows' => 2, |
| 2168 | 'group_with' => 'success', |
| 2169 | ), |
| 2170 | |
| 2171 | ), |
| 2172 | ); |
| 2173 | |
| 2174 | return $field_groups; |
| 2175 | |
| 2176 | } |
| 2177 | |
| 2178 | } |
| 2179 | |
| 2180 | acf_new_instance('acfe_module_form_field_groups'); |
| 2181 | |
| 2182 | endif; |