mirror of
https://gh.wpcy.net/https://github.com/elementor/elementor.git
synced 2026-04-20 12:23:54 +08:00
## 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 |
||
|---|---|---|
| .. | ||
| admin-templates | ||
| base | ||
| controls | ||
| editor-templates | ||
| elements | ||
| interfaces | ||
| libraries | ||
| managers | ||
| settings | ||
| template-library | ||
| widgets | ||
| api.php | ||
| autoloader.php | ||
| beta-testers.php | ||
| compatibility.php | ||
| conditions.php | ||
| db.php | ||
| editor-assets-api.php | ||
| embed.php | ||
| fonts.php | ||
| frontend.php | ||
| heartbeat.php | ||
| maintenance-mode.php | ||
| maintenance.php | ||
| plugin.php | ||
| preview.php | ||
| rollback.php | ||
| shapes.php | ||
| stylesheet.php | ||
| tracker.php | ||
| user-data.php | ||
| user.php | ||
| utils.php | ||