| @@ -1,0 +1,141 @@ | ||
| 1 | +<?php //phpcs:ignore WordPress.Files.FileName.InvalidClassFileName | |
| 2 | +/** | |
| 3 | + * Handles fetching of the site's plan and products from WordPress.com and caching values locally. | |
| 4 | + * | |
| 5 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan instead. | |
| 6 | + * | |
| 7 | + * Not to be confused with the `Jetpack_Plans` class (in `_inc/lib/plans.php`), which | |
| 8 | + * fetches general information about all available plans from WordPress.com, side-effect free. | |
| 9 | + * | |
| 10 | + * @package automattic/jetpack | |
| 11 | + */ | |
| 12 | + | |
| 13 | +use Automattic\Jetpack\Current_Plan; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * Provides methods methods for fetching the site's plan and products from WordPress.com. | |
| 17 | + */ | |
| 18 | +class Jetpack_Plan { | |
| 19 | + /** | |
| 20 | + * The name of the option that will store the site's plan. | |
| 21 | + * | |
| 22 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::PLAN_OPTION | |
| 23 | + * | |
| 24 | + * @var string | |
| 25 | + */ | |
| 26 | + const PLAN_OPTION = Current_Plan::PLAN_OPTION; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * The name of the option that will store the site's products. | |
| 30 | + * | |
| 31 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::SITE_PRODUCTS_OPTION | |
| 32 | + * | |
| 33 | + * @var string | |
| 34 | + */ | |
| 35 | + const SITE_PRODUCTS_OPTION = Current_Plan::SITE_PRODUCTS_OPTION; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * Array of products supported by each plan. | |
| 39 | + * | |
| 40 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::PLAN_DATA | |
| 41 | + * | |
| 42 | + * @var array | |
| 43 | + */ | |
| 44 | + const PLAN_DATA = Current_Plan::PLAN_DATA; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * Given a response to the `/sites/%d` endpoint, will parse the response and attempt to set the | |
| 48 | + * site's plan and products from the response. | |
| 49 | + * | |
| 50 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::update_from_sites_response instead. | |
| 51 | + * | |
| 52 | + * @param array $response The response from `/sites/%d`. | |
| 53 | + * @return bool Was the plan successfully updated? | |
| 54 | + */ | |
| 55 | + public static function update_from_sites_response( $response ) { | |
| 56 | + _deprecated_function( __METHOD__, '12.3', 'Automattic\Jetpack\Current_Plan::update_from_sites_response' ); | |
| 57 | + | |
| 58 | + return Current_Plan::update_from_sites_response( $response ); | |
| 59 | + } | |
| 60 | + | |
| 61 | + /** | |
| 62 | + * Make an API call to WordPress.com for plan status | |
| 63 | + * | |
| 64 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::refresh_from_wpcom instead. | |
| 65 | + * | |
| 66 | + * @access public | |
| 67 | + * @static | |
| 68 | + * | |
| 69 | + * @return bool True if plan is updated, false if no update | |
| 70 | + */ | |
| 71 | + public static function refresh_from_wpcom() { | |
| 72 | + _deprecated_function( __METHOD__, '12.3', 'Automattic\Jetpack\Current_Plan::refresh_from_wpcom' ); | |
| 73 | + | |
| 74 | + return Current_Plan::refresh_from_wpcom(); | |
| 75 | + } | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * Get the plan that this Jetpack site is currently using. | |
| 79 | + * | |
| 80 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::get instead. | |
| 81 | + * | |
| 82 | + * @access public | |
| 83 | + * @static | |
| 84 | + * | |
| 85 | + * @return array Active Jetpack plan details | |
| 86 | + */ | |
| 87 | + public static function get() { | |
| 88 | + _deprecated_function( __METHOD__, '12.3', 'Automattic\Jetpack\Current_Plan::get' ); | |
| 89 | + | |
| 90 | + return Current_Plan::get(); | |
| 91 | + } | |
| 92 | + | |
| 93 | + /** | |
| 94 | + * Get the site's products. | |
| 95 | + * | |
| 96 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::get_products instead. | |
| 97 | + * | |
| 98 | + * @access public | |
| 99 | + * @static | |
| 100 | + * | |
| 101 | + * @return array Active Jetpack products | |
| 102 | + */ | |
| 103 | + public static function get_products() { | |
| 104 | + _deprecated_function( __METHOD__, '12.3', 'Automattic\Jetpack\Current_Plan::get_products' ); | |
| 105 | + | |
| 106 | + return Current_Plan::get_products(); | |
| 107 | + } | |
| 108 | + | |
| 109 | + /** | |
| 110 | + * Gets the minimum plan slug that supports the given feature | |
| 111 | + * | |
| 112 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::get_minimum_plan_for_feature instead. | |
| 113 | + * | |
| 114 | + * @param string $feature The name of the feature. | |
| 115 | + * @return string|bool The slug for the minimum plan that supports. | |
| 116 | + * the feature or false if not found | |
| 117 | + */ | |
| 118 | + public static function get_minimum_plan_for_feature( $feature ) { | |
| 119 | + _deprecated_function( __METHOD__, '12.3', 'Automattic\Jetpack\Current_Plan::get_minimum_plan_for_feature' ); | |
| 120 | + | |
| 121 | + return Current_Plan::get_minimum_plan_for_feature( $feature ); | |
| 122 | + } | |
| 123 | + | |
| 124 | + /** | |
| 125 | + * Determine whether the active plan supports a particular feature | |
| 126 | + * | |
| 127 | + * @deprecated 12.3 use Automattic\Jetpack\Current_Plan::supports instead. | |
| 128 | + * | |
| 129 | + * @access public | |
| 130 | + * @static | |
| 131 | + * | |
| 132 | + * @param string $feature The module or feature to check. | |
| 133 | + * | |
| 134 | + * @return bool True if plan supports feature, false if not | |
| 135 | + */ | |
| 136 | + public static function supports( $feature ) { | |
| 137 | + _deprecated_function( __METHOD__, '12.3', 'Automattic\Jetpack\Current_Plan::supports' ); | |
| 138 | + | |
| 139 | + return Current_Plan::supports( $feature ); | |
| 140 | + } | |
| 141 | +} | |