From 4407d9ed50ddbfd112e430b7096b04caa46546f4 Mon Sep 17 00:00:00 2001 From: Bart van Leeuwen Date: Tue, 18 Feb 2025 11:12:02 +0100 Subject: [PATCH] add PLAUSIBLE_PREFIX support to Helpers.php Allow a different filename in proxy configuration related to issue #228 Some ad blockers bluntly block anything that contains `plausible` Making the $file_name configurable together with the proper rewrite rule solved this. wp_config.php should contain a line like ``` define('PLAUSIBLE_PREFIX','stats') ``` my nginx config now reads: ``` location ~ /js/stats.(?(.*?)).js { proxy_pass https://myplausibel.com/js/plausible.$target.js?ver=2.1.4; proxy_set_header Host myplausible.com; } ``` --- src/Helpers.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Helpers.php b/src/Helpers.php index 39c176a3..d7fc8c8c 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -45,7 +45,10 @@ public static function get_js_url( $local = false ) { */ public static function get_filename( $local = false ) { $settings = self::get_settings(); - $file_name = 'plausible'; + if(defined('PLAUSIBLE_PREFIX')) + $file_name = PLAUSIBLE_PREFIX; + else + $file_name = 'plausible'; if ( $local && self::proxy_enabled() ) { return self::get_proxy_resource( 'file_alias' );