From a91df30b716ad8687a563d4f9205514009797bea Mon Sep 17 00:00:00 2001 From: oskosk Date: Fri, 17 Feb 2023 12:43:27 -0300 Subject: [PATCH] Update the defaults for stb_enabled and stc_enabled according to subscriptions being auto-activated so to not update the frontend unintentionally --- .../plugins/jetpack/modules/comments/comments.php | 6 +++--- projects/plugins/jetpack/modules/subscriptions.php | 14 ++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/projects/plugins/jetpack/modules/comments/comments.php b/projects/plugins/jetpack/modules/comments/comments.php index d1da4f8266c92..da9318e88f986 100644 --- a/projects/plugins/jetpack/modules/comments/comments.php +++ b/projects/plugins/jetpack/modules/comments/comments.php @@ -281,12 +281,12 @@ public function comment_form_after() { ) . '

'; return; } - if ( in_array( 'subscriptions', Jetpack::get_active_modules(), true ) ) { - $stb_enabled = get_option( 'stb_enabled', 1 ); + $default = jetpack_get_module_info( 'subscriptions' )['auto_activate'] === 'No' ? 1 : 0; + $stb_enabled = get_option( 'stb_enabled', $default ); $stb_enabled = empty( $stb_enabled ) ? 0 : 1; - $stc_enabled = get_option( 'stc_enabled', 1 ); + $stc_enabled = get_option( 'stc_enabled', $default ); $stc_enabled = empty( $stc_enabled ) ? 0 : 1; } else { $stb_enabled = 0; diff --git a/projects/plugins/jetpack/modules/subscriptions.php b/projects/plugins/jetpack/modules/subscriptions.php index d96f78210c493..c8b20adfe52e2 100644 --- a/projects/plugins/jetpack/modules/subscriptions.php +++ b/projects/plugins/jetpack/modules/subscriptions.php @@ -418,8 +418,11 @@ public function subscriptions_settings_section() { * Post Subscriptions Toggle. */ public function subscription_post_subscribe_setting() { - - $stb_enabled = get_option( 'stb_enabled', 1 ); + // Keep the previous behaviour after updating subscription to autoactivate + // So we don't update the frontend for new users of Jetpack + // https://github.com/Automattic/jetpack/pull/29028 + $default = jetpack_get_module_info( 'subscriptions' )['auto_activate'] === 'No' ? 1 : 0; + $stb_enabled = get_option( 'stb_enabled', $default ); ?>

@@ -441,8 +444,11 @@ public function subscription_post_subscribe_setting() { * Comments Subscriptions Toggle. */ public function subscription_comment_subscribe_setting() { - - $stc_enabled = get_option( 'stc_enabled', 1 ); + // Keep the previous behaviour after updating subscription to autoactivate + // So we don't update the frontend for new users of Jetpack + // https://github.com/Automattic/jetpack/pull/29028 + $default = jetpack_get_module_info( 'subscriptions' )['auto_activate'] === 'No' ? 1 : 0; + $stc_enabled = get_option( 'stc_enabled', $default ); ?>