elementor/includes
Omer Israeli a47dbdff91
Feat: Add refreshWidgets() API for dynamic widget list updates [ED-23311] (#35156)
## Summary

Adds a public `elementor.refreshWidgets()` API that lets third-party
code (e.g. Angie) dynamically register new widgets on the server side
and then refresh the editor's widget list **without a full page
reload**.

- New PHP AJAX endpoint `refresh_widgets_config` that returns the
complete widget + category configuration (including controls with
defaults).
- New JS `async refreshWidgets()` method on the editor instance that
fetches the updated config, replaces `widgetsCache`, updates panel
categories, refreshes the panel route, and reloads the preview iframe.
- Guards the elements panel against missing preset widgets that may no
longer exist after a refresh.

### Jira

https://elementor.atlassian.net/browse/ED-23311

## Usage Example

```js
// 1. Register your widget on the server (e.g. via AJAX or WP hook)
//    — make sure the widget class is registered with Elementor's widget manager.

// 2. From the browser console or your JS code, refresh the editor widget list:
await elementor.refreshWidgets();

// That's it — the panel will show the updated widget list,
// and the preview iframe will reload to pick up new widget assets (CSS/JS).
```

### What happens under the hood

1. An AJAX request fetches the full widget config (title, icon,
categories, controls with defaults, etc.) and all panel categories.
2. `widgetsCache` is cleared and rebuilt with the fresh data.
3. Panel categories are updated.
4. Global CSS is re-rendered.
5. The `elementor/widgets/refreshed` hook fires (for any listeners).
6. The panel route is refreshed so the Elements tab re-renders.
7. The preview iframe reloads so newly registered widget assets (CSS/JS)
are enqueued.

## Test plan

- [ ] Open the editor, register a new widget server-side (e.g. via
mu-plugin or Angie snippet)
- [ ] Run `await elementor.refreshWidgets()` in the browser console
- [ ] Verify the new widget appears in the panel under the correct
category
- [ ] Drag the new widget onto the canvas — verify it renders correctly
with default control values
- [ ] Verify existing widgets still work normally after the refresh
- [ ] Verify no JS errors in console during and after refresh
2026-04-15 12:24:57 +00:00
..
admin-templates Internal: Fixed lint [ED-17694] (#29791) 2025-01-06 15:01:10 +02:00
base Internal: [V4] Allow some action links in the editor [ED-22096] 2026-01-07 10:23:32 +02:00
controls Internal: PLGs adjustments for Elementor One [ED-22121] (#34151) 2026-01-12 03:52:59 -08:00
editor-templates Internal: Tweaks to atomic form behavior [ED-22577] (#35457) 2026-04-15 12:58:52 +02:00
elements Made strings translatable in two files (#35012) 2026-03-30 07:54:43 +00:00
interfaces Internal: Repeater - Implement min_items functionality (#27377) 2024-05-23 01:02:12 +02:00
libraries Tweak: Fix typos (#28081) 2024-07-21 16:04:56 +03:00
managers Feat: Add refreshWidgets() API for dynamic widget list updates [ED-23311] (#35156) 2026-04-15 12:24:57 +00:00
settings Fix: Editor admin UI changes due to WP 7.0 [ED-23094] (#35046) 2026-03-10 09:40:54 +00:00
template-library Internal: Misconfigured IF statement [ED-22644] (#35240) 2026-03-23 10:59:18 +02:00
widgets Made strings translatable in two files (#35012) 2026-03-30 07:54:43 +00:00
api.php Fix: Changes in the API-Info break the way several 3rd party plugin serve their templates (#32811) (#32820) 2025-09-18 10:57:26 +03:00
autoloader.php Tweak: On import, using the media zip [ED-20913] (#32926) 2025-09-30 14:41:28 +02:00
beta-testers.php Tweak: Progress bar styling 2019-06-23 19:22:16 +03:00
compatibility.php Internal: Fixed lint [ED-17694] (#29791) 2025-01-06 15:01:10 +02:00
conditions.php Internal: Revert dt fix [ED-21555] (#33574) 2025-11-24 11:23:18 +01:00
db.php Fix: Component draft handling [ED-22503] (#34286) 2026-01-18 17:42:46 +02:00
editor-assets-api.php Internal: Quick Start fatal error when remote is down [ED-22816] (#34798) 2026-02-18 10:11:14 +00:00
embed.php Internal: Fixed lint [ED-17694] (#29791) 2025-01-06 15:01:10 +02:00
fonts.php Internal: Fixed lint [ED-17694] (#29791) 2025-01-06 15:01:10 +02:00
frontend.php Fix: Migrations run on frontend and preview [ED-23565] (#35459) 2026-04-14 10:43:53 +03:00
heartbeat.php Improved ajax behavior 2018-10-08 10:40:37 +03:00
maintenance-mode.php Internal: Update php coding standard - NoReservedKeywordParameterNames [ED-20666] (#32598) 2025-09-03 14:15:39 +03:00
maintenance.php Internal: Added deactivation action [ED-16178] (#29913) 2025-01-16 15:09:18 +02:00
plugin.php Internal: Update REST API handling in Editor [ED-22286] (#34955) 2026-03-03 09:05:48 +00:00
preview.php Internal: Clear pregenerated CSS files upon style changes [ED-23383] (#35254) 2026-03-26 17:44:55 +02:00
rollback.php Internal: Update rollback installation text [ED-21145] (#33955) 2026-01-06 11:08:43 +02:00
shapes.php Tweak: Replaced select control with visual choose control in Shape Dividers [ED-19553] (#31482) 2025-06-18 03:26:17 -07:00
stylesheet.php Fix: PHP 8.4 Deprecation Notices [ED-17884] (#32243) 2025-08-27 12:21:19 +03:00
tracker.php Internal: Update consent handling for existing site data usage [ED-21470] (#33336) 2025-11-03 17:43:19 +02:00
user-data.php Internal: Update php coding standard rules - FunctionComment [ED-20572] (#32425) 2025-09-02 14:06:32 +03:00
user.php Internal: Revert delayed timing on Ally PLG [ED-21885] (#33691) 2025-12-03 01:44:42 -08:00
utils.php Internal: Add atomic form wrapper [ED-22410] (#34321) 2026-02-02 09:42:53 +00:00