From d562fbdc5c647b478a721ac98cb7e74b7cdae4c3 Mon Sep 17 00:00:00 2001 From: Moon Date: Thu, 26 Oct 2023 23:09:05 -0700 Subject: [PATCH] Fix CYS JS conflict error latest Gutenberg version (#41052) * dequeue wpcom.editor on cys pages * Add gutenberg_version to wcSettings.admin * Use the new consent string for Gutenberg 16.9 and above * Add changefile(s) from automation for the following project(s): woocommerce * Revert "dequeue wpcom.editor on cys pages" This reverts commit 85c039c7dca7f593ac1e60efb1f3add45a18403d. * Update changelog * Add changefile(s) from automation for the following project(s): woocommerce * Revert "Add changefile(s) from automation for the following project(s): woocommerce" This reverts commit 4554626fded217fbb40675cf17be76e26bfc77c7. * Fix lint issues --------- Co-authored-by: github-actions Co-authored-by: Adrian Duffell <9312929+adrianduffell@users.noreply.github.com> --- .../bin/modified-editsite-lock-unlock.js | 27 +++++++++++++------ ...customize-blank-issue-with-wp-6.4-followup | 4 +++ .../src/Internal/Admin/Settings.php | 2 ++ 3 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 plugins/woocommerce/changelog/41052-update-40840-customize-blank-issue-with-wp-6.4-followup diff --git a/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js b/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js index a9f0ec06e02..499d4e6e54e 100644 --- a/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js +++ b/plugins/woocommerce-admin/bin/modified-editsite-lock-unlock.js @@ -3,16 +3,27 @@ */ import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; -let consentString = +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.'; -if ( window.wcSettings && window.wcSettings.wpVersion ) { - // Parse the version string as a floating-point number - const wpVersion = parseFloat( window.wcSettings.wpVersion ); - if ( ! isNaN( wpVersion ) && wpVersion >= 6.4 ) { - consentString = - 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.'; - } +let consentString = oldConsentString; +const wcSettings = window.wcSettings; +const admin = wcSettings?.admin; + +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; +} + +// 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 } = diff --git a/plugins/woocommerce/changelog/41052-update-40840-customize-blank-issue-with-wp-6.4-followup b/plugins/woocommerce/changelog/41052-update-40840-customize-blank-issue-with-wp-6.4-followup new file mode 100644 index 00000000000..df7f8606a81 --- /dev/null +++ b/plugins/woocommerce/changelog/41052-update-40840-customize-blank-issue-with-wp-6.4-followup @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Fix blank assember hub (CYS) issue on WP 6.3 + latest Gutenberg. diff --git a/plugins/woocommerce/src/Internal/Admin/Settings.php b/plugins/woocommerce/src/Internal/Admin/Settings.php index 24dc4b60b00..8b3c7fcdee4 100644 --- a/plugins/woocommerce/src/Internal/Admin/Settings.php +++ b/plugins/woocommerce/src/Internal/Admin/Settings.php @@ -239,6 +239,8 @@ class Settings { $settings['isWooPayEligible'] = WCPayPromotionInit::is_woopay_eligible(); + $settings['gutenberg_version'] = defined( 'GUTENBERG_VERSION' ) ? constant( 'GUTENBERG_VERSION' ) : 0; + return $settings; }