field-advanced-link.php
3 months ago
field-button-group.php
1 week ago
field-button.php
7 months ago
field-checkbox.php
3 months ago
field-clone.php
2 years ago
field-code-editor.php
3 months ago
field-column.php
3 years ago
field-dynamic-render.php
3 years ago
field-file.php
3 months ago
field-flexible-content-actions-title.php
3 months ago
field-flexible-content-actions-toggle.php
3 months ago
field-flexible-content-actions.php
3 months ago
field-flexible-content-async.php
4 months ago
field-flexible-content-compatibility.php
3 months ago
field-flexible-content-controls.php
9 months ago
field-flexible-content-hide.php
3 months ago
field-flexible-content-hooks.php
9 months ago
field-flexible-content-modal-edit.php
9 months ago
field-flexible-content-modal-select.php
3 months ago
field-flexible-content-modal-settings.php
3 months ago
field-flexible-content-popup.php
3 months ago
field-flexible-content-preview.php
3 months ago
field-flexible-content-state.php
9 months ago
field-flexible-content-thumbnail.php
9 months ago
field-flexible-content-wysiwyg.php
9 months ago
field-flexible-content.php
3 months ago
field-forms.php
3 months ago
field-gallery.php
3 months ago
field-google-map.php
3 months ago
field-group.php
3 months ago
field-hidden.php
3 years ago
field-image.php
3 months ago
field-post-object.php
3 months ago
field-post-statuses.php
3 months ago
field-post-types.php
3 months ago
field-radio.php
3 months ago
field-recaptcha.php
3 months ago
field-relationship.php
3 months ago
field-repeater.php
3 months ago
field-select.php
3 months ago
field-slug.php
1 year ago
field-taxonomies.php
3 months ago
field-taxonomy-terms.php
3 months ago
field-taxonomy.php
3 months ago
field-textarea.php
3 months ago
field-user-roles.php
3 months ago
field-user.php
3 months ago
field-wysiwyg.php
3 months ago
field-textarea.php
96 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_field_textarea')): |
| 8 | |
| 9 | class acfe_field_textarea extends acfe_field_extend{ |
| 10 | |
| 11 | /** |
| 12 | * initialize |
| 13 | */ |
| 14 | function initialize(){ |
| 15 | |
| 16 | $this->name = 'textarea'; |
| 17 | $this->defaults = array( |
| 18 | 'acfe_textarea_code' => 0, |
| 19 | ); |
| 20 | |
| 21 | } |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * field_group_admin_head |
| 26 | */ |
| 27 | function field_group_admin_head(){ |
| 28 | |
| 29 | add_filter('acf/prepare_field/name=new_lines', function($field){ |
| 30 | |
| 31 | // check setting |
| 32 | if(acfe_get($field['wrapper'], 'data-setting') === 'textarea'){ |
| 33 | |
| 34 | $field['conditional_logic'] = array( |
| 35 | array( |
| 36 | array( |
| 37 | 'field' => 'acfe_textarea_code', |
| 38 | 'operator' => '!=', |
| 39 | 'value' => '1' |
| 40 | ) |
| 41 | ) |
| 42 | ); |
| 43 | |
| 44 | } |
| 45 | |
| 46 | return $field; |
| 47 | |
| 48 | }); |
| 49 | |
| 50 | } |
| 51 | |
| 52 | |
| 53 | /** |
| 54 | * render_field_settings |
| 55 | * |
| 56 | * @param $field |
| 57 | */ |
| 58 | function render_field_settings($field){ |
| 59 | |
| 60 | // code mode |
| 61 | acf_render_field_setting($field, array( |
| 62 | 'label' => __('Code mode'), |
| 63 | 'name' => 'acfe_textarea_code', |
| 64 | 'key' => 'acfe_textarea_code', |
| 65 | 'instructions' => __('Switch font family to monospace and allow tab indent. For a more advanced code editor, please use the <code>Code Editor</code> field type', 'acfe'), |
| 66 | 'type' => 'true_false', |
| 67 | 'ui' => 1, |
| 68 | )); |
| 69 | |
| 70 | } |
| 71 | |
| 72 | |
| 73 | /** |
| 74 | * field_wrapper_attributes |
| 75 | * |
| 76 | * @param $wrapper |
| 77 | * @param $field |
| 78 | * |
| 79 | * @return mixed |
| 80 | */ |
| 81 | function field_wrapper_attributes($wrapper, $field){ |
| 82 | |
| 83 | // code mode |
| 84 | if($field['acfe_textarea_code']){ |
| 85 | $wrapper['data-acfe-textarea-code'] = 1; |
| 86 | } |
| 87 | |
| 88 | return $wrapper; |
| 89 | |
| 90 | } |
| 91 | |
| 92 | } |
| 93 | |
| 94 | acf_new_instance('acfe_field_textarea'); |
| 95 | |
| 96 | endif; |