Skip to content

Commit

Permalink
Check if methods exist before using
Browse files Browse the repository at this point in the history
  • Loading branch information
chihsuan committed Sep 3, 2024
1 parent 18f7d65 commit e4a48f7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions class-wc-calypso-bridge-dotcom-features.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,18 @@ private static function has_plan( $plan, $exact_one_plan = false ) {
}

$all_site_purchases = wpcom_get_site_purchases();
$bundles = wp_list_filter( wpcom_get_site_purchases(), array( 'product_type' => 'bundle' ) );
if ( ! is_array( $all_site_purchases ) ) {
return false;
}

$bundles = wp_list_filter( $all_site_purchases, array( 'product_type' => 'bundle' ) );

if ( $exact_one_plan && count( $bundles ) !== 1 ) {
return false;
}

foreach ( $bundles as $bundle ) {
if ( $bundle->billing_product_slug === $plan ) {
if ( isset( $bundle->billing_product_slug ) && $bundle->billing_product_slug === $plan ) {
return true;
}
}
Expand Down

0 comments on commit e4a48f7

Please sign in to comment.