From 4e9d82a18cc6ad707ebc67e23e85813389afd570 Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Wed, 24 Jan 2024 19:12:12 +0100 Subject: [PATCH] Refactor for new Script Modules API --- .../interactivity-api/class-wp-interactivity-api.php | 7 +++++++ packages/block-library/src/query/index.php | 6 +++--- packages/e2e-tests/plugins/interactive-blocks.php | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/compat/wordpress-6.5/interactivity-api/class-wp-interactivity-api.php b/lib/compat/wordpress-6.5/interactivity-api/class-wp-interactivity-api.php index de1d8b2a9e7890..5e3596fb4c9829 100644 --- a/lib/compat/wordpress-6.5/interactivity-api/class-wp-interactivity-api.php +++ b/lib/compat/wordpress-6.5/interactivity-api/class-wp-interactivity-api.php @@ -150,6 +150,13 @@ public function register_script_modules() { array(), defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) ); + + wp_register_script_module( + '@wordpress/interactivity/router', + gutenberg_url( '/build/interactivity/router.min.js' ), + array( '@wordpress/interactivity' ), + defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) + ); } /** diff --git a/packages/block-library/src/query/index.php b/packages/block-library/src/query/index.php index e869c0e2536c1c..e9906d5cad6eb7 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -100,12 +100,12 @@ function register_block_core_query() { wp_register_script_module( '@wordpress/block-library/query', - '/wp-content/plugins/gutenberg/build/interactivity/query.min.js', + gutenberg_url( '/build/interactivity/query.min.js' ), array( '@wordpress/interactivity', array( - 'id' => '@wordpress/interactivity/router', - 'type' => 'dynamic', + 'id' => '@wordpress/interactivity/router', + 'import' => 'dynamic', ), ), defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) diff --git a/packages/e2e-tests/plugins/interactive-blocks.php b/packages/e2e-tests/plugins/interactive-blocks.php index dded910cd5cb42..f80f5ea8008248 100644 --- a/packages/e2e-tests/plugins/interactive-blocks.php +++ b/packages/e2e-tests/plugins/interactive-blocks.php @@ -27,8 +27,8 @@ function () { array( '@wordpress/interactivity', array( - 'id' => '@wordpress/interactivity/router', - 'type' => 'dynamic', + 'id' => '@wordpress/interactivity/router', + 'import' => 'dynamic', ), ), filemtime( $view_file )