Last active
September 27, 2022 12:05
-
-
Save danielcharrua/7853b2b1edb68dbce9bd9af7ec93dc4d to your computer and use it in GitHub Desktop.
Block cookies with gdpr-cookie-compliance (Facebook, Analytics, Omnisend)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// https://wordpress.org/plugins/gdpr-cookie-compliance/ | |
/* disable fbp cookie on gdpr_cookie plugin */ | |
add_filter('facebook_for_woocommerce_integration_pixel_enabled', 'gdpr_cookie_facebook_wc', 20); | |
function gdpr_cookie_facebook_wc() | |
{ | |
$enable_fb_wc = true; | |
if (function_exists('gdpr_cookie_is_accepted')) : | |
$enable_fb_wc = gdpr_cookie_is_accepted('thirdparty'); | |
endif; | |
return $enable_fb_wc; | |
} | |
/* disable analytics on gdpr_cookie plugin */ | |
add_filter('woocommerce_ga_disable_tracking', 'gdpr_ga_integration_wc', 20); | |
function gdpr_ga_integration_wc($disable_ga_wc) | |
{ | |
if (function_exists('gdpr_cookie_is_accepted')) : | |
if (!gdpr_cookie_is_accepted('thirdparty')) : | |
$disable_ga_wc = true; | |
endif; | |
endif; | |
return $disable_ga_wc; | |
} | |
/* disable omnisend on gdpr_cookie plugin */ | |
function load_omnisend_with_consent( $value, $option ) { | |
if (function_exists('gdpr_cookie_is_accepted')) : | |
if (!gdpr_cookie_is_accepted('thirdparty')) : | |
return null; | |
endif; | |
endif; | |
return $value; | |
} | |
add_filter( 'option_omnisend_account_id', 'load_omnisend_with_consent', 10, 2 ); | |
/* force reload on gpdr_cookie accept */ | |
add_action('gdpr_force_reload', '__return_true'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment