PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.0.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.0.0
4.7.2 4.7.1 trunk 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.11.1 3.11.2 3.11.3 3.2.0 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.5 3.6.6 3.7.0 3.7.1 3.8.0 3.9.0 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.2.0 4.2.1 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.3.10 4.3.11 4.3.12 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.7.1 4.3.8 4.3.9 4.3.9.1 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.10 4.5.11 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.7.0
cookiebot / addons / controller / plugin-controller.php
cookiebot / addons / controller Last commit date
addons 6 years ago plugin-controller.php 6 years ago
plugin-controller.php
119 lines
1 <?php
2
3 namespace cookiebot_addons\controller;
4
5 use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6 use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
7 use cookiebot_addons\lib\Settings_Service_Interface;
8
9 class Plugin_Controller {
10
11 /**
12 * IoC container - Dependency Injection
13 *
14 * @var Settings_Service_Interface
15 *
16 * @since 1.1.0
17 */
18 private $settings_service;
19
20 /**
21 * Plugin_Controller constructor.
22 *
23 * @param $settings_service Settings_Service_Interface IoC Container
24 *
25 * @since 1.2.0
26 */
27 public function __construct( Settings_Service_Interface $settings_service ) {
28 $this->settings_service = $settings_service;
29
30 $this->load_init_files();
31 }
32
33 /**
34 * Load init files to use 'validate_plugin' and 'is_plugin_active'
35 *
36 * @since 1.3.0
37 */
38 protected function load_init_files() {
39 if ( ! function_exists( 'is_plugin_active' ) ) {
40 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
41 require_once( ABSPATH . '/wp-includes/l10n.php' );
42 require_once( ABSPATH . '/wp-admin/includes/translation-install.php' );
43 }
44 }
45
46 /**
47 * Load addon configuration if the plugin is activated
48 *
49 * @throws \DI\DependencyException
50 * @throws \DI\NotFoundException
51 *
52 * @version 1.3.0
53 * @since 1.2.0
54 */
55 public function load_active_addons() {
56 /**
57 * Check if Cookiebot is activated and active. Return if cookiebot is inactive
58 */
59 if ( ! function_exists( 'cookiebot_active' ) || ! cookiebot_active() ) {
60 return;
61 }
62
63 /**
64 * Check plugins one by one and load configuration if it is active
65 *
66 * @var $plugin Cookiebot_Addons_Interface
67 */
68 $addonsEnabled = 0;
69 foreach ( $this->settings_service->get_active_addons() as $plugin ) {
70 if ( ! $plugin->cookie_consent->are_cookie_states_accepted( $plugin->get_cookie_types() )
71 || cookiebot_addons_enabled_cache_plugin() ) {
72 $plugin->load_configuration();
73 $addonsEnabled++;
74 }
75 }
76
77 /**
78 * After WordPress is fully loaded
79 *
80 * Run buffer output actions - this runs after scanning of every addons
81 */
82 add_action( 'parse_request', array( $this, 'run_buffer_output_manipulations' ) );
83
84
85 /**
86 * Add notice for the user if any addons is enabled and cookie
87 * blocking mode is set to auto.
88 */
89 if($addonsEnabled > 0 && \Cookiebot_WP::get_cookie_blocking_mode() == 'auto') {
90 if(isset($_GET['page']) && in_array($_GET['page'],array('cookiebot','cookiebot-addons'))) {
91 add_action('admin_notices', function() {
92 echo '<div class="notice notice-warning">
93 <p>
94 <strong>'.__('You enabled Cookiebot auto blocking mode but still using addons').'</strong><br>
95 '.__('In some occasions this may cause client side errors. If you notice any errors please try to disable Cookiebot addons or contact Cookiebot support.').'
96 </p>
97 </div>';
98 });
99 }
100 }
101 }
102
103 /**
104 * Runs every added action hooks to manipulate script tag
105 *
106 * @since 1.3.0
107 */
108 public function run_buffer_output_manipulations() {
109 /**
110 * @var $buffer_output Buffer_Output_Interface
111 */
112 $buffer_output = $this->settings_service->container->get( 'Buffer_Output_Interface' );
113
114 if ( $buffer_output->has_action() ) {
115 $buffer_output->run_actions();
116 }
117 }
118 }
119