settings_service = $settings_service; $this->load_init_files(); } /** * Load init files to use 'validate_plugin' and 'is_plugin_active' * * @since 1.3.0 */ protected function load_init_files() { if ( ! function_exists( 'is_plugin_active' ) ) { require_once ABSPATH . '/wp-admin/includes/plugin.php'; require_once ABSPATH . '/wp-includes/l10n.php'; require_once ABSPATH . '/wp-admin/includes/translation-install.php'; } } /** * Load addon configuration if the plugin is activated * * @throws Exception * @since 1.2.0 * @version 1.3.0 */ public function load_active_addons() { /** * Check if Cookiebot is activated and active. Return if cookiebot is inactive */ if ( ! function_exists( 'cookiebot_active' ) || ! cookiebot_active() ) { return; } if ( Cookiebot_WP::cookiebot_disabled_in_admin() === true && is_admin() ) { return; } /** * Check plugins one by one and load configuration if it is active * * @var $plugin Cookiebot_Addons_Interface */ $addons_enabled_counter = 0; foreach ( $this->settings_service->get_active_addons() as $plugin ) { if ( ! $plugin->cookie_consent->are_cookie_states_accepted( $plugin->get_cookie_types() ) || cookiebot_addons_enabled_cache_plugin() ) { $plugin->load_configuration(); $addons_enabled_counter++; } } /** * After WordPress is fully loaded * * Run buffer output actions - this runs after scanning of every addons */ add_action( 'parse_request', array( $this, 'run_buffer_output_manipulations' ) ); /** * Add notice for the user if any addons is enabled and cookie * blocking mode is set to auto. */ if ( $addons_enabled_counter > 0 && Cookiebot_WP::get_cookie_blocking_mode() === 'auto' ) { //phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'cookiebot', 'cookiebot-addons' ), true ) ) { add_action( 'admin_notices', function() { echo '
' . esc_html__( 'You enabled Cookiebot auto blocking mode but still using addons' ) . '
' . esc_html__( 'In some occasions this may cause client side errors. If you notice any errors please try to disable Cookiebot addons or contact Cookiebot support.' ) . '