Add `woocommerce_coming_soon` option for all sites (#50581)

* Add woocommerce_coming_soon option for all sites

* Set default option

* Add changelog

* Update `woocommerce_coming_soon` option to use `update_option` instead of `add_option`
This commit is contained in:
Chi-Hsuan Huang 2024-08-14 09:37:31 +08:00 committed by GitHub
parent 75c18a6902
commit bb7dbf9e3c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 31 additions and 3 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: update
Add woocommerce_coming_soon option for all sites

View File

@ -262,6 +262,9 @@ class WC_Install {
'9.2.0' => array(
'wc_update_920_add_wc_hooked_blocks_version_option',
),
'9.3.0' => array(
'wc_update_930_add_woocommerce_coming_soon_option',
),
);
/**
@ -292,6 +295,7 @@ class WC_Install {
add_action( 'init', array( __CLASS__, 'check_version' ), 5 );
add_action( 'init', array( __CLASS__, 'manual_database_update' ), 20 );
add_action( 'woocommerce_newly_installed', array( __CLASS__, 'maybe_enable_hpos' ), 20 );
add_action( 'woocommerce_newly_installed', array( __CLASS__, 'add_coming_soon_option' ), 20 );
add_action( 'admin_init', array( __CLASS__, 'wc_admin_db_update_notice' ) );
add_action( 'admin_init', array( __CLASS__, 'add_admin_note_after_page_created' ) );
add_action( 'woocommerce_run_update_callback', array( __CLASS__, 'run_update_callback' ) );
@ -986,6 +990,17 @@ class WC_Install {
}
}
/**
* Add the woocommerce_coming_soon option for new shops.
*
* Ensure that the option is set for all shops, even if core profiler is disabled on the host.
*
* @since 9.3.0
*/
public static function add_coming_soon_option() {
add_option( 'woocommerce_coming_soon', 'no' );
}
/**
* Checks whether HPOS should be enabled for new shops.
*

View File

@ -2779,14 +2779,16 @@ function wc_update_920_add_wc_hooked_blocks_version_option() {
function wc_update_910_remove_obsolete_user_meta() {
global $wpdb;
$deletions = $wpdb->query( "
$deletions = $wpdb->query(
"
DELETE FROM $wpdb->usermeta
WHERE meta_key IN (
'_last_order',
'_order_count',
'_money_spent'
)
" );
"
);
$logger = wc_get_logger();
@ -2815,3 +2817,10 @@ function wc_update_910_remove_obsolete_user_meta() {
);
}
}
/**
* Add woocommerce_coming_soon option when it is not currently present.
*/
function wc_update_930_add_woocommerce_coming_soon_option() {
add_option( 'woocommerce_coming_soon', 'no' );
}

View File

@ -133,7 +133,7 @@ class LaunchYourStore {
$private_link = 'no';
$share_key = wp_generate_password( 32, false );
add_option( 'woocommerce_coming_soon', $coming_soon );
update_option( 'woocommerce_coming_soon', $coming_soon );
add_option( 'woocommerce_store_pages_only', $store_pages_only );
add_option( 'woocommerce_private_link', $private_link );
add_option( 'woocommerce_share_key', $share_key );