Elementor Widget Generator

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

Widget name
Text domain
Example field label
Example field placeholder
Widget ID (lowercase, no spaces)
Widget Category
Content section title
Example field ID (lowercase, no spaces)
Render function content (PHP)

How to use this widget?

  • 1. Copy auto generated code and save as .php file (make it unique name)
  • 2. Upload file to your /plugins/yourplugin/widgets/ directory
  • 3. Go to your main plugin file and find function public function init_widgets and change path to your new widget
**Note: This is not finished widget usable for production. You will usually want to add more fields and change render function to make it useful

AUTO GENERATED CODE

<?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>';
 }
}

?>