field-advanced-link.php
6 years ago
field-button.php
6 years ago
field-clone.php
6 years ago
field-column.php
6 years ago
field-dynamic-message.php
6 years ago
field-file.php
6 years ago
field-flexible-content.php
6 years ago
field-forms.php
6 years ago
field-group.php
6 years ago
field-hidden.php
6 years ago
field-image.php
6 years ago
field-post-statuses.php
6 years ago
field-post-types.php
6 years ago
field-recaptcha.php
6 years ago
field-repeater.php
6 years ago
field-select.php
6 years ago
field-slug.php
6 years ago
field-taxonomies.php
6 years ago
field-taxonomy-terms.php
6 years ago
field-textarea.php
6 years ago
field-user-roles.php
6 years ago
field-group.php
84 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')) |
| 4 | exit; |
| 5 | |
| 6 | add_action('acf/render_field_settings/type=group', 'acfe_field_group_settings'); |
| 7 | function acfe_field_group_settings($field){ |
| 8 | |
| 9 | acf_render_field_setting($field, array( |
| 10 | 'label' => __('Edition modal'), |
| 11 | 'name' => 'acfe_group_modal', |
| 12 | 'key' => 'acfe_group_modal', |
| 13 | 'instructions' => __('Edit fields in a modal'), |
| 14 | 'type' => 'true_false', |
| 15 | 'message' => '', |
| 16 | 'default_value' => false, |
| 17 | 'ui' => true, |
| 18 | 'conditional_logic' => array( |
| 19 | array( |
| 20 | array( |
| 21 | 'field' => 'display', |
| 22 | 'operator' => '==', |
| 23 | 'value' => 'group', |
| 24 | ), |
| 25 | ) |
| 26 | ) |
| 27 | )); |
| 28 | |
| 29 | acf_render_field_setting($field, array( |
| 30 | 'label' => __('Edition modal button'), |
| 31 | 'name' => 'acfe_group_modal_button', |
| 32 | 'key' => 'acfe_group_modal_button', |
| 33 | 'instructions' => __('Text displayed in the edition modal button'), |
| 34 | 'type' => 'text', |
| 35 | 'placeholder' => __('Edit', 'acf'), |
| 36 | 'conditional_logic' => array( |
| 37 | array( |
| 38 | array( |
| 39 | 'field' => 'display', |
| 40 | 'operator' => '==', |
| 41 | 'value' => 'group', |
| 42 | ), |
| 43 | array( |
| 44 | 'field' => 'acfe_group_modal', |
| 45 | 'operator' => '==', |
| 46 | 'value' => '1', |
| 47 | ), |
| 48 | ) |
| 49 | ) |
| 50 | )); |
| 51 | |
| 52 | } |
| 53 | |
| 54 | add_filter('acf/field_wrapper_attributes', 'acfe_field_group_wrapper', 10, 2); |
| 55 | function acfe_field_group_wrapper($wrapper, $field){ |
| 56 | |
| 57 | if($field['type'] !== 'group') |
| 58 | return $wrapper; |
| 59 | |
| 60 | if(isset($field['acfe_group_modal']) && !empty($field['acfe_group_modal'])){ |
| 61 | |
| 62 | $wrapper['data-acfe-group-modal'] = 1; |
| 63 | $wrapper['data-acfe-group-modal-button'] = __('Edit', 'acf'); |
| 64 | |
| 65 | if(isset($field['acfe_group_modal_button']) && !empty($field['acfe_group_modal_button'])){ |
| 66 | |
| 67 | $wrapper['data-acfe-group-modal-button'] = $field['acfe_group_modal_button']; |
| 68 | |
| 69 | } |
| 70 | |
| 71 | } |
| 72 | |
| 73 | return $wrapper; |
| 74 | |
| 75 | } |
| 76 | |
| 77 | add_filter('acf/prepare_field/type=group', 'acfe_field_group_type_class', 99); |
| 78 | function acfe_field_group_type_class($field){ |
| 79 | |
| 80 | $field['wrapper']['class'] .= ' acfe-field-group-layout-' . $field['layout']; |
| 81 | |
| 82 | return $field; |
| 83 | |
| 84 | } |