From f1765dc3a5b02b375a5dcd050dab962870756f9a Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Thu, 25 Jan 2024 11:01:35 +0100 Subject: [PATCH 1/3] Prevent usage of gutenberg_url in block-library --- packages/block-library/src/file/index.php | 2 +- packages/block-library/src/image/index.php | 2 +- packages/block-library/src/navigation/index.php | 2 +- packages/block-library/src/query/index.php | 2 +- packages/block-library/src/search/index.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/block-library/src/file/index.php b/packages/block-library/src/file/index.php index 24eaff8bac622e..98e068014fa34c 100644 --- a/packages/block-library/src/file/index.php +++ b/packages/block-library/src/file/index.php @@ -65,7 +65,7 @@ function register_block_core_file() { wp_register_script_module( '@wordpress/block-library/file-block', - gutenberg_url( '/build/interactivity/file.min.js' ), + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/file.min.js' ) : '/wp-includes/blocks/file/view.min.js', array( '@wordpress/interactivity' ), defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) ); diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index 3297c57d9eab35..5a1cfde5aaaca6 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -325,7 +325,7 @@ function register_block_core_image() { wp_register_script_module( '@wordpress/block-library/image', - gutenberg_url( '/build/interactivity/image.min.js' ), + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/image.min.js' ) : '/wp-includes/blocks/image/view.min.js', array( '@wordpress/interactivity' ), defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) ); diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 0f67a63e7acf27..07ffd52d734eca 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -1082,7 +1082,7 @@ function register_block_core_navigation() { wp_register_script_module( '@wordpress/block-library/navigation-block', - gutenberg_url( '/build/interactivity/navigation.min.js' ), + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/navigation.min.js' ) : '/wp-includes/blocks/navigation/view.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 5d509607a7dc88..3eb6410a54727c 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -101,7 +101,7 @@ function register_block_core_query() { wp_register_script_module( '@wordpress/block-library/query', - gutenberg_url( '/build/interactivity/query.min.js' ), + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/query.min.js' ) : '/wp-includes/blocks/query/view.min.js', array( array( 'id' => '@wordpress/interactivity', diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index 266eb93ca82a47..bb8f2899b348a5 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -199,7 +199,7 @@ function register_block_core_search() { wp_register_script_module( '@wordpress/block-library/search-block', - gutenberg_url( '/build/interactivity/search.min.js' ), + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/search.min.js' ) : '/wp-includes/blocks/search/view.min.js', array( '@wordpress/interactivity' ), defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) ); From 8b20b81cf0142f4478440c29e3a9beb4fa2c2bfb Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Thu, 25 Jan 2024 11:10:34 +0100 Subject: [PATCH 2/3] Add includes_url --- packages/block-library/src/file/index.php | 4 ++-- packages/block-library/src/image/index.php | 2 +- packages/block-library/src/navigation/index.php | 4 ++-- packages/block-library/src/query/index.php | 2 +- packages/block-library/src/search/index.php | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/block-library/src/file/index.php b/packages/block-library/src/file/index.php index 98e068014fa34c..738ca57c02622e 100644 --- a/packages/block-library/src/file/index.php +++ b/packages/block-library/src/file/index.php @@ -64,8 +64,8 @@ function register_block_core_file() { ); wp_register_script_module( - '@wordpress/block-library/file-block', - defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/file.min.js' ) : '/wp-includes/blocks/file/view.min.js', + '@wordpress/block-library/file', + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/file.min.js' ) : includes_url( 'blocks/file/view.min.js' ), array( '@wordpress/interactivity' ), defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) ); diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index 5a1cfde5aaaca6..f926890c1a3fc2 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -325,7 +325,7 @@ function register_block_core_image() { wp_register_script_module( '@wordpress/block-library/image', - defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/image.min.js' ) : '/wp-includes/blocks/image/view.min.js', + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/image.min.js' ) : includes_url( 'blocks/image/view.min.js' ), array( '@wordpress/interactivity' ), defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) ); diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 07ffd52d734eca..9dfbdbf6281294 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -1081,8 +1081,8 @@ function register_block_core_navigation() { ); wp_register_script_module( - '@wordpress/block-library/navigation-block', - defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/navigation.min.js' ) : '/wp-includes/blocks/navigation/view.min.js', + '@wordpress/block-library/navigation', + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/navigation.min.js' ) : includes_url( 'blocks/navigation/view.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 3eb6410a54727c..e21601b1711872 100644 --- a/packages/block-library/src/query/index.php +++ b/packages/block-library/src/query/index.php @@ -101,7 +101,7 @@ function register_block_core_query() { wp_register_script_module( '@wordpress/block-library/query', - defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/query.min.js' ) : '/wp-includes/blocks/query/view.min.js', + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/query.min.js' ) : includes_url( 'blocks/query/view.min.js' ), array( array( 'id' => '@wordpress/interactivity', diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index bb8f2899b348a5..4ee6e9796ced97 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -198,8 +198,8 @@ function register_block_core_search() { ); wp_register_script_module( - '@wordpress/block-library/search-block', - defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/search.min.js' ) : '/wp-includes/blocks/search/view.min.js', + '@wordpress/block-library/search', + defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ? gutenberg_url( '/build/interactivity/search.min.js' ) : includes_url( 'blocks/search/view.min.js' ), array( '@wordpress/interactivity' ), defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' ) ); From 06c04fdfe871282045df6fe7c906262ce3277906 Mon Sep 17 00:00:00 2001 From: Luis Herranz Date: Thu, 25 Jan 2024 12:20:14 +0100 Subject: [PATCH 3/3] Update enqueue module identifiers --- packages/block-library/src/file/index.php | 2 +- packages/block-library/src/navigation/index.php | 2 +- packages/block-library/src/search/index.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/block-library/src/file/index.php b/packages/block-library/src/file/index.php index 738ca57c02622e..06eb10cf1d895b 100644 --- a/packages/block-library/src/file/index.php +++ b/packages/block-library/src/file/index.php @@ -38,7 +38,7 @@ static function ( $matches ) { // If it's interactive, enqueue the script module and add the directives. if ( ! empty( $attributes['displayPreview'] ) ) { - wp_enqueue_script_module( '@wordpress/block-library/file-block' ); + wp_enqueue_script_module( '@wordpress/block-library/file' ); $processor = new WP_HTML_Tag_Processor( $content ); $processor->next_tag(); diff --git a/packages/block-library/src/navigation/index.php b/packages/block-library/src/navigation/index.php index 9dfbdbf6281294..a0672a0bed5801 100644 --- a/packages/block-library/src/navigation/index.php +++ b/packages/block-library/src/navigation/index.php @@ -567,7 +567,7 @@ private static function get_nav_element_directives( $is_interactive, $attributes */ private static function handle_view_script_module_loading( $attributes, $block, $inner_blocks ) { if ( static::is_interactive( $attributes, $inner_blocks ) ) { - wp_enqueue_script_module( '@wordpress/block-library/navigation-block' ); + wp_enqueue_script_module( '@wordpress/block-library/navigation' ); } } diff --git a/packages/block-library/src/search/index.php b/packages/block-library/src/search/index.php index 4ee6e9796ced97..ce4277601937b8 100644 --- a/packages/block-library/src/search/index.php +++ b/packages/block-library/src/search/index.php @@ -80,7 +80,7 @@ function render_block_core_search( $attributes ) { // If it's interactive, enqueue the script module and add the directives. $is_expandable_searchfield = 'button-only' === $button_position; if ( $is_expandable_searchfield ) { - wp_enqueue_script_module( '@wordpress/block-library/search-block' ); + wp_enqueue_script_module( '@wordpress/block-library/search' ); $input->set_attribute( 'data-wp-bind--aria-hidden', '!context.isSearchInputVisible' ); $input->set_attribute( 'data-wp-bind--tabindex', 'state.tabindex' );