forked from complianz/complianz-gdpr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallback-notices.php
386 lines (324 loc) · 15.9 KB
/
callback-notices.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<?php
defined( 'ABSPATH' ) or die( "you do not have access to this page!" );
add_action( 'cmplz_notice_compile_statistics', 'cmplz_compile_statistics' );
function cmplz_compile_statistics() {
if ( get_option( 'cmplz_detected_stats_type' )
|| get_option( 'cmplz_detected_stats_data' )
) {
cmplz_sidebar_notice( __( "This field has been pre-filled based on the scan results.", 'complianz-gdpr' ) );
}
}
function cmplz_notice_cookiedatabase_sync(){
if (!COMPLIANZ::$cookie_admin->use_cdb_api() ) {
cmplz_sidebar_notice(__("Cookiedatabase.org synchronization disabled.", "complianz-gdpr"),'warning');
}
if ( ! function_exists( 'curl_version' ) ) {
cmplz_sidebar_notice( __( 'Your server does not have CURL installed, which is required for the sync. Please contact your hosting company to install CURL.',
'complianz-gdpr' ), 'warning' );
}
$data_cookies = COMPLIANZ::$cookie_admin->get_syncable_cookies();
$data_services = COMPLIANZ::$cookie_admin->get_syncable_services();
if ( $data_cookies['count'] == 0 && $data_services['count'] == 0 ) {
cmplz_sidebar_notice( __( 'Synchronization disabled: This happens when all cookies have synchronized to cookiedatabase.org in the last week.',
'complianz-gdpr' ), 'warning' );
}
}
add_action( 'cmplz_notice_cookiedatabase_sync', 'cmplz_notice_cookiedatabase_sync' );
function cmplz_notice_stats_non_functional() {
if ( get_option( 'cmplz_detected_stats_type' )
|| get_option( 'cmplz_detected_stats_data' )
) {
cmplz_sidebar_notice( __( "This field has been pre-filled based on the scan results.", 'complianz-gdpr' ) . " "
. __( "Please make sure you remove your current implementation to prevent double statistics tracking.", 'complianz-gdpr' ) );
} else {
cmplz_sidebar_notice( __( 'If you add the ID for your statistics tool here, Complianz will configure your site for statistics tracking.', 'complianz-gdpr' ) );
}
}
add_action( 'cmplz_notice_GTM_code', 'cmplz_notice_stats_non_functional' );
add_action( 'cmplz_notice_UA_code', 'cmplz_notice_stats_non_functional' );
add_action( 'cmplz_notice_matomo_site_id', 'cmplz_notice_stats_non_functional' );
add_action( 'cmplz_notice_compile_statistics', 'cmplz_show_compile_statistics_notice', 10, 1 );
function cmplz_show_compile_statistics_notice( $args ) {
$stats = cmplz_scan_detected_stats();
if ( $stats ) {
$type = reset( $stats );
$type = COMPLIANZ::$config->stats[ $type ];
cmplz_sidebar_notice( cmplz_sprintf( __( "The cookie scan detected %s on your site, which means the answer to this question should be %s.", 'complianz-gdpr' ), $type, $type ) );
}
}
add_action( 'cmplz_notice_uses_social_media',
'cmplz_uses_social_media_notice' );
function cmplz_uses_social_media_notice() {
$social_media = cmplz_scan_detected_social_media();
if ( $social_media ) {
foreach ( $social_media as $key => $social_medium ) {
$social_media[ $key ]
= COMPLIANZ::$config->thirdparty_socialmedia[ $social_medium ];
}
$social_media = implode( ', ', $social_media );
cmplz_sidebar_notice( cmplz_sprintf( __( "The scan found social media buttons or widgets for %s on your site, which means the answer should be yes",
'complianz-gdpr' ), $social_media ) );
}
}
add_action( 'cmplz_notice_purpose_personaldata', 'cmplz_purpose_personaldata' );
function cmplz_purpose_personaldata() {
$contact_forms = cmplz_site_uses_contact_forms();
if ( $contact_forms ) {
cmplz_sidebar_notice( __( 'The scan found forms on your site, which means answer should probably include "contact".',
'complianz-gdpr' ) );
}
}
add_action( 'cmplz_notice_uses_thirdparty_services', 'cmplz_uses_thirdparty_services_notice' );
function cmplz_uses_thirdparty_services_notice() {
$thirdparties = cmplz_scan_detected_thirdparty_services();
if ( $thirdparties ) {
foreach ( $thirdparties as $key => $thirdparty ) {
$thirdparties[ $key ] = COMPLIANZ::$config->thirdparty_services[ $thirdparty ];
}
$thirdparties = implode( ', ', $thirdparties );
cmplz_sidebar_notice( cmplz_sprintf( __( "The scan found third-party services on your website: %s, this means the answer should be yes.",
'complianz-gdpr' ), $thirdparties ) );
}
}
add_action( 'cmplz_notice_purpose_personaldata', 'cmplz_purpose_personaldata_notice' );
function cmplz_purpose_personaldata_notice() {
if ( cmplz_has_region('us') && COMPLIANZ::$cookie_admin->site_shares_data()
) {
cmplz_sidebar_notice( __( "The cookie scan detected cookies from services that share data with Third Parties. According to US privacy laws, your website is considered to sell personal data if it collects and shares any personal data in return for money or services. This includes a service like Google Analytics.",
'complianz-gdpr' ) );
}
}
function cmplz_notice_cookie_scan() {
if ( ! function_exists( 'curl_version' ) ) {
cmplz_sidebar_notice( __( 'Your server does not have CURL installed, which is required for the scan. Please contact your hosting company to install CURL.', 'complianz-gdpr' ), 'warning' );
}
if ( ( isset( $_SERVER['HTTP_DNT'] )
&& $_SERVER['HTTP_DNT'] == 1 )
|| isset( $_SERVER['HTTP_SEC_GPC'] )
) {
cmplz_sidebar_notice( __( "Your browser has the Do Not Track or Global Privacy Control setting enabled.","complianz-gdpr")." ".__("This will prevent most cookies from being placed.","complianz-gdpr")." ".__("Please run the scan with these browser options disabled.", 'complianz-gdpr' ), 'warning' );
}
?>
<div id="cmplz_adblock_warning" style="display: none">
<?php cmplz_sidebar_notice( __( "You are using an ad blocker. This will prevent most cookies from being placed. Please run the scan without an adblocker enabled.", 'complianz-gdpr' ), 'warning' ) ?>
</div>
<div id="cmplz_anonymous_window_warning" style="display: none">
<?php cmplz_sidebar_notice( __( "You are using an anonymous window. This will prevent most cookies from being placed. Please run the scan in a normal browser window.",
'complianz-gdpr' ), 'warning' ) ?>
</div>
<?php
}
add_action( 'cmplz_notice_cookie_scan', 'cmplz_notice_cookie_scan' );
function cmplz_google_fonts_warning() {
//Divi specific notice
if (function_exists('et_setup_theme')) {
cmplz_sidebar_notice( __( "Your site uses Divi. If you use reCAPTCHA on your site, you may need to disable the reCAPTCHA integration in Complianz. ", 'complianz-gdpr' ).cmplz_read_more( "https://complianz.io/blocking-recaptcha-on-divi/" ) , 'warning');
}
}
add_action( 'cmplz_notice_thirdparty_services_on_site', 'cmplz_google_fonts_warning' );
function cmplz_used_cookies_notice() {
if ( cmplz_uses_only_functional_cookies() ) {
return;
}
//not relevant if cookie blocker is disabled
if ( !cmplz_can_run_cookie_blocker() ) {
return;
}
cmplz_sidebar_notice( cmplz_sprintf( __( "Because your site uses third-party cookies, the cookie blocker is now activated. If you experience issues on the front-end of your site due to blocked scripts, you can disable specific services or plugin integrations in the %sintegrations section%s, or you can disable the cookie blocker entirely on the %ssettings page%s",
'complianz-gdpr' ),
'<a href="' . admin_url( 'admin.php?page=cmplz-script-center' ) . '">',
'</a>',
'<a href="' . admin_url( 'admin.php?page=cmplz-script-center' ) . '">',
'</a>' ), 'warning' );
}
add_action( 'cmplz_notice_used_cookies', 'cmplz_used_cookies_notice' );
function cmplz_data_disclosed_us() {
if ( COMPLIANZ::$cookie_admin->site_shares_data() ) {
cmplz_sidebar_notice( __( "The cookie scan detected cookies from services which share data with Third Parties. If these cookies were also used in the past 12 months, you should at least select the option 'Internet activity...'",
'complianz-gdpr' ) );
}
}
add_action( 'cmplz_notice_data_disclosed_us', 'cmplz_data_disclosed_us' );
function cmplz_data_sold_us() {
if ( COMPLIANZ::$cookie_admin->site_shares_data() ) {
cmplz_sidebar_notice( __( "The cookie scan detected cookies from services which share data with Third Parties. If these cookies were also used in the past 12 months, you should at least select the option 'Internet activity...'",
'complianz-gdpr' ) );
}
}
add_action( 'cmplz_notice_data_sold_us', 'cmplz_data_sold_us' );
function cmplz_notice_block_recaptcha_service() {
cmplz_sidebar_notice( __( "If you choose to block reCAPTCHA, please make sure you add a placeholder to your forms.",
'complianz-gdpr' )
. cmplz_read_more( 'https://complianz.io/blocking-recaptcha-manually/' ) );
}
add_action( 'cmplz_notice_block_recaptcha_service', 'cmplz_notice_block_recaptcha_service' );
function cmplz_notice_statistics_script() {
cmplz_sidebar_notice( __( 'You have indicated you use a statistics tool which tracks personal data. You can insert this script here so it only fires if the user consents to this.',
'intro cookie usage', 'complianz-gdpr' ) );
}
add_action( 'cmplz_notice_statistics_script', 'cmplz_notice_statistics_script' );
add_action('cmplz_notice_create_pages', 'cmplz_notice_custom_create_pages');
function cmplz_notice_custom_create_pages(){
$created_pages = COMPLIANZ::$document->get_created_pages();
$required_pages = COMPLIANZ::$document->get_required_pages();
if (count($required_pages) > count($created_pages) ){
cmplz_sidebar_notice( __( 'You haven\'t created all required pages yet. You can add missing pages in the previous step, or create them manually with the shortcode. You can come back later to this step to add your pages to the desired menu, or do it manually via Appearance > Menu.',
'complianz-gdpr' )
);
}
}
function cmplz_notice_add_pages_to_menu() {
$created_pages = COMPLIANZ::$document->get_created_pages();
$pages_not_in_menu = COMPLIANZ::$document->pages_not_in_menu();
if ( $pages_not_in_menu ) {
$docs = implode( ", ", $pages_not_in_menu );
//not using cmplz_sprintf( here, as one variant does not include a %s, causing a translation error notice
cmplz_sidebar_notice( sprintf( esc_html( _n( 'The generated document %s has not been assigned to a menu yet, you can do this now, or skip this step and do it later.',
'Not all generated documents have been assigned to a menu yet, you can do this now, or skip this step and do it later.',
count( $pages_not_in_menu ), 'complianz-gdpr' ) ), $docs ),
'warning' );
} else {
if (count($created_pages)>0 ) {
cmplz_sidebar_notice( __( "Great! All your generated documents have been assigned to a menu, so you can skip this step.",
'complianz-gdpr' ), 'warning' );
}
}
}
add_action( 'cmplz_notice_add_pages_to_menu', 'cmplz_notice_add_pages_to_menu' );
add_action( 'cmplz_notice_add_pages_to_menu_region_redirected', 'cmplz_notice_add_pages_to_menu' );
function cmplz_show_category_marketing_notice() {
if ( COMPLIANZ::$cookie_admin->uses_google_tagmanager() ) {
cmplz_sidebar_notice( __( "You're using Google Tag Manager. This means you need to configure Tag Manager to use the below categories.", 'complianz-gdpr' ).cmplz_read_more('https://complianz.io/definitive-guide-to-tag-manager-and-complianz/'), 'warning' );
}
}
add_action( 'cmplz_notice_category_marketing', 'cmplz_show_category_marketing_notice' );
function cmplz_show_category_statistics_notice() {
if ( COMPLIANZ::$cookie_admin->cookie_warning_required_stats( 'eu' ) ) {
cmplz_sidebar_notice( __( "Categories are mandatory for your statistics configuration.", 'complianz-gdpr' ) . cmplz_read_more( 'https://complianz.io/statistics-as-mandatory-category' ), 'warning' );
}
}
add_action( 'cmplz_notice_category_statistics', 'cmplz_show_category_statistics_notice' );
/**
* For the cookie page and the US banner we need a link to the privacy statement.
* In free, and in premium when the privacy statement is not enabled, we choose the WP privacy page. If it is not set, the user needs to create one.
* */
function cmplz_notice_missing_privacy_page() {
if (cmplz_has_region('us') || cmplz_has_region('ca') || cmplz_has_region('au')){
cmplz_sidebar_notice( __( "It is recommended to select a Privacy Statement.", 'complianz-gdpr' )." ".__("The link to the Privacy Statement is used in the cookie banner and in your Cookie Policy.", 'complianz-gdpr' ) );
} else {
cmplz_sidebar_notice( __( "It is recommended to select a Privacy Statement.", 'complianz-gdpr' )." ".__("The link to the Privacy Statement is used in your Cookie Policy.", 'complianz-gdpr' ) );
}
}
add_action( 'cmplz_notice_privacy-statement', 'cmplz_notice_missing_privacy_page' );
/**
* If a plugin places marketing cookie as first party, we can't block it automatically, unless the wp consent api is used.
* User should be warned, and category marketing is necessary
* */
function cmplz_notice_firstparty_marketing() {
if ( cmplz_detected_firstparty_marketing() ) {
cmplz_sidebar_notice( __( "You use plugins which place first-party marketing cookies. You can view these plugins on the integrations page. Complianz cannot automatically block first-party marketing cookies unless these plugins conform to the WP Consent API.", 'complianz-gdpr' )
. cmplz_read_more( 'https://complianz.io/first-party-marketing-cookies' )
);
}
}
add_action( 'cmplz_notice_uses_firstparty_marketing_cookies', 'cmplz_notice_firstparty_marketing' );
add_action( 'cmplz_notice_sensitive_information_processed',
'cmplz_notice_sensitive_information_processed' );
function cmplz_notice_sensitive_information_processed() {
if ( cmplz_uses_sensitive_data() ) {
cmplz_sidebar_notice( __( "You have selected options that indicate your site processes sensitive, personal data. You should select 'Yes'",
'complianz-gdpr' ) );
}
}
add_filter( 'cmplz_default_value', 'cmplz_set_default', 10, 2 );
function cmplz_set_default( $value, $fieldname ) {
if ( $fieldname == 'compile_statistics' ) {
$stats = cmplz_scan_detected_stats();
if ( $stats ) {
return reset( $stats );
}
}
if ( $fieldname == 'purpose_personaldata' ) {
if ( cmplz_has_region('us')
&& COMPLIANZ::$cookie_admin->site_shares_data()
) {
//possibly not an array yet, when it's empty
if ( ! is_array( $value ) ) {
$value = array();
}
$value['selling-data-thirdparty'] = 1;
return $value;
}
}
if ( $fieldname == 'sensitive_information_processed' ) {
if ( cmplz_uses_sensitive_data() ) {
return 'yes';
}
}
if ( $fieldname == 'purpose_personaldata' ) {
$contact_forms = cmplz_site_uses_contact_forms();
if ( $contact_forms ) {
//possibly not an array yet, when it's empty
if ( ! is_array( $value ) ) {
$value = array();
}
$value['contact'] = 1;
return $value;
}
}
if ( $fieldname == 'country_company' ) {
$country_code = substr( get_locale(), 3, 2 );
if ( isset( COMPLIANZ::$config->countries[ $country_code ] ) ) {
$value = $country_code;
}
}
if ( $fieldname === 'uses_social_media' ) {
$social_media = cmplz_scan_detected_social_media();
if ( $social_media ) {
return 'yes';
}
}
if ( $fieldname === 'socialmedia_on_site' ) {
$social_media = cmplz_scan_detected_social_media();
if ( $social_media ) {
$current_social_media = array();
foreach ( $social_media as $key ) {
$current_social_media[ $key ] = 1;
}
return $current_social_media;
}
}
if ( $fieldname === 'uses_thirdparty_services' ) {
$blocked_scripts = COMPLIANZ::$cookie_blocker->blocked_scripts();
$custom_thirdparty_scripts = is_array($blocked_scripts) && count( $blocked_scripts ) > 0;
if ( cmplz_scan_detected_thirdparty_services() || $custom_thirdparty_scripts ) {
return 'yes';
}
}
if ( $fieldname === 'thirdparty_services_on_site' ) {
$thirdparty = cmplz_scan_detected_thirdparty_services();
if ( $thirdparty ) {
$current_thirdparty = array();
foreach ( $thirdparty as $key ) {
$current_thirdparty[ $key ] = 1;
}
return $current_thirdparty;
}
}
if ( $fieldname === 'data_disclosed_us' || $fieldname === 'data_sold_us' ) {
if ( COMPLIANZ::$cookie_admin->site_shares_data() ) {
//possibly not an array yet.
if ( ! is_array( $value ) ) {
$value = array();
}
$value['internet'] = 1;
return $value;
}
}
if ( $fieldname === 'uses_firstparty_marketing_cookies' ) {
if ( cmplz_detected_firstparty_marketing() ) {
return 'yes';
}
}
return $value;
}