Cookie Consent - Version 1.6

Version Description

Moved JS to footer (thanks to Andreas Larsen for the suggestion)

Download this release

Release Info

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

Code changes from version 1.5 to 1.6

Files changed (4) hide show
  1. js/colour-picker.js +3 -3
  2. js/uk-cookie-consent-js.js +27 -27
  3. readme.txt +97 -94
  4. uk-cookie-consent.php +305 -305
js/colour-picker.js CHANGED
@@ -1,3 +1,3 @@
1
- jQuery(document).ready(function($){
2
- $('.my-color-field').wpColorPicker(); //Do the colour picker on theme options
3
- });
1
+ jQuery(document).ready(function($){
2
+ $('.my-color-field').wpColorPicker(); //Do the colour picker on theme options
3
+ });
js/uk-cookie-consent-js.js CHANGED
@@ -1,28 +1,28 @@
1
- //All the cookie setting stuff
2
- function catapultSetCookie(cookieName, cookieValue, nDays) {
3
- var today = new Date();
4
- var expire = new Date();
5
- if (nDays==null || nDays==0) nDays=1;
6
- expire.setTime(today.getTime() + 3600000*24*nDays);
7
- document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString()+"; path=/";
8
- }
9
- function catapultReadCookie(cookieName) {
10
- var theCookie=" "+document.cookie;
11
- var ind=theCookie.indexOf(" "+cookieName+"=");
12
- if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"=");
13
- if (ind==-1 || cookieName=="") return "";
14
- var ind1=theCookie.indexOf(";",ind+1);
15
- if (ind1==-1) ind1=theCookie.length;
16
- return unescape(theCookie.substring(ind+cookieName.length+2,ind1));
17
- }
18
- function catapultDeleteCookie(cookieName) {
19
- var today = new Date();
20
- var expire = new Date() - 30;
21
- expire.setTime(today.getTime() - 3600000*24*90);
22
- document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();
23
- }
24
- function catapultAcceptCookies() {
25
- catapultSetCookie('catAccCookies', true, 30);
26
- jQuery("#catapult-cookie-bar").hide();
27
- jQuery("html").css("margin-top","0");
28
  }
1
+ //All the cookie setting stuff
2
+ function catapultSetCookie(cookieName, cookieValue, nDays) {
3
+ var today = new Date();
4
+ var expire = new Date();
5
+ if (nDays==null || nDays==0) nDays=1;
6
+ expire.setTime(today.getTime() + 3600000*24*nDays);
7
+ document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString()+"; path=/";
8
+ }
9
+ function catapultReadCookie(cookieName) {
10
+ var theCookie=" "+document.cookie;
11
+ var ind=theCookie.indexOf(" "+cookieName+"=");
12
+ if (ind==-1) ind=theCookie.indexOf(";"+cookieName+"=");
13
+ if (ind==-1 || cookieName=="") return "";
14
+ var ind1=theCookie.indexOf(";",ind+1);
15
+ if (ind1==-1) ind1=theCookie.length;
16
+ return unescape(theCookie.substring(ind+cookieName.length+2,ind1));
17
+ }
18
+ function catapultDeleteCookie(cookieName) {
19
+ var today = new Date();
20
+ var expire = new Date() - 30;
21
+ expire.setTime(today.getTime() - 3600000*24*90);
22
+ document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();
23
+ }
24
+ function catapultAcceptCookies() {
25
+ catapultSetCookie('catAccCookies', true, 30);
26
+ jQuery("#catapult-cookie-bar").hide();
27
+ jQuery("html").css("margin-top","0");
28
  }
readme.txt CHANGED
@@ -1,95 +1,98 @@
1
- === Plugin Name ===
2
- Contributors: catapult, husobj
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.5.0
6
- Tested up to: 3.5.1
7
- Stable tag: 1.4.2
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 your site uses cookies.
12
-
13
- == Description ==
14
-
15
- We think this is the simplest but most effective method of dealing with the legislation.
16
-
17
- The plug-in is a straightforward approach to help you comply with the UK interpretation of the EU regulations regarding usage of website cookies. It 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. 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 edit further if you wish.
18
-
19
- Importantly, the plug-in does not disable cookies on your site or prevent the user from continuing to browse the site. Several plug-ins have adopted the "explicit consent" approach which obliges users to opt in to cookies on your site. This is likely to deter visitors.
20
-
21
- == Installation ==
22
-
23
- 1. Upload the `uk-cookie-consent` folder to the `/wp-content/plugins/` directory
24
- 1. Activate the plugin through the 'Plugins' menu in WordPress
25
- 1. Browse to the Cookie Consent option page in Settings to configure
26
-
27
- == Frequently Asked Questions ==
28
-
29
- = Where can I find out more about this plug-in? =
30
-
31
- You can find out more about the plug-in on [its plug-in page](http://catapultdesign.co.uk/plugin/uk-cookie-consent/).
32
-
33
- = Does this definitely cover me under the legislation? =
34
-
35
- You have to make up your own mind about that or consult a legal expert.
36
-
37
- = Where can I find out more about the UK laws regarding cookies? =
38
-
39
- 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.
40
-
41
- 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).
42
-
43
- == Screenshots ==
44
-
45
- 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.
46
-
47
- 1. Simple settings page allows you to modify the message and button text.
48
-
49
- == Changelog ==
50
-
51
- = 1.5 =
52
- Switched the logic so that the bar is initially hidden on the page and only displays if user has not previously dismissed it.
53
- Gives a slightly better performance.
54
- Thanks to chrisHe for the suggestion.
55
-
56
- = 1.4.2. =
57
- Policy page created on register_activation_hook now
58
-
59
- = 1.4.1 =
60
- Tweak to ensure jQuery is a dependency
61
-
62
- = 1.4 =
63
- This plug-in now uses JavaScript to test whether the user has dismissed the front-end notification in order to solve issues with caching plug-ins.
64
- Added configuration options for colour and position of bar.
65
- Set notification button and link to first element in tab list.
66
- Thanks to husobj for contributions and suggestions including localisation and enqueueing scripts and stylesheets
67
-
68
- = 1.3 =
69
- Reinstated user-defined permalink field
70
-
71
- = 1.25 =
72
- Minor admin update
73
-
74
- = 1.24 =
75
- Fixed text alignment issue with Thesis framework (thanks to cavnit for pointing this one out)
76
-
77
- = 1.23 =
78
- Minor admin update
79
-
80
- = 1.22 =
81
- Minor admin update
82
-
83
- = 1.21 =
84
- Added resources to Settings page
85
-
86
- = 1.2 =
87
- Change title of Cookies page to Cookie Policy and removed option to change title
88
- Added trailing slash to Cookie Policy url (thanks to mikeotgaar for spotting this)
89
-
90
- = 1.1 =
91
- Added default text to messages
92
-
93
- == Upgrade Notice ==
94
-
 
 
 
