PluginProbe ʕ •ᴥ•ʔ
Complianz – GDPR/CCPA Cookie Consent / beta
Complianz – GDPR/CCPA Cookie Consent vbeta
7.4.6 trunk 6.5.6 7.0.4 7.0.5 7.1.0 7.1.4 7.1.5 7.2.0 7.3.0 7.3.1 7.4.0 7.4.0.1 7.4.1 7.4.2 7.4.3 7.4.4 7.4.4.1 7.4.4.2 7.4.5 beta
complianz-gdpr / complianz-gpdr.php
complianz-gdpr Last commit date
DNSMPD 1 year ago assets 1 year ago config 1 year ago cookie 1 year ago cookiebanner 1 year ago cron 1 year ago documents 1 year ago gutenberg 1 year ago integrations 1 year ago languages 1 year ago mailer 1 year ago onboarding 1 year ago placeholders 1 year ago progress 1 year ago proof-of-consent 1 year ago rest-api 1 year ago settings 1 year ago templates 1 year ago upgrade 1 year ago LICENSE.txt 1 year ago README.md 1 year ago class-admin.php 1 year ago class-company.php 1 year ago class-cookie-blocker.php 1 year ago class-document.php 1 year ago class-export.php 1 year ago class-field.php 1 year ago class-installer.php 1 year ago class-review.php 1 year ago class-wizard.php 1 year ago complianz-gpdr.php 1 year ago composer.json 1 year ago functions-legacy.php 1 year ago functions.php 1 year ago gulpfile.js 1 year ago index.php 1 year ago loco.xml 1 year ago readme.txt 1 year ago security.md 1 year ago system-status.php 1 year ago uninstall.php 1 year ago upgrade.php 1 year ago
complianz-gpdr.php
311 lines
1 <?php
2 /**
3 * Plugin Name: Complianz | GDPR/CCPA Cookie Consent
4 * Plugin URI: https://www.wordpress.org/plugins/complianz-gdpr
5 * Description: Complianz Privacy Suite for GDPR, CaCPA, DSVGO, AVG with a conditional cookie warning and customized cookie policy
6 * Version: 7.1.5
7 * Requires at least: 5.9
8 * Requires PHP: 7.4
9 * Text Domain: complianz-gdpr
10 * Domain Path: /languages
11 * Author: Really Simple Plugins
12 * Author URI: https://www.complianz.io
13 */
14
15 /*
16 Copyright 2022 Complianz BV (email : support@complianz.io)
17
18 This program is free software; you can redistribute it and/or modify
19 it under the terms of the GNU General Public License, version 2, as
20 published by the Free Software Foundation.
21
22 This program is distributed in the hope that it will be useful,
23 but WITHOUT ANY WARRANTY; without even the implied warranty of
24 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 GNU General Public License for more details.
26
27 You should have received a copy of the GNU General Public License
28 along with this program; if not, write to the Free Software
29 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */
31
32 defined( 'ABSPATH' ) or die( "you do not have access to this page!" );
33 define( 'cmplz_free', true );
34
35 if ( ! function_exists( 'cmplz_activation_check' ) ) {
36 /**
37 * Checks if the plugin can safely be activated, at least php 5.6 and wp 4.6
38 *
39 * @since 2.1.5
40 */
41 function cmplz_activation_check() {
42 if ( version_compare( PHP_VERSION, '7.2', '<' ) ) {
43 deactivate_plugins( plugin_basename( __FILE__ ) );
44 wp_die( __( 'Complianz GDPR cannot be activated. The plugin requires PHP 7.2 or higher',
45 'complianz-gdpr' ) );
46 }
47
48 global $wp_version;
49 if ( version_compare( $wp_version, '4.9', '<' ) ) {
50 deactivate_plugins( plugin_basename( __FILE__ ) );
51 wp_die( __( 'Complianz GDPR cannot be activated. The plugin requires WordPress 4.9 or higher',
52 'complianz-gdpr' ) );
53 }
54 }
55
56 register_activation_hook( __FILE__, 'cmplz_activation_check' );
57 }
58
59 require_once( plugin_dir_path( __FILE__ ) . 'functions.php' );
60 if ( ! class_exists( 'COMPLIANZ' ) ) {
61 class COMPLIANZ {
62 public static $instance;
63 public static $config;
64 public static $company;
65 public static $review;
66 public static $admin;
67 public static $scan;
68 public static $sync;
69 public static $wizard;
70 public static $onboarding;
71 public static $export_settings;
72 public static $rsp_upgrade_to_pro;
73 public static $banner_loader;
74 public static $document;
75 public static $cookie_blocker;
76 public static $progress;
77 public static $DNSMPD;
78 public static $admin_DNSMPD;
79 public static $support;
80 public static $proof_of_consent;
81 public static $documents_admin;
82
83 private function __construct() {
84 $this->setup_constants();
85 $this->includes();
86 $this->hooks();
87
88 self::$config = new cmplz_config();
89 self::$company = new cmplz_company();
90 self::$DNSMPD = new cmplz_DNSMPD();
91
92 if ( cmplz_admin_logged_in() ) {
93 self::$admin_DNSMPD = new cmplz_admin_DNSMPD();
94 self::$review = new cmplz_review();
95 self::$admin = new cmplz_admin();
96 self::$export_settings = new cmplz_export_settings();
97 self::$progress = new cmplz_progress();
98 self::$documents_admin = new cmplz_documents_admin();
99 self::$wizard = new cmplz_wizard();
100 self::$onboarding = new cmplz_onboarding();
101 self::$sync = new cmplz_sync();
102 }
103
104 if (cmplz_admin_logged_in() || cmplz_scan_in_progress() ) {
105 self::$scan = new cmplz_scan();
106 }
107
108 self::$proof_of_consent = new cmplz_proof_of_consent();
109 self::$cookie_blocker = new cmplz_cookie_blocker();
110 self::$banner_loader = new cmplz_banner_loader();
111 self::$document = new cmplz_document();
112 }
113
114 /**
115 * Setup constants for the plugin
116 */
117
118 private function setup_constants() {
119 define( 'CMPLZ_COOKIEDATABASE_URL', 'https://cookiedatabase.org/wp-json/cookiedatabase/' );
120 define( 'CMPLZ_MAIN_MENU_POSITION', 40 );
121
122 //default region code
123 if ( ! defined( 'CMPLZ_DEFAULT_REGION' ) ) {
124 define( 'CMPLZ_DEFAULT_REGION', 'us' );
125 }
126
127 /*statistics*/
128 if ( ! defined( 'CMPLZ_AB_TESTING_DURATION' ) ) {
129 define( 'CMPLZ_AB_TESTING_DURATION', 30 );
130 } //Days
131
132 define( 'cmplz_url', plugin_dir_url( __FILE__ ) );
133 define( 'cmplz_path', plugin_dir_path( __FILE__ ) );
134 define( 'cmplz_plugin', plugin_basename( __FILE__ ) );
135 //for auto upgrade functionality
136 define( 'cmplz_plugin_free', plugin_basename( __FILE__ ) );
137 $debug = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '#'.time() : '';
138 define( 'cmplz_version', '7.1.5' . $debug );
139 define( 'cmplz_plugin_file', __FILE__ );
140 }
141
142 /**
143 * Instantiate the class.
144 *
145 * @return COMPLIANZ
146 * @since 1.0.0
147 *
148 */
149 public static function get_instance() {
150 if ( ! isset( self::$instance )
151 && ! ( self::$instance instanceof COMPLIANZ )
152 ) {
153 self::$instance = new self();
154 }
155
156 return self::$instance;
157 }
158
159 private function includes() {
160 require_once( cmplz_path . 'documents/class-document.php');
161 require_once( cmplz_path . 'cookie/class-cookie.php' );
162 require_once( cmplz_path . 'cookie/class-service.php' );
163 require_once( cmplz_path . 'integrations/integrations.php' );
164 require_once( cmplz_path . 'cron/cron.php' );
165
166 /* Gutenberg block */
167 if ( cmplz_uses_gutenberg() ) {
168 require_once plugin_dir_path(__FILE__) . 'gutenberg/block.php';
169 }
170 require_once plugin_dir_path( __FILE__ ) . 'rest-api/rest-api.php';
171
172 if ( cmplz_admin_logged_in() ) {
173 require_once( cmplz_path . 'config/warnings.php' );
174 require_once( cmplz_path . 'settings/settings.php' );
175 require_once( cmplz_path . 'class-admin.php' );
176 require_once( cmplz_path . 'class-review.php' );
177 require_once( cmplz_path . 'progress/class-progress.php');
178 require_once( cmplz_path . 'cookiebanner/admin/cookiebanner.php');
179 require_once( cmplz_path . 'class-export.php' );
180 require_once( cmplz_path . 'documents/admin-class-documents.php' );
181 require_once( cmplz_path . 'settings/wizard.php' );
182 require_once( cmplz_path . 'onboarding/class-onboarding.php' );
183 require_once( cmplz_path . 'mailer/class-mail.php');
184 require_once( cmplz_path . 'placeholders/class-placeholders.php' );
185
186 if ( isset($_GET['install_pro'])) {
187 require_once( cmplz_path . 'upgrade/upgrade-to-pro.php' );
188 }
189 require_once( cmplz_path . 'upgrade.php' );
190 require_once(cmplz_path . 'DNSMPD/class-admin-DNSMPD.php');
191 require_once(cmplz_path . 'cookie/class-sync.php');
192 }
193
194 if (cmplz_admin_logged_in() || cmplz_scan_in_progress() ) {
195 require_once(cmplz_path . 'cookie/class-scan.php');
196 }
197
198 require_once( cmplz_path . 'proof-of-consent/class-proof-of-consent.php' );
199 require_once(cmplz_path . 'cookiebanner/class-cookiebanner.php');
200 require_once(cmplz_path . 'cookiebanner/class-banner-loader.php');
201
202 require_once(cmplz_path . 'class-company.php');
203 require_once(cmplz_path . 'DNSMPD/class-DNSMPD.php');
204 require_once(cmplz_path . 'config/class-config.php');
205 require_once(cmplz_path . 'class-cookie-blocker.php');
206 }
207
208 private function hooks() {
209 if ( wp_doing_ajax() ) {
210 //using init on ajax calls, as wp is not running.
211 add_action('init', 'cmplz_init_cookie_blocker');
212 } else {
213 //has to be wp for all non ajax calls, because of AMP plugin
214 add_action('wp', 'cmplz_init_cookie_blocker');
215 }
216 load_plugin_textdomain( 'complianz-gdpr' );
217 }
218 }
219
220 /**
221 * Load the plugins main class.
222 */
223 add_action(
224 'plugins_loaded',
225 function () {
226 COMPLIANZ::get_instance();
227 },
228 9
229 );
230 }
231
232 if ( ! function_exists( 'cmplz_set_activation_time_stamp' ) ) {
233
234 /**
235 * Set an activation time stamp
236 *
237 * @param $networkwide
238 */
239 function cmplz_set_activation_time_stamp( $networkwide ) {
240 update_option( 'cmplz_activation_time', time() );
241 update_option( 'cmplz_run_activation', true , false );
242 set_transient('cmplz_redirect_to_settings_page', true, HOUR_IN_SECONDS );
243 }
244 register_activation_hook( __FILE__, 'cmplz_set_activation_time_stamp' );
245 }
246
247 if ( ! function_exists( 'cmplz_activation_check' ) ) {
248 /**
249 * Start the tour of the plugin on activation
250 */
251 function cmplz_activation_check() {
252 do_action('cmplz_activation');
253 }
254
255 register_activation_hook( __FILE__, 'cmplz_activation_check' );
256 }
257 if ( !function_exists('cmplz_is_logged_in_rest')) {
258 function cmplz_is_logged_in_rest() {
259 $is_settings_page_request = isset( $_SERVER['REQUEST_URI'] ) && strpos( $_SERVER['REQUEST_URI'], '/complianz/v1/' ) !== false;
260 if ( ! $is_settings_page_request ) {
261 return false;
262 }
263
264 return is_user_logged_in();
265 }
266 }
267
268 if ( !function_exists('cmplz_admin_logged_in')){
269 function cmplz_admin_logged_in(){
270 $wpcli = defined( 'WP_CLI' ) && WP_CLI;
271 return ( is_admin() && cmplz_user_can_manage()) || cmplz_is_logged_in_rest() || wp_doing_cron() || $wpcli || defined('CMPLZ_DOING_SYSTEM_STATUS');
272 }
273 }
274 if ( ! function_exists('cmplz_add_manage_privacy_capability') ){
275 /**
276 * Add a user capability to WordPress and add to admin and editor role
277 */
278 function cmplz_add_manage_privacy_capability($handle_subsites = true ){
279 $capability = 'manage_privacy';
280 $role = get_role( 'administrator' );
281 if( $role && !$role->has_cap( $capability ) ){
282 $role->add_cap( $capability );
283 }
284
285 //we need to add this role across subsites as well.
286 if ( $handle_subsites && is_multisite() ) {
287 $sites = get_sites();
288 if (count($sites)>0) {
289 foreach ($sites as $site) {
290 switch_to_blog($site->blog_id);
291 cmplz_add_manage_privacy_capability(false);
292 restore_current_blog();
293 }
294 }
295 }
296 }
297 register_activation_hook( __FILE__, 'cmplz_add_manage_privacy_capability' );
298
299 /**
300 * When a new site is added, add our capability
301 * @param $site
302 *
303 * @return void
304 */
305 function cmplz_add_role_to_subsite($site) {
306 switch_to_blog($site->blog_id);
307 cmplz_add_manage_privacy_capability(false);
308 restore_current_blog();
309 }
310 add_action('wp_initialize_site', 'cmplz_add_role_to_subsite', 10, 1);
311 }