[LYS] Regenerate share key on the fly (#46662)

* Add logic to regenerate the share key if it's not set in LaunchYourStore.php

* Add changelog

* Use add_option directly
This commit is contained in:
Chi-Hsuan Huang 2024-04-18 19:39:23 +12:00 committed by GitHub
parent 5e7962af67
commit ea27c1f364
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: enhancement
Regenerate share key on the fly

View File

@ -70,6 +70,9 @@ class LaunchYourStore {
$is_setting_page = $current_screen && 'woocommerce_page_wc-settings' === $current_screen->id; $is_setting_page = $current_screen && 'woocommerce_page_wc-settings' === $current_screen->id;
if ( $is_setting_page ) { if ( $is_setting_page ) {
// Regnerate the share key if it's not set.
add_option( 'woocommerce_share_key', wp_generate_password( 32, false ) );
$settings['siteVisibilitySettings'] = array( $settings['siteVisibilitySettings'] = array(
'shop_permalink' => get_permalink( wc_get_page_id( 'shop' ) ), 'shop_permalink' => get_permalink( wc_get_page_id( 'shop' ) ),
'woocommerce_coming_soon' => get_option( 'woocommerce_coming_soon' ), 'woocommerce_coming_soon' => get_option( 'woocommerce_coming_soon' ),