WC_Site_Tracking::is_tracking_enabled()public staticWC 1.0

Check if tracking is enabled.

Method of the class: WC_Site_Tracking{}

Hooks from the method

Return

true|false.

Usage

$result = WC_Site_Tracking::is_tracking_enabled();

WC_Site_Tracking::is_tracking_enabled() code WC 8.6.1

public static function is_tracking_enabled() {
	/**
	 * Don't track users if a filter has been applied to turn it off.
	 * `woocommerce_apply_tracking` will be deprecated. Please use
	 * `woocommerce_apply_user_tracking` instead.
	 *
	 * @since 3.6.0
	 */
	if ( ! apply_filters( 'woocommerce_apply_user_tracking', true ) || ! apply_filters( 'woocommerce_apply_tracking', true ) ) {
		return false;
	}

	// Check if tracking is actively being opted into.
	$is_obw_opting_in = isset( $_POST['wc_tracker_checkbox'] ) && 'yes' === sanitize_text_field( $_POST['wc_tracker_checkbox'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput

	/**
	 * Don't track users who haven't opted-in to tracking or aren't in
	 * the process of opting-in.
	 */
	if ( 'yes' !== get_option( 'woocommerce_allow_tracking' ) && ! $is_obw_opting_in ) {
		return false;
	}

	if ( ! class_exists( 'WC_Tracks' ) ) {
		return false;
	}

	return true;
}