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 translations. * * @since 7.4.0 * * @return void */ public function load_textdomain(): void { 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 bool $networkwide Whether the plugin is being activated network-wide. * @return void */ function cmplz_set_activation_time_stamp( $networkwide ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found -- We need this parameter for the activation hook 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' ) ) { /** * Check if a user is logged in for Complianz REST API requests. * * This function determines whether the current request is related to * the Complianz REST API (`/complianz/v1/`) and, if so, checks if a user * is logged in. * * @return bool True if the request is for the Complianz REST API and the user is logged in, false otherwise. */ function cmplz_is_logged_in_rest() { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $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' ) ) { /** * Check if an admin user is 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' ) ) { /** * Assign the 'manage_privacy' capability to administrators. * * This function ensures that the 'administrator' role has the 'manage_privacy' capability. * If the site is part of a multisite network and `$handle_subsites` is true, the capability * is also added to all subsites by recursively applying the function to each subsite. * * @param bool $handle_subsites Whether to apply the capability to all subsites in a multisite network. * Default is true. * * @return void */ 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' ); /** * Assign Complianz management capabilities to a new subsite in a multisite network. * https://awo-obertshausen.de/page-sitemap.xml 2026-08-28T11:18:40+00:00