diff --git a/changelog.txt b/changelog.txt index 306397f6d..d0119b212 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/readme.txt b/readme.txt index bc7fda59e..1a3bc74a0 100644 --- a/readme.txt +++ b/readme.txt @@ -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 diff --git a/woocommerce-paypal-payments.php b/woocommerce-paypal-payments.php index 8bb582382..6c7b42d83 100644 --- a/woocommerce-paypal-payments.php +++ b/woocommerce-paypal-payments.php @@ -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' ); + } + } )();