=' ); if ( ! $minimum_woocommerce_active ) { return false; } return true; } /** * This is our constructor, which is private to force the use of get_instance() * * @return void */ private function __construct() { // loading _wca. add_action( 'wp_head', array( $this, 'wp_head_top' ), 1 ); // loading s.js. add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_tracking_script' ) ); self::$analytics = new Jetpack_WooCommerce_Analytics_Universal(); self::$myaccount = new Jetpack_WooCommerce_Analytics_My_Account(); if ( class_exists( 'Automattic\WooCommerce\Blocks\Package' ) && version_compare( Automattic\WooCommerce\Blocks\Package::get_version(), '11.6.2', '>=' ) ) { self::$views = new Jetpack_WooCommerce_Analytics_Checkout_Flow(); } } /** * Make _wca available to queue events */ public function wp_head_top() { if ( is_cart() || is_checkout() || is_checkout_pay_page() || is_order_received_page() || is_add_payment_method_page() ) { echo '' . "\r\n"; } echo '' . "\r\n"; } /** * Place script to call s.js, Store Analytics. */ public function enqueue_tracking_script() { $url = sprintf( 'https://stats.wp.com/s-%d.js', gmdate( 'YW' ) ); wp_enqueue_script( 'woocommerce-analytics', $url, array(), null, // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion -- The version is set in the URL. array( 'in_footer' => false, 'strategy' => 'defer', ) ); } /** * Function to instantiate our class and make it a singleton */ public static function get_instance() { if ( ! self::should_track_store() ) { return; } if ( ! self::$instance ) { self::$instance = new self(); } return self::$instance; } } global $jetpack_woocommerce_analytics; $jetpack_woocommerce_analytics = Jetpack_WooCommerce_Analytics::get_instance();