From 23df5f1dc2a5d5c23dfecf32c5d80311b3d32c00 Mon Sep 17 00:00:00 2001 From: Kader Ibrahim S Date: Fri, 25 Aug 2023 21:54:17 +0530 Subject: [PATCH] Fixes admin notices not thrown in compat checker. (#3) --- .../php/compat-checker/src/Checks/CompatCheck.php | 9 +-------- .../php/compat-checker/src/Checks/WCCompatibility.php | 11 ++++++++--- .../php/compat-checker/src/Checks/WPCompatibility.php | 1 + 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/php/compat-checker/src/Checks/CompatCheck.php b/packages/php/compat-checker/src/Checks/CompatCheck.php index 70103d16..74da2deb 100644 --- a/packages/php/compat-checker/src/Checks/CompatCheck.php +++ b/packages/php/compat-checker/src/Checks/CompatCheck.php @@ -146,13 +146,6 @@ protected function set_plugin_data( $plugin_data ) { public function is_compatible( $plugin_data ) { $this->set_plugin_data( $plugin_data ); add_action( 'admin_notices', array( $this, 'display_admin_notices' ), 20 ); - try { - $this->run_checks(); - $is_compatible = true; - } catch ( IncompatibleException $e ) { - $is_compatible = false; - } - - return $is_compatible; + return $this->run_checks(); } } diff --git a/packages/php/compat-checker/src/Checks/WCCompatibility.php b/packages/php/compat-checker/src/Checks/WCCompatibility.php index bf77d868..e59e5315 100644 --- a/packages/php/compat-checker/src/Checks/WCCompatibility.php +++ b/packages/php/compat-checker/src/Checks/WCCompatibility.php @@ -377,8 +377,13 @@ public function make_upgrade_recommendation() { * Run all compatibility checks. */ protected function run_checks() { - $this->check_wc_installation_and_activation(); - $this->check_wc_version(); - $this->check_wc_upgrade_recommendation(); + try { + $this->check_wc_installation_and_activation(); + $this->check_wc_version(); + $this->check_wc_upgrade_recommendation(); + return true; + } catch ( IncompatibleException $e ) { + return false; + } } } diff --git a/packages/php/compat-checker/src/Checks/WPCompatibility.php b/packages/php/compat-checker/src/Checks/WPCompatibility.php index ac28b648..67b0d886 100644 --- a/packages/php/compat-checker/src/Checks/WPCompatibility.php +++ b/packages/php/compat-checker/src/Checks/WPCompatibility.php @@ -54,5 +54,6 @@ public function wp_not_tested() { */ protected function run_checks() { $this->check_wp_version(); + return true; } }