0) { foreach ($sites as $site) { switch_to_blog($site->blog_id); do_action( 'cmplz_install_tables' ); restore_current_blog(); } } } } public function activation(){ if ( !cmplz_admin_logged_in() ){ return; } if ( get_option( 'cmplz_run_activation' ) ) { update_option('cmplz_activation_time', time(), false ); cmplz_update_option_no_hooks( 'use_cdb_api', 'yes' ); COMPLIANZ::$documents_admin->preload_privacy_info(); $this->run_table_init_hook(); delete_option( 'cmplz_run_activation' ); } } /** * Check if current day falls within required date range. * * @return bool */ public function is_bf(){ if ( defined("cmplz_premium" ) ) { return false; } $start_day = 25; $end_day = 30; $current_year = date("Y");//e.g. 2021 $current_month = date("n");//e.g. 3 $current_day = date("j");//e.g. 4 return $current_year == 2024 && $current_month == 11 && $current_day >= $start_day && $current_day <= $end_day; } /** * Hooked into ajax call to dismiss a warning * @hooked wp_ajax_cmplz_dismiss_warning */ public function dismiss_warning() { $error = false; if ( !cmplz_user_can_manage() ) { $error = true; } if ( !isset($_POST['id']) ) { $error = true; } if ( !$error ) { $warning_id = sanitize_title($_POST['id']); $dismissed_warnings = get_option( 'cmplz_dismissed_warnings', array() ); if ( !in_array($warning_id, $dismissed_warnings) ) { $dismissed_warnings[] = $warning_id; } update_option('cmplz_dismissed_warnings', $dismissed_warnings, false ); delete_transient('complianz_warnings'); delete_transient('complianz_warnings_admin_notices'); } $out = array( 'success' => ! $error, ); die( json_encode( $out ) ); } /** * Sanitize the cookiedomain * @param string $fieldname * @param string $fieldvalue * * @return string|string[] */ public function filter_cookie_domain( $fieldvalue, $fieldname ){ if ( ! cmplz_user_can_manage() ) { return $fieldvalue; } //sanitize the cookie domain return str_replace(array("https://", "http://", "www."), "", $fieldvalue); } /** * check for website hardening plugins * * @return bool */ public function no_security_plugin_active(){ //create switch statement if (defined('rsssl_version')) return false; //really simple security if (defined('WORDFENCE_VERSION')) return false; //wordfence if (class_exists('ITSEC_Core')) return false; //ithemes if (class_exists('AIO_WP_Security')) return false; // All in one security if (class_exists('SG_Security')) return false; // Siteground security if (defined('DEFENDER_VERSION')) return false; if (defined('SUCURISCAN_INIT')) return false; if (defined('JETPACK__VERSION')) return false; if (defined('BULLETPROOF_VERSION')) return false; if (class_exists('MCWPSettings')) return false; if (function_exists('GOTMLS_install')) return false; //anti malware security and brute force firewall return true; } /** * Add a major changes notice to the plugin updates message * @param $plugin_data * @param $response */ public function plugin_update_message($plugin_data, $response){ // if ( strpos($response->slug , 'complianz') !==false && $response->new_version === '7.0.0' && !cmplz_get_option("beta") ) { // echo '
' . ' '.cmplz_sprintf(__("This is a major release and while tested thoroughly you might experience conflicts or lost data. We recommend you back up your data before updating and check your configuration after update.", "complianz-gdpr").'','',''); // } if ( strpos($response->slug , 'complianz') !==false && strpos($response->new_version, 'beta.')!==false && cmplz_get_option("beta") ) { echo '
' . ' '.__("It is highly recommended that you back up your data before updating to the Beta version. Beta versions are not intended for production environments or critical systems. They are best suited for users who are willing to explore new features and provide feedback.", "complianz-gdpr").''; } } /** * If this update is to 6, don't auto update * Deactivated as of 6.0 * * @param $update * @param $item * * @return false|mixed */ public function override_auto_updates( $update, $item ) { if ( isset( $item->slug ) && strpos($item->slug , 'complianz') !==false && version_compare($item->new_version, '6.0.0', '>=') ) { return false; } return $update; } /** * Enqueue some assets * * @param $hook */ public function enqueue_assets( $hook ) { if ( strpos( $hook, 'complianz' ) === false) { return; } $min = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; $rtl = is_rtl() ? 'rtl/' : ''; $url = trailingslashit(cmplz_url) . "assets/css/{$rtl}admin{$min}.css"; $path = trailingslashit(cmplz_path) . "assets/css/{$rtl}admin{$min}.css"; wp_enqueue_style( 'complianz-admin', $url, ['wp-components'], filemtime($path) ); } /** * Add custom link to plugins overview page * * @hooked plugin_action_links_$plugin * * @param array $links * * @return array $links */ public function plugin_settings_link( $links ) { $settings_link = '' . __( "Settings", 'complianz-gdpr' ) . ''; array_unshift( $links, $settings_link ); $support_link = defined( 'cmplz_free' ) ? "https://wordpress.org/support/plugin/complianz-gdpr" : "https://complianz.io/support"; $faq_link = '' . __( 'Support', 'complianz-gdpr' ) . ''; array_unshift( $links, $faq_link ); if ( ! defined( 'cmplz_premium' ) ) { $upgrade_link = '' . __( 'Upgrade to premium', 'complianz-gdpr' ) . ''; array_unshift( $links, $upgrade_link ); } return $links; } /** * Insert some ajax script to dismiss the admin notice * * @since 2.0 * * @access public * * type: dismiss, later * */ public function insert_dismiss_admin_notice_script() { $ajax_nonce = wp_create_nonce( "cmplz_dismiss_admin_notice" ); ?> get_warnings( [ 'admin_notices' => true] ); if (count($warnings)==0) { return; } //only one admin notice at the same time. $keys = array_keys($warnings); $id = $keys[0]; $warning = $warnings[$id]; $this->admin_notice($warning, $id); } /** * @param array $warning */ public function admin_notice( $warning, $id='' ) { if (!isset($warning['open'])) { return; } /** * Prevent notice from being shown on Gutenberg page, as it strips off the class we need for the ajax callback. * * */ $screen = get_current_screen(); if ( $screen && $screen->parent_base === 'edit' ) { return; } ?>

>


true, 'status' => 'all', 'plus_ones' => false, 'progress_items_only' => false, 'admin_notices' => false, ); $args = wp_parse_args($args, $defaults); // if ($disable_notifications) { // $args['status'] = 'urgent'; // } $admin_notice = $args['admin_notices'] ? '_admin_notices' : ''; $cache = $args['cache']; if ( cmplz_is_logged_in_rest() ) { $cache = false; } $warnings = $cache ? get_transient( 'complianz_warnings'.$admin_notice ) : false; //re-check if there are no warnings, or if the transient has expired if ( ! $warnings ) { $warnings = []; $warning_type_defaults = array( 'plus_one' => false, 'warning_condition' => '_true_', 'success_conditions' => array(), 'relation' => 'OR', 'status' => 'open', 'dismissible' => true, 'include_in_progress' => false, 'admin_notice' => false, ); $warning_types = cmplz_load_warning_types(); if (empty($warning_types)) { return []; } foreach ($warning_types as $id => $warning_type) { $warning_types[$id] = wp_parse_args($warning_type, $warning_type_defaults ); } $dismissed_warnings = get_option('cmplz_dismissed_warnings', array() ); foreach ( $warning_types as $id => $warning ) { if ( in_array( sanitize_title($id), $dismissed_warnings) ) { continue; } if ( $args['admin_notices'] && !$warning['admin_notice']){ continue; } if ( !$args['admin_notices'] && $warning['admin_notice']){ continue; } $show_warning = $this->validate_function($warning['warning_condition']); if ( !$show_warning ) { continue; } $relation = $warning['relation']; if ( $relation === 'AND' ) { $success = TRUE; } else { $success = FALSE; } foreach ( $warning[ 'success_conditions'] as $func) { $condition = $this->validate_function($func); if ( $relation === 'AND' ) { $success = $success && $condition; } else { $success = $success || $condition; } } if ( !$success ) { if ( isset( $warning['open']) ) { $warning['message'] = $warning['open']; $warning['status'] = 'open'; $warnings[$id] = $warning; } else if (isset( $warning['urgent']) ) { $warning['message'] = $warning['urgent']; $warning['status'] = 'urgent'; $warnings[$id] = $warning; } else if (isset( $warning['premium']) ) { $warning['message'] = $warning['premium']; $warning['status'] = 'premium'; $warnings[$id] = $warning; } } else { if (isset( $warning['completed']) ) { $warning['message'] = $warning['completed']; $warning['status'] = 'completed'; $warning['plus_one'] = false; $warnings[$id] = $warning; } } } set_transient( 'complianz_warnings'.$admin_notice, $warnings, HOUR_IN_SECONDS ); } //filtering outside cache if, to make sure all warnings are saved for the cache. //filter by status if ($args['status'] !== 'all' ) { $filter_statuses = is_array($args['status']) ? $args['status'] : array($args['status']); foreach ($warnings as $id => $warning ) { if ( !in_array( $warning['status'], $filter_statuses) ) { unset( $warnings[$id] ); } } } //filter by plus ones if ($args['plus_ones']) { //if notifications disabled, we return an empty array when the plus ones are requested. if ( $disable_notifications ) { return array(); } foreach ($warnings as $id => $warning ) { //prevent notices on upgrade to 5.0 if ( !isset( $warning['plus_one'])) continue; if ( !$warning['plus_one'] ){ unset($warnings[$id]); } } } //filter for progress bar if ($args['progress_items_only']) { foreach ($warnings as $id => $warning ) { //prevent notices on upgrade to 5.0 if ( !isset( $warning['include_in_progress'])) continue; if ( !$warning['include_in_progress'] ){ unset($warnings[$id]); } } } //sort so warnings are on top $completed = array(); $open = array(); $urgent = array(); $bf_notice = array(); if ( ! empty( $warnings ) ) { foreach ( $warnings as $key => $warning ) { if ( $key === 'bf-notice2023' ) { $bf_notice[$key] = $warning; } elseif ( isset($warning['status']) && $warning['status'] === 'urgent' ) { $urgent[$key] = $warning; } elseif ( isset($warning['status']) && $warning['status'] === 'open' ) { $open[$key] = $warning; } else { $completed[$key] = $warning; } } } return $bf_notice + $urgent + $open + $completed; } /** * Get output of function, in format 'function', or 'class()->sub()->function' * We can pass one variable to the function * @param string $func * @return string|bool */ private function validate_function( $func ){ $invert = false; if (strpos($func, 'NOT ') !== FALSE ) { $func = str_replace('NOT ', '', $func); $invert = true; } if ( empty($func) ) { return true; } if ( strpos($func, 'get_option_') !== false ) { $field = str_replace( 'get_option_', '', $func ); $output = get_option( $field ); } else if ( preg_match( '/get_value_(.*)==(.*)/i', $func, $matches)) { $fieldname = $matches[1]; $value = $matches[2]; $output = cmplz_get_option( $fieldname ) === $value; } else if ( $func === '_true_') { $output = true; } else if ( $func === '_false_' ) { $output = false; } else { if ( preg_match( '/(.*)->(.*)/i', $func, $matches)) { if (preg_match( '/(.*)->(.*)\((.*)\)/i', $func, $sub_matches )) { $class = $sub_matches[1]; $function = $sub_matches[2]; $variable = $sub_matches[3]; $output = COMPLIANZ::${$class}->$function($variable); } else { $class = $matches[1]; $function = $matches[2]; $output = COMPLIANZ::${$class}->$function(); } } else if ( preg_match( '/(.*)\((.*)\)/i', $func, $matches ) ) { $func = $matches[1]; $variable = $matches[2]; $output = $func($variable); } else{ $output = $func(); } } if ( $invert ) { $output = !$output; } return $output; } } } //class closure