Skip to content

Commit

Permalink
Webfonts: increase priority of init hook to account for block reregis…
Browse files Browse the repository at this point in the history
…tration (#41569)

* `gutenberg_register_webfonts_from_theme_json()` calls `WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()`, which instantiates `WP_Theme_JSON_Gutenberg()`;
Gutenberg server-side blocks are registered via the init hook with a priority value of `20`. E.g., `add_action( 'init', 'register_block_core_image', 20 )`;
This priority value is added dynamically during the build. See: tools/webpack/blocks.js.
We want to make sure Gutenberg blocks are re-registered before any Theme_JSON operations take place so that we have access to updated merged data.

* Remove evil space
  • Loading branch information
ramonjd authored Jun 7, 2022
1 parent 3d07c25 commit 877668d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/experimental/register-webfonts-from-theme-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,9 @@ function gutenberg_add_registered_webfonts_to_theme_json( $data ) {
return $data;
}

add_action( 'init', 'gutenberg_register_webfonts_from_theme_json' );
// `gutenberg_register_webfonts_from_theme_json()` calls `WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()`, which instantiates `WP_Theme_JSON_Gutenberg()`;
// Gutenberg server-side blocks are registered via the init hook with a priority value of `20`. E.g., `add_action( 'init', 'register_block_core_image', 20 )`;
// This priority value is added dynamically during the build. See: tools/webpack/blocks.js.
// We want to make sure Gutenberg blocks are re-registered before any Theme_JSON operations take place
// so that we have access to updated merged data.
add_action( 'init', 'gutenberg_register_webfonts_from_theme_json', 21 );

0 comments on commit 877668d

Please sign in to comment.