From a1c6bac501427f9ab271a4d8f9154ca0e541d89f Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Wed, 17 Jul 2024 10:52:52 +0200 Subject: [PATCH] Remove duplicate filter. --- src/Filters.php | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/Filters.php b/src/Filters.php index 0b9a9774..213cc0d9 100644 --- a/src/Filters.php +++ b/src/Filters.php @@ -27,7 +27,6 @@ class Filters { */ public function __construct() { add_filter( 'script_loader_tag', [ $this, 'add_plausible_attributes' ], 10, 2 ); - add_filter( 'rest_url', [ $this, 'wpml_compatibility' ], 10, 1 ); add_filter( 'plausible_analytics_script_params', [ $this, 'maybe_add_custom_params' ] ); } @@ -43,7 +42,7 @@ public function __construct() { * @return string */ public function add_plausible_attributes( $tag, $handle ) { - // Bailout, if not `Plausible Analytics` script. + // Bail if it's not our script. if ( 'plausible-analytics' !== $handle ) { return $tag; // @codeCoverageIgnore } @@ -61,8 +60,8 @@ public function add_plausible_attributes( $tag, $handle ) { // Triggered when exclude pages is enabled. if ( ! empty( $settings[ 'excluded_pages' ] ) && $settings[ 'excluded_pages' ] ) { - $excluded_pages = $settings[ 'excluded_pages' ]; - $params .= " data-exclude='{$excluded_pages}'"; + $excluded_pages = $settings[ 'excluded_pages' ]; // @codeCoverageIgnore + $params .= " data-exclude='{$excluded_pages}'"; // @codeCoverageIgnore } $params = apply_filters( 'plausible_analytics_script_params', $params ); @@ -70,25 +69,6 @@ public function add_plausible_attributes( $tag, $handle ) { return str_replace( ' src', " {$params} src", $tag ); } - /** - * WPML overrides the REST API URL to include the language 'subdirectory', which leads to 404s. - * This forces it back to default behavior. - * - * @param mixed $url - * - * @return string|void - * @throws Exception - */ - public function wpml_compatibility( $url ) { - $rest_endpoint = Helpers::get_rest_endpoint( false ); - - if ( strpos( $url, $rest_endpoint ) !== false ) { - return get_option( 'home' ) . $rest_endpoint; // @codeCoverageIgnore - } - - return $url; - } - /** * Adds custom parameters Author and Category if Custom Pageview Properties is enabled. *