From f5b783e775390e4b1ab7cb41780bf8e13b4b5e13 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 19 Sep 2024 13:55:02 +0200 Subject: [PATCH] Replace WP modules action with GB modules Avoid registering modules twice. Anticipates changes in https://github.com/WordPress/wordpress-develop/pull/7360 --- lib/client-assets.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client-assets.php b/lib/client-assets.php index 5f25fa6c81c357..ed1d2ee4eb7d07 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -606,7 +606,7 @@ function gutenberg_register_vendor_scripts( $scripts ) { * * Script modules that are registered by Core will be re-registered by Gutenberg. */ -function gutenberg_register_script_modules() { +function gutenberg_default_script_modules() { /* * Expects multidimensional array like: * @@ -645,11 +645,11 @@ function gutenberg_register_script_modules() { } $path = gutenberg_url( "build-module/{$file_name}" ); - wp_deregister_script_module( $script_module_id ); wp_register_script_module( $script_module_id, $path, $script_module_data['dependencies'], $script_module_data['version'] ); } } -add_action( 'after_setup_theme', 'gutenberg_register_script_modules', 20 ); +remove_action( 'wp_default_scripts', 'wp_default_script_modules' ); +add_action( 'wp_default_scripts', 'gutenberg_register_script_modules' ); /* * Always remove the Core action hook while gutenberg_enqueue_stored_styles() exists to avoid styles being printed twice.