From ea27c1f364caaba24d3e2dd9caacd33f064ec79a Mon Sep 17 00:00:00 2001 From: Chi-Hsuan Huang Date: Thu, 18 Apr 2024 19:39:23 +1200 Subject: [PATCH] [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 --- .../changelog/enhance-regenerate-share-key-on-the-fly | 4 ++++ plugins/woocommerce/src/Admin/Features/LaunchYourStore.php | 3 +++ 2 files changed, 7 insertions(+) create mode 100644 plugins/woocommerce/changelog/enhance-regenerate-share-key-on-the-fly diff --git a/plugins/woocommerce/changelog/enhance-regenerate-share-key-on-the-fly b/plugins/woocommerce/changelog/enhance-regenerate-share-key-on-the-fly new file mode 100644 index 00000000000..41e7caa8aeb --- /dev/null +++ b/plugins/woocommerce/changelog/enhance-regenerate-share-key-on-the-fly @@ -0,0 +1,4 @@ +Significance: patch +Type: enhancement + +Regenerate share key on the fly diff --git a/plugins/woocommerce/src/Admin/Features/LaunchYourStore.php b/plugins/woocommerce/src/Admin/Features/LaunchYourStore.php index 5d3bb3d356a..d166439b2c3 100644 --- a/plugins/woocommerce/src/Admin/Features/LaunchYourStore.php +++ b/plugins/woocommerce/src/Admin/Features/LaunchYourStore.php @@ -70,6 +70,9 @@ class LaunchYourStore { $is_setting_page = $current_screen && 'woocommerce_page_wc-settings' === $current_screen->id; 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( 'shop_permalink' => get_permalink( wc_get_page_id( 'shop' ) ), 'woocommerce_coming_soon' => get_option( 'woocommerce_coming_soon' ),