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

Revert "Add/shield memberships blocks for unconnected jetpack sites" #39376

Merged
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

This file was deleted.

16 changes: 6 additions & 10 deletions projects/plugins/jetpack/extensions/blocks/donations/donations.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@
* registration if we need to.
*/
function register_block() {

require_once JETPACK__PLUGIN_DIR . '/modules/memberships/class-jetpack-memberships.php';
if ( \Jetpack_Memberships::should_enable_monetize_blocks_in_editor() ) {
Blocks::jetpack_register_block(
__DIR__,
array(
'render_callback' => __NAMESPACE__ . '\render_block',
)
);
}
Blocks::jetpack_register_block(
__DIR__,
array(
'render_callback' => __NAMESPACE__ . '\render_block',
)
);
}
add_action( 'init', __NAMESPACE__ . '\register_block' );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function register_block() {
}

require_once JETPACK__PLUGIN_DIR . '/modules/memberships/class-jetpack-memberships.php';
if ( \Jetpack_Memberships::should_enable_monetize_blocks_in_editor() ) {
if ( \Jetpack_Memberships::is_enabled_jetpack_recurring_payments() ) {
Blocks::jetpack_register_block(
__DIR__,
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,17 @@
* registration if we need to.
*/
function register_block() {

require_once JETPACK__PLUGIN_DIR . '/modules/memberships/class-jetpack-memberships.php';
if ( \Jetpack_Memberships::should_enable_monetize_blocks_in_editor() ) {
Blocks::jetpack_register_block(
__DIR__,
array(
'render_callback' => __NAMESPACE__ . '\render_block',
'provides_context' => array(
'premium-content/planId' => 'selectedPlanId', // Deprecated.
'premium-content/planIds' => 'selectedPlanIds',
'isPremiumContentChild' => 'isPremiumContentChild',
),
)
);
}
Blocks::jetpack_register_block(
__DIR__,
array(
'render_callback' => __NAMESPACE__ . '\render_block',
'provides_context' => array(
'premium-content/planId' => 'selectedPlanId', // Deprecated.
'premium-content/planIds' => 'selectedPlanIds',
'isPremiumContentChild' => 'isPremiumContentChild',
),
)
);

register_post_meta(
'post',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
namespace Automattic\Jetpack\Extensions\Subscriptions;

use Automattic\Jetpack\Blocks;
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
use Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service\Abstract_Token_Subscription_Service;
use Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service\Jetpack_Token_Subscription_Service;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Status\Host;
use Jetpack;
use Jetpack_Gutenberg;
Expand Down Expand Up @@ -43,9 +45,10 @@ function register_block() {
return;
}

require_once JETPACK__PLUGIN_DIR . '/modules/memberships/class-jetpack-memberships.php';
if ( \Jetpack_Memberships::should_enable_monetize_blocks_in_editor() ) {

if (
( defined( 'IS_WPCOM' ) && IS_WPCOM )
|| ( ( new Connection_Manager( 'jetpack' ) )->has_connected_owner() && ! ( new Status() )->is_offline_mode() )
) {
Blocks::jetpack_register_block(
__DIR__,
array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
*/

use Automattic\Jetpack\Blocks;
use Automattic\Jetpack\Connection\Manager as Connection_Manager;
use Automattic\Jetpack\Extensions\Premium_Content\Subscription_Service\Abstract_Token_Subscription_Service;
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Status\Host;
use const Automattic\Jetpack\Extensions\Subscriptions\META_NAME_FOR_POST_LEVEL_ACCESS_SETTINGS;
use const Automattic\Jetpack\Extensions\Subscriptions\META_NAME_FOR_POST_TIER_ID_SETTINGS;
Expand Down Expand Up @@ -176,7 +174,7 @@ public static function get_instance() {
self::$instance->register_init_hook();
// Yes, `pro-plan` with a dash, `jetpack_personal` with an underscore. Check the v1.5 endpoint to verify.
$wpcom_plan_slug = defined( 'ENABLE_PRO_PLAN' ) ? 'pro-plan' : 'personal-bundle';
self::$required_plan = ( new Host() )->is_wpcom_simple() ? $wpcom_plan_slug : 'jetpack_personal';
self::$required_plan = ( defined( 'IS_WPCOM' ) && IS_WPCOM ) ? $wpcom_plan_slug : 'jetpack_personal';
}

return self::$instance;
Expand Down Expand Up @@ -745,21 +743,7 @@ public static function user_can_view_post( $post_id = null ) {
* @return bool
*/
public static function is_enabled_jetpack_recurring_payments() {
$api_available = ( new Host() )->is_wpcom_simple() || Jetpack::is_connection_ready();
return $api_available;
}

/**
* Whether to enable the blocks in the editor.
* All Monetize blocks (except Simple Payments) need an active connecting and a user with at least `edit_posts` capability
*
* @return bool
*/
public static function should_enable_monetize_blocks_in_editor() {
$manager = new Connection_Manager( 'jetpack' );
$jetpack_ready_and_user_connected = $manager->is_connected() && $manager->is_user_connected();
$is_offline_mode = ( new Status() )->is_offline_mode();
$api_available = ( new Host() )->is_wpcom_simple() || ( $jetpack_ready_and_user_connected && ! $is_offline_mode );
$api_available = ( ( defined( 'IS_WPCOM' ) && IS_WPCOM ) || Jetpack::is_connection_ready() );
return $api_available;
}

Expand Down
Loading