Skip to content

Commit

Permalink
Prevent usage of gutenberg_url in block-library (#58242)
Browse files Browse the repository at this point in the history
* Prevent usage of gutenberg_url in block-library

* Add includes_url

* Update enqueue module identifiers
  • Loading branch information
luisherranz authored and cbravobernal committed Jan 25, 2024
1 parent 1a220b5 commit 385bf9f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions packages/block-library/src/file/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -64,8 +64,8 @@ function register_block_core_file() {
);

wp_register_script_module(
'@wordpress/block-library/file-block',
gutenberg_url( '/build/interactivity/file.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' )
);
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) : includes_url( 'blocks/image/view.min.js' ),
array( '@wordpress/interactivity' ),
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
);
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
}
}

Expand Down Expand Up @@ -1081,8 +1081,8 @@ function register_block_core_navigation() {
);

wp_register_script_module(
'@wordpress/block-library/navigation-block',
gutenberg_url( '/build/interactivity/navigation.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' )
);
Expand Down
2 changes: 1 addition & 1 deletion packages/block-library/src/query/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) : includes_url( 'blocks/query/view.min.js' ),
array(
array(
'id' => '@wordpress/interactivity',
Expand Down
6 changes: 3 additions & 3 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -198,8 +198,8 @@ function register_block_core_search() {
);

wp_register_script_module(
'@wordpress/block-library/search-block',
gutenberg_url( '/build/interactivity/search.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' )
);
Expand Down

0 comments on commit 385bf9f

Please sign in to comment.