95
  Recommended
1
+ === Plugin Name ===
2
+ Contributors: catapult, husobj
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.5.0
6
+ Tested up to: 3.7.1
7
+ Stable tag: 1.6
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 your site uses cookies.
12
+
13
+ == Description ==
14
+
15
+ We think this is the simplest but most effective method of dealing with the legislation.
16
+
17
+ The plug-in is a straightforward approach to help you comply with the UK interpretation of the EU regulations regarding usage of website cookies. It 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. 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 edit further if you wish.
18
+
19
+ Importantly, the plug-in does not disable cookies on your site or prevent the user from continuing to browse the site. Several plug-ins have adopted the "explicit consent" approach which obliges users to opt in to cookies on your site. This is likely to deter visitors.
20
+
21
+ == Installation ==
22
+
23
+ 1. Upload the `uk-cookie-consent` folder to the `/wp-content/plugins/` directory
24
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
25
+ 1. Browse to the Cookie Consent option page in Settings to configure
26
+
27
+ == Frequently Asked Questions ==
28
+
29
+ = Where can I find out more about this plug-in? =
30
+
31
+ You can find out more about the plug-in on [its plug-in page](http://catapultdesign.co.uk/plugin/uk-cookie-consent/).
32
+
33
+ = Does this definitely cover me under the legislation? =
34
+
35
+ You have to make up your own mind about that or consult a legal expert.
36
+
37
+ = Where can I find out more about the UK laws regarding cookies? =
38
+
39
+ 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.
40
+
41
+ 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).
42
+
43
+ == Screenshots ==
44
+
45
+ 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.
46
+
47
+ 1. Simple settings page allows you to modify the message and button text.
48
+
49
+ == Changelog ==
50
+
51
+ = 1.6 =
52
+ Moved JS to footer (thanks to Andreas Larsen for the suggestion)
53
+
54
+ = 1.5 =
55
+ Switched the logic so that the bar is initially hidden on the page and only displays if user has not previously dismissed it.
56
+ Gives a slightly better performance.
57
+ Thanks to chrisHe for the suggestion.
58
+
59
+ = 1.4.2. =
60
+ Policy page created on register_activation_hook now
61
+
62
+ = 1.4.1 =
63
+ Tweak to ensure jQuery is a dependency
64
+
65
+ = 1.4 =
66
+ This plug-in now uses JavaScript to test whether the user has dismissed the front-end notification in order to solve issues with caching plug-ins.
67
+ Added configuration options for colour and position of bar.
68
+ Set notification button and link to first element in tab list.
69
+ Thanks to husobj for contributions and suggestions including localisation and enqueueing scripts and stylesheets
70
+
71
+ = 1.3 =
72
+ Reinstated user-defined permalink field
73
+
74
+ = 1.25 =
75
+ Minor admin update
76
+
77
+ = 1.24 =
78
+ Fixed text alignment issue with Thesis framework (thanks to cavnit for pointing this one out)
79
+
80
+ = 1.23 =
81
+ Minor admin update
82
+
83
+ = 1.22 =
84
+ Minor admin update
85
+
86
+ = 1.21 =
87
+ Added resources to Settings page
88
+
89
+ = 1.2 =
90
+ Change title of Cookies page to Cookie Policy and removed option to change title
91
+ Added trailing slash to Cookie Policy url (thanks to mikeotgaar for spotting this)
92
+
93
+ = 1.1 =
94
+ Added default text to messages
95
+
96
+ == Upgrade Notice ==
97
+
98
  Recommended
