Generate Elementor widget for your Elementor plugin. Use Elementor Plugin Generator to create Elementor plugin and then use this generator to create widget for it. In this widget generator we include single input text field for easier understanding of Elementor structure
<?php
//Custom Elementor widget generated by Brewpy.app
class Brewpy_Elementor_Widget_1642621954107 extends ElementorWidget_Base {
public function get_name() {
return 'mywidget';
}
public function get_title() {
return __( 'My Elementor Widget', 'text_domain' );
}
public function get_icon() {
return 'fa fa-bookmark';
}
public function get_categories() {
return [ 'general' ];
}
protected function _register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => __( 'Content', 'text_domain' ),
'tab' => ElementorControls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'widgeturl',
[
'label' => __( 'Enter the URL', 'text_domain' ),
'type' => ElementorControls_Manager::TEXT,
'input_type' => 'url',
'placeholder' => __( 'https://example.com', 'text_domain' ),
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
echo '<div class="oembed-elementor-widget">';
echo $settings['widgeturl'];
echo '</div>';
}
}
?>