Cookie Consent - Version 1.0

Version Description

Download this release

Release Info

Developer Catapult
Plugin Icon 128x128 Cookie Consent
Version 1.0
Comparing to
See all releases

Version 1.0

Files changed (4) hide show
  1. readme.txt +47 -0
  2. screenshot-1.png +0 -0
  3. screenshot-2.gif +0 -0
  4. uk-cookie-consent.php +193 -0
readme.txt ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Plugin Name ===
2
+ Contributors: catapult
3
+ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=M2FLCU6Z4A2LA
4
+ Tags: cookies, eu, cookie law, implied consent, uk cookie consent
5
+ Requires at least: 3.3.2
6
+ Tested up to: 3.3.2
7
+ Stable tag: 1.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Shows an unobtrusive yet clear message to users that the site uses cookies.
12
+
13
+ == Description ==
14
+
15
+ Simple plug-in to help compliance with the UK interpretation of the EU regulations regarding usage of website cookies. A user to your site is presented with a clear yet unobtrusive notification that the site is using cookies and may then acknowledge and dismiss the notification or click to find out more. The plug-in automatically creates a new page with pre-populated information on cookies and how to disable them, which you may further edit if you wish.
16
+
17
+ Importantly, the plug-in does not disable cookies on your site or prevent the user from continuing to browse the site - it comes with standard wording on what cookies are and advice on how to disable them in the browser. The plug-in follows the notion of "implied consent" as described by the UK's Information Commissioner and makes the assumption that most users who choose not to accept cookies will do so for all websites.
18
+
19
+ == Installation ==
20
+
21
+ 1. Upload the `uk-cookie-consent` folder to the `/wp-content/plugins/` directory
22
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
23
+ 1. Browse to the Cookie Consent option page in Settings to configure
24
+
25
+ == Frequently Asked Questions ==
26
+
27
+ = Where can I find out more about this plug-in? =
28
+
29
+ You can find out more about the plug-in on [its plug-in page](http://catapultdesign.co.uk/plugin/uk-cookie-consent/).
30
+
31
+ = Where can I find out more about the UK laws regarding cookies? =
32
+
33
+ We have written a short article on [our interpretation of the UK cookie law](http://catapultdesign.co.uk/uk-cookie-consent/). This outlines some of the background to the regulations and the reasons for choosing the 'implied consent' method.
34
+
35
+ You will find more details of the regulations on the [Information Commissioner's Office site](http://www.ico.gov.uk/for_organisations/privacy_and_electronic_communications/the_guide/cookies.aspx).
36
+
37
+ == Screenshots ==
38
+
39
+ 1. The plug-in places an unobtrusive notification at the top of the page. The user can acknowledge and dismiss the notification by clicking the green button - this is consent for the use of cookies. Alternatively, the user can click the link for more information to be directed to a pre-populated page describing what cookies are and how to disable them.
40
+
41
+ 1. Simple settings page allows you to modify the message and button text.
42
+
43
+ == Changelog ==
44
+
45
+
46
+ == Upgrade Notice ==
47
+
screenshot-1.png ADDED
Binary file
screenshot-2.gif ADDED
Binary file
uk-cookie-consent.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: UK Cookie Consent
4
+ Plugin URI: http://catapultdesign.co.uk/plugin/uk-cookie-consent/
5
+ Description: Simple plug-in to help compliance with the UK interpretation of the EU regulations regarding usage of website cookies. A user to your site is presented with a clear yet unobtrusive notification that the site is using cookies and may then acknowledge and dismiss the notification or click to find out more. The plug-in does not disable cookies on your site or prevent the user from continuing to browse the site - it comes with standard wording on what cookies are and advice on how to disable them in the browser. The plug-in follows the notion of "implied consent" as described by the UK's Information Commissioner and makes the assumption that most users who choose not to accept cookies will do so for all websites.
6
+ Author: Catapult
7
+ Version: 1.0
8
+ Author URI: http://catapultdesign.co.uk/
9
+ */
10
+
11
+ $options = get_option('catapult_cookie_options');
12
+
13
+ $wp_content_url = get_option( 'siteurl' ) . '/wp-content';
14
+ $wp_plugin_url = plugins_url() . '/catapult-cookie-consent';
15
+
16
+
17
+ //Add an option page for the settings
18
+ add_action('admin_menu', 'catapult_cookie_plugin_menu');
19
+ function catapult_cookie_plugin_menu() {
20
+ add_options_page('Cookie Consent', 'Cookie Consent', 'manage_options', 'catapult_cookie_consent', 'catapult_cookie_options_page');
21
+ }
22
+
23
+ function catapult_cookie_options_page() { ?>
24
+ <div class="wrap">
25
+ <h2>Cookie Consent Settings</h2>
26
+ <?php //Check to see if the info page has been created
27
+ $options = get_option('catapult_cookie_options');
28
+ $pagename = $options['catapult_cookie_link_settings'];
29
+ if ( !$pagename ) $pagename = 'Cookies';
30
+ $cpage = get_page_by_title ( $pagename );
31
+ if ( !$cpage ) {
32
+ global $user_ID;
33
+ $page['post_type'] = 'page';
34
+ $page['post_content'] = '<p>This site uses cookies - small text files that are placed on your machine to help the site provide a better user experience. In general, cookies are used to retain user preferences, store information for things like shopping carts, and provide anonymised tracking data to third party applications like Google Analytics.</p>
35
+ <p>As a rule, cookies will make your browsing experience better. However, you may prefer to disable cookies on this site and on others. The most effective way to do this is to disable cookies in your browser. We suggest consulting the Help section of your browser or taking a look at <a href="http://www.aboutcookies.org">the About Cookies website</a> which offers guidance for all modern browsers.</p>';
36
+ $page['post_parent'] = 0;
37
+ $page['post_author'] = $user_ID;
38
+ $page['post_status'] = 'publish';
39
+ $page['post_title'] = $pagename;
40
+ $pageid = wp_insert_post ( $page );
41
+ if ( $pageid == 0 ) {
42
+ echo '<div class="updated settings-error">Failed to create page.</div>';
43
+ }
44
+ } ?>
45
+ <form action="options.php" method="post">
46
+
47
+ <?php settings_fields('catapult_cookie_options'); ?>
48
+ <?php do_settings_sections('catapult_cookie'); ?>
49
+ <input name="cat_submit" type="submit" id="submit" class="button-primary" style="margin-top:30px;" value="<?php esc_attr_e('Save Changes'); ?>" />
50
+ </form>
51
+ </div>
52
+ <?php }
53
+
54
+ add_action('admin_init', 'catapult_cookie_admin_init');
55
+ function catapult_cookie_admin_init(){
56
+ register_setting( 'catapult_cookie_options', 'catapult_cookie_options', 'catapult_cookie_options_validate' );
57
+ add_settings_section('catapult_cookie_main', 'Settings', 'catapult_cookie_section_text', 'catapult_cookie', 'catapult_cookie_main' );
58
+ add_settings_field('catapult_cookie_text', 'Notification text', 'catapult_cookie_text_settings', 'catapult_cookie', 'catapult_cookie_main' );
59
+ add_settings_field('catapult_cookie_accept', 'Accept text', 'catapult_cookie_accept_settings', 'catapult_cookie', 'catapult_cookie_main' );
60
+ add_settings_field('catapult_cookie_more', 'More info text', 'catapult_cookie_more_settings', 'catapult_cookie', 'catapult_cookie_main' );
61
+ add_settings_field('catapult_cookie_link', 'Info page name', 'catapult_cookie_link_settings', 'catapult_cookie', 'catapult_cookie_main' );
62
+ }
63
+
64
+ function catapult_cookie_section_text() {
65
+ echo '<p>You can just use these settings as they are or update the text as you wish. We recommend keeping it brief.</p>
66
+ <p>For any support queries, please post on the <a href="http://wordpress.org/extend/plugins/uk-cookie-consent/">WordPress forum</a>.</p>';
67
+ }
68
+
69
+ function catapult_cookie_text_settings() {
70
+ $options = get_option('catapult_cookie_options');
71
+ $value = htmlentities ( $options['catapult_cookie_text_settings'], ENT_QUOTES );
72
+ if ( !$value ) {
73
+ $value = 'This site uses cookies';
74
+ }
75
+ echo "<input id='catapult_cookie_text_settings' name='catapult_cookie_options[catapult_cookie_text_settings]' size='50' type='text' value='{$value}' />";
76
+ }
77
+ function catapult_cookie_accept_settings() {
78
+ $options = get_option('catapult_cookie_options');
79
+ $value = htmlentities ( $options['catapult_cookie_accept_settings'], ENT_QUOTES );
80
+ if ( !$value ) {
81
+ $value = 'No problem';
82
+ }
83
+ echo "<input id='catapult_cookie_accept_settings' name='catapult_cookie_options[catapult_cookie_accept_settings]' size='50' type='text' value='{$value}' />";
84
+ }
85
+ function catapult_cookie_more_settings() {
86
+ $options = get_option('catapult_cookie_options');
87
+ $value = htmlentities ( $options['catapult_cookie_more_settings'], ENT_QUOTES );
88
+ if ( !$value ) {
89
+ $value = 'More info';
90
+ }
91
+ echo "<input id='catapult_cookie_more_settings' name='catapult_cookie_options[catapult_cookie_more_settings]' size='50' type='text' value='{$value}' />";
92
+ }
93
+ function catapult_cookie_link_settings() {
94
+ $options = get_option('catapult_cookie_options');
95
+ $value = htmlentities ( $options['catapult_cookie_link_settings'], ENT_QUOTES );
96
+ if ( !$value ) {
97
+ $value = 'Cookies';
98
+ }
99
+ echo "<input id='catapult_cookie_link_settings' name='catapult_cookie_options[catapult_cookie_link_settings]' size='50' type='text' value='{$value}' />";
100
+ }
101
+
102
+ function catapult_cookie_options_validate($input) {
103
+ $options = get_option('catapult_cookie_options');
104
+ $options['catapult_cookie_text_settings'] = trim($input['catapult_cookie_text_settings']);
105
+ $options['catapult_cookie_accept_settings'] = trim($input['catapult_cookie_accept_settings']);
106
+ $options['catapult_cookie_more_settings'] = trim($input['catapult_cookie_more_settings']);
107
+ $options['catapult_cookie_link_settings'] = trim($input['catapult_cookie_link_settings']);
108
+ $options['catapult_cookie_page_settings'] = trim($input['catapult_cookie_page_settings']);
109
+ return $options;
110
+ }
111
+
112
+ //Enqueue jquery
113
+ function catapult_cookie_jquery() {
114
+ wp_enqueue_script( 'jquery' );
115
+ }
116
+ add_action('wp_enqueue_scripts', 'catapult_cookie_jquery');
117
+
118
+ //Add CSS and JS if the cookie is not set
119
+ function catapult_add_cookie_css() {
120
+ if ( !isset ( $_COOKIE["catAccCookies"] ) ) {
121
+ echo '<style type="text/css" media="screen">
122
+ html { margin-top: 32px; }
123
+ * html body { margin-top: 32px; }
124
+ #catapult-cookie-bar {
125
+ direction: ltr;
126
+ color: #DDD;
127
+ font: normal 13px/28px sans-serif;
128
+ height: 30px;
129
+ position: fixed;
130
+ top: 0;
131
+ left: 0;
132
+ width: 100%;
133
+ min-width: 600px;
134
+ z-index: 99999;
135
+ padding:2px 20px 0;
136
+ background-color: #464646;
137
+ background-image: -ms-linear-gradient(bottom, #373737, #464646 5px);
138
+ background-image: -moz-linear-gradient(bottom, #373737, #464646 5px);
139
+ background-image: -o-linear-gradient(bottom, #373737, #464646 5px);
140
+ background-image: -webkit-gradient(linear,left bottom,left top,from( #373737),to(#464646));
141
+ background-image: -webkit-linear-gradient(bottom, #373737, #464646 5px);
142
+ background-image: linear-gradient(bottom, #373737, #464646 5px);
143
+ }
144
+ #catapult-cookie-bar a {
145
+ color:#fff;
146
+ }
147
+ button#catapultCookie {
148
+ margin:0 20px;
149
+ line-height:20px;
150
+ background:#45AE52;
151
+ border:none;
152
+ color:#fff;
153
+ padding:0 12px;
154
+ border-radius: 3px;
155
+ cursor: pointer;
156
+ font-size: 13px;
157
+ font-weight: bold;
158
+ font-family: sans-serif;
159
+ text-shadow: #555 1px 1px;
160
+ }
161
+ button#catapultCookie:hover {
162
+ background:#5EC544;
163
+ }
164
+ </style>
165
+ <script type="text/javascript">
166
+ function catapultAcceptCookies() {
167
+ days = 30;
168
+ var date = new Date();
169
+ date.setTime(date.getTime()+(days*24*60*60*1000));
170
+ var expires = "; expires="+date.toGMTString();
171
+ document.cookie = "catAccCookies=true"+expires+"; path=/";
172
+ jQuery("#catapult-cookie-bar").hide();
173
+ jQuery("html").css("margin-top","0");
174
+ }
175
+ </script>';
176
+ }
177
+ }
178
+ add_action ( 'wp_head', 'catapult_add_cookie_css' );
179
+
180
+ //Add the notification bar if the cookie is not set
181
+ function catapult_add_cookie_bar() {
182
+ if ( !isset ( $_COOKIE["catAccCookies"] ) ) {
183
+ $options = get_option('catapult_cookie_options');
184
+ $current_text = $options['catapult_cookie_text_settings'];
185
+ $accept_text = $options['catapult_cookie_accept_settings'];
186
+ $more_text = $options['catapult_cookie_more_settings'];
187
+ $link_text = strtolower ( $options['catapult_cookie_link_settings'] );
188
+ echo '<div id="catapult-cookie-bar">' . htmlspecialchars ( $current_text ) . '<button id="catapultCookie" onclick="catapultAcceptCookies()">' . htmlspecialchars ( $accept_text ) . '</button><a href="' . get_bloginfo ( 'url' ) . '/' . $link_text . '">' . htmlspecialchars ( $more_text ) . '</a></div>';
189
+ }
190
+ }
191
+ add_action ( 'wp_footer', 'catapult_add_cookie_bar', 1000 );
192
+
193
+