if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
* Elementor widget that insert a custom HTML code into the page.
class Widget_Html extends Widget_Base {
* Retrieve HTML widget name.
* @return string Widget name.
public function get_name() {
* Retrieve HTML widget title.
* @return string Widget title.
public function get_title() {
return esc_html__( 'HTML', 'elementor' );
* Retrieve HTML widget icon.
* @return string Widget icon.
public function get_icon() {
* Retrieve the list of keywords the widget belongs to.
* @return array Widget keywords.
public function get_keywords() {
return [ 'html', 'code', 'embed', 'script' ];
protected function is_dynamic_content(): bool {
public function show_in_panel() {
return User::is_current_user_can_use_custom_html();
public function has_widget_inner_wrapper(): bool {
return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
* Register HTML widget controls.
* Adds different input fields to allow the user to change and customize the widget settings.
protected function register_controls() {
$this->start_controls_section(
'label' => esc_html__( 'HTML Code', 'elementor' ),
'label' => esc_html__( 'HTML Code', 'elementor' ),
'type' => Controls_Manager::CODE,
'placeholder' => esc_html__( 'Enter your code', 'elementor' ),
'is_editable' => User::is_current_user_can_use_custom_html(),
$this->end_controls_section();
* Render HTML widget output on the frontend.
* Written in PHP and used to generate the final HTML.
protected function render() {
$this->print_unescaped_setting( 'html' );
* Render HTML widget output in the editor.
* Written as a Backbone JavaScript template and used to generate the live preview.
protected function content_template() {