PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | vendor/automattic/jetpack-plans/src/class-plans.php +29 -0 13.5.2 → 16.3-beta View file →
@@ -78,5 +78,34 @@
78 78 return $plan;
79 79 }
80 80 }
81 81 }
82 +
83 + /**
84 + * Efficiently get the short name of a plan from a slug.
85 + *
86 + * @param string $plan_slug Plan slug.
87 + * @return string|null Short product name or null if not round.
88 + */
89 + public static function get_plan_short_name( $plan_slug ) {
90 + if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
91 + if ( ! class_exists( 'Store_Product_List' ) ) {
92 + require WP_CONTENT_DIR . '/admin-plugins/wpcom-billing/store-product-list.php';
93 + }
94 +
95 + // Skip additional work like processing of coupons, since we only need the plan's short name.
96 + $products = Store_Product_List::get();
97 +
98 + foreach ( $products as $product ) {
99 + if ( isset( $product['product_slug'] ) && $product['product_slug'] === $plan_slug ) {
100 + return $product['product_name_short'] ?? null;
101 + }
102 + }
103 +
104 + return null;
105 + }
106 +
107 + // Fallback to less efficient method for Jetpack environments.
108 + $plan = self::get_plan( $plan_slug );
109 + return $plan->product_name_short ?? null;
110 + }
82 111 }