From 4c7f985ac602bff944378512da6519b188e98e67 Mon Sep 17 00:00:00 2001 From: Dan0sz <18595395+Dan0sz@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:59:37 +0200 Subject: [PATCH] Fixed: only add manual.js on Search pages. --- src/Actions.php | 2 +- src/Helpers.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Actions.php b/src/Actions.php index 6e2ee22..29918a7 100644 --- a/src/Actions.php +++ b/src/Actions.php @@ -84,7 +84,7 @@ public function maybe_register_assets() { // Track search results. Tracks a search event with the search term and the number of results, and a pageview with the site's search URL. if ( Helpers::is_enhanced_measurement_enabled( 'search' ) && is_search() ) { - global $wp_rewrite, $wp_query; + global $wp_query; $data = wp_json_encode( [ diff --git a/src/Helpers.php b/src/Helpers.php index fb8dd79..39c176a 100644 --- a/src/Helpers.php +++ b/src/Helpers.php @@ -76,7 +76,7 @@ public static function get_filename( $local = false ) { } // Add the manual scripts as we need it to track the search parameter. - if ( self::is_enhanced_measurement_enabled( 'search' ) ) { + if ( is_search() && self::is_enhanced_measurement_enabled( 'search' ) ) { $file_name .= '.manual'; // @codeCoverageIgnore }