mirror of
git://develop.git.wordpress.org/
synced 2025-03-20 03:49:54 +01:00
Add a new filter `script_module_data_{$module_id}` to associate data with a Script Module. For example: {{{#!php add_filter( 'script_module_data_MyScriptModuleID', function ( array $data ): array { $data['script-needs-this-data'] = 'ok'; return $data; } ); }}} If the Script Module is included in the page, enqueued or as a dependency, the associated data will be JSON-encoded and embedded in the HTML in a `<script type="application/json">` tag with an ID of the form `wp-script-module-data-{$module_id}` allowing the Script Module to access the data on the client. See the original proposal: https://make.wordpress.org/core/2024/05/06/proposal-server-to-client-data-sharing-for-script-modules/ Developed in https://github.com/WordPress/wordpress-develop/pull/6682. Props jonsurrell, cbravobernal, westonruter, gziolo, bernhard-reiter, youknowriad, sergiomdgomes, czapla. Fixes #61510. See #60647. git-svn-id: https://develop.svn.wordpress.org/trunk@58579 602fd350-edb4-49c9-b593-d223f7449a82