Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
Created July 9, 2018 04:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbitzer/54f7ce92b4658a698a7fd0b25c1102a6 to your computer and use it in GitHub Desktop.
Save danielbitzer/54f7ce92b4658a698a7fd0b25c1102a6 to your computer and use it in GitHub Desktop.
[AutomateWoo] Custom session tracking cookies permitted logic
<?php
/**
* Using this filter will completely override the value of 'Require cookie consent' in settings.
* Presubmit tracking is depending on session tracking so this filter will also control when presubmit tracking is permitted
* (unless presubmit tracking is completely disabled in settings).
*/
add_filter( 'automatewoo/session_tracking/cookies_permitted', 'my_filter_automatewoo_session_tracking_cookies_permitted' );
/**
* @param bool $permitted
* @return bool
*/
function my_filter_automatewoo_session_tracking_cookies_permitted( $permitted ) {
$cookie_name = 'consent_status';
$cookie = isset( $_COOKIE[ $cookie_name ] ) ? sanitize_text_field( $_COOKIE[ $cookie_name ] ) : false;
if ( $cookie === 'allow' ) {
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment