popover-toggle.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace Elementor;
  3. if ( ! defined( 'ABSPATH' ) ) {
  4. exit; // Exit if accessed directly.
  5. }
  6. /**
  7. * Elementor popover toggle control.
  8. *
  9. * A base control for creating a popover toggle control. By default displays a toggle
  10. * button to open and close a popover.
  11. *
  12. * @since 1.9.0
  13. */
  14. class Control_Popover_Toggle extends Base_Data_Control {
  15. /**
  16. * Get popover toggle control type.
  17. *
  18. * Retrieve the control type, in this case `popover_toggle`.
  19. *
  20. * @since 1.9.0
  21. * @access public
  22. *
  23. * @return string Control type.
  24. */
  25. public function get_type() {
  26. return 'popover_toggle';
  27. }
  28. /**
  29. * Get popover toggle control default settings.
  30. *
  31. * Retrieve the default settings of the popover toggle control. Used to
  32. * return the default settings while initializing the popover toggle
  33. * control.
  34. *
  35. * @since 1.9.0
  36. * @access protected
  37. *
  38. * @return array Control default settings.
  39. */
  40. protected function get_default_settings() {
  41. return [
  42. 'return_value' => 'yes',
  43. ];
  44. }
  45. /**
  46. * Render popover toggle control output in the editor.
  47. *
  48. * Used to generate the control HTML in the editor using Underscore JS
  49. * template. The variables for the class are available using `data` JS
  50. * object.
  51. *
  52. * @since 1.9.0
  53. * @access public
  54. */
  55. public function content_template() {
  56. $control_uid = $this->get_control_uid();
  57. ?>
  58. <div class="elementor-control-field">
  59. <label class="elementor-control-title">{{{ data.label }}}</label>
  60. <div class="elementor-control-input-wrapper">
  61. <input id="<?php echo $control_uid; ?>-custom" class="elementor-control-popover-toggle-toggle" type="radio" name="elementor-choose-{{ data.name }}-{{ data._cid }}" value="{{ data.return_value }}">
  62. <label class="elementor-control-popover-toggle-toggle-label" for="<?php echo $control_uid; ?>-custom">
  63. <i class="eicon-edit" aria-hidden="true"></i>
  64. <span class="elementor-screen-only"><?php echo __( 'Edit', 'elementor' ); ?></span>
  65. </label>
  66. <input id="<?php echo $control_uid; ?>-default" type="radio" name="elementor-choose-{{ data.name }}-{{ data._cid }}" value="">
  67. <label class="elementor-control-popover-toggle-reset-label tooltip-target" for="<?php echo $control_uid; ?>-default" data-tooltip="<?php echo __( 'Back to default', 'elementor' ); ?>" data-tooltip-pos="s">
  68. <i class="fa fa-repeat" aria-hidden="true"></i>
  69. <span class="elementor-screen-only"><?php echo __( 'Back to default', 'elementor' ); ?></span>
  70. </label>
  71. </div>
  72. </div>
  73. <?php
  74. }
  75. }