number.php 1.9 KB

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