Skip to content

Commit

Permalink
Refactor how we derive shown_products & not_shown_products.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottprogrammer committed Jan 17, 2025
1 parent 4c7b9b5 commit 394c879
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
4 changes: 2 additions & 2 deletions projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ public static function get_paid_plans_plugins_requirements() {
$plugin_requirements = array();
foreach ( Products::get_products_classes() as $slug => $product_class ) {
// Skip these- we don't show them in My Jetpack.
if ( in_array( $slug, Products::$not_shown_products, true ) ) {
if ( in_array( $slug, Products::get_not_shown_products(), true ) ) {
continue;
}
if ( ! $product_class::has_paid_plan_for_product() ) {
Expand Down Expand Up @@ -1028,7 +1028,7 @@ public static function alert_if_paid_plan_expiring( array $red_bubble_slugs ) {
$products_included_in_expiring_plan = array();
foreach ( $product_classes as $key => $product ) {
// Skip these- we don't show them in My Jetpack.
if ( in_array( $key, Products::$not_shown_products, true ) ) {
if ( in_array( $key, Products::get_not_shown_products(), true ) ) {
continue;
}

Expand Down
45 changes: 27 additions & 18 deletions projects/packages/my-jetpack/src/class-products.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,6 @@ class Products {
self::STATUS_NEEDS_ATTENTION__ERROR,
);

/**
* List of product slugs that are Not displayed on the main My Jetpack page
*
* @var array
*/
public static $not_shown_products = array(
'creator',
'extras',
'ai', // 'ai' is a duplicate class of 'jetpack-ai', and therefore not needed.
'scan',
'security',
'growth',
'complete',
'newsletter',
'site-accelerator',
'related-posts',
);

/**
* Get the list of Products classes
*
Expand Down Expand Up @@ -194,6 +176,33 @@ public static function get_products_classes() {
return $final_classes;
}

/**
* List of product slugs that are displayed on the main My Jetpack page
*
* @var array
*/
public static $shown_products = array(
'anti-spam',
'backup',
'boost',
'crm',
'jetpack-ai',
'search',
'social',
'protect',
'videopress',
'stats',
);

/**
* Gets the list of product slugs that are Not displayed on the main My Jetpack page
*
* @return array
*/
public static function get_not_shown_products() {
return array_diff( array_keys( static::get_products_classes() ), self::$shown_products );
}

/**
* Product data
*
Expand Down

0 comments on commit 394c879

Please sign in to comment.