-
Notifications
You must be signed in to change notification settings - Fork 800
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/trunk' into add/ci-php-8.4
- Loading branch information
Showing
15 changed files
with
280 additions
and
35 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
projects/js-packages/components/changelog/add-growth-upsells-to-social-and-stats-interstials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
Add Stats icon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,5 @@ export const JetpackModuleToProductCard: { | |
scan: null, | ||
security: null, | ||
creator: null, | ||
growth: null, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/packages/my-jetpack/changelog/add-growth-upsells-to-social-and-stats-interstials
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
Add growth upsell to Stats and Social interstitials |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 209 additions & 0 deletions
209
projects/packages/my-jetpack/src/products/class-growth.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
<?php | ||
/** | ||
* Growth plan | ||
* | ||
* @package my-jetpack | ||
*/ | ||
|
||
namespace Automattic\Jetpack\My_Jetpack\Products; | ||
|
||
use Automattic\Jetpack\My_Jetpack\Module_Product; | ||
use Automattic\Jetpack\My_Jetpack\Wpcom_Products; | ||
use WP_Error; | ||
|
||
/** | ||
* Class responsible for handling the Growth plan | ||
*/ | ||
class Growth extends Module_Product { | ||
|
||
/** | ||
* The product slug | ||
* | ||
* @var string | ||
*/ | ||
public static $slug = 'growth'; | ||
|
||
/** | ||
* The Jetpack module name | ||
* | ||
* @var string | ||
*/ | ||
public static $module_name = 'growth'; | ||
|
||
/** | ||
* Get the product name | ||
* | ||
* @return string | ||
*/ | ||
public static function get_name() { | ||
return 'Growth'; | ||
} | ||
|
||
/** | ||
* Get the product title | ||
* | ||
* @return string | ||
*/ | ||
public static function get_title() { | ||
return 'Jetpack Growth'; | ||
} | ||
|
||
/** | ||
* Get the internationalized product description | ||
* | ||
* @return string | ||
*/ | ||
public static function get_description() { | ||
return __( 'Grow and track your audience effortlessly.', 'jetpack-my-jetpack' ); | ||
} | ||
|
||
/** | ||
* Get the internationalized product description | ||
* | ||
* @return string | ||
*/ | ||
public static function get_long_description() { | ||
return __( 'Essential tools to help you grow your audience, track visitor engagement, and turn leads into loyal customers and advocates.', 'jetpack-my-jetpack' ); | ||
} | ||
|
||
/** | ||
* Get the internationalized feature list | ||
* | ||
* @return array Growth features list | ||
*/ | ||
public static function get_features() { | ||
return array( | ||
_x( 'Jetpack Social', 'Growth Product Feature', 'jetpack-my-jetpack' ), | ||
_x( 'Jetpack Stats (up to 100K site views)', 'Growth Product Feature', 'jetpack-my-jetpack' ), | ||
_x( 'Unlimited subscriber imports', 'Growth Product Feature', 'jetpack-my-jetpack' ), | ||
_x( 'Earn more from your content', 'Growth Product Feature', 'jetpack-my-jetpack' ), | ||
_x( 'Accept payments with PayPal', 'Growth Product Feature', 'jetpack-my-jetpack' ), | ||
_x( 'Increase earnings with WordAds', 'Growth Product Feature', 'jetpack-my-jetpack' ), | ||
); | ||
} | ||
|
||
/** | ||
* Get the product pricing details | ||
* | ||
* @return array Pricing details | ||
*/ | ||
public static function get_pricing_for_ui() { | ||
$product_slug = static::get_wpcom_product_slug(); | ||
return array_merge( | ||
array( | ||
'available' => true, | ||
'wpcom_product_slug' => $product_slug, | ||
), | ||
Wpcom_Products::get_product_pricing( $product_slug ) | ||
); | ||
} | ||
|
||
/** | ||
* Get the WPCOM product slug used to make the purchase | ||
* | ||
* @return string | ||
*/ | ||
public static function get_wpcom_product_slug() { | ||
return 'jetpack_growth_yearly'; | ||
} | ||
|
||
/** | ||
* Checks whether the Jetpack module is active | ||
* | ||
* This is a bundle and not a product. We should not use this information for anything | ||
* | ||
* @return bool | ||
*/ | ||
public static function is_module_active() { | ||
return false; | ||
} | ||
|
||
/** | ||
* Activates the product by installing and activating its plugin | ||
* | ||
* @param WP_Error|bool $current_result Is the result of the top level activation actions. You probably won't do anything if it is an WP_Error. | ||
* @return bool|\WP_Error | ||
*/ | ||
public static function do_product_specific_activation( $current_result ) { | ||
$product_activation = parent::do_product_specific_activation( $current_result ); | ||
|
||
// A bundle is not a module. There's nothing in the plugin to be activated, so it's ok to fail to activate the module. | ||
if ( is_wp_error( $product_activation ) && 'module_activation_failed' === $product_activation->get_error_code() ) { | ||
return $product_activation; | ||
} | ||
|
||
// At this point, Jetpack plugin is installed. Let's activate each individual product. | ||
$activation = Social::activate(); | ||
if ( is_wp_error( $activation ) ) { | ||
return $activation; | ||
} | ||
|
||
$activation = Stats::activate(); | ||
if ( is_wp_error( $activation ) ) { | ||
return $activation; | ||
} | ||
|
||
return $activation; | ||
} | ||
|
||
/** | ||
* Checks whether the Product is active | ||
* | ||
* Growth is a bundle and not a module. Activation takes place on WPCOM. So lets consider it active if jetpack is active and has the plan. | ||
* | ||
* @return bool | ||
*/ | ||
public static function is_active() { | ||
return static::is_jetpack_plugin_active() && static::has_required_plan(); | ||
} | ||
|
||
/** | ||
* Checks whether the current plan (or purchase) of the site already supports the product | ||
* | ||
* @return bool | ||
*/ | ||
public static function has_required_plan() { | ||
$purchases_data = Wpcom_Products::get_site_current_purchases(); | ||
if ( is_wp_error( $purchases_data ) ) { | ||
return false; | ||
} | ||
if ( is_array( $purchases_data ) && ! empty( $purchases_data ) ) { | ||
foreach ( $purchases_data as $purchase ) { | ||
if ( | ||
str_starts_with( $purchase->product_slug, 'jetpack_growth' ) || | ||
str_starts_with( $purchase->product_slug, 'jetpack_complete' ) | ||
) { | ||
return true; | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Checks whether the product is a bundle | ||
* | ||
* @return bool | ||
*/ | ||
public static function is_bundle_product() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Returns all products it contains. | ||
* | ||
* @return array Product slugs | ||
*/ | ||
public static function get_supported_products() { | ||
return array( 'social', 'stats' ); | ||
} | ||
|
||
/** | ||
* Get the URL where the user manages the product | ||
* | ||
* @return string | ||
*/ | ||
public static function get_manage_url() { | ||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.