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 \DI\DependencyException * @throws \DI\NotFoundException * * @version 1.3.0 * @since 1.2.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 */ $addonsEnabled = 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(); $addonsEnabled++; } } /** * 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($addonsEnabled > 0 && \Cookiebot_WP::get_cookie_blocking_mode() == 'auto') { if(isset($_GET['page']) && in_array($_GET['page'],array('cookiebot','cookiebot-addons'))) { add_action('admin_notices', function() { echo '
'.__('You enabled Cookiebot auto blocking mode but still using addons').'
'.__('In some occasions this may cause client side errors. If you notice any errors please try to disable Cookiebot addons or contact Cookiebot support.').'