Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
95.73% covered (success)
95.73%
112 / 117
81.82% covered (warning)
81.82%
9 / 11
CRAP
0.00% covered (danger)
0.00%
0 / 1
WPCOM_Features
95.73% covered (success)
95.73%
112 / 117
81.82% covered (warning)
81.82%
9 / 11
75
0.00% covered (danger)
0.00%
0 / 1
 feature_exists
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 in_array_recursive
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
5
 has_feature
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
8
 add_free_plan_purchase
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 resolve_blog_id
60.00% covered (warning)
60.00%
3 / 5
0.00% covered (danger)
0.00%
0 / 1
3.58
 site_has_sticker
40.00% covered (danger)
40.00%
2 / 5
0.00% covered (danger)
0.00%
0 / 1
10.40
 is_legacy_gating_site
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
1 / 1
8
 get_map_sticker_slugs
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
1 / 1
7
 get_site_gating_cache_suffix
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
4
 purchase_in_products_map
100.00% covered (success)
100.00%
47 / 47
100.00% covered (success)
100.00%
1 / 1
32
 get_feature_slugs
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2/**
3 * THIS FILE EXISTS VERBATIM IN WPCOM AND WPCOMSH.
4 *
5 * DANGER DANGER DANGER!!!
6 * If you make any changes to this class you must MANUALLY update this file in both WPCOM and WPCOMSH.
7 *
8 * @package WPCOM_Features
9 */
10
11/**
12 * Map features to purchases.
13 */
14class WPCOM_Features {
15
16    /**
17     * Key used to exclude plans from features.
18     */
19    public const EXCLUDE_PLANS = 'exclude_plans';
20
21    /**
22     * Sticker marking a site that has switched from legacy features to 2026 feature gating
23     * after plan upgrade/downgrade. One-way change.
24     */
25    public const STICKER_FEATURE_GATING_2026 = 'feature-gating-2026';
26
27    /**
28     * Sticker marking a site that stays on the pre-2026 feature gating regardless of its blog ID.
29     * Only needed for staging sites since they could be created after the cutoff.
30     */
31    public const STICKER_PRE_FEATURE_GATING_2026 = 'pre-feature-gating-2026';
32
33    /**
34     * The original pricing-differentiation sticker. Used for identifying sites with new features
35     * which were created before the cutoff, as part of an experiment.
36     */
37    public const STICKER_GATING_BUSINESS_Q1 = 'gating-business-q1';
38
39    /**
40     * First blog ID guaranteed to carry `gating-business-q1` from creation, after the universal
41     * creation hook was deployed. Using blog ID since we can't get
42     * the blog creation date on WPCloud sites.
43     */
44    public const FEATURE_GATING_2026_CUTOFF_BLOG_ID = 256966305;
45
46    /*
47     * Private const for every mapped purchase, sorted by product_id.
48     */
49    private const SPACE_1GB                                   = 'wordpress_com_1gb_space_addon_yearly';
50    private const SPACE_10GB                                  = '1gb_space_upgrade'; // 9
51    private const SPACE_25GB                                  = '5gb_space_upgrade'; // 10
52    private const SPACE_50GB                                  = '10gb_space_upgrade'; // 11
53    private const NO_ADS                                      = 'no-adverts/no-adverts.php'; // 12
54    private const WPCOM_VIDEOPRESS                            = 'videopress'; // 15
55    private const SPACE_100GB                                 = '50gb_space_upgrade'; // 19
56    private const SPACE_200GB                                 = '100gb_space_upgrade'; // 20
57    private const SPACE_3GB                                   = '3gb_space_upgrade'; // 21
58    private const WPCOM_CUSTOM_DESIGN                         = 'custom-design'; // 45
59    private const WPCOM_VIDEOPRESS_PRO                        = 'videopress-pro'; // 47
60    private const WPCOM_UNLIMITED_THEMES                      = 'unlimited_themes'; // 49
61    private const GAPPS                                       = 'gapps'; // 69
62    private const GAPPS_UNLIMITED                             = 'gapps_unlimited'; // 70
63    private const WP_TITAN_MAIL_MONTHLY                       = 'wp_titan_mail_monthly'; // 400
64    private const WP_TITAN_MAIL_YEARLY                        = 'wp_titan_mail_yearly'; // 401
65    private const WP_TITAN_MAIL_PREMIUM_MONTHLY               = 'wp_titan_mail_premium_monthly'; // 402
66    private const WP_TITAN_MAIL_PREMIUM_YEARLY                = 'wp_titan_mail_premium_yearly'; // 403
67    private const WP_TITAN_MAIL_ULTRA_MONTHLY                 = 'wp_titan_mail_ultra_monthly'; // 404
68    private const WP_TITAN_MAIL_ULTRA_YEARLY                  = 'wp_titan_mail_ultra_yearly'; // 405
69    private const WP_GOOGLE_WORKSPACE_BUSINESS_STARTER_YEARLY = 'wp_google_workspace_business_starter_yearly'; // 690
70    private const WPCOM_SEARCH                                = 'wpcom_search'; // 800
71    private const WPCOM_SEARCH_MONTHLY                        = 'wpcom_search_monthly'; // 801
72    private const YOAST_PREMIUM                               = 'yoast_premium'; // 900
73    private const VALUE_BUNDLE                                = 'value_bundle'; // 1003
74    private const BUNDLE_PRO                                  = 'bundle_pro'; // 1004
75    private const BUNDLE_SUPER                                = 'bundle_super'; // 1005
76    private const BUNDLE_ENTERPRISE                           = 'wpcom-enterprise'; // 1007
77    private const BUSINESS_BUNDLE                             = 'business-bundle'; // 1008
78    private const PERSONAL_BUNDLE                             = 'personal-bundle'; // 1009
79    private const BLOGGER_BUNDLE                              = 'blogger-bundle'; // 1010
80    private const ECOMMERCE_BUNDLE                            = 'ecommerce-bundle'; // 1011
81    private const VALUE_BUNDLE_MONTHLY                        = 'value_bundle_monthly'; // 1013
82    private const PRO_PLAN_MONTHLY                            = 'pro-plan-monthly'; // 1034
83    private const BUSINESS_BUNDLE_MONTHLY                     = 'business-bundle-monthly'; // 1018
84    private const PERSONAL_BUNDLE_MONTHLY                     = 'personal-bundle-monthly'; // 1019
85    private const ECOMMERCE_BUNDLE_MONTHLY                    = 'ecommerce-bundle-monthly'; // 1021
86    private const VALUE_BUNDLE_2Y                             = 'value_bundle-2y'; // 1023
87    private const BUSINESS_BUNDLE_2Y                          = 'business-bundle-2y'; // 1028
88    private const PERSONAL_BUNDLE_2Y                          = 'personal-bundle-2y'; // 1029
89    private const BLOGGER_BUNDLE_2Y                           = 'blogger-bundle-2y'; // 1030
90    private const ECOMMERCE_BUNDLE_2Y                         = 'ecommerce-bundle-2y'; // 1031
91    private const VALUE_BUNDLE_3Y                             = 'value_bundle-3y'; // 1043
92    private const BUSINESS_BUNDLE_3Y                          = 'business-bundle-3y'; // 1048
93    private const PERSONAL_BUNDLE_3Y                          = 'personal-bundle-3y'; // 1049
94    private const ECOMMERCE_BUNDLE_3Y                         = 'ecommerce-bundle-3y'; // 1051
95    private const PRO_PLAN_2Y                                 = 'pro-plan-2y'; // 1035
96    private const PRO_PLAN                                    = 'pro-plan'; // 1032
97    private const STARTER_PLAN                                = 'starter-plan'; // 1033
98    private const WP_P2_PLUS_MONTHLY                          = 'wp_p2_plus_monthly'; // 1040
99    private const ECOMMERCE_TRIAL_BUNDLE_MONTHLY              = 'ecommerce-trial-bundle-monthly'; // 1052
100    private const WPCOM_WOOEXPRESS_MEDIUM_BUNDLE_MONTHLY      = 'wooexpress-medium-bundle-monthly'; // 1053
101    private const WPCOM_WOOEXPRESS_MEDIUM_BUNDLE_YEARLY       = 'wooexpress-medium-bundle-yearly'; // 1055
102    private const WPCOM_WOOEXPRESS_SMALL_BUNDLE_MONTHLY       = 'wooexpress-small-bundle-monthly'; // 1054
103    private const WPCOM_WOOEXPRESS_SMALL_BUNDLE_YEARLY        = 'wooexpress-small-bundle-yearly'; // 1056
104    private const WPCOM_MIGRATION_TRIAL_BUNDLE_MONTHLY        = 'wp_bundle_migration_trial_monthly'; // 1057
105    private const WPCOM_HOSTING_TRIAL_BUNDLE_MONTHLY          = 'wp_bundle_hosting_trial_monthly'; // 1058
106    private const WPCOM_STAGING_PRODUCT                       = 'wp_staging_site_lifetime'; // 1060
107    private const WPCOM_HUNDRED_YEAR_BUNDLE                   = 'wp_com_hundred_year_bundle_centennially'; // 1061
108    private const STUDENT_BUNDLE                              = 'wp_bundle_student_yearly'; // 1090
109    private const JETPACK_PREMIUM                             = 'jetpack_premium'; // 2000
110    private const JETPACK_BUSINESS                            = 'jetpack_business'; // 2001
111    private const JETPACK_FREE                                = 'jetpack_free'; // 2002
112    private const JETPACK_PREMIUM_MONTHLY                     = 'jetpack_premium_monthly'; // 2003
113    private const JETPACK_BUSINESS_MONTHLY                    = 'jetpack_business_monthly'; // 2004
114    private const JETPACK_PERSONAL                            = 'jetpack_personal'; // 2005
115    private const JETPACK_PERSONAL_MONTHLY                    = 'jetpack_personal_monthly'; // 2006
116    private const JETPACK_SECURITY_DAILY                      = 'jetpack_security_daily'; // 2010
117    private const JETPACK_SECURITY_DAILY_MONTHLY              = 'jetpack_security_daily_monthly'; // 2011
118    private const JETPACK_SECURITY_REALTIME                   = 'jetpack_security_realtime'; // 2012
119    private const JETPACK_SECURITY_REALTIME_MONTHLY           = 'jetpack_security_realtime_monthly'; // 2013
120    private const JETPACK_GROWTH_BI_YEARLY                    = 'jetpack_growth_bi_yearly'; // 2023
121    private const JETPACK_GROWTH_YEARLY                       = 'jetpack_growth_yearly'; // 2022
122    private const JETPACK_GROWTH_MONTHLY                      = 'jetpack_growth_monthly'; // 2021
123    private const JETPACK_COMPLETE_BI_YEARLY                  = 'jetpack_complete_bi_yearly'; // 2035
124    private const JETPACK_COMPLETE                            = 'jetpack_complete'; // 2014
125    private const JETPACK_COMPLETE_MONTHLY                    = 'jetpack_complete_monthly'; // 2015
126    private const JETPACK_SECURITY_T0_YEARLY                  = 'jetpack_security_t0_yearly'; // 10237
127    private const JETPACK_SECURITY_T0_MONTHLY                 = 'jetpack_security_t0_monthly'; // 10238
128    private const JETPACK_SECURITY_T1_BI_YEARLY               = 'jetpack_security_t1_bi_yearly'; // 2034
129    private const JETPACK_SECURITY_T1_YEARLY                  = 'jetpack_security_t1_yearly'; // 2016
130    private const JETPACK_SECURITY_T1_MONTHLY                 = 'jetpack_security_t1_monthly'; // 2017
131    private const JETPACK_SECURITY_T2_YEARLY                  = 'jetpack_security_t2_yearly'; // 2019
132    private const JETPACK_SECURITY_T2_MONTHLY                 = 'jetpack_security_t2_monthly'; // 2020
133    private const JETPACK_STARTER_YEARLY                      = 'jetpack_starter_yearly'; // 2030
134    private const JETPACK_STARTER_MONTHLY                     = 'jetpack_starter_monthly'; // 2031
135    private const JETPACK_BACKUP_DAILY                        = 'jetpack_backup_daily'; // 2100
136    private const JETPACK_BACKUP_DAILY_MONTHLY                = 'jetpack_backup_daily_monthly'; // 2101
137    private const JETPACK_BACKUP_REALTIME                     = 'jetpack_backup_realtime'; // 2102
138    private const JETPACK_BACKUP_REALTIME_MONTHLY             = 'jetpack_backup_realtime_monthly'; // 2103
139    private const JETPACK_SEARCH_BI_YEARLY                    = 'jetpack_search_bi_yearly'; // 2031
140    private const JETPACK_SEARCH                              = 'jetpack_search'; // 2104
141    private const JETPACK_SEARCH_MONTHLY                      = 'jetpack_search_monthly'; // 2105
142    private const JETPACK_SCAN_BI_YEARLY                      = 'jetpack_scan_bi_yearly'; // 2038
143    private const JETPACK_SCAN                                = 'jetpack_scan'; // 2106
144    private const JETPACK_SCAN_MONTHLY                        = 'jetpack_scan_monthly'; // 2107
145    private const JETPACK_SCAN_REALTIME                       = 'jetpack_scan_realtime'; // 2108
146    private const JETPACK_SCAN_REALTIME_MONTHLY               = 'jetpack_scan_realtime_monthly'; // 2109
147    private const JETPACK_ANTI_SPAM_BI_YEARLY                 = 'jetpack_anti_spam_bi_yearly'; // 2039
148    private const JETPACK_ANTI_SPAM                           = 'jetpack_anti_spam'; // 2110
149    private const JETPACK_ANTI_SPAM_MONTHLY                   = 'jetpack_anti_spam_monthly'; // 2111
150    private const JETPACK_BACKUP_T1_BI_YEARLY                 = 'jetpack_backup_t1_bi_yearly'; // 2123
151    private const JETPACK_BACKUP_T1_YEARLY                    = 'jetpack_backup_t1_yearly'; // 2112
152    private const JETPACK_BACKUP_T1_MONTHLY                   = 'jetpack_backup_t1_monthly'; // 2113
153    private const JETPACK_BACKUP_T2_YEARLY                    = 'jetpack_backup_t2_yearly'; // 2114
154    private const JETPACK_BACKUP_T2_MONTHLY                   = 'jetpack_backup_t2_monthly'; // 2115
155    private const JETPACK_BACKUP_ADDON_STORAGE_10GB_MONTHLY   = 'jetpack_backup_addon_storage_10gb_monthly'; // 2040
156    private const JETPACK_BACKUP_ADDON_STORAGE_100GB_MONTHLY  = 'jetpack_backup_addon_storage_100gb_monthly'; // 2044
157    private const JETPACK_BACKUP_ADDON_STORAGE_1TB_MONTHLY    = 'jetpack_backup_addon_storage_1tb_monthly'; // 2048
158    private const JETPACK_BACKUP_ADDON_STORAGE_3TB_MONTHLY    = 'jetpack_backup_addon_storage_3tb_monthly'; // 2052
159    private const JETPACK_BACKUP_ADDON_STORAGE_5TB_MONTHLY    = 'jetpack_backup_addon_storage_5tb_monthly'; // 2056
160    private const JETPACK_VIDEOPRESS_BI_YEARLY                = 'jetpack_videopress_bi_yearly'; // 2119
161    private const JETPACK_VIDEOPRESS                          = 'jetpack_videopress'; // 2116
162    private const JETPACK_VIDEOPRESS_MONTHLY                  = 'jetpack_videopress_monthly'; // 2117
163    private const JETPACK_BACKUP_T0_YEARLY                    = 'jetpack_backup_t0_yearly'; // 2120
164    private const JETPACK_BACKUP_T0_MONTHLY                   = 'jetpack_backup_t0_monthly'; // 2121
165    private const JETPACK_SEARCH_FREE                         = 'jetpack_search_free'; // 2130
166    private const JETPACK_BACKUP_ONE_TIME                     = 'jetpack_backup_one_time'; // 2201
167    private const JETPACK_STATS_FREE                          = 'jetpack_stats_free_yearly'; // 2221
168    private const JETPACK_STATS_PWYW                          = 'jetpack_stats_pwyw_yearly'; // 2222
169    private const JETPACK_STATS_MONTHLY                       = 'jetpack_stats_monthly'; // 2220
170    private const JETPACK_STATS_YEARLY                        = 'jetpack_stats_yearly'; // 2219
171    private const JETPACK_STATS_BI_YEARLY                     = 'jetpack_stats_bi_yearly'; // 2223
172    private const JETPACK_MONITOR_MONTHLY                     = 'jetpack_monitor_monthly'; // 2241
173    private const JETPACK_MONITOR_YEARLY                      = 'jetpack_monitor_yearly'; // 2242
174    private const AKISMET_FREE                                = 'ak_free_yearly'; // 2300
175    private const AKISMET_PERSONAL_MONTHLY                    = 'ak_personal_monthly'; // 2309
176    private const AKISMET_PERSONAL_YEARLY                     = 'ak_personal_yearly'; // 2310
177    private const AKISMET_PLUS_BI_YEARLY                      = 'ak_plus_bi_yearly_1'; // 2327
178    private const AKISMET_PLUS_YEARLY                         = 'ak_plus_yearly_1'; // 2311
179    private const AKISMET_PLUS_MONTHLY                        = 'ak_plus_monthly_1'; // 2312
180    private const AKISMET_PLUS_20K_BI_YEARLY                  = 'ak_plus_bi_yearly_2'; // 2328
181    private const AKISMET_PLUS_20K_YEARLY                     = 'ak_plus_yearly_2'; // 2313
182    private const AKISMET_PLUS_20K_MONTHLY                    = 'ak_plus_monthly_2'; // 2314
183    private const AKISMET_PLUS_30K_BI_YEARLY                  = 'ak_plus_bi_yearly_3'; // 2329
184    private const AKISMET_PLUS_30K_YEARLY                     = 'ak_plus_yearly_3'; // 2315
185    private const AKISMET_PLUS_30K_MONTHLY                    = 'ak_plus_monthly_3'; // 2316
186    private const AKISMET_PLUS_40K_BI_YEARLY                  = 'ak_plus_bi_yearly_4'; // 2330
187    private const AKISMET_PLUS_40K_YEARLY                     = 'ak_plus_yearly_4'; // 2317
188    private const AKISMET_PLUS_40K_MONTHLY                    = 'ak_plus_monthly_4'; // 2318
189    private const AKISMET_ENTERPRISE_BI_YEARLY                = 'ak_ent_bi_yearly_1'; // 2331
190    private const AKISMET_ENTERPRISE_YEARLY                   = 'ak_ent_yearly_1'; // 2319
191    private const AKISMET_ENTERPRISE_MONTHLY                  = 'ak_ent_monthly_1'; // 2320
192    private const AKISMET_ENTERPRISE_350K_YEARLY              = 'ak_ep350k_yearly_1'; // 2321
193    private const AKISMET_ENTERPRISE_350K_MONTHLY             = 'ak_ep350k_monthly_1'; // 2322
194    private const AKISMET_ENTERPRISE_2M_YEARLY                = 'ak_ep2m_yearly_1'; // 2323
195    private const AKISMET_ENTERPRISE_2M_MONTHLY               = 'ak_ep2m_monthly_1'; // 2324
196    private const AKISMET_ENTERPRISE_GT2M_YEARLY              = 'ak_epgt2m_yearly_1'; // 2325
197    private const AKISMET_ENTERPRISE_GT2M_MONTHLY             = 'ak_epgt2m_monthly_1'; // 2326
198    private const AKISMET_PRO_500_MONTHLY                     = 'ak_pro5h_monthly'; // 2332
199    private const AKISMET_PRO_500_YEARLY                      = 'ak_pro5h_yearly'; // 2333
200    private const AKISMET_PRO_500_BI_YEARLY                   = 'ak_pro5h_bi_yearly'; // 2334
201    private const AKISMET_BUSINESS_5K_MONTHLY                 = 'ak_bus5k_monthly'; // 2335
202    private const AKISMET_BUSINESS_5K_YEARLY                  = 'ak_bus5k_yearly'; // 2336
203    private const AKISMET_BUSINESS_5K_BI_YEARLY               = 'ak_bus5k_bi_yearly'; // 2337
204    private const AKISMET_ENTERPRISE_15K_MONTHLY              = 'ak_ep15k_monthly'; // 2338
205    private const AKISMET_ENTERPRISE_15K_YEARLY               = 'ak_ep15k_yearly'; // 2339
206    private const AKISMET_ENTERPRISE_15K_BI_YEARLY            = 'ak_ep15k_bi_yearly'; // 2340
207    private const AKISMET_ENTERPRISE_25K_MONTHLY              = 'ak_ep25k_monthly'; // 2341
208    private const AKISMET_ENTERPRISE_25K_YEARLY               = 'ak_ep25k_yearly'; // 2342
209    private const AKISMET_ENTERPRISE_25K_BI_YEARLY            = 'ak_ep25k_bi_yearly'; // 2343
210    private const JETPACK_BOOST_BI_YEARLY                     = 'jetpack_boost_bi_yearly'; // 2036
211    private const JETPACK_BOOST                               = 'jetpack_boost_yearly'; // 2401
212    private const JETPACK_BOOST_MONTHLY                       = 'jetpack_boost_monthly'; // 2400
213    private const JETPACK_AI_MONTHLY                          = 'jetpack_ai_monthly'; // 2450
214    private const JETPACK_AI_YEARLY                           = 'jetpack_ai_yearly'; // 2451
215    private const JETPACK_AI_BI_YEARLY                        = 'jetpack_ai_bi_yearly'; // 2452
216    private const JETPACK_SOCIAL_BASIC_MONTHLY_LEGACY         = 'jetpack_social_monthly'; // 2500
217    private const JETPACK_SOCIAL_BASIC_BI_YEARLY              = 'jetpack_social_basic_bi_yearly'; // 2037
218    private const JETPACK_SOCIAL_BASIC                        = 'jetpack_social_basic_yearly'; // 2503
219    private const JETPACK_SOCIAL_BASIC_MONTHLY                = 'jetpack_social_basic_monthly'; // 2504
220    private const JETPACK_SOCIAL_ADVANCED_BI_YEARLY           = 'jetpack_social_advanced_bi_yearly'; // 2604
221    private const JETPACK_SOCIAL_ADVANCED                     = 'jetpack_social_advanced_yearly'; // 2602
222    private const JETPACK_SOCIAL_ADVANCED_MONTHLY             = 'jetpack_social_advanced_monthly'; // 2603
223    private const JETPACK_GOLDEN_TOKEN                        = 'jetpack_golden_token_lifetime'; // 2900
224    private const JETPACK_CREATOR_MONTHLY                     = 'jetpack_creator_monthly'; // 2610
225    private const JETPACK_CREATOR_YEARLY                      = 'jetpack_creator_yearly'; // 2611
226    private const JETPACK_CREATOR_BI_YEARLY                   = 'jetpack_creator_bi_yearly'; // 2612
227    private const JETPACK_SOCIAL_V1_MONTHLY                   = 'jetpack_social_v1_monthly'; // 2606
228    private const JETPACK_SOCIAL_V1_YEARLY                    = 'jetpack_social_v1_yearly'; // 2605
229    private const JETPACK_SOCIAL_V1_BI_YEARLY                 = 'jetpack_social_v1_bi_yearly'; // 2607
230    private const A4A_WPCOM_BUSINESS_BUNDLE_YEARLY            = 'a4a_wp_bundle_business_yearly'; // 3300
231    private const A4A_WPCOM_BUSINESS_BUNDLE_MONTHLY           = 'a4a_wp_bundle_business_monthly'; // 3301
232    private const A4A_JETPACK_COMPLETE_YEARLY                 = 'a4a_jetpack_complete_yearly'; // 3302
233    private const A4A_JETPACK_COMPLETE_MONTHLY                = 'a4a_jetpack_complete_monthly'; // 3303
234    private const A4A_JETPACK_SECURITY_TIER_1_YEARLY          = 'a4a_jetpack_security_t1_yearly'; // 3304
235    private const A4A_JETPACK_SECURITY_TIER_1_MONTHLY         = 'a4a_jetpack_security_t1_monthly'; // 3305
236    private const A4A_JETPACK_SECURITY_TIER_2_YEARLY          = 'a4a_jetpack_security_t2_yearly'; // 3306
237    private const A4A_JETPACK_SECURITY_TIER_2_MONTHLY         = 'a4a_jetpack_security_t2_monthly'; // 3307
238    private const A4A_JETPACK_SEARCH_YEARLY                   = 'a4a_jetpack_search_yearly'; // 3318
239    private const A4A_JETPACK_SEARCH_MONTHLY                  = 'a4a_jetpack_search_monthly'; // 3319
240    private const A4A_JETPACK_SCAN_YEARLY                     = 'a4a_jetpack_scan_yearly'; // 3320
241    private const A4A_JETPACK_SCAN_MONTHLY                    = 'a4a_jetpack_scan_monthly'; // 3321
242    private const A4A_JETPACK_ANTI_SPAM_YEARLY                = 'a4a_jetpack_anti_spam_yearly'; // 3322
243    private const A4A_JETPACK_ANTI_SPAM_MONTHLY               = 'a4a_jetpack_anti_spam_monthly'; // 3323
244    private const A4A_JETPACK_BACKUP_TIER_1_YEARLY            = 'a4a_jetpack_backup_t1_yearly'; // 3324
245    private const A4A_JETPACK_BACKUP_TIER_1_MONTHLY           = 'a4a_jetpack_backup_t1_monthly'; // 3325
246    private const A4A_JETPACK_BACKUP_TIER_2_YEARLY            = 'a4a_jetpack_backup_t2_yearly'; // 3326
247    private const A4A_JETPACK_BACKUP_TIER_2_MONTHLY           = 'a4a_jetpack_backup_t2_monthly'; // 3327
248    private const A4A_JETPACK_VIDEOPRESS_YEARLY               = 'a4a_jetpack_videopress_yearly'; // 3328
249    private const A4A_JETPACK_VIDEOPRESS_MONTHLY              = 'a4a_jetpack_videopress_monthly'; // 3329
250    private const A4A_JETPACK_STATS_YEARLY                    = 'a4a_jetpack_stats_yearly'; // 3330
251    private const A4A_JETPACK_STATS_MONTHLY                   = 'a4a_jetpack_stats_monthly'; // 3331
252    private const A4A_JETPACK_MONITOR_YEARLY                  = 'a4a_jetpack_monitor_yearly'; // 3332
253    private const A4A_JETPACK_MONITOR_MONTHLY                 = 'a4a_jetpack_monitor_monthly'; // 3333
254    private const A4A_JETPACK_BOOST_YEARLY                    = 'a4a_jetpack_boost_yearly'; // 3334
255    private const A4A_JETPACK_BOOST_MONTHLY                   = 'a4a_jetpack_boost_monthly'; // 3335
256    private const A4A_JETPACK_AI_YEARLY                       = 'a4a_jetpack_ai_yearly'; // 3336
257    private const A4A_JETPACK_AI_MONTHLY                      = 'a4a_jetpack_ai_monthly'; // 3337
258    private const A4A_JETPACK_SOCIAL_V1_YEARLY                = 'a4a_jetpack_social_v1_yearly'; // 3338
259    private const A4A_JETPACK_SOCIAL_V1_MONTHLY               = 'a4a_jetpack_social_v1_monthly'; // 3339
260    private const A4A_JETPACK_CREATOR_YEARLY                  = 'a4a_jetpack_creator_yearly'; // 3340
261    private const A4A_JETPACK_CREATOR_MONTHLY                 = 'a4a_jetpack_creator_monthly'; // 3341
262    private const WOO_HOSTED_BASIC_PLAN_MONTHLY               = 'woo_hosted_basic_plan_monthly'; // 4001
263    private const WOO_HOSTED_BASIC_PLAN_YEARLY                = 'woo_hosted_basic_plan_yearly'; // 4002
264    private const WOO_HOSTED_PRO_PLAN_MONTHLY                 = 'woo_hosted_pro_plan_monthly'; // 4003
265    private const WOO_HOSTED_PRO_PLAN_YEARLY                  = 'woo_hosted_pro_plan_yearly'; // 4004
266
267    // WPCOM "Level 2": Groups of level 1s.
268    private const WPCOM_BLOGGER_PLANS           = array( self::BLOGGER_BUNDLE, self::BLOGGER_BUNDLE_2Y );
269    private const WPCOM_PERSONAL_PLANS          = array( self::PERSONAL_BUNDLE, self::PERSONAL_BUNDLE_MONTHLY, self::PERSONAL_BUNDLE_2Y, self::PERSONAL_BUNDLE_3Y );
270    private const WPCOM_STARTER_PLANS           = array( self::STARTER_PLAN );
271    private const WPCOM_PREMIUM_PLANS           = array( self::BUNDLE_PRO, self::VALUE_BUNDLE, self::VALUE_BUNDLE_MONTHLY, self::VALUE_BUNDLE_2Y, self::VALUE_BUNDLE_3Y );
272    private const WPCOM_PRO_PLANS               = array( self::PRO_PLAN, self::PRO_PLAN_MONTHLY, self::PRO_PLAN_2Y );
273    private const WPCOM_MIGRATION_TRIAL_PLANS   = array( self::WPCOM_MIGRATION_TRIAL_BUNDLE_MONTHLY );
274    private const WPCOM_HOSTING_TRIAL_PLANS     = array( self::WPCOM_HOSTING_TRIAL_BUNDLE_MONTHLY );
275    private const WPCOM_STUDENT_PLANS           = array( self::STUDENT_BUNDLE );
276    private const WPCOM_BUSINESS_PLANS          = array( self::BUSINESS_BUNDLE, self::BUSINESS_BUNDLE_MONTHLY, self::BUSINESS_BUNDLE_2Y, self::BUSINESS_BUNDLE_3Y, self::WPCOM_MIGRATION_TRIAL_PLANS, self::WPCOM_HUNDRED_YEAR_BUNDLE, self::WPCOM_HOSTING_TRIAL_BUNDLE_MONTHLY, self::A4A_WPCOM_BUSINESS_BUNDLE_YEARLY, self::A4A_WPCOM_BUSINESS_BUNDLE_MONTHLY, self::WPCOM_STUDENT_PLANS );
277    private const WPCOM_ECOMMERCE_PLANS         = array( self::ECOMMERCE_BUNDLE, self::ECOMMERCE_BUNDLE_MONTHLY, self::ECOMMERCE_BUNDLE_2Y, self::ECOMMERCE_BUNDLE_3Y );
278    private const WPCOM_ECOMMERCE_TRIAL_PLANS   = array( self::ECOMMERCE_TRIAL_BUNDLE_MONTHLY );
279    private const WPCOM_WOOEXPRESS_MEDIUM_PLANS = array( self::WPCOM_WOOEXPRESS_MEDIUM_BUNDLE_MONTHLY, self::WPCOM_WOOEXPRESS_MEDIUM_BUNDLE_YEARLY );
280    private const WPCOM_WOOEXPRESS_SMALL_PLANS  = array( self::WPCOM_WOOEXPRESS_SMALL_BUNDLE_MONTHLY, self::WPCOM_WOOEXPRESS_SMALL_BUNDLE_YEARLY );
281    private const WOO_HOSTED_PLANS              = array( self::WOO_HOSTED_BASIC_PLAN_MONTHLY, self::WOO_HOSTED_BASIC_PLAN_YEARLY, self::WOO_HOSTED_PRO_PLAN_MONTHLY, self::WOO_HOSTED_PRO_PLAN_YEARLY );
282    private const GOOGLE_WORKSPACE_PRODUCTS     = array( self::WP_GOOGLE_WORKSPACE_BUSINESS_STARTER_YEARLY );
283    private const GSUITE_PRODUCTS               = array( self::GAPPS, self::GAPPS_UNLIMITED );
284    private const WPCOM_TITAN_MAIL_PRODUCTS     = array( self::WP_TITAN_MAIL_MONTHLY, self::WP_TITAN_MAIL_YEARLY, self::WP_TITAN_MAIL_PREMIUM_MONTHLY, self::WP_TITAN_MAIL_PREMIUM_YEARLY, self::WP_TITAN_MAIL_ULTRA_MONTHLY, self::WP_TITAN_MAIL_ULTRA_YEARLY );
285
286    private const WPCOM_PERSONAL_AND_PREMIUM_PLANS = array( self::WPCOM_PERSONAL_PLANS, self::WPCOM_PREMIUM_PLANS );
287    // Unlock Business-gated features for sites with the flex-cache-site sticker via the free plan.
288    private const WPCOM_FLEX_CACHE_SITE_FREE_PLANS = array(
289        'required_sticker' => 'flex-cache-site',
290        self::JETPACK_ALL_SITES,
291    );
292
293    // WPCOM "Level 3" A: Groups of level 2s.
294    private const WPCOM_BLOGGER_AND_HIGHER_PLANS  = array( self::WPCOM_BLOGGER_PLANS, self::WPCOM_PERSONAL_PLANS, self::WPCOM_STARTER_PLANS, self::WPCOM_PREMIUM_PLANS, self::WPCOM_PRO_PLANS, self::WPCOM_BUSINESS_PLANS, self::WPCOM_ECOMMERCE_PLANS, self::WPCOM_ECOMMERCE_TRIAL_PLANS, self::WPCOM_WOOEXPRESS_PLANS );
295    private const WPCOM_PERSONAL_AND_HIGHER_PLANS = array( self::WPCOM_PERSONAL_PLANS, self::WPCOM_STARTER_PLANS, self::WPCOM_PREMIUM_PLANS, self::WPCOM_PRO_PLANS, self::WPCOM_BUSINESS_PLANS, self::WPCOM_ECOMMERCE_PLANS, self::WPCOM_ECOMMERCE_TRIAL_PLANS, self::WPCOM_WOOEXPRESS_PLANS );
296    private const WPCOM_STARTER_AND_HIGHER_PLANS  = array( self::WPCOM_STARTER_PLANS, self::WPCOM_PREMIUM_PLANS, self::WPCOM_PRO_PLANS, self::WPCOM_BUSINESS_PLANS, self::WPCOM_ECOMMERCE_PLANS, self::WPCOM_ECOMMERCE_TRIAL_PLANS, self::WPCOM_WOOEXPRESS_PLANS );
297    private const WPCOM_PREMIUM_AND_HIGHER_PLANS  = array( self::WPCOM_PREMIUM_PLANS, self::WPCOM_PRO_PLANS, self::WPCOM_BUSINESS_PLANS, self::WPCOM_ECOMMERCE_PLANS, self::WPCOM_ECOMMERCE_TRIAL_PLANS, self::WPCOM_WOOEXPRESS_PLANS );
298    private const WPCOM_BUSINESS_AND_HIGHER_PLANS = array( self::WPCOM_BUSINESS_PLANS, self::WPCOM_ECOMMERCE_PLANS, self::WPCOM_ECOMMERCE_TRIAL_PLANS, self::WPCOM_WOOEXPRESS_PLANS );
299    private const WPCOM_WOOEXPRESS_PLANS          = array( self::WPCOM_WOOEXPRESS_MEDIUM_PLANS, self::WPCOM_WOOEXPRESS_SMALL_PLANS );
300
301    // WPCOM "Level 3" C: Misc product groupings unrelated to free plan trials.
302    private const WPCOM_EMAIL_PRODUCTS = array( self::GOOGLE_WORKSPACE_PRODUCTS, self::GSUITE_PRODUCTS, self::WPCOM_TITAN_MAIL_PRODUCTS );
303
304    // Jetpack "Level 2": Groups of level 1s.
305    private const JETPACK_BUSINESS_PLANS = array( self::JETPACK_BUSINESS, self::JETPACK_BUSINESS_MONTHLY );
306    private const JETPACK_PREMIUM_PLANS  = array( self::JETPACK_PREMIUM, self::JETPACK_PREMIUM_MONTHLY );
307    private const JETPACK_PERSONAL_PLANS = array( self::JETPACK_PERSONAL, self::JETPACK_PERSONAL_MONTHLY );
308    private const JETPACK_GROWTH_PLANS   = array( self::JETPACK_GROWTH_BI_YEARLY, self::JETPACK_GROWTH_YEARLY, self::JETPACK_GROWTH_MONTHLY );
309    private const JETPACK_COMPLETE_PLANS = array( self::JETPACK_COMPLETE_BI_YEARLY, self::JETPACK_COMPLETE, self::JETPACK_COMPLETE_MONTHLY, self::A4A_JETPACK_COMPLETE_YEARLY, self::A4A_JETPACK_COMPLETE_MONTHLY );
310    private const JETPACK_STARTER_PLANS  = array( self::JETPACK_STARTER_YEARLY, self::JETPACK_STARTER_MONTHLY );
311
312    private const JETPACK_SECURITY_DAILY_PLANS    = array( self::JETPACK_SECURITY_DAILY, self::JETPACK_SECURITY_DAILY_MONTHLY );
313    private const JETPACK_SECURITY_REALTIME_PLANS = array( self::JETPACK_SECURITY_REALTIME, self::JETPACK_SECURITY_REALTIME_MONTHLY );
314    private const JETPACK_SECURITY_T0_PLANS       = array( self::JETPACK_SECURITY_T0_MONTHLY, self::JETPACK_SECURITY_T0_YEARLY );
315    private const JETPACK_SECURITY_T1_PLANS       = array( self::JETPACK_SECURITY_T1_MONTHLY, self::JETPACK_SECURITY_T1_YEARLY, self::JETPACK_SECURITY_T1_BI_YEARLY, self::A4A_JETPACK_SECURITY_TIER_1_MONTHLY, self::A4A_JETPACK_SECURITY_TIER_1_YEARLY );
316    private const JETPACK_SECURITY_T2_PLANS       = array( self::JETPACK_SECURITY_T2_MONTHLY, self::JETPACK_SECURITY_T2_YEARLY, self::A4A_JETPACK_SECURITY_TIER_2_MONTHLY, self::A4A_JETPACK_SECURITY_TIER_2_YEARLY );
317
318    private const JETPACK_SCAN_PLANS = array( self::JETPACK_SCAN_BI_YEARLY, self::JETPACK_SCAN, self::JETPACK_SCAN_MONTHLY, self::JETPACK_SCAN_REALTIME, self::JETPACK_SCAN_REALTIME_MONTHLY, self::A4A_JETPACK_SCAN_YEARLY, self::A4A_JETPACK_SCAN_MONTHLY );
319
320    private const JETPACK_SOCIAL_PLANS          = array( self::JETPACK_SOCIAL_BASIC_BI_YEARLY, self::JETPACK_SOCIAL_BASIC, self::JETPACK_SOCIAL_BASIC_MONTHLY, self::JETPACK_SOCIAL_BASIC_MONTHLY_LEGACY );
321    private const JETPACK_SOCIAL_ADVANCED_PLANS = array( self::JETPACK_SOCIAL_ADVANCED_BI_YEARLY, self::JETPACK_SOCIAL_ADVANCED, self::JETPACK_SOCIAL_ADVANCED_MONTHLY );
322    private const JETPACK_SOCIAL_V1_PLANS       = array( self::JETPACK_SOCIAL_V1_YEARLY, self::JETPACK_SOCIAL_V1_MONTHLY, self::JETPACK_SOCIAL_V1_BI_YEARLY, self::A4A_JETPACK_SOCIAL_V1_YEARLY, self::A4A_JETPACK_SOCIAL_V1_MONTHLY );
323
324    private const JETPACK_STATS_PLANS = array( self::JETPACK_STATS_BI_YEARLY, self::JETPACK_STATS_YEARLY, self::JETPACK_STATS_MONTHLY, self::JETPACK_STATS_PWYW, self::JETPACK_STATS_FREE, self::A4A_JETPACK_STATS_YEARLY, self::A4A_JETPACK_STATS_MONTHLY );
325
326    private const JETPACK_VIDEOPRESS_PLANS = array( self::JETPACK_VIDEOPRESS_BI_YEARLY, self::JETPACK_VIDEOPRESS, self::JETPACK_VIDEOPRESS_MONTHLY, self::A4A_JETPACK_VIDEOPRESS_YEARLY, self::A4A_JETPACK_VIDEOPRESS_MONTHLY );
327
328    private const JETPACK_SEARCH_PLANS = array( self::JETPACK_SEARCH_FREE, self::JETPACK_SEARCH_BI_YEARLY, self::JETPACK_SEARCH, self::JETPACK_SEARCH_MONTHLY, self::A4A_JETPACK_SEARCH_YEARLY, self::A4A_JETPACK_SEARCH_MONTHLY );
329
330    private const JETPACK_AI_PLANS = array( self::JETPACK_AI_BI_YEARLY, self::JETPACK_AI_YEARLY, self::JETPACK_AI_MONTHLY, self::A4A_JETPACK_AI_YEARLY, self::A4A_JETPACK_AI_MONTHLY );
331
332    private const JETPACK_BOOST_PLANS = array( self::JETPACK_BOOST_BI_YEARLY, self::JETPACK_BOOST, self::JETPACK_BOOST_MONTHLY, self::A4A_JETPACK_BOOST_YEARLY, self::A4A_JETPACK_BOOST_MONTHLY );
333
334    private const JETPACK_BACKUP_DAILY_PLANS    = array( self::JETPACK_BACKUP_DAILY, self::JETPACK_BACKUP_DAILY_MONTHLY );
335    private const JETPACK_BACKUP_REALTIME_PLANS = array( self::JETPACK_BACKUP_REALTIME, self::JETPACK_BACKUP_REALTIME_MONTHLY );
336    private const JETPACK_BACKUP_T0_PLANS       = array( self::JETPACK_BACKUP_T0_MONTHLY, self::JETPACK_BACKUP_T0_YEARLY );
337    private const JETPACK_BACKUP_T1_PLANS       = array( self::JETPACK_BACKUP_T1_MONTHLY, self::JETPACK_BACKUP_T1_YEARLY, self::JETPACK_BACKUP_T1_BI_YEARLY, self::A4A_JETPACK_BACKUP_TIER_1_YEARLY, self::A4A_JETPACK_BACKUP_TIER_1_MONTHLY );
338    private const JETPACK_BACKUP_T2_PLANS       = array( self::JETPACK_BACKUP_T2_MONTHLY, self::JETPACK_BACKUP_T2_YEARLY, self::A4A_JETPACK_BACKUP_TIER_2_YEARLY, self::A4A_JETPACK_BACKUP_TIER_2_MONTHLY );
339
340    private const JETPACK_CREATOR_PLANS = array( self::JETPACK_CREATOR_MONTHLY, self::JETPACK_CREATOR_YEARLY, self::JETPACK_CREATOR_BI_YEARLY, self::A4A_JETPACK_CREATOR_YEARLY, self::A4A_JETPACK_CREATOR_MONTHLY );
341
342    // Jetpack "Level 3": Groups of level 2.
343    private const JETPACK_PERSONAL_AND_HIGHER = array(
344        self::JETPACK_PERSONAL_PLANS,
345        self::JETPACK_PREMIUM_PLANS,
346        self::JETPACK_BUSINESS_PLANS,
347        self::JETPACK_COMPLETE_PLANS,
348        self::JETPACK_SECURITY_DAILY_PLANS,
349        self::JETPACK_SECURITY_REALTIME_PLANS,
350        self::JETPACK_SECURITY_T0_PLANS,
351        self::JETPACK_SECURITY_T1_PLANS,
352        self::JETPACK_SECURITY_T2_PLANS,
353        self::JETPACK_STARTER_PLANS,
354    );
355    private const JETPACK_PREMIUM_AND_HIGHER  = array(
356        self::JETPACK_PREMIUM_PLANS,
357        self::JETPACK_BUSINESS_PLANS,
358        self::JETPACK_COMPLETE_PLANS,
359        self::JETPACK_SECURITY_DAILY_PLANS,
360        self::JETPACK_SECURITY_REALTIME_PLANS,
361        self::JETPACK_SECURITY_T0_PLANS,
362        self::JETPACK_SECURITY_T1_PLANS,
363        self::JETPACK_SECURITY_T2_PLANS,
364    );
365
366    private const AKISMET_PLANS = array(
367        self::AKISMET_FREE,
368        self::AKISMET_PERSONAL_MONTHLY,
369        self::AKISMET_PERSONAL_YEARLY,
370        self::AKISMET_PLUS_MONTHLY,
371        self::AKISMET_PLUS_YEARLY,
372        self::AKISMET_PLUS_BI_YEARLY,
373        self::AKISMET_PLUS_20K_MONTHLY,
374        self::AKISMET_PLUS_20K_YEARLY,
375        self::AKISMET_PLUS_20K_BI_YEARLY,
376        self::AKISMET_PLUS_30K_MONTHLY,
377        self::AKISMET_PLUS_30K_YEARLY,
378        self::AKISMET_PLUS_30K_BI_YEARLY,
379        self::AKISMET_PLUS_40K_MONTHLY,
380        self::AKISMET_PLUS_40K_YEARLY,
381        self::AKISMET_PLUS_40K_BI_YEARLY,
382        self::AKISMET_ENTERPRISE_MONTHLY,
383        self::AKISMET_ENTERPRISE_YEARLY,
384        self::AKISMET_ENTERPRISE_BI_YEARLY,
385        self::AKISMET_ENTERPRISE_350K_MONTHLY,
386        self::AKISMET_ENTERPRISE_350K_YEARLY,
387        self::AKISMET_ENTERPRISE_2M_MONTHLY,
388        self::AKISMET_ENTERPRISE_2M_YEARLY,
389        self::AKISMET_PRO_500_MONTHLY,
390        self::AKISMET_PRO_500_YEARLY,
391        self::AKISMET_PRO_500_BI_YEARLY,
392        self::AKISMET_BUSINESS_5K_MONTHLY,
393        self::AKISMET_BUSINESS_5K_YEARLY,
394        self::AKISMET_BUSINESS_5K_BI_YEARLY,
395        self::AKISMET_ENTERPRISE_15K_MONTHLY,
396        self::AKISMET_ENTERPRISE_15K_YEARLY,
397        self::AKISMET_ENTERPRISE_15K_BI_YEARLY,
398        self::AKISMET_ENTERPRISE_25K_MONTHLY,
399        self::AKISMET_ENTERPRISE_25K_YEARLY,
400        self::AKISMET_ENTERPRISE_25K_BI_YEARLY,
401    );
402
403    // Features automatically granted to all sites regardless of their purchases are mapped to these constants.
404    private const WPCOM_ALL_SITES   = 'wpcom-all-sites';
405    private const JETPACK_ALL_SITES = 'jetpack-all-sites';
406
407    /*
408     * Public const for every mapped feature, sorted alphabetically.
409     */
410    public const AI_ASSISTANT                      = 'ai-assistant';
411    public const AI_SEO_ENHANCER                   = 'ai-seo-enhancer';
412    public const AD_CREDIT_VOUCHERS                = 'ad-credit';
413    public const ADVANCED_SEO                      = 'advanced-seo';
414    public const AKISMET                           = 'akismet';
415    public const ANTISPAM                          = 'antispam';
416    public const ARCHIVE_CONTENT                   = 'archive-content';
417    public const ATOMIC                            = 'atomic';
418    public const BACKUPS                           = 'backups';
419    public const BACKUPS_DAILY                     = 'backups-daily';
420    public const BACKUPS_RESTORE                   = 'restore';
421    public const BIG_SKY                           = 'big-sky';
422    public const BACKUPS_SELF_SERVE                = 'backups-self-serve';
423    public const BACKUP_ONE_TIME                   = 'backup-one-time';
424    public const BLAZE_CREDITS_VOUCHER             = 'blaze-credits-voucher';
425    public const BLOG_DOMAIN_ONLY                  = 'blog-domain-only';
426    public const CALENDLY                          = 'calendly';
427    public const CDN                               = 'cdn';
428    public const CLASSIC_SEARCH                    = 'search';
429    public const CLOUD_CRITICAL_CSS                = 'cloud-critical-css';
430    public const CORNERSTONE_TEN_PAGES             = 'cornerstone-10-pages';
431    public const CLOUDFLARE_ANALYTICS              = 'cloudflare-analytics';
432    public const CLOUDFLARE_CDN                    = 'cloudflare-cdn';
433    public const CONCIERGE                         = 'concierge';
434    public const CONCIERGE_BUSINESS                = 'concierge-business';
435    public const COPY_SITE                         = 'copy-site';
436    public const CORE_AUDIO                        = 'core/audio';
437    public const CORE_COVER                        = 'core/cover';
438    public const CORE_VIDEO                        = 'core/video';
439    public const CREDIT_VOUCHERS                   = 'credit-vouchers';
440    public const CUSTOM_DESIGN                     = 'custom-design';
441    public const CUSTOM_DOMAIN                     = 'custom-domain';
442    public const DOMAIN_MAPPING                    = 'domain-mapping';
443    public const DONATIONS                         = 'donations';
444    public const ECOMMERCE_MANAGED_PLUGINS         = 'ecommerce-managed-plugins';
445    public const ECOMMERCE_MANAGED_PLUGINS_SMALL   = 'ecommerce-managed-plugins-small';
446    public const ECOMMERCE_MANAGED_PLUGINS_MEDIUM  = 'ecommerce-managed-plugins-medium';
447    public const ECOMMERCE_MANAGED_PLUGINS_TRIAL   = 'ecommerce-managed-plugins-trial';
448    public const EDIT_PLUGINS                      = 'edit-plugins';
449    public const EDIT_THEMES                       = 'edit-themes';
450    public const EMAIL_PROFESSIONAL                = 'email-professional';
451    public const EMAIL_SUBSCRIPTION                = 'email-subscription';
452    public const EMAIL_FORWARDS_EXTENDED_LIMIT     = 'email-forwards-extended-limit';
453    public const FIELD_FILE                        = 'field-file';
454    public const FORM_INTEGRATIONS                 = 'form-integrations';
455    public const FORM_WEBHOOKS                     = 'form-webhooks';
456    public const FREE_BLOG                         = 'free-blog';
457    public const FULL_ACTIVITY_LOG                 = 'full-activity-log';
458    public const GITHUB_DEPLOYMENTS                = 'github-deployments';
459    public const GLOBAL_STYLES                     = 'global-styles';
460    public const GOOGLE_ANALYTICS                  = 'google-analytics';
461    public const GOOGLE_MY_BUSINESS                = 'google-my-business';
462    public const IMAGE_CDN_LIAR                    = 'image-cdn-liar';
463    public const IMAGE_CDN_QUALITY                 = 'image-cdn-quality';
464    public const IMAGE_SIZE_ANALYSIS               = 'image-size-analysis';
465    public const INSTALL_PLUGINS                   = 'install-plugins';
466    public const INSTALL_PURCHASED_PLUGINS         = 'install-purchased-plugins';
467    public const INSTALL_THEMES                    = 'install-themes';
468    public const INSTALL_WOO_ONBOARDING_PLUGINS    = 'install-woo-onboarding-plugins';
469    public const INSTANT_SEARCH                    = 'instant-search';
470    public const JETPACK_DASHBOARD                 = 'jetpack-dashboard';
471    public const LEGACY_CONTACT                    = 'legacy-contact';
472    public const LIST_INSTALLED_PLUGINS            = 'list-installed-plugins';
473    public const LIVE_SUPPORT                      = 'live_support';
474    public const LOCKED_MODE                       = 'locked-mode';
475    public const LOGS                              = 'logs';
476    public const MAILPOET_BUSINESS                 = 'mailpoet-business';
477    public const MANAGE_PLUGINS                    = 'manage-plugins';
478    public const MONITORING                        = 'monitoring';
479    public const MONITOR_1_MINUTE_CHECK_INTERVAL   = 'monitor-1-minute-check-interval';
480    public const MONITOR_MULTIPLE_EMAIL_RECIPIENTS = 'monitor-multiple-email-recipients';
481    public const MONITOR_SMS_NOTIFICATIONS         = 'monitor-sms-notifications';
482    public const MULTISTEP_FORM                    = 'multistep-form';
483    public const NO_ADVERTS_NO_ADVERTS_PHP         = 'no-adverts/no-adverts.php';
484    public const NO_WPCOM_BRANDING                 = 'no-wpcom-branding';
485    public const OPENTABLE                         = 'opentable';
486    public const PAYMENTS                          = 'payments';
487    public const PAYMENT_BUTTONS                   = 'payment-buttons';
488    public const PAYPAL_PAYMENT_BUTTONS            = 'paypal-payment-buttons';
489    public const PERFORMANCE                       = 'performance';
490    public const PERFORMANCE_HISTORY               = 'performance-history';
491    public const PODCASTING                        = 'podcasting';
492    public const POLLDADDY                         = 'polldaddy';
493    public const POSTS_TO_PODCAST_TIER_1           = 'posts-to-podcast-tier-1';
494    public const POSTS_TO_PODCAST_TIER_2           = 'posts-to-podcast-tier-2';
495    public const POSTS_TO_PODCAST_TIER_3           = 'posts-to-podcast-tier-3';
496    public const PREMIUM_CONTENT_CONTAINER         = 'premium-content/container';
497    public const PERSONAL_THEMES                   = 'personal-themes';
498    public const PREMIUM_THEMES                    = 'premium-themes';
499    public const PARTNER_THEMES                    = 'partner-themes';
500    public const COMMUNITY_THEMES                  = 'community-themes';
501    public const WOOCOMMERCE_THEMES                = 'woocommerce-themes';
502    public const SENSEI_THEMES                     = 'sensei-themes';
503    public const PRIORITY_SUPPORT                  = 'priority_support';
504    public const PRIVATE_WHOIS                     = 'private_whois';
505    public const REAL_TIME_BACKUPS                 = 'real-time-backups';
506    public const REAL_TIME_COLLABORATION           = 'real-time-collaboration';
507    public const RECURRING_PAYMENTS                = 'recurring-payments';
508    public const REDUCED_ATOMIC_EMAIL_PRIORITY     = 'reduced-email-priority';
509    public const REPUBLICIZE                       = 'republicize';
510    public const SCAN                              = 'scan';
511    public const SCAN_MANAGED                      = 'scan-managed';
512    public const SCAN_SELF_SERVE                   = 'scan-self-serve';
513    public const SCHEDULED_UPDATES                 = 'scheduled-updates';
514    public const SECURITY_SETTINGS                 = 'security-settings';
515    public const SEO_ADMIN_UI                      = 'seo-admin-ui';
516    public const SEO_PREVIEW_TOOLS                 = 'seo-preview-tools';
517    public const SEND_A_MESSAGE                    = 'send-a-message';
518    public const SET_PRIMARY_CUSTOM_DOMAIN         = 'set-primary-custom-domain';
519    public const SFTP                              = 'sftp';
520    public const SIMPLE_PAYMENTS                   = 'simple-payments';
521    public const SITE_PREVIEW_LINKS                = 'site-preview-links';
522    public const SOCIAL_ADMIN_UI_V2                = 'social-admin-ui-v2';
523    public const SOCIAL_IMAGE_FOCAL_POINT          = 'social-image-focal-point';
524    public const SOCIAL_IMAGE_GENERATOR            = 'social-image-generator';
525    public const SOCIAL_MESSAGE_TEMPLATES          = 'social-message-templates';
526    public const SOCIAL_SHARES_1000                = 'social-shares-1000';
527    public const SOCIAL_ENHANCED_PUBLISHING        = 'social-enhanced-publishing';
528    public const SOCIAL_IMAGE_AUTO_CONVERT         = 'social-image-auto-convert';
529    public const SPACE                             = 'space';
530    public const SPACE_UPGRADED_STORAGE            = 'space-upgraded-storage';
531    public const SSH                               = 'ssh';
532    public const STAGING_SITES                     = 'staging-sites';
533    public const STATS_BASIC_TEMP                  = 'stats-basic';
534    public const STATS_COMMERCIAL                  = 'stats-commercial';
535    public const STATS_FREE                        = 'stats-free';
536    public const STATS_PAID                        = 'stats-paid';
537    public const STUDIO_SYNC                       = 'studio-sync';
538    public const SUBSCRIBER_UNLIMITED_IMPORTS      = 'subscriber-unlimited-imports';
539    public const SUBSCRIPTION_GIFTING              = 'subscription-gifting';
540    public const SUPPORT                           = 'support';
541    public const TITAN_MAIL_1YEAR_TRIAL            = 'titan_mail_1year_trial';
542    public const UPGRADED_UPLOAD_FILETYPES         = 'upgraded_upload_filetypes';
543    public const UPLOAD_AUDIO_FILES                = 'upload-audio-files';
544    public const UPLOAD_PLUGINS                    = 'upload-plugins';
545    public const UPLOAD_SPACE_1GB                  = 'upload-space-1gb-addon';
546    public const UPLOAD_SPACE_3GB                  = 'upload-space-3gb';
547    public const UPLOAD_SPACE_10GB                 = 'upload-space-10gb';
548    public const UPLOAD_SPACE_25GB                 = 'upload-space-25gb';
549    public const UPLOAD_SPACE_50GB                 = 'upload-space-50gb';
550    public const UPLOAD_SPACE_100GB                = 'upload-space-100gb';
551    public const UPLOAD_SPACE_200GB                = 'upload-space-200gb';
552    public const UPLOAD_SPACE_UNLIMITED            = 'upload-space-unlimited';
553    public const UPLOAD_THEMES                     = 'upload-themes';
554    public const UPLOAD_VIDEO_FILES                = 'upload-video-files';
555    public const VAULTPRESS_AUTOMATED_RESTORES     = 'vaultpress-automated-restores';
556    public const VAULTPRESS_BACKUP_ARCHIVE         = 'vaultpress-backup-archive';
557    public const VAULTPRESS_BACKUPS                = 'vaultpress-backups';
558    public const VAULTPRESS_SECURITY_SCANNING      = 'vaultpress-security-scanning';
559    public const VAULTPRESS_STORAGE_SPACE          = 'vaultpress-storage-space';
560    public const VIDEO_HOSTING                     = 'video-hosting';
561    public const VIDEOPRESS                        = 'videopress';
562    public const VIDEOPRESS_1TB_STORAGE            = 'videopress-1tb-storage';
563    public const VIDEOPRESS_VIDEO                  = 'videopress/video';
564    public const VIDEOPRESS_UNLIMITED_STORAGE      = 'videopress-unlimited-storage';
565    public const WHATSAPP_BUTTON                   = 'whatsapp-button';
566    public const WOOP                              = 'woop';
567    public const WORDADS                           = 'wordads';
568    public const WORDADS_JETPACK                   = 'wordads-jetpack';
569
570    /*
571     * Private const array of features with sub-array of purchases that include that feature. Sorted alphabetically.
572     */
573    private const FEATURES_MAP = array(
574        self::AI_ASSISTANT                      => array(
575            self::JETPACK_AI_PLANS,
576            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
577            self::JETPACK_COMPLETE_PLANS,
578        ),
579        self::AI_SEO_ENHANCER                   => array(
580            self::WPCOM_PREMIUM_PLANS,
581            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
582            self::JETPACK_COMPLETE_PLANS,
583        ),
584        self::AD_CREDIT_VOUCHERS                => array(
585            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
586            self::WPCOM_PRO_PLANS,
587        ),
588
589        /*
590         * ADVANCED_SEO - Called seo-tools in Jetpack.
591         *
592         * Active for:
593         * - Simple and Atomic sites with Premium or up plan.
594         * - Jetpack sites with any plan.
595         * - Not VIP sites.
596         */
597        self::ADVANCED_SEO                      => array(
598            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
599            self::JETPACK_ALL_SITES,
600        ),
601        self::AKISMET                           => array(
602            self::AKISMET_PLANS,
603            self::JETPACK_PERSONAL_AND_HIGHER,
604            self::WPCOM_ALL_SITES,
605        ),
606        self::ANTISPAM                          => array(
607            self::JETPACK_ANTI_SPAM_BI_YEARLY,
608            self::JETPACK_ANTI_SPAM,
609            self::JETPACK_ANTI_SPAM_MONTHLY,
610            self::A4A_JETPACK_ANTI_SPAM_YEARLY,
611            self::A4A_JETPACK_ANTI_SPAM_MONTHLY,
612            self::JETPACK_PERSONAL_AND_HIGHER,
613            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
614            self::WPCOM_PRO_PLANS,
615        ),
616
617        // Automatically syncs content to the Internet Archive on publish and update.
618        self::ARCHIVE_CONTENT                   => array(
619            self::WPCOM_HUNDRED_YEAR_BUNDLE,
620        ),
621
622        self::ATOMIC                            => array(
623            self::WPCOM_PRO_PLANS,
624            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
625            self::WPCOM_STAGING_PRODUCT,
626            array( 'product_type' => array( 'marketplace_plugin', 'saas_plugin' ) ),
627            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
628        ),
629        // BACKUPS - Site has *any* kind of backups.
630        self::BACKUPS                           => array(
631            self::JETPACK_BACKUP_DAILY_PLANS,
632            self::JETPACK_BACKUP_ONE_TIME,
633            self::JETPACK_BACKUP_REALTIME_PLANS,
634            self::JETPACK_BACKUP_T0_PLANS,
635            self::JETPACK_BACKUP_T1_PLANS,
636            self::JETPACK_BACKUP_T2_PLANS,
637            self::JETPACK_PERSONAL_AND_HIGHER,
638            self::JETPACK_GOLDEN_TOKEN,
639            self::WPCOM_PRO_PLANS,
640            self::WPCOM_STAGING_PRODUCT,
641            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
642            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
643        ),
644        // BACKUPS_DAILY - Site has product that includes daily backups.
645        self::BACKUPS_DAILY                     => array(
646            self::JETPACK_BACKUP_DAILY_PLANS,
647            self::JETPACK_PERSONAL_AND_HIGHER,
648            self::JETPACK_SECURITY_DAILY_PLANS,
649        ),
650        self::BACKUPS_RESTORE                   => array(
651            self::WPCOM_PRO_PLANS,
652            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
653            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
654        ),
655        self::BACKUPS_SELF_SERVE                => array(
656            self::JETPACK_BACKUP_DAILY_PLANS,
657            self::JETPACK_BACKUP_ONE_TIME,
658            self::JETPACK_BACKUP_REALTIME_PLANS,
659            self::JETPACK_BACKUP_T0_PLANS,
660            self::JETPACK_BACKUP_T1_PLANS,
661            self::JETPACK_BACKUP_T2_PLANS,
662            self::JETPACK_PERSONAL_AND_HIGHER,
663            self::JETPACK_GOLDEN_TOKEN,
664            self::WPCOM_PRO_PLANS,
665            self::WPCOM_STAGING_PRODUCT,
666            // Business and higher can self serve restoring backups.
667            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
668            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
669        ),
670
671        /*
672         * BACKUP_ONE_TIME - Site has purchased a one-time backup.
673         * Note the jetpack_backup_one_time product never expires. So any feature gated with BACKUP_ONE_TIME will
674         * likewise, never expire.
675         */
676        self::BACKUP_ONE_TIME                   => array(
677            self::JETPACK_BACKUP_ONE_TIME,
678        ),
679        // Plans that grant unlimited Big Sky usage and exit the Big Sky free trial.
680        self::BIG_SKY                           => array(
681            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
682        ),
683        self::BLAZE_CREDITS_VOUCHER             => array(
684            array(
685                // Business.
686                self::BUSINESS_BUNDLE,
687                self::BUSINESS_BUNDLE_MONTHLY,
688                self::BUSINESS_BUNDLE_2Y,
689                self::BUSINESS_BUNDLE_3Y,
690                // Ecommerce.
691                self::ECOMMERCE_BUNDLE,
692                self::ECOMMERCE_BUNDLE_MONTHLY,
693                self::ECOMMERCE_BUNDLE_2Y,
694                self::ECOMMERCE_BUNDLE_3Y,
695            ),
696        ),
697        // BLOG_DOMAIN_ONLY - Users on Blogger plan can only purchase .blog domains.
698        self::BLOG_DOMAIN_ONLY                  => array(
699            self::WPCOM_BLOGGER_PLANS,
700        ),
701        self::CALENDLY                          => array(
702            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
703            self::JETPACK_BUSINESS_PLANS,
704            self::JETPACK_PREMIUM_PLANS,
705            self::WP_P2_PLUS_MONTHLY,
706        ),
707        self::CDN                               => array(
708            self::JETPACK_ALL_SITES,
709            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
710            self::WPCOM_PRO_PLANS,
711        ),
712        self::CLASSIC_SEARCH                    => array(
713            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
714            self::WPCOM_PRO_PLANS,
715            self::JETPACK_SEARCH_PLANS,
716            self::JETPACK_COMPLETE_PLANS,
717            self::JETPACK_BUSINESS_PLANS,
718            self::WPCOM_SEARCH,
719            self::WPCOM_SEARCH_MONTHLY,
720            self::WP_P2_PLUS_MONTHLY,
721        ),
722        self::CLOUD_CRITICAL_CSS                => array(
723            self::JETPACK_BOOST_PLANS,
724            self::JETPACK_COMPLETE_PLANS,
725        ),
726        self::CORNERSTONE_TEN_PAGES             => array(
727            self::JETPACK_BOOST_PLANS,
728            self::JETPACK_COMPLETE_PLANS,
729        ),
730        self::CLOUDFLARE_ANALYTICS              => array(
731            self::JETPACK_PREMIUM_AND_HIGHER,
732            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
733            self::WPCOM_PRO_PLANS,
734        ),
735        self::CLOUDFLARE_CDN                    => array(
736            self::JETPACK_PREMIUM_AND_HIGHER,
737            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
738            self::WPCOM_PRO_PLANS,
739        ),
740        self::CONCIERGE                         => array(
741            self::WPCOM_BUSINESS_PLANS,
742            self::WPCOM_ECOMMERCE_PLANS,
743        ),
744        self::CONCIERGE_BUSINESS                => array(
745            self::WPCOM_BUSINESS_PLANS,
746        ),
747        self::COPY_SITE                         => array(
748            self::WPCOM_PRO_PLANS,
749            self::EXCLUDE_PLANS => array(
750                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
751            ),
752            // Copy a site requires an Atomic site, so this mirrors the plans that can be
753            // Atomic: Personal, Premium, and Business or higher plans (not all paid plans).
754            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
755            self::WPCOM_PERSONAL_AND_PREMIUM_PLANS,
756            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
757        ),
758        // CORE_AUDIO - core/audio requires a paid plan for uploading audio files.
759        self::CORE_AUDIO                        => array(
760            self::WP_P2_PLUS_MONTHLY,
761            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
762            self::JETPACK_PERSONAL_AND_HIGHER,
763        ),
764        // CORE_COVER - core/cover requires a paid plan for uploading video files.
765        self::CORE_COVER                        => array(
766            self::WP_P2_PLUS_MONTHLY,
767            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
768            self::JETPACK_BUSINESS_PLANS,
769            self::JETPACK_PREMIUM_PLANS,
770        ),
771        // CORE_VIDEO - core/video requires a paid plan.
772        self::CORE_VIDEO                        => array(
773            self::WP_P2_PLUS_MONTHLY,
774            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
775            self::JETPACK_BUSINESS_PLANS,
776            self::JETPACK_PREMIUM_PLANS,
777        ),
778        self::CREDIT_VOUCHERS                   => array(
779            self::BUNDLE_PRO,
780            self::BUNDLE_SUPER,
781            self::BUNDLE_ENTERPRISE,
782            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
783        ),
784        self::CUSTOM_DESIGN                     => array(
785            self::WPCOM_CUSTOM_DESIGN,
786            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
787        ),
788        self::CUSTOM_DOMAIN                     => array(
789            self::WPCOM_BLOGGER_AND_HIGHER_PLANS,
790            self::WOO_HOSTED_PLANS,
791        ),
792        self::DOMAIN_MAPPING                    => array(
793            self::WPCOM_BLOGGER_AND_HIGHER_PLANS,
794            self::WPCOM_PRO_PLANS,
795            self::WOO_HOSTED_PLANS,
796        ),
797        self::DONATIONS                         => array(
798            array(
799                'before_feature_gating_2026' => true,
800                self::WPCOM_ALL_SITES,
801            ),
802            array(
803                'before_feature_gating_2026' => true,
804                self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
805            ),
806            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
807            self::JETPACK_ALL_SITES,
808        ),
809        // ECOMMERCE_MANAGED_PLUGINS - Can install the plugin bundle that comes with eCommerce plans.
810        self::ECOMMERCE_MANAGED_PLUGINS         => array(
811            self::WPCOM_ECOMMERCE_PLANS,
812            self::WPCOM_ECOMMERCE_TRIAL_PLANS,
813            self::WPCOM_WOOEXPRESS_PLANS,
814        ),
815        // ECOMMERCE_MANAGED_PLUGINS_SMALL - Can install the plugin bundle that comes with eCommerce Small plans.
816        self::ECOMMERCE_MANAGED_PLUGINS_SMALL   => array(
817            self::WPCOM_WOOEXPRESS_SMALL_PLANS,
818        ),
819        // ECOMMERCE_MANAGED_PLUGINS_MEDIUM - Can install the plugin bundle that comes with eCommerce Medium plans.
820        self::ECOMMERCE_MANAGED_PLUGINS_MEDIUM  => array(
821            self::WPCOM_ECOMMERCE_PLANS,
822            self::WPCOM_WOOEXPRESS_MEDIUM_PLANS,
823        ),
824        // ECOMMERCE_MANAGED_PLUGINS_TRIAL - Can install the plugin bundle that comes with eCommerce Trial plans.
825        self::ECOMMERCE_MANAGED_PLUGINS_TRIAL   => array(
826            self::WPCOM_ECOMMERCE_TRIAL_PLANS,
827        ),
828        // EDIT_PLUGINS - Provides the edit_plugins capability on atomic sites, does nothing on simple sites.
829        self::EDIT_PLUGINS                      => array(
830            self::WPCOM_PRO_PLANS,
831            self::EXCLUDE_PLANS => array(
832                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
833            ),
834            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
835            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
836        ),
837        // EDIT_THEMES - Provides the edit_themes capability on atomic sites, does nothing on simple sites.
838        self::EDIT_THEMES                       => array(
839            self::WPCOM_PRO_PLANS,
840            self::EXCLUDE_PLANS => array(
841                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
842            ),
843            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
844            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
845        ),
846        // EMAIL_PROFESSIONAL - Access to Titan email hosting, often referred to as WordPress.com "Professional Email".
847        self::EMAIL_PROFESSIONAL                => array(
848            self::WPCOM_TITAN_MAIL_PRODUCTS,
849        ),
850        // EMAIL_SUBSCRIPTION - Represents having at least one product providing email.
851        self::EMAIL_SUBSCRIPTION                => array(
852            self::WPCOM_EMAIL_PRODUCTS,
853        ),
854        self::EMAIL_FORWARDS_EXTENDED_LIMIT     => array(
855            self::BUNDLE_ENTERPRISE,
856            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
857            self::WPCOM_PRO_PLANS,
858        ),
859        // FIELD_FILE - Premium block/feature (jetpack/field-file) for uploading files with cloud backend.
860        // See: https://github.com/Automattic/jetpack/pull/43177 / https://github.a8c.com/Automattic/wpcom/pull/179247
861        self::FIELD_FILE                        => array(
862            array(
863                'before_feature_gating_2026' => true,
864                self::WPCOM_PERSONAL_PLANS,
865                self::WPCOM_PREMIUM_PLANS,
866            ),
867            self::WPCOM_PRO_PLANS,
868            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
869            self::JETPACK_COMPLETE_PLANS,
870        ),
871        self::FORM_INTEGRATIONS                 => array(
872            array(
873                'before_feature_gating_2026' => true,
874                self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
875            ),
876            self::WPCOM_PRO_PLANS,
877            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
878            self::JETPACK_ALL_SITES,
879        ),
880        self::FORM_WEBHOOKS                     => array(
881            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
882            self::JETPACK_ALL_SITES,
883        ),
884        self::FREE_BLOG                         => array(
885            self::WPCOM_ALL_SITES,
886        ),
887        self::FULL_ACTIVITY_LOG                 => array(
888            self::JETPACK_BACKUP_DAILY_PLANS,
889            self::JETPACK_BACKUP_REALTIME_PLANS,
890            self::JETPACK_BACKUP_T0_PLANS,
891            self::JETPACK_BACKUP_T1_PLANS,
892            self::JETPACK_BACKUP_T2_PLANS,
893            self::JETPACK_PERSONAL_AND_HIGHER,
894            self::JETPACK_GOLDEN_TOKEN,
895            self::WPCOM_BLOGGER_AND_HIGHER_PLANS,
896            self::WPCOM_PRO_PLANS,
897        ),
898        self::GITHUB_DEPLOYMENTS                => array(
899            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
900            self::EXCLUDE_PLANS => array(
901                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
902            ),
903        ),
904        self::GLOBAL_STYLES                     => array(
905            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
906        ),
907        self::GOOGLE_ANALYTICS                  => array(
908            self::JETPACK_PREMIUM_AND_HIGHER,
909            self::WPCOM_STARTER_AND_HIGHER_PLANS,
910        ),
911        self::GOOGLE_MY_BUSINESS                => array(
912            self::WPCOM_PRO_PLANS,
913            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
914            self::JETPACK_BUSINESS_PLANS,
915            self::JETPACK_SECURITY_REALTIME_PLANS,
916            self::JETPACK_COMPLETE_PLANS,
917            self::JETPACK_SECURITY_T1_PLANS,
918            self::JETPACK_SECURITY_T2_PLANS,
919        ),
920        self::IMAGE_CDN_LIAR                    => array(
921            self::JETPACK_BOOST_PLANS,
922            self::JETPACK_COMPLETE_PLANS,
923        ),
924        self::IMAGE_CDN_QUALITY                 => array(
925            self::JETPACK_BOOST_PLANS,
926            self::JETPACK_COMPLETE_PLANS,
927        ),
928        self::IMAGE_SIZE_ANALYSIS               => array(
929            self::JETPACK_BOOST_PLANS,
930            self::JETPACK_COMPLETE_PLANS,
931        ),
932        self::INSTALL_PLUGINS                   => array(
933            self::WPCOM_PRO_PLANS,
934            self::EXCLUDE_PLANS => array(
935                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
936            ),
937            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
938            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
939        ),
940        self::INSTALL_PURCHASED_PLUGINS         => array(
941            self::WPCOM_PRO_PLANS,
942            self::WPCOM_STARTER_PLANS,
943            self::EXCLUDE_PLANS => array(
944                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
945            ),
946            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
947            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
948        ),
949        self::INSTALL_THEMES                    => array(
950            self::WPCOM_PRO_PLANS,
951            self::JETPACK_ALL_SITES,
952            self::EXCLUDE_PLANS => array(
953                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
954            ),
955            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
956            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
957        ),
958        self::INSTALL_WOO_ONBOARDING_PLUGINS    => array(
959            self::WPCOM_ECOMMERCE_TRIAL_PLANS,
960        ),
961        self::INSTANT_SEARCH                    => array(
962            self::WPCOM_SEARCH,
963            self::WPCOM_SEARCH_MONTHLY,
964            self::WP_P2_PLUS_MONTHLY,
965            self::JETPACK_SEARCH_PLANS,
966            self::JETPACK_COMPLETE_PLANS,
967        ),
968        self::JETPACK_DASHBOARD                 => array(
969            self::WPCOM_PRO_PLANS,
970            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
971            self::JETPACK_ALL_SITES,
972        ),
973
974        // Allows sites to designate a contact person to look after their site after they pass away.
975        self::LEGACY_CONTACT                    => array(
976            self::WPCOM_HUNDRED_YEAR_BUNDLE,
977        ),
978        self::LIST_INSTALLED_PLUGINS            => array(
979            self::WPCOM_PRO_PLANS,
980            self::WPCOM_STARTER_PLANS,
981            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
982            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
983        ),
984        // LIVE_SUPPORT - Monthly plans do not get live support. p7DVsv-a9N-p2.
985        self::LIVE_SUPPORT                      => array(
986            // Premium (Excluding Monthly).
987            self::BUNDLE_PRO,
988            self::VALUE_BUNDLE,
989            self::VALUE_BUNDLE_2Y,
990            self::VALUE_BUNDLE_3Y,
991            // Pro.
992            self::PRO_PLAN,
993            self::PRO_PLAN_2Y,
994            // Business (Excluding Monthly).
995            self::BUSINESS_BUNDLE,
996            self::BUSINESS_BUNDLE_2Y,
997            self::BUSINESS_BUNDLE_3Y,
998            // Student (yearly).
999            self::STUDENT_BUNDLE,
1000            // Ecommerce (Excluding Monthly).
1001            self::ECOMMERCE_BUNDLE,
1002            self::ECOMMERCE_BUNDLE_2Y,
1003            self::ECOMMERCE_BUNDLE_3Y,
1004            // Woo Express (Small and Medium plans), excluding monthly.
1005            self::WPCOM_WOOEXPRESS_MEDIUM_BUNDLE_YEARLY,
1006            self::WPCOM_WOOEXPRESS_SMALL_BUNDLE_YEARLY,
1007        ),
1008
1009        // Enables a setting to lock the site content to prevent changes (incl. disabling comments site-wide).
1010        self::LOCKED_MODE                       => array(
1011            self::WPCOM_HUNDRED_YEAR_BUNDLE,
1012        ),
1013        self::LOGS                              => array(
1014            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1015            self::WPCOM_PRO_PLANS,
1016        ),
1017        self::MAILPOET_BUSINESS                 => array(
1018            self::WPCOM_BUSINESS_PLANS,
1019            self::WPCOM_ECOMMERCE_PLANS,
1020            self::WPCOM_WOOEXPRESS_PLANS,
1021            self::WOO_HOSTED_PLANS,
1022        ),
1023        // MANAGE_PLUGINS - Atomic only feature. Can upload, install, and activate any 3rd party plugin.
1024        self::MANAGE_PLUGINS                    => array(
1025            self::WPCOM_PRO_PLANS,
1026            self::EXCLUDE_PLANS => array(
1027                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1028            ),
1029            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1030            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1031        ),
1032        self::MONITORING                        => array(
1033            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1034            self::WPCOM_PRO_PLANS,
1035        ),
1036
1037        // MONITOR_1_MINUTE_CHECK_INTERVAL - Jetpack Monitor checks site uptime once per minute
1038        self::MONITOR_1_MINUTE_CHECK_INTERVAL   => array(
1039            self::JETPACK_MONITOR_MONTHLY,
1040            self::JETPACK_MONITOR_YEARLY,
1041            self::A4A_JETPACK_MONITOR_MONTHLY,
1042            self::A4A_JETPACK_MONITOR_YEARLY,
1043        ),
1044        // MONITOR_MULTIPLE_EMAIL_RECIPIENTS - Jetpack Monitor can email more than one recipient when a site goes down
1045        self::MONITOR_MULTIPLE_EMAIL_RECIPIENTS => array(
1046            self::JETPACK_MONITOR_MONTHLY,
1047            self::JETPACK_MONITOR_YEARLY,
1048            self::A4A_JETPACK_MONITOR_MONTHLY,
1049            self::A4A_JETPACK_MONITOR_YEARLY,
1050        ),
1051        // MONITOR_SMS_NOTIFICATIONS - Jetpack Monitor can send notifications via SMS when a site goes down
1052        self::MONITOR_SMS_NOTIFICATIONS         => array(
1053            self::JETPACK_MONITOR_MONTHLY,
1054            self::JETPACK_MONITOR_YEARLY,
1055            self::A4A_JETPACK_MONITOR_MONTHLY,
1056            self::A4A_JETPACK_MONITOR_YEARLY,
1057        ),
1058        self::MULTISTEP_FORM                    => array(
1059            array(
1060                'before_feature_gating_2026' => true,
1061                self::WPCOM_PERSONAL_PLANS,
1062                self::WPCOM_PREMIUM_PLANS,
1063            ),
1064            self::WPCOM_PRO_PLANS,
1065            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1066            self::JETPACK_ALL_SITES,
1067        ),
1068        self::NO_ADVERTS_NO_ADVERTS_PHP         => array(
1069            self::NO_ADS,
1070            // Deliberately leaves out the Starter plan.
1071            self::WPCOM_BLOGGER_PLANS,
1072            self::WPCOM_PERSONAL_PLANS,
1073            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1074        ),
1075        // NO_WPCOM_BRANDING - Enable the ability to hide the WP.com branding in the site footer.
1076        self::NO_WPCOM_BRANDING                 => array(
1077            self::WPCOM_PRO_PLANS,
1078            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1079            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1080        ),
1081        self::OPENTABLE                         => array(
1082            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1083            self::JETPACK_BUSINESS_PLANS,
1084            self::JETPACK_PREMIUM_PLANS,
1085        ),
1086        self::PAYMENTS                          => array(
1087            array(
1088                'before_feature_gating_2026' => true,
1089                self::WPCOM_PERSONAL_PLANS,
1090            ),
1091            self::WPCOM_STARTER_PLANS,
1092            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1093        ),
1094        self::PAYMENT_BUTTONS                   => array(
1095            array(
1096                'before_feature_gating_2026' => true,
1097                self::WPCOM_ALL_SITES,
1098            ),
1099            array(
1100                'before_feature_gating_2026' => true,
1101                self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1102            ),
1103            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1104            self::JETPACK_ALL_SITES,
1105        ),
1106        self::PAYPAL_PAYMENT_BUTTONS            => array(
1107            array(
1108                'before_feature_gating_2026' => true,
1109                self::WPCOM_ALL_SITES,
1110            ),
1111            array(
1112                'before_feature_gating_2026' => true,
1113                self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1114            ),
1115            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1116            self::JETPACK_ALL_SITES,
1117        ),
1118        self::PERFORMANCE                       => array(
1119            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1120            self::WPCOM_PRO_PLANS,
1121        ),
1122        self::PERFORMANCE_HISTORY               => array(
1123            self::JETPACK_BOOST_PLANS,
1124            self::JETPACK_COMPLETE_PLANS,
1125        ),
1126        self::PODCASTING                        => array(
1127            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1128            self::JETPACK_ALL_SITES,
1129        ),
1130        self::POLLDADDY                         => array(
1131            self::JETPACK_BUSINESS_PLANS,
1132        ),
1133        // POSTS_TO_PODCAST_TIER_{1,2,3} â€” generates a podcast-style episode
1134        // from recent posts. Monthly quotas: TIER_1 = 5, TIER_2 = 10,
1135        // TIER_3 = 20. Sites accumulate tiers via the _AND_HIGHER cascades;
1136        // the lib's quota helper takes the highest tier present.
1137        self::POSTS_TO_PODCAST_TIER_1           => array(
1138            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1139        ),
1140        self::POSTS_TO_PODCAST_TIER_2           => array(
1141            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1142        ),
1143        self::POSTS_TO_PODCAST_TIER_3           => array(
1144            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1145        ),
1146        // PREMIUM_CONTENT_CONTAINER - premium-content requires a paid wpcom plan.
1147        self::PREMIUM_CONTENT_CONTAINER         => array(
1148            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1149            self::WP_P2_PLUS_MONTHLY,
1150        ),
1151        self::PERSONAL_THEMES                   => array(
1152            self::WPCOM_UNLIMITED_THEMES,
1153            self::BUNDLE_ENTERPRISE,
1154            self::WPCOM_PRO_PLANS,
1155            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1156            self::JETPACK_BUSINESS_PLANS,
1157        ),
1158        self::PREMIUM_THEMES                    => array(
1159            self::WPCOM_UNLIMITED_THEMES,
1160            self::BUNDLE_ENTERPRISE,
1161            self::WPCOM_PRO_PLANS,
1162            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1163            self::JETPACK_BUSINESS_PLANS,
1164        ),
1165        self::PARTNER_THEMES                    => array(
1166            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1167            self::WPCOM_PRO_PLANS,
1168            self::EXCLUDE_PLANS => array(
1169                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1170            ),
1171        ),
1172        self::COMMUNITY_THEMES                  => array(
1173            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1174            self::WPCOM_PRO_PLANS,
1175            self::EXCLUDE_PLANS => array(
1176                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1177            ),
1178            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1179        ),
1180        self::WOOCOMMERCE_THEMES                => array(
1181            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1182            self::WPCOM_PRO_PLANS,
1183            self::EXCLUDE_PLANS => array(
1184                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1185            ),
1186            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1187        ),
1188        self::SENSEI_THEMES                     => array(
1189            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1190            self::WPCOM_PRO_PLANS,
1191            self::EXCLUDE_PLANS => array(
1192                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1193            ),
1194        ),
1195        self::PRIORITY_SUPPORT                  => array(
1196            self::JETPACK_BACKUP_T1_PLANS,
1197            self::JETPACK_BACKUP_T2_PLANS,
1198            self::JETPACK_PERSONAL_AND_HIGHER,
1199            self::JETPACK_GOLDEN_TOKEN,
1200            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1201            self::WPCOM_PRO_PLANS,
1202        ),
1203        self::PRIVATE_WHOIS                     => array(
1204            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1205        ),
1206        self::REAL_TIME_BACKUPS                 => array(
1207            self::JETPACK_BACKUP_REALTIME_PLANS,
1208            self::JETPACK_BACKUP_T0_PLANS,
1209            self::JETPACK_BACKUP_T1_PLANS,
1210            self::JETPACK_BACKUP_T2_PLANS,
1211            self::JETPACK_BUSINESS_PLANS,
1212            self::JETPACK_COMPLETE_PLANS,
1213            self::JETPACK_SECURITY_REALTIME_PLANS,
1214            self::JETPACK_SECURITY_T0_PLANS,
1215            self::JETPACK_SECURITY_T1_PLANS,
1216            self::JETPACK_SECURITY_T2_PLANS,
1217            self::JETPACK_STARTER_PLANS,
1218            self::JETPACK_GOLDEN_TOKEN,
1219            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1220            self::WPCOM_PRO_PLANS,
1221            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1222        ),
1223
1224        self::REAL_TIME_COLLABORATION           => array(
1225            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1226        ),
1227
1228        self::RECURRING_PAYMENTS                => array(
1229            self::WPCOM_ALL_SITES,
1230            self::WPCOM_STARTER_PLANS,
1231            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1232            self::JETPACK_ALL_SITES,
1233        ),
1234
1235        /*
1236         * Reduced email priority when sending emails via SMTP via the Atomic platform.
1237         */
1238        self::REDUCED_ATOMIC_EMAIL_PRIORITY     => array(
1239            self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1240            self::WPCOM_MIGRATION_TRIAL_PLANS,
1241            self::WPCOM_HOSTING_TRIAL_PLANS,
1242        ),
1243
1244        /*
1245         * REPUBLICIZE
1246         *
1247         * Active for:
1248         * - Simple and Atomic sites with Premium or up plan.
1249         * - Jetpack sites with Premium or up plan, or a Jetpack Social plan.
1250         */
1251        self::REPUBLICIZE                       => array(
1252            self::WP_P2_PLUS_MONTHLY,
1253            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1254            self::JETPACK_ALL_SITES,
1255        ),
1256        self::SCAN                              => array(
1257            self::JETPACK_PREMIUM_AND_HIGHER,
1258            self::JETPACK_SCAN_PLANS,
1259            self::JETPACK_GOLDEN_TOKEN,
1260            self::WPCOM_PERSONAL_AND_PREMIUM_PLANS,
1261            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1262            self::WPCOM_PRO_PLANS,
1263            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1264        ),
1265
1266        /*
1267         * SCAN_MANAGED - Scan results are managed internally by Atomic guild HEs and not shown in user UI.
1268         * See D57207-code.
1269         */
1270        self::SCAN_MANAGED                      => array(
1271            self::WPCOM_PERSONAL_AND_PREMIUM_PLANS,
1272            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1273            self::WPCOM_PRO_PLANS,
1274            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1275        ),
1276
1277        // This governs UI access to Jetpack Scan.
1278        // All WoW sites should perform scans, however we don't want to expose the UI to sites on lower wpcom plans.
1279        // It's not completely clear how this differs from SCAN_MANAGED.
1280        self::SCAN_SELF_SERVE                   => array(
1281            self::JETPACK_PREMIUM_AND_HIGHER,
1282            self::JETPACK_SCAN_PLANS,
1283            self::JETPACK_GOLDEN_TOKEN,
1284            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1285            self::WPCOM_PRO_PLANS,
1286            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1287        ),
1288
1289        /*
1290         * SCHEDULED_UPDATES - Allows users to schedule plugin and (eventually) theme updates for their sites.
1291         *
1292         * @see pcmemI-2O3-p2
1293         */
1294        self::SCHEDULED_UPDATES                 => array(
1295            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1296            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1297        ),
1298
1299        /*
1300         * SECURITY_SETTINGS - Initially added to determine whether to show /settings/security.
1301         * More info: https://github.com/Automattic/wp-calypso/issues/51820
1302         *
1303         * Active for:
1304         * - Simple and Atomic sites with Business or up plan.
1305         * - Jetpack sites with any plan.
1306         */
1307        self::SECURITY_SETTINGS                 => array(
1308            self::WPCOM_PRO_PLANS,
1309            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1310            self::JETPACK_ALL_SITES,
1311            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1312        ),
1313        self::SEO_ADMIN_UI                      => array(
1314            // For now, this is controlled via a blog sticker in Store_Product_List.
1315            array(
1316                'before' => '2004-12-12',
1317                self::WPCOM_ALL_SITES,
1318            ),
1319        ),
1320        self::SEO_PREVIEW_TOOLS                 => array(
1321            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1322            self::BUNDLE_ENTERPRISE,
1323            self::JETPACK_ALL_SITES,
1324            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1325        ),
1326        self::SEND_A_MESSAGE                    => array(
1327            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1328            self::JETPACK_ALL_SITES,
1329        ),
1330
1331        /*
1332         * SET_PRIMARY_CUSTOM_DOMAIN - Set custom domain as primary.
1333         * It allows to set a custom domain of the site as primary.
1334         *
1335         * Active for:
1336         * - Simple and Atomic sites with any standard WordPress.com plan
1337         */
1338        self::SET_PRIMARY_CUSTOM_DOMAIN         => array(
1339            self::WPCOM_BLOGGER_AND_HIGHER_PLANS,
1340            self::WOO_HOSTED_PLANS,
1341            self::YOAST_PREMIUM,
1342        ),
1343        // Hosting Configuration.
1344        self::SFTP                              => array(
1345            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1346            self::WPCOM_PRO_PLANS,
1347            self::EXCLUDE_PLANS => array(
1348                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1349            ),
1350            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1351        ),
1352
1353        self::SSH                               => array(
1354            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1355            self::EXCLUDE_PLANS => array(
1356                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1357            ),
1358            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1359        ),
1360        self::SIMPLE_PAYMENTS                   => array(
1361            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1362            self::JETPACK_PREMIUM_AND_HIGHER,
1363            self::JETPACK_CREATOR_PLANS,
1364            self::JETPACK_GROWTH_PLANS,
1365        ),
1366        self::SITE_PREVIEW_LINKS                => array(
1367            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1368        ),
1369
1370        /*
1371         * SOCIAL_SHARES_1000 - This feature is linked to the ability to share upto 1000 social media shares on the Jetpack Social Plugin.
1372         *
1373         */
1374        self::SOCIAL_SHARES_1000                => array(
1375            self::JETPACK_ALL_SITES,
1376            self::BUNDLE_ENTERPRISE,
1377        ),
1378
1379        self::SOCIAL_ENHANCED_PUBLISHING        => array(
1380            self::JETPACK_SOCIAL_ADVANCED_PLANS,
1381            self::JETPACK_COMPLETE_PLANS,
1382            self::BUNDLE_ENTERPRISE,
1383            self::JETPACK_SOCIAL_V1_PLANS,
1384            self::JETPACK_SOCIAL_PLANS,
1385            self::JETPACK_GROWTH_PLANS,
1386            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1387        ),
1388        self::SOCIAL_ADMIN_UI_V2                => array(
1389            // For now, this is controlled via a blog sticker in Store_Product_List.
1390            array(
1391                'before' => '2004-12-12',
1392                self::WPCOM_ALL_SITES,
1393            ),
1394        ),
1395        self::SOCIAL_IMAGE_FOCAL_POINT          => array(
1396            // For now, this is controlled via a blog sticker in Store_Product_List.
1397            array(
1398                'before' => '2004-12-12',
1399                self::WPCOM_ALL_SITES,
1400            ),
1401        ),
1402        self::SOCIAL_IMAGE_GENERATOR            => array(
1403            self::JETPACK_SOCIAL_ADVANCED_PLANS,
1404            self::JETPACK_COMPLETE_PLANS,
1405            self::BUNDLE_ENTERPRISE,
1406            self::JETPACK_SOCIAL_V1_PLANS,
1407            self::JETPACK_SOCIAL_PLANS,
1408            self::JETPACK_GROWTH_PLANS,
1409            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1410        ),
1411        self::SOCIAL_MESSAGE_TEMPLATES          => array(
1412            // Gated on the paid social plans, matching SOCIAL_ENHANCED_PUBLISHING.
1413            self::JETPACK_SOCIAL_ADVANCED_PLANS,
1414            self::JETPACK_COMPLETE_PLANS,
1415            self::BUNDLE_ENTERPRISE,
1416            self::JETPACK_SOCIAL_V1_PLANS,
1417            self::JETPACK_SOCIAL_PLANS,
1418            self::JETPACK_GROWTH_PLANS,
1419            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1420        ),
1421        self::SOCIAL_IMAGE_AUTO_CONVERT         => array(
1422            self::WPCOM_ALL_SITES,
1423        ),
1424        self::SPACE                             => array(
1425            self::WPCOM_ALL_SITES,
1426        ),
1427
1428        /*
1429         * Products that have upgraded storage space on WordPress.com, beyond
1430         * the bare minimum advertised for free sites. This list includes all
1431         * WordPress.com plans and space upgrade products.
1432         */
1433        self::SPACE_UPGRADED_STORAGE            => array(
1434            self::WPCOM_BLOGGER_AND_HIGHER_PLANS,
1435            self::BUNDLE_SUPER,
1436            self::BUNDLE_ENTERPRISE,
1437            self::WP_P2_PLUS_MONTHLY,
1438            self::SPACE_1GB,
1439            self::SPACE_3GB,
1440            self::SPACE_10GB,
1441            self::SPACE_25GB,
1442            self::SPACE_50GB,
1443            self::SPACE_100GB,
1444            self::SPACE_200GB,
1445            self::EXCLUDE_PLANS => array(
1446                self::WPCOM_HOSTING_TRIAL_PLANS,
1447            ),
1448        ),
1449        self::STAGING_SITES                     => array(
1450            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1451            self::EXCLUDE_PLANS => array(
1452                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1453            ),
1454            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1455        ),
1456        // Gives near full access to all stats features. All features except new commercial level modules like UTM and device stats.
1457        self::STATS_FREE                        => array(
1458            self::JETPACK_STATS_PLANS,
1459            self::JETPACK_GROWTH_PLANS,
1460            // Provides legacy access for free and personal sites created before 2024-01-09.
1461            // Can be removed once we are ready to paywall all free and/or old personal sites.
1462            array(
1463                'before' => '2024-01-09',
1464                self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1465                self::WPCOM_ALL_SITES,
1466            ),
1467        ),
1468        // Provides limited stats for free and personal sites created before 2024-12-06.
1469        // Features: Posts/Locations/Emails/File downloads
1470        // Can be removed once we are ready to paywall all free sites.
1471        self::STATS_BASIC_TEMP                  => array(
1472            array(
1473                'before' => '2024-12-12',
1474                self::WPCOM_ALL_SITES,
1475            ),
1476        ),
1477        // Provides personal sites and higher access to all stats features except commercial level modules.
1478        // Features: Posts/Locations/Emails/File downloads/Referrers/Clicks
1479        self::STATS_PAID                        => array(
1480            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1481            self::WP_P2_PLUS_MONTHLY,
1482            self::JETPACK_STATS_PWYW,
1483            self::JETPACK_STATS_MONTHLY,
1484            self::JETPACK_STATS_BI_YEARLY,
1485            self::JETPACK_STATS_YEARLY,
1486            self::JETPACK_COMPLETE_PLANS,
1487            self::JETPACK_BUSINESS_PLANS,
1488            self::JETPACK_GROWTH_PLANS,
1489        ),
1490        // Provides premium sites and higher access to all stats features.
1491        // Features: STATS_PAID + UTM & Devices modules
1492        self::STATS_COMMERCIAL                  => array(
1493            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1494            self::JETPACK_STATS_MONTHLY,
1495            self::JETPACK_STATS_BI_YEARLY,
1496            self::JETPACK_STATS_YEARLY,
1497            self::JETPACK_COMPLETE_PLANS,
1498            self::JETPACK_BUSINESS_PLANS,
1499            self::JETPACK_GROWTH_PLANS,
1500            // A4A Jetpack Stats plans
1501            self::A4A_JETPACK_STATS_MONTHLY,
1502            self::A4A_JETPACK_STATS_YEARLY,
1503        ),
1504        self::STUDIO_SYNC                       => array(
1505            self::WPCOM_PRO_PLANS,
1506            self::WPCOM_PERSONAL_AND_PREMIUM_PLANS,
1507            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1508            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1509        ),
1510
1511        // Importing subscribers to the site without limits.
1512        self::SUBSCRIBER_UNLIMITED_IMPORTS      => array(
1513            self::WP_P2_PLUS_MONTHLY,
1514            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1515            self::JETPACK_PERSONAL_AND_HIGHER,
1516            self::JETPACK_SOCIAL_PLANS,
1517            self::JETPACK_SOCIAL_ADVANCED_PLANS,
1518            self::JETPACK_SOCIAL_V1_PLANS,
1519            self::JETPACK_CREATOR_PLANS,
1520            self::JETPACK_GROWTH_PLANS,
1521            self::EXCLUDE_PLANS => array(
1522                self::WPCOM_MIGRATION_TRIAL_PLANS,
1523                self::WPCOM_HOSTING_TRIAL_PLANS,
1524            ),
1525            // A4A Jetpack Stats plans
1526            self::A4A_JETPACK_STATS_MONTHLY,
1527            self::A4A_JETPACK_STATS_YEARLY,
1528        ),
1529
1530        self::SUBSCRIPTION_GIFTING              => array(
1531            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1532            self::EXCLUDE_PLANS => array(
1533                self::WPCOM_MIGRATION_TRIAL_PLANS,
1534                self::WPCOM_HOSTING_TRIAL_PLANS,
1535                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1536            ),
1537        ),
1538
1539        // SUPPORT - Everybody needs somebody.
1540        self::SUPPORT                           => array(
1541            self::WPCOM_ALL_SITES,
1542            self::JETPACK_PERSONAL_AND_HIGHER,
1543            self::JETPACK_GOLDEN_TOKEN,
1544        ),
1545        self::TITAN_MAIL_1YEAR_TRIAL            => array(
1546            array(
1547                self::WPCOM_BUSINESS_PLANS,
1548                self::WPCOM_ECOMMERCE_PLANS,
1549            ),
1550        ),
1551        self::UPGRADED_UPLOAD_FILETYPES         => array(
1552            self::SPACE_1GB,
1553            self::SPACE_3GB,
1554            self::SPACE_10GB,
1555            self::SPACE_25GB,
1556            self::SPACE_50GB,
1557            self::SPACE_100GB,
1558            self::SPACE_200GB,
1559            self::WPCOM_BLOGGER_AND_HIGHER_PLANS,
1560            self::WP_P2_PLUS_MONTHLY,
1561        ),
1562        self::UPLOAD_AUDIO_FILES                => array(
1563            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1564            self::JETPACK_ALL_SITES,
1565        ),
1566        self::UPLOAD_PLUGINS                    => array(
1567            self::WPCOM_PRO_PLANS,
1568            self::EXCLUDE_PLANS => array(
1569                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1570            ),
1571            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1572            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1573        ),
1574        self::UPLOAD_SPACE_1GB                  => array(
1575            self::SPACE_1GB,
1576        ),
1577        self::UPLOAD_SPACE_3GB                  => array(
1578            self::SPACE_3GB,
1579        ),
1580        self::UPLOAD_SPACE_10GB                 => array(
1581            self::SPACE_10GB,
1582        ),
1583        self::UPLOAD_SPACE_25GB                 => array(
1584            self::SPACE_25GB,
1585        ),
1586        self::UPLOAD_SPACE_50GB                 => array(
1587            self::SPACE_50GB,
1588        ),
1589        self::UPLOAD_SPACE_100GB                => array(
1590            self::SPACE_100GB,
1591        ),
1592        self::UPLOAD_SPACE_200GB                => array(
1593            self::SPACE_200GB,
1594            array(
1595                'before' => LEGACY_200GB_CUTOFF_DATE,
1596                self::WPCOM_BUSINESS_PLANS,
1597                self::WPCOM_ECOMMERCE_PLANS,
1598            ),
1599            array(
1600                'required_sticker' => 'legacy-200gb-storage',
1601                self::WPCOM_BUSINESS_PLANS,
1602                self::WPCOM_ECOMMERCE_PLANS,
1603            ),
1604        ),
1605        self::UPLOAD_SPACE_UNLIMITED            => array(
1606            array(
1607                'before' => '2019-08-01',
1608                self::WPCOM_BUSINESS_PLANS,
1609                self::WPCOM_ECOMMERCE_PLANS,
1610            ),
1611        ),
1612        self::UPLOAD_THEMES                     => array(
1613            self::WPCOM_PRO_PLANS,
1614            self::EXCLUDE_PLANS => array(
1615                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1616            ),
1617            self::WPCOM_PERSONAL_AND_HIGHER_PLANS,
1618            self::WPCOM_FLEX_CACHE_SITE_FREE_PLANS,
1619        ),
1620
1621        /*
1622         * UPLOAD_VIDEO_FILES - This feature is linked to the ability to upload video files to the website.
1623         *
1624         * Active for:
1625         * - Simple and Atomic sites with Premium or up plan.
1626         * - Jetpack sites with any plan.
1627         */
1628        self::UPLOAD_VIDEO_FILES                => array(
1629            self::WP_P2_PLUS_MONTHLY,
1630            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1631            self::JETPACK_ALL_SITES,
1632        ),
1633
1634        self::VAULTPRESS_AUTOMATED_RESTORES     => array(
1635            self::JETPACK_PREMIUM_PLANS,
1636            self::JETPACK_BUSINESS_PLANS,
1637        ),
1638        self::VAULTPRESS_BACKUP_ARCHIVE         => array(
1639            self::JETPACK_PREMIUM_PLANS,
1640            self::JETPACK_BUSINESS_PLANS,
1641        ),
1642        self::VAULTPRESS_BACKUPS                => array(
1643            self::JETPACK_PERSONAL_AND_HIGHER,
1644        ),
1645        self::VAULTPRESS_SECURITY_SCANNING      => array(
1646            self::JETPACK_BUSINESS_PLANS,
1647        ),
1648        self::VAULTPRESS_STORAGE_SPACE          => array(
1649            self::JETPACK_PREMIUM_PLANS,
1650            self::JETPACK_BUSINESS_PLANS,
1651        ),
1652
1653        /*
1654         * VIDEO_HOSTING - Host video effortlessly and deliver it at high speeds to your viewers.
1655         * https://jetpack.com/features/design/video-hosting/
1656         *
1657         * Active for:
1658         * - Simple and Atomic sites with Premium or up plan.
1659         * - Jetpack sites with Premium or up plan.
1660         */
1661        self::VIDEO_HOSTING                     => array(
1662            array(
1663                'before_feature_gating_2026' => true,
1664                self::WPCOM_PREMIUM_PLANS,
1665            ),
1666            self::WPCOM_PRO_PLANS,
1667            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1668            self::JETPACK_PREMIUM_AND_HIGHER,
1669            self::EXCLUDE_PLANS => array(
1670                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1671            ),
1672        ),
1673        self::VIDEOPRESS                        => array(
1674            self::JETPACK_BUSINESS_PLANS,
1675            self::JETPACK_COMPLETE_PLANS,
1676            self::JETPACK_PERSONAL_PLANS,
1677            self::JETPACK_PREMIUM_PLANS,
1678            self::JETPACK_VIDEOPRESS_PLANS,
1679            array(
1680                'before_feature_gating_2026' => true,
1681                self::WPCOM_PREMIUM_PLANS,
1682            ),
1683            self::WPCOM_PRO_PLANS,
1684            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1685            self::WPCOM_VIDEOPRESS,
1686            self::WPCOM_VIDEOPRESS_PRO,
1687            self::WP_P2_PLUS_MONTHLY,
1688            array(
1689                'before' => '2021-10-07',
1690                self::JETPACK_SECURITY_DAILY_PLANS,
1691                self::JETPACK_SECURITY_REALTIME_PLANS,
1692                self::JETPACK_SECURITY_T0_PLANS,
1693                self::JETPACK_SECURITY_T1_PLANS,
1694                self::JETPACK_SECURITY_T2_PLANS,
1695            ),
1696        ),
1697
1698        /*
1699         * Note: VIDEOPRESS_1TB_STORAGE and VIDEOPRESS_UNLIMITED_STORAGE are
1700         * currently only checked on standalone Jetpack sites.
1701         * For example, adding VIDEOPRESS_UNLIMITED_STORAGE to a WP.com plan
1702         * will not provide it with unlimited VideoPress storage.
1703         *
1704         * All WoA VIDEOPRESS sites currently get 2TB storage on their cache
1705         * site for VideoPress.
1706         */
1707        self::VIDEOPRESS_1TB_STORAGE            => array(
1708            array(
1709                self::JETPACK_COMPLETE_PLANS,
1710                self::JETPACK_VIDEOPRESS_PLANS,
1711                self::JETPACK_PREMIUM_PLANS,
1712                self::JETPACK_BUSINESS_PLANS,
1713            ),
1714        ),
1715        // VIDEOPRESS_VIDEO - videopress/video requires a paid plan.
1716        self::VIDEOPRESS_VIDEO                  => array(
1717            self::WP_P2_PLUS_MONTHLY,
1718            array(
1719                'before_feature_gating_2026' => true,
1720                self::WPCOM_PREMIUM_PLANS,
1721            ),
1722            self::WPCOM_PRO_PLANS,
1723            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1724            self::JETPACK_BUSINESS_PLANS,
1725            self::JETPACK_PREMIUM_PLANS,
1726            self::EXCLUDE_PLANS => array(
1727                self::WPCOM_ECOMMERCE_TRIAL_PLANS,
1728            ),
1729        ),
1730        self::VIDEOPRESS_UNLIMITED_STORAGE      => array(
1731            array(
1732                'before' => '2021-10-07',
1733                self::JETPACK_COMPLETE_PLANS,
1734                self::JETPACK_SECURITY_DAILY_PLANS,
1735                self::JETPACK_SECURITY_REALTIME_PLANS,
1736                self::JETPACK_SECURITY_T0_PLANS,
1737                self::JETPACK_SECURITY_T1_PLANS,
1738                self::JETPACK_SECURITY_T2_PLANS,
1739                self::JETPACK_PREMIUM_PLANS,
1740                self::JETPACK_BUSINESS_PLANS,
1741            ),
1742        ),
1743        self::WHATSAPP_BUTTON                   => array(
1744            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1745            self::JETPACK_ALL_SITES,
1746        ),
1747
1748        /*
1749         * WOOP - WooCommerce on all Plans is available to install.
1750         *
1751         * Active for:
1752         * - Simple and Atomic sites with Business or up plan.
1753         * - Not Jetpack sites
1754         */
1755        self::WOOP                              => array(
1756            self::WPCOM_PRO_PLANS,
1757            self::WPCOM_BUSINESS_AND_HIGHER_PLANS,
1758        ),
1759        self::WORDADS                           => array(
1760            self::JETPACK_STARTER_PLANS,
1761            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1762            self::JETPACK_PREMIUM_AND_HIGHER,
1763            self::JETPACK_CREATOR_PLANS,
1764            self::JETPACK_GROWTH_PLANS,
1765        ),
1766
1767        /*
1768         * WORDADS_JETPACK - `wordads-jetpack` is maintained as a legacy alias of `wordads` which was used to gate
1769         * the feature in old versions of Jetpack.
1770         * @see https://github.com/Automattic/jetpack/blob/c4f8fe120e1286e85f49e20e0f7fe22e44641449/projects/plugins/jetpack/class.jetpack-plan.php#L330.
1771         */
1772        self::WORDADS_JETPACK                   => array(
1773            self::WPCOM_PREMIUM_AND_HIGHER_PLANS,
1774            self::JETPACK_PREMIUM_AND_HIGHER,
1775        ),
1776    );
1777    /**
1778     * Some A8C owned sites have additional features enabled. e.g. Jetpack SEO.
1779     * This is an array of blog IDs where these features are enabled.
1780     */
1781    public const A8C_SITES_WITH_ADDITIONAL_SEO_FEATURES = array(
1782        1, // https://wordpress.com/
1783        69197545, // br.support.wordpress.com
1784        69197545, // br.support.wordpress.com
1785        12084301, // he.support.wordpress.com
1786        12358344, // pt.support.wordpress.com
1787        20614491, // de.support.wordpress.com
1788        110643074, // es.support.wordpress.com
1789        9619154, // en.support.wordpress.com
1790        9620355, // fr.support.wordpress.com
1791        22718864, // ru.support.wordpress.com
1792        26068228, // ja.support.wordpress.com
1793        151395884, // ko.support.wordpress.com
1794        151398260, // sv.support.wordpress.com
1795        151398564, // ar.support.wordpress.com
1796        150300509, // it.support.wordpress.com
1797        150381433, // nl.support.wordpress.com
1798        150645278, // id.support.wordpress.com
1799        150881074, // tr.support.wordpress.com
1800        151397720, // zh-cn.support.wordpress.com
1801        151397956, // zh-tw.support.wordpress.com
1802        3584907, // en.blog.wordpress.com
1803        7944537, // ja.blog.wordpress.com
1804        11241806, // es.blog.wordpress.com
1805        8181651, // pt.blog.wordpress.com
1806        8994420, // fr.blog.wordpress.com
1807        66243751, // br.blog.wordpress.com
1808        196931530, // enwpgo.wordpress.com
1809        173323553, // eswpgo.wordpress.com
1810        173331416, // dewpgo.wordpress.com
1811        162814143, // frwpgo.wordpress.com
1812        173328699, // itwpgo.wordpress.com
1813        163161552, // brwpgo.wordpress.com
1814        53424024, // discover.wordpress.com
1815        489937, // dailypost.wordpress.com
1816        33534099,  // developer.wordpress.com
1817        233643880, // eswpcomdeveloper.wordpress.com
1818        244311505, // jawpcomdeveloper.wordpress.com
1819        244447807, // frwpcomdeveloper.wordpress.com
1820        244448116, // dewpcomdeveloper.wordpress.com
1821        244448279, // ptbrwpcomdeveloper.wordpress.com
1822        244517526, // idwpcomdeveloper.wordpress.com
1823        244516213, // itwpcomdeveloper.wordpress.com
1824        244518337, // nlwpcomdeveloper.wordpress.com
1825        22994, // theme.wordpress.com
1826        16390, // learn.wordpress.com
1827        54117, // automattic.wordpress.com
1828    );
1829
1830    /**
1831     * Checks whether the given feature is declared in our map.
1832     *
1833     * @param string $feature The feature to check.
1834     *
1835     * @return bool Whether the given feature exists.
1836     */
1837    public static function feature_exists( $feature ) {
1838        return ! empty( self::FEATURES_MAP[ $feature ] );
1839    }
1840
1841    /**
1842     * Given a primitive type $needle, and an array $haystack, recursively
1843     * search $haystack for an instance of $needle. If arrays are encountered,
1844     * they will also be searched. Only strict comparisons are used.
1845     *
1846     * @param mixed $needle   What to look for.
1847     * @param array $haystack Array of items to check, may contain other arrays.
1848     *
1849     * @return bool Is the needle in the haystack somewhere?
1850     */
1851    public static function in_array_recursive( $needle, $haystack ) {
1852        foreach ( $haystack as $item ) {
1853            if ( is_array( $item ) ) {
1854                if ( self::in_array_recursive( $needle, $item ) ) {
1855                    return true;
1856                }
1857            } elseif ( $item === $needle ) {
1858                return true;
1859            }
1860        }
1861        return false;
1862    }
1863
1864    /**
1865     * Given an array of $purchases and a single feature name, consult the FEATURES_MAP to determine if the feature
1866     * is included in one of the $purchases.
1867     *
1868     * Use the function wpcom_site_has_feature( $feature ) to determine if a site has access to a certain feature.
1869     *
1870     * @param string $feature   A singular feature.
1871     * @param array  $purchases A collection of purchases.
1872     * @param string $site_type Site type to check. Can be 'wpcom' or 'jetpack'. Default empty string.
1873     * @param int    $blog_id   The blog ID to check. Default null.
1874     *
1875     * @return bool Is the feature included in one of the purchases.
1876     */
1877    public static function has_feature( $feature, $purchases, $site_type = '', $blog_id = null ) {
1878        if ( ! self::feature_exists( $feature ) ) {
1879            return false;
1880        }
1881
1882        $products_map = self::FEATURES_MAP[ $feature ];
1883
1884        // Automatically grant features that don't require any purchase.
1885        if (
1886            ( 'wpcom' === $site_type && in_array( self::WPCOM_ALL_SITES, $products_map, true ) ) ||
1887            ( 'jetpack' === $site_type && in_array( self::JETPACK_ALL_SITES, $products_map, true ) )
1888        ) {
1889            return true;
1890        }
1891
1892        foreach ( $purchases as $purchase ) {
1893            if ( self::purchase_in_products_map( $purchase, $products_map, $blog_id ) ) {
1894                return true;
1895            }
1896        }
1897        return false;
1898    }
1899
1900    /**
1901     * Treat free plan as a purchase so the logic for purchase_in_products_map are applied when checking for legacy features.
1902     * As the free plan isn't actually a purchase, there is no subscribed_date, so we use the blog_registered_date instead.
1903     *
1904     * @param array  $purchases Reference to an array of purchases, this function adds a free plan to the end of the array passed in.
1905     * @param string $site_type Site type to check. Can be 'wpcom' or 'jetpack'.
1906     * @param string $blog_registered_date The date the blog was registered.
1907     */
1908    public static function add_free_plan_purchase( &$purchases, $site_type, $blog_registered_date ) {
1909        $free_purchase_object                  = new stdClass();
1910        $free_purchase_object->product_slug    = "{$site_type}-all-sites";
1911        $free_purchase_object->subscribed_date = $blog_registered_date;
1912
1913        $purchases[] = $free_purchase_object;
1914    }
1915
1916    /**
1917     * Resolve the WordPress.com blog ID to check stickers and the gating cutoff against.
1918     *
1919     * @param int|null $blog_id Blog ID, or null to resolve from the environment.
1920     *
1921     * @return int
1922     */
1923    private static function resolve_blog_id( $blog_id = null ) {
1924        if ( null !== $blog_id ) {
1925            return (int) $blog_id;
1926        }
1927
1928        if ( function_exists( '_wpcom_get_current_blog_id' ) ) {
1929            return (int) _wpcom_get_current_blog_id();
1930        }
1931
1932        return (int) get_current_blog_id();
1933    }
1934
1935    /**
1936     * Whether a site carries a blog sticker, on Simple or in WPCOMSH.
1937     *
1938     * `$blog_id` is ignored on WoW, WPCOMSH reads Atomic Persistent Data, there is no way to read
1939     * another site's from there. A caller that needs a specific site's stickers has to establish
1940     * that it is the current site first, e.g `is_legacy_gating_site()`.
1941     *
1942     * @param string   $sticker Sticker slug.
1943     * @param int|null $blog_id Blog ID, or null to resolve from the environment. Ignored on Atomic.
1944     *
1945     * @return bool
1946     */
1947    private static function site_has_sticker( $sticker, $blog_id = null ) {
1948        if ( defined( 'IS_ATOMIC' ) && IS_ATOMIC && function_exists( 'wpcomsh_is_site_sticker_active' ) ) {
1949            return (bool) wpcomsh_is_site_sticker_active( $sticker );
1950        }
1951
1952        if ( function_exists( 'has_blog_sticker' ) ) {
1953            return (bool) has_blog_sticker( $sticker, self::resolve_blog_id( $blog_id ) );
1954        }
1955
1956        return false;
1957    }
1958
1959    /**
1960     * Whether a site is still on the pre-2026 feature gating.
1961     *
1962     * 1. A legacy site that switches to new features is never legacy again.
1963     * 2. `pre-feature-gating-2026` wins over `gating-business-q1`, because a staging site cloned
1964     *    from a legacy production site could have both: the creation hook stickers every new blog,
1965     *    and the staging hook then marks it as mirroring a legacy site.
1966     * 3. `gating-business-q1` covers the ~2.0M sites below the cutoff that are already on the new
1967     *    gating -- the Jan-Jun experiment cohort plus everything `POST /sites/new` stickered
1968     *    between June and August 2026. "No sticker" is not the same as "old site".
1969     * 4. Otherwise the blog ID decides.
1970     *
1971     * @param int $blog_id Blog ID. Required: pass the site being asked about, never a guess.
1972     *
1973     * @return bool
1974     */
1975    public static function is_legacy_gating_site( $blog_id ) {
1976        $blog_id = (int) $blog_id;
1977
1978        // On WoW the sticker checks read the current site's persistent data.
1979        if ( defined( 'IS_ATOMIC' ) && IS_ATOMIC && $blog_id !== self::resolve_blog_id() ) {
1980            if ( function_exists( '_doing_it_wrong' ) ) {
1981                _doing_it_wrong(
1982                    __METHOD__,
1983                    'Atomic sites cannot resolve stickers for a site other than the current one.',
1984                    '' // No version.
1985                );
1986            }
1987
1988            return true;
1989        }
1990
1991        if ( self::site_has_sticker( self::STICKER_FEATURE_GATING_2026, $blog_id ) ) {
1992            return false;
1993        }
1994
1995        if ( self::site_has_sticker( self::STICKER_PRE_FEATURE_GATING_2026, $blog_id ) ) {
1996            return true;
1997        }
1998
1999        if ( self::site_has_sticker( self::STICKER_GATING_BUSINESS_Q1, $blog_id ) ) {
2000            return false;
2001        }
2002
2003        return $blog_id < self::FEATURE_GATING_2026_CUTOFF_BLOG_ID;
2004    }
2005
2006    /**
2007     * Every blog sticker the products map gates on, in a stable order.
2008     *
2009     * @return string[]
2010     */
2011    private static function get_map_sticker_slugs() {
2012        static $slugs = null;
2013
2014        if ( null !== $slugs ) {
2015            return $slugs;
2016        }
2017
2018        $found = array();
2019        $walk  = static function ( $node ) use ( &$walk, &$found ) {
2020            foreach ( $node as $key => $value ) {
2021                if ( 'required_sticker' === $key || 'sticker_not_present' === $key ) {
2022                    foreach ( (array) $value as $slug ) {
2023                        $found[ $slug ] = true;
2024                    }
2025                } elseif ( is_array( $value ) ) {
2026                    $walk( $value );
2027                }
2028            }
2029        };
2030        $walk( self::FEATURES_MAP );
2031
2032        $slugs = array_keys( $found );
2033        sort( $slugs );
2034
2035        return $slugs;
2036    }
2037
2038    /**
2039     * A cache-key fragment covering every per-site input the products map consults.
2040     *
2041     * Feature resolution for a given product is not the same for every site, so anything caching it
2042     * outside a per-site key has to vary on this. The inputs are: before_feature_gating_2026 and
2043     * required_sticker / sticker_not_present.
2044     *
2045     * @param int $blog_id Blog ID to describe.
2046     *
2047     * @return string
2048     */
2049    public static function get_site_gating_cache_suffix( $blog_id ) {
2050        $suffix = self::is_legacy_gating_site( $blog_id ) ? '_pre_gating_2026' : '_gating_2026';
2051
2052        foreach ( self::get_map_sticker_slugs() as $slug ) {
2053            if ( self::site_has_sticker( $slug, $blog_id ) ) {
2054                $suffix .= '_' . $slug;
2055            }
2056        }
2057
2058        return $suffix;
2059    }
2060
2061    /**
2062     * The products definition array ($products_map) may contain 1st-level sub-arrays with 'before' and/or 'after' keys
2063     * used to restrict access to a feature based on when the purchase was made. If the $purchase is included in
2064     * $products_map, and it was purchased within the defined date range (if a date range is defined), return true.
2065     *
2066     * Additionally, the 1st level of the array may contain the key 'excluded_plans' which is an array of plans that
2067     * should be excluded from the feature. This is useful for when there are very specific exceptions that would
2068     * otherwise require a lot of configuration to be added. If a plan is excluded, no further checks will be done.
2069     *
2070     * @param object $purchase A single purchase.
2071     * @param array  $products_map A feature map definition array.
2072     * @param int    $blog_id The blog ID to check. Default null.
2073     *
2074     * @return bool If the purchase is included in $products_map and meets any purchase date-range rules.
2075     */
2076    public static function purchase_in_products_map( $purchase, $products_map, $blog_id = null ) {
2077
2078        // First check if the current purchase is excluded in the product definition.
2079        if ( isset( $products_map[ self::EXCLUDE_PLANS ] ) ) {
2080            $excluded_plans = $products_map[ self::EXCLUDE_PLANS ] ?? array();
2081            if ( ! empty( $excluded_plans ) && self::in_array_recursive( $purchase->product_slug, array( $excluded_plans ) ) ) {
2082                return false;
2083            }
2084            unset( $products_map[ self::EXCLUDE_PLANS ] );
2085        }
2086
2087        // Loop through the first level of the $products_map array to identify potential legacy feature date ranges.
2088        foreach ( $products_map as $product_definition ) {
2089
2090            if ( ! empty( $product_definition['product_type'] ) ) {
2091                if ( ! empty( $purchase->product_type ) && in_array( $purchase->product_type, $product_definition['product_type'], true ) ) {
2092                    return true;
2093                }
2094                continue;
2095            }
2096
2097            $purchase_eligible_by_date    = false;
2098            $purchase_eligible_by_sticker = false;
2099
2100            // Check if sticker requirement exists.
2101            $required_sticker = $product_definition['required_sticker'] ?? null;
2102            if ( $required_sticker ) {
2103                $purchase_eligible_by_sticker = self::site_has_sticker( $required_sticker, $blog_id );
2104                // Remove the sticker key so $product_definition is clean for in_array_recursive search.
2105                unset( $product_definition['required_sticker'] );
2106            } else {
2107                $purchase_eligible_by_sticker = true; // No sticker requirement, so eligible by default.
2108            }
2109
2110            // Check if sticker_not_present requirement exists (feature only available when sticker is NOT present).
2111            $sticker_not_present = $product_definition['sticker_not_present'] ?? null;
2112            if ( $sticker_not_present ) {
2113                $has_sticker = self::site_has_sticker( $sticker_not_present, $blog_id );
2114                // Only eligible if the sticker is NOT present.
2115                $purchase_eligible_by_sticker = $purchase_eligible_by_sticker && ! $has_sticker;
2116                // Remove the sticker key so $product_definition is clean for in_array_recursive search.
2117                unset( $product_definition['sticker_not_present'] );
2118            }
2119
2120            // Check if the site has legacy/current features, previously use gating-business-q1 sticker
2121            if ( isset( $product_definition['before_feature_gating_2026'] ) ) {
2122                $purchase_eligible_by_sticker = $purchase_eligible_by_sticker
2123                    && (bool) $product_definition['before_feature_gating_2026'] === self::is_legacy_gating_site( self::resolve_blog_id( $blog_id ) );
2124                // Remove the key so $product_definition is clean for in_array_recursive search.
2125                unset( $product_definition['before_feature_gating_2026'] );
2126            }
2127
2128            // If 'before' & 'after' are empty, this is not a legacy feature.
2129            if ( empty( $product_definition['before'] ) && empty( $product_definition['after'] ) ) {
2130                $purchase_eligible_by_date = true;
2131            } else {
2132                // If the date key is defined, set its variable to its Unix timestamp, else set invalid or undefined dates to false.
2133                $before          = isset( $product_definition['before'] ) ? strtotime( $product_definition['before'] ) : false;
2134                $after           = isset( $product_definition['after'] ) ? strtotime( $product_definition['after'] ) : false;
2135                $subscribed_date = isset( $purchase->subscribed_date ) ? strtotime( $purchase->subscribed_date ) : false;
2136
2137                // Remove the date keys so $product_definition is clean for in_array_recursive search.
2138                unset( $product_definition['before'], $product_definition['after'] );
2139
2140                // If 'before' or 'after', & the subscribed_date are valid, check if the legacy feature is available.
2141                if ( ( false !== $before || false !== $after ) && false !== $subscribed_date ) {
2142                    if ( false !== $before && false !== $after ) {
2143                        if (
2144                            $subscribed_date >= $after &&
2145                            $subscribed_date <= $before ) {
2146                            $purchase_eligible_by_date = true;
2147                        }
2148                    } elseif ( false !== $before ) {
2149                        if ( $subscribed_date <= $before ) {
2150                            $purchase_eligible_by_date = true;
2151                        }
2152                    } elseif ( false !== $after ) {
2153                        if ( $subscribed_date >= $after ) {
2154                            $purchase_eligible_by_date = true;
2155                        }
2156                    }
2157                }
2158            }
2159
2160            // If the date range and sticker requirements are cleared, check if the purchase is included in the $product_definition.
2161            if ( $purchase_eligible_by_date && $purchase_eligible_by_sticker ) {
2162                if ( self::in_array_recursive( $purchase->product_slug ?? null, array( $product_definition ) ) ) {
2163                    return true;
2164                }
2165            }
2166        }
2167
2168        return false;
2169    }
2170
2171    /**
2172     * Return a list of all possible feature slugs.
2173     *
2174     * @return array An array of strings like 'premium-themes', one for each possible feature slug.
2175     */
2176    public static function get_feature_slugs() {
2177        return array_keys( self::FEATURES_MAP );
2178    }
2179}