1(function () { 2 const allAPICats = ["functional", "statistics", "marketing", "preferences"] 3 4 function wpInitConsent() { 5 if (window.wpConsentData && wpConsentData.consents) { 6 const saved = wpConsentData.consents 7 8 wp_set_consent("functional", saved["functional-cookies"] || "deny"); 9 wp_set_consent("statistics", saved["statistics-cookies"] || "deny"); 10 wp_set_consent("marketing", saved["marketing-cookies"] || "deny"); 11 wp_set_consent("preferences", saved["preferences-cookies"] || "deny"); 12 } 13 } 14 15 function consentWithoutCategories() { 16 CookieScript.instance.onAcceptAll = function () { 17 wp_set_consent("functional", "allow"); 18 wp_set_consent("statistics", "allow"); 19 wp_set_consent("marketing", "allow"); 20 wp_set_consent("preferences", "allow"); 21 }; 22 23 CookieScript.instance.onAccept = function (categories) { 24 wp_set_consent("functional", "allow"); 25 wp_set_consent("statistics", "allow"); 26 wp_set_consent("marketing", "allow"); 27 wp_set_consent("preferences", "allow"); 28 }; 29 30 CookieScript.instance.onReject = function () { 31 wp_set_consent("functional", "deny"); 32 wp_set_consent("statistics", "deny"); 33 wp_set_consent("marketing", "deny"); 34 wp_set_consent("preferences", "deny"); 35 }; 36 } 37 38 function clearConsentCookies() { 39 allAPICats.forEach(cat => { 40 const name = "wp_consent_" + cat 41 document.cookie = name + "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT" 42 }) 43 } 44 45 if (typeof CookieScript === "undefined") { 46 window.wp_consent_type = "optin" 47 document.dispatchEvent(new CustomEvent("wp_consent_type_defined")) 48 49 if (typeof wp_set_consent === "function") { 50 allAPICats.forEach(cat => wp_set_consent(cat, "deny")) 51 } 52 53 clearConsentCookies() 54 55 return 56 } 57 58 window.wp_consent_type = "optin" 59 document.dispatchEvent(new CustomEvent("wp_consent_type_defined")) 60 61 const mapCsCat = { 62 strict: "functional", 63 performance: "statistics", 64 targeting: "marketing", 65 functionality: "preferences", 66 unclassified: "preferences" 67 } 68 69 function syncConsent() { 70 if (typeof wp_set_consent !== "function") return 71 const currentState = CookieScript.instance.currentState() 72 const csCats = currentState.categories ?? [] 73 const mapCats = csCats.map(cat => mapCsCat[cat]).filter(Boolean) 74 const consentAction = currentState.action 75 const saved = (window.wpConsentData && window.wpConsentData.consents) ? window.wpConsentData.consents : {}; 76 77 if (!consentAction) { 78 wpInitConsent() 79 return 80 } 81 82 if (mapCats.length === 0) { 83 consentWithoutCategories() 84 return 85 } 86 87 wp_set_consent("functional", "allow"); 88 89 ["statistics", "marketing", "preferences"].forEach(apiCat => { 90 const savedValue = saved[apiCat + "-cookies"]; 91 92 if (savedValue === "ignore") { 93 return; 94 } 95 96 if (mapCats.includes(apiCat)) { 97 wp_set_consent(apiCat, "allow") 98 } else { 99 wp_set_consent(apiCat, "deny") 100 } 101 }) 102 } 103 104 ["DOMContentLoaded", "CookieScriptLoaded", "CookieScriptAccept", "CookieScriptReject", "CookieScriptAcceptAll", "CookieScriptRejectAll"] 105 .forEach(evt => document.addEventListener(evt, syncConsent)) 106 107 document.addEventListener("wp_listen_for_consent_change", syncConsent) 108})()
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.