Files
Testing/blog/wp-content/plugins/cookiebot/js/cookiebot-wp-consent-level-api-integration.js
sean 0e8a8b3028
Some checks failed
deploy-testing / deploy (push) Has been cancelled
Initial testing snapshot
2026-11-17 16:15:01 -05:00

35 lines
1.2 KiB
JavaScript

'use strict';
window.wp_consent_type = 'optin';
window.addEventListener('CookiebotOnAccept', cookiebot_update_consent_level, false);
window.addEventListener('CookiebotOnDecline', cookiebot_update_consent_level, false);
window.addEventListener('load', cookiebot_update_consent_level, false);
function cookiebot_update_consent_level(e) {
wp_set_consent( 'functional', 'allow' ); //always allow functional cookies
if ( typeof Cookiebot === 'undefined' ) {
var consentMappingKey = 'n=1;p=1;s=1;m=1';
}
else {
var consentMappingKey = 'n=1;';
consentMappingKey = consentMappingKey + 'p=' + ( ( Cookiebot.consent.preferences ) ? '1' : '0' ) + ';';
consentMappingKey = consentMappingKey + 's=' + ( ( Cookiebot.consent.statistics ) ? '1' : '0' ) + ';';
consentMappingKey = consentMappingKey + 'm=' + ( ( Cookiebot.consent.marketing ) ? '1' : '0' );
}
for( var key in cookiebot_category_mapping[consentMappingKey] ) {
var strValue = cookiebot_category_mapping[consentMappingKey][key] ? 'allow' : 'deny';
if( ( wp_has_consent( key ) && strValue != 'allow' ) || ( !wp_has_consent(key) && strValue == 'allow' ) ) {
wp_set_consent( key, strValue );
}
}
}