Skip to content

Commit 5ab97e2

Browse files
authored
Feature gating for Donations payment block (#46374)
* WIP: feature gating for payments Donations will work with this change but Paypal needs more work * changelog * Features coming from Free do not work on Atomic Adjust accordingly. We'll have to use the same pattern for all gated Payments features
1 parent a3795e3 commit 5ab97e2

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: other
3+
4+
Feature gating for two blocks

projects/plugins/jetpack/class.jetpack-gutenberg.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,23 @@ private static function get_site_specific_features() {
12331233
return $site_specific_features;
12341234
}
12351235

1236+
/**
1237+
* Get default required plan for blocks that need a fallback when no plan is found in features data.
1238+
* This ensures upgrade banners appear for blocks that are available via WPCOM_ALL_SITES/JETPACK_ALL_SITES
1239+
* but should still show upgrade prompts.
1240+
*
1241+
* @param string $slug Block slug.
1242+
* @return string|false Plan slug if a default should be used, false otherwise.
1243+
*/
1244+
private static function get_default_plan_for_block( $slug ) {
1245+
$default_plans = array(
1246+
'donations' => 'value_bundle', // Premium plan slug for WordPress.com.
1247+
'payment-buttons' => 'value_bundle', // Premium plan slug for WordPress.com.
1248+
);
1249+
1250+
return isset( $default_plans[ $slug ] ) ? $default_plans[ $slug ] : false;
1251+
}
1252+
12361253
/**
12371254
* Set the availability of the block as the editor
12381255
* is loaded.
@@ -1268,6 +1285,13 @@ public static function set_availability_for_plan( $slug ) {
12681285
if ( ! empty( $features_data['available'][ $slug ] ) ) {
12691286
$plan = $features_data['available'][ $slug ][0];
12701287
}
1288+
1289+
if ( empty( $plan ) ) {
1290+
$default_plan = self::get_default_plan_for_block( $slug );
1291+
if ( $default_plan ) {
1292+
$plan = $default_plan;
1293+
}
1294+
}
12711295
} else {
12721296
// Jetpack sites.
12731297
$plan = Jetpack_Plan::get_minimum_plan_for_feature( $slug );

projects/plugins/jetpack/extensions/blocks/donations/donations.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function register_block() {
3131
__DIR__,
3232
array(
3333
'render_callback' => __NAMESPACE__ . '\render_block',
34+
'plan_check' => true,
3435
)
3536
);
3637
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: changed
3+
4+
Feature gating for two blocks

projects/plugins/wpcomsh/wpcom-features/class-wpcom-features.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,15 @@ class WPCOM_Features {
731731
self::WOO_HOSTED_PLANS,
732732
),
733733
self::DONATIONS => array(
734-
self::WPCOM_ALL_SITES,
734+
array(
735+
'sticker_not_present' => 'gating-business-q1',
736+
self::WPCOM_ALL_SITES,
737+
),
738+
array(
739+
'sticker_not_present' => 'gating-business-q1',
740+
self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
741+
),
742+
self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
735743
self::JETPACK_ALL_SITES,
736744
),
737745
// ECOMMERCE_MANAGED_PLUGINS - Can install the plugin bundle that comes with eCommerce plans.

0 commit comments

Comments
 (0)