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-textarea.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')) |
| 4 | exit; |
| 5 | |
| 6 | // Settings |
| 7 | add_action('acf/render_field_settings/type=textarea', 'acfe_field_textarea_settings'); |
| 8 | function acfe_field_textarea_settings($field){ |
| 9 | |
| 10 | acf_render_field_setting($field, array( |
| 11 | 'label' => __('Code mode'), |
| 12 | 'name' => 'acfe_textarea_code', |
| 13 | 'key' => 'acfe_textarea_code', |
| 14 | 'instructions' => __('Switch font family to monospace and allow tab indent'), |
| 15 | 'type' => 'true_false', |
| 16 | 'ui' => 1, |
| 17 | )); |
| 18 | |
| 19 | } |
| 20 | |
| 21 | // Field wrapper |
| 22 | add_filter('acf/field_wrapper_attributes', 'acfe_field_textarea_wrapper', 10, 2); |
| 23 | function acfe_field_textarea_wrapper($wrapper, $field){ |
| 24 | |
| 25 | if($field['type'] != 'textarea') |
| 26 | return $wrapper; |
| 27 | |
| 28 | if(isset($field['acfe_textarea_code']) && !empty($field['acfe_textarea_code'])){ |
| 29 | |
| 30 | $wrapper['data-acfe-textarea-code'] = 1; |
| 31 | |
| 32 | } |
| 33 | |
| 34 | return $wrapper; |
| 35 | |
| 36 | } |