FlexibleContent
3 months ago
class-acf-field-accordion.php
2 months ago
class-acf-field-button-group.php
2 months ago
class-acf-field-checkbox.php
2 months ago
class-acf-field-clone.php
3 months ago
class-acf-field-color_picker.php
2 months ago
class-acf-field-date_picker.php
2 months ago
class-acf-field-date_time_picker.php
2 months ago
class-acf-field-email.php
2 months ago
class-acf-field-file.php
2 months ago
class-acf-field-flexible-content.php
1 month ago
class-acf-field-gallery.php
1 month ago
class-acf-field-google-map.php
2 months ago
class-acf-field-group.php
2 months ago
class-acf-field-icon_picker.php
8 months ago
class-acf-field-image.php
2 months ago
class-acf-field-link.php
2 months ago
class-acf-field-message.php
1 year ago
class-acf-field-nav-menu.php
1 year ago
class-acf-field-number.php
2 months ago
class-acf-field-oembed.php
1 month ago
class-acf-field-output.php
1 year ago
class-acf-field-page_link.php
1 month ago
class-acf-field-password.php
2 months ago
class-acf-field-post_object.php
1 month ago
class-acf-field-radio.php
2 months ago
class-acf-field-range.php
2 months ago
class-acf-field-relationship.php
1 month ago
class-acf-field-repeater.php
1 month ago
class-acf-field-select.php
1 month ago
class-acf-field-separator.php
1 year ago
class-acf-field-tab.php
1 year ago
class-acf-field-taxonomy.php
1 month ago
class-acf-field-text.php
2 months ago
class-acf-field-textarea.php
2 months ago
class-acf-field-time_picker.php
2 months ago
class-acf-field-true_false.php
2 months ago
class-acf-field-url.php
2 months ago
class-acf-field-user.php
1 month ago
class-acf-field-wysiwyg.php
2 months ago
class-acf-field.php
2 months ago
class-acf-repeater-table.php
1 year ago
index.php
1 year ago
class-acf-field-accordion.php
160 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! class_exists( 'acf_field__accordion' ) ) : |
| 4 | |
| 5 | class acf_field__accordion extends acf_field { |
| 6 | |
| 7 | public $show_in_rest = false; |
| 8 | |
| 9 | /** |
| 10 | * initialize |
| 11 | * |
| 12 | * This function will setup the field type data |
| 13 | * |
| 14 | * @date 30/10/17 |
| 15 | * @since ACF 5.6.3 |
| 16 | * |
| 17 | * @param n/a |
| 18 | * @return n/a |
| 19 | */ |
| 20 | function initialize() { |
| 21 | |
| 22 | // vars |
| 23 | $this->name = 'accordion'; |
| 24 | $this->label = __( 'Accordion', 'secure-custom-fields' ); |
| 25 | $this->category = 'layout'; |
| 26 | $this->description = __( 'Allows you to group and organize custom fields into collapsable panels that are shown while editing content. Useful for keeping large datasets tidy.', 'secure-custom-fields' ); |
| 27 | $this->preview_image = acf_get_url() . '/assets/images/field-type-previews/field-preview-accordion.png'; |
| 28 | $this->doc_url = 'https://developer.wordpress.org/secure-custom-fields/features/fields/accordion/'; |
| 29 | $this->tutorial_url = 'https://developer.wordpress.org/secure-custom-fields/features/fields/accordion/accordion-tutorial/'; |
| 30 | $this->supports = array( |
| 31 | 'required' => false, |
| 32 | 'bindings' => false, |
| 33 | ); |
| 34 | $this->defaults = array( |
| 35 | 'open' => 0, |
| 36 | 'multi_expand' => 0, |
| 37 | 'endpoint' => 0, |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | /** |
| 43 | * render_field |
| 44 | * |
| 45 | * Create the HTML interface for your field |
| 46 | * |
| 47 | * @date 30/10/17 |
| 48 | * @since ACF 5.6.3 |
| 49 | * |
| 50 | * @param array $field |
| 51 | * @return n/a |
| 52 | */ |
| 53 | function render_field( $field ) { |
| 54 | |
| 55 | // vars |
| 56 | $atts = array( |
| 57 | 'class' => 'acf-fields', |
| 58 | 'data-open' => $field['open'], |
| 59 | 'data-multi_expand' => $field['multi_expand'], |
| 60 | 'data-endpoint' => $field['endpoint'], |
| 61 | ); |
| 62 | |
| 63 | ?> |
| 64 | <div <?php echo acf_esc_attrs( $atts ); ?>></div> |
| 65 | <?php |
| 66 | } |
| 67 | |
| 68 | |
| 69 | |
| 70 | /** |
| 71 | * Create extra options for your field. This is rendered when editing a field. |
| 72 | * The value of $field['name'] can be used (like bellow) to save extra data to the $field |
| 73 | * |
| 74 | * @param $field - an array holding all the field's data |
| 75 | * |
| 76 | * @type action |
| 77 | * @since ACF 3.6 |
| 78 | * @date 23/01/13 |
| 79 | */ |
| 80 | function render_field_settings( $field ) { |
| 81 | acf_render_field_setting( |
| 82 | $field, |
| 83 | array( |
| 84 | 'label' => __( 'Open', 'secure-custom-fields' ), |
| 85 | 'instructions' => __( 'Display this accordion as open on page load.', 'secure-custom-fields' ), |
| 86 | 'name' => 'open', |
| 87 | 'type' => 'true_false', |
| 88 | 'ui' => 1, |
| 89 | ) |
| 90 | ); |
| 91 | |
| 92 | acf_render_field_setting( |
| 93 | $field, |
| 94 | array( |
| 95 | 'label' => __( 'Multi-Expand', 'secure-custom-fields' ), |
| 96 | 'instructions' => __( 'Allow this accordion to open without closing others.', 'secure-custom-fields' ), |
| 97 | 'name' => 'multi_expand', |
| 98 | 'type' => 'true_false', |
| 99 | 'ui' => 1, |
| 100 | ) |
| 101 | ); |
| 102 | |
| 103 | acf_render_field_setting( |
| 104 | $field, |
| 105 | array( |
| 106 | 'label' => __( 'Endpoint', 'secure-custom-fields' ), |
| 107 | 'instructions' => __( 'Define an endpoint for the previous accordion to stop. This accordion will not be visible.', 'secure-custom-fields' ), |
| 108 | 'name' => 'endpoint', |
| 109 | 'type' => 'true_false', |
| 110 | 'ui' => 1, |
| 111 | ) |
| 112 | ); |
| 113 | } |
| 114 | |
| 115 | |
| 116 | /** |
| 117 | * This filter is applied to the $field after it is loaded from the database |
| 118 | * |
| 119 | * @type filter |
| 120 | * @since ACF 3.6 |
| 121 | * @date 23/01/13 |
| 122 | * |
| 123 | * @param $field - the field array holding all the field options |
| 124 | * |
| 125 | * @return $field - the field array holding all the field options |
| 126 | */ |
| 127 | function load_field( $field ) { |
| 128 | |
| 129 | // remove name to avoid caching issue |
| 130 | $field['name'] = ''; |
| 131 | |
| 132 | // remove required to avoid JS issues |
| 133 | $field['required'] = 0; |
| 134 | |
| 135 | // set value other than 'null' to avoid ACF loading / caching issue |
| 136 | $field['value'] = false; |
| 137 | |
| 138 | // return |
| 139 | return $field; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Returns an array of JSON-LD Property output types that are supported by this field type. |
| 144 | * |
| 145 | * @since ACF 6.8 |
| 146 | * |
| 147 | * @return string[] |
| 148 | */ |
| 149 | public function get_jsonld_output_types(): array { |
| 150 | return array(); |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | |
| 155 | // initialize |
| 156 | acf_register_field_type( 'acf_field__accordion' ); |
| 157 | endif; // class_exists check |
| 158 | |
| 159 | ?> |
| 160 |