Merge pull request #498 from woocommerce/PCP-524-check-if-woocommerce-is-active-mu-plugins

Change the way of checking if WooCommerce is active
This commit is contained in:
Emili Castells 2022-02-23 10:03:04 +01:00 committed by GitHub
commit 2cb0efb10a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 8 deletions

View file

@ -4,6 +4,7 @@
* Fix - DCC orders randomly failing #503
* Fix - Multi-currency broke #481
* Fix - Address information from PayPal shortcut flow not loaded #451
* Fix - WooCommerce as mu-plugin is not detected as active #461
* Enhancement - Improve onboarding flow, allow no card processing #443
* Enhancement - Add Germany to supported ACDC countries #459
* Enhancement - Add filters to allow ACDC for countries #437

View file

@ -85,6 +85,7 @@ Follow the steps below to connect the plugin to your PayPal account:
* Fix - DCC orders randomly failing #503
* Fix - Multi-currency broke #481
* Fix - Address information from PayPal shortcut flow not loaded #451
* Fix - WooCommerce as mu-plugin is not detected as active #461
* Enhancement - Improve onboarding flow, allow no card processing #443
* Enhancement - Add Germany to supported ACDC countries #459
* Enhancement - Add filters to allow ACDC for countries #437

View file

@ -41,10 +41,7 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
function init() {
$root_dir = __DIR__;
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
if ( ! is_woocommerce_activated() ) {
add_action(
'admin_notices',
function() {
@ -124,10 +121,7 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
add_filter(
'plugin_action_links_' . plugin_basename( __FILE__ ),
function( $links ) {
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
if ( ! is_woocommerce_activated() ) {
return $links;
}
@ -144,4 +138,13 @@ define( 'PPCP_FLAG_SUBSCRIPTION', true );
}
);
/**
* Check if WooCommerce is active.
*
* @return bool true if WooCommerce is active, otherwise false.
*/
function is_woocommerce_activated(): bool {
return class_exists( 'woocommerce' );
}
} )();