Elementor Add-on Plugin Generator

Scaffold an Elementor add-on plugin: the header, the version gate with its admin notices, widget and category registration, and a widget to start from.

Enable JavaScript to change the fields; the files below are for the defaults.

The folder under wp-content/plugins, the main file name and the style handle.

Left empty the header line is left out rather than written blank.

Prefixes every function and, upper-cased, every constant. Left empty it comes from the folder name.

Checked against ELEMENTOR_VERSION before anything loads. 3.24 or newer covers the current registration API.

A header Elementor reads to warn users when your add-on has not been tested with their version.

Stored in every page that uses the widget. Changing it later orphans those pages.

Widget CSS

style-depends loads the file only on pages using the widget; always loads it on every Elementor page.

Create this plugin folder: wp-content/plugins/my-elementor-addon

Scaffold the plugin an Elementor widget lives in: the header, the version gate, the registration hooks and a widget that already works.

How to use

  1. Name the plugin and set the folder name. The folder name is also the main file name and the stylesheet handle, so keep it short.
  2. Set the minimum Elementor version. The plugin checks it before loading anything and shows an admin notice instead of crashing.
  3. Decide whether you want your own panel category. With one, your widgets group under their own heading rather than landing in General.
  4. Leave the starter widget on for the first build. It proves the registration works; replace it with output from the Elementor Widget Generator once it does.
  5. Choose how the CSS loads. The default registers the stylesheet and lets the widget ask for it, so pages without the widget never download it.
  6. Create the folder in wp-content/plugins, copy each tab into the file it names, then activate the plugin.

Example

With the defaults the plugin gates itself, then hooks registration:

add_action( 'plugins_loaded', 'my_addon_boot' );

function my_addon_boot() {
	if ( ! my_addon_requirements_met() ) {
		return;
	}

	require_once MY_ADDON_PATH . 'widgets/class-hello-widget.php';

	add_action( 'elementor/widgets/register', 'my_addon_register_widgets' );
	add_action( 'elementor/elements/categories_registered', 'my_addon_register_category' );
	add_action( 'wp_enqueue_scripts', 'my_addon_register_assets' );
}

The gate is the part worth reading. It checks three things in order, and each failure adds an admin notice rather than letting PHP fatal on a missing class:

function my_addon_requirements_met() {
	if ( ! did_action( 'elementor/loaded' ) ) {
		add_action( 'admin_notices', 'my_addon_notice_no_elementor' );

		return false;
	}

	if ( ! version_compare( ELEMENTOR_VERSION, MY_ADDON_MIN_ELEMENTOR, '>=' ) ) {
		add_action( 'admin_notices', 'my_addon_notice_old_elementor' );

		return false;
	}

	return true;
}

Pitfalls

  • Hooking elementor/loaded to boot the plugin means nothing runs when Elementor is missing, including the notice that would explain why. Boot on plugins_loaded and check did_action instead, which is what this scaffold does.
  • Extending the widget base class at file scope fatals when Elementor is absent. The widget file is only required inside the gate, after the check passes.
  • elementor/widgets/register replaced elementor/widgets/widgets_registered, and the manager method is now register, not register_widget_type. Old tutorials still show the pair that was removed in Elementor 3.5.
  • A widget’s name is stored in every page that uses it. Renaming it leaves those pages with a widget Elementor cannot find, and the content is gone from the canvas.
  • Categories have to be registered before the panel is built. Registering one inside the widget’s own file is too late, so it lives in the plugin file.
  • Enqueuing your stylesheet on every Elementor page is the common shortcut. Registering it and naming the handle in the widget’s style dependencies loads it only where it is used.
  • Calling load_plugin_textdomain on plugins_loaded triggers the “translation loading was triggered too early” notice on WordPress 6.7 and newer. It runs on init here.
  • Widget settings are user input. The starter widget escapes on output; copying a tutorial that echoes settings raw is how add-ons ship stored cross-site scripting.

Compatibility

Every file is also downloadable as a single .zip, built in your browser. The archive stores the files rather than deflating them, which is what WordPress’s own installer reads, and the whole set goes in a folder named after the plugin, so Plugins → Add New → Upload installs it directly.

The registration API used here needs Elementor 3.5 or newer, and the scaffold defaults to requiring 3.24 so the widget style dependency behaviour is available. WordPress 6.7 or newer for the init translation timing, PHP 7.4 or newer for the syntax. Nothing here depends on Elementor Pro. The Elementor tested up to header is read by Elementor itself to warn users about untested add-ons. The tool runs entirely in your browser.

Frequently asked questions

Where does the widget class go?
In widgets/, one file per widget, required inside the gate. Add more widget files and register each one in the same function.
Do I need a namespace?
No. Prefixed function and class names are enough for a small add-on, and they keep the file readable. A namespace is worth it once you have a loader class and several widgets.
Why is my widget missing from the panel?
Either the registration hook never ran, which means the gate failed, or the widget returns a category that was never registered. Both show up in the panel as a widget that simply is not there.
Can I use this with a classic theme?
Yes. Elementor add-ons are independent of the theme; the plugin only needs Elementor itself.
How do I add settings for the whole add-on?
Add an options page in the plugin file and read it in the widget through get_option. Keep it out of the widget class so the widget stays about its own controls.

From the people who built this tool

Master Addons for Elementor

The widgets Elementor leaves out, built to stay fast: advanced tabs and accordions, mega menus, tables, forms and the extensions around them.

See Master Addons Free version on WordPress.org

Weekly drops

New tools, when there are new tools

One email when something worth using ships. No schedule to fill, so no filler.

Your address goes nowhere else, and one click unsubscribes.