WF Cookie Consent - Version 0.8.1

Version Description

Support for WPML and polylang

Download this release

Release Info

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

Version 0.8.1

Files changed (3) hide show
  1. js/cookiechoices.js +235 -0
  2. readme.txt +27 -0
  3. wf-cookie-consent.php +178 -0
js/cookiechoices.js ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: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 = "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 = "OK";
53
+ data.linkText = "Ulteriori informazioni";
54
+
55
+ break;
56
+
57
+ case "fr":
58
+
59
+ 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 = "OK";
61
+ data.linkText = "En savoir plus";
62
+
63
+ break;
64
+
65
+ default:
66
+
67
+ data.cookieText = "Cookies help us deliver our services. By using our services, you agree to our use of cookies.";
68
+ data.dismissText = "Got it";
69
+ data.linkText = "Learn more";
70
+
71
+ }
72
+
73
+ _showCookieConsent(data.cookieText, data.dismissText, data.linkText, data.linkHref, data.styles, false);
74
+
75
+ }
76
+
77
+ }
78
+
79
+ function _createHeaderElement(cookieText, dismissText, linkText, linkHref, styles) {
80
+ var butterBarStyles = styles;
81
+ var cookieConsentElement = document.createElement('div');
82
+ var wrapper = document.createElement('div');
83
+ wrapper.style.cssText = "padding-right: 50px;";
84
+
85
+ cookieConsentElement.id = cookieConsentId;
86
+ cookieConsentElement.style.cssText = butterBarStyles;
87
+
88
+ wrapper.appendChild(_createConsentText(cookieText));
89
+ if (!!linkText && !!linkHref) {
90
+ wrapper.appendChild(_createInformationLink(linkText, linkHref));
91
+ }
92
+ wrapper.appendChild(_createDismissLink(dismissText));
93
+
94
+ cookieConsentElement.appendChild(wrapper);
95
+ cookieConsentElement.appendChild(_createDismissIcon());
96
+
97
+ return cookieConsentElement;
98
+ }
99
+
100
+ function _createDialogElement(cookieText, dismissText, linkText, linkHref) {
101
+ var glassStyle = 'position:fixed;width:100%;height:100%;z-index:999;' +
102
+ 'top:0;left:0;opacity:0.5;filter:alpha(opacity=50);' +
103
+ 'background-color:#ccc;';
104
+ var dialogStyle = 'z-index:1000;position:fixed;left:50%;top:50%';
105
+ var contentStyle = 'position:relative;left:-50%;margin-top:-25%;' +
106
+ 'background-color:#fff;padding:20px;box-shadow:4px 4px 25px #888;';
107
+
108
+ var cookieConsentElement = document.createElement('div');
109
+ cookieConsentElement.id = cookieConsentId;
110
+
111
+ var glassPanel = document.createElement('div');
112
+ glassPanel.style.cssText = glassStyle;
113
+
114
+ var content = document.createElement('div');
115
+ content.style.cssText = contentStyle;
116
+
117
+ var dialog = document.createElement('div');
118
+ dialog.style.cssText = dialogStyle;
119
+
120
+ var dismissLink = _createDismissLink(dismissText);
121
+ dismissLink.style.display = 'block';
122
+ dismissLink.style.textAlign = 'right';
123
+ dismissLink.style.marginTop = '8px';
124
+
125
+ content.appendChild(_createConsentText(cookieText));
126
+ if (!!linkText && !!linkHref) {
127
+ content.appendChild(_createInformationLink(linkText, linkHref));
128
+ }
129
+ content.appendChild(dismissLink);
130
+ dialog.appendChild(content);
131
+ cookieConsentElement.appendChild(glassPanel);
132
+ cookieConsentElement.appendChild(dialog);
133
+ return cookieConsentElement;
134
+ }
135
+
136
+ function _setElementText(element, text) {
137
+ // IE8 does not support textContent, so we should fallback to innerText.
138
+ var supportsTextContent = 'textContent' in document.body;
139
+
140
+ if (supportsTextContent) {
141
+ element.textContent = text;
142
+ } else {
143
+ element.innerText = text;
144
+ }
145
+ }
146
+
147
+ function _createConsentText(cookieText) {
148
+ var consentText = document.createElement('span');
149
+ _setElementText(consentText, cookieText);
150
+ return consentText;
151
+ }
152
+
153
+ function _createDismissLink(dismissText) {
154
+ var dismissLink = document.createElement('a');
155
+ _setElementText(dismissLink, dismissText);
156
+ dismissLink.id = dismissLinkId;
157
+ dismissLink.href = '#';
158
+ dismissLink.style.marginLeft = '24px';
159
+ return dismissLink;
160
+ }
161
+
162
+ function _createDismissIcon() {
163
+ var dismissIcon = document.createElement('a');
164
+ dismissIcon.id = dismissIconId;
165
+ dismissIcon.href = '#';
166
+ 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: rgba(204, 204, 204, 0.6); background-repeat: no-repeat; background-image: url(data:image/png;base64,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);';
167
+ return dismissIcon;
168
+ }
169
+
170
+ function _createInformationLink(linkText, linkHref) {
171
+ var infoLink = document.createElement('a');
172
+ _setElementText(infoLink, linkText);
173
+ infoLink.href = linkHref;
174
+ infoLink.target = '_blank';
175
+ infoLink.style.marginLeft = '8px';
176
+ return infoLink;
177
+ }
178
+
179
+ function _dismissLinkClick() {
180
+ _saveUserPreference();
181
+ _removeCookieConsent();
182
+ return false;
183
+ }
184
+
185
+ function _showCookieConsent(cookieText, dismissText, linkText, linkHref, styles, isDialog) {
186
+ if (_shouldDisplayConsent()) {
187
+ _removeCookieConsent();
188
+ var consentElement = (isDialog) ?
189
+ _createDialogElement(cookieText, dismissText, linkText, linkHref) :
190
+ _createHeaderElement(cookieText, dismissText, linkText, linkHref, styles);
191
+ var fragment = document.createDocumentFragment();
192
+ fragment.appendChild(consentElement);
193
+ document.body.appendChild(fragment.cloneNode(true));
194
+ document.getElementById(dismissLinkId).onclick = _dismissLinkClick;
195
+ document.getElementById(dismissIconId).onclick = _dismissLinkClick;
196
+ }
197
+ }
198
+
199
+ function showCookieConsentBar(cookieText, dismissText, linkText, linkHref) {
200
+ _showCookieConsent(cookieText, dismissText, linkText, linkHref, false);
201
+ }
202
+
203
+ function showCookieConsentDialog(cookieText, dismissText, linkText, linkHref) {
204
+ _showCookieConsent(cookieText, dismissText, linkText, linkHref, true);
205
+ }
206
+
207
+ function _removeCookieConsent() {
208
+ var cookieChoiceElement = document.getElementById(cookieConsentId);
209
+ if (cookieChoiceElement != null) {
210
+ cookieChoiceElement.parentNode.removeChild(cookieChoiceElement);
211
+ }
212
+ }
213
+
214
+ function _saveUserPreference() {
215
+ // Set the cookie expiry to one year after today.
216
+ var expiryDate = new Date();
217
+ expiryDate.setFullYear(expiryDate.getFullYear() + 1);
218
+ document.cookie = cookieName + '=y; expires=' + expiryDate.toGMTString();
219
+ }
220
+
221
+ function _shouldDisplayConsent() {
222
+ // Display the header only if the cookie has not been set.
223
+ return !document.cookie.match(new RegExp(cookieName + '=([^;]+)'));
224
+ }
225
+
226
+ var exports = {};
227
+ exports.showCookieBar = showCookieBar;
228
+ exports.showCookieConsentBar = showCookieConsentBar;
229
+ exports.showCookieConsentDialog = showCookieConsentDialog;
230
+ return exports;
231
+ })();
232
+
233
+ window.cookieChoices = cookieChoices;
234
+ return cookieChoices;
235
+ })(this);
readme.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: wunderfarm
3
+ Donate link: http://wunderfarm.com/
4
+ Tags: compliance, cookie law, cookies, eu cookie law, eu privacy directive, privacy, privacy directive, cookie consent, Multi language, WPML, polylang
5
+ Requires at least: 3.0.1
6
+ Tested up to: 4.2.2
7
+ Stable tag: 0.8.1
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ The `wunderfarm-way` to show how your website complies with the EU Cookie Law - with multi-language support!
12
+
13
+ == Description ==
14
+
15
+ `WF Cookie Consent` shows the user a clear message that the site uses cookies.
16
+ This plugin supports multi-language installations with the polylang-plugin from Chouby or WPML-plugin from wpml.org. It has a wide array of settings for controlling the style and contents.
17
+ WF Cookie Consent is the "wunderfarm-way" to show how your website complies with the EU Cookie Law.
18
+
19
+ == Installation ==
20
+
21
+ 1. Upload `WF Cookie Consent` to the `/wp-content/plugins/` directory
22
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
23
+
24
+ == Changelog ==
25
+
26
+ = 0.8.1 =
27
+ Support for WPML and polylang
wf-cookie-consent.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
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: 0.8.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.1', 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
+ ?>
42
+ <script type="text/javascript">
43
+ document.addEventListener('DOMContentLoaded', function(event) { cookieChoices.showCookieBar({ linkHref: '<?php echo $linkHref; ?>', dismissText: '<?php echo $dismissText; ?>', position: '<?php echo $position; ?>', cookieText:'<?php echo $cookieText; ?>', linkText: '<?php echo $linkText; ?>', language: '<?php echo $language; ?>'}) });
44
+ </script>
45
+ <?php
46
+
47
+ }
48
+
49
+ add_action('wp_footer', 'wf_cookieconsent_load', 10, 1);
50
+
51
+ /*
52
+ * Admin Page
53
+ */
54
+
55
+ // add the admin options page
56
+ add_action('admin_menu', 'plugin_admin_add_page');
57
+
58
+ function plugin_admin_add_page() {
59
+ add_options_page('WF Cookie Consent Settings', 'WF Cookie Consent', 'manage_options', 'wf-cookieconsent', 'wf_cookieconsent_options_page');
60
+ }
61
+
62
+ // display the admin options page
63
+ function wf_cookieconsent_options_page(){
64
+
65
+ ?>
66
+
67
+ <div class="wrap">
68
+ <h2>WF Cookie Consent - Settings</h2>
69
+ Here you can choose a page to link for more information, change all the texts or leave the default options.
70
+ <form action="options.php" method="post">
71
+ <?php settings_fields('wf_cookieconsent_options'); ?>
72
+ <?php do_settings_sections('wf-cookieconsent'); ?>
73
+
74
+ <input name="Submit" type="submit" class="button button-primary" value="<?php esc_attr_e('Save Changes'); ?>" />
75
+ </form>
76
+ </div>
77
+
78
+ <?php
79
+
80
+ }
81
+
82
+ // add the admin settings and such
83
+ add_action('admin_init', 'plugin_admin_init');
84
+
85
+ function plugin_admin_init(){
86
+ register_setting( 'wf_cookieconsent_options', 'wf_cookieconsent_options' );
87
+
88
+ add_settings_section('plugin_main', 'General settings', '', 'wf-cookieconsent');
89
+ add_settings_field('wf_position', esc_html__('Position'), 'plugin_setting_radio', 'wf-cookieconsent', 'plugin_main', array( 'fieldname' => 'wf_position','radioFields' => array( 'top' , 'bottom') ) );
90
+
91
+ foreach(wf_get_languages() as $lang){
92
+ add_settings_section('plugin_main_' . $lang, 'Custom settings (' . $lang . ')', '', 'wf-cookieconsent');
93
+ add_settings_field('wf_linkhref', esc_html__('Page to provide more information'), 'plugin_setting_page_selector', 'wf-cookieconsent', 'plugin_main_' . $lang, array( 'fieldname' => 'wf_linkhref', 'lang' => $lang ) );
94
+ add_settings_field('wf_linktext', esc_html__('Linktext to provide more information'), 'plugin_setting_string', 'wf-cookieconsent', 'plugin_main_' . $lang, array( 'fieldname' => 'wf_linktext', 'lang' => $lang ) );
95
+ add_settings_field('wf_cookietext', esc_html__('Infotext'), 'plugin_setting_string', 'wf-cookieconsent', 'plugin_main_' . $lang, array( 'fieldname' => 'wf_cookietext', 'lang' => $lang ) );
96
+ add_settings_field('wf_dismisstext', esc_html__('Dismisstext'), 'plugin_setting_string', 'wf-cookieconsent', 'plugin_main_' . $lang, array( 'fieldname' => 'wf_dismisstext', 'lang' => $lang ) );
97
+ }
98
+ }
99
+
100
+ function plugin_setting_string($args) {
101
+ $options = get_option('wf_cookieconsent_options');
102
+
103
+ if(empty($options[$args['lang']][$args['fieldname']]))
104
+ $options[$args['lang']][$args['fieldname']] = '';
105
+
106
+ echo "<input id='plugin_text_string' name='wf_cookieconsent_options[{$args['lang']}][{$args['fieldname']}]' size='40' type='text' value='{$options[$args['lang']][$args['fieldname']]}' />";
107
+ }
108
+
109
+ function plugin_setting_page_selector($args) {
110
+ $options = get_option('wf_cookieconsent_options');
111
+
112
+ if(empty($options[$args['lang']][$args['fieldname']]))
113
+ $options[$args['lang']][$args['fieldname']] = '';
114
+
115
+ wp_dropdown_pages(array(
116
+ 'name' => 'wf_cookieconsent_options['.$args['lang'].']['.$args['fieldname'].']',
117
+ 'selected' => $options[$args['lang']][$args['fieldname']],
118
+ 'show_option_none' => ' '));
119
+ }
120
+
121
+ function plugin_setting_radio($args) {
122
+ $options = get_option('wf_cookieconsent_options');
123
+
124
+ if(empty($options[$args['fieldname']]))
125
+ $options[$args['fieldname']] = '';
126
+
127
+ echo "<fieldset>";
128
+ if(!empty($args['radioFields'])) {
129
+ foreach ($args['radioFields'] as $radioField) {
130
+ echo "<input type='radio' id='' name='wf_cookieconsent_options[{$args['fieldname']}]' value='{$radioField}'" . ($radioField == $options[$args['fieldname']] ? 'checked' : '')."><label for=''>" . $radioField . "</label><br />";
131
+ }
132
+ }
133
+ echo "</fieldset>";
134
+ }
135
+
136
+ /*
137
+ * Helpers
138
+ */
139
+
140
+ function wf_get_language() {
141
+ $language = null;
142
+ //get language from polylang plugin https://wordpress.org/plugins/polylang/
143
+ if(function_exists('pll_current_language'))
144
+ $language = pll_current_language();
145
+ //get language from wpml plugin https://wpml.org
146
+ elseif(defined('ICL_LANGUAGE_CODE'))
147
+ $language = ICL_LANGUAGE_CODE;
148
+ //return wp get_locale() - first 2 chars (en, it, de ...)
149
+ else
150
+ $language = substr(get_locale(),0,2);
151
+
152
+ return $language;
153
+ }
154
+
155
+ function wf_get_languages() {
156
+ $languages = null;
157
+ //get all languages from polylang plugin https://wordpress.org/plugins/polylang/
158
+ global $polylang;
159
+ if (isset($polylang)) {
160
+ $pl_languages = $polylang->model->get_languages_list();
161
+ foreach ($pl_languages as $pl_language) {
162
+ $languages[] = $pl_language->name;
163
+ }
164
+ } else if(function_exists('icl_get_languages')) {
165
+ //icl_get_languages for wpml
166
+ $wpml_languages = icl_get_languages();
167
+ foreach ($wpml_languages as $wpml_language) {
168
+ $languages[] = $wpml_language['language_code'];
169
+ }
170
+ }
171
+ else {
172
+ //return wp get_locale() - first 2 chars (en, it, de ...)
173
+ $languages[] = substr(get_locale(),0,2);
174
+ }
175
+ return $languages;
176
+ }
177
+
178
+ ?>