← All changes
|
modules/woocommerce-analytics/class-jetpack-woocommerce-analytics.php
+17
-5
13.0.2
→
16.3-a.7
View file →
| @@ -4,12 +4,10 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package automattic/jetpack |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -use Automattic\Jetpack\Assets; | |
| 9 | - | |
| 10 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | - exit; | |
| 9 | + exit( 0 ); | |
| 12 | 10 | } |
| 13 | 11 | |
| 14 | 12 | require __DIR__ . '/classes/class-jetpack-woocommerce-analytics-trait.php'; |
| 15 | 13 | require_once __DIR__ . '/classes/class-jetpack-woocommerce-analytics-universal.php'; |
| @@ -113,14 +111,28 @@ | ||
| 113 | 111 | /** |
| 114 | 112 | * Place script to call s.js, Store Analytics. |
| 115 | 113 | */ |
| 116 | 114 | public function enqueue_tracking_script() { |
| 117 | - $filename = sprintf( | |
| 115 | + // No store activity to track on 404 pages. | |
| 116 | + if ( is_404() ) { | |
| 117 | + return; | |
| 118 | + } | |
| 119 | + | |
| 120 | + $url = sprintf( | |
| 118 | 121 | 'https://stats.wp.com/s-%d.js', |
| 119 | 122 | gmdate( 'YW' ) |
| 120 | 123 | ); |
| 121 | 124 | |
| 122 | - Assets::enqueue_async_script( 'woocommerce-analytics', esc_url( $filename ), esc_url( $filename ), array(), null, false ); | |
| 125 | + wp_enqueue_script( | |
| 126 | + 'woocommerce-analytics', | |
| 127 | + $url, | |
| 128 | + array(), | |
| 129 | + null, // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- The version is set in the URL. | |
| 130 | + array( | |
| 131 | + 'in_footer' => false, | |
| 132 | + 'strategy' => 'defer', | |
| 133 | + ) | |
| 134 | + ); | |
| 123 | 135 | } |
| 124 | 136 | |
| 125 | 137 | /** |
| 126 | 138 | * Function to instantiate our class and make it a singleton |