Widget Builder
Data controls in 3.17.0
Section titled “Data controls in 3.17.0”Widget specs support query, shortcode and remote-source data controls. Query sources include posts, products, terms, menu, site, breadcrumbs, cart and remote. These let an agent design a custom Elementor widget around site data instead of copying values into every instance.
Shortcodes use an allowlisted provider registry, including saved Elementor templates and supported form plugins. This is not an arbitrary shortcode execution field. Discover installed providers and inspect their supported parameters before building a widget.
Remote queries include configured OpenWeather, Google Reviews, Yelp and generic JSON workflows. Configure keys under EMCP Tools → Connection → 3rd-party services → Live data providers. Keys stay outside cloud settings sync. Plan field mapping, loading and empty states, and inspect rendered output before you activate a widget.
Structured defaults are supported for icon, URL, media and multi-select controls. Reserved Elementor control names, including animation and _animation, are refused: those names can trigger entrance-animation behavior and make a widget invisible. Filled active states should have explicit text and background controls so a later style change preserves readable contrast.
The bundled Widget Builder skill documents current spec shapes. Read it and the live tool schema before creating a data-backed widget; query controls do not make arbitrary external data safe or structurally compatible with a template.
The Widget Builder lets an AI agent design a custom Elementor widget (a pricing card, a stat counter, a testimonial block) from a structured spec. The plugin compiles that spec into a real Elementor widget that appears in the editor panel, ready to drop onto any page.
Crucially, the AI never writes PHP. It submits a JSON spec plus an HTML template with {{control}} placeholders. A plugin-owned generator compiles that into a Widget_Base class, escaping every value by its declared control type. The generated code lives in an isolated sandbox under wp-content/emcp-sandbox/. It never touches WordPress core, your theme, or any other plugin.
How it works
Section titled “How it works”- The agent calls
list-control-typesto learn the spec shape and supported controls. - It builds a spec: sections of controls (text, color, select, dimensions, typography group, repeater, …) plus an
html_templatethat references those controls. validate-widget-specdry-runs the generator and returns any errors without persisting.create-custom-widgetgenerates theWidget_BasePHP, writes it to the sandbox, and saves it as an inactive draft. Since 3.18.0 it never activates a widget (the oldactivateargument is gone), and its response carries a note saying so.- You review the code on Sandbox → Widgets (View code) and switch the widget on. Only then does it appear under the “Custom (EMCP)” category in the Elementor panel.
- The agent (or you) places it on a page like any other widget. Until you activate it, an agent cannot place it, so it should ask you to.
A runtime safety net validates each widget on create/update and isolates compile failures, so a malformed widget is demoted to draft with a recorded error rather than breaking the editor.
Spec essentials
Section titled “Spec essentials”- 35 control types, including group controls (typography, border, box-shadow, background), repeaters, responsive controls, and conditional visibility.
- Template syntax:
{{control_name}}for values,{{#if control}}…{{/if}}for conditionals,{{#each repeater}}…{{/each}}for loops. Every value is escaped by its control type. - Optional per-widget CSS/JS: registered and enqueued only when the widget renders on a page.
Connected agents that load the bundled widget-builder Agent Skill already know the full spec format and control catalog.
| Tool | Purpose |
|---|---|
emcp-tools/list-control-types | List supported control types + the spec shape |
emcp-tools/validate-widget-spec | Schema + generator dry-run; returns errors, persists nothing |
emcp-tools/create-custom-widget | Generate a widget from a spec as an inactive draft |
emcp-tools/update-custom-widget | Replace a widget’s spec, regenerate, re-validate |
emcp-tools/get-custom-widget | Return a widget’s spec + generated PHP + status |
emcp-tools/list-custom-widgets | List generated widgets (id, title, name, status) |
emcp-tools/set-widget-status | Return a widget to an inactive draft. Accepts only draft; active is refused with activation_requires_admin |
emcp-tools/delete-custom-widget | Delete a widget (CPT record + sandbox files) |
Permissions
Section titled “Permissions”Creating, updating, deactivating, and deleting widgets require manage_options plus unfiltered_html, the same bar as site-wide custom code. Read tools (get-, list-, list-control-types, validate-) require edit_posts.
