-
Notifications
You must be signed in to change notification settings - Fork 40
/
complianz-gpdr.php
311 lines (273 loc) · 9.88 KB
/
complianz-gpdr.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
<?php
/**
* Plugin Name: Complianz | GDPR/CCPA Cookie Consent
* Plugin URI: https://www.wordpress.org/plugins/complianz-gdpr
* Description: Complianz Privacy Suite for GDPR, CaCPA, DSVGO, AVG with a conditional cookie warning and customized cookie policy
* Version: 7.1.5
* Requires at least: 5.9
* Requires PHP: 7.4
* Text Domain: complianz-gdpr
* Domain Path: /languages
* Author: Really Simple Plugins
* Author URI: https://www.complianz.io
*/
/*
Copyright 2022 Complianz BV (email : [email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
defined( 'ABSPATH' ) or die( "you do not have access to this page!" );
define( 'cmplz_free', true );
if ( ! function_exists( 'cmplz_activation_check' ) ) {
/**
* Checks if the plugin can safely be activated, at least php 5.6 and wp 4.6
*
* @since 2.1.5
*/
function cmplz_activation_check() {
if ( version_compare( PHP_VERSION, '7.2', '<' ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die( __( 'Complianz GDPR cannot be activated. The plugin requires PHP 7.2 or higher',
'complianz-gdpr' ) );
}
global $wp_version;
if ( version_compare( $wp_version, '4.9', '<' ) ) {
deactivate_plugins( plugin_basename( __FILE__ ) );
wp_die( __( 'Complianz GDPR cannot be activated. The plugin requires WordPress 4.9 or higher',
'complianz-gdpr' ) );
}
}
register_activation_hook( __FILE__, 'cmplz_activation_check' );
}
require_once( plugin_dir_path( __FILE__ ) . 'functions.php' );
if ( ! class_exists( 'COMPLIANZ' ) ) {
class COMPLIANZ {
public static $instance;
public static $config;
public static $company;
public static $review;
public static $admin;
public static $scan;
public static $sync;
public static $wizard;
public static $onboarding;
public static $export_settings;
public static $rsp_upgrade_to_pro;
public static $banner_loader;
public static $document;
public static $cookie_blocker;
public static $progress;
public static $DNSMPD;
public static $admin_DNSMPD;
public static $support;
public static $proof_of_consent;
public static $documents_admin;
private function __construct() {
$this->setup_constants();
$this->includes();
$this->hooks();
self::$config = new cmplz_config();
self::$company = new cmplz_company();
self::$DNSMPD = new cmplz_DNSMPD();
if ( cmplz_admin_logged_in() ) {
self::$admin_DNSMPD = new cmplz_admin_DNSMPD();
self::$review = new cmplz_review();
self::$admin = new cmplz_admin();
self::$export_settings = new cmplz_export_settings();
self::$progress = new cmplz_progress();
self::$documents_admin = new cmplz_documents_admin();
self::$wizard = new cmplz_wizard();
self::$onboarding = new cmplz_onboarding();
self::$sync = new cmplz_sync();
}
if (cmplz_admin_logged_in() || cmplz_scan_in_progress() ) {
self::$scan = new cmplz_scan();
}
self::$proof_of_consent = new cmplz_proof_of_consent();
self::$cookie_blocker = new cmplz_cookie_blocker();
self::$banner_loader = new cmplz_banner_loader();
self::$document = new cmplz_document();
}
/**
* Setup constants for the plugin
*/
private function setup_constants() {
define( 'CMPLZ_COOKIEDATABASE_URL', 'https://cookiedatabase.org/wp-json/cookiedatabase/' );
define( 'CMPLZ_MAIN_MENU_POSITION', 40 );
//default region code
if ( ! defined( 'CMPLZ_DEFAULT_REGION' ) ) {
define( 'CMPLZ_DEFAULT_REGION', 'us' );
}
/*statistics*/
if ( ! defined( 'CMPLZ_AB_TESTING_DURATION' ) ) {
define( 'CMPLZ_AB_TESTING_DURATION', 30 );
} //Days
define( 'cmplz_url', plugin_dir_url( __FILE__ ) );
define( 'cmplz_path', plugin_dir_path( __FILE__ ) );
define( 'cmplz_plugin', plugin_basename( __FILE__ ) );
//for auto upgrade functionality
define( 'cmplz_plugin_free', plugin_basename( __FILE__ ) );
$debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '#'.time() : '';
define( 'cmplz_version', '7.1.5' . $debug );
define( 'cmplz_plugin_file', __FILE__ );
}
/**
* Instantiate the class.
*
* @return COMPLIANZ
* @since 1.0.0
*
*/
public static function get_instance() {
if ( ! isset( self::$instance )
&& ! ( self::$instance instanceof COMPLIANZ )
) {
self::$instance = new self();
}
return self::$instance;
}
private function includes() {
require_once( cmplz_path . 'documents/class-document.php');
require_once( cmplz_path . 'cookie/class-cookie.php' );
require_once( cmplz_path . 'cookie/class-service.php' );
require_once( cmplz_path . 'integrations/integrations.php' );
require_once( cmplz_path . 'cron/cron.php' );
/* Gutenberg block */
if ( cmplz_uses_gutenberg() ) {
require_once plugin_dir_path(__FILE__) . 'gutenberg/block.php';
}
require_once plugin_dir_path( __FILE__ ) . 'rest-api/rest-api.php';
if ( cmplz_admin_logged_in() ) {
require_once( cmplz_path . 'config/warnings.php' );
require_once( cmplz_path . 'settings/settings.php' );
require_once( cmplz_path . 'class-admin.php' );
require_once( cmplz_path . 'class-review.php' );
require_once( cmplz_path . 'progress/class-progress.php');
require_once( cmplz_path . 'cookiebanner/admin/cookiebanner.php');
require_once( cmplz_path . 'class-export.php' );
require_once( cmplz_path . 'documents/admin-class-documents.php' );
require_once( cmplz_path . 'settings/wizard.php' );
require_once( cmplz_path . 'onboarding/class-onboarding.php' );
require_once( cmplz_path . 'mailer/class-mail.php');
require_once( cmplz_path . 'placeholders/class-placeholders.php' );
if ( isset($_GET['install_pro'])) {
require_once( cmplz_path . 'upgrade/upgrade-to-pro.php' );
}
require_once( cmplz_path . 'upgrade.php' );
require_once(cmplz_path . 'DNSMPD/class-admin-DNSMPD.php');
require_once(cmplz_path . 'cookie/class-sync.php');
}
if (cmplz_admin_logged_in() || cmplz_scan_in_progress() ) {
require_once(cmplz_path . 'cookie/class-scan.php');
}
require_once( cmplz_path . 'proof-of-consent/class-proof-of-consent.php' );
require_once(cmplz_path . 'cookiebanner/class-cookiebanner.php');
require_once(cmplz_path . 'cookiebanner/class-banner-loader.php');
require_once(cmplz_path . 'class-company.php');
require_once(cmplz_path . 'DNSMPD/class-DNSMPD.php');
require_once(cmplz_path . 'config/class-config.php');
require_once(cmplz_path . 'class-cookie-blocker.php');
}
private function hooks() {
if ( wp_doing_ajax() ) {
//using init on ajax calls, as wp is not running.
add_action('init', 'cmplz_init_cookie_blocker');
} else {
//has to be wp for all non ajax calls, because of AMP plugin
add_action('wp', 'cmplz_init_cookie_blocker');
}
load_plugin_textdomain( 'complianz-gdpr' );
}
}
/**
* Load the plugins main class.
*/
add_action(
'plugins_loaded',
function () {
COMPLIANZ::get_instance();
},
9
);
}
if ( ! function_exists( 'cmplz_set_activation_time_stamp' ) ) {
/**
* Set an activation time stamp
*
* @param $networkwide
*/
function cmplz_set_activation_time_stamp( $networkwide ) {
update_option( 'cmplz_activation_time', time() );
update_option( 'cmplz_run_activation', true , false );
set_transient('cmplz_redirect_to_settings_page', true, HOUR_IN_SECONDS );
}
register_activation_hook( __FILE__, 'cmplz_set_activation_time_stamp' );
}
if ( ! function_exists( 'cmplz_activation_check' ) ) {
/**
* Start the tour of the plugin on activation
*/
function cmplz_activation_check() {
do_action('cmplz_activation');
}
register_activation_hook( __FILE__, 'cmplz_activation_check' );
}
if ( !function_exists('cmplz_is_logged_in_rest')) {
function cmplz_is_logged_in_rest() {
$is_settings_page_request = isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '/complianz/v1/' ) !== false;
if ( ! $is_settings_page_request ) {
return false;
}
return is_user_logged_in();
}
}
if ( !function_exists('cmplz_admin_logged_in')){
function cmplz_admin_logged_in(){
$wpcli = defined( 'WP_CLI' ) && WP_CLI;
return ( is_admin() && cmplz_user_can_manage()) || cmplz_is_logged_in_rest() || wp_doing_cron() || $wpcli || defined('CMPLZ_DOING_SYSTEM_STATUS');
}
}
if ( ! function_exists('cmplz_add_manage_privacy_capability') ){
/**
* Add a user capability to WordPress and add to admin and editor role
*/
function cmplz_add_manage_privacy_capability($handle_subsites = true ){
$capability = 'manage_privacy';
$role = get_role( 'administrator' );
if( $role && !$role->has_cap( $capability ) ){
$role->add_cap( $capability );
}
//we need to add this role across subsites as well.
if ( $handle_subsites && is_multisite() ) {
$sites = get_sites();
if (count($sites)>0) {
foreach ($sites as $site) {
switch_to_blog($site->blog_id);
cmplz_add_manage_privacy_capability(false);
restore_current_blog();
}
}
}
}
register_activation_hook( __FILE__, 'cmplz_add_manage_privacy_capability' );
/**
* When a new site is added, add our capability
* @param $site
*
* @return void
*/
function cmplz_add_role_to_subsite($site) {
switch_to_blog($site->blog_id);
cmplz_add_manage_privacy_capability(false);
restore_current_blog();
}
add_action('wp_initialize_site', 'cmplz_add_role_to_subsite', 10, 1);
}