Skip to content

Commit

Permalink
Subscribe modal: remove filters and enable for Jetpack sites (#33909)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Brandon Kraft <[email protected]>
  • Loading branch information
simison and kraftbj authored Nov 16, 2023
1 parent 7c19c59 commit c92668f
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Always enable subscribe modal task in launchpad.
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,6 @@ function wpcom_launchpad_get_task_definitions() {
return __( 'Enable subscribers modal', 'jetpack-mu-wpcom' );
},
'is_complete_callback' => 'wpcom_launchpad_is_task_option_completed',
'is_visible_callback' => 'wpcom_launchpad_is_enable_subscribers_modal_visible',
'get_calypso_path' => function ( $task, $default, $data ) {
return '/settings/newsletter/' . $data['site_slug_encoded'];
},
Expand Down Expand Up @@ -1370,15 +1369,6 @@ function wpcom_launchpad_mark_enable_subscribers_modal_complete( $old_value, $va
add_action( 'update_option_sm_enabled', 'wpcom_launchpad_mark_enable_subscribers_modal_complete', 10, 3 );
add_action( 'add_option_sm_enabled', 'wpcom_launchpad_mark_enable_subscribers_modal_complete', 10, 3 );

/**
* Determines whether the enable_subscribers_modal task should show.
*
* @return bool True if the task should show, false otherwise.
*/
function wpcom_launchpad_is_enable_subscribers_modal_visible() {
return apply_filters( 'jetpack_subscriptions_modal_enabled', false );
}

/**
* Determine `domain_claim` task visibility.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import React, { useCallback } from 'react';
import { connect } from 'react-redux';
import { isCurrentUserLinked, isUnavailableInOfflineMode, isOfflineMode } from 'state/connection';
import {
isSubscriptionModalEnabled,
currentThemeIsBlockTheme,
currentThemeStylesheet,
getSiteAdminUrl,
Expand All @@ -33,7 +32,6 @@ const trackViewSubsClick = () => {
*/
function SubscriptionsSettings( props ) {
const {
hasSubscriptionModal,
unavailableInOfflineMode,
isLinked,
isOffline,
Expand Down Expand Up @@ -149,36 +147,32 @@ function SubscriptionsSettings( props ) {
'jetpack'
) }
/>
{ hasSubscriptionModal && (
<>
<ToggleControl
checked={ isSubscriptionsActive && isSmEnabled }
disabled={
! isSubscriptionsActive ||
unavailableInOfflineMode ||
isSavingAnyOption( [ 'subscriptions' ] ) ||
! isLinked
}
toggling={ isSavingAnyOption( [ 'sm_enabled' ] ) }
onChange={ handleSubscribeModalToggleChange }
label={ __( 'Enable subscriber pop-up', 'jetpack' ) }
/>
<p className="jp-form-setting-explanation">
{ __(
'Automatically add a subscribe form pop-up to every post and turn visitors into subscribers. It will appear as readers scroll through your posts.',
'jetpack'
) }
{ isBlockTheme && subscribeModalEditorUrl && (
<>
{ ' ' }
<ExternalLink href={ subscribeModalEditorUrl }>
{ __( 'Preview and edit the pop-up', 'jetpack' ) }
</ExternalLink>
</>
) }
</p>
</>
) }
<ToggleControl
checked={ isSubscriptionsActive && isSmEnabled }
disabled={
! isSubscriptionsActive ||
unavailableInOfflineMode ||
isSavingAnyOption( [ 'subscriptions' ] ) ||
! isLinked
}
toggling={ isSavingAnyOption( [ 'sm_enabled' ] ) }
onChange={ handleSubscribeModalToggleChange }
label={ __( 'Enable subscriber pop-up', 'jetpack' ) }
/>
<p className="jp-form-setting-explanation">
{ __(
'Automatically add a subscribe form pop-up to every post and turn visitors into subscribers. It will appear as readers scroll through your posts.',
'jetpack'
) }
{ isBlockTheme && subscribeModalEditorUrl && (
<>
{ ' ' }
<ExternalLink href={ subscribeModalEditorUrl }>
{ __( 'Preview and edit the pop-up', 'jetpack' ) }
</ExternalLink>
</>
) }
</p>
</FormFieldset>
}
</SettingsGroup>
Expand All @@ -201,7 +195,6 @@ export default withModuleSettingsFormHelpers(
isLinked: isCurrentUserLinked( state ),
isOffline: isOfflineMode( state ),
isSubscriptionsActive: ownProps.getOptionValue( 'subscriptions' ),
hasSubscriptionModal: isSubscriptionModalEnabled( state ),
unavailableInOfflineMode: isUnavailableInOfflineMode( state, 'subscriptions' ),
subscriptions: getModule( state, 'subscriptions' ),
isStbEnabled: ownProps.getOptionValue( 'stb_enabled' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,16 +700,6 @@ export function isBlazeDashboardEnabled( state ) {
return !! state.jetpack.initialState.isBlazeDashboardEnabled;
}

/**
* Returns true if Subscribe Modal can be used on the site.
*
* @param {object} state - Global state tree.
* @returns {boolean} True if Subscription Modal is available on the site.
*/
export function isSubscriptionModalEnabled( state ) {
return !! state.jetpack.initialState.isSubscriptionModalEnabled;
}

/**
* Returns true if Jetpack's Pre-connection helpers are enabled.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,6 @@ public static function get_initial_state() {
'isOdysseyStatsEnabled' => Stats_Options::get_option( 'enable_odyssey_stats' ),
'shouldInitializeBlaze' => Blaze::should_initialize(),
'isBlazeDashboardEnabled' => Blaze::is_dashboard_enabled(),
/** This filter is documented in plugins/jetpack/modules/subscriptions/subscribe-module/class-jetpack-subscribe-module.php */
'isSubscriptionModalEnabled' => apply_filters( 'jetpack_subscriptions_modal_enabled', false ),
'socialInitialState' => self::get_publicize_initial_state(),
'gutenbergInitialState' => self::get_gutenberg_initial_state(),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: enhancement

Add subscribe modal to Newsletter settings
25 changes: 11 additions & 14 deletions projects/plugins/jetpack/modules/subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,18 @@ public function configure() {

/** Enable Subscribe Modal */

/** This filter is documented in plugins/jetpack/modules/subscriptions/subscribe-module/class-jetpack-subscribe-module.php */
if ( apply_filters( 'jetpack_subscriptions_modal_enabled', false ) ) {
add_settings_field(
'jetpack_subscriptions_comment_subscribe',
__( 'Enable Subscribe Modal', 'jetpack' ),
array( $this, 'subscribe_modal_setting' ),
'discussion',
'jetpack_subscriptions'
);
add_settings_field(
'jetpack_subscriptions_comment_subscribe',
__( 'Enable Subscribe Modal', 'jetpack' ),
array( $this, 'subscribe_modal_setting' ),
'discussion',
'jetpack_subscriptions'
);

register_setting(
'discussion',
'sm_enabled'
);
}
register_setting(
'discussion',
'sm_enabled'
);

/** Email me whenever: Someone follows my blog */
/* @since 8.1 */
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


0 comments on commit c92668f

Please sign in to comment.