PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.8.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.8.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 5 years ago plugin-controller.php 6 years ago
plugin-controller.php
123 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 if( \Cookiebot_WP::cookiebot_disabled_in_admin() === true && is_admin() ) {
64 return;
65 }
66
67 /**
68 * Check plugins one by one and load configuration if it is active
69 *
70 * @var $plugin Cookiebot_Addons_Interface
71 */
72 $addonsEnabled = 0;
73 foreach ( $this->settings_service->get_active_addons() as $plugin ) {
74 if ( ! $plugin->cookie_consent->are_cookie_states_accepted( $plugin->get_cookie_types() )
75 || cookiebot_addons_enabled_cache_plugin() ) {
76 $plugin->load_configuration();
77 $addonsEnabled++;
78 }
79 }
80
81 /**
82 * After WordPress is fully loaded
83 *
84 * Run buffer output actions - this runs after scanning of every addons
85 */
86 add_action( 'parse_request', array( $this, 'run_buffer_output_manipulations' ) );
87
88
89 /**
90 * Add notice for the user if any addons is enabled and cookie
91 * blocking mode is set to auto.
92 */
93 if($addonsEnabled > 0 && \Cookiebot_WP::get_cookie_blocking_mode() == 'auto') {
94 if(isset($_GET['page']) && in_array($_GET['page'],array('cookiebot','cookiebot-addons'))) {
95 add_action('admin_notices', function() {
96 echo '<div class="notice notice-warning">
97 <p>
98 <strong>'.__('You enabled Cookiebot auto blocking mode but still using addons').'</strong><br>
99 '.__('In some occasions this may cause client side errors. If you notice any errors please try to disable Cookiebot addons or contact Cookiebot support.').'
100 </p>
101 </div>';
102 });
103 }
104 }
105 }
106
107 /**
108 * Runs every added action hooks to manipulate script tag
109 *
110 * @since 1.3.0
111 */
112 public function run_buffer_output_manipulations() {
113 /**
114 * @var $buffer_output Buffer_Output_Interface
115 */
116 $buffer_output = $this->settings_service->container->get( 'Buffer_Output_Interface' );
117
118 if ( $buffer_output->has_action() ) {
119 $buffer_output->run_actions();
120 }
121 }
122 }
123