textarea.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Elementor;
  3. use Elementor\Modules\DynamicTags\Module as TagsModule;
  4. if ( ! defined( 'ABSPATH' ) ) {
  5. exit; // Exit if accessed directly.
  6. }
  7. /**
  8. * Elementor textarea control.
  9. *
  10. * A base control for creating textarea control. Displays a classic textarea.
  11. *
  12. * @since 1.0.0
  13. */
  14. class Control_Textarea extends Base_Data_Control {
  15. /**
  16. * Get textarea control type.
  17. *
  18. * Retrieve the control type, in this case `textarea`.
  19. *
  20. * @since 1.0.0
  21. * @access public
  22. *
  23. * @return string Control type.
  24. */
  25. public function get_type() {
  26. return 'textarea';
  27. }
  28. /**
  29. * Get textarea control default settings.
  30. *
  31. * Retrieve the default settings of the textarea control. Used to return the
  32. * default settings while initializing the textarea control.
  33. *
  34. * @since 1.0.0
  35. * @access protected
  36. *
  37. * @return array Control default settings.
  38. */
  39. protected function get_default_settings() {
  40. return [
  41. 'label_block' => true,
  42. 'rows' => 5,
  43. 'placeholder' => '',
  44. 'dynamic' => [
  45. 'categories' => [ TagsModule::TEXT_CATEGORY ],
  46. ],
  47. ];
  48. }
  49. /**
  50. * Render textarea control output in the editor.
  51. *
  52. * Used to generate the control HTML in the editor using Underscore JS
  53. * template. The variables for the class are available using `data` JS
  54. * object.
  55. *
  56. * @since 1.0.0
  57. * @access public
  58. */
  59. public function content_template() {
  60. $control_uid = $this->get_control_uid();
  61. ?>
  62. <div class="elementor-control-field">
  63. <label for="<?php echo $control_uid; ?>" class="elementor-control-title">{{{ data.label }}}</label>
  64. <div class="elementor-control-input-wrapper">
  65. <textarea id="<?php echo $control_uid; ?>" class="elementor-control-tag-area" rows="{{ data.rows }}" data-setting="{{ data.name }}" placeholder="{{ data.placeholder }}"></textarea>
  66. </div>
  67. </div>
  68. <# if ( data.description ) { #>
  69. <div class="elementor-control-field-description">{{{ data.description }}}</div>
  70. <# } #>
  71. <?php
  72. }
  73. }