Created
July 9, 2018 04:49
-
-
Save danielbitzer/54f7ce92b4658a698a7fd0b25c1102a6 to your computer and use it in GitHub Desktop.
[AutomateWoo] Custom session tracking cookies permitted logic
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 | |
/** | |
* 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