uk-cookie-consent.php CHANGED
@@ -1,306 +1,306 @@
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.5
8
- Author URI: http://catapultdesign.co.uk/
9
- */
10
-
11
- // Language
12
- load_plugin_textdomain( 'uk-cookie-consent', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
13
-
14
- //Add an option page for the settings
15
- add_action('admin_menu', 'catapult_cookie_plugin_menu');
16
- function catapult_cookie_plugin_menu() {
17
- add_options_page( __( 'Cookie Consent', 'uk-cookie-consent' ), __( 'Cookie Consent', 'uk-cookie-consent' ), 'manage_options', 'catapult_cookie_consent', 'catapult_cookie_options_page' );
18
- }
19
-
20
- function catapult_cookie_options_page() { ?>
21
- <div class="wrap">
22
- <h2><?php _e( 'UK Cookie Consent', 'uk-cookie-consent' ); ?></h2>
23
- <div id="poststuff" class="metabox-holder has-right-sidebar">
24
- <div class="meta-box-sortabless">
25
- <div class="postbox">
26
- <h3 class="hndle"><?php _e( 'Your settings', 'uk-cookie-consent' ); ?></h3>
27
- <div class="inside">
28
- <form action="options.php" method="post">
29
- <?php settings_fields('catapult_cookie_options'); ?>
30
- <?php do_settings_sections('catapult_cookie'); ?>
31
- <input name="cat_submit" type="submit" id="submit" class="button-primary" style="margin-top:30px;" value="<?php esc_attr_e( __( 'Save Changes', 'uk-cookie-consent' ) ); ?>" />
32
- <?php $options = get_option('catapult_cookie_options');
33
- $value = htmlentities ( $options['catapult_cookie_link_settings'], ENT_QUOTES );
34
- if ( !$value ) {
35
- $value = 'cookie-policy';
36
- } ?>
37
- <p><?php echo sprintf( __( 'Your Cookies Policy page is <a href="%s">here</a>. You may wish to create a menu item or other link on your site to this page.', 'uk-cookie-consent' ), home_url( $value ) ); ?></p>
38
- </form>
39
- </div>
40
- </div>
41
- </div>
42
- <div class="meta-box-sortabless ui-sortable" style="position:relative;">
43
- <div class="postbox">
44
- <h3 class="hndle"><?php _e( 'Resources', 'uk-cookie-consent' ); ?></h3>
45
- <div class="inside">
46
- <p><a href="http://www.ico.gov.uk/for_organisations/privacy_and_electronic_communications/the_guide/cookies.aspx"><?php _e( 'Information Commissioner\'s Office Guidance on Cookies', 'uk-cookie-consent' ); ?></a></p>
47
- <p><a href="http://www.aboutcookies.org/default.aspx">AboutCookies.org</a></p>
48
- <p><a href="http://catapultdesign.co.uk/uk-cookie-consent/"><?php _e( 'Our interpretation of the guidance', 'uk-cookie-consent' ); ?></a></p>
49
- </div>
50
- </div>
51
- </div>
52
- </div><!-- poststuff -->
53
- </div>
54
- <?php }
55
-
56
- add_action('admin_init', 'catapult_cookie_admin_init');
57
-
58
- function catapult_create_policy_page() {
59
- //Check to see if the info page has been created
60
- $options = get_option('catapult_cookie_options');
61
- $pagename = __( 'Cookie Policy', 'uk-cookie-consent' );
62
- $cpage = get_page_by_title ( $pagename );
63
- if ( !$cpage ) {
64
- global $user_ID;
65
- $page['post_type'] = 'page';
66
- $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. 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', 'uk-cookie-consent' ) . '</p>';
67
- $page['post_parent'] = 0;
68
- $page['post_author'] = $user_ID;
69
- $page['post_status'] = 'publish';
70
- $page['post_title'] = $pagename;
71
- $pageid = wp_insert_post ( $page );
72
- }
73
- }
74
- register_activation_hook( __FILE__, 'catapult_create_policy_page' );
75
-
76
- function catapult_cookie_admin_init(){
77
- register_setting( 'catapult_cookie_options', 'catapult_cookie_options', 'catapult_cookie_options_validate' );
78
- add_settings_section('catapult_cookie_main', '', 'catapult_cookie_section_text', 'catapult_cookie', 'catapult_cookie_main' );
79
- add_settings_field('catapult_cookie_text', __( 'Notification text', 'uk-cookie-consent' ), 'catapult_cookie_text_settings', 'catapult_cookie', 'catapult_cookie_main' );
80
- add_settings_field('catapult_cookie_accept', __( 'Accept text', 'uk-cookie-consent' ), 'catapult_cookie_accept_settings', 'catapult_cookie', 'catapult_cookie_main' );
81
- add_settings_field('catapult_cookie_more', __( 'More info text', 'uk-cookie-consent' ), 'catapult_cookie_more_settings', 'catapult_cookie', 'catapult_cookie_main' );
82
- add_settings_field('catapult_cookie_link', __( 'Info page permalink', 'uk-cookie-consent' ), 'catapult_cookie_link_settings', 'catapult_cookie', 'catapult_cookie_main' );
83
- add_settings_field('catapult_cookie_text_colour', __( 'Text colour', 'uk-cookie-consent' ), 'catapult_cookie_text_colour_settings', 'catapult_cookie', 'catapult_cookie_main' );
84
- add_settings_field('catapult_cookie_link_colour', __( 'Link colour', 'uk-cookie-consent' ), 'catapult_cookie_link_colour_settings', 'catapult_cookie', 'catapult_cookie_main' );
85
- add_settings_field('catapult_cookie_bg_colour', __( 'Bar colour', 'uk-cookie-consent' ), 'catapult_cookie_bg_colour_settings', 'catapult_cookie', 'catapult_cookie_main' );
86
- add_settings_field('catapult_cookie_button_colour', __( 'Button colour', 'uk-cookie-consent' ), 'catapult_cookie_button_colour_settings', 'catapult_cookie', 'catapult_cookie_main' );
87
- add_settings_field('catapult_cookie_bar_position', __( 'Notification position', 'uk-cookie-consent' ), 'catapult_cookie_bar_position_settings', 'catapult_cookie', 'catapult_cookie_main' );
88
- }
89
-
90
- function catapult_cookie_section_text() {
91
- echo '<p>' . __( 'You can just use these settings as they are or update the text as you wish. We recommend keeping it brief.', 'uk-cookie-consent' ) . '</p>
92
- <p>' . __( 'The plug-in automatically creates a page called "Cookie Policy" and sets the default More Info link to yoursitename.com/cookie-policy.', 'uk-cookie-consent' ) . '</p>
93
- <p>' . __( 'If you find the page hasn\'t been created, hit the Save Changes button on this page.', 'uk-cookie-consent' ) . '</p>
94
- <p>' . __( 'If you would like to change the permalink, just update the Info page permalink setting, e.g. enter "?page_id=4" if you are using the default permalink settings (and 4 is the id of your new Cookie Policy page).', 'uk-cookie-consent' ) . '</p>
95
- <p>' . sprintf( __( 'For any support queries, please post on the <a href="%s">WordPress forum</a>.', 'uk-cookie-consent' ), 'http://wordpress.org/extend/plugins/uk-cookie-consent/' ) . '</p>
96
- <p><strong>' . sprintf( __( 'And if this plug-in has been helpful to you, then <a href="%s">please rate it</a>.', 'uk-cookie-consent' ), 'http://wordpress.org/extend/plugins/uk-cookie-consent/' ) . '</strong></p>';
97
- }
98
-
99
- function catapult_cookie_text_settings() {
100
- $options = get_option( 'catapult_cookie_options' );
101
- $value = $options['catapult_cookie_text_settings'];
102
- if ( !$value ) {
103
- $value = __( 'This site uses cookies', 'uk-cookie-consent' );
104
- }
105
- echo '<input id="catapult_cookie_text_settings" name="catapult_cookie_options[catapult_cookie_text_settings]" size="50" type="text" value="' . esc_attr( $value ) . '" />';
106
- }
107
- function catapult_cookie_accept_settings() {
108
- $options = get_option('catapult_cookie_options');
109
- $value = $options['catapult_cookie_accept_settings'];
110
- if ( !$value ) {
111
- $value = __( 'No problem', 'uk-cookie-consent' );
112
- }
113
- echo '<input id="catapult_cookie_accept_settings" name="catapult_cookie_options[catapult_cookie_accept_settings]" size="50" type="text" value="' . esc_attr( $value ) . '" />';
114
- }
115
- function catapult_cookie_more_settings() {
116
- $options = get_option('catapult_cookie_options');
117
- $value = $options['catapult_cookie_more_settings'];
118
- if ( !$value ) {
119
- $value = __( 'More info', 'uk-cookie-consent' );
120
- }
121
- echo '<input id="catapult_cookie_more_settings" name="catapult_cookie_options[catapult_cookie_more_settings]" size="50" type="text" value="' . esc_attr( $value ) . '" />';
122
- }
123
- function catapult_cookie_link_settings() {
124
- $options = get_option('catapult_cookie_options');
125
- $value = $options['catapult_cookie_link_settings'];
126
- if ( !$value ) {
127
- $value = __( 'cookie-policy', 'uk-cookie-consent' );
128
- }
129
- echo '<input id="catapult_cookie_link_settings" name="catapult_cookie_options[catapult_cookie_link_settings]" size="50" type="text" value="' . esc_attr( $value ) . '" />';
130
- }
131
- function catapult_cookie_text_colour_settings() {
132
- $options = get_option('catapult_cookie_options');
133
- $value = $options['catapult_cookie_text_colour_settings'];
134
- if ( !$value ) {
135
- $value = '#dddddd';
136
- } ?>
137
- <input type="text" id="catapult_cookie_text_colour" name="catapult_cookie_options[catapult_cookie_text_colour_settings]" value="<?php echo $value; ?>" class="my-color-field" />
138
- <?php }
139
- function catapult_cookie_link_colour_settings() {
140
- $options = get_option('catapult_cookie_options');
141
- $value = $options['catapult_cookie_link_colour_settings'];
142
- if ( !$value ) {
143
- $value = '#dddddd';
144
- } ?>
145
- <input type="text" name="catapult_cookie_options[catapult_cookie_link_colour_settings]" value="<?php echo $value; ?>" class="my-color-field" />
146
- <?php }
147
- function catapult_cookie_bg_colour_settings() {
148
- $options = get_option('catapult_cookie_options');
149
- $value = $options['catapult_cookie_bg_colour_settings'];
150
- if ( !$value ) {
151
- $value = '#464646';
152
- } ?>
153
- <input type="text" name="catapult_cookie_options[catapult_cookie_bg_colour_settings]" value="<?php echo $value; ?>" class="my-color-field" />
154
- <?php }
155
- function catapult_cookie_button_colour_settings() {
156
- $options = get_option('catapult_cookie_options');
157
- $value = $options['catapult_cookie_button_colour_settings'];
158
- if ( !$value ) {
159
- $value = '#45AE52';
160
- } ?>
161
- <input type="text" name="catapult_cookie_options[catapult_cookie_button_colour_settings]" value="<?php echo $value; ?>" class="my-color-field" />
162
- <?php }
163
- function catapult_cookie_bar_position_settings() {
164
- $options = get_option('catapult_cookie_options');
165
- $value = $options['catapult_cookie_bar_position_settings'];
166
- if ( !$value ) {
167
- $value = 'top';
168
- } ?>
169
- <select id="catapult_cookie_bar_position_settings" name="catapult_cookie_options[catapult_cookie_bar_position_settings]" >';
170
- <option value="top" <?php if ( $value == 'top' ) { ?> selected="selected" <?php } ?>>Top</option>;
171
- <option value="bottom" <?php if ( $value == 'bottom' ) { ?> selected="selected" <?php } ?>>Bottom</option>;
172
- </select>
173
- <?php }
174
-
175
- function catapult_cookie_options_validate($input) {
176
- $options = get_option( 'catapult_cookie_options' );
177
- $options['catapult_cookie_text_settings'] = trim($input['catapult_cookie_text_settings']);
178
- $options['catapult_cookie_accept_settings'] = trim($input['catapult_cookie_accept_settings']);
179
- $options['catapult_cookie_more_settings'] = trim($input['catapult_cookie_more_settings']);
180
- $options['catapult_cookie_link_settings'] = trim($input['catapult_cookie_link_settings']);
181
- $options['catapult_cookie_text_colour_settings'] = trim($input['catapult_cookie_text_colour_settings']);
182
- $options['catapult_cookie_link_colour_settings'] = trim($input['catapult_cookie_link_colour_settings']);
183
- $options['catapult_cookie_bg_colour_settings'] = trim($input['catapult_cookie_bg_colour_settings']);
184
- $options['catapult_cookie_button_colour_settings'] = trim($input['catapult_cookie_button_colour_settings']);
185
- $options['catapult_cookie_bar_position_settings'] = trim($input['catapult_cookie_bar_position_settings']);
186
- return $options;
187
- }
188
- //Enqueue color-picker script for admin
189
- function catapult_color_picker() {
190
- wp_enqueue_style( 'wp-color-picker' );
191
- wp_enqueue_script( 'uk-cookie-consent-colour-picker', plugins_url ( 'js/colour-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
192
- }
193
- add_action( 'admin_enqueue_scripts', 'catapult_color_picker' );
194
-
195
-
196
- //Enqueue jquery
197
- function catapult_cookie_jquery() {
198
- wp_enqueue_script( 'jquery' );
199
- wp_enqueue_script( 'uk-cookie-consent-js', plugins_url ( 'js/uk-cookie-consent-js.js', __FILE__ ), array ( 'jquery' ) );
200
- }
201
- add_action('wp_enqueue_scripts', 'catapult_cookie_jquery');
202
-
203
-
204
- //Add CSS and JS
205
- //Add some JS to the header to test whether the cookie option has been set
206
- function catapult_add_cookie_css() {
207
- $options = get_option( 'catapult_cookie_options' );
208
- if ( $options['catapult_cookie_text_colour_settings'] ) {
209
- $text_colour = $options['catapult_cookie_text_colour_settings'];
210
- } else {
211
- $text_colour = "#ddd";
212
- }
213
- if ( $options['catapult_cookie_link_colour_settings'] ) {
214
- $link_colour = $options['catapult_cookie_link_colour_settings'];
215
- } else {
216
- $link_colour = "#fff;";
217
- }
218
- if ( $options['catapult_cookie_bg_colour_settings'] ) {
219
- $bg_colour = $options['catapult_cookie_bg_colour_settings'];
220
- } else {
221
- $bg_colour = "#464646";
222
- }
223
- if ( $options['catapult_cookie_button_colour_settings'] ) {
224
- $button_colour = $options['catapult_cookie_button_colour_settings'];
225
- } else {
226
- $button_colour = "#45AE52";
227
- }
228
- if ( $options['catapult_cookie_bar_position_settings'] ) {
229
- $position = $options['catapult_cookie_bar_position_settings'];
230
- } else {
231
- $position = "top";
232
- }
233
- echo '
234
- <style type="text/css" media="screen">
235
- #catapult-cookie-bar {
236
- display: none;
237
- direction: ltr;
238
- color: ' . $text_colour . ';
239
- min-height: 30px;
240
- position: fixed;
241
- left: 0;
242
- ' . $position . ': 0;
243
- width: 100%;
244
- z-index: 99999;
245
- padding:6px 20px 4px;
246
- background-color: ' . $bg_colour . ';
247
- text-align:left;
248
- }
249
- #catapult-cookie-bar a {
250
- color: ' . $link_colour . ';
251
- }
252
- button#catapultCookie {
253
- margin:0 20px;
254
- line-height:20px;
255
- background:' . $button_colour . ';
256
- border:none;
257
- color: ' . $link_colour . ';
258
- padding:4px 12px;
259
- border-radius: 3px;
260
- cursor: pointer;
261
- font-size: 13px;
262
- font-weight: bold;
263
- }
264
- </style>';
265
- }
266
- add_action ( 'wp_head', 'catapult_add_cookie_css' );
267
-
268
- function catapult_add_cookie_js() { ?>
269
- <script type="text/javascript">
270
- jQuery(document).ready(function(){
271
- if(!catapultReadCookie("catAccCookies")){//If the cookie has been set
272
- jQuery("#catapult-cookie-bar").show();
273
- jQuery("html").css("margin-top","0");
274
- }
275
- });
276
- </script>
277
- <?php }
278
- add_action ( 'wp_head', 'catapult_add_cookie_js' );
279
-
280
- //Add the notification bar
281
- function catapult_add_cookie_bar() {
282
- $options = get_option('catapult_cookie_options');
283
- if ( $options['catapult_cookie_text_settings'] ) {
284
- $current_text = $options['catapult_cookie_text_settings'];
285
- } else {
286
- $current_text = "This site uses cookies";
287
- }
288
- if ( $options['catapult_cookie_accept_settings'] ) {
289
- $accept_text = $options['catapult_cookie_accept_settings'];
290
- } else {
291
- $accept_text = "Okay, thanks";
292
- }
293
- if ( $options['catapult_cookie_more_settings'] ) {
294
- $more_text = $options['catapult_cookie_more_settings'];
295
- } else {
296
- $more_text = "Find out more";
297
- }
298
- if ( $options['catapult_cookie_link_settings'] ) {
299
- $link_text = strtolower ( $options['catapult_cookie_link_settings'] );
300
- } else {
301
- $link_text = "cookie-policy";
302
- }
303
- $content = sprintf( '<div id="catapult-cookie-bar">%s<button id="catapultCookie" tabindex=1 onclick="catapultAcceptCookies();">%s</button><a tabindex=1 href="%s">%s</a></div>', htmlspecialchars( $current_text ), htmlspecialchars( $accept_text ), home_url( $link_text ), htmlspecialchars( $more_text ) );
304
- echo apply_filters( 'catapult_cookie_content', $content, $options );
305
- }
306
  add_action ( 'wp_footer', 'catapult_add_cookie_bar', 1000 );
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.6
8
+ Author URI: http://catapultdesign.co.uk/
9
+ */
10
+
11
+ // Language
12
+ load_plugin_textdomain( 'uk-cookie-consent', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
13
+
14
+ //Add an option page for the settings
15
+ add_action('admin_menu', 'catapult_cookie_plugin_menu');
16
+ function catapult_cookie_plugin_menu() {
17
+ add_options_page( __( 'Cookie Consent', 'uk-cookie-consent' ), __( 'Cookie Consent', 'uk-cookie-consent' ), 'manage_options', 'catapult_cookie_consent', 'catapult_cookie_options_page' );
18
+ }
19
+
20
+ function catapult_cookie_options_page() { ?>
21
+ <div class="wrap">
22
+ <h2><?php _e( 'UK Cookie Consent', 'uk-cookie-consent' ); ?></h2>
23
+ <div id="poststuff" class="metabox-holder has-right-sidebar">
24
+ <div class="meta-box-sortabless">
25
+ <div class="postbox">
26
+ <h3 class="hndle"><?php _e( 'Your settings', 'uk-cookie-consent' ); ?></h3>
27
+ <div class="inside">
28
+ <form action="options.php" method="post">
29
+ <?php settings_fields('catapult_cookie_options'); ?>
30
+ <?php do_settings_sections('catapult_cookie'); ?>
31
+ <input name="cat_submit" type="submit" id="submit" class="button-primary" style="margin-top:30px;" value="<?php esc_attr_e( __( 'Save Changes', 'uk-cookie-consent' ) ); ?>" />
32
+ <?php $options = get_option('catapult_cookie_options');
33
+ $value = htmlentities ( $options['catapult_cookie_link_settings'], ENT_QUOTES );
34
+ if ( !$value ) {
35
+ $value = 'cookie-policy';
36
+ } ?>
37
+ <p><?php echo sprintf( __( 'Your Cookies Policy page is <a href="%s">here</a>. You may wish to create a menu item or other link on your site to this page.', 'uk-cookie-consent' ), home_url( $value ) ); ?></p>
38
+ </form>
39
+ </div>
40
+ </div>
41
+ </div>
42
+ <div class="meta-box-sortabless ui-sortable" style="position:relative;">
43
+ <div class="postbox">
44
+ <h3 class="hndle"><?php _e( 'Resources', 'uk-cookie-consent' ); ?></h3>
45
+ <div class="inside">
46
+ <p><a href="http://www.ico.gov.uk/for_organisations/privacy_and_electronic_communications/the_guide/cookies.aspx"><?php _e( 'Information Commissioner\'s Office Guidance on Cookies', 'uk-cookie-consent' ); ?></a></p>
47
+ <p><a href="http://www.aboutcookies.org/default.aspx">AboutCookies.org</a></p>
48
+ <p><a href="http://catapultdesign.co.uk/uk-cookie-consent/"><?php _e( 'Our interpretation of the guidance', 'uk-cookie-consent' ); ?></a></p>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </div><!-- poststuff -->
53
+ </div>
54
+ <?php }
55
+
56
+ add_action('admin_init', 'catapult_cookie_admin_init');
57
+
58
+ function catapult_create_policy_page() {
59
+ //Check to see if the info page has been created
60
+ $options = get_option('catapult_cookie_options');
61
+ $pagename = __( 'Cookie Policy', 'uk-cookie-consent' );
62
+ $cpage = get_page_by_title ( $pagename );
63
+ if ( !$cpage ) {
64
+ global $user_ID;
65
+ $page['post_type'] = 'page';
66
+ $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. 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', 'uk-cookie-consent' ) . '</p>';
67
+ $page['post_parent'] = 0;
68
+ $page['post_author'] = $user_ID;
69
+ $page['post_status'] = 'publish';
70
+ $page['post_title'] = $pagename;
71
+ $pageid = wp_insert_post ( $page );
72
+ }
73
+ }
74
+ register_activation_hook( __FILE__, 'catapult_create_policy_page' );
75
+
76
+ function catapult_cookie_admin_init(){
77
+ register_setting( 'catapult_cookie_options', 'catapult_cookie_options', 'catapult_cookie_options_validate' );
78
+ add_settings_section('catapult_cookie_main', '', 'catapult_cookie_section_text', 'catapult_cookie', 'catapult_cookie_main' );
79
+ add_settings_field('catapult_cookie_text', __( 'Notification text', 'uk-cookie-consent' ), 'catapult_cookie_text_settings', 'catapult_cookie', 'catapult_cookie_main' );
80
+ add_settings_field('catapult_cookie_accept', __( 'Accept text', 'uk-cookie-consent' ), 'catapult_cookie_accept_settings', 'catapult_cookie', 'catapult_cookie_main' );
81
+ add_settings_field('catapult_cookie_more', __( 'More info text', 'uk-cookie-consent' ), 'catapult_cookie_more_settings', 'catapult_cookie', 'catapult_cookie_main' );
82
+ add_settings_field('catapult_cookie_link', __( 'Info page permalink', 'uk-cookie-consent' ), 'catapult_cookie_link_settings', 'catapult_cookie', 'catapult_cookie_main' );
83
+ add_settings_field('catapult_cookie_text_colour', __( 'Text colour', 'uk-cookie-consent' ), 'catapult_cookie_text_colour_settings', 'catapult_cookie', 'catapult_cookie_main' );
84
+ add_settings_field('catapult_cookie_link_colour', __( 'Link colour', 'uk-cookie-consent' ), 'catapult_cookie_link_colour_settings', 'catapult_cookie', 'catapult_cookie_main' );
85
+ add_settings_field('catapult_cookie_bg_colour', __( 'Bar colour', 'uk-cookie-consent' ), 'catapult_cookie_bg_colour_settings', 'catapult_cookie', 'catapult_cookie_main' );
86
+ add_settings_field('catapult_cookie_button_colour', __( 'Button colour', 'uk-cookie-consent' ), 'catapult_cookie_button_colour_settings', 'catapult_cookie', 'catapult_cookie_main' );
87
+ add_settings_field('catapult_cookie_bar_position', __( 'Notification position', 'uk-cookie-consent' ), 'catapult_cookie_bar_position_settings', 'catapult_cookie', 'catapult_cookie_main' );
88
+ }
89
+
90
+ function catapult_cookie_section_text() {
91
+ echo '<p>' . __( 'You can just use these settings as they are or update the text as you wish. We recommend keeping it brief.', 'uk-cookie-consent' ) . '</p>
92
+ <p>' . __( 'The plug-in automatically creates a page called "Cookie Policy" and sets the default More Info link to yoursitename.com/cookie-policy.', 'uk-cookie-consent' ) . '</p>
93
+ <p>' . __( 'If you find the page hasn\'t been created, hit the Save Changes button on this page.', 'uk-cookie-consent' ) . '</p>
94
+ <p>' . __( 'If you would like to change the permalink, just update the Info page permalink setting, e.g. enter "?page_id=4" if you are using the default permalink settings (and 4 is the id of your new Cookie Policy page).', 'uk-cookie-consent' ) . '</p>
95
+ <p>' . sprintf( __( 'For any support queries, please post on the <a href="%s">WordPress forum</a>.', 'uk-cookie-consent' ), 'http://wordpress.org/extend/plugins/uk-cookie-consent/' ) . '</p>
96
+ <p><strong>' . sprintf( __( 'And if this plug-in has been helpful to you, then <a href="%s">please rate it</a>.', 'uk-cookie-consent' ), 'http://wordpress.org/extend/plugins/uk-cookie-consent/' ) . '</strong></p>';
97
+ }
98
+
99
+ function catapult_cookie_text_settings() {
100
+ $options = get_option( 'catapult_cookie_options' );
101
+ $value = $options['catapult_cookie_text_settings'];
102
+ if ( !$value ) {
103
+ $value = __( 'This site uses cookies', 'uk-cookie-consent' );
104
+ }
105
+ echo '<input id="catapult_cookie_text_settings" name="catapult_cookie_options[catapult_cookie_text_settings]" size="50" type="text" value="' . esc_attr( $value ) . '" />';
106
+ }
107
+ function catapult_cookie_accept_settings() {
108
+ $options = get_option('catapult_cookie_options');
109
+ $value = $options['catapult_cookie_accept_settings'];
110
+ if ( !$value ) {
111
+ $value = __( 'No problem', 'uk-cookie-consent' );
112
+ }
113
+ echo '<input id="catapult_cookie_accept_settings" name="catapult_cookie_options[catapult_cookie_accept_settings]" size="50" type="text" value="' . esc_attr( $value ) . '" />';
114
+ }
115
+ function catapult_cookie_more_settings() {
116
+ $options = get_option('catapult_cookie_options');
117
+ $value = $options['catapult_cookie_more_settings'];
118
+ if ( !$value ) {
119
+ $value = __( 'More info', 'uk-cookie-consent' );
120
+ }
121
+ echo '<input id="catapult_cookie_more_settings" name="catapult_cookie_options[catapult_cookie_more_settings]" size="50" type="text" value="' . esc_attr( $value ) . '" />';
122
+ }
123
+ function catapult_cookie_link_settings() {
124
+ $options = get_option('catapult_cookie_options');
125
+ $value = $options['catapult_cookie_link_settings'];
126
+ if ( !$value ) {
127
+ $value = __( 'cookie-policy', 'uk-cookie-consent' );
128
+ }
129
+ echo '<input id="catapult_cookie_link_settings" name="catapult_cookie_options[catapult_cookie_link_settings]" size="50" type="text" value="' . esc_attr( $value ) . '" />';
130
+ }
131
+ function catapult_cookie_text_colour_settings() {
132
+ $options = get_option('catapult_cookie_options');
133
+ $value = $options['catapult_cookie_text_colour_settings'];
134
+ if ( !$value ) {
135
+ $value = '#dddddd';
136
+ } ?>
137
+ <input type="text" id="catapult_cookie_text_colour" name="catapult_cookie_options[catapult_cookie_text_colour_settings]" value="<?php echo $value; ?>" class="my-color-field" />
138
+ <?php }
139
+ function catapult_cookie_link_colour_settings() {
140
+ $options = get_option('catapult_cookie_options');
141
+ $value = $options['catapult_cookie_link_colour_settings'];
142
+ if ( !$value ) {
143
+ $value = '#dddddd';
144
+ } ?>
145
+ <input type="text" name="catapult_cookie_options[catapult_cookie_link_colour_settings]" value="<?php echo $value; ?>" class="my-color-field" />
146
+ <?php }
147
+ function catapult_cookie_bg_colour_settings() {
148
+ $options = get_option('catapult_cookie_options');
149
+ $value = $options['catapult_cookie_bg_colour_settings'];
150
+ if ( !$value ) {
151
+ $value = '#464646';
152
+ } ?>
153
+ <input type="text" name="catapult_cookie_options[catapult_cookie_bg_colour_settings]" value="<?php echo $value; ?>" class="my-color-field" />
154
+ <?php }
155
+ function catapult_cookie_button_colour_settings() {
156
+ $options = get_option('catapult_cookie_options');
157
+ $value = $options['catapult_cookie_button_colour_settings'];
158
+ if ( !$value ) {
159
+ $value = '#45AE52';
160
+ } ?>
161
+ <input type="text" name="catapult_cookie_options[catapult_cookie_button_colour_settings]" value="<?php echo $value; ?>" class="my-color-field" />
162
+ <?php }
163
+ function catapult_cookie_bar_position_settings() {
164
+ $options = get_option('catapult_cookie_options');
165
+ $value = $options['catapult_cookie_bar_position_settings'];
166
+ if ( !$value ) {
167
+ $value = 'top';
168
+ } ?>
169
+ <select id="catapult_cookie_bar_position_settings" name="catapult_cookie_options[catapult_cookie_bar_position_settings]" >';
170
+ <option value="top" <?php if ( $value == 'top' ) { ?> selected="selected" <?php } ?>>Top</option>;
171
+ <option value="bottom" <?php if ( $value == 'bottom' ) { ?> selected="selected" <?php } ?>>Bottom</option>;
172
+ </select>
173
+ <?php }
174
+
175
+ function catapult_cookie_options_validate($input) {
176
+ $options = get_option( 'catapult_cookie_options' );
177
+ $options['catapult_cookie_text_settings'] = trim($input['catapult_cookie_text_settings']);
178
+ $options['catapult_cookie_accept_settings'] = trim($input['catapult_cookie_accept_settings']);
179
+ $options['catapult_cookie_more_settings'] = trim($input['catapult_cookie_more_settings']);
180
+ $options['catapult_cookie_link_settings'] = trim($input['catapult_cookie_link_settings']);
181
+ $options['catapult_cookie_text_colour_settings'] = trim($input['catapult_cookie_text_colour_settings']);
182
+ $options['catapult_cookie_link_colour_settings'] = trim($input['catapult_cookie_link_colour_settings']);
183
+ $options['catapult_cookie_bg_colour_settings'] = trim($input['catapult_cookie_bg_colour_settings']);
184
+ $options['catapult_cookie_button_colour_settings'] = trim($input['catapult_cookie_button_colour_settings']);
185
+ $options['catapult_cookie_bar_position_settings'] = trim($input['catapult_cookie_bar_position_settings']);
186
+ return $options;
187
+ }
188
+ //Enqueue color-picker script for admin
189
+ function catapult_color_picker() {
190
+ wp_enqueue_style( 'wp-color-picker' );
191
+ wp_enqueue_script( 'uk-cookie-consent-colour-picker', plugins_url ( 'js/colour-picker.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
192
+ }
193
+ add_action( 'admin_enqueue_scripts', 'catapult_color_picker' );
194
+
195
+
196
+ //Enqueue jquery
197
+ function catapult_cookie_jquery() {
198
+ wp_enqueue_script( 'jquery' );
199
+ wp_enqueue_script( 'uk-cookie-consent-js', plugins_url ( 'js/uk-cookie-consent-js.js', __FILE__ ), array ( 'jquery' ) );
200
+ }
201
+ add_action('wp_enqueue_scripts', 'catapult_cookie_jquery');
202
+
203
+
204
+ //Add CSS and JS
205
+ //Add some JS to the header to test whether the cookie option has been set
206
+ function catapult_add_cookie_css() {
207
+ $options = get_option( 'catapult_cookie_options' );
208
+ if ( $options['catapult_cookie_text_colour_settings'] ) {
209
+ $text_colour = $options['catapult_cookie_text_colour_settings'];
210
+ } else {
211
+ $text_colour = "#ddd";
212
+ }
213
+ if ( $options['catapult_cookie_link_colour_settings'] ) {
214
+ $link_colour = $options['catapult_cookie_link_colour_settings'];
215
+ } else {
216
+ $link_colour = "#fff;";
217
+ }
218
+ if ( $options['catapult_cookie_bg_colour_settings'] ) {
219
+ $bg_colour = $options['catapult_cookie_bg_colour_settings'];
220
+ } else {
221
+ $bg_colour = "#464646";
222
+ }
223
+ if ( $options['catapult_cookie_button_colour_settings'] ) {
224
+ $button_colour = $options['catapult_cookie_button_colour_settings'];
225
+ } else {
226
+ $button_colour = "#45AE52";
227
+ }
228
+ if ( $options['catapult_cookie_bar_position_settings'] ) {
229
+ $position = $options['catapult_cookie_bar_position_settings'];
230
+ } else {
231
+ $position = "top";
232
+ }
233
+ echo '
234
+ <style type="text/css" media="screen">
235
+ #catapult-cookie-bar {
236
+ display: none;
237
+ direction: ltr;
238
+ color: ' . $text_colour . ';
239
+ min-height: 30px;
240
+ position: fixed;
241
+ left: 0;
242
+ ' . $position . ': 0;
243
+ width: 100%;
244
+ z-index: 99999;
245
+ padding:6px 20px 4px;
246
+ background-color: ' . $bg_colour . ';
247
+ text-align:left;
248
+ }
249
+ #catapult-cookie-bar a {
250
+ color: ' . $link_colour . ';
251
+ }
252
+ button#catapultCookie {
253
+ margin:0 20px;
254
+ line-height:20px;
255
+ background:' . $button_colour . ';
256
+ border:none;
257
+ color: ' . $link_colour . ';
258
+ padding:4px 12px;
259
+ border-radius: 3px;
260
+ cursor: pointer;
261
+ font-size: 13px;
262
+ font-weight: bold;
263
+ }
264
+ </style>';
265
+ }
266
+ add_action ( 'wp_head', 'catapult_add_cookie_css' );
267
+
268
+ function catapult_add_cookie_js() { ?>
269
+ <script type="text/javascript">
270
+ jQuery(document).ready(function(){
271
+ if(!catapultReadCookie("catAccCookies")){//If the cookie has not been set
272
+ jQuery("#catapult-cookie-bar").show();
273
+ jQuery("html").css("margin-top","0");
274
+ }
275
+ });
276
+ </script>
277
+ <?php }
278
+ add_action ( 'wp_footer', 'catapult_add_cookie_js' );
279
+
280
+ //Add the notification bar
281
+ function catapult_add_cookie_bar() {
282
+ $options = get_option('catapult_cookie_options');
283
+ if ( $options['catapult_cookie_text_settings'] ) {
284
+ $current_text = $options['catapult_cookie_text_settings'];
285
+ } else {
286
+ $current_text = "This site uses cookies";
287
+ }
288
+ if ( $options['catapult_cookie_accept_settings'] ) {
289
+ $accept_text = $options['catapult_cookie_accept_settings'];
290
+ } else {
291
+ $accept_text = "Okay, thanks";
292
+ }
293
+ if ( $options['catapult_cookie_more_settings'] ) {
294
+ $more_text = $options['catapult_cookie_more_settings'];
295
+ } else {
296
+ $more_text = "Find out more";
297
+ }
298
+ if ( $options['catapult_cookie_link_settings'] ) {
299
+ $link_text = strtolower ( $options['catapult_cookie_link_settings'] );
300
+ } else {
301
+ $link_text = "cookie-policy";
302
+ }
303
+ $content = sprintf( '<div id="catapult-cookie-bar">%s<button id="catapultCookie" tabindex=1 onclick="catapultAcceptCookies();">%s</button><a tabindex=1 href="%s">%s</a></div>', htmlspecialchars( $current_text ), htmlspecialchars( $accept_text ), home_url( $link_text ), htmlspecialchars( $more_text ) );
304
+ echo apply_filters( 'catapult_cookie_content', $content, $options );
305
+ }
306
  add_action ( 'wp_footer', 'catapult_add_cookie_bar', 1000 );