WF Cookie Consent - Version 1.1.0

Version Description

Better admin default options, performance improvements and iubenda integration added.

Download this release

Release Info

Developer wunderfarm
Plugin Icon 128x128 WF Cookie Consent
Version 1.1.0
Comparing to
See all releases

Code changes from version 1.0.1 to 1.1.0

Files changed (3) hide show
  1. js/cookiechoices.js +203 -257
  2. readme.txt +6 -3
  3. wf-cookie-consent.php +196 -88
js/cookiechoices.js CHANGED
@@ -1,257 +1,203 @@
1
- /*
2
- Copyright 2014 Google Inc. All rights reserved.
3
-
4
- Licensed under the Apache License, Version 2.0 (the "License");
5
- you may not use this file except in compliance with the License.
6
- You may obtain a copy of the License at
7
-
8
- http://www.apache.org/licenses/LICENSE-2.0
9
-
10
- Unless required by applicable law or agreed to in writing, software
11
- distributed under the License is distributed on an "AS IS" BASIS,
12
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- See the License for the specific language governing permissions and
14
- limitations under the License.
15
- */
16
-
17
- (function(window) {
18
-
19
- if (!!window.cookieChoices) {
20
- return window.cookieChoices;
21
- }
22
-
23
- var cookieChoices = (function() {
24
-
25
- var cookieName = 'displayCookieConsent';
26
- var cookieConsentId = 'cookieChoiceInfo';
27
- var dismissLinkId = 'cookieChoiceDismiss';
28
- var dismissIconId = 'cookieChoiceDismissIcon';
29
-
30
- function showCookieBar(data) {
31
-
32
- if (typeof data != 'undefined' && typeof data.linkHref != 'undefined') {
33
-
34
- data.position = data.position || "bottom";
35
- data.language = data.language || "en";
36
- data.styles = data.styles || 'position:fixed; width:100%; background-color:#EEEEEE; background-color:rgba(238, 238, 238, 0.9); margin:0; left:0; ' + data.position + ':0; padding:4px; z-index:1000; text-align:center;';
37
-
38
-
39
- switch (data.language) {
40
-
41
- case "de":
42
-
43
- data.cookieText = data.cookieText || "Cookies erleichtern die Bereitstellung unserer Dienste. Mit der Nutzung unserer Dienste erklären Sie sich damit einverstanden, dass wir Cookies verwenden. ";
44
- data.dismissText = data.dismissText || "OK";
45
- data.linkText = data.linkText || "Weitere Informationen";
46
-
47
- break;
48
-
49
- case "it":
50
-
51
- data.cookieText = data.cookieText || "I cookie ci aiutano ad erogare servizi di qualità. Utilizzando i nostri servizi, l'utente accetta le nostre modalità d'uso dei cookie.";
52
- data.dismissText = data.dismissText || "OK";
53
- data.linkText = data.linkText || "Ulteriori informazioni";
54
-
55
- break;
56
-
57
- case "fr":
58
-
59
- data.cookieText = data.cookieText || "Les cookies nous permettent de vous proposer nos services plus facilement. En utilisant nos services, vous nous donnez expressément votre accord pour exploiter ces cookies.";
60
- data.dismissText = data.dismissText || "OK";
61
- data.linkText = data.linkText || "En savoir plus";
62
-
63
- break;
64
-
65
- case "nl":
66
-
67
- data.cookieText = data.cookieText || "Cookies helpen ons bij het leveren van onze diensten. Door gebruik te maken van onze diensten, gaat u akkoord met ons gebruik van cookies.";
68
- data.dismissText = data.dismissText || "OK";
69
- data.linkText = data.linkText || "Meer informatie";
70
-
71
- break;
72
-
73
- case "fi":
74
-
75
- data.cookieText = data.cookieText || "Evästeet auttavat meitä palvelujemme toimituksessa. Käyttämällä palvelujamme hyväksyt evästeiden käytön.";
76
- data.dismissText = data.dismissText || "Selvä";
77
- data.linkText = data.linkText || "Lisätietoja";
78
-
79
- break;
80
-
81
- default:
82
-
83
- data.cookieText = data.cookieText || "Cookies help us deliver our services. By using our services, you agree to our use of cookies.";
84
- data.dismissText = data.dismissText || "Got it";
85
- data.linkText = data.linkText || "Learn more";
86
-
87
- }
88
-
89
- _showCookieConsent(htmlDecode(data.cookieText), htmlDecode(data.dismissText), htmlDecode(data.linkText), data.linkHref, data.styles, false);
90
-
91
- }
92
-
93
- }
94
-
95
- function _createHeaderElement(cookieText, dismissText, linkText, linkHref, styles) {
96
- var butterBarStyles = styles;
97
- var cookieConsentElement = document.createElement('div');
98
- var wrapper = document.createElement('div');
99
- wrapper.style.cssText = "padding-right: 50px;";
100
-
101
- cookieConsentElement.id = cookieConsentId;
102
- cookieConsentElement.style.cssText = butterBarStyles;
103
-
104
- wrapper.appendChild(_createConsentText(cookieText));
105
- if (!!linkText && !!linkHref) {
106
- wrapper.appendChild(_createInformationLink(linkText, linkHref));
107
- }
108
- wrapper.appendChild(_createDismissLink(dismissText));
109
-
110
- cookieConsentElement.appendChild(wrapper);
111
- cookieConsentElement.appendChild(_createDismissIcon());
112
-
113
- return cookieConsentElement;
114
- }
115
-
116
- function _createDialogElement(cookieText, dismissText, linkText, linkHref) {
117
- var glassStyle = 'position:fixed;width:100%;height:100%;z-index:999;' +
118
- 'top:0;left:0;opacity:0.5;filter:alpha(opacity=50);' +
119
- 'background-color:#ccc;';
120
- var dialogStyle = 'z-index:1000;position:fixed;left:50%;top:50%';
121
- var contentStyle = 'position:relative;left:-50%;margin-top:-25%;' +
122
- 'background-color:#fff;padding:20px;box-shadow:4px 4px 25px #888;';
123
-
124
- var cookieConsentElement = document.createElement('div');
125
- cookieConsentElement.id = cookieConsentId;
126
-
127
- var glassPanel = document.createElement('div');
128
- glassPanel.style.cssText = glassStyle;
129
-
130
- var content = document.createElement('div');
131
- content.style.cssText = contentStyle;
132
-
133
- var dialog = document.createElement('div');
134
- dialog.style.cssText = dialogStyle;
135
-
136
- var dismissLink = _createDismissLink(dismissText);
137
- dismissLink.style.display = 'block';
138
- dismissLink.style.textAlign = 'right';
139
- dismissLink.style.marginTop = '8px';
140
-
141
- content.appendChild(_createConsentText(cookieText));
142
- if (!!linkText && !!linkHref) {
143
- content.appendChild(_createInformationLink(linkText, linkHref));
144
- }
145
- content.appendChild(dismissLink);
146
- dialog.appendChild(content);
147
- cookieConsentElement.appendChild(glassPanel);
148
- cookieConsentElement.appendChild(dialog);
149
- return cookieConsentElement;
150
- }
151
-
152
- function _setElementText(element, text) {
153
- // IE8 does not support textContent, so we should fallback to innerText.
154
- var supportsTextContent = 'textContent' in document.body;
155
-
156
- if (supportsTextContent) {
157
- element.textContent = text;
158
- } else {
159
- element.innerText = text;
160
- }
161
- }
162
-
163
- function _createConsentText(cookieText) {
164
- var consentText = document.createElement('span');
165
- _setElementText(consentText, cookieText);
166
- return consentText;
167
- }
168
-
169
- function _createDismissLink(dismissText) {
170
- var dismissLink = document.createElement('a');
171
- _setElementText(dismissLink, dismissText);
172
- dismissLink.id = dismissLinkId;
173
- dismissLink.href = '#';
174
- dismissLink.style.marginLeft = '24px';
175
- return dismissLink;
176
- }
177
-
178
- function _createDismissIcon() {
179
- var dismissIcon = document.createElement('a');
180
- dismissIcon.id = dismissIconId;
181
- dismissIcon.href = '#';
182
- dismissIcon.style.cssText = 'width: 50px; height: 100%; background-size: 20px; display: inline-block; position: absolute; right: 0px; top: 0px; background-position: 34% 50%; background-color: #CCCCCC; background-color: rgba(204, 204, 204, 0.6); background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABixJREFUeNrUW2tsVFUQnlZBaRFQUVFbY/0BKD76UBRUfASj1R9GJBoCiVYIMfgg4a9NjBWQHzSS4CMo8QEagqhBajRifCuaIIgVioooKolIRBCotvKo87lz29nZu2Xv7j1n707yZZN795w5M2fuOTNz5pSRHzpf0MC4hHEeYwRjMON4RhdjD+NXxreMDYzNjHbGXpcDK3PUbwXjUsYNjKsYNYyzRdhcaR/jJ0YH4x3GOsZ2SjiNZsyVQffEDChkDWMyozJpFgDTns2YlGVwvzC+Y3zP2MrYwTgopn+EcSLjBMbpjFGiyJHyOyikvy2MpxnLGAeKOePVMpB/Qmbsa0YLYwLjtDz6LmeMYUxjvCprhOXxDePOYgk/k7HLDAiz+iLjWsbAmPnViJVtCVHEK/LeC2E2V5gBdDOWMC70wB87x3T5lPQYdvmwhoaQGfhEzNw3DZNPbL8ay1FZhMtdMLzJfIeY9WYHpp7PpKw3k7JcFtbY6FZGp2LwM+PGBG2/QxjPGCWsjksJEPRv1fEm2aKSSM1GCdg9BhTSYb0x+88YZybcGZslvkUw5icLWe07zMwnXfiA5hhLeDA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S3rlm751VAsKPkM9Wl/jlXUpfbgIleFBzEj7zX6rx4hMoOM+JWoHVxhIWUPKqx8Yas0ey9+a4OkfUtMoooa2AoClumqmCuWDmYz/lwiLylFECwt4pRRQcE/CCGdMOyXI5I0SKnYbp654dJvglsynzztJ75OnuEC5DbqTMMz6kmxoc8j2FUifY9tpOl+zzg3ya3xCJFfZR5gUqnLzcQ6m64zgW4fGSwNhOmadJH8uEFI0ukO8w7O7g75SqyYETdT2lEq7D+ukLfnqVeHFTxaLaKfwYrUNc3YKy2HHW9dbKanybOCNh1Cku9h4xW3w2OJ87STI8+D2jn/YkyYylsivtT6IzUiUzgzq83VT4nWG447gh+rg4NbEWY7uu7MY2hcuUKGtFgTLq9IZLCq1CtlaM4bCsHTis3CuK+4HxOeMrMfduFwP8T4ABAECF2S1VopbxAAAAAElFTkSuQmCC);';
183
- return dismissIcon;
184
- }
185
-
186
- function _createInformationLink(linkText, linkHref) {
187
- var infoLink = document.createElement('a');
188
- _setElementText(infoLink, linkText);
189
- infoLink.href = linkHref;
190
- infoLink.target = '_blank';
191
- infoLink.style.marginLeft = '8px';
192
- return infoLink;
193
- }
194
-
195
- function _dismissLinkClick() {
196
- _saveUserPreference();
197
- _removeCookieConsent();
198
- return false;
199
- }
200
-
201
- function _showCookieConsent(cookieText, dismissText, linkText, linkHref, styles, isDialog) {
202
- if (_shouldDisplayConsent()) {
203
- _removeCookieConsent();
204
- var consentElement = (isDialog) ?
205
- _createDialogElement(cookieText, dismissText, linkText, linkHref) :
206
- _createHeaderElement(cookieText, dismissText, linkText, linkHref, styles);
207
- var fragment = document.createDocumentFragment();
208
- fragment.appendChild(consentElement);
209
- document.body.appendChild(fragment.cloneNode(true));
210
- document.getElementById(dismissLinkId).onclick = _dismissLinkClick;
211
- document.getElementById(dismissIconId).onclick = _dismissLinkClick;
212
- }
213
- }
214
-
215
- function showCookieConsentBar(cookieText, dismissText, linkText, linkHref) {
216
- _showCookieConsent(cookieText, dismissText, linkText, linkHref, false);
217
- }
218
-
219
- function showCookieConsentDialog(cookieText, dismissText, linkText, linkHref) {
220
- _showCookieConsent(cookieText, dismissText, linkText, linkHref, true);
221
- }
222
-
223
- function _removeCookieConsent() {
224
- var cookieChoiceElement = document.getElementById(cookieConsentId);
225
- if (cookieChoiceElement != null) {
226
- cookieChoiceElement.parentNode.removeChild(cookieChoiceElement);
227
- }
228
- }
229
-
230
- function _saveUserPreference() {
231
- // Set the cookie expiry to one year after today.
232
- var expiryDate = new Date();
233
- expiryDate.setFullYear(expiryDate.getFullYear() + 1);
234
- document.cookie = cookieName + '=y;path=/; expires=' + expiryDate.toGMTString();
235
- }
236
-
237
- function _shouldDisplayConsent() {
238
- // Display the header only if the cookie has not been set.
239
- return !document.cookie.match(new RegExp(cookieName + '=([^;]+)'));
240
- }
241
-
242
- function htmlDecode(input){
243
- var e = document.createElement('textarea');
244
- e.innerHTML = input;
245
- return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
246
- }
247
-
248
- var exports = {};
249
- exports.showCookieBar = showCookieBar;
250
- exports.showCookieConsentBar = showCookieConsentBar;
251
- exports.showCookieConsentDialog = showCookieConsentDialog;
252
- return exports;
253
- })();
254
-
255
- window.cookieChoices = cookieChoices;
256
- return cookieChoices;
257
- })(this);
1
+ /*
2
+ Copyright 2014 Google Inc. All rights reserved.
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ */
16
+
17
+ (function() {
18
+
19
+ var cookieName = 'displayCookieConsent';
20
+ var cookieConsentId = 'cookieChoiceInfo';
21
+ var dismissLinkId = 'cookieChoiceDismiss';
22
+ var dismissIconId = 'cookieChoiceDismissIcon';
23
+
24
+ function showCookieBar() {
25
+ var data = window._wfCookieConsentSettings;
26
+ if (typeof data != 'undefined' && typeof data.wf_linkhref != 'undefined') {
27
+ data.styles = 'position:fixed; width:100%; background-color:#EEEEEE; background-color:rgba(238, 238, 238, 0.9); margin:0; left:0; ' + data.wf_position + ':0; padding:4px; z-index:1000; text-align:center;';
28
+ _showCookieConsent(
29
+ htmlDecode(data.wf_cookietext),
30
+ htmlDecode(data.wf_dismisstext),
31
+ htmlDecode(data.wf_linktext),
32
+ data.wf_linkhref,
33
+ data.styles,
34
+ false
35
+ );
36
+ }
37
+ }
38
+
39
+ function _createHeaderElement(cookieText, dismissText, linkText, linkHref, styles) {
40
+ var butterBarStyles = styles;
41
+ var cookieConsentElement = document.createElement('div');
42
+ var wrapper = document.createElement('div');
43
+ wrapper.style.cssText = "padding-right: 50px;";
44
+
45
+ cookieConsentElement.id = cookieConsentId;
46
+ cookieConsentElement.style.cssText = butterBarStyles;
47
+
48
+ wrapper.appendChild(_createConsentText(cookieText));
49
+ if (!!linkText && !!linkHref) {
50
+ wrapper.appendChild(_createInformationLink(linkText, linkHref));
51
+ }
52
+ wrapper.appendChild(_createDismissLink(dismissText));
53
+
54
+ cookieConsentElement.appendChild(wrapper);
55
+ cookieConsentElement.appendChild(_createDismissIcon());
56
+
57
+ return cookieConsentElement;
58
+ }
59
+
60
+ function _createDialogElement(cookieText, dismissText, linkText, linkHref) {
61
+ var glassStyle = 'position:fixed;width:100%;height:100%;z-index:999;' +
62
+ 'top:0;left:0;opacity:0.5;filter:alpha(opacity=50);' +
63
+ 'background-color:#ccc;';
64
+ var dialogStyle = 'z-index:1000;position:fixed;left:50%;top:50%';
65
+ var contentStyle = 'position:relative;left:-50%;margin-top:-25%;' +
66
+ 'background-color:#fff;padding:20px;box-shadow:4px 4px 25px #888;';
67
+
68
+ var cookieConsentElement = document.createElement('div');
69
+ cookieConsentElement.id = cookieConsentId;
70
+
71
+ var glassPanel = document.createElement('div');
72
+ glassPanel.style.cssText = glassStyle;
73
+
74
+ var content = document.createElement('div');
75
+ content.style.cssText = contentStyle;
76
+
77
+ var dialog = document.createElement('div');
78
+ dialog.style.cssText = dialogStyle;
79
+
80
+ var dismissLink = _createDismissLink(dismissText);
81
+ dismissLink.style.display = 'block';
82
+ dismissLink.style.textAlign = 'right';
83
+ dismissLink.style.marginTop = '8px';
84
+
85
+ content.appendChild(_createConsentText(cookieText));
86
+ if (!!linkText && !!linkHref) {
87
+ content.appendChild(_createInformationLink(linkText, linkHref));
88
+ }
89
+ content.appendChild(dismissLink);
90
+ dialog.appendChild(content);
91
+ cookieConsentElement.appendChild(glassPanel);
92
+ cookieConsentElement.appendChild(dialog);
93
+ return cookieConsentElement;
94
+ }
95
+
96
+ function _setElementText(element, text) {
97
+ // IE8 does not support textContent, so we should fallback to innerText.
98
+ var supportsTextContent = 'textContent' in document.body;
99
+
100
+ if (supportsTextContent) {
101
+ element.textContent = text;
102
+ } else {
103
+ element.innerText = text;
104
+ }
105
+ }
106
+
107
+ function _createConsentText(cookieText) {
108
+ var consentText = document.createElement('span');
109
+ _setElementText(consentText, cookieText);
110
+ return consentText;
111
+ }
112
+
113
+ function _createDismissLink(dismissText) {
114
+ var dismissLink = document.createElement('a');
115
+ _setElementText(dismissLink, dismissText);
116
+ dismissLink.id = dismissLinkId;
117
+ dismissLink.href = '#';
118
+ dismissLink.style.marginLeft = '24px';
119
+ return dismissLink;
120
+ }
121
+
122
+ function _createDismissIcon() {
123
+ var dismissIcon = document.createElement('a');
124
+ dismissIcon.id = dismissIconId;
125
+ dismissIcon.href = '#';
126
+ dismissIcon.style.cssText = 'width: 50px; height: 100%; background-size: 20px; display: inline-block; position: absolute; right: 0px; top: 0px; background-position: 34% 50%; background-color: #CCCCCC; background-color: rgba(204, 204, 204, 0.6); background-repeat: no-repeat; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAGXRFWHRTb2Z0d2FyZQB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
127
+ return dismissIcon;
128
+ }
129
+
130
+ function _createInformationLink(linkText, linkHref) {
131
+ var infoLink = document.createElement('a');
132
+ _setElementText(infoLink, linkText);
133
+ infoLink.href = linkHref;
134
+ infoLink.target = '_blank';
135
+ infoLink.style.marginLeft = '8px';
136
+ return infoLink;
137
+ }
138
+
139
+ function _dismissLinkClick() {
140
+ _saveUserPreference();
141
+ _removeCookieConsent();
142
+ return false;
143
+ }
144
+
145
+ function _showCookieConsent(cookieText, dismissText, linkText, linkHref, styles, isDialog) {
146
+ if (_shouldDisplayConsent()) {
147
+ _removeCookieConsent();
148
+ var consentElement = (isDialog) ?
149
+ _createDialogElement(cookieText, dismissText, linkText, linkHref) :
150
+ _createHeaderElement(cookieText, dismissText, linkText, linkHref, styles);
151
+ var fragment = document.createDocumentFragment();
152
+ fragment.appendChild(consentElement);
153
+ document.body.appendChild(fragment.cloneNode(true));
154
+ document.getElementById(dismissLinkId).onclick = _dismissLinkClick;
155
+ document.getElementById(dismissIconId).onclick = _dismissLinkClick;
156
+ }
157
+ }
158
+
159
+ function showCookieConsentBar(cookieText, dismissText, linkText, linkHref) {
160
+ _showCookieConsent(cookieText, dismissText, linkText, linkHref, false);
161
+ }
162
+
163
+ function showCookieConsentDialog(cookieText, dismissText, linkText, linkHref) {
164
+ _showCookieConsent(cookieText, dismissText, linkText, linkHref, true);
165
+ }
166
+
167
+ function _removeCookieConsent() {
168
+ var cookieChoiceElement = document.getElementById(cookieConsentId);
169
+ if (cookieChoiceElement != null) {
170
+ cookieChoiceElement.parentNode.removeChild(cookieChoiceElement);
171
+ }
172
+ }
173
+
174
+ function _saveUserPreference() {
175
+ // Set the cookie expiry to one year after today.
176
+ var expiryDate = new Date();
177
+ expiryDate.setFullYear(expiryDate.getFullYear() + 1);
178
+ document.cookie = cookieName + '=y;path=/; expires=' + expiryDate.toGMTString();
179
+ }
180
+
181
+ function _shouldDisplayConsent() {
182
+ // Display the header only if the cookie has not been set.
183
+ return !document.cookie.match(new RegExp(cookieName + '=([^;]+)'));
184
+ }
185
+
186
+ function htmlDecode(input) {
187
+ var e = document.createElement('textarea');
188
+ e.innerHTML = input;
189
+ return e.childNodes.length === 0 ? "" : e.childNodes[0].nodeValue;
190
+ }
191
+
192
+
193
+ if (document.addEventListener) {
194
+ document.addEventListener('DOMContentLoaded', showCookieBar);
195
+ } else {
196
+ document.attachEvent('onreadystatechange', function(event) {
197
+ if (document.readyState === "complete") {
198
+ showCookieBar();
199
+ }
200
+ });
201
+ }
202
+
203
+ })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
  === Plugin Name ===
