Docs: Correct formatting for script module data filter documentation examples.

Follow-up to [58579].

Props jonsurrell.
See #62281.
Built from https://develop.svn.wordpress.org/trunk@59505


git-svn-id: http://core.svn.wordpress.org/trunk@58891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2024-12-11 15:20:18 +00:00
parent d1058355a5
commit caaf759d21
2 changed files with 21 additions and 18 deletions

View File

@ -407,11 +407,12 @@ class WP_Script_Modules {
* initialization or immediately on page load. It does not replace the REST API or * initialization or immediately on page load. It does not replace the REST API or
* fetching data from the client. * fetching data from the client.
* *
* @example * Example:
*
* add_filter( * add_filter(
* 'script_module_data_MyScriptModuleID', * 'script_module_data_MyScriptModuleID',
* function ( array $data ): array { * function ( array $data ): array {
* $data['script-needs-this-data'] = 'ok'; * $data['dataForClient'] = 'ok';
* return $data; * return $data;
* } * }
* ); * );
@ -423,7 +424,8 @@ class WP_Script_Modules {
* *
* The data can be read on the client with a pattern like this: * The data can be read on the client with a pattern like this:
* *
* @example * Example:
*
* const dataContainer = document.getElementById( 'wp-script-module-data-MyScriptModuleID' ); * const dataContainer = document.getElementById( 'wp-script-module-data-MyScriptModuleID' );
* let data = {}; * let data = {};
* if ( dataContainer ) { * if ( dataContainer ) {
@ -431,6 +433,7 @@ class WP_Script_Modules {
* data = JSON.parse( dataContainer.textContent ); * data = JSON.parse( dataContainer.textContent );
* } catch {} * } catch {}
* } * }
* // data.dataForClient === 'ok';
* initMyScriptModuleWithData( data ); * initMyScriptModuleWithData( data );
* *
* @since 6.7.0 * @since 6.7.0

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.8-alpha-59504'; $wp_version = '6.8-alpha-59505';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.