html.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 HTML widget.
  9. *
  10. * Elementor widget that insert a custom HTML code into the page.
  11. *
  12. * @since 1.0.0
  13. */
  14. class Widget_Html extends Widget_Base {
  15. /**
  16. * Get widget name.
  17. *
  18. * Retrieve HTML widget name.
  19. *
  20. * @since 1.0.0
  21. * @access public
  22. *
  23. * @return string Widget name.
  24. */
  25. public function get_name() {
  26. return 'html';
  27. }
  28. /**
  29. * Get widget title.
  30. *
  31. * Retrieve HTML widget title.
  32. *
  33. * @since 1.0.0
  34. * @access public
  35. *
  36. * @return string Widget title.
  37. */
  38. public function get_title() {
  39. return __( 'HTML', 'elementor' );
  40. }
  41. /**
  42. * Get widget icon.
  43. *
  44. * Retrieve HTML widget icon.
  45. *
  46. * @since 1.0.0
  47. * @access public
  48. *
  49. * @return string Widget icon.
  50. */
  51. public function get_icon() {
  52. return 'eicon-coding';
  53. }
  54. /**
  55. * Get widget keywords.
  56. *
  57. * Retrieve the list of keywords the widget belongs to.
  58. *
  59. * @since 2.1.0
  60. * @access public
  61. *
  62. * @return array Widget keywords.
  63. */
  64. public function get_keywords() {
  65. return [ 'html', 'code' ];
  66. }
  67. /**
  68. * Register HTML widget controls.
  69. *
  70. * Adds different input fields to allow the user to change and customize the widget settings.
  71. *
  72. * @since 1.0.0
  73. * @access protected
  74. */
  75. protected function _register_controls() {
  76. $this->start_controls_section(
  77. 'section_title',
  78. [
  79. 'label' => __( 'HTML Code', 'elementor' ),
  80. ]
  81. );
  82. $this->add_control(
  83. 'html',
  84. [
  85. 'label' => '',
  86. 'type' => Controls_Manager::CODE,
  87. 'default' => '',
  88. 'placeholder' => __( 'Enter your code', 'elementor' ),
  89. 'show_label' => false,
  90. ]
  91. );
  92. $this->end_controls_section();
  93. }
  94. /**
  95. * Render HTML widget output on the frontend.
  96. *
  97. * Written in PHP and used to generate the final HTML.
  98. *
  99. * @since 1.0.0
  100. * @access protected
  101. */
  102. protected function render() {
  103. echo $this->get_settings_for_display( 'html' );
  104. }
  105. /**
  106. * Render HTML widget output in the editor.
  107. *
  108. * Written as a Backbone JavaScript template and used to generate the live preview.
  109. *
  110. * @since 1.0.0
  111. * @access protected
  112. */
  113. protected function _content_template() {
  114. ?>
  115. {{{ settings.html }}}
  116. <?php
  117. }
  118. }