Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetpack: Auto-activate Subscriptions #29028

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2541,14 +2541,20 @@ public static function get_updateable_data_list( $selector = '' ) {
'stb_enabled' => array(
'description' => esc_html__( "Show a <em>'follow blog'</em> option in the comment form", 'jetpack' ),
'type' => 'boolean',
'default' => 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,
'validate_callback' => __CLASS__ . '::validate_boolean',
'jp_group' => 'subscriptions',
),
'stc_enabled' => array(
'description' => esc_html__( "Show a <em>'follow comments'</em> option in the comment form", 'jetpack' ),
'type' => 'boolean',
'default' => 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,
'validate_callback' => __CLASS__ . '::validate_boolean',
'jp_group' => 'subscriptions',
),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

Autoactivate Subscriptions
6 changes: 3 additions & 3 deletions projects/plugins/jetpack/modules/comments/comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,12 @@ public function comment_form_after() {
) . '</p>';
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;
Expand Down
24 changes: 17 additions & 7 deletions projects/plugins/jetpack/modules/subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* First Introduced: 1.2
* Requires Connection: Yes
* Requires User Connection: Yes
* Auto Activate: No
* Auto Activate: Yes
* Module Tags: Social
* Feature: Engagement
* Additional Search Queries: subscriptions, subscription, email, follow, followers, subscribers, signup
Expand Down Expand Up @@ -414,12 +414,23 @@ public function subscriptions_settings_section() {
<?php
}

/**
* Returns the default value for the options stc_enabled and stb_enabled
* that should be assumed depending on the Auto-activate status of the
* subscriptions module.
* We 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
*/
public function stc_stb_default_value() {
return jetpack_get_module_info( 'subscriptions' )['auto_activate'] === 'No' ? 1 : 0;
}

/**
* Post Subscriptions Toggle.
*/
public function subscription_post_subscribe_setting() {

$stb_enabled = get_option( 'stb_enabled', 1 );
$stb_enabled = get_option( 'stb_enabled', $this->stc_stb_default_value() );
?>

<p class="description">
Expand All @@ -441,8 +452,7 @@ public function subscription_post_subscribe_setting() {
* Comments Subscriptions Toggle.
*/
public function subscription_comment_subscribe_setting() {

$stc_enabled = get_option( 'stc_enabled', 1 );
$stc_enabled = get_option( 'stc_enabled', $this->stc_stb_default_value() );
?>

<p class="description">
Expand Down Expand Up @@ -809,7 +819,7 @@ public function comment_subscribe_init( $submit_button ) {

$str = '';

if ( false === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 === (int) get_option( 'stc_enabled', 1 ) && empty( $post->post_password ) && 'post' === get_post_type() ) {
if ( false === has_filter( 'comment_form', 'show_subscription_checkbox' ) && 1 === (int) get_option( 'stc_enabled', $this->stc_stb_default_value() ) && empty( $post->post_password ) && 'post' === get_post_type() ) {
// Subscribe to comments checkbox.
$str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_comments" id="subscribe_comments" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $comments_checked . ' /> ';
$comment_sub_text = __( 'Notify me of follow-up comments by email.', 'jetpack' );
Expand All @@ -828,7 +838,7 @@ public function comment_subscribe_init( $submit_button ) {
$str .= '</p>';
}

if ( 1 === (int) get_option( 'stb_enabled', 1 ) ) {
if ( 1 === (int) get_option( 'stb_enabled', $this->stc_stb_default_value() ) ) {
// Subscribe to blog checkbox.
$str .= '<p class="comment-subscription-form"><input type="checkbox" name="subscribe_blog" id="subscribe_blog" value="subscribe" style="width: auto; -moz-appearance: checkbox; -webkit-appearance: checkbox;"' . $blog_checked . ' /> ';
$blog_sub_text = __( 'Notify me of new posts by email.', 'jetpack' );
Expand Down