Skip to content

Commit

Permalink
Don't use wp_scripts_get_suffix() in Gutenberg
Browse files Browse the repository at this point in the history
  • Loading branch information
luisherranz committed Feb 8, 2024
1 parent 4408d63 commit 91c5635
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/experimental/interactivity-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
function gutenberg_interactivity_override_script_module_urls( $url ) {
$pattern = '/wp-includes\/js\/dist\/interactivity(-router)?(\.min)?\.js/';
if ( preg_match( $pattern, $url, $matches ) ) {
return gutenberg_url( '/build/interactivity/' . ( $matches[1] ? 'router' : 'index' ) . wp_scripts_get_suffix() . '.js' );
return gutenberg_url( '/build/interactivity/' . ( $matches[1] ? 'router' : 'index' ) . '.min.js' );
}
return $url;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/file/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ static function ( $matches ) {

// If it's interactive, enqueue the script module and add the directives.
if ( ! empty( $attributes['displayPreview'] ) ) {
$suffix = wp_scripts_get_suffix();
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
$module_url = gutenberg_url( "/build/interactivity/file{$suffix}.js" );
$module_url = gutenberg_url( "/build/interactivity/file.min.js" );
}

wp_register_script_module(
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ function render_block_core_image( $attributes, $content, $block ) {
isset( $lightbox_settings['enabled'] ) &&
true === $lightbox_settings['enabled']
) {
$suffix = wp_scripts_get_suffix();
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
$module_url = gutenberg_url( "/build/interactivity/image{$suffix}.js" );
$module_url = gutenberg_url( "/build/interactivity/image.min.js" );
}

wp_register_script_module(
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/navigation/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,8 @@ 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 ) ) {
$suffix = wp_scripts_get_suffix();
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
$module_url = gutenberg_url( "/build/interactivity/navigation{$suffix}.js" );
$module_url = gutenberg_url( "/build/interactivity/navigation.min.js" );
}

wp_register_script_module(
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/query/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ function render_block_core_query( $attributes, $content, $block ) {
// Enqueue the script module and add the necessary directives if the block is
// interactive.
if ( $is_interactive ) {
$suffix = wp_scripts_get_suffix();
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
$module_url = gutenberg_url( "/build/interactivity/query{$suffix}.js" );
$module_url = gutenberg_url( "/build/interactivity/query.min.js" );
}

wp_register_script_module(
Expand Down
3 changes: 1 addition & 2 deletions packages/block-library/src/search/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ 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 ) {
$suffix = wp_scripts_get_suffix();
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
$module_url = gutenberg_url( "/build/interactivity/search{$suffix}.js" );
$module_url = gutenberg_url( "/build/interactivity/search.min.js" );
}

wp_register_script_module(
Expand Down

0 comments on commit 91c5635

Please sign in to comment.