You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Scripts can also have translation data via `wp_set_script_translations()`. This can be added like following:
322
+
Scripts can also have translation data via `wp_set_script_translations()`. This can be added like the following:
322
323
323
324
```php
324
325
<?php
@@ -449,6 +450,20 @@ $script->withAttributes(['src' => 'another-script.js']); // Will not overwrite "
449
450
450
451
WordPress 6.5 introduced Script Modules for native JavaScript ES6 modules. The `ScriptModule` class provides basic asset management with the following limitations:
451
452
453
+
### Module Data
454
+
455
+
Scripts Modules allow sharing data from the server to the client via a filter `"script_module_data_{$handle}"`.
456
+
457
+
Assets registered as `ScriptModule` can have shared data added like following:
458
+
459
+
```php
460
+
$module = new ScriptModule('@my-plugin/main', 'assets/main.js');
0 commit comments