PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.0.1
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.0.1
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 / src / addons / controller / Plugin_Controller.php
cookiebot / src / addons / controller Last commit date
addons 4 years ago Plugin_Controller.php 4 years ago
Plugin_Controller.php
95 lines
1 <?php
2
3 namespace cybot\cookiebot\addons\controller;
4
5 use cybot\cookiebot\addons\controller\addons\Base_Cookiebot_Addon;
6 use cybot\cookiebot\lib\buffer\Buffer_Output_Interface;
7 use cybot\cookiebot\lib\Settings_Service_Interface;
8 use cybot\cookiebot\lib\Cookiebot_WP;
9 use Exception;
10 use function cybot\cookiebot\lib\cookiebot_addons_enabled_cache_plugin;
11 use function cybot\cookiebot\lib\cookiebot_active;
12
13 class Plugin_Controller {
14
15 /**
16 * @var Settings_Service_Interface
17 */
18 private $settings_service;
19
20 /**
21 * @param Settings_Service_Interface $settings_service
22 */
23 public function __construct( Settings_Service_Interface $settings_service ) {
24 $this->settings_service = $settings_service;
25 }
26
27 /**
28 * @throws Exception
29 */
30 public function load_active_addons() {
31 if ( ! cookiebot_active() ) {
32 return;
33 }
34
35 if ( Cookiebot_WP::cookiebot_disabled_in_admin() === true && is_admin() ) {
36 return;
37 }
38
39 $addons_enabled_counter = 0;
40 /** @var Base_Cookiebot_Addon $addon */
41 foreach ( $this->settings_service->get_active_addons() as $addon ) {
42 if ( ! $addon->cookie_consent->are_cookie_states_accepted( $addon->get_cookie_types() )
43 || cookiebot_addons_enabled_cache_plugin() ) {
44 $addon->load_addon_configuration();
45 $addons_enabled_counter++;
46 }
47 }
48
49 /**
50 * After WordPress is fully loaded
51 *
52 * Run buffer output actions - this runs after scanning of every addons
53 */
54 add_action( 'parse_request', array( $this, 'run_buffer_output_manipulations' ) );
55
56 /**
57 * Add notice for the user if any addons is enabled and cookie
58 * blocking mode is set to auto.
59 */
60 if ( $addons_enabled_counter > 0 && Cookiebot_WP::get_cookie_blocking_mode() === 'auto' ) {
61 //phpcs:ignore WordPress.Security.NonceVerification.Recommended
62 if ( isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'cookiebot', 'cookiebot-addons' ), true ) ) {
63 add_action(
64 'admin_notices',
65 function() {
66 echo '<div class="notice notice-warning">
67 <p>
68 <strong>' . esc_html__( 'You enabled Cookiebot auto blocking mode but still using addons', 'cookiebot' ) . '</strong><br>
69 ' . 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.', 'cookiebot' ) . '
70 </p>
71 </div>';
72 }
73 );
74 }
75 }
76 }
77
78 /**
79 * Runs every added action hooks to manipulate script tag
80 *
81 * @throws Exception
82 * @since 1.3.0
83 */
84 public function run_buffer_output_manipulations() {
85 /**
86 * @var $buffer_output Buffer_Output_Interface
87 */
88 $buffer_output = $this->settings_service->container->get( 'Buffer_Output_Interface' );
89
90 if ( $buffer_output->has_action() ) {
91 $buffer_output->run_actions();
92 }
93 }
94 }
95