diff --git a/lib/experimental/register-webfonts-from-theme-json.php b/lib/experimental/register-webfonts-from-theme-json.php index 576d74ab0c56b0..f0a37677eb0637 100644 --- a/lib/experimental/register-webfonts-from-theme-json.php +++ b/lib/experimental/register-webfonts-from-theme-json.php @@ -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 );