From e8d1b2ee16b71cc2cfaa7ffac7ccd68639678de1 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Thu, 17 Feb 2022 16:52:40 +0400 Subject: [PATCH 1/2] Change the way of checking if WooCommerce is active This needs to be done because of problem if WooCommerce is installed as MU plugin --- woocommerce-paypal-payments.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/woocommerce-paypal-payments.php b/woocommerce-paypal-payments.php index 81531358a..11b81b5fb 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() { @@ -112,10 +109,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; } @@ -132,4 +126,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' ); + } + } )(); From 672959dd475a699dddd7a8986f86884566578baf Mon Sep 17 00:00:00 2001 From: dinamiko Date: Wed, 23 Feb 2022 09:59:12 +0100 Subject: [PATCH 2/2] Update changelog --- changelog.txt | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+) 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