2
  Contributors: wunderfarm
3
- Donate link: http://wunderfarm.com/
4
  Tags: compliance, cookie law, cookielaw, cookies, cookiebar, policy, bar, eu cookie law, cookie law banner, cookiechoices, eu privacy directive, privacy, privacy directive, cookie consent, cookieconsent, Multi language, WPML, polylang, responsive, admin, code, content, embed, google, html, integration, javascript, links, login, marketing, page, pages, plugin, simple, text, url, wordpress, law, lightweight,
5
  Requires at least: 3.0.1
6
- Tested up to: 4.6
7
- Stable tag: 1.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -29,6 +29,9 @@ WF Cookie Consent is the "wunderfarm-way" to show how your website complies with
29
 
30
  == Changelog ==
31
 
 
 
 
32
  = 1.0.1 =
33
  Bugfix: Unescaped HTML in text output
34
 
1
  === Plugin Name ===
2
  Contributors: wunderfarm
3
+ Donate link: https://www.wunderfarm.com
4
  Tags: compliance, cookie law, cookielaw, cookies, cookiebar, policy, bar, eu cookie law, cookie law banner, cookiechoices, eu privacy directive, privacy, privacy directive, cookie consent, cookieconsent, Multi language, WPML, polylang, responsive, admin, code, content, embed, google, html, integration, javascript, links, login, marketing, page, pages, plugin, simple, text, url, wordpress, law, lightweight,
