Cookiebot | GDPR Compliant Cookie Consent and Notice - Version 2.5.0

Version Description

Download this release

Release Info

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

Code changes from version 2.4.2 to 2.5.0

Files changed (33) hide show
  1. addons/controller/addons/add-to-any/add-to-any.php +9 -0
  2. addons/controller/addons/addthis/addthis.php +9 -0
  3. addons/controller/addons/caos-host-analyticsjs-local/caos-host-analyticsjs-local.php +9 -0
  4. addons/controller/addons/cookiebot-addons-interface.php +7 -0
  5. addons/controller/addons/custom-facebook-feed-pro/custom-facebook-feed-pro.php +9 -0
  6. addons/controller/addons/custom-facebook-feed/custom-facebook-feed.php +9 -0
  7. addons/controller/addons/embed-autocorrect/embed-autocorrect.php +663 -507
  8. addons/controller/addons/facebook-for-woocommerce/facebook-for-woocommerce.php +9 -0
  9. addons/controller/addons/ga-google-analytics/ga-google-analytics.php +9 -0
  10. addons/controller/addons/gadwp/gadwp.php +9 -0
  11. addons/controller/addons/google-analyticator/google-analyticator.php +9 -0
  12. addons/controller/addons/google-analytics-plus/google-analytics-plus.php +9 -0
  13. addons/controller/addons/google-analytics/google-analytics.php +9 -0
  14. addons/controller/addons/hubspot-leadin/hubspot-leadin.php +9 -0
  15. addons/controller/addons/hubspot-tracking-code/hubspot-tracking-code.php +9 -0
  16. addons/controller/addons/instagram-feed/instagram-feed.php +9 -0
  17. addons/controller/addons/jetpack/jetpack.php +9 -0
  18. addons/controller/addons/ninja-forms/ninja-forms.php +9 -0
  19. addons/controller/addons/optinmonster/optinmonster.php +9 -0
  20. addons/controller/addons/pixel-caffeine/pixel-caffeine.php +9 -0
  21. addons/controller/addons/wd-google-analytics/wd-google-analytics.php +9 -0
  22. addons/controller/addons/wp-analytify/wp-analytify.php +9 -0
  23. addons/controller/addons/wp-piwik/wp-piwik.php +9 -0
  24. addons/controller/addons/wpforms/wpforms.php +9 -0
  25. addons/cookiebot-addons-init.php +1 -1
  26. addons/js/settings.js +58 -0
  27. addons/lib/settings-service-interface.php +12 -0
  28. addons/lib/settings-service.php +20 -0
  29. addons/style/css/admin_styles.css +16 -0
  30. addons/view/admin/settings/available-addon-callback.php +5 -1
  31. cookiebot.php +20 -5
  32. readme.txt +14 -3
  33. widgets/cookiebot-declaration-widget.php +82 -0
