From 9905b05297d86b6fa7c72c7e79ef9c219b7de2a8 Mon Sep 17 00:00:00 2001 From: Luigi Teschio Date: Thu, 20 Jun 2024 10:00:47 +0200 Subject: [PATCH] CYS: fix crash of CYS on WordPress 6.6 (#48664) * CYS: fix crash of CYS on WordPress 6.6 * Add changefile(s) from automation for the following project(s): woocommerce * CYS: fix crash of CYS on WordPress 6.6 --------- Co-authored-by: github-actions --- .../bin/modified-editsite-lock-unlock.js | 45 +++++++++---------- ...ys-assembler-is-not-loaded-on-wordpress-66 | 4 ++ 2 files changed, 24 insertions(+), 25 deletions(-) create mode 100644 plugins/woocommerce/changelog/48664-48663-cys-assembler-is-not-loaded-on-wordpress-66 diff --git a/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js b/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js index 499d4e6e54e..140c67f8930 100644 --- a/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js +++ b/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js @@ -1,34 +1,29 @@ /** - * WordPress dependencies + * External dependencies */ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; -const oldConsentString = - 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.'; -const newConsentString = - 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.'; +const wordPressConsentString = { + 6.4: 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.', + 6.5: 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', + 6.6: 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', +}; -let consentString = oldConsentString; -const wcSettings = window.wcSettings; -const admin = wcSettings?.admin; +function optInToUnstableAPIs() { + let error; + for ( const optInString of Object.values( wordPressConsentString ) ) { + try { + return __dangerousOptInToUnstableAPIsOnlyForCoreModules( + optInString, + '@wordpress/edit-site' + ); + } catch ( anError ) { + error = anError; + } + } -const wpVersion = parseFloat( wcSettings?.wpVersion ); -const gutenbergVersion = parseFloat( admin?.gutenberg_version ); - -// Use the new consent string if the WP version is 6.4 and above -if ( ! isNaN( wpVersion ) && wpVersion >= 6.4 ) { - consentString = newConsentString; + throw error; } -// Users can install the latest Gutenberg plugin manually -// Use the new consent string for Gutenberg 16.9 and above -if ( ! isNaN( gutenbergVersion ) && gutenbergVersion >= 16.9 ) { - consentString = newConsentString; -} - -export const { lock, unlock } = - __dangerousOptInToUnstableAPIsOnlyForCoreModules( - consentString, - '@wordpress/edit-site' - ); +export const { lock, unlock } = optInToUnstableAPIs(); //# sourceMappingURL=lock-unlock.js.map diff --git a/plugins/woocommerce/changelog/48664-48663-cys-assembler-is-not-loaded-on-wordpress-66 b/plugins/woocommerce/changelog/48664-48663-cys-assembler-is-not-loaded-on-wordpress-66 new file mode 100644 index 00000000000..52b65738e40 --- /dev/null +++ b/plugins/woocommerce/changelog/48664-48663-cys-assembler-is-not-loaded-on-wordpress-66 @@ -0,0 +1,4 @@ +Significance: patch +Type: fix + +CYS: fix crash of CYS on WordPress 6.6 \ No newline at end of file