Skip to content

Commit

Permalink
Gate newsletter feature by using a filter
Browse files Browse the repository at this point in the history
  • Loading branch information
romarioraffington committed Jan 13, 2023
1 parent fa544f1 commit 10190af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
22 changes: 15 additions & 7 deletions projects/plugins/jetpack/class.jetpack-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,13 +684,13 @@ public static function enqueue_block_editor_assets() {
$initial_state = array(
'available_blocks' => self::get_availability(),
'jetpack' => array(
'is_active' => Jetpack::is_connection_ready(),
'is_current_user_connected' => $is_current_user_connected,
'is_active' => Jetpack::is_connection_ready(),
'is_current_user_connected' => $is_current_user_connected,
/** This filter is documented in class.jetpack-gutenberg.php */
'enable_upgrade_nudge' => apply_filters( 'jetpack_block_editor_enable_upgrade_nudge', false ),
'is_private_site' => '-1' === get_option( 'blog_public' ),
'is_coming_soon' => ( function_exists( 'site_is_coming_soon' ) && site_is_coming_soon() ) || (bool) get_option( 'wpcom_public_coming_soon' ),
'is_offline_mode' => $status->is_offline_mode(),
'enable_upgrade_nudge' => apply_filters( 'jetpack_block_editor_enable_upgrade_nudge', false ),
'is_private_site' => '-1' === get_option( 'blog_public' ),
'is_coming_soon' => ( function_exists( 'site_is_coming_soon' ) && site_is_coming_soon() ) || (bool) get_option( 'wpcom_public_coming_soon' ),
'is_offline_mode' => $status->is_offline_mode(),
/**
* Enable the RePublicize UI in the block editor context.
*
Expand All @@ -701,7 +701,15 @@ public static function enqueue_block_editor_assets() {
*
* @param bool true Enable the RePublicize UI in the block editor context. Defaults to true.
*/
'republicize_enabled' => apply_filters( 'jetpack_block_editor_republicize_feature', true ),
'republicize_enabled' => apply_filters( 'jetpack_block_editor_republicize_feature', true ),
/**
* Enable the Paid Newsletters feature in the block editor context.
*
* @since $$next_version$$
*
* @param bool false Enable the Paid Newsletters feature in the block editor context. Defaults to false.
*/
'is_newsletter_feature_enabled' => apply_filters( 'jetpack_subscriptions_newsletter_feature_enabled', false ),
),
'siteFragment' => $status->get_site_suffix(),
'adminUrl' => esc_url( admin_url() ),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getJetpackData } from '@automattic/jetpack-shared-extension-utils';
import { Button, ToolbarButton } from '@wordpress/components';
import { _x, __ } from '@wordpress/i18n';

Expand Down Expand Up @@ -26,9 +27,7 @@ export const getPaidPlanLink = hasNewsletterPlans => {
};

export const isNewsletterFeatureEnabled = () => {
return !! window?.Jetpack_Editor_Initial_State?.available_blocks[
'paid-newsletters-in-subscriptions' // We probably want to introduce a new "extension" instead of reusing this one.
];
return getJetpackData()?.jetpack?.is_newsletter_feature_enabled ?? false;
};

export default function GetAddPaidPlanButton( { context = 'other', hasNewsletterPlans } ) {
Expand Down
1 change: 0 additions & 1 deletion projects/plugins/jetpack/extensions/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"amazon",
"google-docs-embed",
"launchpad-save-modal",
"paid-newsletters-in-subscriptions",
"post-publish-promote-post-panel",
"recipe",
"videopress/video",
Expand Down

0 comments on commit 10190af

Please sign in to comment.