5
  Requires at least: 3.0.1
6
+ Tested up to: 4.7
7
+ Stable tag: 1.1.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
29
 
30
  == Changelog ==
31
 
32
+ = 1.1.0 =
33
+ Better admin default options, performance improvements and iubenda integration added.
34
+
35
  = 1.0.1 =
36
  Bugfix: Unescaped HTML in text output
37
 
wf-cookie-consent.php CHANGED
@@ -3,135 +3,228 @@
3
  Plugin Name: WF Cookie Consent
4
  Plugin URI: http://www.wunderfarm.com/plugins/wf-cookie-consent
5
  Description: The wunderfarm-way to show how your website complies with the EU Cookie Law.
6
- Version: 1.0.1
7
  License: GNU General Public License v2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Author: wunderfarm
10
  Author URI: http://www.wunderfarm.com
11
  */
12
 
13
- defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
14
 
15
  /*
16
  * Enqueue JS
17
  */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
- function wf_cookieconsent_scripts() {
20
-
21
- wp_enqueue_script( 'wf-cookiechoices', plugin_dir_url( __FILE__ ) . 'js/cookiechoices.js', array(), '0.0.4', true );
22
-
23
- }
24
-
25
- add_action( 'wp_enqueue_scripts', 'wf_cookieconsent_scripts' );
26
 
