Cookiebot | GDPR Compliant Cookie Consent and Notice - Version 2.4.2

Version Description

Download this release

Release Info

Developer cookiebot
Plugin Icon 128x128 Cookiebot | GDPR Compliant Cookie Consent and Notice
Version 2.4.2
Comparing to
See all releases

Code changes from version 2.4.1 to 2.4.2

addons/addons.json CHANGED
@@ -67,5 +67,8 @@
67
  },
68
  "Gadwp": {
69
  "class": "cookiebot_addons\\controller\\addons\\gadwp\\Gadwp"
 
 
 
70
  }
71
  }
67
  },
68
  "Gadwp": {
69
  "class": "cookiebot_addons\\controller\\addons\\gadwp\\Gadwp"
70
+ },
71
+ "Addthis": {
72
+ "class": "cookiebot_addons\\controller\\addons\\addthis\\Addthis"
73
  }
74
  }
addons/controller/addons/addthis/addthis.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace cookiebot_addons\controller\addons\addthis;
4
+
5
+ use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6
+ use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7
+ use cookiebot_addons\lib\Cookie_Consent_Interface;
8
+ use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9
+ use cookiebot_addons\lib\Settings_Service_Interface;
10
+
11
+ class Addthis implements Cookiebot_Addons_Interface {
12
+
13
+ /**
14
+ * @var Settings_Service_Interface
15
+ *
16
+ * @since 1.3.0
17
+ */
18
+ protected $settings;
19
+
20
+ /**
21
+ * @var Script_Loader_Tag_Interface
22
+ *
23
+ * @since 1.3.0
24
+ */
25
+ protected $script_loader_tag;
26
+
27
+ /**
28
+ * @var Cookie_Consent_Interface
29
+ *
30
+ * @since 1.3.0
31
+ */
32
+ public $cookie_consent;
33
+
34
+ /**
35
+ * @var Buffer_Output_Interface
36
+ *
37
+ * @since 1.3.0
38
+ */
39
+ protected $buffer_output;
40
+
41
+ /**
42
+ * Jetpack constructor.
43
+ *
44
+ * @param $settings Settings_Service_Interface
45
+ * @param $script_loader_tag Script_Loader_Tag_Interface
46
+ * @param $cookie_consent Cookie_Consent_Interface
47
+ * @param $buffer_output Buffer_Output_Interface
48
+ *
49
+ * @since 1.3.0
50
+ */
51
+ public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
52
+ $this->settings = $settings;
53
+ $this->script_loader_tag = $script_loader_tag;
54
+ $this->cookie_consent = $cookie_consent;
55
+ $this->buffer_output = $buffer_output;
56
+ }
57
+
58
+ /**
59
+ * Loads addon configuration
60
+ *
61
+ * @since 1.3.0
62
+ */
63
+ public function load_configuration() {
64
+ /**
65
+ * We add the action after wp_loaded and replace the original
66
+ * Addthis script action with our own adjusted version.
67
+ */
68
+ add_action( 'wp_loaded', array( $this, 'cookiebot_addon_addthis' ), 10 );
69
+ }
70
+
71
+ /**
72
+ * Manipulate the scripts if they are loaded.
73
+ *
74
+ * @since 1.3.0
75
+ */
76
+ public function cookiebot_addon_addthis() {
77
+
78
+ // block the script untill the consent is given
79
+ $this->script_loader_tag->add_tag( 'addthis_widget', $this->get_cookie_types() );
80
+
81
+ $this->buffer_output->add_tag( 'wp_footer', 19, array(
82
+ 'addthis_product' => $this->get_cookie_types(),
83
+ ), false );
84
+ $this->buffer_output->add_tag( 'wp_head', 19, array(
85
+ 'addthis_product ' => $this->get_cookie_types(),
86
+ ), false );
87
+ }
88
+
89
+ /**
90
+ * Return addon/plugin name
91
+ *
92
+ * @return string
93
+ *
94
+ * @since 1.3.0
95
+ */
96
+ public function get_addon_name() {
97
+ return 'WordPress Share Buttons Plugin – AddThis';
98
+ }
99
+
100
+ /**
101
+ * Option name in the database
102
+ *
103
+ * @return string
104
+ *
105
+ * @since 1.3.0
106
+ */
107
+ public function get_option_name() {
108
+ return 'addthis';
109
+ }
110
+
111
+ /**
112
+ * Plugin file name
113
+ *
114
+ * @return string
115
+ *
116
+ * @since 1.3.0
117
+ */
118
+ public function get_plugin_file() {
119
+ return 'addthis/addthis_social_widget.php';
120
+ }
121
+
122
+ /**
123
+ * Returns checked cookie types
124
+ * @return mixed
125
+ *
126
+ * @since 1.3.0
127
+ */
128
+ public function get_cookie_types() {
129
+ return $this->settings->get_cookie_types( $this->get_option_name() );
130
+ }
131
+
132
+ /**
133
+ * Returns default cookie types
134
+ * @return array
135
+ *
136
+ * @since 1.5.0
137
+ */
138
+ public function get_default_cookie_types() {
139
+ return array( 'marketing', 'statistics' );
140
+ }
141
+
142
+
143
+ /**
144
+ * Check if plugin is activated and checked in the backend
145
+ *
146
+ * @since 1.3.0
147
+ */
148
+ public function is_addon_enabled() {
149
+ return $this->settings->is_addon_enabled( $this->get_option_name() );
150
+ }
151
+
152
+ /**
153
+ * Checks if addon is installed
154
+ *
155
+ * @since 1.3.0
156
+ */
157
+ public function is_addon_installed() {
158
+ return $this->settings->is_addon_installed( $this->get_plugin_file() );
159
+ }
160
+
161
+ /**
162
+ * Checks if addon is activated
163
+ *
164
+ * @since 1.3.0
165
+ */
166
+ public function is_addon_activated() {
167
+ return $this->settings->is_addon_activated( $this->get_plugin_file() );
168
+ }
169
+
170
+ /**
171
+ * Retrieves current installed version of the addon
172
+ *
173
+ * @return bool
174
+ *
175
+ * @since 2.2.1
176
+ */
177
+ public function get_addon_version() {
178
+ return $this->settings->get_addon_version( $this->get_plugin_file() );
179
+ }
180
+
181
+ /**
182
+ * Default placeholder content
183
+ *
184
+ * @return string
185
+ *
186
+ * @since 1.8.0
187
+ */
188
+ public function get_default_placeholder() {
189
+ return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to view this element.';
190
+ }
191
+
192
+ /**
193
+ * Get placeholder content
194
+ *
195
+ * This function will check following features:
196
+ * - Current language
197
+ *
198
+ * @param $src
199
+ *
200
+ * @return bool|mixed
201
+ *
202
+ * @since 1.8.0
203
+ */
204
+ public function get_placeholder( $src = '' ) {
205
+ return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
206
+ }
207
+
208
+ /**
209
+ * Checks if it does have custom placeholder content
210
+ *
211
+ * @return mixed
212
+ *
213
+ * @since 1.8.0
214
+ */
215
+ public function has_placeholder() {
216
+ return $this->settings->has_placeholder( $this->get_option_name() );
217
+ }
218
+
219
+ /**
220
+ * returns all placeholder contents
221
+ *
222
+ * @return mixed
223
+ *
224
+ * @since 1.8.0
225
+ */
226
+ public function get_placeholders() {
227
+ return $this->settings->get_placeholders( $this->get_option_name() );
228
+ }
229
+
230
+ /**
231
+ * Return true if the placeholder is enabled
232
+ *
233
+ * @return mixed
234
+ *
235
+ * @since 1.8.0
236
+ */
237
+ public function is_placeholder_enabled() {
238
+ return $this->settings->is_placeholder_enabled( $this->get_option_name() );
239
+ }
240
+
241
+ /**
242
+ * Adds extra information under the label
243
+ *
244
+ * @return string
245
+ *
246
+ * @since 1.8.0
247
+ */
248
+ public function get_extra_information() {
249
+ return false;
250
+ }
251
+
252
+ /**
253
+ * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
254
+ *
255
+ * @return boolean
256
+ *
257
+ * @since 1.8.0
258
+ */
259
+ public function get_svn_url() {
260
+ return 'https://plugins.svn.wordpress.org/addthis/trunk/addthis_social_widget.php';
261
+ }
262
+
263
+ /**
264
+ * Placeholder helper overlay in the settings page.
265
+ *
266
+ * @return string
267
+ *
268
+ * @since 1.8.0
269
+ */
270
+ public function get_placeholder_helper() {
271
+ return '<p>Merge tags you can use in the placeholder text:</p><ul><li>%cookie_types - Lists required cookie types</li><li>[renew_consent]text[/renew_consent] - link to display cookie settings in frontend</li></ul>';
272
+ }
273
+
274
+ /**
275
+ * Returns parent class or false
276
+ *
277
+ * @return string|bool
278
+ *
279
+ * @since 2.1.3
280
+ */
281
+ public function get_parent_class() {
282
+ return get_parent_class( $this );
283
+ }
284
+
285
+ /**
286
+ * Action after enabling the addon on the settings page
287
+ *
288
+ * @since 2.2.0
289
+ */
290
+ public function post_hook_after_enabling() {
291
+ //do nothing
292
+ }
293
+
294
+ /**
295
+ * Cookiebot plugin is deactivated
296
+ *
297
+ * @since 2.2.0
298
+ */
299
+ public function plugin_deactivated() {
300
+ //do nothing
301
+ }
302
+ }
addons/controller/addons/custom-facebook-feed/custom-facebook-feed.php CHANGED
@@ -75,7 +75,6 @@ class Custom_Facebook_Feed implements Cookiebot_Addons_Interface {
75
  */
76
  public function cookiebot_addon_custom_facebook_feed() {
77
 
78
- //Remove cff_js action and replace it with our own
79
  if ( has_action( 'wp_footer', 'cff_js' ) ) {
80
  /**
81
  * Consent not given - no cache
75
  */
76
  public function cookiebot_addon_custom_facebook_feed() {
77
 
 
78
  if ( has_action( 'wp_footer', 'cff_js' ) ) {
79
  /**
80
  * Consent not given - no cache
addons/controller/addons/embed-autocorrect/embed-autocorrect.php CHANGED
@@ -166,10 +166,10 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
166
  }
167
  unset( $matches );
168
 
169
- preg_match_all( '|<blockquote[^>]*class=\"twitter-tweet\"[^>]*>.*?</script></p>|si', $content, $matches );
170
  foreach ( $matches[0] as $match ) {
171
  //Find src.
172
- preg_match( '|<a href=\"([^\"]*)\">([^<]*)</a></p></blockquote>|', $match, $matchSrc );
173
  $src = $matchSrc[1];
174
 
175
  //Replace - and add cookie consent notice.
@@ -196,24 +196,25 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
196
  unset( $matches );
197
 
198
 
199
- //Match all youtube, vimeo and facebook iframes.
200
- preg_match_all( '/<iframe[^>]* src=("|\')[^("|\')](facebook\.com|youtu\.be|youtube\.com|youtube-nocookie\.com|player\.vimeo\.com)*[^>]*>.*?<\/iframe>/mi', $content, $matches );
 
201
 
202
  foreach ( $matches[0] as $x=>$match ) {
203
- /**
204
- * Get the source attribute value
205
- */
206
  $start = strpos( $match, ' src=' ) + 6;
207
  $end = strpos( $match, $matches[1][$x], $start );
208
  $src = substr( $match, $start, $end - $start );
209
 
 
 
 
 
210
 
211
- //Replace - and add cookie consent notice.
212
  $adjusted = str_replace( ' src=', ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=', $match );
213
 
214
- /**
215
- * Generate placeholder
216
- */
217
  $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
218
 
219
  /**
@@ -229,7 +230,27 @@ class Embed_Autocorrect implements Cookiebot_Addons_Interface {
229
  $content = str_replace( $match, $adjusted, $content );
230
  }
231
 
232
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
233
 
234
 
235
 
166
  }
167
  unset( $matches );
168
 
169
+ preg_match_all( '|<blockquote[^>]*class=\"twitter-tweet\"[^>]*>.*?</script>|si', $content, $matches );
170
  foreach ( $matches[0] as $match ) {
171
  //Find src.
172
+ preg_match( '|<a href=\"([^\"]*)\">([^<]*)</a></blockquote>|', $match, $matchSrc );
173
  $src = $matchSrc[1];
174
 
175
  //Replace - and add cookie consent notice.
196
  unset( $matches );
197
 
198
 
199
+ //Match all speakerdeck, slideshare, screencast, reverbnation, mixcloud, kickstarter,
200
+ // dailymoition, collegehumor, cloudup, animoto, videopress, youtube, vimeo and facebook iframes.
201
+ preg_match_all( '/<iframe[^>]* src=("|\')[^("|\')]*(facebook\.com|youtu\.be|youtube\.com|youtube-nocookie\.com|player\.vimeo\.com)*[^>]*>.*?<\/iframe>/mi', $content, $matches );
202
 
203
  foreach ( $matches[0] as $x=>$match ) {
204
+ /** Get the source attribute value */
 
 
205
  $start = strpos( $match, ' src=' ) + 6;
206
  $end = strpos( $match, $matches[1][$x], $start );
207
  $src = substr( $match, $start, $end - $start );
208
 
209
+ /** Skip the matched iframe if the data-cookieconsent attribute exists */
210
+ if( strpos($match, 'data-cookieconsent') !== false ) {
211
+ continue;
212
+ }
213
 
214
+ /** Replace - and add cookie consent notice. */
215
  $adjusted = str_replace( ' src=', ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=', $match );
216
 
217
+ /** Generate placeholder */
 
 
218
  $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
219
 
220
  /**
230
  $content = str_replace( $match, $adjusted, $content );
231
  }
232
 
233
+ unset( $matches );
234
+ preg_match_all( '/<script.*(instagram|issuu|imgur|polldaddy|tumblr)+.*<\/script>/mi', $content, $matches );
235
+ foreach ( $matches[0] as $x => $match ) {
236
+ //Replace - and add cookie consent notice.
237
+ $adjusted = str_replace( ' src=', ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=', $match );
238
+ /**
239
+ * Generate placeholder
240
+ */
241
+ $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
242
+ /**
243
+ * Modify placeholder by Filter
244
+ *
245
+ * @param $placeholder string Current placeholder text
246
+ * @param $src string Source attribute from the embedded video
247
+ * @param $this array Array of required cookie types
248
+ */
249
+ $placeholder = apply_filters( 'cookiebot_addons_embed_placeholder', $placeholder, $src, $this->get_cookie_types() );
250
+ $adjusted .= $placeholder;
251
+ $content = str_replace( $match, $adjusted, $content );
252
+ }
253
+ unset( $matches );
254
 
255
 
256
 
addons/controller/addons/wp-analytify/wp-analytify.php CHANGED
@@ -70,8 +70,9 @@ class Wp_Analytify implements Cookiebot_Addons_Interface {
70
  * @since 1.5.0
71
  */
72
  public function cookiebot_addon_analytify() {
73
- // Disable Analytify if cookie consent not allowed
74
- cookiebot_addons_remove_class_action( 'wp_head', 'WP_Analytify', 'analytify_add_analytics_code' );
 
75
  }
76
 
77
  /**
70
  * @since 1.5.0
71
  */
72
  public function cookiebot_addon_analytify() {
73
+ $this->buffer_output->add_tag( 'wp_head', 10, array(
74
+ 'GoogleAnalyticsObject' => $this->get_cookie_types()
75
+ ), false );
76
  }
77
 
78
  /**
addons/controller/addons/wpforms/wpforms.php CHANGED
@@ -78,7 +78,9 @@ class Wpforms implements Cookiebot_Addons_Interface {
78
  * Create cookie when the visitor gives consent
79
  */
80
  public function enqueue_script_for_adding_the_cookie_after_the_consent() {
81
- wp_enqueue_script( 'wpforms-gdpr-cookiebot', COOKIEBOT_URL . 'addons/controller/addons/wpforms/cookie-after-consent.js', array( 'jquery' ),
 
 
82
  '',
83
  true );
84
  wp_localize_script( 'wpforms-gdpr-cookiebot', 'cookiebot_wpforms_settings', array( 'cookie_types' => $this->get_cookie_types() ) );
78
  * Create cookie when the visitor gives consent
79
  */
80
  public function enqueue_script_for_adding_the_cookie_after_the_consent() {
81
+ wp_enqueue_script( 'wpforms-gdpr-cookiebot',
82
+ COOKIEBOT_URL . 'addons/controller/addons/wpforms/cookie-after-consent.js',
83
+ array( 'jquery' ),
84
  '',
85
  true );
86
  wp_localize_script( 'wpforms-gdpr-cookiebot', 'cookiebot_wpforms_settings', array( 'cookie_types' => $this->get_cookie_types() ) );
addons/cookiebot-addons-init.php CHANGED
@@ -115,7 +115,7 @@ class Cookiebot_Addons {
115
  */
116
  add_action( 'plugins_loaded', array(
117
  new Plugin_Controller( $this->container->get( 'Settings_Service_Interface' ) ),
118
- 'load_active_addons'
119
  ) );
120
 
121
  /**
@@ -165,7 +165,7 @@ class Cookiebot_Addons {
165
  'Script_Loader_Tag_Interface' => DI\object( 'cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag' ),
166
  'Cookie_Consent_Interface' => DI\object( 'cookiebot_addons\lib\Cookie_Consent' ),
167
  'Buffer_Output_Interface' => DI\object( 'cookiebot_addons\lib\buffer\Buffer_Output' ),
168
- 'plugins' => DI\value( $this->plugins )
169
  )
170
  );
171
 
115
  */
116
  add_action( 'plugins_loaded', array(
117
  new Plugin_Controller( $this->container->get( 'Settings_Service_Interface' ) ),
118
+ 'load_active_addons',
119
  ) );
120
 
121
  /**
165
  'Script_Loader_Tag_Interface' => DI\object( 'cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag' ),
166
  'Cookie_Consent_Interface' => DI\object( 'cookiebot_addons\lib\Cookie_Consent' ),
167
  'Buffer_Output_Interface' => DI\object( 'cookiebot_addons\lib\buffer\Buffer_Output' ),
168
+ 'plugins' => DI\value( $this->plugins ),
169
  )
170
  );
171
 
addons/lib/cookie-consent.php CHANGED
@@ -19,12 +19,22 @@ class Cookie_Consent implements Cookie_Consent_Interface {
19
  */
20
  private $states = array();
21
 
 
 
 
 
 
22
  /**
23
  * Scan cookiebot cookie
24
  *
 
 
25
  * @since 1.2.0
 
26
  */
27
- public function __construct() {
 
 
28
  $this->scan_cookie();
29
  }
30
 
@@ -32,13 +42,14 @@ class Cookie_Consent implements Cookie_Consent_Interface {
32
  * Scans cookiebot consent cookie and fills in $states with accepted consents.
33
  *
34
  * @since 1.2.0
 
35
  */
36
  public function scan_cookie() {
37
  //default - set strictly necessary cookies
38
  $this->add_state( 'necessary' );
39
 
40
- if ( isset( $_COOKIE["CookieConsent"] ) ) {
41
- switch ( $_COOKIE["CookieConsent"] ) {
42
  case "0":
43
  //The user has not accepted cookies - set strictly necessary cookies only
44
  break;
@@ -53,24 +64,26 @@ class Cookie_Consent implements Cookie_Consent_Interface {
53
  default: //The user has accepted one or more type of cookies
54
 
55
  //Read current user consent in encoded JavaScript format
56
- $valid_php_json = preg_replace( '/\s*:\s*([a-zA-Z0-9_]+?)([}\[,])/', ':"$1"$2', preg_replace( '/([{\[,])\s*([a-zA-Z0-9_]+?):/', '$1"$2":', str_replace( "'", '"', stripslashes( $_COOKIE["CookieConsent"] ) ) ) );
 
 
57
  $CookieConsent = json_decode( $valid_php_json );
58
 
59
- if ( filter_var( $CookieConsent->preferences, FILTER_VALIDATE_BOOLEAN ) ) {
60
  //Current user accepts preference cookies
61
  $this->add_state( 'preferences' );
62
  } else {
63
  //Current user does NOT accept preference cookies
64
  }
65
 
66
- if ( filter_var( $CookieConsent->statistics, FILTER_VALIDATE_BOOLEAN ) ) {
67
  //Current user accepts statistics cookies
68
  $this->add_state( 'statistics' );
69
  } else {
70
  //Current user does NOT accept statistics cookies
71
  }
72
 
73
- if ( filter_var( $CookieConsent->marketing, FILTER_VALIDATE_BOOLEAN ) ) {
74
  //Current user accepts marketing cookies
75
  $this->add_state( 'marketing' );
76
  } else {
19
  */
20
  private $states = array();
21
 
22
+ /**
23
+ * @var array|null
24
+ */
25
+ private $cookie;
26
+
27
  /**
28
  * Scan cookiebot cookie
29
  *
30
+ * @param $default_cookie
31
+ *
32
  * @since 1.2.0
33
+ * @version 2.4.1
34
  */
35
+ public function __construct($default_cookie = null) {
36
+ $this->cookie = ( isset( $_COOKIE['CookieConsent'] ) ) ? $_COOKIE['CookieConsent'] : $default_cookie;
37
+
38
  $this->scan_cookie();
39
  }
40
 
42
  * Scans cookiebot consent cookie and fills in $states with accepted consents.
43
  *
44
  * @since 1.2.0
45
+ * @version 2.4.1
46
  */
47
  public function scan_cookie() {
48
  //default - set strictly necessary cookies
49
  $this->add_state( 'necessary' );
50
 
51
+ if ( ! empty( $this->cookie ) ) {
52
+ switch ( $this->cookie ) {
53
  case "0":
54
  //The user has not accepted cookies - set strictly necessary cookies only
55
  break;
64
  default: //The user has accepted one or more type of cookies
65
 
66
  //Read current user consent in encoded JavaScript format
67
+ $valid_php_json = preg_replace( '/\s*:\s*([a-zA-Z0-9_]+?)([}\[,])/', ':"$1"$2',
68
+ preg_replace( '/([{\[,])\s*([a-zA-Z0-9_]+?):/', '$1"$2":',
69
+ str_replace( "'", '"', stripslashes( $this->cookie ) ) ) );
70
  $CookieConsent = json_decode( $valid_php_json );
71
 
72
+ if ( isset( $CookieConsent->preferences ) && filter_var( $CookieConsent->preferences, FILTER_VALIDATE_BOOLEAN ) ) {
73
  //Current user accepts preference cookies
74
  $this->add_state( 'preferences' );
75
  } else {
76
  //Current user does NOT accept preference cookies
77
  }
78
 
79
+ if ( isset( $CookieConsent->statistics ) && filter_var( $CookieConsent->statistics, FILTER_VALIDATE_BOOLEAN ) ) {
80
  //Current user accepts statistics cookies
81
  $this->add_state( 'statistics' );
82
  } else {
83
  //Current user does NOT accept statistics cookies
84
  }
85
 
86
+ if ( isset( $CookieConsent->marketing ) && filter_var( $CookieConsent->marketing, FILTER_VALIDATE_BOOLEAN ) ) {
87
  //Current user accepts marketing cookies
88
  $this->add_state( 'marketing' );
89
  } else {
addons/tests/integration/addons/test-addthis.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace cookiebot_addons\tests\integration\addons;
4
+
5
+ class Test_Addthis extends \WP_UnitTestCase {
6
+
7
+ public function setUp() {
8
+
9
+ }
10
+
11
+ /**
12
+ * This will validate if the hook "caos_analytics_render_tracking_code" still exists
13
+ *
14
+ */
15
+ public function test_addthis() {
16
+ $content = file_get_contents( 'https://plugins.svn.wordpress.org/addthis/trunk/backend/AddThisPlugin.php' );
17
+
18
+ $this->assertNotFalse( strpos( $content, "'addthis_widget',") );
19
+ $this->assertNotFalse( strpos( $content, "window.addthis_product ") );
20
+ $this->assertNotFalse( strpos( $content, 'add_action(\'wp_enqueue_scripts\', array($this, \'enqueueScripts\'));') );
21
+
22
+ }
23
+ }
addons/tests/unit/test-cookie-consent.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace cookiebot_addons\tests\unit;
4
+
5
+ use cookiebot_addons\lib\Cookie_Consent;
6
+ use DI\ContainerBuilder;
7
+ use DI;
8
+
9
+ class Test_Cookie_Consent extends \WP_UnitTestCase {
10
+
11
+ /**
12
+ * @var string Encoded json format
13
+ */
14
+ private $cookie;
15
+
16
+ public function setUp() {
17
+ $this->cookie = '{"stamp":"0boMmPgsG8gUTRvMkOLtyZ1uLvOFJobBbNb23IZO/TpY3eETvRxFfg==","necessary":"true","preferences":"true","statistics":"false","marketing":"false","ver":"1","utc":"1557479161596"}';
18
+ }
19
+
20
+ /**
21
+ * Test Cookie Consent with valid encoded json format
22
+ *
23
+ * @since 2.4.1
24
+ */
25
+ public function test_scan_cookie_with_encoded_json_format() {
26
+ $cookie_consent = new Cookie_Consent( $this->cookie );
27
+
28
+ $this->assertEquals( $cookie_consent->get_cookie_states(), array( 'necessary', 'preferences' ) );
29
+ }
30
+
31
+ /**
32
+ * Test Cookie Consent with unchecked status
33
+ * Only necessary type should be allowed
34
+ *
35
+ * @since 2.4.1
36
+ */
37
+ public function test_scan_cookie_with_zero_value() {
38
+ $cookie_consent = new Cookie_Consent( 0 );
39
+
40
+ $this->assertEquals( $cookie_consent->get_cookie_states(), array( 'necessary' ) );
41
+ }
42
+
43
+ /**
44
+ * Test Cookie Consent with every type checked
45
+ *
46
+ * @since 2.4.1
47
+ */
48
+ public function test_scan_cookie_everything_checked() {
49
+ $cookie_consent = new Cookie_Consent( - 1 );
50
+
51
+ $this->assertEquals( $cookie_consent->get_cookie_states(),
52
+ array( 'necessary', 'preferences', 'statistics', 'marketing' ) );
53
+ }
54
+
55
+ /**
56
+ * Test Cookie Consent with invalid encoded json format
57
+ * Should return only necessary type
58
+ *
59
+ * @since 2.4.1
60
+ */
61
+ public function test_scan_cookie_with_wrong_encoded_json_format() {
62
+ $cookie_consent = new Cookie_Consent( '{"test":"test"}' );
63
+
64
+ $this->assertEquals( $cookie_consent->get_cookie_states(), array( 'necessary' ) );
65
+ }
66
+ }
cookiebot.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Cookiebot | GDPR Compliant Cookie Consent and Notice
4
  Plugin URI: https://cookiebot.com/
5
  Description: Cookiebot is a fully GDPR & ePrivacy compliant cookie consent solution supporting prior consent, cookie declaration, and documentation of consents. Easy to install, implement and configure.
6
  Author: Cybot A/S
7
- Version: 2.4.1
8
  Author URI: http://cookiebot.com
9
  Text Domain: cookiebot
10
  Domain Path: /langs
@@ -21,7 +21,7 @@ final class Cookiebot_WP {
21
  * @var string
22
  * @since 1.0.0
23
  */
24
- public $version = '2.4.1';
25
 
26
  /**
27
  * @var Cookiebot_WP The single instance of the class
@@ -102,6 +102,7 @@ final class Cookiebot_WP {
102
  if( (!defined('COOKIEBOT_ADDONS_STANDALONE') || COOKIEBOT_ADDONS_STANDALONE != true || !defined('COOKIE_ADDONS_LOADED')) && $dismissAddons !== true ) {
103
  //Make sure we got a PHP version that works
104
  if(version_compare(PHP_VERSION, '5.4.0', '>=')) {
 
105
  include_once('addons/cookiebot-addons-init.php');
106
  }
107
  else {
@@ -299,12 +300,12 @@ final class Cookiebot_WP {
299
  }
300
 
301
  // Check if cookiebot autoupdate is disabled
302
- if(!get_option('cookiebot-autoupdate',true)) {
303
  return $update;
304
  }
305
 
306
  // Check if multisite autoupdate is disabled
307
- if(is_multisite() && !get_site_option('cookiebot-autoupdate',true)) {
308
  return $update;
309
  }
310
 
@@ -548,7 +549,7 @@ final class Cookiebot_WP {
548
  <tr valign="top">
549
  <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
550
  <td>
551
- <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_option('cookiebot-autoupdate',true), true); ?> />
552
  <p class="description">
553
  <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
554
  </p>
@@ -713,7 +714,7 @@ final class Cookiebot_WP {
713
  <tr valign="top">
714
  <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
715
  <td>
716
- <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_site_option('cookiebot-autoupdate',true), true); ?> />
717
  <p class="description">
718
  <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
719
  </p>
4
  Plugin URI: https://cookiebot.com/
5
  Description: Cookiebot is a fully GDPR & ePrivacy compliant cookie consent solution supporting prior consent, cookie declaration, and documentation of consents. Easy to install, implement and configure.
6
  Author: Cybot A/S
7
+ Version: 2.4.2
8
  Author URI: http://cookiebot.com
9
  Text Domain: cookiebot
10
  Domain Path: /langs
21
  * @var string
22
  * @since 1.0.0
23
  */
24
+ public $version = '2.4.2';
25
 
26
  /**
27
  * @var Cookiebot_WP The single instance of the class
102
  if( (!defined('COOKIEBOT_ADDONS_STANDALONE') || COOKIEBOT_ADDONS_STANDALONE != true || !defined('COOKIE_ADDONS_LOADED')) && $dismissAddons !== true ) {
103
  //Make sure we got a PHP version that works
104
  if(version_compare(PHP_VERSION, '5.4.0', '>=')) {
105
+ define('COOKIEBOT_URL', plugin_dir_url( __FILE__ ));
106
  include_once('addons/cookiebot-addons-init.php');
107
  }
108
  else {
300
  }
301
 
302
  // Check if cookiebot autoupdate is disabled
303
+ if(!get_option('cookiebot-autoupdate',false)) {
304
  return $update;
305
  }
306
 
307
  // Check if multisite autoupdate is disabled
308
+ if(is_multisite() && !get_site_option('cookiebot-autoupdate',false)) {
309
  return $update;
310
  }
311
 
549
  <tr valign="top">
550
  <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
551
  <td>
552
+ <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_option('cookiebot-autoupdate',false), true); ?> />
553
  <p class="description">
554
  <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
555
  </p>
714
  <tr valign="top">
715
  <th scope="row"><?php _e('Auto-update Cookiebot','cookiebot'); ?></th>
716
  <td>
717
+ <input type="checkbox" name="cookiebot-autoupdate" value="1" <?php checked(1,get_site_option('cookiebot-autoupdate',false), true); ?> />
718
  <p class="description">
719
  <?php _e('Automatic update your Cookiebot plugin when new releases becomes available.','cookiebot') ?>
720
  </p>
phpunit.xml CHANGED
@@ -5,6 +5,7 @@
5
  convertErrorsToExceptions="true"
6
  convertNoticesToExceptions="true"
7
  convertWarningsToExceptions="true"
 
8
  >
9
  <testsuites>
10
  <testsuite>
5
  convertErrorsToExceptions="true"
6
  convertNoticesToExceptions="true"
7
  convertWarningsToExceptions="true"
8
+ strict="true"
9
  >
10
  <testsuites>
11
  <testsuite>
readme.txt CHANGED
@@ -3,7 +3,7 @@
3
  * Tags: cookie, compliance, eu, gdpr, europe, cookie consent, consent
4
  * Requires at least: 4.4
5
  * Tested up to: 5.1
6
- * Stable tag: 2.4.1
7
  * Requires PHP: 5.4
8
  * License: GPLv2 or later
9
 
@@ -151,6 +151,11 @@ Cookiebot works with GTM, however you need to enable the "Hide Cookie Popup" opt
151
 
152
  ## Changelog ##
153
 
 
 
 
 
 
154
  ### 2.4.1 - 2019-03-19 ###
155
  * Fix jetpack related warning
156
 
3
  * Tags: cookie, compliance, eu, gdpr, europe, cookie consent, consent
4
  * Requires at least: 4.4
5
  * Tested up to: 5.1
6
+ * Stable tag: 2.4.2
7
  * Requires PHP: 5.4
8
  * License: GPLv2 or later
9
 
151
 
152
  ## Changelog ##
153
 
154
+ ### 2.4.2 - 2019-05-15 ###
155
+ * Adding addthis addon
156
+ * Disable default autoupgrade
157
+ * Minor fixes
158
+
159
  ### 2.4.1 - 2019-03-19 ###
160
  * Fix jetpack related warning
161