EU Cookie Law - Version 2.1

Version Description

03.06.2015 = * Added option to link directly to a page instead of popup * Added ability to change default cookie-lock message * Added [cookie-control] shortcode * Minor changes + bugfixes

Download this release

Release Info

Developer Milmor
Plugin Icon 128x128 EU Cookie Law
Version 2.1
Comparing to
See all releases

Code changes from version 2.0.5 to 2.1

Files changed (5) hide show
  1. class-admin.php +27 -4
  2. class-frontend.php +104 -35
  3. css/style.css +16 -0
  4. eu-cookie-law.php +10 -2
  5. readme.txt +28 -13
class-admin.php CHANGED
@@ -7,7 +7,7 @@ function peadig_eucookie_init(){
7
 
8
  add_action('admin_menu', 'show_peadig_eucookie_options');
9
  function show_peadig_eucookie_options() {
10
- add_options_page('EU Cookie Options', 'EU Cookie', 'manage_options', 'peadig_eucookie', 'peadig_eucookie_options');
11
  }
12
 
13
 
@@ -22,7 +22,8 @@ function pea_cook_defaults()
22
  'barlink' => 'more information',
23
  'barbutton' => 'Accept',
24
  'closelink' => 'Close',
25
- 'boxcontent' => 'The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.'
 
26
  )
27
  );
28
  }
@@ -32,7 +33,7 @@ function pea_cook_defaults()
32
  function peadig_eucookie_options() {
33
  ?>
34
  <div class="wrap">
35
- <h2>EU Cookie Options</h2>
36
  <form method="post" action="options.php">
37
  <?php settings_fields('peadig_eucookie_options'); ?>
38
  <?php $options = get_option('peadig_eucookie'); ?>
@@ -80,11 +81,33 @@ function peadig_eucookie_options() {
80
  <tr valign="top"><th scope="row"><label for="barbutton">"Close Popup" Text</label></th>
81
  <td><input id="closelink" type="text" name="peadig_eucookie[closelink]" value="<?php echo $options['closelink']; ?>" /></td>
82
  </tr>
83
- <tr valign="top"><th scope="row"><label for="boxcontent">Popup Box Content<br/>Use this to inform your users about your cookie policy</label></th>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  <td>
85
  <textarea style='font-size: 90%; width:95%;' name='peadig_eucookie[boxcontent]' id='boxcontent' rows='9' ><?php echo $options['boxcontent']; ?></textarea>
86
  </td>
87
  </tr>
 
 
 
 
 
88
  </table>
89
  <p class="submit">
90
  <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
7
 
8
  add_action('admin_menu', 'show_peadig_eucookie_options');
9
  function show_peadig_eucookie_options() {
10
+ add_options_page('EU Cookie Law', 'EU Cookie Law', 'manage_options', 'peadig_eucookie', 'peadig_eucookie_options');
11
  }
12
 
13
 
22
  'barlink' => 'more information',
23
  'barbutton' => 'Accept',
24
  'closelink' => 'Close',
25
+ 'boxcontent' => 'The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.',
26
+ 'bhtmlcontent' => '<b>Content not available.</b><br><small>Please allow cookies by clicking Accept on the banner</small>'
27
  )
28
  );
29
  }
