Cookie Law / GDPR Info - Version 1.5

Version Description

  • Major update: the cookie bar is now inserted into the page via wp_footer rather than using jQuery (for better performance and greater browser compatibility)
  • Update: if the cookie bar is in the header, there is now an option to fix the bar to the header using position:fixed
Download this release

Release Info

Developer richardashby
Plugin Icon Cookie Law / GDPR Info
Version 1.5
Comparing to
See all releases

Code changes from version 1.4.3 to 1.5

admin/cli-admin-page.php CHANGED
@@ -177,6 +177,18 @@ function cookielawinfo_print_admin_page() {
177
  </select>
178
  </td>
179
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
180
  <tr valign="top">
181
  <th scope="row"><label for="notify_animate_show_field">On load</label></th>
182
  <td>
177
  </select>
178
  </td>
179
  </tr>
180
+
181
+ <!-- header_fix code here -->
182
+ <tr valign="top">
183
+ <th scope="row"><label for="header_fix_field">Fix Cookie Bar to Header?</label></th>
184
+ <td>
185
+ <input type="radio" id="header_fix_field_yes" name="header_fix_field" class="styled" value="true" <?php echo ( $the_options['header_fix'] == true ) ? ' checked="checked" />' : ' />'; ?> Yes
186
+ <input type="radio" id="iheader_fix_field_no" name="header_fix_field" class="styled" value="false" <?php echo ( $the_options['header_fix'] == false ) ? ' checked="checked" />' : ' />'; ?> No
187
+ <span class="cli-plugin-example">If you select "Header" then you can optionally stick the cookie bar to the header. Will not have any effect if you select "Footer".</span>
188
+ </td>
189
+ </tr>
190
+ <!-- /header_fix -->
191
+
192
  <tr valign="top">
193
  <th scope="row"><label for="notify_animate_show_field">On load</label></th>
194
  <td>
admin/cli-admin.php CHANGED
@@ -50,6 +50,7 @@ function cookielawinfo_get_default_settings() {
50
  'button_2_button_colour' => '#333',
51
  'button_2_button_size' => 'medium',
52
  'font_family' => 'inherit', // Pick the family, not the easy name (see helper function below)
 
53
  'is_on' => true,
54
  'notify_animate_hide' => true,
55
  'notify_animate_show' => false,
@@ -276,6 +277,7 @@ function cookielawinfo_sanitise($key, $value) {
276
  case 'scroll_close':
277
  case 'scroll_close_reload':
278
  case 'show_once_yn':
 
279
  if ( $value == 'true' || $value === true ) {
280
  $ret = true;
281
  }
@@ -352,25 +354,6 @@ function cookielawinfo_custom_dashboard_styles( $hook ) {
352
 
353
  wp_register_style( 'cookielawinfo-admin-style', plugins_url('/cookie-law-info/css/cli-admin-style.css') );
354
  wp_enqueue_style( 'cookielawinfo-admin-style' );
355
-
356
- /** RICHARDASHBY EDIT: remove old colourpicker */
357
- /*
358
- if ( cookielawinfo_colourpicker_enabled() ) {
359
- wp_enqueue_script('spectrum-colorpicker', plugins_url('/cookie-law-info/admin/bgrins-spectrum/spectrum.js'), array('jquery'));
360
- wp_register_style( 'spectrum-style', plugins_url('/cookie-law-info/admin/bgrins-spectrum/spectrum.css') );
361
- wp_enqueue_style( 'spectrum-style' );
362
- }
363
- */
364
-
365
- /** RICHARDASHBY EDIT: remove jqueryUI (js and CSS) for accordion tabs */
366
- /** @todo Replace UI with own jQuery, far simpler! */
367
- /*
368
- wp_enqueue_script('jquery-ui-custom', plugins_url('/cookie-law-info/js/jquery-ui-1.8.20.custom.min.js'), array('jquery'));
369
- wp_enqueue_script('admin-ui-controller', plugins_url('/cookie-law-info/js/admin-ui-controller.js'), array('jquery'));
370
-
371
- wp_register_style( 'jquery-ui-custom', plugins_url('/cookie-law-info/css/smoothness/jquery-ui-1.8.20.custom.css') );
372
- wp_enqueue_style( 'jquery-ui-custom' );
373
- */
374
  }
375
 
376
 
@@ -384,13 +367,6 @@ function cookielawinfo_custom_dashboard_styles_my_colours() {
384
  if ( $screen->post_type != 'cookielawinfo' ) {
385
  return;
386
  }
387
-
388
- /** RICHARDASHBY EDIT: remove old colourpicker */
389
- /*
390
- if( cookielawinfo_colourpicker_enabled() ) {
391
- wp_enqueue_script('spectrum-custom', plugins_url('/cookie-law-info/admin/bgrins-spectrum/my-colours.js'));
392
- }
393
- */
394
  }
395
 
396
 
50
  'button_2_button_colour' => '#333',
51
  'button_2_button_size' => 'medium',
52
  'font_family' => 'inherit', // Pick the family, not the easy name (see helper function below)
53
+ 'header_fix' => false,
54
  'is_on' => true,
55
  'notify_animate_hide' => true,
56
  'notify_animate_show' => false,
277
  case 'scroll_close':
278
  case 'scroll_close_reload':
279
  case 'show_once_yn':
280
+ case 'header_fix':
281
  if ( $value == 'true' || $value === true ) {
282
  $ret = true;
283
  }
354
 
355
  wp_register_style( 'cookielawinfo-admin-style', plugins_url('/cookie-law-info/css/cli-admin-style.css') );
356
  wp_enqueue_style( 'cookielawinfo-admin-style' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
  }
358
 
359
 
367
  if ( $screen->post_type != 'cookielawinfo' ) {
368
  return;
369
  }
 
 
 
 
 
 
 
370
  }
371
 
372
 
cookie-law-info.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://wordpress.org/extend/plugins/cookie-law-info/description/
5
  Description: A simple way of 'implied consent' to show your website complies with the EU Cookie Law, which came into force on 26 May 2012.
6
  Author: Richard Ashby
7
  Author URI: http://cookielawinfo.com/
8
- Version: 1.4.3
9
  License: GPL2
10
  */
11
 
@@ -64,16 +64,6 @@ add_shortcode( 'cookie_button', 'cookielawinfo_shortcode_main_button' ); // a s
64
 
65
  // Dashboard styles:
66
  add_action( 'admin_enqueue_scripts', 'cookielawinfo_custom_dashboard_styles' );
67
-
68
-
69
- /** RICHARDASHBY EDIT */
70
- //add_action( 'admin_footer', 'cookielawinfo_custom_dashboard_styles_my_colours' );
71
-
72
-
73
-
74
- /** RICHARDASHBY EDIT */
75
- // WP3.5 colour picker:
76
- // http://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
77
  add_action( 'admin_enqueue_scripts', 'cookielawinfo_enqueue_color_picker' );
78
  function cookielawinfo_enqueue_color_picker( $hook ) {
79
  if ( 'cookielawinfo_page_cookie-law-info' != $hook )
@@ -83,7 +73,6 @@ function cookielawinfo_enqueue_color_picker( $hook ) {
83
  }
84
 
85
 
86
-
87
  // Cookie Audit custom post type functions:
88
  add_action( 'admin_init', 'cookielawinfo_custom_posts_admin_init' );
89
  add_action( 'init', 'cookielawinfo_register_custom_post_type' );
@@ -92,8 +81,7 @@ add_filter( 'manage_edit-cookielawinfo_columns', 'cookielawinfo_edit_columns' );
92
  add_action( 'manage_posts_custom_column', 'cookielawinfo_custom_columns' );
93
 
94
 
95
- // 12/05 edit
96
- // Add plugin settings / more plugins link to the WordPress dashboard 'plugins' page:
97
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'cookielawinfo_plugin_action_links' );
98
  function cookielawinfo_plugin_action_links( $links ) {
99
  $links[] = '<a href="'. get_admin_url(null, 'edit.php?post_type=cookielawinfo&page=cookie-law-info') .'">Settings</a>';
5
  Description: A simple way of 'implied consent' to show your website complies with the EU Cookie Law, which came into force on 26 May 2012.
6
  Author: Richard Ashby
7
  Author URI: http://cookielawinfo.com/
8
+ Version: 1.5
9
  License: GPL2
10
  */
11
 
64
 
65
  // Dashboard styles:
66
  add_action( 'admin_enqueue_scripts', 'cookielawinfo_custom_dashboard_styles' );
 
 
 
 
 
 
 
 
 
 
67
  add_action( 'admin_enqueue_scripts', 'cookielawinfo_enqueue_color_picker' );
68
  function cookielawinfo_enqueue_color_picker( $hook ) {
69
  if ( 'cookielawinfo_page_cookie-law-info' != $hook )
73
  }
74
 
75
 
 
76
  // Cookie Audit custom post type functions:
77
  add_action( 'admin_init', 'cookielawinfo_custom_posts_admin_init' );
78
  add_action( 'init', 'cookielawinfo_register_custom_post_type' );
81
  add_action( 'manage_posts_custom_column', 'cookielawinfo_custom_columns' );
82
 
83
 
84
+ // Add plugin settings link:
 
85
  add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'cookielawinfo_plugin_action_links' );
86
  function cookielawinfo_plugin_action_links( $links ) {
87
  $links[] = '<a href="'. get_admin_url(null, 'edit.php?post_type=cookielawinfo&page=cookie-law-info') .'">Settings</a>';
css/cli-style.css CHANGED
@@ -3,6 +3,7 @@
3
  font-size: 10pt;
4
  margin: 0 auto;
5
  padding: 5px 0;
 
6
  text-align: center;
7
  width: 100%;
8
  z-index: 9999;
3
  font-size: 10pt;
4
  margin: 0 auto;
5
  padding: 5px 0;
6
+ position: absolute;
7
  text-align: center;
8
  width: 100%;
9
  z-index: 9999;
js/cookielawinfo.js CHANGED
@@ -1,5 +1,5 @@
1
  function cli_show_cookiebar(p) {
2
-
3
  var Cookie = {
4
  set: function(name,value,days) {
5
  if (days) {
@@ -34,7 +34,6 @@ function cli_show_cookiebar(p) {
34
 
35
  var ACCEPT_COOKIE_NAME = 'viewed_cookie_policy',
36
  ACCEPT_COOKIE_EXPIRE = 365,
37
- html = p.html,
38
  json_payload = p.settings;
39
 
40
  if (typeof JSON.parse !== "function") {
@@ -42,7 +41,6 @@ function cli_show_cookiebar(p) {
42
  return;
43
  }
44
  var settings = JSON.parse(json_payload);
45
- jQuery('body').prepend(html);
46
 
47
 
48
  var cached_header = jQuery(settings.notify_div_id),
@@ -62,6 +60,15 @@ function cli_show_cookiebar(p) {
62
  'color': settings.text,
63
  'font-family': settings.font_family
64
  };
 
 
 
 
 
 
 
 
 
65
  var showagain_args = {
66
  'background-color': settings.background,
67
  'color': l1hs(settings.text),
@@ -76,7 +83,6 @@ function cli_show_cookiebar(p) {
76
  if ( settings.notify_position_vertical == "top" ) {
77
  if ( settings.border_on ) {
78
  hdr_args['border-bottom'] = '4px solid ' + l1hs(settings.border);
79
- hdr_args['position'] = 'fixed';
80
  }
81
  showagain_args.top = '0';
82
  }
@@ -104,7 +110,6 @@ function cli_show_cookiebar(p) {
104
  cached_header.hide();
105
  }
106
 
107
- // Show once code:
108
  if ( settings.show_once_yn ) {
109
  setTimeout(close_header, settings.show_once);
110
  }
@@ -140,7 +145,6 @@ function cli_show_cookiebar(p) {
140
  });
141
  }
142
 
143
- // Action event listener for "show header" event:
144
  cached_showagain_tab.click(function(e) {
145
  e.preventDefault();
146
  cached_showagain_tab.slideUp(settings.animate_speed_hide, function slideShow() {
@@ -148,21 +152,17 @@ function cli_show_cookiebar(p) {
148
  });
149
  });
150
 
151
- // Action event listener to capture delete cookies shortcode click. This simply deletes the viewed_cookie_policy cookie. To use:
152
- // <a href='#' id='cookielawinfo-cookie-delete' class='cookie_hdr_btn'>Delete Cookies</a>
153
  jQuery("#cookielawinfo-cookie-delete").click(function() {
154
  Cookie.erase(ACCEPT_COOKIE_NAME);
155
  return false;
156
  });
157
 
158
- // action event listeners to capture "accept/continue" events:
159
  jQuery("#cookie_action_close_header").click(function(e) {
160
  e.preventDefault();
161
  accept_close();
162
  });
163
 
164
  function accept_close() {
165
- // Set cookie then hide header:
166
  Cookie.set(ACCEPT_COOKIE_NAME, 'yes', ACCEPT_COOKIE_EXPIRE);
167
 
168
  if (settings.notify_animate_hide) {
@@ -175,11 +175,6 @@ function cli_show_cookiebar(p) {
175
  return false;
176
  }
177
 
178
- /**
179
- * Soprattutto per gli italiani :)
180
- * If the visitor scrolls then under Italian law you have implied consent
181
- * Please note that this is not the law in other EU states, this is the Italian interpretation of the law
182
- */
183
  function closeOnScroll() {
184
  if (window.pageYOffset > 100 && !Cookie.read(ACCEPT_COOKIE_NAME)) {
185
  accept_close();
1
  function cli_show_cookiebar(p) {
2
+ /* plugin version 1.5 */
3
  var Cookie = {
4
  set: function(name,value,days) {
5
  if (days) {
34
 
35
  var ACCEPT_COOKIE_NAME = 'viewed_cookie_policy',
36
  ACCEPT_COOKIE_EXPIRE = 365,
 
37
  json_payload = p.settings;
38
 
39
  if (typeof JSON.parse !== "function") {
41
  return;
42
  }
43
  var settings = JSON.parse(json_payload);
 
44
 
45
 
46
  var cached_header = jQuery(settings.notify_div_id),
60
  'color': settings.text,
61
  'font-family': settings.font_family
62
  };
63
+ if ( settings.notify_position_vertical == "top" ) {
64
+ if ( settings.header_fix === true ) {
65
+ hdr_args['position'] = 'fixed';
66
+ }
67
+ hdr_args['top'] = '0';
68
+ } else {
69
+ hdr_args['bottom'] = '0';
70
+ }
71
+
72
  var showagain_args = {
73
  'background-color': settings.background,
74
  'color': l1hs(settings.text),
83
  if ( settings.notify_position_vertical == "top" ) {
84
  if ( settings.border_on ) {
85
  hdr_args['border-bottom'] = '4px solid ' + l1hs(settings.border);
 
86
  }
87
  showagain_args.top = '0';
88
  }
110
  cached_header.hide();
111
  }
112
 
 
113
  if ( settings.show_once_yn ) {
114
  setTimeout(close_header, settings.show_once);
115
  }
145
  });
146
  }
147
 
 
148
  cached_showagain_tab.click(function(e) {
149
  e.preventDefault();
150
  cached_showagain_tab.slideUp(settings.animate_speed_hide, function slideShow() {
152
  });
153
  });
154
 
 
 
155
  jQuery("#cookielawinfo-cookie-delete").click(function() {
156
  Cookie.erase(ACCEPT_COOKIE_NAME);
157
  return false;
158
  });
159
 
 
160
  jQuery("#cookie_action_close_header").click(function(e) {
161
  e.preventDefault();
162
  accept_close();
163
  });
164
 
165
  function accept_close() {
 
166
  Cookie.set(ACCEPT_COOKIE_NAME, 'yes', ACCEPT_COOKIE_EXPIRE);
167
 
168
  if (settings.notify_animate_hide) {
175
  return false;
176
  }
177
 
 
 
 
 
 
178
  function closeOnScroll() {
179
  if (window.pageYOffset > 100 && !Cookie.read(ACCEPT_COOKIE_NAME)) {
180
  accept_close();
php/functions.php CHANGED
@@ -45,6 +45,7 @@ function cookielawinfo_get_json_settings() {
45
  'button_2_link_colour' => $settings['button_2_link_colour'],
46
  'button_2_as_button' => $settings['button_2_as_button'],
47
  'font_family' => $settings['font_family'],
 
48
  'notify_animate_hide' => $settings['notify_animate_hide'],
49
  'notify_animate_show' => $settings['notify_animate_show'],
50
  'notify_div_id' => $settings['notify_div_id'],
@@ -82,37 +83,27 @@ function cookielawinfo_inject_cli_script() {
82
  $the_options = cookielawinfo_get_admin_settings();
83
 
84
  if ( $the_options['is_on'] == true ) {
85
-
86
- // Process string for JavaScript
87
- // REFACTOR / DEBUG:
88
- // Consider using esc_js( $str ) instead of manually correcting (though is > WP v2.8 only, hence doing manually)
89
-
90
- // $str processes shortcodes:
91
- $str = addslashes ( do_shortcode( stripslashes ( $the_options['notify_message'] ) ) );
92
-
93
- // Remove line breaks (breaks JavaScript if param is split over > 1 lines)
94
- $line_breaks = array("\r\n", "\n", "\r");
95
- $str = str_replace($line_breaks, '<br />', $str);
96
-
97
- // You can construct your own HTML and CSS here if needed.
98
  $notify_html = '<div id="' . cookielawinfo_remove_hash( $the_options["notify_div_id"] ) . '"><span>' . $str . '</span></div>';
99
 
100
  if ( $the_options['showagain_tab'] === true ) {
101
  $notify_html .= '<div id="' . cookielawinfo_remove_hash( $the_options["showagain_div_id"] ) . '"><span id="cookie_hdr_showagain">' . $the_options["showagain_text"] . '</span></div>';
102
  }
 
 
 
 
103
 
104
  ?>
105
 
106
  <script type="text/javascript">
107
  //<![CDATA[
108
  jQuery(document).ready(function() {
109
-
110
- // Edit 09/05: remove globals and package into Object Literal, and removed the debug function
111
  cli_show_cookiebar({
112
- html: '<?php echo $notify_html; ?>',
113
  settings: '<?php echo cookielawinfo_get_json_settings(); ?>'
114
  });
115
-
116
  });
117
  //]]>
118
  </script>
@@ -133,9 +124,6 @@ function cookielawinfo_enqueue_frontend_scripts() {
133
  $the_options = cookielawinfo_get_admin_settings();
134
  if ( $the_options['is_on'] == true ) {
135
 
136
- // Edit 09/05: remove jQuery cookie dependency
137
- //wp_enqueue_script( 'jquery-cookie', CLI_PLUGIN_URL . 'js/jquery.cookie.js', array('jquery') );
138
-
139
  wp_register_style( 'cookielawinfo-style', CLI_PLUGIN_URL . 'css/cli-style.css' );
140
  wp_enqueue_style( 'cookielawinfo-style' );
141
 
@@ -143,12 +131,6 @@ function cookielawinfo_enqueue_frontend_scripts() {
143
  wp_enqueue_script( 'cookie-law-info-script', CLI_PLUGIN_URL . 'js/cookielawinfo.js', array( 'jquery' ) );
144
  }
145
  wp_register_style( 'cookielawinfo-table-style', CLI_PLUGIN_URL . 'css/cli-tables.css' );
146
-
147
- /**
148
- * RICHARDASHBY EDIT: only enqueue on pages that need it
149
- * Previously this next line of code included CSS on every page, which is a waste of resources
150
- * Old >>> wp_enqueue_style( 'cookielawinfo-table-style' );
151
- */
152
  }
153
 
154
 
45
  'button_2_link_colour' => $settings['button_2_link_colour'],
46
  'button_2_as_button' => $settings['button_2_as_button'],
47
  'font_family' => $settings['font_family'],
48
+ 'header_fix' => $settings['header_fix'],
49
  'notify_animate_hide' => $settings['notify_animate_hide'],
50
  'notify_animate_show' => $settings['notify_animate_show'],
51
  'notify_div_id' => $settings['notify_div_id'],
83
  $the_options = cookielawinfo_get_admin_settings();
84
 
85
  if ( $the_options['is_on'] == true ) {
86
+
87
+ // Output the HTML in the footer:
88
+ $str = do_shortcode( stripslashes ( $the_options['notify_message'] ) );
 
 
 
 
 
 
 
 
 
 
89
  $notify_html = '<div id="' . cookielawinfo_remove_hash( $the_options["notify_div_id"] ) . '"><span>' . $str . '</span></div>';
90
 
91
  if ( $the_options['showagain_tab'] === true ) {
92
  $notify_html .= '<div id="' . cookielawinfo_remove_hash( $the_options["showagain_div_id"] ) . '"><span id="cookie_hdr_showagain">' . $the_options["showagain_text"] . '</span></div>';
93
  }
94
+
95
+ echo $notify_html;
96
+
97
+ // Now output the JavaScript:
98
 
99
  ?>
100
 
101
  <script type="text/javascript">
102
  //<![CDATA[
103
  jQuery(document).ready(function() {
 
 
104
  cli_show_cookiebar({
 
105
  settings: '<?php echo cookielawinfo_get_json_settings(); ?>'
106
  });
 
107
  });
108
  //]]>
109
  </script>
124
  $the_options = cookielawinfo_get_admin_settings();
125
  if ( $the_options['is_on'] == true ) {
126
 
 
 
 
127
  wp_register_style( 'cookielawinfo-style', CLI_PLUGIN_URL . 'css/cli-style.css' );
128
  wp_enqueue_style( 'cookielawinfo-style' );
129
 
131
  wp_enqueue_script( 'cookie-law-info-script', CLI_PLUGIN_URL . 'js/cookielawinfo.js', array( 'jquery' ) );
132
  }
133
  wp_register_style( 'cookielawinfo-table-style', CLI_PLUGIN_URL . 'css/cli-tables.css' );
 
 
 
 
 
 
134
  }
135
 
136
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://cookielawinfo.com/donate
4
  Tags: eu cookie law, cookie law, eu privacy directive, privacy directive, cookies, privacy, compliance
5
  Requires at least: 3.3.1
6
  Tested up to: 4.2.2
7
- Stable tag: 1.4.3
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -141,6 +141,10 @@ See http://cookielawinfo.com for more information on what is required.
141
 
142
  == Changelog ==
143
 
 
 
 
 
144
  = 1.4.3 =
145
  * jQuery 'reload' bug fix on accept
146
 
4
  Tags: eu cookie law, cookie law, eu privacy directive, privacy directive, cookies, privacy, compliance
5
  Requires at least: 3.3.1
6
  Tested up to: 4.2.2
7
+ Stable tag: 1.5
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
141
 
142
  == Changelog ==
143
 
144
+ = 1.5 =
145
+ * Major update: the cookie bar is now inserted into the page via wp_footer rather than using jQuery (for better performance and greater browser compatibility)
146
+ * Update: if the cookie bar is in the header, there is now an option to fix the bar to the header using position:fixed
147
+
148
  = 1.4.3 =
149
  * jQuery 'reload' bug fix on accept
150