27
  /*
28
  * Load cookie consent
29
  */
 
30
 
31
- function wf_cookieconsent_load() {
32
-
33
- $options = get_option('wf_cookieconsent_options');
34
- $language = wf_get_language();
35
- $linkHref = (empty($options[$language]['wf_linkhref']) ? '' : $options[$language]['wf_linkhref']);
36
- $linkText = (empty($options[$language]['wf_linktext']) ? '' : $options[$language]['wf_linktext']);
37
- $cookieText = (empty($options[$language]['wf_cookietext']) ? '' : $options[$language]['wf_cookietext']);
38
- $position = (empty($options['wf_position']) ? '' : $options['wf_position']);
39
- $dismissText = (empty($options[$language]['wf_dismisstext']) ? '' : $options[$language]['wf_dismisstext']);
40
-
41
- if(is_numeric($linkHref))
42
- $linkHref = get_page_link($linkHref);
43
 
44
  ?>
45
- <script type="text/javascript">
46
-
47
- (function(){
48
-
49
- var cookieBar = function() { cookieChoices.showCookieBar({ linkHref: '<?php echo esc_js($linkHref); ?>', dismissText: '<?php echo esc_js($dismissText); ?>', position: '<?php echo esc_js($position); ?>', cookieText:'<?php echo esc_js($cookieText); ?>', linkText: '<?php echo esc_js($linkText); ?>', language: '<?php echo esc_js($language); ?>'}) };
50
-
51
- if(document.addEventListener) {
52
- document.addEventListener('DOMContentLoaded', cookieBar);
53
- }
54
- else {
55
- document.attachEvent('onreadystatechange', function(event) {
56
- if ( document.readyState === "complete" ) {
57
- cookieBar();
58
- }
59
- });
60
- }
61
- })();
62
-
63
- </script>
64
  <?php
65
-
66
  }
 