33
  function peadig_eucookie_options() {
34
  ?>
35
  <div class="wrap">
36
+ <h2>EU Cookie Law <?php echo get_option( 'ecl_version_number' ); ?> &bull; Options</h2>
37
  <form method="post" action="options.php">
38
  <?php settings_fields('peadig_eucookie_options'); ?>
39
  <?php $options = get_option('peadig_eucookie'); ?>
81
  <tr valign="top"><th scope="row"><label for="barbutton">"Close Popup" Text</label></th>
82
  <td><input id="closelink" type="text" name="peadig_eucookie[closelink]" value="<?php echo $options['closelink']; ?>" /></td>
83
  </tr>
84
+ <tr valign="top"><th scope="row"><label for="boxlinkid">Bar Link<br/><small>Use this field if you want to link a page instead of showing the popup</small></label></th>
85
+ <td>
86
+ <?php $args = array(
87
+ 'depth' => 0,
88
+ 'child_of' => 0,
89
+ 'selected' => $options['boxlinkid'],
90
+ 'echo' => 1,
91
+ 'name' => 'peadig_eucookie[boxlinkid]',
92
+ 'id' => 'boxlinkid',
93
+ 'show_option_none' => 'none',
94
+ 'show_option_no_change' => null,
95
+ 'option_none_value' => null,
96
+ ); ?>
97
+
98
+ <?php wp_dropdown_pages($args); ?>
99
+ </td>
100
+ </tr>
101
+ <tr valign="top"><th scope="row"><label for="boxcontent">Popup Box Content<br/><small>Use this to inform your users about your cookie policy</small></label></th>
102
  <td>
103
  <textarea style='font-size: 90%; width:95%;' name='peadig_eucookie[boxcontent]' id='boxcontent' rows='9' ><?php echo $options['boxcontent']; ?></textarea>
104
  </td>
105
  </tr>
106
+ <tr valign="top"><th scope="row"><label for="bhtmlcontent">Blocked code message<br/><small>This is the message that will be displayed for locked-code areas</small></label></th>
107
+ <td>
108
+ <textarea style='font-size: 90%; width:95%;' name='peadig_eucookie[bhtmlcontent]' id='bhtmlcontent' rows='9' ><?php echo $options['bhtmlcontent']; ?></textarea>
109
+ </td>
110
+ </tr>
111
  </table>
112
  <p class="submit">
113
  <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
class-frontend.php CHANGED
@@ -7,38 +7,62 @@ function peadig_eucookie_scripts() {
7
  }
8
  add_action('wp_head', 'peadig_eucookie_scripts');
9
 
10
- function eu_cookie_check() {
11
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }
13
 
 
 
 
 
 
14
  function peadig_eucookie_bar() {
15
  $options = get_option('peadig_eucookie');
16
 
17
- if ( !$options['enabled'] ) {
18
  return;
19
  }
20
-
21
- if(!$_COOKIE['euCookie']){
22
- //for Cookie
23
- switch($options['length']){
24
- case "hours":
25
- $multi = (1/24);
26
- break;
27
- case "days":
28
- $multi = 1;
29
- break;
30
- case "weeks":
31
- $multi = 7;
32
- break;
33
- case "months":
34
- $multi = 30;
35
- break;
36
- }
37
-
38
- $expireTimer = $multi * $options['lengthnum'];
39
  ?>
40
  <div class="pea_cook_wrapper pea_cook_<?php if ($options['position']!="") {echo $options['position'];} else {echo "bottomright";} ?>">
41
- <p><?php echo $options['barmessage']; ?> <a href="#" id="fom"><?php echo $options['barlink']; ?></a> <button id="pea_cook_btn" class="pea_cook_btn" href="#"><?php echo $options['barbutton']; ?></button></p>
42
  </div>
43
  <div class="pea_cook_more_info_popover">
44
  <div class="pea_cook_more_info_popover_inner">
@@ -49,17 +73,19 @@ function peadig_eucookie_bar() {
49
 
50
  <script type="text/javascript">
51
  jQuery(document).ready(function($){
 
52
  $("#fom").click(function() {
53
  $(".pea_cook_more_info_popover").fadeIn("slow");
54
  $(".pea_cook_wrapper").fadeOut("fast");
55
  });
 
56
  $("#pea_close").click(function() {
57
  $(".pea_cook_wrapper").fadeIn("fast");
58
  $(".pea_cook_more_info_popover").fadeOut("slow");
59
  });
60
  $('#pea_cook_btn').click(function() {
61
  var expire = new Date();
62
- expire.setDate(expire.getDate() + <?php echo $expireTimer?>);
63
  var isoDate = new Date(expire).toISOString();
64
  document.cookie = "euCookie=set; expires=" + isoDate + "; path=/";
65
  window.location.reload();
@@ -69,22 +95,65 @@ function peadig_eucookie_bar() {
69
  });
70
  </script>
71
  <?php
72
- }
73
  }
74
  add_action('wp_footer', 'peadig_eucookie_bar', 1000);
75
 
76
  function eu_cookie_shortcode( $atts, $content = null ) {
77
- if (!$_COOKIE['euCookie']) {
78
- extract(shortcode_atts(
79
- array(
80
- 'height' => 'auto',
81
- 'width' => 'auto',
82
- 'text' => '<b>Content not available.</b><br><small>Please allow cookies by clicking Accept on the banner</small>',
83
- ), $atts));
84
- ob_start();
 
 
 
 
85
  return '<div class="eucookie" style="width:'.$width.';height:'.$height.';
86
  background:url(\''.plugins_url('img/congruent_pentagon.png',__FILE__).'\') repeat;"><span>'.$text.'</span><!--' . $content . '--></div><div class="clear"></div>';
87
  }
88
- return $content;
89
  }
90
- add_shortcode( 'cookie', 'eu_cookie_shortcode' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  }
8
  add_action('wp_head', 'peadig_eucookie_scripts');
9
 
10
+ function cookie_accepted() {
11
+ $options = get_option('peadig_eucookie');
12
+ if ( !$options['enabled'] ) { return true; }
13
+ if ( $_COOKIE['euCookie'] ) {
14
+ return true;
15
+ } else {
16
+ return false;
17
+ }
18
+ }
19
+
20
+ function get_expire_timer() {
21
+ $options = get_option('peadig_eucookie');
22
+
23
+ if(!$_COOKIE['euCookie']){
24
+ //for Cookie
25
+ switch($options['length']){
26
+ case "hours":
27
+ $multi = (1/24);
28
+ break;
29
+ case "days":
30
+ $multi = 1;
31
+ break;
32
+ case "weeks":
33
+ $multi = 7;
34
+ break;
35
+ case "months":
36
+ $multi = 30;
37
+ break;
38
+ }
39
+
40
+ return $multi * $options['lengthnum'];
41
+ }
42
  }
43
 
44
+ function eu_cookie_enabled() {
45
+ $options = get_option('peadig_eucookie');
46
+ return $options['enabled'];
47
+ }
48
+
49
  function peadig_eucookie_bar() {
50
  $options = get_option('peadig_eucookie');
51
 
52
+ if ( cookie_accepted() ) {
53
  return;
54
  }
55
+
56
+ if ( $options['boxlinkid'] ) {
57
+ $link = get_permalink($options['boxlinkid']);
58
+ } else {
59
+ $link = '#';
60
+ }
61
+
62
+
 
 
 
 
 
 
 
 
 
 
 
63
  ?>
64
  <div class="pea_cook_wrapper pea_cook_<?php if ($options['position']!="") {echo $options['position'];} else {echo "bottomright";} ?>">
65
+ <p><?php echo $options['barmessage']; ?> <a href="<?php echo $link; ?>" id="fom"><?php echo $options['barlink']; ?></a> <button id="pea_cook_btn" class="pea_cook_btn" href="#"><?php echo $options['barbutton']; ?></button></p>
66
  </div>
67
  <div class="pea_cook_more_info_popover">
68
  <div class="pea_cook_more_info_popover_inner">
73
 
74
  <script type="text/javascript">
75
  jQuery(document).ready(function($){
76
+ <?php if ( $link == '#') { ?>
77
  $("#fom").click(function() {
78
  $(".pea_cook_more_info_popover").fadeIn("slow");
79
  $(".pea_cook_wrapper").fadeOut("fast");
80
  });
81
+ <?php } ?>
82
  $("#pea_close").click(function() {
83
  $(".pea_cook_wrapper").fadeIn("fast");
84
  $(".pea_cook_more_info_popover").fadeOut("slow");
85
  });
86
  $('#pea_cook_btn').click(function() {
87
  var expire = new Date();
88
+ expire.setDate(expire.getDate() + <?php echo get_expire_timer(); ?>);
89
  var isoDate = new Date(expire).toISOString();
90
  document.cookie = "euCookie=set; expires=" + isoDate + "; path=/";
91
  window.location.reload();
95
  });
96
  </script>
97
  <?php
 
98
  }
99
  add_action('wp_footer', 'peadig_eucookie_bar', 1000);
100
 
101
  function eu_cookie_shortcode( $atts, $content = null ) {
102
+ $options = get_option('peadig_eucookie');
103
+ extract(shortcode_atts(
104
+ array(
105
+ 'height' => 'auto',
106
+ 'width' => 'auto',
107
+ 'text' => $options['bhtmlcontent']
108
+ ),
109
+ $atts)
110
+ );
111
+ if ( cookie_accepted() ) {
112
+ return $content;
113
+ } else {
114
  return '<div class="eucookie" style="width:'.$width.';height:'.$height.';
115
  background:url(\''.plugins_url('img/congruent_pentagon.png',__FILE__).'\') repeat;"><span>'.$text.'</span><!--' . $content . '--></div><div class="clear"></div>';
116
  }
 
117
  }
118
+ add_shortcode( 'cookie', 'eu_cookie_shortcode' );
119
+
120
+ function eu_cookie_control_shortcode( $atts ) {
121
+ if (!eu_cookie_enabled()) { return; }
122
+ if ( cookie_accepted() ) {
123
+ return '
124
+ <div class="pea_cook_control">
125
+ Cookies are currently enabled.
126
+ <button id="eu_revoke_cookies" class="eu_control_btn" href="#">Revoke Cookies</button>
127
+ </div>
128
+ <script type="text/javascript">
129
+ jQuery(document).ready(function($){
130
+ $(".eu_control_btn").click(function() {
131
+ document.cookie = "euCookie=set; Max-Age=0; path=/";
132
+ window.location.reload();
133
+ $(".pea_cook_wrapper").fadeIn("fast");
134
+ });
135
+ });
136
+ </script>';
137
+ } else {
138
+ return '
139
+ <div class="pea_cook_control">
140
+ Cookies are currently disabled.
141
+ <button id="eu_revoke_cookies" class="eu_control_btn" href="#">Accept Cookies</button>
142
+ </div>
143
+ <script type="text/javascript">
144
+ jQuery(document).ready(function($){
145
+ $(".eu_control_btn").click(function() {
146
+ var expire = new Date();
147
+ expire.setDate(expire.getDate() + '.get_expire_timer().');
148
+ var isoDate = new Date(expire).toISOString();
149
+ document.cookie = "euCookie=set; expires=" + isoDate + "; path=/";
150
+ window.location.reload();
151
+
152
+ $(".pea_cook_wrapper").fadeOut("fast");
153
+ });
154
+ });
155
+ </script>';
156
+
157
+ }
158
+ }
159
+ add_shortcode( 'cookie-control', 'eu_cookie_control_shortcode' );
css/style.css CHANGED
@@ -12,6 +12,22 @@
12
  text-align: center;
13
  }
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  .pea_cook_wrapper.pea_cook_topleft {
16
  top:30px;
17
  left:30px;
12
  text-align: center;
13
  }
14
 
15
+ .pea_cook_control {
16
+ float:left;
17
+ width:100%;
18
+ background-color: rgba(0,0,0,0.85);
19
+ /* For IE 5.5 - 7 */
20
+ filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#cc000000, endColorstr=#cc000000);
21
+ /* For IE 8*/
22
+ -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#cc000000, endColorstr=#cc000000)";
23
+ padding: 8px 21px;
24
+ margin: 0;
25
+ -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;
26
+ z-index: 10000;
27
+ text-align: center;
28
+ color:white;
29
+ }
30
+
31
  .pea_cook_wrapper.pea_cook_topleft {
32
  top:30px;
33
  left:30px;
eu-cookie-law.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: EU Cookie Law
4
  Plugin URI: https://wordpress.org/plugins/eu-cookie-law/
5
  Description: Cookie Law informs users that your site has cookies, with a popup for more information and ability to lock scripts before acceptance.
6
- Version: 2.0.5
7
  Author: Alex Moss, Marco Milesi, Peadig, Shane Jones
8
  Author URI: https://wordpress.org/plugins/eu-cookie-law/
9
  Contributors: alexmoss, Milmor, peer, ShaneJones
@@ -26,7 +26,15 @@ function ecl_action_admin_init() {
26
 
27
  $arraya_ecl_v = get_plugin_data ( __FILE__ );
28
  $new_version = $arraya_ecl_v['Version'];
29
-
 
 
 
 
 
 
 
 
30
  update_option( 'ecl_version_number', $new_version );
31
  } add_action('admin_init', 'ecl_action_admin_init');
32
 
3
  Plugin Name: EU Cookie Law
4
  Plugin URI: https://wordpress.org/plugins/eu-cookie-law/
5
  Description: Cookie Law informs users that your site has cookies, with a popup for more information and ability to lock scripts before acceptance.
6
+ Version: 2.1
7
  Author: Alex Moss, Marco Milesi, Peadig, Shane Jones
8
  Author URI: https://wordpress.org/plugins/eu-cookie-law/
9
  Contributors: alexmoss, Milmor, peer, ShaneJones
26
 
27
  $arraya_ecl_v = get_plugin_data ( __FILE__ );
28
  $new_version = $arraya_ecl_v['Version'];
29
+
30
+ if ( !get_option( 'ecl_version_number' ) ) { pea_cook_defaults(); }
31
+
32
+ if (version_compare(get_option( 'ecl_version_number' ), "2.1", "<")) {
33
+ $my_options = get_option('peadig_eucookie');
34
+ $my_options['bhtmlcontent'] = '<b>Content not available.</b><br><small>Please allow cookies by clicking Accept on the banner</small>';
35
+ update_option('peadig_eucookie', $my_options);
36
+ }
37
+
38
  update_option( 'ecl_version_number', $new_version );
39
  } add_action('admin_init', 'ecl_action_admin_init');
40
 
readme.txt CHANGED
@@ -1,12 +1,12 @@
1
  === EU Cookie Law ===
2
  Contributors: alexmoss, Milmor, pleer, ShaneJones
3
- Version: 2.0.5
4
  Author: Alex Moss, Marco Milesi, Peadig, Shane Jones
5
  Author URI: https://profiles.wordpress.org/milmor/
6
  Tags: eu cookie, cookies, law, analytics, european, italia, garante, privacy
7
  Requires at least: 3.8
8
  Tested up to: 4.3
9
- Stable tag: 2.0.5
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -31,6 +31,17 @@ Demo: [www.sanpellegrinoterme.gov.it](http://www.sanpellegrinoterme.gov.it)
31
  * Great responsiveness for tablets and smartphones
32
  * Set banner position
33
 
 
 
 
 
 
 
 
 
 
 
 
34
  > EU Cookie Law started from [Peadig](http://peadig.com/wordpress-plugins/eu-cookie-law/) in 2012 and in june 2015 has became part of the project [WPGov.it](http://www.wpgov.it) that aims to give Italian Public Government powerful open source solutions to make complete and law-compatible websites.
35
 
36
  = Included Languages =
@@ -53,25 +64,25 @@ This section describes how to install the plugin and get it working.
53
  3. Go to the EU Cookie settings page
54
  4. Go through the steps and hit update!
55
 
56
- == Frequently Asked Questions ==
57
-
58
- = How can i block cookies? =
59
-
60
- At the moment you can use `[cookie]` and `[/cookie]` shortcodes. Everthing there will be shown only when cookies are accepted.
61
- There are some parameters too:
62
- - height: ex. 200px
63
- - width: ex. 100%
64
-
65
- ex. `[cookie height="100px" width="100%"] //My code [/cookie]`
66
-
67
  == Screenshots ==
68
 
69
  1. Example (cookie not accepted) - [www.sanpellegrinoterme.gov.it](http://www.sanpellegrinoterme.gov.it)
70
  2. Example (cookie accepted) - [www.sanpellegrinoterme.gov.it](http://www.sanpellegrinoterme.gov.it)
71
  3. Example of the banner
 
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
 
 
 
 
 
75
  = 2.0.3 + 2.0.4 + 2.0.5 - 03.06.2015 =
76
  * Fixed cookie storing caused by wrong iso date
77
  * Better css for small screens
@@ -86,3 +97,7 @@ ex. `[cookie height="100px" width="100%"] //My code [/cookie]`
86
  = 1.1 =
87
  * Fixed cookie storing bug
88
  * Added in CSS support for IE
 
 
 
 
1
  === EU Cookie Law ===
2
  Contributors: alexmoss, Milmor, pleer, ShaneJones
3
+ Version: 2.1
4
  Author: Alex Moss, Marco Milesi, Peadig, Shane Jones
5
  Author URI: https://profiles.wordpress.org/milmor/
6
  Tags: eu cookie, cookies, law, analytics, european, italia, garante, privacy
7
  Requires at least: 3.8
8
  Tested up to: 4.3
9
+ Stable tag: 2.1
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
31
  * Great responsiveness for tablets and smartphones
32
  * Set banner position
33
 
34
+ = Cookie block =
35
+ You can lock cookies using `[cookie]` and `[/cookie]` shortcodes in every page and widget.
36
+ ex. `[cookie height="100px" width="100%"] //My code [/cookie]`
37
+
38
+ In php files:
39
+ `if ( function_exists('cookie_accepted') && cookie_accepted() ) {
40
+ // Your code
41
+ }`
42
+
43
+ You can also use `[cookie-control]` in your cookie policy to display a box that allows to revoke consent (if cookies accepted) of accept cookies (if not done yet).
44
+
45
  > EU Cookie Law started from [Peadig](http://peadig.com/wordpress-plugins/eu-cookie-law/) in 2012 and in june 2015 has became part of the project [WPGov.it](http://www.wpgov.it) that aims to give Italian Public Government powerful open source solutions to make complete and law-compatible websites.
46
 
47
  = Included Languages =
64
  3. Go to the EU Cookie settings page
65
  4. Go through the steps and hit update!
66
 
 
 
 
 
 
 
 
 
 
 
 
67
  == Screenshots ==
68
 
69
  1. Example (cookie not accepted) - [www.sanpellegrinoterme.gov.it](http://www.sanpellegrinoterme.gov.it)
70
  2. Example (cookie accepted) - [www.sanpellegrinoterme.gov.it](http://www.sanpellegrinoterme.gov.it)
71
  3. Example of the banner
72
+ 4. Example of `[cookie-control]`
73
 
74
  == Changelog ==
75
 
76
+ = 2.1.1 04.06.2015 =
77
+ * Fixed shortcodes in `[cookie]...[/cookie]` not being correctly rendered
78
+ * Best tinymce icon with windowmanager
79
+
80
+ = 2.1 03.06.2015 =
81
+ * Added option to link directly to a page instead of popup
82
+ * Added ability to change default cookie-lock message
83
+ * Added `[cookie-control]` shortcode
84
+ * Minor changes + bugfixes
85
+
86
  = 2.0.3 + 2.0.4 + 2.0.5 - 03.06.2015 =
87
  * Fixed cookie storing caused by wrong iso date
88
  * Better css for small screens
97
  = 1.1 =
98
  * Fixed cookie storing bug
99
  * Added in CSS support for IE
100
+
101
+ == Shortcodes & Functions ==
102
+
103
+ = Shortcodes =