Skip to content

Commit 889d385

Browse files
Update docs (#343)
1 parent 77f374b commit 889d385

3 files changed

Lines changed: 47 additions & 11 deletions

File tree

src/dynamic-tags/dynamic-tags-groups.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,30 @@ To simplify navigation, all tags are arranged into groups. This allows users to
88

99
## Available Groups
1010

11-
Elementor Pro adds the following groups:
11+
Elementor core registers one built-in group:
1212

13-
* **Post** - Post related dynamic data.
14-
* **Archive** - Theme archive related dynamic data.
15-
* **Site** - Site related dynamic data.
16-
* **Media** - Dynamic data based on media files.
17-
* **Actions** - Custom dynamic data.
18-
* **Author** - Post author dynamic data.
19-
* **Comments** - Post comments dynamic data.
13+
| Slug | Label |
14+
|------|-------|
15+
| `base` | Base Tags |
16+
17+
Elementor Pro registers additional groups:
18+
19+
| Slug | Label |
20+
|------|-------|
21+
| `post` | Post |
22+
| `archive` | Archive |
23+
| `site` | Site |
24+
| `media` | Media |
25+
| `action` | Actions |
26+
| `author` | Author |
27+
| `comments` | Comments |
2028

2129
If you would like to use the groups added by Elementor Pro, your addons must [make sure Elementor Pro was loaded](./../addons/compatibility/).
2230

31+
::: tip Groups vs. Categories
32+
Groups control where a tag appears in the **dynamic tags panel list** (the visual grouping users see). Categories are a separate concept: they control which **controls** a tag can appear on (for example, `text`, `url`, `image`, `color`). A tag declares its categories in `get_categories()` and its display group in `get_group()`.
33+
:::
34+
2335
## Applying Groups
2436

2537
When creating new dynamic tags, you can set the tag group by returning group names with the `get_group()` method:
@@ -36,7 +48,7 @@ class Elementor_Test_Tag extends \Elementor\Core\DynamicTags\Tag {
3648

3749
## Creating New Groups
3850

39-
Elementor Pro’s dynamic tags manager lets external developers create custom groups using the `elementor/dynamic_tags/register_tags` action hook:
51+
External developers can create custom groups using the `elementor/dynamic_tags/register` action hook, which passes the dynamic tags manager as a parameter:
4052

4153
```php
4254
/**

src/widgets/add-new-widget.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Elementor offers many built-in widgets out of the box, but it also allows external developers to register new widgets.
66

77
## Hooks
8-
8+
99
To do that we simply hook to the `elementor/widgets/register` action which provides access to the widgets manager as a parameter. Developers can use the manager to add new widgets using the `register()` method with the widget instance.
1010

1111
## Registering Widgets

src/widgets/widget-dependencies.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
2626

2727
* **Style Dependencies** – The `get_style_depends()` method lets you define the CSS files required to run the widget.
2828

29-
Please note that these dependencies should already be registered. The widget class only informs Elementor what dependencies it needs to enqueue.
29+
Both methods must return an array of **registered** script/style handles. The widget class does not register anything itself — it only tells Elementor which already-registered assets to enqueue when the widget is rendered. Returning an unregistered handle has no effect.
3030

3131
## Registering Scripts & Styles in WordPress
3232

@@ -143,3 +143,27 @@ class Elementor_Test_Widget extends \Elementor\Widget_Base {
143143
```
144144

145145
This can be handy when 3rd party widgets register their own frontend handlers. Read more about it on [controls `frontend_available` argument](./../editor-controls/frontend-available/).
146+
147+
### Editor-Only Dependencies
148+
149+
`get_script_depends()` and `get_style_depends()` are enqueued whenever the widget renders — including inside the editor preview iframe. They are not the right place for scripts that should only load in the editor panel itself (outside the preview).
150+
151+
For assets needed only inside the editor panel, register and enqueue them via the `elementor/editor/before_enqueue_scripts` or `elementor/editor/after_enqueue_scripts` action hooks instead:
152+
153+
```php
154+
function my_plugin_register_editor_only_assets() {
155+
wp_register_script(
156+
'my-widget-editor-script',
157+
plugins_url( 'assets/js/my-widget-editor.js', __FILE__ ),
158+
[ 'elementor-editor' ]
159+
);
160+
}
161+
add_action( 'wp_enqueue_scripts', 'my_plugin_register_editor_only_assets' );
162+
163+
function my_plugin_enqueue_editor_only_assets() {
164+
wp_enqueue_script( 'my-widget-editor-script' );
165+
}
166+
add_action( 'elementor/editor/before_enqueue_scripts', 'my_plugin_enqueue_editor_only_assets' );
167+
```
168+
169+
This asset loads in the editor panel but is never enqueued on the frontend or inside the preview iframe. See [Editor Scripts](./../scripts-styles/editor-scripts/) for more details.

0 commit comments

Comments
 (0)