WC_Site_Tracking::is_tracking_enabled()

Check if tracking is enabled.


Description Description


Return Return

(bool)


Top ↑

Source Source

File: includes/tracks/class-wc-site-tracking.php

19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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.
     */
    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;
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.