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 <github-actions@github.com>
This commit is contained in:
Luigi Teschio 2024-06-20 10:00:47 +02:00 committed by GitHub
parent 0a411dd352
commit 9905b05297
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 25 deletions

View File

@ -1,34 +1,29 @@
/** /**
* WordPress dependencies * External dependencies
*/ */
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis'; import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';
const oldConsentString = const wordPressConsentString = {
'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.'; 6.4: 'I know using unstable features means my plugin or theme will inevitably break on the next WordPress release.',
const newConsentString = 6.5: 'I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.',
'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; function optInToUnstableAPIs() {
const wcSettings = window.wcSettings; let error;
const admin = wcSettings?.admin; for ( const optInString of Object.values( wordPressConsentString ) ) {
try {
const wpVersion = parseFloat( wcSettings?.wpVersion ); return __dangerousOptInToUnstableAPIsOnlyForCoreModules(
const gutenbergVersion = parseFloat( admin?.gutenberg_version ); optInString,
// 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 } =
__dangerousOptInToUnstableAPIsOnlyForCoreModules(
consentString,
'@wordpress/edit-site' '@wordpress/edit-site'
); );
} catch ( anError ) {
error = anError;
}
}
throw error;
}
export const { lock, unlock } = optInToUnstableAPIs();
//# sourceMappingURL=lock-unlock.js.map //# sourceMappingURL=lock-unlock.js.map

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
CYS: fix crash of CYS on WordPress 6.6