67
 
68
- add_action('wp_footer', 'wf_cookieconsent_load', 100, 1);
69
 
70
  /*
71
  * Admin Page
72
  */
73
 
74
- // add the admin options page
75
- add_action('admin_menu', 'wf_cookieconsent_admin_add_page');
 
 
 
 
 
76
 
 
 
77
  function wf_cookieconsent_admin_add_page() {
78
  add_options_page('WF Cookie Consent Settings', 'WF Cookie Consent', 'manage_options', 'wf-cookieconsent', 'wf_cookieconsent_options_page');
79
  }
 
80
 
81
  // display the admin options page
82
  function wf_cookieconsent_options_page(){
83
 
84
  ?>
85
-
86
  <div class="wrap">
87
  <h2>WF Cookie Consent - Settings</h2>
88
- Here you can choose a page to link for more information, change all the texts or leave the default options.
89
  <form action="options.php" method="post">
90
- <?php settings_fields('wf_cookieconsent_options'); ?>
91
- <?php do_settings_sections('wf-cookieconsent'); ?>
92
-
93
- <input name="Submit" type="submit" class="button button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
94
  </form>
95
  </div>
96
-
97
  <?php
98
-
99
  }
100
 
101
  // add the admin settings and such
102
- add_action('admin_init', 'wf_cookieconsent_admin_init');
103
-
104
  function wf_cookieconsent_admin_init(){
 
105
  register_setting( 'wf_cookieconsent_options', 'wf_cookieconsent_options' );
106
 
107
- add_settings_section('plugin_main', 'General settings', '', 'wf-cookieconsent');
108
- add_settings_field('wf_position', esc_html__('Position'), 'wf_cookieconsent_setting_radio', 'wf-cookieconsent', 'plugin_main', array( 'fieldname' => 'wf_position', 'fielddescription' => 'Choose the position for the infobar', 'radioFields' => array( 'top' , 'bottom') ) );
109
-
110
- foreach(wf_get_languages() as $lang){
111
- add_settings_section('plugin_main_' . $lang, 'Custom settings (' . $lang . ')', '', 'wf-cookieconsent');
112
- add_settings_field('wf_linkhref', esc_html__('Page to provide more information'), 'wf_cookieconsent_setting_page_selector', 'wf-cookieconsent', 'plugin_main_' . $lang, array( 'fieldname' => 'wf_linkhref', 'fielddescription' => '', 'lang' => $lang ) );
113
- add_settings_field('wf_linktext', esc_html__('Link text to provide more information'), 'wf_cookieconsent_setting_string', 'wf-cookieconsent', 'plugin_main_' . $lang, array( 'fieldname' => 'wf_linktext', 'fielddescription' => '', 'lang' => $lang ) );
114
- add_settings_field('wf_cookietext', esc_html__('Info text'), 'wf_cookieconsent_setting_string', 'wf-cookieconsent', 'plugin_main_' . $lang, array( 'fieldname' => 'wf_cookietext', 'fielddescription' => '', 'lang' => $lang ) );
115
- add_settings_field('wf_dismisstext', esc_html__('Dismiss text'), 'wf_cookieconsent_setting_string', 'wf-cookieconsent', 'plugin_main_' . $lang, array( 'fieldname' => 'wf_dismisstext', 'fielddescription' => '', 'lang' => $lang ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  }
117
  }
 
118
 
119
- function wf_cookieconsent_setting_string($args) {
120
- $options = get_option('wf_cookieconsent_options');
 
 
 
 
121
 
122
- if(empty($options[$args['lang']][$args['fieldname']]))
123
- $options[$args['lang']][$args['fieldname']] = '';
124
- $esc_value = esc_attr($options[$args['lang']][$args['fieldname']]);
125
- echo "<input id='plugin_text_string' name='wf_cookieconsent_options[{$args['lang']}][{$args['fieldname']}]' size='40' type='text' value='{$esc_value}' />";
126
  echo (empty($args['fielddescription']) ? '' : "<p class='description'>". $args['fielddescription'] ."</p>");
127
  }
128
 
129
  function wf_cookieconsent_setting_page_selector($args) {
130
- $options = get_option('wf_cookieconsent_options');
131
-
132
- if(empty($options[$args['lang']][$args['fieldname']]))
133
- $options[$args['lang']][$args['fieldname']] = '';
134
-
135
  $wf_page_query = new WP_Query( array(
136
  'post_type' => 'page',
137
  'suppress_filters' => true, // With this option, WPML will not use any filter
@@ -140,30 +233,27 @@ function wf_cookieconsent_setting_page_selector($args) {
140
  'lang'=>'all', // With this option, Polylang will return all languages
141
  'nopaging'=>true
142
  ) );
143
-
144
  echo "<select name='wf_cookieconsent_options[".$args['lang']."][".$args['fieldname']."]' id='wf_cookieconsent_options[".$args['lang']."][".$args['fieldname']."]'>";
145
  foreach ( $wf_page_query->posts as $post ) {
146
  $wf_language_information = wf_get_language_information($post->ID);
147
- if(!empty($wf_language_information))
148
  $wf_language_information = "(" . $wf_language_information . ")";
149
-
150
- if($options[$args['lang']][$args['fieldname']] == $post->ID)
151
- echo "<option class='level-0' value='" . $post->ID . "' selected='selected'>" . $post->post_title . " " . $wf_language_information . "</option>";
152
- else
153
- echo "<option class='level-0' value='" . $post->ID . "'>" . $post->post_title . " " . $wf_language_information . "</option>";
154
-
155
  }
156
  echo "</select>";
157
-
158
  echo (empty($args['fielddescription']) ? '' : "<p class='description'>". $args['fielddescription'] ."</p>");
159
  }
160
 
161
  function wf_cookieconsent_setting_radio($args) {
162
- $options = get_option('wf_cookieconsent_options');
163
-
164
- if(empty($options[$args['fieldname']]))
165
  $options[$args['fieldname']] = '';
166
-
167
  echo "<fieldset>";
168
  if(!empty($args['radioFields'])) {
169
  foreach ($args['radioFields'] as $radioField) {
@@ -171,8 +261,26 @@ function wf_cookieconsent_setting_radio($args) {
171
  }
172
  }
173
  echo (empty($args['fielddescription']) ? '' : "<p class='description'>". $args['fielddescription'] ."</p>");
174
- echo "</fieldset>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
 
176
 
177
 
178
  /*
3
  Plugin Name: WF Cookie Consent
4
  Plugin URI: http://www.wunderfarm.com/plugins/wf-cookie-consent
5
  Description: The wunderfarm-way to show how your website complies with the EU Cookie Law.
6
+ Version: 1.1.0
7
  License: GNU General Public License v2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
  Author: wunderfarm
10
  Author URI: http://www.wunderfarm.com
11
  */
12
 
13
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
14
 
15
  /*
16
  * Enqueue JS
17
  */
18
+ function wf_cookieconsent_scripts() {
19
+ wp_enqueue_script('wf-cookie-consent-cookiechoices', plugin_dir_url( __FILE__ ) . 'js/cookiechoices.js', array(), false, true);
20
+ }
21
+ add_action( 'wp_enqueue_scripts', 'wf_cookieconsent_scripts' );
22
+
23
+
24
+ function wf_cookieconsent_get_options($language = null) {
25
+
26
+ $options = get_option('wf_cookieconsent_options');
27
+ if (!$language) $language = wf_get_language();
28
+
29
+ $data = array(
30
+ 'wf_cookietext' => empty($options[$language]['wf_cookietext']) ? null : $options[$language]['wf_cookietext'],
31
+ 'wf_dismisstext' => empty($options[$language]['wf_dismisstext']) ? null : $options[$language]['wf_dismisstext'],
32
+ 'wf_linktext' => empty($options[$language]['wf_linktext']) ? null : $options[$language]['wf_linktext'],
33
+ 'wf_linkhref' => empty($options[$language]['wf_linkhref']) ? null : $options[$language]['wf_linkhref'],
34
+ 'wf_position' => empty($options['wf_position']) ? 'bottom' : $options['wf_position'],
35
+ 'language' => $language
36
+ );
37
+
38
+ switch ($data['language']) {
39
+
40
+ case 'de':
41
+ if (empty($data['wf_cookietext'])) $data['wf_cookietext'] = "Cookies erleichtern die Bereitstellung unserer Dienste. Mit der Nutzung unserer Dienste erklären Sie sich damit einverstanden, dass wir Cookies verwenden. ";
42
+ if (empty($data['wf_dismisstext'])) $data['wf_dismisstext'] = "OK";
43
+ if (empty($data['wf_linktext'])) $data['wf_linktext'] = "Weitere Informationen";
44
+ break;
45
+
46
+ case 'it':
47
+ if (empty($data['wf_cookietext'])) $data['wf_cookietext'] = "I cookie ci aiutano ad erogare servizi di qualità. Utilizzando i nostri servizi, l'utente accetta le nostre modalità d'uso dei cookie.";
48
+ if (empty($data['wf_dismisstext'])) $data['wf_dismisstext'] = "OK";
49
+ if (empty($data['wf_linktext'])) $data['wf_linktext'] = "Ulteriori informazioni";
50
+ break;
51
+
52
+ case 'fr':
53
+ if (empty($data['wf_cookietext'])) $data['wf_cookietext'] = "Les cookies nous permettent de vous proposer nos services plus facilement. En utilisant nos services, vous nous donnez expressément votre accord pour exploiter ces cookies.";
54
+ if (empty($data['wf_dismisstext'])) $data['wf_dismisstext'] = "OK";
55
+ if (empty($data['wf_linktext'])) $data['wf_linktext'] = "En savoir plus";
56
+ break;
57
+
58
+ case 'nl':
59
+ if (empty($data['wf_cookietext'])) $data['wf_cookietext'] = "Cookies helpen ons bij het leveren van onze diensten. Door gebruik te maken van onze diensten, gaat u akkoord met ons gebruik van cookies.";
60
+ if (empty($data['wf_dismisstext'])) $data['wf_dismisstext'] = "OK";
61
+ if (empty($data['wf_linktext'])) $data['wf_linktext'] = "Meer informatie";
62
+ break;
63
+
64
+ case 'fi':
65
+ if (empty($data['wf_cookietext'])) $data['wf_cookietext'] = "Evästeet auttavat meitä palvelujemme toimituksessa. Käyttämällä palvelujamme hyväksyt evästeiden käytön.";
66
+ if (empty($data['wf_dismisstext'])) $data['wf_dismisstext'] = "Selvä";
67
+ if (empty($data['wf_linktext'])) $data['wf_linktext'] = "Lisätietoja";
68
+ break;
69
+
70
+ default:
71
+ if (empty($data['wf_cookietext'])) $data['wf_cookietext'] = "Cookies help us deliver our services. By using our services, you agree to our use of cookies.";
72
+ if (empty($data['wf_dismisstext'])) $data['wf_dismisstext'] = "Got it";
73
+ if (empty($data['wf_linktext'])) $data['wf_linktext'] = "Learn more";
74
+ break;
75
+ }
76
+ return $data;
77
+ }
78
 
 
 
 
 
 
 
 
79
 
80
  /*
81
  * Load cookie consent
82
  */
83
+ function wf_cookieconsent_load() {
84
 
85
+ $data = wf_cookieconsent_get_options();
86
+ if(is_numeric($data['wf_linkhref'])) {
87
+ $data['wf_linkhref'] = get_page_link($data['wf_linkhref']);
88
+ }
 
 
 
 
 
 
 
 
89
 
90
  ?>
91
+ <script type="text/javascript">
92
+ window._wfCookieConsentSettings = <?php print json_encode($data) ?>;
93
+ </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  <?php
 
95
  }
96
+ add_action('wp_footer', 'wf_cookieconsent_load', 100, 1);
97
 
 
98
 
99
  /*
100
  * Admin Page
101
  */
102
 
103
+ // add settings link on plugin page
104
+ function wf_cookieconsent_settings_link($links) {
105
+ $settings_link = '<a href="options-general.php?page=wf-cookieconsent">Settings</a>';
106
+ array_unshift($links, $settings_link);
107
+ return $links;
108
+ }
109
+ add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'wf_cookieconsent_settings_link' );
110
 
111
+
112
+ // add the admin options page
113
  function wf_cookieconsent_admin_add_page() {
114
  add_options_page('WF Cookie Consent Settings', 'WF Cookie Consent', 'manage_options', 'wf-cookieconsent', 'wf_cookieconsent_options_page');
115
  }
116
+ add_action('admin_menu', 'wf_cookieconsent_admin_add_page');
117
 
118
  // display the admin options page
119
  function wf_cookieconsent_options_page(){
120
 
121
  ?>
 
122
  <div class="wrap">
123
  <h2>WF Cookie Consent - Settings</h2>
 
124
  <form action="options.php" method="post">
125
+ <?php settings_fields('wf_cookieconsent_options'); ?>
126
+ <?php do_settings_sections('wf-cookieconsent'); ?>
127
+ <input name="Submit" type="submit" class="button button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
 
128
  </form>
129
  </div>
 
130
  <?php
 
131
  }
132
 
133
  // add the admin settings and such
 
 
134
  function wf_cookieconsent_admin_init(){
135
+ $languages = wf_get_languages();
136
  register_setting( 'wf_cookieconsent_options', 'wf_cookieconsent_options' );
137
 
138
+ $sectionKey = 'plugin_main';
139
+ add_settings_section($sectionKey, count($languages) > 1 ? esc_html__('General settings', 'wf-cookie-consent') : '', '', 'wf-cookieconsent');
140
+
141
+ add_settings_field(
142
+ 'wf_position',
143
+ esc_html__('Position'),
144
+ 'wf_cookieconsent_setting_radio',
145
+ 'wf-cookieconsent',
146
+ 'plugin_main',
147
+ array(
148
+ 'fieldname' => 'wf_position',
149
+ 'fielddescription' => esc_html__('Choose the position for the banner', 'wf-cookie-consent'),
150
+ 'radioFields' => array( 'top' , 'bottom')
151
+ )
152
+ );
153
+
154
+ foreach($languages as $lang) {
155
+ if (count($languages) > 1) {
156
+ $sectionKey = 'plugin_main_' . $lang;
157
+ add_settings_section($sectionKey, esc_html__('Language specific settings: ' . $lang, 'wf-cookie-consent'), '', 'wf-cookieconsent');
158
+ }
159
+ add_settings_field(
160
+ 'wf_cookietext',
161
+ esc_html__('Info text', 'wf-cookie-consent'),
162
+ 'wf_cookieconsent_setting_textarea',
163
+ 'wf-cookieconsent',
164
+ $sectionKey,
165
+ array(
166
+ 'fieldname' => 'wf_cookietext',
167
+ 'fielddescription' => '',
168
+ 'lang' => $lang
169
+ )
170
+ );
171
+ add_settings_field(
172
+ 'wf_linkhref',
173
+ esc_html__('Cookie policy page', 'wf-cookie-consent'),
174
+ 'wf_cookieconsent_setting_page_selector',
175
+ 'wf-cookieconsent',
176
+ $sectionKey,
177
+ array(
178
+ 'fieldname' => 'wf_linkhref',
179
+ 'fielddescription' => '',
180
+ 'lang' => $lang
181
+ )
182
+ );
183
+ add_settings_field(
184
+ 'wf_linktext',
185
+ esc_html__('Cookie policy link text', 'wf-cookie-consent'),
186
+ 'wf_cookieconsent_setting_input_text',
187
+ 'wf-cookieconsent',
188
+ $sectionKey,
189
+ array(
190
+ 'fieldname' => 'wf_linktext',
191
+ 'fielddescription' => '',
192
+ 'lang' => $lang
193
+ )
194
+ );
195
+
196
+ add_settings_field(
197
+ 'wf_dismisstext',
198
+ esc_html__('Dismiss text', 'wf-cookie-consent'),
199
+ 'wf_cookieconsent_setting_input_text',
200
+ 'wf-cookieconsent',
201
+ $sectionKey,
202
+ array(
203
+ 'fieldname' => 'wf_dismisstext',
204
+ 'fielddescription' => '',
205
+ 'lang' => $lang
206
+ )
207
+ );
208
  }
209
  }
210
+ add_action('admin_init', 'wf_cookieconsent_admin_init');
211
 
212
+ function wf_cookieconsent_setting_input_text($args) {
213
+ $options = wf_cookieconsent_get_options($args['lang']);
214
+ $esc_value = esc_attr($options[$args['fieldname']]);
215
+ echo "<input id='wf_cookieconsent_options[{$args['lang']}][{$args['fieldname']}]' name='wf_cookieconsent_options[{$args['lang']}][{$args['fieldname']}]' size='40' type='text' value='{$esc_value}' />";
216
+ echo (empty($args['fielddescription']) ? '' : "<p class='description'>". $args['fielddescription'] ."</p>");
217
+ }
218
 
219
+ function wf_cookieconsent_setting_textarea($args) {
220
+ $options = wf_cookieconsent_get_options($args['lang']);
221
+ $esc_value = esc_attr($options[$args['fieldname']]);
222
+ echo "<textarea id='wf_cookieconsent_options[{$args['lang']}][{$args['fieldname']}]' name='wf_cookieconsent_options[{$args['lang']}][{$args['fieldname']}]' cols='40' rows='5'>{$esc_value}</textarea>";
223
  echo (empty($args['fielddescription']) ? '' : "<p class='description'>". $args['fielddescription'] ."</p>");
224
  }
225
 
226
  function wf_cookieconsent_setting_page_selector($args) {
227
+ $options = wf_cookieconsent_get_options($args['lang']);
 
 
 
 
228
  $wf_page_query = new WP_Query( array(
229
  'post_type' => 'page',
230
  'suppress_filters' => true, // With this option, WPML will not use any filter
233
  'lang'=>'all', // With this option, Polylang will return all languages
234
  'nopaging'=>true
235
  ) );
 
236
  echo "<select name='wf_cookieconsent_options[".$args['lang']."][".$args['fieldname']."]' id='wf_cookieconsent_options[".$args['lang']."][".$args['fieldname']."]'>";
237
  foreach ( $wf_page_query->posts as $post ) {
238
  $wf_language_information = wf_get_language_information($post->ID);
239
+ if(!empty($wf_language_information)) {
240
  $wf_language_information = "(" . $wf_language_information . ")";
241
+ }
242
+ if($options[$args['fieldname']] == $post->ID) {
243
+ echo "<option class='level-0' value='" . $post->ID . "' selected='selected'>" . $post->post_title . " " . $wf_language_information . "</option>";
244
+ } else {
245
+ echo "<option class='level-0' value='" . $post->ID . "'>" . $post->post_title . " " . $wf_language_information . "</option>";
246
+ }
247
  }
248
  echo "</select>";
 
249
  echo (empty($args['fielddescription']) ? '' : "<p class='description'>". $args['fielddescription'] ."</p>");
250
  }
251
 
252
  function wf_cookieconsent_setting_radio($args) {
253
+ $options = wf_cookieconsent_get_options($args['lang']);
254
+ if(empty($options[$args['fieldname']])) {
 
255
  $options[$args['fieldname']] = '';
256
+ }
257
  echo "<fieldset>";
258
  if(!empty($args['radioFields'])) {
259
  foreach ($args['radioFields'] as $radioField) {
261
  }
262
  }
263
  echo (empty($args['fielddescription']) ? '' : "<p class='description'>". $args['fielddescription'] ."</p>");
264
+ echo "</fieldset>";
265
+ }
266
+
267
+
268
+ function wf_cookieconsent_admin_notice__iubenda() {
269
+ global $pagenow;
270
+ if ($pagenow == 'options-general.php' && $_GET['page'] == 'wf-cookieconsent') {
271
+ ?>
272
+ <div class="notice notice-info">
273
+ <p>
274
+ <?php print wp_kses( __( 'Websites that use third-party cookies as well as their own cookies for tracking and analytics must comply with the Cookie law and are required to obtain explicit consent from the user. Users must be provided with a clear, comprehensible and visible notice about the use of cookies by the website.', 'wf-cookie-consent' ), array('b'=>array())); ?>
275
+ </p>
276
+ <p>
277
+ <?php print sprintf( wp_kses( __( '<b>The WF Cookie Consent banner is only one part of the requirement</b>, you must provide a link to a more detailed actual cookie policy. <a href="%s" target="_blank">Click here to learn more on how to generate a cookie policy.</a>', 'wf-cookie-consent' ), array('b'=>array(),'a'=>array('href'=>array(), 'target'=>array()))), esc_url('https://www.iubenda.com/en/help/posts/3284') ); ?>
278
+ </p>
279
+ </div>
280
+ <?php
281
+ }
282
  }
283
+ add_action( 'admin_notices', 'wf_cookieconsent_admin_notice__iubenda' );
284
 
285
 
286
  /*