From caaf759d21dabffa84ab1e47d1a40798f2693fa0 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 11 Dec 2024 15:20:18 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-script-modules.php | 37 +++++++++++++------------ wp-includes/version.php | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/wp-includes/class-wp-script-modules.php b/wp-includes/class-wp-script-modules.php index 384bf9ef2f..dbfa038f8c 100644 --- a/wp-includes/class-wp-script-modules.php +++ b/wp-includes/class-wp-script-modules.php @@ -407,14 +407,15 @@ class WP_Script_Modules { * initialization or immediately on page load. It does not replace the REST API or * fetching data from the client. * - * @example - * add_filter( - * 'script_module_data_MyScriptModuleID', - * function ( array $data ): array { - * $data['script-needs-this-data'] = 'ok'; - * return $data; - * } - * ); + * Example: + * + * add_filter( + * 'script_module_data_MyScriptModuleID', + * function ( array $data ): array { + * $data['dataForClient'] = 'ok'; + * return $data; + * } + * ); * * If the filter returns no data (an empty array), nothing will be embedded in the page. * @@ -423,15 +424,17 @@ class WP_Script_Modules { * * The data can be read on the client with a pattern like this: * - * @example - * const dataContainer = document.getElementById( 'wp-script-module-data-MyScriptModuleID' ); - * let data = {}; - * if ( dataContainer ) { - * try { - * data = JSON.parse( dataContainer.textContent ); - * } catch {} - * } - * initMyScriptModuleWithData( data ); + * Example: + * + * const dataContainer = document.getElementById( 'wp-script-module-data-MyScriptModuleID' ); + * let data = {}; + * if ( dataContainer ) { + * try { + * data = JSON.parse( dataContainer.textContent ); + * } catch {} + * } + * // data.dataForClient === 'ok'; + * initMyScriptModuleWithData( data ); * * @since 6.7.0 * diff --git a/wp-includes/version.php b/wp-includes/version.php index 225dbe240e..4d1c867e58 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @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.