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