From df661b96f27e215c13e137210cc583d648159b79 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Fri, 18 Apr 2025 15:58:12 +0200 Subject: [PATCH 1/6] Fixed: Function _load_textdomain_just_in_time was called incorrectly in WP 6.8 --- src/Plugin.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Plugin.php b/src/Plugin.php index bcd28af..1e79e69 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -42,9 +42,11 @@ public function setup() { * @return void */ public function register_services() { + if ( is_admin() ) { + add_action( 'init', [ $this, 'load_settings' ] ); + new Admin\Upgrades(); - new Admin\Settings\Page(); new Admin\Filters(); new Admin\Actions(); new Admin\Module(); @@ -60,6 +62,10 @@ public function register_services() { new Proxy(); } + public function load_settings() { + new Admin\Settings\Page(); + } + /** * Loads the plugin's translated strings. * From 999eab3333c2305b04d2801e089826554724e338 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Fri, 18 Apr 2025 17:10:05 +0200 Subject: [PATCH 2/6] Improved: is_wc_active and is_edd_active methods did too much. --- src/Integrations.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Integrations.php b/src/Integrations.php index 247c29d..5168300 100644 --- a/src/Integrations.php +++ b/src/Integrations.php @@ -27,12 +27,12 @@ public function __construct() { */ private function init() { // WooCommerce - if ( self::is_wc_active() ) { + if ( self::is_wc_active() && Helpers::is_enhanced_measurement_enabled( 'revenue' ) ) { new Integrations\WooCommerce(); } // Easy Digital Downloads - if ( self::is_edd_active() ) { + if ( self::is_edd_active() && Helpers::is_enhanced_measurement_enabled( 'revenue' ) ) { new Integrations\EDD(); } @@ -47,7 +47,7 @@ private function init() { * @return bool */ public static function is_wc_active() { - return apply_filters( 'plausible_analytics_integrations_woocommerce', function_exists( 'WC' ) && Helpers::is_enhanced_measurement_enabled( 'revenue' ) ); + return apply_filters( 'plausible_analytics_integrations_woocommerce', function_exists( 'WC' ) ); } /** @@ -55,7 +55,7 @@ public static function is_wc_active() { * @return bool */ public static function is_edd_active() { - return apply_filters( 'plausible_analytics_integrations_edd', function_exists( 'EDD' ) && Helpers::is_enhanced_measurement_enabled( 'revenue' ) ); + return apply_filters( 'plausible_analytics_integrations_edd', function_exists( 'EDD' ) ); } /** From 3183e2b8ff9ff499e7a6b552172f021867451222 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Fri, 18 Apr 2025 17:11:57 +0200 Subject: [PATCH 3/6] Fixed: Translation loading for the plausible-analytics domain was triggered too early. --- src/Plugin.php | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 1e79e69..3c2c062 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -45,16 +45,16 @@ public function register_services() { if ( is_admin() ) { add_action( 'init', [ $this, 'load_settings' ] ); - + add_action( 'init', [ $this, 'load_provisioning' ] ); + add_action( 'init', [ $this, 'load_integrations_provisioning' ] ); + new Admin\Upgrades(); new Admin\Filters(); new Admin\Actions(); new Admin\Module(); - new Admin\Provisioning(); - new Admin\Provisioning\Integrations(); } - new Integrations(); + add_action( 'init', [ $this, 'load_integrations' ] ); new Actions(); new Ajax(); new Compatibility(); @@ -66,6 +66,33 @@ public function load_settings() { new Admin\Settings\Page(); } + /** + * Load @see Admin\Provisioning() + * + * @return void + */ + public function load_provisioning() { + new Admin\Provisioning(); + } + + /** + * Load @see Admin\Provisioning\Integrations() + * + * @return void + */ + public function load_integrations_provisioning() { + new Admin\Provisioning\Integrations(); + } + + /** + * Load @see Integrations() + * + * @return void + */ + public function load_integrations() { + new Integrations(); + } + /** * Loads the plugin's translated strings. * From b9329b15820c5085c1d43fdce161ad7b07dfc010 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Fri, 18 Apr 2025 20:29:29 +0200 Subject: [PATCH 4/6] Ignore this code, because there's nothing to test. --- src/Plugin.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Plugin.php b/src/Plugin.php index 3c2c062..5a893d4 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -46,7 +46,6 @@ public function register_services() { if ( is_admin() ) { add_action( 'init', [ $this, 'load_settings' ] ); add_action( 'init', [ $this, 'load_provisioning' ] ); - add_action( 'init', [ $this, 'load_integrations_provisioning' ] ); new Admin\Upgrades(); new Admin\Filters(); @@ -62,6 +61,13 @@ public function register_services() { new Proxy(); } + /** + * Load @see Admin\Settings\Page() + * + * @return void + * + * @codeCoverageIgnore + */ public function load_settings() { new Admin\Settings\Page(); } @@ -70,17 +76,11 @@ public function load_settings() { * Load @see Admin\Provisioning() * * @return void + * + * @codeCoverageIgnore */ public function load_provisioning() { new Admin\Provisioning(); - } - - /** - * Load @see Admin\Provisioning\Integrations() - * - * @return void - */ - public function load_integrations_provisioning() { new Admin\Provisioning\Integrations(); } @@ -88,6 +88,8 @@ public function load_integrations_provisioning() { * Load @see Integrations() * * @return void + * + * @codeCoverageIgnore */ public function load_integrations() { new Integrations(); From 84e23406b128a8366e46ed499085c19cec80783b Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Fri, 18 Apr 2025 20:31:59 +0200 Subject: [PATCH 5/6] is_edd_recurring_active did too much. --- src/Integrations.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Integrations.php b/src/Integrations.php index 5168300..3a71a99 100644 --- a/src/Integrations.php +++ b/src/Integrations.php @@ -71,6 +71,6 @@ public static function is_form_submit_active() { * @return mixed|null */ public static function is_edd_recurring_active() { - return apply_filters( 'plausible_analytics_integrations_edd_recurring', function_exists( 'EDD_Recurring' ) && Helpers::is_enhanced_measurement_enabled( 'revenue' ) ); + return apply_filters( 'plausible_analytics_integrations_edd_recurring', function_exists( 'EDD_Recurring' ) ); } } From f423fcf33000a64d6f75ee9d1688e2ab75d9acee Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Fri, 18 Apr 2025 20:34:08 +0200 Subject: [PATCH 6/6] Minor refactor. --- src/Integrations.php | 10 +--------- tests/integration/IntegrationsTest.php | 11 ----------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Integrations.php b/src/Integrations.php index 3a71a99..e54a640 100644 --- a/src/Integrations.php +++ b/src/Integrations.php @@ -37,7 +37,7 @@ private function init() { } // Form Plugins - if ( self::is_form_submit_active() ) { + if ( Helpers::is_enhanced_measurement_enabled( 'form-completions' ) ) { new Integrations\FormSubmit(); } } @@ -58,14 +58,6 @@ public static function is_edd_active() { return apply_filters( 'plausible_analytics_integrations_edd', function_exists( 'EDD' ) ); } - /** - * Check if Form Submissions option is enabled in Enhanced Measurements. - * @return mixed|null - */ - public static function is_form_submit_active() { - return apply_filters( 'plausible_analytics_integrations_form_submit', Helpers::is_enhanced_measurement_enabled( 'form-completions' ) ); - } - /** * Checks if EDD Recurring is installed and activated. * @return mixed|null diff --git a/tests/integration/IntegrationsTest.php b/tests/integration/IntegrationsTest.php index 6873e23..22b4bb8 100644 --- a/tests/integration/IntegrationsTest.php +++ b/tests/integration/IntegrationsTest.php @@ -50,15 +50,4 @@ public function testIsEddActive() { remove_filter( 'plausible_analytics_integrations_edd', '__return_true' ); } - - /** - * Determines if the form submission functionality is currently active. - */ - public function isFormSubmitActive() { - add_filter( 'plausible_analytics_integrations_form_submit', '__return_true' ); - - $this->assertTrue( Integrations::is_form_submit_active() ); - - remove_filter( 'plausible_analytics_integrations_form_submit', '__return_true' ); - } }