Cookie Consent - Version 2.3.9

Version Description

  • Updated: removed tracking
Download this release

Release Info

Developer Catapult_Themes
Plugin Icon 128x128 Cookie Consent
Version 2.3.9
Comparing to
See all releases

Code changes from version 2.3.8 to 2.3.9

readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Catapult_Themes, husobj, jraczynski
3
  Donate Link: https://www.paypal.me/catapultthemes
4
  Tags: cookie law, cookies, eu cookie law, eu privacy directive, cookie compliance, cookie law, cookie notice, cookie notification, wpml, geo ip
5
  Requires at least: 4.3
6
- Tested up to: 4.9.2
7
- Stable tag: 2.3.8
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  The only cookie consent plugin you'll ever need.
@@ -71,6 +71,9 @@ You will find more details of the regulations on the [Information Commissioner's
71
 
72
  == Changelog ==
73
 
 
 
 
74
  = 2.3.8 =
75
  * Updated: tracking class
76
 
3
  Donate Link: https://www.paypal.me/catapultthemes
4
  Tags: cookie law, cookies, eu cookie law, eu privacy directive, cookie compliance, cookie law, cookie notice, cookie notification, wpml, geo ip
5
  Requires at least: 4.3
6
+ Tested up to: 4.9.3
7
+ Stable tag: 2.3.9
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  The only cookie consent plugin you'll ever need.
71
 
72
  == Changelog ==
73
 
74
+ = 2.3.9 =
75
+ * Updated: removed tracking
76
+
77
  = 2.3.8 =
78
  * Updated: tracking class
79
 
tracking/class-plugin-usage-tracker.php DELETED
@@ -1,1025 +0,0 @@
1
- <?php
2
- /**
3
- * This is the class that sends all the data back to the home site
4
- * It also handles opting in and deactivation
5
- * @version 1.2.3
6
- */
7
-
8
- // Exit if accessed directly
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- if( ! class_exists( 'Plugin_Usage_Tracker') ) {
14
-
15
- class Plugin_Usage_Tracker {
16
-
17
- private $wisdom_version = '1.2.3';
18
- private $home_url = '';
19
- private $plugin_file = '';
20
- private $plugin_name = '';
21
- private $options = array();
22
- private $require_optin = true;
23
- private $include_goodbye_form = true;
24
- private $marketing = false;
25
- private $collect_email = false;
26
- private $what_am_i = 'plugin';
27
- private $theme_allows_tracking = 0;
28
-
29
- /**
30
- * Class constructor
31
- *
32
- * @param $_home_url The URL to the site we're sending data to
33
- * @param $_plugin_file The file path for this plugin
34
- * @param $_options Plugin options to track
35
- * @param $_require_optin Whether user opt-in is required (always required on WordPress.org)
36
- * @param $_include_goodbye_form Whether to include a form when the user deactivates
37
- * @param $_marketing Marketing method:
38
- * 0: Don't collect email addresses
39
- * 1: Request permission same time as tracking opt-in
40
- * 2: Request permission after opt-in
41
- */
42
- public function __construct(
43
- $_plugin_file,
44
- $_home_url,
45
- $_options,
46
- $_require_optin=true,
47
- $_include_goodbye_form=true,
48
- $_marketing=false ) {
49
-
50
- $this->plugin_file = $_plugin_file;
51
- $this->home_url = trailingslashit( $_home_url );
52
-
53
- // If the filename is 'functions' then we're tracking a theme
54
- if( basename( $this->plugin_file, '.php' ) != 'functions' ) {
55
- $this->plugin_name = basename( $this->plugin_file, '.php' );
56
- } else {
57
- $this->what_am_i = 'theme';
58
- $theme = wp_get_theme();
59
- if( $theme->Name ) {
60
- $this->plugin_name = sanitize_text_field( $theme->Name );
61
- }
62
- }
63
-
64
- $this->options = $_options;
65
- $this->require_optin = $_require_optin;
66
- $this->include_goodbye_form = $_include_goodbye_form;
67
- $this->marketing = $_marketing;
68
-
69
- // Only use this on switching theme
70
- $this->theme_allows_tracking = get_theme_mod( 'wisdom-allow-tracking', 0 );
71
-
72
- // Schedule / deschedule tracking when activated / deactivated
73
- if( $this->what_am_i == 'theme' ) {
74
- // Need to think about scheduling for sites that have already activated the theme
75
- add_action( 'after_switch_theme', array( $this, 'schedule_tracking' ) );
76
- add_action( 'switch_theme', array( $this, 'deactivate_this_plugin' ) );
77
- } else {
78
- register_activation_hook( $this->plugin_file, array( $this, 'schedule_tracking' ) );
79
- register_deactivation_hook( $this->plugin_file, array( $this, 'deactivate_this_plugin' ) );
80
- }
81
-
82
- // Get it going
83
- $this->init();
84
-
85
- }
86
-
87
- public function init() {
88
- // Check marketing
89
- if( $this->marketing == 3 ) {
90
- $this->set_can_collect_email( true, $this->plugin_name );
91
- }
92
-
93
- // Check whether opt-in is required
94
- // If not, then tracking is allowed
95
- if( ! $this->require_optin ) {
96
- $this->set_can_collect_email( true, $this->plugin_name );
97
- $this->set_is_tracking_allowed( true );
98
- $this->update_block_notice();
99
- $this->do_tracking();
100
- }
101
-
102
- // Hook our do_tracking function to the weekly action
103
- add_filter( 'cron_schedules', array( $this, 'schedule_weekly_event' ) );
104
- // It's called weekly, but in fact it could be daily, weekly or monthly
105
- add_action( 'put_do_weekly_action', array( $this, 'do_tracking' ) );
106
-
107
- // Use this action for local testing
108
- // add_action( 'admin_init', array( $this, 'do_tracking' ) );
109
-
110
- // Display the admin notice on activation
111
- add_action( 'admin_notices', array( $this, 'optin_notice' ) );
112
- add_action( 'admin_notices', array( $this, 'marketing_notice' ) );
113
-
114
- // Deactivation
115
- add_filter( 'plugin_action_links_' . plugin_basename( $this->plugin_file ), array( $this, 'filter_action_links' ) );
116
- add_action( 'admin_footer-plugins.php', array( $this, 'goodbye_ajax' ) );
117
- add_action( 'wp_ajax_goodbye_form', array( $this, 'goodbye_form_callback' ) );
118
-
119
- }
120
-
121
- /**
122
- * When the plugin is activated
123
- * Create scheduled event
124
- * And check if tracking is enabled - perhaps the plugin has been reactivated
125
- *
126
- * @since 1.0.0
127
- */
128
- public function schedule_tracking() {
129
- if ( ! wp_next_scheduled( 'put_do_weekly_action' ) ) {
130
- $schedule = $this->get_schedule();
131
- wp_schedule_event( time(), $schedule, 'put_do_weekly_action' );
132
- }
133
- $this->do_tracking( true );
134
- }
135
-
136
- /**
137
- * Create weekly schedule
138
- *
139
- * @since 1.2.3
140
- */
141
- public function schedule_weekly_event( $schedules ) {
142
- $schedules['weekly'] = array(
143
- 'interval' => 604800,
144
- 'display' => __( 'Once Weekly' )
145
- );
146
- $schedules['monthly'] = array(
147
- 'interval' => 2635200,
148
- 'display' => __( 'Once Monthly' )
149
- );
150
- return $schedules;
151
- }
152
-
153
- /**
154
- * Get how frequently data is tracked back
155
- *
156
- * @since 1.2.3
157
- */
158
- public function get_schedule() {
159
- // Could be daily, weekly or monthly
160
- $schedule = apply_filters( 'wisdom_filter_schedule', 'monthly' );
161
- return $schedule;
162
- }
163
-
164
- /**
165
- * This is our function to get everything going
166
- * Check that user has opted in
167
- * Collect data
168
- * Then send it back
169
- *
170
- * @since 1.0.0
171
- * @param $force Force tracking if it's not time
172
- */
173
- public function do_tracking( $force=false ) {
174
-
175
- // If the home site hasn't been defined, we just drop out. Nothing much we can do.
176
- if ( ! $this->home_url ) {
177
- return;
178
- }
179
-
180
- // Check to see if the user has opted in to tracking
181
- $allow_tracking = $this->get_is_tracking_allowed();
182
- if( ! $allow_tracking ) {
183
- return;
184
- }
185
-
186
- // Check to see if it's time to track
187
- $track_time = $this->get_is_time_to_track();
188
- if( ! $track_time && ! $force ) {
189
- return;
190
- }
191
-
192
- $this->set_admin_email();
193
-
194
- // Get our data
195
- $body = $this->get_data();
196
-
197
- // Send the data
198
- $this->send_data( $body );
199
-
200
- }
201
-
202
- /**
203
- * We hook this to admin_init when the user accepts tracking
204
- * Ensures the email address is available
205
- *
206
- * @since 1.2.1
207
- */
208
- public function force_tracking() {
209
- $this->do_tracking( true ); // Run this straightaway
210
- }
211
-
212
- /**
213
- * Send the data to the home site
214
- *
215
- * @since 1.0.0
216
- */
217
- public function send_data( $body ) {
218
-
219
- $request = wp_remote_post(
220
- esc_url( $this->home_url . '?usage_tracker=hello' ),
221
- array(
222
- 'method' => 'POST',
223
- 'timeout' => 20,
224
- 'redirection' => 5,
225
- 'httpversion' => '1.1',
226
- 'blocking' => true,
227
- 'body' => $body,
228
- 'user-agent' => 'PUT/1.0.0; ' . home_url()
229
- )
230
- );
231
-
232
- $this->set_track_time();
233
-
234
- if( is_wp_error( $request ) ) {
235
- return $request;
236
- }
237
-
238
- }
239
-
240
- /**
241
- * Here we collect most of the data
242
- *
243
- * @since 1.0.0
244
- */
245
- public function get_data() {
246
-
247
- // Use this to pass error messages back if necessary
248
- $body['message'] = '';
249
-
250
- // Use this array to send data back
251
- $body = array(
252
- 'plugin_slug' => sanitize_text_field( $this->plugin_name ),
253
- 'url' => home_url(),
254
- 'site_name' => get_bloginfo( 'name' ),
255
- 'site_version' => get_bloginfo( 'version' ),
256
- 'site_language' => get_bloginfo( 'language' ),
257
- 'charset' => get_bloginfo( 'charset' ),
258
- 'wisdom_version' => $this->wisdom_version,
259
- 'php_version' => phpversion(),
260
- 'multisite' => is_multisite(),
261
- 'file_location' => __FILE__,
262
- 'product_type' => esc_html( $this->what_am_i )
263
- );
264
-
265
- // Collect the email if the correct option has been set
266
- if( $this->get_can_collect_email() ) {
267
- $body['email'] = $this->get_admin_email();
268
- }
269
- $body['marketing_method'] = $this->marketing;
270
-
271
- $body['server'] = isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '';
272
-
273
- // Retrieve current plugin information
274
- if( ! function_exists( 'get_plugins' ) ) {
275
- include ABSPATH . '/wp-admin/includes/plugin.php';
276
- }
277
-
278
- $plugins = array_keys( get_plugins() );
279
- $active_plugins = get_option( 'active_plugins', array() );
280
-
281
- foreach ( $plugins as $key => $plugin ) {
282
- if ( in_array( $plugin, $active_plugins ) ) {
283
- // Remove active plugins from list so we can show active and inactive separately
284
- unset( $plugins[$key] );
285
- }
286
- }
287
-
288
- $body['active_plugins'] = $active_plugins;
289
- $body['inactive_plugins'] = $plugins;
290
-
291
- // Check text direction
292
- $body['text_direction'] = 'LTR';
293
- if( function_exists( 'is_rtl' ) ) {
294
- if( is_rtl() ) {
295
- $body['text_direction'] = 'RTL';
296
- }
297
- } else {
298
- $body['text_direction'] = 'not set';
299
- }
300
-
301
- /**
302
- * Get our plugin data
303
- * Currently we grab plugin name and version
304
- * Or, return a message if the plugin data is not available
305
- * @since 1.0.0
306
- */
307
- $plugin = $this->plugin_data();
308
- $body['status'] = 'Active'; // Never translated
309
- if( empty( $plugin ) ) {
310
- // We can't find the plugin data
311
- // Send a message back to our home site
312
- $body['message'] .= __( 'We can\'t detect any product information. This is most probably because you have not included the code snippet.', 'singularity' );
313
- $body['status'] = 'Data not found'; // Never translated
314
- } else {
315
- if( isset( $plugin['Name'] ) ) {
316
- $body['plugin'] = sanitize_text_field( $plugin['Name'] );
317
- }
318
- if( isset( $plugin['Version'] ) ) {
319
- $body['version'] = sanitize_text_field( $plugin['Version'] );
320
- }
321
-
322
- }
323
-
324
- /**
325
- * Get our plugin options
326
- * @since 1.0.0
327
- */
328
- $options = $this->options;
329
- $plugin_options = array();
330
- if( ! empty( $options ) && is_array( $options ) ) {
331
- foreach( $options as $option ) {
332
- $fields = get_option( $option );
333
- // Check for permission to send this option
334
- if( isset( $fields['wisdom_registered_setting'] ) ) {
335
- foreach( $fields as $key=>$value ) {
336
- $plugin_options[$key] = $value;
337
- }
338
- }
339
- }
340
- }
341
- $body['plugin_options'] = $this->options; // Returns array
342
- $body['plugin_options_fields'] = $plugin_options; // Returns object
343
-
344
- /**
345
- * Get our theme data
346
- * Currently we grab theme name and version
347
- * @since 1.0.0
348
- */
349
- $theme = wp_get_theme();
350
- if( $theme->Name ) {
351
- $body['theme'] = sanitize_text_field( $theme->Name );
352
- }
353
- if( $theme->Version ) {
354
- $body['theme_version'] = sanitize_text_field( $theme->Version );
355
- }
356
- if( $theme->Template ) {
357
- $body['theme_parent'] = sanitize_text_field( $theme->Template );
358
- }
359
-
360
- // Return the data
361
- return $body;
362
-
363
- }
364
-
365
- /**
366
- * Return plugin data
367
- * @since 1.0.0
368
- */
369
- public function plugin_data() {
370
- // Being cautious here
371
- if( ! function_exists( 'get_plugin_data' ) ) {
372
- include ABSPATH . '/wp-admin/includes/plugin.php';
373
- }
374
- // Retrieve current plugin information
375
- $plugin = get_plugin_data( $this->plugin_file );
376
- return $plugin;
377
- }
378
-
379
- /**
380
- * Deactivating plugin
381
- * @since 1.0.0
382
- */
383
- public function deactivate_this_plugin() {
384
- // Check to see if the user has opted in to tracking
385
- if( $this->what_am_i == 'theme' ) {
386
- $allow_tracking = $this->theme_allows_tracking;
387
- } else {
388
- $allow_tracking = $this->get_is_tracking_allowed();
389
- }
390
-
391
- if( ! $allow_tracking ) {
392
- return;
393
- }
394
-
395
- $body = $this->get_data();
396
- $body['status'] = 'Deactivated'; // Never translated
397
- $body['deactivated_date'] = time();
398
-
399
- // Add deactivation form data
400
- if( false !== get_option( 'wisdom_deactivation_reason_' . $this->plugin_name ) ) {
401
- $body['deactivation_reason'] = get_option( 'wisdom_deactivation_reason_' . $this->plugin_name );
402
- }
403
- if( false !== get_option( 'wisdom_deactivation_details_' . $this->plugin_name ) ) {
404
- $body['deactivation_details'] = get_option( 'wisdom_deactivation_details_' . $this->plugin_name );
405
- }
406
-
407
- $this->send_data( $body );
408
- // Clear scheduled update
409
- wp_clear_scheduled_hook( 'put_do_weekly_action' );
410
-
411
- // Clear the wisdom_last_track_time value for this plugin
412
- // @since 1.2.2
413
- $track_time = get_option( 'wisdom_last_track_time' );
414
- if( isset( $track_time[$this->plugin_name]) ) {
415
- unset( $track_time[$this->plugin_name] );
416
- }
417
- update_option( 'wisdom_last_track_time', $track_time );
418
-
419
- }
420
-
421
- /**
422
- * Is tracking allowed?
423
- * @since 1.0.0
424
- */
425
- public function get_is_tracking_allowed() {
426
-
427
- // First, check if the user has changed their mind and opted out of tracking
428
- if( $this->has_user_opted_out() ) {
429
- $this->set_is_tracking_allowed( false, $this->plugin_name );
430
- return false;
431
- }
432
-
433
- if( $this->what_am_i == 'theme' ) {
434
-
435
- $mod = get_theme_mod( 'wisdom-allow-tracking', 0 );
436
- if( $mod ) {
437
- return true;
438
- }
439
-
440
- } else {
441
-
442
- // The wisdom_allow_tracking option is an array of plugins that are being tracked
443
- $allow_tracking = get_option( 'wisdom_allow_tracking' );
444
- // If this plugin is in the array, then tracking is allowed
445
- if( isset( $allow_tracking[$this->plugin_name] ) ) {
446
- return true;
447
- }
448
-
449
- }
450
-
451
- return false;
452
- }
453
-
454
- /**
455
- * Set if tracking is allowed
456
- * Option is an array of all plugins with tracking permitted
457
- * More than one plugin may be using the tracker
458
- * @since 1.0.0
459
- * @param $is_allowed Boolean true if tracking is allowed, false if not
460
- */
461
- public function set_is_tracking_allowed( $is_allowed, $plugin=null ) {
462
-
463
- if( empty( $plugin ) ) {
464
- $plugin = $this->plugin_name;
465
- }
466
-
467
- // The wisdom_allow_tracking option is an array of plugins that are being tracked
468
- $allow_tracking = get_option( 'wisdom_allow_tracking' );
469
-
470
- // If the user has decided to opt out
471
- if( $this->has_user_opted_out() ) {
472
- if( $this->what_am_i == 'theme' ) {
473
- set_theme_mod( 'wisdom-allow-tracking', 0 );
474
- } else {
475
- if( isset( $allow_tracking[$plugin] ) ) {
476
- unset( $allow_tracking[$plugin] );
477
- }
478
- }
479
-
480
- } else if( $is_allowed || ! $this->require_optin ) {
481
- // If the user has agreed to allow tracking or if opt-in is not required
482
-
483
- if( $this->what_am_i == 'theme' ) {
484
- set_theme_mod( 'wisdom-allow-tracking', 1 );
485
- } else {
486
- if( empty( $allow_tracking ) || ! is_array( $allow_tracking ) ) {
487
- // If nothing exists in the option yet, start a new array with the plugin name
488
- $allow_tracking = array( $plugin => $plugin );
489
- } else {
490
- // Else add the plugin name to the array
491
- $allow_tracking[$plugin] = $plugin;
492
- }
493
- }
494
-
495
- } else {
496
-
497
- if( $this->what_am_i == 'theme' ) {
498
- set_theme_mod( 'wisdom-allow-tracking', 0 );
499
- } else {
500
- if( isset( $allow_tracking[$plugin] ) ) {
501
- unset( $allow_tracking[$plugin] );
502
- }
503
- }
504
-
505
- }
506
-
507
- update_option( 'wisdom_allow_tracking', $allow_tracking );
508
-
509
- }
510
-
511
- /**
512
- * Has the user opted out of allowing tracking?
513
- * Note that themes are opt in / plugins are opt out
514
- * @since 1.1.0
515
- * @return Boolean
516
- */
517
- public function has_user_opted_out() {
518
- // Different opt-out methods for plugins and themes
519
- if( $this->what_am_i == 'theme' ) {
520
- // Look for the theme mod
521
- $mod = get_theme_mod( 'wisdom-allow-tracking', 0 );
522
- if( false === $mod ) {
523
- // If the theme mod is not set, then return true - the user has opted out
524
- return true;
525
- }
526
- } else {
527
- // Iterate through the options that are being tracked looking for wisdom_opt_out setting
528
- if( ! empty( $this->options ) ) {
529
- foreach( $this->options as $option_name ) {
530
- // Check each option
531
- $options = get_option( $option_name );
532
- // If we find the setting, return true
533
- if( ! empty( $options['wisdom_opt_out'] ) ) {
534
- return true;
535
- }
536
- }
537
- }
538
- }
539
- return false;
540
- }
541
-
542
- /**
543
- * Check if it's time to track
544
- * @since 1.1.1
545
- */
546
- public function get_is_time_to_track() {
547
- // Let's see if we're due to track this plugin yet
548
- $track_times = get_option( 'wisdom_last_track_time', array() );
549
- if( ! isset( $track_times[$this->plugin_name] ) ) {
550
- // If we haven't set a time for this plugin yet, then we must track it
551
- return true;
552
- } else {
553
- // If the time is set, let's get our schedule and check if it's time to track
554
- $schedule = $this->get_schedule();
555
- if( $schedule == 'daily' ) {
556
- $period = 'day';
557
- } else if( $schedule == 'weekly' ) {
558
- $period = 'week';
559
- } else {
560
- $period = 'month';
561
- }
562
- if( $track_times[$this->plugin_name] < strtotime( '-1 ' . $period ) ) {
563
- return true;
564
- }
565
- }
566
- return false;
567
- }
568
-
569
- /**
570
- * Record the time we send tracking data
571
- * @since 1.1.1
572
- */
573
- public function set_track_time() {
574
- // We've tracked, so record the time
575
- $track_times = get_option( 'wisdom_last_track_time', array() );
576
- // Set different times according to plugin, in case we are tracking multiple plugins
577
- $track_times[$this->plugin_name] = time();
578
- update_option( 'wisdom_last_track_time', $track_times );
579
- }
580
-
581
- /**
582
- * Set if we should block the opt-in notice for this plugin
583
- * Option is an array of all plugins that have received a response from the user
584
- * @since 1.0.0
585
- */
586
- public function update_block_notice( $plugin=null ) {
587
- if( empty( $plugin ) ) {
588
- $plugin = $this->plugin_name;
589
- }
590
- $block_notice = get_option( 'wisdom_block_notice' );
591
- if( empty( $block_notice ) || ! is_array( $block_notice ) ) {
592
- // If nothing exists in the option yet, start a new array with the plugin name
593
- $block_notice = array( $plugin => $plugin );
594
- } else {
595
- // Else add the plugin name to the array
596
- $block_notice[$plugin] = $plugin;
597
- }
598
- update_option( 'wisdom_block_notice', $block_notice );
599
- }
600
-
601
- /**
602
- * Can we collect the email address?
603
- * @since 1.0.0
604
- */
605
- public function get_can_collect_email() {
606
- // The wisdom_collect_email option is an array of plugins that are being tracked
607
- $collect_email = get_option( 'wisdom_collect_email' );
608
- // If this plugin is in the array, then we can collect the email address
609
- if( isset( $collect_email[$this->plugin_name] ) ) {
610
- return true;
611
- }
612
- return false;
613
- }
614
-
615
- /**
616
- * Set if user has allowed us to collect their email address
617
- * Option is an array of all plugins with email collection permitted
618
- * More than one plugin may be using the tracker
619
- * @since 1.0.0
620
- * @param $can_collect Boolean true if collection is allowed, false if not
621
- */
622
- public function set_can_collect_email( $can_collect, $plugin=null ) {
623
- if( empty( $plugin ) ) {
624
- $plugin = $this->plugin_name;
625
- }
626
- // The wisdom_collect_email option is an array of plugins that are being tracked
627
- $collect_email = get_option( 'wisdom_collect_email' );
628
- // If the user has agreed to allow tracking or if opt-in is not required
629
- if( $can_collect ) {
630
- if( empty( $collect_email ) || ! is_array( $collect_email ) ) {
631
- // If nothing exists in the option yet, start a new array with the plugin name
632
- $collect_email = array( $plugin => $plugin );
633
- } else {
634
- // Else add the plugin name to the array
635
- $collect_email[$plugin] = $plugin;
636
- }
637
- } else {
638
- if( isset( $collect_email[$plugin] ) ) {
639
- unset( $collect_email[$plugin] );
640
- }
641
- }
642
- update_option( 'wisdom_collect_email', $collect_email );
643
- }
644
-
645
- /**
646
- * Get the correct email address to use
647
- * @since 1.1.2
648
- * @return Email address
649
- */
650
- public function get_admin_email() {
651
- // The wisdom_collect_email option is an array of plugins that are being tracked
652
- $email = get_option( 'wisdom_admin_emails' );
653
- // If this plugin is in the array, then we can collect the email address
654
- if( isset( $email[$this->plugin_name] ) ) {
655
- return $email[$this->plugin_name];
656
- }
657
- return false;
658
- }
659
-
660
- /**
661
- * Set the correct email address to use
662
- * There might be more than one admin on the site
663
- * So we only use the first admin's email address
664
- * @param $email Email address to set
665
- * @param $plugin Plugin name to set email address for
666
- * @since 1.1.2
667
- */
668
- public function set_admin_email( $email=null, $plugin=null ) {
669
- if( empty( $plugin ) ) {
670
- $plugin = $this->plugin_name;
671
- }
672
- // If no email address passed, try to get the current user's email
673
- if( empty( $email ) ) {
674
- // Have to check that current user object is available
675
- if( function_exists( 'wp_get_current_user' ) ) {
676
- $current_user = wp_get_current_user();
677
- $email = $current_user->user_email;
678
- }
679
- }
680
- // The wisdom_admin_emails option is an array of admin email addresses
681
- $admin_emails = get_option( 'wisdom_admin_emails' );
682
- if( empty( $admin_emails ) || ! is_array( $admin_emails ) ) {
683
- // If nothing exists in the option yet, start a new array with the plugin name
684
- $admin_emails = array( $plugin => sanitize_email( $email ) );
685
- } else if( empty( $admin_emails[$plugin] ) ) {
686
- // Else add the email address to the array, if not already set
687
- $admin_emails[$plugin] = sanitize_email( $email );
688
- }
689
- update_option( 'wisdom_admin_emails', $admin_emails );
690
- }
691
-
692
- /**
693
- * Display the admin notice to users to allow them to opt in
694
- *
695
- * @since 1.0.0
696
- */
697
- public function optin_notice() {
698
- // Check for plugin args
699
- if( isset( $_GET['plugin'] ) && isset( $_GET['plugin_action'] ) ) {
700
- $plugin = sanitize_text_field( $_GET['plugin'] );
701
- $action = sanitize_text_field( $_GET['plugin_action'] );
702
- if( $action == 'yes' ) {
703
- $this->set_is_tracking_allowed( true, $plugin );
704
- // Run this straightaway
705
- add_action( 'admin_init', array( $this, 'force_tracking' ) );
706
- } else {
707
- $this->set_is_tracking_allowed( false, $plugin );
708
- }
709
- $this->update_block_notice( $plugin );
710
- }
711
-
712
- // Check whether to block the notice, e.g. because we're in a local environment
713
- // wisdom_block_notice works the same as wisdom_allow_tracking, an array of plugin names
714
- $block_notice = get_option( 'wisdom_block_notice' );
715
-
716
- if( isset( $block_notice[$this->plugin_name] ) ) {
717
- return;
718
- }
719
-
720
- if ( ! current_user_can( 'manage_options' ) ) {
721
- return;
722
- }
723
-
724
- // @credit EDD
725
- // Don't bother asking user to opt in if they're in local dev
726
- if ( stristr( network_site_url( '/' ), 'dev' ) !== false || stristr( network_site_url( '/' ), 'localhost' ) !== false || stristr( network_site_url( '/' ), ':8888' ) !== false ) {
727
- $this->update_block_notice();
728
- } else {
729
-
730
- // Display the notice requesting permission to track
731
- // Retrieve current plugin information
732
- $plugin = $this->plugin_data();
733
- $plugin_name = $plugin['Name'];
734
-
735
- // Args to add to query if user opts in to tracking
736
- $yes_args = array(
737
- 'plugin' => $this->plugin_name,
738
- 'plugin_action' => 'yes'
739
- );
740
-
741
- // Decide how to request permission to collect email addresses
742
- if( $this->marketing == 1 ) {
743
- // Option 1 combines permissions to track and collect email
744
- $yes_args['marketing_optin'] = 'yes';
745
- } else if( $this->marketing == 2 ) {
746
- // Option 2 enables a second notice that fires after the user opts in to tracking
747
- $yes_args['marketing'] = 'yes';
748
- }
749
- $url_yes = add_query_arg( $yes_args );
750
- $url_no = add_query_arg( array(
751
- 'plugin' => $this->plugin_name,
752
- 'plugin_action' => 'no'
753
- ) );
754
-
755
- // Decide on notice text
756
- if( $this->marketing != 1 ) {
757
- // Standard notice text
758
- $notice_text = sprintf(
759
- __( 'Thank you for installing our %1$s. We would like to track its usage on your site. We don\'t record any sensitive data, only information regarding the WordPress environment and %1$s settings, which we will use to help us make improvements to the %1$s. Tracking is completely optional.', 'singularity' ),
760
- $this->what_am_i
761
- );
762
- } else {
763
- // If we have option 1 for marketing, we include reference to sending product information here
764
- $notice_text = sprintf(
765
- __( 'Thank you for installing our %1$s. We\'d like your permission to track its usage on your site and subscribe you to our newsletter. We won\'t record any sensitive data, only information regarding the WordPress environment and %1$s settings, which we will use to help us make improvements to the %1$s. Tracking is completely optional.', 'singularity' ),
766
- $this->what_am_i
767
- );
768
- }
769
- // And we allow you to filter the text anyway
770
- $notice_text = apply_filters( 'wisdom_notice_text_' . esc_attr( $this->plugin_name ), $notice_text ); ?>
771
-
772
- <div class="notice notice-info updated put-dismiss-notice">
773
- <p><?php echo '<strong>' . esc_html( $plugin_name ) . '</strong>'; ?></p>
774
- <p><?php echo esc_html( $notice_text ); ?></p>
775
- <p>
776
- <a href="<?php echo esc_url( $url_yes ); ?>" class="button-secondary"><?php _e( 'Allow', 'singularity' ); ?></a>
777
- <a href="<?php echo esc_url( $url_no ); ?>" class="button-secondary"><?php _e( 'Do Not Allow', 'singularity' ); ?></a>
778
- </p>
779
- </div>
780
- <?php
781
- }
782
-
783
- }
784
-
785
- /**
786
- * Display the marketing notice to users if enabled
787
- * Only displays after the user has opted in to tracking
788
- *
789
- * @since 1.0.0
790
- */
791
- public function marketing_notice() {
792
- // Check if user has opted in to marketing
793
- if( isset( $_GET['marketing_optin'] ) ) {
794
- // Set marketing optin
795
- $this->set_can_collect_email( sanitize_text_field( $_GET['marketing_optin'] ), $this->plugin_name );
796
- // Do tracking
797
- $this->do_tracking( true );
798
- } else if( isset( $_GET['marketing'] ) && $_GET['marketing']=='yes' ) {
799
- // Display the notice requesting permission to collect email address
800
- // Retrieve current plugin information
801
- $plugin = $this->plugin_data();
802
- $plugin_name = $plugin['Name'];
803
-
804
- $url_yes = add_query_arg( array(
805
- 'plugin' => $this->plugin_name,
806
- 'marketing_optin' => 'yes'
807
- ) );
808
- $url_no = add_query_arg( array(
809
- 'plugin' => $this->plugin_name,
810
- 'marketing_optin' => 'no'
811
- ) );
812
-
813
- $marketing_text = sprintf(
814
- __( 'Thank you for opting in to tracking. Would you like to receive occasional news about this %s, including details of new features and special offers?', 'singularity' ),
815
- $this->what_am_i
816
- );
817
- $marketing_text = apply_filters( 'wisdom_marketing_text_' . esc_attr( $this->plugin_name ), $marketing_text ); ?>
818
-
819
- <div class="notice notice-info updated put-dismiss-notice">
820
- <p><?php echo '<strong>' . esc_html( $plugin_name ) . '</strong>'; ?></p>
821
- <p><?php echo esc_html( $marketing_text ); ?></p>
822
- <p>
823
- <a href="<?php echo esc_url( $url_yes ); ?>" data-putnotice="yes" class="button-secondary"><?php _e( 'Yes Please', 'singularity' ); ?></a>
824
- <a href="<?php echo esc_url( $url_no ); ?>" data-putnotice="no" class="button-secondary"><?php _e( 'No Thank You', 'singularity' ); ?></a>
825
- </p>
826
- </div>
827
- <?php }
828
- }
829
-
830
- /**
831
- * Filter the deactivation link to allow us to present a form when the user deactivates the plugin
832
- * @since 1.0.0
833
- */
834
- public function filter_action_links( $links ) {
835
- // Check to see if the user has opted in to tracking
836
- if( ! $this->get_is_tracking_allowed() ) {
837
- return $links;
838
- }
839
- if( isset( $links['deactivate'] ) && $this->include_goodbye_form ) {
840
- $deactivation_link = $links['deactivate'];
841
- // Insert an onClick action to allow form before deactivating
842
- $deactivation_link = str_replace( '<a ', '<div class="put-goodbye-form-wrapper"><span class="put-goodbye-form" id="put-goodbye-form-' . esc_attr( $this->plugin_name ) . '"></span></div><a onclick="javascript:event.preventDefault();" id="put-goodbye-link-' . esc_attr( $this->plugin_name ) . '" ', $deactivation_link );
843
- $links['deactivate'] = $deactivation_link;
844
- }
845
- return $links;
846
- }
847
-
848
- /*
849
- * Form text strings
850
- * These are non-filterable and used as fallback in case filtered strings aren't set correctly
851
- * @since 1.0.0
852
- */
853
- public function form_default_text() {
854
- $form = array();
855
- $form['heading'] = __( 'Sorry to see you go', 'singularity' );
856
- $form['body'] = __( 'Before you deactivate the plugin, would you quickly give us your reason for doing so?', 'singularity' );
857
- $form['options'] = array(
858
- __( 'Set up is too difficult', 'singularity' ),
859
- __( 'Lack of documentation', 'singularity' ),
860
- __( 'Not the features I wanted', 'singularity' ),
861
- __( 'Found a better plugin', 'singularity' ),
862
- __( 'Installed by mistake', 'singularity' ),
863
- __( 'Only required temporarily', 'singularity' ),
864
- __( 'Didn\'t work', 'singularity' )
865
- );
866
- $form['details'] = __( 'Details (optional)', 'singularity' );
867
- return $form;
868
- }
869
-
870
- /**
871
- * Form text strings
872
- * These can be filtered
873
- * The filter hook must be unique to the plugin
874
- * @since 1.0.0
875
- */
876
- public function form_filterable_text() {
877
- $form = $this->form_default_text();
878
- return apply_filters( 'wisdom_form_text_' . esc_attr( $this->plugin_name ), $form );
879
- }
880
-
881
- /**
882
- * Form text strings
883
- * These can be filtered
884
- * @since 1.0.0
885
- */
886
- public function goodbye_ajax() {
887
- // Get our strings for the form
888
- $form = $this->form_filterable_text();
889
- if( ! isset( $form['heading'] ) || ! isset( $form['body'] ) || ! isset( $form['options'] ) || ! is_array( $form['options'] ) || ! isset( $form['details'] ) ) {
890
- // If the form hasn't been filtered correctly, we revert to the default form
891
- $form = $this->form_default_text();
892
- }
893
- // Build the HTML to go in the form
894
- $html = '<div class="put-goodbye-form-head"><strong>' . esc_html( $form['heading'] ) . '</strong></div>';
895
- $html .= '<div class="put-goodbye-form-body"><p>' . esc_html( $form['body'] ) . '</p>';
896
- if( is_array( $form['options'] ) ) {
897
- $html .= '<div class="put-goodbye-options"><p>';
898
- foreach( $form['options'] as $option ) {
899
- $html .= '<input type="checkbox" name="put-goodbye-options[]" id="' . str_replace( " ", "", esc_attr( $option ) ) . '" value="' . esc_attr( $option ) . '"> <label for="' . str_replace( " ", "", esc_attr( $option ) ) . '">' . esc_attr( $option ) . '</label><br>';
900
- }
901
- $html .= '</p><label for="put-goodbye-reasons">' . esc_html( $form['details'] ) .'</label><textarea name="put-goodbye-reasons" id="put-goodbye-reasons" rows="2" style="width:100%"></textarea>';
902
- $html .= '</div><!-- .put-goodbye-options -->';
903
- }
904
- $html .= '</div><!-- .put-goodbye-form-body -->';
905
- $html .= '<p class="deactivating-spinner"><span class="spinner"></span> ' . __( 'Submitting form', 'singularity' ) . '</p>';
906
- ?>
907
- <div class="put-goodbye-form-bg"></div>
908
- <style type="text/css">
909
- .put-form-active .put-goodbye-form-bg {
910
- background: rgba( 0, 0, 0, .5 );
911
- position: fixed;
912
- top: 0;
913
- left: 0;
914
- width: 100%;
915
- height: 100%;
916
- }
917
- .put-goodbye-form-wrapper {
918
- position: relative;
919
- z-index: 999;
920
- display: none;
921
- }
922
- .put-form-active .put-goodbye-form-wrapper {
923
- display: block;
924
- }
925
- .put-goodbye-form {
926
- display: none;
927
- }
928
- .put-form-active .put-goodbye-form {
929
- position: absolute;
930
- bottom: 30px;
931
- left: 0;
932
- max-width: 400px;
933
- background: #fff;
934
- white-space: normal;
935
- }
936
- .put-goodbye-form-head {
937
- background: #0073aa;
938
- color: #fff;
939
- padding: 8px 18px;
940
- }
941
- .put-goodbye-form-body {
942
- padding: 8px 18px;
943
- color: #444;
944
- }
945
- .deactivating-spinner {
946
- display: none;
947
- }
948
- .deactivating-spinner .spinner {
949
- float: none;
950
- margin: 4px 4px 0 18px;
951
- vertical-align: bottom;
952
- visibility: visible;
953
- }
954
- .put-goodbye-form-footer {
955
- padding: 8px 18px;
956
- }
957
- </style>
958
- <script>
959
- jQuery(document).ready(function($){
960
- $("#put-goodbye-link-<?php echo esc_attr( $this->plugin_name ); ?>").on("click",function(){
961
- // We'll send the user to this deactivation link when they've completed or dismissed the form
962
- var url = document.getElementById("put-goodbye-link-<?php echo esc_attr( $this->plugin_name ); ?>");
963
- $('body').toggleClass('put-form-active');
964
- $("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").fadeIn();
965
- $("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").html( '<?php echo $html; ?>' + '<div class="put-goodbye-form-footer"><p><a id="put-submit-form" class="button primary" href="#"><?php _e( 'Submit and Deactivate', 'singularity' ); ?></a>&nbsp;<a class="secondary button" href="'+url+'"><?php _e( 'Just Deactivate', 'singularity' ); ?></a></p></div>');
966
- $('#put-submit-form').on('click', function(e){
967
- // As soon as we click, the body of the form should disappear
968
- $("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .put-goodbye-form-body").fadeOut();
969
- $("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .put-goodbye-form-footer").fadeOut();
970
- // Fade in spinner
971
- $("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?> .deactivating-spinner").fadeIn();
972
- e.preventDefault();
973
- var values = new Array();
974
- $.each($("input[name='put-goodbye-options[]']:checked"), function(){
975
- values.push($(this).val());
976
- });
977
- var details = $('#put-goodbye-reasons').val();
978
- var data = {
979
- 'action': 'goodbye_form',
980
- 'values': values,
981
- 'details': details,
982
- 'security': "<?php echo wp_create_nonce ( 'wisdom_goodbye_form' ); ?>",
983
- 'dataType': "json"
984
- }
985
- $.post(
986
- ajaxurl,
987
- data,
988
- function(response){
989
- // Redirect to original deactivation URL
990
- window.location.href = url;
991
- }
992
- );
993
- });
994
- // If we click outside the form, the form will close
995
- $('.put-goodbye-form-bg').on('click',function(){
996
- $("#put-goodbye-form-<?php echo esc_attr( $this->plugin_name ); ?>").fadeOut();
997
- $('body').removeClass('put-form-active');
998
- });
999
- });
1000
- });
1001
- </script>
1002
- <?php }
1003
-
1004
- /**
1005
- * AJAX callback when the form is submitted
1006
- * @since 1.0.0
1007
- */
1008
- public function goodbye_form_callback() {
1009
- check_ajax_referer( 'wisdom_goodbye_form', 'security' );
1010
- if( isset( $_POST['values'] ) ) {
1011
- $values = json_encode( wp_unslash( $_POST['values'] ) );
1012
- update_option( 'wisdom_deactivation_reason_' . $this->plugin_name, $values );
1013
- }
1014
- if( isset( $_POST['details'] ) ) {
1015
- $details = sanitize_text_field( $_POST['details'] );
1016
- update_option( 'wisdom_deactivation_details_' . $this->plugin_name, $details );
1017
- }
1018
- $this->do_tracking(); // Run this straightaway
1019
- echo 'success';
1020
- wp_die();
1021
- }
1022
-
1023
- }
1024
-
1025
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
uk-cookie-consent.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Cookie Consent
4
  Plugin URI: https://catapultthemes.com/cookie-consent/
5
  Description: The only cookie consent plugin you'll ever need.
6
- Version: 2.3.8
7
  Author: Catapult_Themes
8
  Author URI: https://catapultthemes.com/
9
  Text Domain: uk-cookie-consent
@@ -75,25 +75,3 @@ function ctcc_create_policy_page() {
75
  }
76
  }
77
  register_activation_hook ( __FILE__, 'ctcc_create_policy_page' );
78
-
79
- /**
80
- * This function allows you to track usage of your plugin
81
- * Place in your main plugin file
82
- * Refer to https://wisdomplugin.com/support for help
83
- */
84
- if( ! class_exists( 'Plugin_Usage_Tracker') ) {
85
- require_once dirname( __FILE__ ) . '/tracking/class-plugin-usage-tracker.php';
86
- }
87
- if( ! function_exists( 'uk_cookie_consent_start_plugin_tracking' ) ) {
88
- function uk_cookie_consent_start_plugin_tracking() {
89
- $wisdom = new Plugin_Usage_Tracker(
90
- __FILE__,
91
- 'https://wisdomplugin.com',
92
- array( 'ctcc_options_settings' ),
93
- true,
94
- true,
95
- 1
96
- );
97
- }
98
- uk_cookie_consent_start_plugin_tracking();
99
- }
3
  Plugin Name: Cookie Consent
4
  Plugin URI: https://catapultthemes.com/cookie-consent/
5
  Description: The only cookie consent plugin you'll ever need.
6
+ Version: 2.3.9
7
  Author: Catapult_Themes
8
  Author URI: https://catapultthemes.com/
9
  Text Domain: uk-cookie-consent
75
  }
76
  }
77
  register_activation_hook ( __FILE__, 'ctcc_create_policy_page' );