File tree Expand file tree Collapse file tree 1 file changed +20
-17
lines changed
Expand file tree Collapse file tree 1 file changed +20
-17
lines changed Original file line number Diff line number Diff line change @@ -407,14 +407,15 @@ public function print_script_module_data(): void {
407407 * initialization or immediately on page load. It does not replace the REST API or
408408 * fetching data from the client.
409409 *
410- * @example
411- * add_filter(
412- * 'script_module_data_MyScriptModuleID',
413- * function ( array $data ): array {
414- * $data['script-needs-this-data'] = 'ok';
415- * return $data;
416- * }
417- * );
410+ * Example:
411+ *
412+ * add_filter(
413+ * 'script_module_data_MyScriptModuleID',
414+ * function ( array $data ): array {
415+ * $data['dataForClient'] = 'ok';
416+ * return $data;
417+ * }
418+ * );
418419 *
419420 * If the filter returns no data (an empty array), nothing will be embedded in the page.
420421 *
@@ -423,15 +424,17 @@ public function print_script_module_data(): void {
423424 *
424425 * The data can be read on the client with a pattern like this:
425426 *
426- * @example
427- * const dataContainer = document.getElementById( 'wp-script-module-data-MyScriptModuleID' );
428- * let data = {};
429- * if ( dataContainer ) {
430- * try {
431- * data = JSON.parse( dataContainer.textContent );
432- * } catch {}
433- * }
434- * initMyScriptModuleWithData( data );
427+ * Example:
428+ *
429+ * const dataContainer = document.getElementById( 'wp-script-module-data-MyScriptModuleID' );
430+ * let data = {};
431+ * if ( dataContainer ) {
432+ * try {
433+ * data = JSON.parse( dataContainer.textContent );
434+ * } catch {}
435+ * }
436+ * // data.dataForClient === 'ok';
437+ * initMyScriptModuleWithData( data );
435438 *
436439 * @since 6.7.0
437440 *
You can’t perform that action at this time.
0 commit comments