Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit b27eedf

Browse files
committed
Fix Interactivity API runtime registering
1 parent 7ae8b81 commit b27eedf

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/Interactivity/scripts.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,25 @@ function woocommerce_interactivity_move_interactive_scripts_to_the_footer() {
2525
* as a dependency in interactive blocks.
2626
*/
2727
function woocommerce_interactivity_register_runtime() {
28-
$script_path = plugins_url( '../../build/wc-interactivity.js', __FILE__ );
28+
$plugin_path = \Automattic\WooCommerce\Blocks\Package::get_path();
29+
$plugin_url = plugin_dir_url( $plugin_path . '/index.php' );
30+
31+
$file = 'build/wc-interactivity.js';
32+
33+
$file_path = $plugin_path . $file;
34+
$file_url = $plugin_url . $file;
35+
36+
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && file_exists( $file_path ) ) {
37+
$version = filemtime( $file_path );
38+
} else {
39+
$version = \Automattic\WooCommerce\Blocks\Package::get_version();
40+
}
41+
2942
wp_register_script(
3043
'wc-interactivity',
31-
$script_path,
44+
$file_url,
3245
array(),
33-
filemtime( $script_path ),
46+
$version,
3447
true
3548
);
3649
}

0 commit comments

Comments
 (0)