| 1 |
<?php |
| 2 |
namespace MasterAddons\Inc\Admin\WidgetBuilder\Controls; |
| 3 |
|
| 4 |
defined('ABSPATH') || exit; |
| 5 |
|
| 6 |
/** |
| 7 |
* TEXTAREA Control |
| 8 |
* Handles Elementor TEXTAREA control type |
| 9 |
* |
| 10 |
* Supported properties: |
| 11 |
* - label: Control label |
| 12 |
* - name: Field name (used for control key) |
| 13 |
* - description: Description below field |
| 14 |
* - placeholder: Placeholder text |
| 15 |
* - default: Default value |
| 16 |
* - rows: Number of rows for textarea |
| 17 |
* |
| 18 |
* Common settings (handled by base class): |
| 19 |
* - show_label: Show/hide label |
| 20 |
* - label_block: Display label on separate line |
| 21 |
* - responsive: Enable responsive control |
| 22 |
* - dynamic: Enable dynamic content support |
| 23 |
* - separator: Control separator position |
| 24 |
* - condition: Conditional display logic |
| 25 |
* - selectors: CSS selectors for styling |
| 26 |
*/ |
| 27 |
class Textarea extends Control_Base { |
| 28 |
|
| 29 |
public function get_type() { |
| 30 |
return 'TEXTAREA'; |
| 31 |
} |
| 32 |
|
| 33 |
public function build($control_key, $field) { |
| 34 |
$label = !empty($field['label']) ? $field['label'] : 'Textarea'; |
| 35 |
|
| 36 |
// Check if responsive control |
| 37 |
$is_responsive = isset($field['responsive']) && $field['responsive']; |
| 38 |
|
| 39 |
// Build control header |
| 40 |
$content = $this->build_control_header($control_key, $label, 'TEXTAREA', $is_responsive); |
| 41 |
|
| 42 |
// Add TEXTAREA-specific properties FIRST |
| 43 |
$content .= $this->build_textarea_properties($field); |
| 44 |
|
| 45 |
// Add common properties |
| 46 |
$content .= $this->build_common_properties($field); |
| 47 |
|
| 48 |
// Close control |
| 49 |
$content .= $this->build_control_footer(); |
| 50 |
|
| 51 |
return $content; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Build TEXTAREA-specific properties |
| 56 |
* |
| 57 |
* @param array $field Field configuration |
| 58 |
* @return string |
| 59 |
*/ |
| 60 |
protected function build_textarea_properties($field) { |
| 61 |
$content = ''; |
| 62 |
|
| 63 |
// Rows - number of visible text lines |
| 64 |
if (isset($field['rows']) && $field['rows'] !== '' && $field['rows'] !== null) { |
| 65 |
$content .= $this->format_number_property('rows', intval($field['rows'])); |
| 66 |
} |
| 67 |
|
| 68 |
return $content; |
| 69 |
} |
| 70 |
|
| 71 |
protected function default_label() { |
| 72 |
return 'Textarea'; |
| 73 |
} |
| 74 |
|
| 75 |
protected function get_type_specific_config($field) { |
| 76 |
$config = []; |
| 77 |
if (isset($field['rows']) && $field['rows'] !== '' && $field['rows'] !== null) { |
| 78 |
$config['rows'] = intval($field['rows']); |
| 79 |
} |
| 80 |
return $config; |
| 81 |
} |
| 82 |
} |
| 83 |
|