Prevent script caching by using the WC core version to hash Interactivity API assets instead of old WC Blocks version (#44806)

* Prevent script caching by using the WC core version to hash Interactivity API assets instead of old WC Blocks version

* Add changelog entry
This commit is contained in:
Albert Juhé Lluveras 2024-02-21 12:14:45 +01:00 committed by GitHub
parent ccb1fb3d76
commit 6b9e732ebf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Prevent script caching by using the WC core version to hash Interactivity API assets instead of old WC Blocks version

View File

@ -1,4 +1,6 @@
<?php
use Automattic\Jetpack\Constants;
/**
* Move interactive scripts to the footer. This is a temporary measure to make
* it work with `wc_store` and it should be replaced with deferred scripts or
@ -36,7 +38,8 @@ function woocommerce_interactivity_register_runtime() {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG && file_exists( $file_path ) ) {
$version = filemtime( $file_path );
} else {
$version = \Automattic\WooCommerce\Blocks\Package::get_version();
// Use wc- prefix here to prevent collisions when WC Core version catches up to a version previously used by the WC Blocks feature plugin.
$version = 'wc-' . Constants::get_constant( 'WC_VERSION' );
}
wp_register_script(