addons/controller/addons/add-to-any/add-to-any.php CHANGED
@@ -302,4 +302,13 @@ class Add_To_Any implements Cookiebot_Addons_Interface {
302
public function plugin_deactivated() {
303
//do nothing
304
}
305
}
302
public function plugin_deactivated() {
303
//do nothing
304
}
305
+
306
+ /**
307
+ * @return mixed
308
+ *
309
+ * @since 2.4.5
310
+ */
311
+ public function extra_available_addon_option() {
312
+ //do nothing
313
+ }
314
}
addons/controller/addons/addthis/addthis.php CHANGED
@@ -299,4 +299,13 @@ class Addthis implements Cookiebot_Addons_Interface {
299
public function plugin_deactivated() {
300
//do nothing
301
}
302
}
299
public function plugin_deactivated() {
300
//do nothing
301
}
302
+
303
+ /**
304
+ * @return mixed
305
+ *
306
+ * @since 2.4.5
307
+ */
308
+ public function extra_available_addon_option() {
309
+ //do nothing
310
+ }
311
}
addons/controller/addons/caos-host-analyticsjs-local/caos-host-analyticsjs-local.php CHANGED
@@ -330,4 +330,13 @@ class CAOS_Host_Analyticsjs_Local implements Cookiebot_Addons_Interface {
330
public function plugin_deactivated() {
331
//do nothing
332
}
333
}
330
public function plugin_deactivated() {
331
//do nothing
332
}
333
+
334
+ /**
335
+ * @return mixed
336
+ *
337
+ * @since 2.4.5
338
+ */
339
+ public function extra_available_addon_option() {
340
+ //do nothing
341
+ }
342
}
addons/controller/addons/cookiebot-addons-interface.php CHANGED
@@ -189,4 +189,11 @@ Interface Cookiebot_Addons_Interface {
189
* @since 2.2.0
190
*/
191
public function plugin_deactivated();
192
}
189
* @since 2.2.0
190
*/
191
public function plugin_deactivated();
192
+
193
+ /**
194
+ * @return mixed
195
+ *
196
+ * @since 2.4.5
197
+ */
198
+ public function extra_available_addon_option();
199
}
addons/controller/addons/custom-facebook-feed-pro/custom-facebook-feed-pro.php CHANGED
@@ -304,4 +304,13 @@ class Custom_Facebook_Feed_Pro implements Cookiebot_Addons_Interface {
304
public function plugin_deactivated() {
305
//do nothing
306
}
307
}
304
public function plugin_deactivated() {
305
//do nothing
306
}
307
+
308
+ /**
309
+ * @return mixed
310
+ *
311
+ * @since 2.4.5
312
+ */
313
+ public function extra_available_addon_option() {
314
+ //do nothing
315
+ }
316
}
addons/controller/addons/custom-facebook-feed/custom-facebook-feed.php CHANGED
@@ -303,4 +303,13 @@ class Custom_Facebook_Feed implements Cookiebot_Addons_Interface {
303
public function plugin_deactivated() {
304
//do nothing
305
}
306
}
303
public function plugin_deactivated() {
304
//do nothing
305
}
306
+
307
+ /**
308
+ * @return mixed
309
+ *
310
+ * @since 2.4.5
311
+ */
312
+ public function extra_available_addon_option() {
313
+ //do nothing
314
+ }
315
}
addons/controller/addons/embed-autocorrect/embed-autocorrect.php CHANGED
@@ -8,513 +8,669 @@ use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
8
use cookiebot_addons\lib\Cookie_Consent_Interface;
9
use cookiebot_addons\lib\Settings_Service_Interface;
10
11
- class Embed_Autocorrect 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.2.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 GA Google
66
- * Analytics action with our own adjusted version.
67
- */
68
- add_action( 'wp_loaded', array( $this, 'cookiebot_addon_embed_autocorrect' ) );
69
- }
70
-
71
- /**
72
- * Check for embed autocorrect action hooks
73
- *
74
- * @since 1.3.0
75
- */
76
- public function cookiebot_addon_embed_autocorrect() {
77
-
78
- //add filters to handle autocorrection in content
79
- add_filter( 'the_content', array(
80
- $this,
81
- 'cookiebot_addon_embed_autocorrect_content'
82
- ), 1000 ); //Ensure it is executed as the last filter
83
-
84
- //add filters to handle autocorrection in widget text
85
- add_filter( 'widget_text', array(
86
- $this,
87
- 'cookiebot_addon_embed_autocorrect_content'
88
- ), 1000 ); //Ensure it is executed as the last filter
89
-
90
-
91
- //add fitler to handle video shortcodes
92
- add_filter( 'wp_video_shortcode', array(
93
- $this,
94
- 'cookiebot_addon_embed_autocorrect_handle_video'
95
- ), 1000 );
96
-
97
- //add fitler to handle audio shortcodes
98
- add_filter( 'wp_audio_shortcode', array(
99
- $this,
100
- 'cookiebot_addon_embed_autocorrect_handle_audio'
101
- ), 1000 );
102
-
103
- add_action( 'wp_head', array(
104
- $this,
105
- 'cookiebot_addon_embed_autocorrect_javascript'
106
- ) );
107
-
108
- }
109
-
110
- /**
111
- * Add javascript to handle videos as loaded
112
- *
113
- * @since 1.1.0
114
- */
115
- public function cookiebot_addon_embed_autocorrect_javascript() {
116
- $library = apply_filters( 'wp_video_shortcode_library', 'mediaelement' );
117
- if($library === 'mediaelement') {
118
- ?><style type="text/css">video.wp-video-shortcode__disabled,audio.wp-audio-shortcode__disabled { display:none; }</style>
119
- <script>
120
- window.addEventListener('CookiebotOnTagsExecuted',function (e) {
121
- if(<?php echo 'Cookiebot.consent.'.implode(' && Cookiebot.consent.',$this->get_cookie_types()); ?>) {
122
- jQuery('.wp-video-shortcode__disabled').addClass('wp-video-shortcode').removeClass('wp-video-shortcode__disabled');
123
- jQuery('.wp-audio-shortcode__disabled').addClass('wp-audio-shortcode').removeClass('wp-audio-shortcode__disabled');
124
- window.wp.mediaelement.initialize();
125
- }
126
- }, false );
127
- </script><?php
128
- }
129
- }
130
-
131
-
132
- /**
133
- * Autocorrection of Vimeo and Youtube tags to make them GDPR compatible
134
- *
135
- * @since 1.1.0
136
- */
137
- public function cookiebot_addon_embed_autocorrect_content( $content ) {
138
- //Make sure Cookiebot is active and the user has enabled autocorrection
139
-
140
- preg_match_all( '|<div[^>]*id=\"fb-root\">.*?</blockquote>|si', $content, $matches );
141
- foreach ( $matches[0] as $match ) {
142
- //Find src.
143
- preg_match( '|<a href=\"([^\"]*)\">([^<]*)</a></p></blockquote>|', $match, $matchSrc );
144
- $src = $matchSrc[1];
145
-
146
- //Replace - and add cookie consent notice.
147
- $adjusted = str_replace( '<script>', '<script type="text/plain" data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '">', $match );
148
-
149
- /**
150
- * Generate placeholder
151
- */
152
- $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
153
-
154
- /**
155
- * Modify placeholder by Filter
156
- *
157
- * @param $placeholder string Current placeholder text
158
- * @param $src string Source attribute from the embedded video
159
- * @param $this array Array of required cookie types
160
- */
161
- $placeholder = apply_filters( 'cookiebot_addons_embed_placeholder', $placeholder, $src, $this->get_cookie_types() );
162
-
163
- $adjusted .= $placeholder;
164
- $content = str_replace( $match, $adjusted, $content );
165
-
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.
176
- $adjusted = str_replace( '<script ', '<script type="text/plain" data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" ', $match );
177
-
178
- /**
179
- * Generate placeholder
180
- */
181
- $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
182
-
183
- /**
184
- * Modify placeholder by Filter
185
- *
186
- * @param $placeholder string Current placeholder text
187
- * @param $src string Source attribute from the embedded video
188
- * @param $this array Array of required cookie types
189
- */
190
- $placeholder = apply_filters( 'cookiebot_addons_embed_placeholder', $placeholder, $src, $this->get_cookie_types() );
191
-
192
- $adjusted .= $placeholder;
193
- $content = str_replace( $match, $adjusted, $content );
194
-
195
- }
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
- /**
221
- * Modify placeholder by Filter
222
- *
223
- * @param $placeholder string Current placeholder text
224
- * @param $src string Source attribute from the embedded video
225
- * @param $this array Array of required cookie types
226
- */
227
- $placeholder = apply_filters( 'cookiebot_addons_embed_placeholder', $placeholder, $src, $this->get_cookie_types() );
228
-
229
- $adjusted .= $placeholder;
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
-
257
- return $content;
258
- }
259
-
260
- /**
261
- * Implementation of filter wp_video_shortcode - fixing code for cookiebot.
262
- */
263
- public function cookiebot_addon_embed_autocorrect_handle_video($output, $atts, $video, $post_id, $library) {
264
- /**
265
- * Generate placeholder
266
- */
267
- $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
268
- $placeholder = apply_filters( 'cookiebot_addons_embed_placeholder', $placeholder, $src, $this->get_cookie_types() );
269
-
270
-
271
- $output = str_replace( 'wp-video-shortcode','wp-video-shortcode__disabled', $output );
272
- $output = str_replace( ' src=', ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=', $output );
273
- $output.= $placeholder;
274
- return $output;
275
- }
276
-
277
- /**
278
- * Implementation of filter wp_audio_shortcode - fixing code for cookiebot.
279
- */
280
- public function cookiebot_addon_embed_autocorrect_handle_audio($output, $atts, $video, $post_id, $library) {
281
- /**
282
- * Generate placeholder
283
- */
284
- $placeholder = $this->generate_placeholder_with_src( apply_filters( 'cookiebot_addons_embed_source', $src ) );
285
- $placeholder = apply_filters( 'cookiebot_addons_embed_placeholder', $placeholder, $src, $this->get_cookie_types() );
286
-
287
- $output = str_replace( 'wp-audio-shortcode','wp-audio-shortcode__disabled', $output );
288
- $output = str_replace( ' src=', ' data-cookieconsent="' . cookiebot_addons_output_cookie_types( $this->get_cookie_types() ) . '" data-src=', $output );
289
- $output.= $placeholder;
290
- return $output;
291
- }
292
-
293
- /**
294
- * Generates placeholder for given source
295
- *
296
- * @param $src
297
- *
298
- * @return string
299
- */
300
- public function generate_placeholder_with_src( $src = '' ) {
301
- $cookieContentNotice = '<div class="cookieconsent-optout-' . cookiebot_addons_get_one_cookie_type( $this->get_cookie_types() ) . '">';
302
- $cookieContentNotice .= $this->get_placeholder( $src );
303
- $cookieContentNotice .= '</div>';
304
-
305
- return $cookieContentNotice;
306
- }
307
-
308
- /**
309
- * Return addon/plugin name
310
- *
311
- * @return string
312
- *
313
- * @since 1.3.0
314
- */
315
- public function get_addon_name() {
316
- return 'Embed autocorrect';
317
- }
318
-
319
- /**
320
- * Option name in the database
321
- *
322
- * @return string
323
- *
324
- * @since 1.3.0
325
- */
326
- public function get_option_name() {
327
- return 'embed_autocorrect';
328
- }
329
-
330
- /**
331
- * Plugin file path
332
- *
333
- * @return string
334
- *
335
- * @since 1.3.0
336
- */
337
- public function get_plugin_file() {
338
- return false;
339
- }
340
-
341
- /**
342
- * Returns checked cookie types
343
- * @return mixed
344
- *
345
- * @since 1.3.0
346
- */
347
- public function get_cookie_types() {
348
- return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
349
- }
350
-
351
- /**
352
- * Returns default cookie types
353
- * @return array
354
- *
355
- * @since 1.5.0
356
- */
357
- public function get_default_cookie_types() {
358
- return array( 'marketing', 'statistics' );
359
- }
360
-
361
- /**
362
- * Check if plugin is activated and checked in the backend
363
- *
364
- * @since 1.3.0
365
- */
366
- public function is_addon_enabled() {
367
- return $this->settings->is_addon_enabled( $this->get_option_name() );
368
- }
369
-
370
- /**
371
- * Checks if addon is installed
372
- *
373
- * @since 1.3.0
374
- */
375
- public function is_addon_installed() {
376
- return $this->settings->is_addon_installed( $this->get_plugin_file() );
377
- }
378
-
379
- /**
380
- * Checks if addon is activated
381
- *
382
- * @since 1.3.0
383
- */
384
- public function is_addon_activated() {
385
- return $this->settings->is_addon_activated( $this->get_plugin_file() );
386
- }
387
-
388
- /**
389
- * Retrieves current installed version of the addon
390
- *
391
- * @return bool
392
- *
393
- * @since 2.2.1
394
- */
395
- public function get_addon_version() {
396
- return false;
397
- }
398
-
399
- /**
400
- * Default placeholder content
401
- *
402
- * @return string
403
- *
404
- * @since 1.8.0
405
- */
406
- public function get_default_placeholder() {
407
- return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
408
- }
409
-
410
- /**
411
- * Get placeholder content
412
- *
413
- * This function will check following features:
414
- * - Current language
415
- *
416
- * @param $src
417
- *
418
- * @return bool|mixed
419
- *
420
- * @since 1.8.0
421
- */
422
- public function get_placeholder( $src = '' ) {
423
- return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
424
- }
425
-
426
- /**
427
- * Checks if it does have custom placeholder content
428
- *
429
- * @return mixed
430
- *
431
- * @since 1.8.0
432
- */
433
- public function has_placeholder() {
434
- return $this->settings->has_placeholder( $this->get_option_name() );
435
- }
436
-
437
- /**
438
- * returns all placeholder contents
439
- *
440
- * @return mixed
441
- *
442
- * @since 1.8.0
443
- */
444
- public function get_placeholders() {
445
- return $this->settings->get_placeholders( $this->get_option_name() );
446
- }
447
-
448
- /**
449
- * Return true if the placeholder is enabled
450
- *
451
- * @return mixed
452
- *
453
- * @since 1.8.0
454
- */
455
- public function is_placeholder_enabled() {
456
- return $this->settings->is_placeholder_enabled( $this->get_option_name() );
457
- }
458
-
459
- /**
460
- * Adds extra information under the label
461
- *
462
- * @return string
463
- *
464
- * @since 1.8.0
465
- */
466
- public function get_extra_information() {
467
- return '<p>' . __( 'Blocks embedded videos from Youtube, Twitter, Vimeo and Facebook.', 'cookiebot-addons' ) . '</p>';
468
- }
469
-
470
- /**
471
- * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
472
- *
473
- * @return boolean
474
- *
475
- * @since 1.8.0
476
- */
477
- public function get_svn_url() {
478
- return false;
479
- }
480
-
481
- /**
482
- * Placeholder helper overlay in the settings page.
483
- *
484
- * @return string
485
- *
486
- * @since 1.8.0
487
- */
488
- public function get_placeholder_helper() {
489
- return '<p>Merge tags you can use in the placeholder text:</p><ul><li>%src - video source</li><li>%cookie_types - Lists required cookie types</li><li>[renew_consent]text[/renew_consent] - link to display cookie settings in the frontend</li></ul>';
490
- }
491
-
492
- /**
493
- * Returns parent class or false
494
- *
495
- * @return string|bool
496
- *
497
- * @since 2.1.3
498
- */
499
- public function get_parent_class() {
500
- return get_parent_class( $this );
501
- }
502
-
503
- /**
504
- * Action after enabling the addon on the settings page
505
- *
506
- * @since 2.2.0
507
- */
508
- public function post_hook_after_enabling() {
509
- //do nothing
510
- }
511
-
512
- /**
513
- * Cookiebot plugin is deactivated
514
- *
515
- * @since 2.2.0
516
- */
517
- public function plugin_deactivated() {
518
- //do nothing
519
- }
520
}
8
use cookiebot_addons\lib\Cookie_Consent_Interface;
9
use cookiebot_addons\lib\Settings_Service_Interface;
10
11
+ class Embed_Autocorrect implements Cookiebot_Addons_Interface
12
+ {
13
+
14
+ /**
15
+ * @var Settings_Service_Interface
16
+ *
17
+ * @since 1.3.0
18
+ */
19
+ protected $settings;
20
+
21
+ /**
22
+ * @var Script_Loader_Tag_Interface
23
+ *
24
+ * @since 1.3.0
25
+ */
26
+ protected $script_loader_tag;
27
+
28
+ /**
29
+ * @var Cookie_Consent_Interface
30
+ *
31
+ * @since 1.3.0
32
+ */
33
+ public $cookie_consent;
34
+
35
+ /**
36
+ * @var Buffer_Output_Interface
37
+ *
38
+ * @since 1.3.0
39
+ */
40
+ protected $buffer_output;
41
+
42
+ /**
43
+ * Jetpack constructor.
44
+ *
45
+ * @param $settings Settings_Service_Interface
46
+ * @param $script_loader_tag Script_Loader_Tag_Interface
47
+ * @param $cookie_consent Cookie_Consent_Interface
48
+ * @param $buffer_output Buffer_Output_Interface
49
+ *
50
+ * @since 1.2.0
51
+ */
52
+ public function __construct(
53
+ Settings_Service_Interface $settings,
54
+ Script_Loader_Tag_Interface $script_loader_tag,
55
+ Cookie_Consent_Interface $cookie_consent,
56
+ Buffer_Output_Interface $buffer_output
57
+ ) {
58
+ $this->settings = $settings;
59
+ $this->script_loader_tag = $script_loader_tag;
60
+ $this->cookie_consent = $cookie_consent;
61
+ $this->buffer_output = $buffer_output;
62
+ }
63
+
64
+ /**
65
+ * Loads addon configuration
66
+ *
67
+ * @since 1.3.0
68
+ */
69
+ public function load_configuration()
70
+ {
71
+ /**
72
+ * We add the action after wp_loaded and replace the original GA Google
73
+ * Analytics action with our own adjusted version.
74
+ */
75
+ add_action('wp_loaded', array($this, 'cookiebot_addon_embed_autocorrect'));
76
+ }
77
+
78
+ /**
79
+ * Check for embed autocorrect action hooks
80
+ *
81
+ * @since 1.3.0
82
+ */
83
+ public function cookiebot_addon_embed_autocorrect()
84
+ {
85
+
86
+ //add filters to handle autocorrection in content
87
+ add_filter('the_content', array(
88
+ $this,
89
+ 'cookiebot_addon_embed_autocorrect_content',
90
+ ), 1000); //Ensure it is executed as the last filter
91
+
92
+ //add filters to handle autocorrection in widget text
93
+ add_filter('widget_text', array(
94
+ $this,
95
+ 'cookiebot_addon_embed_autocorrect_content',
96
+ ), 1000); //Ensure it is executed as the last filter
97
+
98
+
99
+ //add fitler to handle video shortcodes
100
+ add_filter('wp_video_shortcode', array(
101
+ $this,
102
+ 'cookiebot_addon_embed_autocorrect_handle_video',
103
+ ), 1000);
104
+
105
+ //add fitler to handle audio shortcodes
106
+ add_filter('wp_audio_shortcode', array(
107
+ $this,
108
+ 'cookiebot_addon_embed_autocorrect_handle_audio',
109
+ ), 1000);
110
+
111
+ add_action('wp_head', array(
112
+ $this,
113
+ 'cookiebot_addon_embed_autocorrect_javascript',
114
+ ));
115
+ }
116
+
117
+ /**
118
+ * Add javascript to handle videos as loaded
119
+ *
120
+ * @since 1.1.0
121
+ */
122
+ public function cookiebot_addon_embed_autocorrect_javascript()
123
+ {
124
+ $library = apply_filters('wp_video_shortcode_library', 'mediaelement');
125
+ if ($library === 'mediaelement') {
126
+ ?>
127
+ <style type="text/css">video.wp-video-shortcode__disabled, audio.wp-audio-shortcode__disabled {
128
+ display: none;
129
+ }</style>
130
+ <script>
131
+ window.addEventListener( 'CookiebotOnTagsExecuted', function ( e ) {
132
+ if (<?php echo 'Cookiebot.consent.'.implode(' && Cookiebot.consent.',
133
+ $this->get_cookie_types()); ?>) {
134
+ jQuery( '.wp-video-shortcode__disabled' ).addClass( 'wp-video-shortcode' ).removeClass( 'wp-video-shortcode__disabled' );
135
+ jQuery( '.wp-audio-shortcode__disabled' ).addClass( 'wp-audio-shortcode' ).removeClass( 'wp-audio-shortcode__disabled' );
136
+ window.wp.mediaelement.initialize();
137
+ }
138
+ }, false );
139
+ </script><?php
140
+ }
141
+ }
142
+
143
+
144
+ /**
145
+ * Autocorrection of Vimeo and Youtube tags to make them GDPR compatible
146
+ *
147
+ * @since 1.1.0
148
+ */
149
+ public function cookiebot_addon_embed_autocorrect_content($content)
150
+ {
151
+ //Make sure Cookiebot is active and the user has enabled autocorrection
152
+
153
+ preg_match_all('|<div[^>]*id=\"fb-root\">.*?</blockquote>|si', $content, $matches);
154
+ foreach ($matches[0] as $match) {
155
+ //Find src.
156
+ preg_match('|<a href=\"([^\"]*)\">([^<]*)</a></p></blockquote>|', $match, $matchSrc);
157
+ $src = $matchSrc[1];
158
+
159
+ //Replace - and add cookie consent notice.
160
+ $adjusted = str_replace('<script>',
161
+ '<script type="text/plain" data-cookieconsent="'.cookiebot_addons_output_cookie_types($this->get_cookie_types()).'">',
162
+ $match);
163
+
164
+ /**
165
+ * Generate placeholder
166
+ */
167
+ $placeholder = $this->generate_placeholder_with_src(apply_filters('cookiebot_addons_embed_source',
168
+ $src));
169
+
170
+ /**
171
+ * Modify placeholder by Filter
172
+ *
173
+ * @param $placeholder string Current placeholder text
174
+ * @param $src string Source attribute from the embedded video
175
+ * @param $this array Array of required cookie types
176
+ */
177
+ $placeholder = apply_filters('cookiebot_addons_embed_placeholder', $placeholder, $src,
178
+ $this->get_cookie_types());
179
+
180
+ $adjusted .= $placeholder;
181
+ $content = str_replace($match, $adjusted, $content);
182
+
183
+ }
184
+ unset($matches);
185
+
186
+ preg_match_all('|<blockquote[^>]*class=\"twitter-tweet\"[^>]*>.*?</script>|si', $content, $matches);
187
+ foreach ($matches[0] as $match) {
188
+ //Find src.
189
+ preg_match('|<a href=\"([^\"]*)\">([^<]*)</a></blockquote>|', $match, $matchSrc);
190
+ $src = $matchSrc[1];
191
+
192
+ //Replace - and add cookie consent notice.
193
+ $adjusted = str_replace('<script ',
194
+ '<script type="text/plain" data-cookieconsent="'.cookiebot_addons_output_cookie_types($this->get_cookie_types()).'" ',
195
+ $match);
196
+
197
+ /**
198
+ * Generate placeholder
199
+ */
200
+ $placeholder = $this->generate_placeholder_with_src(apply_filters('cookiebot_addons_embed_source',
201
+ $src));
202
+
203
+ /**
204
+ * Modify placeholder by Filter
205
+ *
206
+ * @param $placeholder string Current placeholder text
207
+ * @param $src string Source attribute from the embedded video
208
+ * @param $this array Array of required cookie types
209
+ */
210
+ $placeholder = apply_filters('cookiebot_addons_embed_placeholder', $placeholder, $src,
211
+ $this->get_cookie_types());
212
+
213
+ $adjusted .= $placeholder;
214
+ $content = str_replace($match, $adjusted, $content);
215
+
216
+ }
217
+ unset($matches);
218
+
219
+
220
+ //Match all speakerdeck, slideshare, screencast, reverbnation, mixcloud, kickstarter,
221
+ // dailymoition, collegehumor, cloudup, animoto, videopress, youtube, vimeo and facebook iframes.
222
+ preg_match_all($this->get_regex(),
223
+ $content, $matches);
224
+
225
+ foreach ($matches[0] as $x => $match) {
226
+ /** Get the source attribute value */
227
+ $start = strpos($match, ' src=') + 6;
228
+ $end = strpos($match, $matches[1][$x], $start);
229
+ $src = substr($match, $start, $end - $start);
230
+
231
+ /** Skip the matched iframe if the data-cookieconsent attribute exists */
232
+ if (strpos($match, 'data-cookieconsent') !== false) {
233
+ continue;
234
}
235
236
+ /** Replace - and add cookie consent notice. */
237
+ $adjusted = str_replace(' src=',
238
+ ' data-cookieconsent="'.cookiebot_addons_output_cookie_types($this->get_cookie_types()).'" data-src=',
239
+ $match);
240
+
241
+ /** Generate placeholder */
242
+ $placeholder = $this->generate_placeholder_with_src(apply_filters('cookiebot_addons_embed_source',
243
+ $src));
244
+
245
+ /**
246
+ * Modify placeholder by Filter
247
+ *
248
+ * @param $placeholder string Current placeholder text
249
+ * @param $src string Source attribute from the embedded video
250
+ * @param $this array Array of required cookie types
251
+ */
252
+ $placeholder = apply_filters('cookiebot_addons_embed_placeholder', $placeholder, $src,
253
+ $this->get_cookie_types());
254
+
255
+ $adjusted .= $placeholder;
256
+ $content = str_replace($match, $adjusted, $content);
257
+ }
258
+
259
+ unset($matches);
260
+ preg_match_all('/<script.*(instagram|issuu|imgur|polldaddy|tumblr)+.*<\/script>/mi', $content, $matches);
261
+ foreach ($matches[0] as $x => $match) {
262
+ //Replace - and add cookie consent notice.
263
+ $adjusted = str_replace(' src=',
264
+ ' data-cookieconsent="'.cookiebot_addons_output_cookie_types($this->get_cookie_types()).'" data-src=',
265
+ $match);
266
+ /**
267
+ * Generate placeholder
268
+ */
269
+ $placeholder = $this->generate_placeholder_with_src(apply_filters('cookiebot_addons_embed_source',
270
+ $src));
271
+ /**
272
+ * Modify placeholder by Filter
273
+ *
274
+ * @param $placeholder string Current placeholder text
275
+ * @param $src string Source attribute from the embedded video
276
+ * @param $this array Array of required cookie types
277
+ */
278
+ $placeholder = apply_filters('cookiebot_addons_embed_placeholder', $placeholder, $src,
279
+ $this->get_cookie_types());
280
+ $adjusted .= $placeholder;
281
+ $content = str_replace($match, $adjusted, $content);
282
+ }
283
+ unset($matches);
284
+
285
+
286
+ return $content;
287
+ }
288
+
289
+ /**
290
+ * Implementation of filter wp_video_shortcode - fixing code for cookiebot.
291
+ */
292
+ public function cookiebot_addon_embed_autocorrect_handle_video(
293
+ $output,
294
+ $atts = array(),
295
+ $video = '',
296
+ $post_id = null,
297
+ $library = ''
298
+ ) {
299
+ /* Find src in markup */
300
+ preg_match('| src=\"([^\"]*)\"|', $output, $match);
301
+ $src = $match[1];
302
+
303
+ /**
304
+ * Generate placeholder
305
+ */
306
+ $placeholder = $this->generate_placeholder_with_src(apply_filters('cookiebot_addons_embed_source', $src));
307
+ $placeholder = apply_filters('cookiebot_addons_embed_placeholder', $placeholder, $src,
308
+ $this->get_cookie_types());
309
+
310
+ $output = str_replace('wp-video-shortcode', 'wp-video-shortcode__disabled', $output);
311
+ $output = str_replace(' src=',
312
+ ' data-cookieconsent="'.cookiebot_addons_output_cookie_types($this->get_cookie_types()).'" data-src=',
313
+ $output);
314
+ $output .= $placeholder;
315
+
316
+ return $output;
317
+ }
318
+
319
+ /**
320
+ * Implementation of filter wp_audio_shortcode - fixing code for cookiebot.
321
+ */
322
+ public function cookiebot_addon_embed_autocorrect_handle_audio(
323
+ $output,
324
+ $atts = array(),
325
+ $video = '',
326
+ $post_id = null,
327
+ $library = ''
328
+ ) {
329
+ /* Find src in markup */
330
+ preg_match('| src=\"([^\"]*)\"|', $output, $match);
331
+ $src = $match[1];
332
+
333
+ /**
334
+ * Generate placeholder
335
+ */
336
+ $placeholder = $this->generate_placeholder_with_src(apply_filters('cookiebot_addons_embed_source', $src));
337
+ $placeholder = apply_filters('cookiebot_addons_embed_placeholder', $placeholder, $src,
338
+ $this->get_cookie_types());
339
+
340
+ $output = str_replace('wp-audio-shortcode', 'wp-audio-shortcode__disabled', $output);
341
+ $output = str_replace(' src=',
342
+ ' data-cookieconsent="'.cookiebot_addons_output_cookie_types($this->get_cookie_types()).'" data-src=',
343
+ $output);
344
+ $output .= $placeholder;
345
+
346
+ return $output;
347
+ }
348
+
349
+ /**
350
+ * Generates placeholder for given source
351
+ *
352
+ * @param $src
353
+ *
354
+ * @return string
355
+ */
356
+ public function generate_placeholder_with_src($src = '')
357
+ {
358
+ $cookieContentNotice = '<div class="cookieconsent-optout-'.cookiebot_addons_get_one_cookie_type($this->get_cookie_types()).'">';
359
+ $cookieContentNotice .= $this->get_placeholder($src);
360
+ $cookieContentNotice .= '</div>';
361
+
362
+ return $cookieContentNotice;
363
+ }
364
+
365
+ /**
366
+ * Return addon/plugin name
367
+ *
368
+ * @return string
369
+ *
370
+ * @since 1.3.0
371
+ */
372
+ public function get_addon_name()
373
+ {
374
+ return 'Embed autocorrect';
375
+ }
376
+
377
+ /**
378
+ * Option name in the database
379
+ *
380
+ * @return string
381
+ *
382
+ * @since 1.3.0
383
+ */
384
+ public function get_option_name()
385
+ {
386
+ return 'embed_autocorrect';
387
+ }
388
+
389
+ /**
390
+ * Plugin file path
391
+ *
392
+ * @return string
393
+ *
394
+ * @since 1.3.0
395
+ */
396
+ public function get_plugin_file()
397
+ {
398
+ return false;
399
+ }
400
+
401
+ /**
402
+ * Returns checked cookie types
403
+ * @return mixed
404
+ *
405
+ * @since 1.3.0
406
+ */
407
+ public function get_cookie_types()
408
+ {
409
+ return $this->settings->get_cookie_types($this->get_option_name(), $this->get_default_cookie_types());
410
+ }
411
+
412
+ /**
413
+ * Returns default cookie types
414
+ * @return array
415
+ *
416
+ * @since 1.5.0
417
+ */
418
+ public function get_default_cookie_types()
419
+ {
420
+ return array('marketing', 'statistics');
421
+ }
422
+
423
+ /**
424
+ * Check if plugin is activated and checked in the backend
425
+ *
426
+ * @since 1.3.0
427
+ */
428
+ public function is_addon_enabled()
429
+ {
430
+ return $this->settings->is_addon_enabled($this->get_option_name());
431
+ }
432
+
433
+ /**
434
+ * Checks if addon is installed
435
+ *
436
+ * @since 1.3.0
437
+ */
438
+ public function is_addon_installed()
439
+ {
440
+ return $this->settings->is_addon_installed($this->get_plugin_file());
441
+ }
442
+
443
+ /**
444
+ * Checks if addon is activated
445
+ *
446
+ * @since 1.3.0
447
+ */
448
+ public function is_addon_activated()
449
+ {
450
+ return $this->settings->is_addon_activated($this->get_plugin_file());
451
+ }
452
+
453
+ /**
454
+ * Retrieves current installed version of the addon
455
+ *
456
+ * @return bool
457
+ *
458
+ * @since 2.2.1
459
+ */
460
+ public function get_addon_version()
461
+ {
462
+ return false;
463
+ }
464
+
465
+ /**
466
+ * Default placeholder content
467
+ *
468
+ * @return string
469
+ *
470
+ * @since 1.8.0
471
+ */
472
+ public function get_default_placeholder()
473
+ {
474
+ return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
475
+ }
476
+
477
+ /**
478
+ * Get placeholder content
479
+ *
480
+ * This function will check following features:
481
+ * - Current language
482
+ *
483
+ * @param $src
484
+ *
485
+ * @return bool|mixed
486
+ *
487
+ * @since 1.8.0
488
+ */
489
+ public function get_placeholder($src = '')
490
+ {
491
+ return $this->settings->get_placeholder($this->get_option_name(), $this->get_default_placeholder(),
492
+ cookiebot_addons_output_cookie_types($this->get_cookie_types()), $src);
493
+ }
494
+
495
+ /**
496
+ * Checks if it does have custom placeholder content
497
+ *
498
+ * @return mixed
499
+ *
500
+ * @since 1.8.0
501
+ */
502
+ public function has_placeholder()
503
+ {
504
+ return $this->settings->has_placeholder($this->get_option_name());
505
+ }
506
+
507
+ /**
508
+ * returns all placeholder contents
509
+ *
510
+ * @return mixed
511
+ *
512
+ * @since 1.8.0
513
+ */
514
+ public function get_placeholders()
515
+ {
516
+ return $this->settings->get_placeholders($this->get_option_name());
517
+ }
518
+
519
+ /**
520
+ * Return true if the placeholder is enabled
521
+ *
522
+ * @return mixed
523
+ *
524
+ * @since 1.8.0
525
+ */
526
+ public function is_placeholder_enabled()
527
+ {
528
+ return $this->settings->is_placeholder_enabled($this->get_option_name());
529
+ }
530
+
531
+ /**
532
+ * Adds extra information under the label
533
+ *
534
+ * @return string
535
+ *
536
+ * @since 1.8.0
537
+ */
538
+ public function get_extra_information()
539
+ {
540
+ return '<p>'.__('Blocks embedded videos from Youtube, Twitter, Vimeo and Facebook.',
541
+ 'cookiebot-addons').'</p>';
542
+ }
543
+
544
+ /**
545
+ * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
546
+ *
547
+ * @return boolean
548
+ *
549
+ * @since 1.8.0
550
+ */
551
+ public function get_svn_url()
552
+ {
553
+ return false;
554
+ }
555
+
556
+ /**
557
+ * Placeholder helper overlay in the settings page.
558
+ *
559
+ * @return string
560
+ *
561
+ * @since 1.8.0
562
+ */
563
+ public function get_placeholder_helper()
564
+ {
565
+ return '<p>Merge tags you can use in the placeholder text:</p><ul><li>%src - video source</li><li>%cookie_types - Lists required cookie types</li><li>[renew_consent]text[/renew_consent] - link to display cookie settings in the frontend</li></ul>';
566
+ }
567
+
568
+ /**
569
+ * Returns parent class or false
570
+ *
571
+ * @return string|bool
572
+ *
573
+ * @since 2.1.3
574
+ */
575
+ public function get_parent_class()
576
+ {
577
+ return get_parent_class($this);
578
+ }
579
+
580
+ /**
581
+ * Action after enabling the addon on the settings page
582
+ *
583
+ * @since 2.2.0
584
+ */
585
+ public function post_hook_after_enabling()
586
+ {
587
+ //do nothing
588
+ }
589
+
590
+ /**
591
+ * Cookiebot plugin is deactivated
592
+ *
593
+ * @since 2.2.0
594
+ */
595
+ public function plugin_deactivated()
596
+ {
597
+ //do nothing
598
+ }
599
+
600
+ /**
601
+ * Returns regex from the database
602
+ * If it does not exist then it will return the default regex
603
+ *
604
+ * @return string
605
+ *
606
+ * @since 2.4.6
607
+ */
608
+ private function get_regex()
609
+ {
610
+ return $this->settings->get_addon_regex($this->get_option_name(), $this->get_default_regex());
611
+ }
612
+
613
+ /**
614
+ * Returns the default regex
615
+ *
616
+ * @return string
617
+ *
618
+ * @since 2.4.6
619
+ */
620
+ private function get_default_regex()
621
+ {
622
+ return '/<iframe[^>]* src=("|\').*(facebook\.com|youtu\.be|youtube\.com|youtube-nocookie\.com|player\.vimeo\.com).*[^>].*>.*?<\/iframe>/mi';
623
+ }
624
+
625
+ /**
626
+ * Returns true if the default and the normal regex functions match
627
+ *
628
+ * @return bool
629
+ *
630
+ * @since 2.4.6
631
+ */
632
+ private function is_regex_default() {
633
+ return $this->get_regex() === $this->get_default_regex();
634
+ }
635
+ /**
636
+ * @return mixed
637
+ *
638
+ * @since 2.4.6
639
+ */
640
+ public function extra_available_addon_option()
641
+ {
642
+ ?>
643
+ <div class="show_advanced_options">
644
+ <button class="button button-secondary"><?php _e('Show advanced options', 'cookiebot-addons'); ?></button>
645
+ <span class="help-tip"
646
+ title="<?php echo __('This is for more advanced users.', 'cookiebot-addons'); ?>"></span>
647
+ </div>
648
+ <div class="advanced_options">
649
+
650
+ <label for="embed_regex"><?php _e('Regex:', 'cookiebot-addons'); ?></label>
651
+ <textarea
652
+ id="embed_regex"
653
+ cols="80"
654
+ rows="5"
655
+ name="cookiebot_available_addons[<?php echo $this->get_option_name(); ?>][regex]"
656
+ disabled
657
+ ><?php echo esc_html($this->get_regex()); ?></textarea>
658
+
659
+ <?php if( $this->is_regex_default() ) : ?>
660
+ <button id="edit_embed_regex" class="button"><?php _e('Edit regex', 'cookiebot-addons'); ?></button>
661
+ <?php endif; ?>
662
+
663
+ <button
664
+ id="btn_default_embed_regex"
665
+ class="button<?php echo ($this->is_regex_default()) ? ' hidden' : ''; ?>"
666
+ type="button"
667
+ value="Reset to default regex"><?php _e('Reset to default regex', 'cookiebot-addons'); ?></button>
668
+ <input
669
+ type="hidden"
670
+ name="default_embed_regex"
671
+ id="default_embed_regex"
672
+ value="<?php echo esc_html($this->get_default_regex()); ?>"/>
673
+ </div>
674
+ <?php
675
+ }
676
}
addons/controller/addons/facebook-for-woocommerce/facebook-for-woocommerce.php CHANGED
@@ -335,4 +335,13 @@ class Facebook_For_Woocommerce implements Cookiebot_Addons_Interface {
335
public function plugin_deactivated() {
336
//do nothing
337
}
338
}
335
public function plugin_deactivated() {
336
//do nothing
337
}
338
+
339
+ /**
340
+ * @return mixed
341
+ *
342
+ * @since 2.4.5
343
+ */
344
+ public function extra_available_addon_option() {
345
+ //do nothing
346
+ }
347
}
addons/controller/addons/ga-google-analytics/ga-google-analytics.php CHANGED
@@ -310,4 +310,13 @@ class Ga_Google_Analytics implements Cookiebot_Addons_Interface {
310
public function plugin_deactivated() {
311
//do nothing
312
}
313
}
310
public function plugin_deactivated() {
311
//do nothing
312
}
313
+
314
+ /**
315
+ * @return mixed
316
+ *
317
+ * @since 2.4.5
318
+ */
319
+ public function extra_available_addon_option() {
320
+ //do nothing
321
+ }
322
}
addons/controller/addons/gadwp/gadwp.php CHANGED
@@ -323,4 +323,13 @@ class Gadwp implements Cookiebot_Addons_Interface {
323
public function plugin_deactivated() {
324
//do nothing
325
}
326
}
323
public function plugin_deactivated() {
324
//do nothing
325
}
326
+
327
+ /**
328
+ * @return mixed
329
+ *
330
+ * @since 2.4.5
331
+ */
332
+ public function extra_available_addon_option() {
333
+ //do nothing
334
+ }
335
}
addons/controller/addons/google-analyticator/google-analyticator.php CHANGED
@@ -326,4 +326,13 @@ class Google_Analyticator implements Cookiebot_Addons_Interface {
326
public function plugin_deactivated() {
327
//do nothing
328
}
329
}
326
public function plugin_deactivated() {
327
//do nothing
328
}
329
+
330
+ /**
331
+ * @return mixed
332
+ *
333
+ * @since 2.4.5
334
+ */
335
+ public function extra_available_addon_option() {
336
+ //do nothing
337
+ }
338
}
addons/controller/addons/google-analytics-plus/google-analytics-plus.php CHANGED
@@ -289,4 +289,13 @@ class Google_Analytics_Plus implements Cookiebot_Addons_Interface {
289
public function plugin_deactivated() {
290
//do nothing
291
}
292
}
289
public function plugin_deactivated() {
290
//do nothing
291
}
292
+
293
+ /**
294
+ * @return mixed
295
+ *
296
+ * @since 2.4.5
297
+ */
298
+ public function extra_available_addon_option() {
299
+ //do nothing
300
+ }
301
}
addons/controller/addons/google-analytics/google-analytics.php CHANGED
@@ -294,4 +294,13 @@ class Google_Analytics implements Cookiebot_Addons_Interface {
294
public function plugin_deactivated() {
295
//do nothing
296
}
297
}
294
public function plugin_deactivated() {
295
//do nothing
296
}
297
+
298
+ /**
299
+ * @return mixed
300
+ *
301
+ * @since 2.4.5
302
+ */
303
+ public function extra_available_addon_option() {
304
+ //do nothing
305
+ }
306
}
addons/controller/addons/hubspot-leadin/hubspot-leadin.php CHANGED
@@ -292,4 +292,13 @@ class Hubspot_Leadin implements Cookiebot_Addons_Interface {
292
public function plugin_deactivated() {
293
//do nothing
294
}
295
}
292
public function plugin_deactivated() {
293
//do nothing
294
}
295
+
296
+ /**
297
+ * @return mixed
298
+ *
299
+ * @since 2.4.5
300
+ */
301
+ public function extra_available_addon_option() {
302
+ //do nothing
303
+ }
304
}
addons/controller/addons/hubspot-tracking-code/hubspot-tracking-code.php CHANGED
@@ -305,4 +305,13 @@ class Hubspot_Tracking_Code implements Cookiebot_Addons_Interface {
305
public function plugin_deactivated() {
306
//do nothing
307
}
308
}
305
public function plugin_deactivated() {
306
//do nothing
307
}
308
+
309
+ /**
310
+ * @return mixed
311
+ *
312
+ * @since 2.4.5
313
+ */
314
+ public function extra_available_addon_option() {
315
+ //do nothing
316
+ }
317
}
addons/controller/addons/instagram-feed/instagram-feed.php CHANGED
@@ -288,4 +288,13 @@ class Instagram_Feed implements Cookiebot_Addons_Interface {
288
public function plugin_deactivated() {
289
//do nothing
290
}
291
}
288
public function plugin_deactivated() {
289
//do nothing
290
}
291
+
292
+ /**
293
+ * @return mixed
294
+ *
295
+ * @since 2.4.5
296
+ */
297
+ public function extra_available_addon_option() {
298
+ //do nothing
299
+ }
300
}
addons/controller/addons/jetpack/jetpack.php CHANGED
@@ -395,4 +395,13 @@ class Jetpack implements Cookiebot_Addons_Interface {
395
public function plugin_deactivated() {
396
//do nothing
397
}
398
}
395
public function plugin_deactivated() {
396
//do nothing
397
}
398
+
399
+ /**
400
+ * @return mixed
401
+ *
402
+ * @since 2.4.5
403
+ */
404
+ public function extra_available_addon_option() {
405
+ //do nothing
406
+ }
407
}
addons/controller/addons/ninja-forms/ninja-forms.php CHANGED
@@ -307,4 +307,13 @@ class Ninja_Forms implements Cookiebot_Addons_Interface {
307
public function plugin_deactivated() {
308
//do nothing
309
}
310
}
307
public function plugin_deactivated() {
308
//do nothing
309
}
310
+
311
+ /**
312
+ * @return mixed
313
+ *
314
+ * @since 2.4.5
315
+ */
316
+ public function extra_available_addon_option() {
317
+ //do nothing
318
+ }
319
}
addons/controller/addons/optinmonster/optinmonster.php CHANGED
@@ -286,4 +286,13 @@ class Optinmonster implements Cookiebot_Addons_Interface {
286
public function plugin_deactivated() {
287
//do nothing
288
}
289
}
286
public function plugin_deactivated() {
287
//do nothing
288
}
289
+
290
+ /**
291
+ * @return mixed
292
+ *
293
+ * @since 2.4.5
294
+ */
295
+ public function extra_available_addon_option() {
296
+ //do nothing
297
+ }
298
}
addons/controller/addons/pixel-caffeine/pixel-caffeine.php CHANGED
@@ -294,4 +294,13 @@ class Pixel_Caffeine implements Cookiebot_Addons_Interface {
294
public function plugin_deactivated() {
295
//do nothing
296
}
297
}
294
public function plugin_deactivated() {
295
//do nothing
296
}
297
+
298
+ /**
299
+ * @return mixed
300
+ *
301
+ * @since 2.4.5
302
+ */
303
+ public function extra_available_addon_option() {
304
+ //do nothing
305
+ }
306
}
addons/controller/addons/wd-google-analytics/wd-google-analytics.php CHANGED
@@ -288,4 +288,13 @@ class Wd_Google_Analytics implements Cookiebot_Addons_Interface {
288
public function plugin_deactivated() {
289
//do nothing
290
}
291
}
288
public function plugin_deactivated() {
289
//do nothing
290
}
291
+
292
+ /**
293
+ * @return mixed
294
+ *
295
+ * @since 2.4.5
296
+ */
297
+ public function extra_available_addon_option() {
298
+ //do nothing
299
+ }
300
}
addons/controller/addons/wp-analytify/wp-analytify.php CHANGED
@@ -288,4 +288,13 @@ class Wp_Analytify implements Cookiebot_Addons_Interface {
288
public function plugin_deactivated() {
289
//do nothing
290
}
291
}
288
public function plugin_deactivated() {
289
//do nothing
290
}
291
+
292
+ /**
293
+ * @return mixed
294
+ *
295
+ * @since 2.4.5
296
+ */
297
+ public function extra_available_addon_option() {
298
+ //do nothing
299
+ }
300
}
addons/controller/addons/wp-piwik/wp-piwik.php CHANGED
@@ -316,4 +316,13 @@ class Wp_Piwik implements Cookiebot_Addons_Interface {
316
public function plugin_deactivated() {
317
//do nothing
318
}
319
}
316
public function plugin_deactivated() {
317
//do nothing
318
}
319
+
320
+ /**
321
+ * @return mixed
322
+ *
323
+ * @since 2.4.5
324
+ */
325
+ public function extra_available_addon_option() {
326
+ //do nothing
327
+ }
328
}
addons/controller/addons/wpforms/wpforms.php CHANGED
@@ -357,4 +357,13 @@ class Wpforms implements Cookiebot_Addons_Interface {
357
358
update_option( $option, $options );
359
}
360
}
357
358
update_option( $option, $options );
359
}
360
+
361
+ /**
362
+ * @return mixed
363
+ *
364
+ * @since 2.4.5
365
+ */
366
+ public function extra_available_addon_option() {
367
+ //do nothing
368
+ }
369
}
addons/cookiebot-addons-init.php CHANGED
@@ -23,7 +23,7 @@ define( 'COOKIEBOT_ADDONS_BASE_NAME', dirname( plugin_basename( __FILE__ ) ) );
23
/**
24
* Same version as the CookiebotWP
25
*/
26
- define( 'COOKIEBOT_ADDONS_VERSION', '2.4.0' );
27
28
/**
29
* Register autoloader to load files/classes dynamically
23
/**
24
* Same version as the CookiebotWP
25
*/
26
+ define( 'COOKIEBOT_ADDONS_VERSION', '2.5.0' );
27
28
/**
29
* Register autoloader to load files/classes dynamically
addons/js/settings.js CHANGED
@@ -16,6 +16,9 @@ function init() {
16
button_add_placeholder_language();
17
button_delete_language();
18
tooltip();
19
}
20
21
/**
@@ -142,4 +145,59 @@ function tooltip() {
142
'fadeOut': 50,
143
'delay': 200
144
} );
145
}
16
button_add_placeholder_language();
17
button_delete_language();
18
tooltip();
19
+ show_advanced_options();
20
+ edit_embed_regex();
21
+ set_default_embed_regex();
22
}
23
24
/**
145
'fadeOut': 50,
146
'delay': 200
147
} );
148
+ }
149
+
150
+ /**
151
+ * Show advanced options
152
+ *
153
+ * @since 2.4.5
154
+ */
155
+ function show_advanced_options() {
156
+ jQuery(document).on('click', '.show_advanced_options', function( e ) {
157
+ e.preventDefault();
158
+
159
+ /** Toggle displaying advanced options **/
160
+ jQuery( this ).next().toggle();
161
+
162
+ return false;
163
+ } );
164
+ }
165
+
166
+ function edit_embed_regex() {
167
+ jQuery(document).on('click', '#edit_embed_regex', function(e) {
168
+ e.preventDefault();
169
+
170
+ /** Get the textarea for the embed regex **/
171
+ let embed_regex = document.getElementById("embed_regex");
172
+
173
+ /** Remove the disable attribute in the textarea **/
174
+ embed_regex.disabled = false;
175
+
176
+ /** Make the Reset default button back visible **/
177
+ let default_button = document.getElementById('btn_default_embed_regex');
178
+ default_button.classList.remove('hidden');
179
+
180
+ jQuery(this).hide();
181
+
182
+ return false;
183
+ });
184
+ }
185
+
186
+ /**
187
+ * Set default embed regex
188
+ *
189
+ * @since 2.4.5
190
+ */
191
+ function set_default_embed_regex() {
192
+ jQuery(document).on('click', '#btn_default_embed_regex', function( e ) {
193
+ e.preventDefault();
194
+
195
+ /** get the value of the default embed regex **/
196
+ let default_regex = jQuery( "#default_embed_regex").val();
197
+
198
+ /** Update the textarea of the embed regex **/
199
+ jQuery( '#embed_regex' ).val( default_regex );
200
+
201
+ return false;
202
+ } );
203
}
addons/lib/settings-service-interface.php CHANGED
@@ -71,6 +71,18 @@ Interface Settings_Service_Interface {
71
*/
72
public function get_cookie_types( $addon, $default = array() );
73
74
/**
75
* Returns addons one by one through a generator
76
*
71
*/
72
public function get_cookie_types( $addon, $default = array() );
73
74
+ /**
75
+ * Returns regex for given addon
76
+ *
77
+ * @param $addon string option name
78
+ * @param $default string default regex
79
+ *
80
+ * @return string
81
+ *
82
+ * @since 2.4.5
83
+ */
84
+ public function get_addon_regex( $addon, $default = '' );
85
+
86
/**
87
* Returns addons one by one through a generator
88
*
addons/lib/settings-service.php CHANGED
@@ -102,6 +102,26 @@ class Settings_Service implements Settings_Service_Interface {
102
return $default;
103
}
104
105
/**
106
* Returns addons one by one through a generator
107
*
102
return $default;
103
}
104
105
+ /**
106
+ * Returns regex for given addon
107
+ *
108
+ * @param $addon string option name
109
+ * @param $default string default regex
110
+ *
111
+ * @return string
112
+ *
113
+ * @since 2.4.5
114
+ */
115
+ public function get_addon_regex( $addon, $default = '' ) {
116
+ $option = get_option( static::OPTION_NAME );
117
+
118
+ if ( isset( $option[ $addon ]['regex'] ) ) {
119
+ return $option[ $addon ]['regex'];
120
+ }
121
+
122
+ return $default;
123
+ }
124
+
125
/**
126
* Returns addons one by one through a generator
127
*
addons/style/css/admin_styles.css CHANGED
@@ -141,4 +141,20 @@ div.extra_information {
141
border-width: 6px;
142
height: 0;
143
width: 0
144
}
141
border-width: 6px;
142
height: 0;
143
width: 0
144
+ }
145
+
146
+ /**
147
+ Show advanced options
148
+ */
149
+ .show_advanced_options {
150
+ margin: 15px 0 10px 0;
151
+ }
152
+ .advanced_options{
153
+ display: none;
154
+ }
155
+ .advanced_options label{
156
+ vertical-align: top;
157
+ }
158
+ #embed_regex {
159
+ width: 400px;
160
}
addons/view/admin/settings/available-addon-callback.php CHANGED
@@ -1,4 +1,5 @@
1
<?php
2
$addon = $args['addon'];
3
4
require_once( ABSPATH . '/wp-includes/l10n.php' );
@@ -100,4 +101,7 @@ require_once( ABSPATH . '/wp-admin/includes/translation-install.php' );
100
data-addon="<?php echo $addon->get_option_name(); ?>"><?php _e( '+ Add language', 'cookiebot-addons' ); ?></button>
101
</p>
102
</div>
103
- </div>
1
<?php
2
+ /** @var \cookiebot_addons\controller\addons\Cookiebot_Addons_Interface $addon */
3
$addon = $args['addon'];
4
5
require_once( ABSPATH . '/wp-includes/l10n.php' );
101
data-addon="<?php echo $addon->get_option_name(); ?>"><?php _e( '+ Add language', 'cookiebot-addons' ); ?></button>
102
</p>
103
</div>
104
+ <?php
105
+ $addon->extra_available_addon_option();
106
+ ?>
107
+ </div>
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.2
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.2';
25
26
/**
27
* @var Cookiebot_WP The single instance of the class
@@ -102,8 +102,8 @@ 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
- define('COOKIEBOT_URL', plugin_dir_url( __FILE__ ));
106
- include_once('addons/cookiebot-addons-init.php');
107
}
108
else {
109
define('COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION',true);
@@ -171,6 +171,11 @@ final class Cookiebot_WP {
171
if(is_admin() || (defined('DOING_CRON') && DOING_CRON)) {
172
add_filter('auto_update_plugin', array($this,'automatic_updates'), 10, 2);
173
}
174
}
175
176
/**
@@ -182,6 +187,16 @@ final class Cookiebot_WP {
182
function load_textdomain() {
183
load_plugin_textdomain( 'cookiebot', false, basename( dirname( __FILE__ ) ) . '/langs' );
184
}
185
186
/**
187
* Cookiebot_WP Add dashboard widgets to admin
@@ -319,7 +334,7 @@ final class Cookiebot_WP {
319
* @version 1.4.0
320
* @since 1.4.0
321
*/
322
- function get_supported_languages() {
323
$supportedLanguages = array();
324
$supportedLanguages['nb'] = __('Norwegian Bokmål','cookiebot');
325
$supportedLanguages['tr'] = __('Turkish','cookiebot');
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.5.0
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.5.0';
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( dirname( __FILE__ ) . '/addons/cookiebot-addons-init.php' );
107
}
108
else {
109
define('COOKIEBOT_ADDONS_UNSUPPORTED_PHPVERSION',true);
171
if(is_admin() || (defined('DOING_CRON') && DOING_CRON)) {
172
add_filter('auto_update_plugin', array($this,'automatic_updates'), 10, 2);
173
}
174
+
175
+ //Loading widgets
176
+ include_once( dirname( __FILE__ ) . '/widgets/cookiebot-declaration-widget.php' );
177
+ add_action( 'widgets_init', array($this,'register_widgets') );
178
+
179
}
180
181
/**
187
function load_textdomain() {
188
load_plugin_textdomain( 'cookiebot', false, basename( dirname( __FILE__ ) ) . '/langs' );
189
}
190
+
191
+ /**
192
+ * Cookiebot_WP Register widgets
193
+ *
194
+ * @version 2.5.0
195
+ * @since 2.5.0
196
+ */
197
+ function register_widgets() {
198
+ register_widget( 'Cookiebot_Declaration_Widget' );
199
+ }
200
201
/**
202
* Cookiebot_WP Add dashboard widgets to admin
334
* @version 1.4.0
335
* @since 1.4.0
336
*/
337
+ public static function get_supported_languages() {
338
$supportedLanguages = array();
339
$supportedLanguages['nb'] = __('Norwegian Bokmål','cookiebot');
340
$supportedLanguages['tr'] = __('Turkish','cookiebot');
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
* Contributors: cookiebot,phpgeekdk,aytac
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
10
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.
@@ -151,6 +151,17 @@ Cookiebot works with GTM, however you need to enable the "Hide Cookie Popup" opt
151
152
## Changelog ##
153
154
### 2.4.2 - 2019-05-15 ###
155
* Adding addthis addon
156
* Disable default autoupgrade
2
* Contributors: cookiebot,phpgeekdk,aytac
3
* Tags: cookie, compliance, eu, gdpr, europe, cookie consent, consent
4
* Requires at least: 4.4
5
+ * Tested up to: 5.2
6
+ * Stable tag: 2.5.0
7
+ * Requires PHP: 5.6
8
* License: GPLv2 or later
9
10
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.
151
152
## Changelog ##
153
154
+ ### 2.5.0 - 2019-06-12 ###
155
+ * Add support for custom regex for embed autocorrect
156
+ * Adding Cookie Declaration widget
157
+ * Remove support for PHP 5.4
158
+
159
+ ### 2.4.4 - 2019-05-22 ###
160
+ * Minor bugfixes in Embed Autocorrect addon
161
+
162
+ ### 2.4.3 - 2019-05-16 ###
163
+ * Fix bug in Embed Autocorrect addon.
164
+
165
### 2.4.2 - 2019-05-15 ###
166
* Adding addthis addon
167
* Disable default autoupgrade
widgets/cookiebot-declaration-widget.php ADDED
@@ -0,0 +1,82 @@
1
+ <?php
2
+
3
+ // The widget class for Cookiebot D
4
+ class Cookiebot_Declaration_Widget extends WP_Widget {
5
+
6
+ // Main constructor
7
+ public function __construct() {
8
+ parent::__construct(
9
+ 'cookiebot_declaration_widget',
10
+ __( 'Cookiebot - Cookie Declaration', 'cookiebot' ),
11
+ array(
12
+ 'customize_selective_refresh' => true,
13
+ )
14
+ );
15
+ }
16
+
17
+ // The widget form (for the backend )
18
+ public function form( $instance ) {
19
+ $defaults = array('lang'=>'');
20
+ extract( wp_parse_args( ( array ) $instance, $defaults ) );
21
+ ?>
22
+ <p>
23
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title', 'Cookiebot' ); ?></label>
24
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
25
+ </p>
26
+ <p>
27
+ <label for="<?php echo $this->get_field_id( 'lang' ); ?>"><?php _e( 'Language', 'cookiebot' ); ?></label>
28
+ <select name="<?php echo $this->get_field_name( 'lang' ); ?>" id="<?php echo $this->get_field_id( 'lang' ); ?>" class="widefat">
29
+ <option value=""><?php echo __('- Default -', 'cookiebot'); ?></option>
30
+ <?php
31
+ $options = Cookiebot_WP::get_supported_languages();
32
+ foreach ( $options as $key => $name ) {
33
+ echo '<option value="' . esc_attr( $key ) . '" id="' . esc_attr( $key ) . '" '. selected( $lang, $key, false ) . '>'. $name . '</option>';
34
+ }
35
+ ?>
36
+ </select>
37
+
38
+ </p>
39
+ <?php
40
+ }
41
+
42
+ // Update widget settings
43
+ public function update( $new_instance, $old_instance ) {
44
+ $instance = $old_instance;
45
+ $instance['lang'] = isset( $new_instance['lang'] ) ? wp_strip_all_tags( $new_instance['lang'] ) : '';
46
+ $instance['title'] = isset( $new_instance['title'] ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
47
+ return $instance;
48
+ }
49
+
50
+ // Display the widget
51
+ public function widget( $args, $instance ) {
52
+ extract( $args );
53
+ extract( $instance );
54
+
55
+ // WordPress core before_widget hook
56
+ echo $before_widget;
57
+
58
+ echo '<div class="widget-text wp_widget_plugin_box cookiebot_cookie_declaration">';
59
+
60
+ // Display widget title if defined
61
+ if ( $title ) {
62
+ echo $before_title . $title . $after_title;
63
+ }
64
+
65
+ $cbid = Cookiebot_WP::get_cbid();
66
+ if(!empty($lang)) { $lang = ' data-culture="'.$lang.'"'; }
67
+ if(!is_multisite() || get_site_option('cookiebot-script-tag-cd-attribute','custom') == 'custom') {
68
+ $tagAttr = get_option('cookiebot-script-tag-cd-attribute','async');
69
+ }
70
+ else {
71
+ $tagAttr = get_site_option('cookiebot-script-tag-cd-attribute');
72
+ }
73
+
74
+ echo '<script id="CookieDeclaration" src="https://consent.cookiebot.com/'.$cbid.'/cd.js"'.$lang.' type="text/javascript" '.$tagAttr.'></script>';
75
+
76
+ echo '</div>';
77
+
78
+ // WordPress core after_widget hook
79
+ echo $after_widget;
80
+ }
81
+
82
+ }