From cfac2e6b96b6b1a17e93261120096bcb5a64cab8 Mon Sep 17 00:00:00 2001
From: Dan0sz <18595395+Dan0sz@users.noreply.github.com>
Date: Tue, 8 Oct 2024 09:27:57 +0200
Subject: [PATCH] Fixed: Cloudflare, WPFC, LiteSpeed and Autoptimize
compatibility for Minimal Analytics. Removed caos_script_custom_attributes
filter, because it's no longer used in the plugin.
---
includes/compatibility/class-autoptimize.php | 3 ++-
includes/compatibility/class-cloudflare.php | 3 ++-
includes/compatibility/class-litespeed.php | 3 ++-
includes/compatibility/class-wp-fastest-cache.php | 3 ++-
includes/frontend/class-tracking.php | 4 ----
templates/frontend-tracking-code-minimal-ga4.phtml | 7 ++++---
6 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/includes/compatibility/class-autoptimize.php b/includes/compatibility/class-autoptimize.php
index 1eaf1df..775de71 100644
--- a/includes/compatibility/class-autoptimize.php
+++ b/includes/compatibility/class-autoptimize.php
@@ -27,7 +27,8 @@ public function __construct() {
* @return void
*/
private function init() {
- add_filter( 'caos_script_custom_attributes', [ $this, 'exclude_from_autoptimize' ] );
+ add_filter( 'caos_gtag_custom_attributes', [ $this, 'exclude_from_autoptimize' ] );
+ add_filter( 'caos_ma4_custom_attributes', [ $this, 'exclude_from_autoptimize' ] );
}
/**
diff --git a/includes/compatibility/class-cloudflare.php b/includes/compatibility/class-cloudflare.php
index c789b1a..b4ea036 100644
--- a/includes/compatibility/class-cloudflare.php
+++ b/includes/compatibility/class-cloudflare.php
@@ -27,7 +27,8 @@ public function __construct() {
* @return void
*/
private function init() {
- add_filter( 'caos_script_custom_attributes', [ $this, 'exclude_from_cloudflare' ] );
+ add_filter( 'caos_gtag_custom_attributes', [ $this, 'exclude_from_cloudflare' ] );
+ add_filter( 'caos_ma4_custom_attributes', [ $this, 'exclude_from_cloudflare' ] );
}
/**
diff --git a/includes/compatibility/class-litespeed.php b/includes/compatibility/class-litespeed.php
index 73ace82..376d25e 100644
--- a/includes/compatibility/class-litespeed.php
+++ b/includes/compatibility/class-litespeed.php
@@ -27,7 +27,8 @@ public function __construct() {
* @return void
*/
private function init() {
- add_filter( 'caos_script_custom_attributes', [ $this, 'exclude_from_litespeed' ] );
+ add_filter( 'caos_gtag_custom_attributes', [ $this, 'exclude_from_litespeed' ] );
+ add_filter( 'caos_ma4_custom_attributes', [ $this, 'exclude_from_litespeed' ] );
}
/**
diff --git a/includes/compatibility/class-wp-fastest-cache.php b/includes/compatibility/class-wp-fastest-cache.php
index 503a73b..c7cd01d 100644
--- a/includes/compatibility/class-wp-fastest-cache.php
+++ b/includes/compatibility/class-wp-fastest-cache.php
@@ -27,7 +27,8 @@ public function __construct() {
* @return void
*/
private function init() {
- add_filter( 'caos_script_custom_attributes', [ $this, 'exclude_from_wpfc' ] );
+ add_filter( 'caos_gtag_custom_attributes', [ $this, 'exclude_from_wpfc' ] );
+ add_filter( 'caos_ma4_custom_attributes', [ $this, 'exclude_from_wpfc' ] );
}
/**
diff --git a/includes/frontend/class-tracking.php b/includes/frontend/class-tracking.php
index 583c999..09c2cb3 100644
--- a/includes/frontend/class-tracking.php
+++ b/includes/frontend/class-tracking.php
@@ -444,10 +444,6 @@ public function add_attributes( $tag, $handle ) {
$tag = str_replace( 'script src', 'script async src', $tag );
}
- if ( $handle === $this->handle && $custom_attributes = apply_filters( 'caos_script_custom_attributes', '' ) ) {
- return str_replace( '
-