Italy Cookie Choices (for EU Cookie Law) - Version 1.0.0

Version Description

Download this release

Release Info

Developer overclokk
Plugin Icon Italy Cookie Choices (for EU Cookie Law)
Version 1.0.0
Comparing to
See all releases

Version 1.0.0

italy-cookie-choices.php ADDED
@@ -0,0 +1,467 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: Italy Cookie Choices
4
+ * Plugin URI: https://plus.google.com/u/0/communities/109254048492234113886
5
+ * Description: Minimal code to make sure your website repect the Italian coockie law
6
+ * Version: 1.0.0
7
+ * Author: Enea Overclokk
8
+ * Author URI: https://plus.google.com/u/0/communities/109254048492234113886
9
+ * Text Domain: ItalyCookieChoices
10
+ * License: GPLv2 or later
11
+ *
12
+ * @package Italy Cookie Choices
13
+ * @since 1.0.0
14
+ *
15
+ * This program is free software; you can redistribute it and/or modify
16
+ * it under the terms of the GNU General Public License, version 2, as
17
+ * published by the Free Software Foundation.
18
+ *
19
+ * This program is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License
25
+ * along with this program; if not, write to the Free Software
26
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27
+ */
28
+
29
+
30
+ /**
31
+ * This will make shure the plugin files can't be accessed within the web browser directly.
32
+ */
33
+ if ( !defined( 'WPINC' ) )
34
+ die;
35
+
36
+ /**
37
+ * Define some costant for internal use
38
+ */
39
+ if ( !defined( 'ITALY_COOKIE_CHOICES_PLUGIN' ) )
40
+ define('ITALY_COOKIE_CHOICES_PLUGIN', true);
41
+
42
+ /**
43
+ * Example = F:\xampp\htdocs\italystrap\wp-content\plugins\italystrap-extended\italystrap.php
44
+ */
45
+ if ( !defined( 'ITALY_COOKIE_CHOICES_FILE' ) )
46
+ define('ITALY_COOKIE_CHOICES_FILE', __FILE__ );
47
+
48
+ /**
49
+ * Example = F:\xampp\htdocs\italystrap\wp-content\plugins\italystrap-extended/
50
+ */
51
+ if ( !defined( 'ITALY_COOKIE_CHOICES_PLUGIN_PATH' ) )
52
+ define('ITALY_COOKIE_CHOICES_PLUGIN_PATH', plugin_dir_path( ITALY_COOKIE_CHOICES_FILE ));
53
+ /**
54
+ * Example = italystrap-extended/italystrap.php
55
+ */
56
+ if ( !defined( 'ITALY_COOKIE_CHOICES_BASENAME' ) )
57
+ define('ITALY_COOKIE_CHOICES_BASENAME', plugin_basename( ITALY_COOKIE_CHOICES_FILE ));
58
+
59
+
60
+ /**
61
+ *
62
+ */
63
+ if ( !class_exists( 'Italy_Cookie_Choices' ) ){
64
+
65
+ class Italy_Cookie_Choices{
66
+
67
+ /**
68
+ * Definition of variables containing the configuration
69
+ * to be applied to the various function calls wordpress
70
+ */
71
+ protected $capability = 'manage_options';
72
+
73
+ /**
74
+ * Global variables and default values
75
+ * @var array
76
+ */
77
+ protected $default_options = array();
78
+
79
+ /**
80
+ * Option
81
+ * @var array
82
+ */
83
+ private $options = array();
84
+
85
+ /**
86
+ * [__construct description]
87
+ */
88
+ public function __construct(){
89
+
90
+ /**
91
+ * Add Admin menù page
92
+ */
93
+ add_action( 'admin_menu', array( $this, 'addMenuPage') );
94
+
95
+ /**
96
+ *
97
+ */
98
+ add_action( 'admin_init', array( $this, 'italy_cl_settings_init') );
99
+
100
+ /**
101
+ *
102
+ */
103
+ add_action( 'wp_footer', array( $this, 'print_script_inline'), '9' );
104
+
105
+
106
+ }
107
+
108
+ /**
109
+ * Add page for ItalyCookieChoices admin page
110
+ */
111
+ public function addMenuPage(){
112
+
113
+ add_options_page(
114
+ __('Italy Cookie Choices Dashboard', 'ItalyCookieChoices'),
115
+ 'Italy Cookie Choices',
116
+ $this->capability,
117
+ 'italy-cookie-choices',
118
+ array( $this, 'dashboard')
119
+ );
120
+ }
121
+
122
+ /**
123
+ * The dashboard callback
124
+ */
125
+ public function dashboard(){
126
+
127
+ if ( !current_user_can( $this->capability ) )
128
+ wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
129
+
130
+ ?>
131
+ <div class="wrap">
132
+
133
+ <?php settings_errors(); ?>
134
+
135
+ <form action='options.php' method='post'>
136
+
137
+ <?php
138
+ settings_fields( 'italy_cl_options_group' );
139
+ do_settings_sections( 'italy_cl_options_group' );
140
+ submit_button();
141
+ ?>
142
+
143
+ </form>
144
+ </div>
145
+ <?php
146
+
147
+ }
148
+
149
+ /**
150
+ * [italy_cl_settings_init description]
151
+ * @return [type] [description]
152
+ */
153
+ public function italy_cl_settings_init() {
154
+
155
+ /**
156
+ * Load Plugin Textdomain
157
+ */
158
+ load_plugin_textdomain('ItalyCookieChoices', false, ITALY_COOKIE_CHOICES_BASENAME . '/languages' );
159
+
160
+ /**
161
+ * Create default options
162
+ * @var array
163
+ */
164
+ $this->default_options = array(
165
+
166
+ 'text' => 'Cookies help us deliver our services. By using our services, you agree to our use of cookies.',
167
+ 'url' => 'http://www.aboutcookies.org/',
168
+ 'anchor_text' => __( 'More Info', 'ItalyCookieChoices' ),
169
+ 'button_text' => __( 'Close', 'ItalyCookieChoices' )
170
+
171
+ );
172
+
173
+ /**
174
+ * [$this->options description]
175
+ * @var [type]
176
+ */
177
+ $this->options = get_option( 'italy_cookie_choices' );
178
+
179
+ /**
180
+ * If the theme options don't exist, create them.
181
+ */
182
+ if( false === $this->options )
183
+ add_option( 'italy_cookie_choices', $this->default_options );
184
+
185
+ /**
186
+ *
187
+ */
188
+ add_settings_section(
189
+ 'italy_cl_pluginPage_section',
190
+ __( 'Italy Cookie Choices options page', 'ItalyCookieChoices' ),
191
+ array( $this, 'italy_cl_settings_section_callback'),
192
+ 'italy_cl_options_group'
193
+ );
194
+
195
+ /**
196
+ * Checkbox for activation
197
+ */
198
+ add_settings_field(
199
+ 'active',
200
+ __( 'Activate', 'ItalyCookieChoices' ),
201
+ array( $this, 'italy_cl_option_active'),
202
+ 'italy_cl_options_group',
203
+ 'italy_cl_pluginPage_section'
204
+ );
205
+
206
+ /**
207
+ * How to display banner
208
+ * Default Bar
209
+ */
210
+ add_settings_field(
211
+ 'banner',
212
+ __( 'Where display the banner', 'ItalyCookieChoices' ),
213
+ array( $this, 'italy_cl_option_banner'),
214
+ 'italy_cl_options_group',
215
+ 'italy_cl_pluginPage_section'
216
+ );
217
+
218
+ /**
219
+ *
220
+ */
221
+ add_settings_field(
222
+ 'text',
223
+ __( 'Text to display', 'ItalyCookieChoices' ),
224
+ array( $this, 'italy_cl_option_text'),
225
+ 'italy_cl_options_group',
226
+ 'italy_cl_pluginPage_section'
227
+ );
228
+
229
+ /**
230
+ *
231
+ */
232
+ add_settings_field(
233
+ 'url',
234
+ __( 'URL for cookie policy', 'ItalyCookieChoices' ),
235
+ array( $this, 'italy_cl_option_url'),
236
+ 'italy_cl_options_group',
237
+ 'italy_cl_pluginPage_section'
238
+ );
239
+
240
+ /**
241
+ *
242
+ */
243
+ add_settings_field(
244
+ 'anchor_text',
245
+ __( 'Anchor text for URL', 'ItalyCookieChoices' ),
246
+ array( $this, 'italy_cl_option_anchor_text'),
247
+ 'italy_cl_options_group',
248
+ 'italy_cl_pluginPage_section'
249
+ );
250
+
251
+ /**
252
+ *
253
+ */
254
+ add_settings_field(
255
+ 'button_text',
256
+ __( 'Button text', 'ItalyCookieChoices' ),
257
+ array( $this, 'italy_cl_option_button_text'),
258
+ 'italy_cl_options_group',
259
+ 'italy_cl_pluginPage_section'
260
+ );
261
+
262
+ /**
263
+ *
264
+ */
265
+ register_setting(
266
+ 'italy_cl_options_group',
267
+ 'italy_cookie_choices',
268
+ array( $this, 'sanitize_callback')
269
+ );
270
+
271
+
272
+ }
273
+
274
+
275
+ /**
276
+ * [italy_cl_settings_section_callback description]
277
+ * @return [type] [description]
278
+ */
279
+ public function italy_cl_settings_section_callback() {
280
+
281
+ _e( 'This section description', 'ItalyCookieChoices' );
282
+
283
+ }
284
+
285
+ /**
286
+ * Snippet for checkbox
287
+ * @return strimg Activate banner in front-end Default doesn't display
288
+ */
289
+ public function italy_cl_option_active($args) {
290
+
291
+ $active = ( isset( $this->options['active'] ) ) ? $this->options['active'] : '' ;
292
+ ?>
293
+
294
+ <input type='checkbox' name='italy_cookie_choices[active]' <?php checked( $active, 1 ); ?> value='1'>
295
+ <label for="italy_cookie_choices[active]">
296
+ <?php _e( 'Display banner for Cookie Law in front-end', 'ItalyCookieChoices' ); ?>
297
+ </label>
298
+
299
+ <?php
300
+
301
+ }
302
+
303
+ /**
304
+ * Choose how to display banner in page
305
+ * @return string Display input and labels in plugin options page
306
+ */
307
+ public function italy_cl_option_banner($args) {
308
+
309
+ $banner = ( isset( $this->options['banner'] ) ) ? $this->options['banner'] : '1' ;
310
+
311
+ ?>
312
+
313
+ <input name="italy_cookie_choices[banner]" type="radio" value="1" id="radio_1" <?php checked( '1', $banner ); ?> />
314
+
315
+ <label for="radio_1">
316
+ <?php _e( 'Top Bar (Default, Display a top bar wth your message)', 'ItalyCookieChoices' ); ?>
317
+ </label>
318
+
319
+ <br>
320
+
321
+ <input name="italy_cookie_choices[banner]" type="radio" value="2" id="radio_2" <?php checked( '2', $banner ); ?> />
322
+
323
+ <label for="radio_2">
324
+ <?php _e( 'Dialog (Display an overlay with your message)', 'ItalyCookieChoices' ); ?>
325
+ </label>
326
+
327
+ <?php
328
+
329
+ }
330
+
331
+ /**
332
+ * Textarea for the message to display
333
+ * @return string
334
+ */
335
+ public function italy_cl_option_text($args) {
336
+
337
+ ?>
338
+
339
+ <textarea rows="5" name="italy_cookie_choices[text]" id="italy_cookie_choices[text]"><?php echo esc_textarea( $this->options['text'] ); ?></textarea>
340
+ <label for="italy_cookie_choices[text]">
341
+ <?php echo __( 'People will see this notice only the first time that they enter your site', 'ItalyCookieChoices' ); ?>
342
+ </label>
343
+
344
+ <?php
345
+
346
+ }
347
+
348
+ /**
349
+ * Input for url policy page
350
+ * @return string
351
+ */
352
+ public function italy_cl_option_url($args) {
353
+
354
+ ?>
355
+ <input type="text" id="italy_cookie_choices[url]" name="italy_cookie_choices[url]" value="<?php echo esc_url( $this->options['url'] ); ?>" />
356
+
357
+ <label for="italy_cookie_choices[url]">
358
+ <?php echo __( 'Insert here the link to your policy page', 'ItalyCookieChoices' ); ?>
359
+ </label>
360
+
361
+ <?php
362
+
363
+ }
364
+
365
+ /**
366
+ * Input for anchor_text
367
+ * @return string
368
+ */
369
+ public function italy_cl_option_anchor_text($args) {
370
+
371
+ ?>
372
+ <input type="text" id="italy_cookie_choices[anchor_text]" name="italy_cookie_choices[anchor_text]" value="<?php echo esc_attr( $this->options['anchor_text'] ); ?>" />
373
+
374
+ <label for="italy_cookie_choices[anchor_text]">
375
+ <?php echo __( 'Insert here anchor text for the link', 'ItalyCookieChoices'); ?>
376
+ </label>
377
+
378
+ <?php
379
+
380
+ }
381
+
382
+ /**
383
+ * Input for anchor_text
384
+ * @return string
385
+ */
386
+ public function italy_cl_option_button_text($args) {
387
+
388
+ ?>
389
+ <input type="text" id="italy_cookie_choices[button_text]" name="italy_cookie_choices[button_text]" value="<?php echo esc_attr( $this->options['button_text'] ); ?>" />
390
+
391
+ <label for="italy_cookie_choices[button_text]">
392
+ <?php echo __( 'Insert here name of button (e.g. "Close") ', 'ItalyCookieChoices' ); ?>
393
+ </label>
394
+
395
+ <?php
396
+
397
+ }
398
+
399
+ /**
400
+ * Sanitize data
401
+ * @param array $input Data to sanitize
402
+ * @return array Data sanitized
403
+ */
404
+ public function sanitize_callback( $input ){
405
+
406
+ $new_input = array();
407
+
408
+ if( isset( $input['active'] ) )
409
+ $new_input['active'] = $input['active'];
410
+
411
+ if( isset( $input['banner'] ) )
412
+ $new_input['banner'] = $input['banner'];
413
+
414
+ if( isset( $input['text'] ) )
415
+ $new_input['text'] = sanitize_text_field( $input['text'] );
416
+
417
+ if( isset( $input['url'] ) )
418
+ $new_input['url'] = sanitize_text_field( $input['url'] );
419
+
420
+ if( isset( $input['anchor_text'] ) )
421
+ $new_input['anchor_text'] = sanitize_text_field( $input['anchor_text'] );
422
+
423
+ if( isset( $input['button_text'] ) )
424
+ $new_input['button_text'] = sanitize_text_field( $input['button_text'] );
425
+
426
+ return $new_input;
427
+
428
+ }
429
+
430
+ /**
431
+ * Print script inline
432
+ * @return string Print script inline
433
+ * @link https://www.cookiechoices.org/
434
+ */
435
+ public function print_script_inline(){
436
+
437
+ $this->options = get_option( 'italy_cookie_choices' );
438
+
439
+ /**
440
+ * If is not active exit
441
+ */
442
+ if ( !isset( $this->options['active'] ) )
443
+ return;
444
+
445
+ if ( $this->options['banner'] === '1' )
446
+ $banner = 'Bar';
447
+ elseif ( $this->options['banner'] === '2' )
448
+ $banner = 'Dialog';
449
+ else
450
+ $banner = '';
451
+
452
+ /**
453
+ * Snippet for display banner
454
+ * @var string
455
+ */
456
+ $banner = 'document.addEventListener("DOMContentLoaded", function(event) {cookieChoices.showCookieConsent' . $banner . '("' . esc_html( $this->options['text'] ) . '", "' . esc_html( $this->options['button_text'] ) . '", "' . esc_html( $this->options['anchor_text'] ) . '", "' . esc_url( $this->options['url'] ) . '");});';
457
+
458
+ echo '<!-- Italy Cookie Choices --><script>';
459
+ require 'js/cookiechoices.php';
460
+ echo $banner . '</script>';
461
+
462
+ }
463
+
464
+ }// class
465
+ }//endif
466
+
467
+ new Italy_Cookie_Choices;
js/LICENSE ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
js/cookiechoices.js ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 document = window.document;
24
+ // IE8 does not support textContent, so we should fallback to innerText.
25
+ var supportsTextContent = 'textContent' in document.body;
26
+
27
+ var cookieChoices = (function() {
28
+
29
+ var cookieName = 'displayCookieConsent';
30
+ var cookieConsentId = 'cookieChoiceInfo';
31
+ var dismissLinkId = 'cookieChoiceDismiss';
32
+
33
+ function _createHeaderElement(cookieText, dismissText, linkText, linkHref) {
34
+ var butterBarStyles = 'position:fixed;width:100%;background-color:#eee;' +
35
+ 'margin:0; left:0; top:0;padding:4px;z-index:1000;text-align:center;';
36
+
37
+ var cookieConsentElement = document.createElement('div');
38
+ cookieConsentElement.id = cookieConsentId;
39
+ cookieConsentElement.style.cssText = butterBarStyles;
40
+ cookieConsentElement.appendChild(_createConsentText(cookieText));
41
+
42
+ if (!!linkText && !!linkHref) {
43
+ cookieConsentElement.appendChild(_createInformationLink(linkText, linkHref));
44
+ }
45
+ cookieConsentElement.appendChild(_createDismissLink(dismissText));
46
+ return cookieConsentElement;
47
+ }
48
+
49
+ function _createDialogElement(cookieText, dismissText, linkText, linkHref) {
50
+ var glassStyle = 'position:fixed;width:100%;height:100%;z-index:999;' +
51
+ 'top:0;left:0;opacity:0.5;filter:alpha(opacity=50);' +
52
+ 'background-color:#ccc;';
53
+ var dialogStyle = 'z-index:1000;position:fixed;left:50%;top:50%';
54
+ var contentStyle = 'position:relative;left:-50%;margin-top:-25%;' +
55
+ 'background-color:#fff;padding:20px;box-shadow:4px 4px 25px #888;';
56
+
57
+ var cookieConsentElement = document.createElement('div');
58
+ cookieConsentElement.id = cookieConsentId;
59
+
60
+ var glassPanel = document.createElement('div');
61
+ glassPanel.style.cssText = glassStyle;
62
+
63
+ var content = document.createElement('div');
64
+ content.style.cssText = contentStyle;
65
+
66
+ var dialog = document.createElement('div');
67
+ dialog.style.cssText = dialogStyle;
68
+
69
+ var dismissLink = _createDismissLink(dismissText);
70
+ dismissLink.style.display = 'block';
71
+ dismissLink.style.textAlign = 'right';
72
+ dismissLink.style.marginTop = '8px';
73
+
74
+ content.appendChild(_createConsentText(cookieText));
75
+ if (!!linkText && !!linkHref) {
76
+ content.appendChild(_createInformationLink(linkText, linkHref));
77
+ }
78
+ content.appendChild(dismissLink);
79
+ dialog.appendChild(content);
80
+ cookieConsentElement.appendChild(glassPanel);
81
+ cookieConsentElement.appendChild(dialog);
82
+ return cookieConsentElement;
83
+ }
84
+
85
+ function _setElementText(element, text) {
86
+ if (supportsTextContent) {
87
+ element.textContent = text;
88
+ } else {
89
+ element.innerText = text;
90
+ }
91
+ }
92
+
93
+ function _createConsentText(cookieText) {
94
+ var consentText = document.createElement('span');
95
+ _setElementText(consentText, cookieText);
96
+ return consentText;
97
+ }
98
+
99
+ function _createDismissLink(dismissText) {
100
+ var dismissLink = document.createElement('a');
101
+ _setElementText(dismissLink, dismissText);
102
+ dismissLink.id = dismissLinkId;
103
+ dismissLink.href = '#';
104
+ dismissLink.style.marginLeft = '24px';
105
+ return dismissLink;
106
+ }
107
+
108
+ function _createInformationLink(linkText, linkHref) {
109
+ var infoLink = document.createElement('a');
110
+ _setElementText(infoLink, linkText);
111
+ infoLink.href = linkHref;
112
+ infoLink.target = '_blank';
113
+ infoLink.style.marginLeft = '8px';
114
+ return infoLink;
115
+ }
116
+
117
+ function _dismissLinkClick() {
118
+ _saveUserPreference();
119
+ _removeCookieConsent();
120
+ return false;
121
+ }
122
+
123
+ function _showCookieConsent(cookieText, dismissText, linkText, linkHref, isDialog) {
124
+ if (_shouldDisplayConsent()) {
125
+ _removeCookieConsent();
126
+ var consentElement = (isDialog) ?
127
+ _createDialogElement(cookieText, dismissText, linkText, linkHref) :
128
+ _createHeaderElement(cookieText, dismissText, linkText, linkHref);
129
+ var fragment = document.createDocumentFragment();
130
+ fragment.appendChild(consentElement);
131
+ document.body.appendChild(fragment.cloneNode(true));
132
+ document.getElementById(dismissLinkId).onclick = _dismissLinkClick;
133
+ }
134
+ }
135
+
136
+ function showCookieConsentBar(cookieText, dismissText, linkText, linkHref) {
137
+ _showCookieConsent(cookieText, dismissText, linkText, linkHref, false);
138
+ }
139
+
140
+ function showCookieConsentDialog(cookieText, dismissText, linkText, linkHref) {
141
+ _showCookieConsent(cookieText, dismissText, linkText, linkHref, true);
142
+ }
143
+
144
+ function _removeCookieConsent() {
145
+ var cookieChoiceElement = document.getElementById(cookieConsentId);
146
+ if (cookieChoiceElement != null) {
147
+ cookieChoiceElement.parentNode.removeChild(cookieChoiceElement);
148
+ }
149
+ }
150
+
151
+ function _saveUserPreference() {
152
+ // Set the cookie expiry to one year after today.
153
+ var expiryDate = new Date();
154
+ expiryDate.setFullYear(expiryDate.getFullYear() + 1);
155
+ document.cookie = cookieName + '=y; expires=' + expiryDate.toGMTString();
156
+ }
157
+
158
+ function _shouldDisplayConsent() {
159
+ // Display the header only if the cookie has not been set.
160
+ return !document.cookie.match(new RegExp(cookieName + '=([^;]+)'));
161
+ }
162
+
163
+ var exports = {};
164
+ exports.showCookieConsentBar = showCookieConsentBar;
165
+ exports.showCookieConsentDialog = showCookieConsentDialog;
166
+ return exports;
167
+ })();
168
+
169
+ window.cookieChoices = cookieChoices;
170
+ return cookieChoices;
171
+ })(this);
js/cookiechoices.php ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){if(e.cookieChoices)return e.cookieChoices;var t=e.document,n="textContent"in t.body,i=function(){function e(e,n,i,o){var d="position:fixed;width:100%;background-color:#eee;margin:0; left:0; top:0;padding:4px;z-index:9999;text-align:center;",l=t.createElement("div");return l.id=C,l.style.cssText=d,l.appendChild(r(e)),i&&o&&l.appendChild(c(i,o)),l.appendChild(a(n)),l}function i(e,n,i,o){var d="position:fixed;width:100%;height:100%;z-index:999;top:0;left:0;opacity:0.5;filter:alpha(opacity=50);background-color:#ccc;",l="z-index:1000;position:fixed;left:50%;top:50%",p="position:relative;left:-50%;margin-top:-25%;background-color:#fff;padding:20px;box-shadow:4px 4px 25px #888;",s=t.createElement("div");s.id=C;var f=t.createElement("div");f.style.cssText=d;var u=t.createElement("div");u.style.cssText=p;var h=t.createElement("div");h.style.cssText=l;var x=a(n);return x.style.display="block",x.style.textAlign="right",x.style.marginTop="8px",u.appendChild(r(e)),i&&o&&u.appendChild(c(i,o)),u.appendChild(x),h.appendChild(u),s.appendChild(f),s.appendChild(h),s}function o(e,t){n?e.textContent=t:e.innerText=t}function r(e){var n=t.createElement("span");return o(n,e),n}function a(e){var n=t.createElement("a");return o(n,e),n.id=g,n.href="#",n.style.marginLeft="24px",n}function c(e,n){var i=t.createElement("a");return o(i,e),i.href=n,i.target="_blank",i.style.marginLeft="8px",i}function d(){return u(),f(),!1}function l(n,o,r,a,c){if(h()){f();var l=c?i(n,o,r,a):e(n,o,r,a),p=t.createDocumentFragment();p.appendChild(l),t.body.appendChild(p.cloneNode(!0)),t.getElementById(g).onclick=d}}function p(e,t,n,i){l(e,t,n,i,!1)}function s(e,t,n,i){l(e,t,n,i,!0)}function f(){var e=t.getElementById(C);null!=e&&e.parentNode.removeChild(e)}function u(){var e=new Date;e.setFullYear(e.getFullYear()+1),t.cookie=x+"=y; expires="+e.toGMTString()}function h(){return!t.cookie.match(new RegExp(x+"=([^;]+)"))}var x="displayCookieConsent",C="cookieChoiceInfo",g="cookieChoiceDismiss",m={};return m.showCookieConsentBar=p,m.showCookieConsentDialog=s,m}();return e.cookieChoices=i,i}(this);
readme.txt ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Italy Cookie Choices ===
2
+ Contributors: Enea Overclokk
3
+ Tags: cookies, cookie law
4
+ Requires at least: 3.8
5
+ Tested up to: 4.3.0
6
+ Stable tag: 1.0.0
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Italy Cookie Choices allows you to easily comply with the european cookie law, showing
11
+ a notice to the user only the very first time that visits your website.
12
+
13
+ == Description ==
14
+
15
+ Italy Cookie Choices allows you to easily comply with the european cookie law, showing
16
+ a notice to the user only the very first time that visits your website.
17
+ Message, position and the style can be easyly modified through the plugin menu.
18
+
19
+ The plugin will not add any CSS stylesheet or Javascript file but only inline script, what does not make your web site load more slowly.
20
+
21
+ == Installation ==
22
+
23
+ 1. Upload `italy-cookie-choices` folder to the `/wp-content/plugins/` directory
24
+ 2. Activate the plugin through the 'Plugins' menu in WordPress
25
+ 3. Configure the plugin throught Settings -> Italy Cookie Choices
26
+
27
+ == Frequently Asked Questions ==
28
+
29
+ = How does it work? =
30
+
31
+ When a user visit your site, the plugin will check if this user has been already there, checking for a cookie that the plugin self creates (it is just a session cookie, so it is not against the law). If the user has not this cookie, a message will be shown (you can configure where, how and what will be show). If the users keeps surfing in your web, now or withing the next month, it means that he accepted the use of cookies in your website, so this message
32
+ will not be shown again.
33
+
34
+ = Why am I not seeing the message? =
35
+
36
+ Probably, you already have visited the site before, so you accepted the use of cookies and the plugin installed a cookie in your browser to know it. If you want to test if the plugin is working properly, try removing the cookies `displayCookieConsent` from your web browser or navigating in incognito mode. If you think that the plugin is not working properly, just open an issue here https://github.com/overclokk/italy-cookie-choices/issues and I will check it for you.
37
+
38
+ == Screenshots ==
39
+
40
+ 1. Italy Cookie Choices Options Menu
41
+ 2. Italy Cookie Choices top bar in front end
42
+ 3. Italy Cookie Choices Options for Dialog box
43
+ 4. Italy Cookie Choices Dialog Box in front end
44
+
45
+ == Changelog ==
46
+
47
+ = 1.0 =
48
+ * First release.
49
+
50
+ == Upgrade Notice ==
51
+ = 1.0 = First First release.
screenshot-1.jpg ADDED
Binary file
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file
screenshot-4.jpg ADDED
Binary file