forked from Really-Simple-Plugins/consent-api-example-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.min.js
1 lines (1 loc) · 1.31 KB
/
main.min.js
1
jQuery(document).ready(function($){var consentCategory=$("#example-plugin-content").data("consentcategory");console.log("checking consent for category "+consentCategory);console.log("load plugin example");document.addEventListener("wp_listen_for_consent_change",function(e){console.log("listen for consent events");var changedConsentCategory=e.detail;console.log(changedConsentCategory);for(var key in changedConsentCategory){if(changedConsentCategory.hasOwnProperty(key)){if(key===consentCategory&&changedConsentCategory[key]==="allow"){console.log("set "+consentCategory+" cookie on user actions");activateConsent()}}}});$(document).on("wp_consent_type_defined",activateMyCookies);function activateMyCookies(consentData){if(wp_has_consent(consentCategory)){console.log("do "+consentCategory+" cookie stuff")}else{console.log("no "+consentCategory+" cookies please")}}if(!window.waitfor_consent_hook){console.log("we don't have to wait for the consent type, we can check the consent level right away!");if(wp_has_consent(consentCategory)){activateConsent();console.log("set "+consentCategory+" stuff now!")}else{console.log("No "+consentCategory+" stuff please!")}}function activateConsent(){console.log("fire "+consentCategory);$("#example-plugin-content .functional-content").hide();$("#example-plugin-content .marketing-content").show()}});