Tracks: use woocommerce_apply_user_tracking and woocommerce_apply_tracking

This commit is contained in:
Paul Sealock 2019-05-22 09:18:34 +12:00
parent ca4e79bdd1
commit c74d5b30ca
1 changed files with 8 additions and 4 deletions

View File

@ -18,17 +18,21 @@ class WC_Site_Tracking {
*/
public static function is_tracking_enabled() {
/**
* Don't track users who haven't opted-in to tracking or if a filter
* has been applied to turn it off.
* 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 ) ) {
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.NoNonceVerification, 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;
}