Skip to content

Commit

Permalink
Use has_cached_account_connection to decide loading the plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
htdat committed Oct 1, 2021
1 parent a453a88 commit f03f18c
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions includes/class-wc-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,13 @@ public static function check_plugin_dependencies() {
);
}

$res['passed'] = false;
/**
* If WCPay account is connected, still silently load the plugin.
* Can not use self::$account->is_stripe_connected() as many dependencies are not loaded at this point.
*
* @since 3.1.0
*/
$res['passed'] = self::has_cached_account_connection();
return $res;
}

Expand Down Expand Up @@ -486,7 +492,13 @@ public static function check_plugin_dependencies() {
$res['message'] .= ' <a href="' . $deactivate_url . '">' . __( 'Use the bundled version of WooCommerce Admin', 'woocommerce-payments' ) . '</a>';
}

$res['passed'] = false;
/**
* If WCPay account is connected, still silently load the plugin.
* Can not use self::$account->is_stripe_connected() as many dependencies are not loaded at this point.
*
* @since 3.1.0
*/
$res['passed'] = self::has_cached_account_connection();
return $res;
}

Expand Down Expand Up @@ -523,6 +535,16 @@ private static function is_at_plugin_install_page() {
return 'update' === $cur_screen->id && 'plugins' === $cur_screen->parent_base;
}

/**
* Check if the current WCPay Account has cache data.
*
* @return bool True if the cache data exists in wp_options.
*/
private static function has_cached_account_connection(): bool {
$account_data = get_option( 'wcpay_account_data' );
return isset( $account_data['account'] ) && is_array( $account_data['account'] );
}

/**
* Adds links to the plugin's row in the "Plugins" Wp-Admin page.
*
Expand Down

0 comments on commit f03f18c

Please sign in to comment.