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. *