PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.5.8
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.5.8
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 1 year ago Plugin_Controller.php 1 year ago
Plugin_Controller.php
104 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
17 /**
18 * @var Settings_Service_Interface
19 */
20 private $settings_service;
21
22 /**
23 * @param Settings_Service_Interface $settings_service
24 */
25 public function __construct( Settings_Service_Interface $settings_service ) {
26 $this->settings_service = $settings_service;
27 }
28
29 /**
30 * @throws Exception
31 */
32 public function load_active_addons() {
33 if ( ! cookiebot_active() ) {
34 return;
35 }
36
37 /**
38 * Add notice for the user if any addons is enabled and cookie
39 * blocking mode is set to auto.
40 */
41 if ( count( $this->settings_service->get_active_addons() ) > 0 &&
42 Cookiebot_WP::get_cookie_blocking_mode() === 'auto' &&
43 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
44 isset( $_GET['page'] ) &&
45 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
46 in_array( $_GET['page'], array( 'cookiebot', 'cookiebot-addons' ), true ) ) {
47 add_action(
48 'admin_notices',
49 function () {
50 echo '<div class="notice notice-warning"><p><strong>' .
51 esc_html__(
52 'You enabled Cookiebot™ auto blocking mode but still using addons',
53 'cookiebot'
54 ) .
55 '</strong><br>' .
56 esc_html__(
57 'In some occasions this may cause client side errors. If you notice any errors please try to disable Cookiebot™ addons or contact Cookiebot™ support.',
58 'cookiebot'
59 ) .
60 '</p></div>';
61 }
62 );
63 }
64
65 if ( Cookiebot_WP::cookiebot_disabled_in_admin() === true && is_admin() ) {
66 return;
67 }
68
69 $addons_enabled_counter = 0;
70 /** @var Base_Cookiebot_Addon $addon */
71 foreach ( $this->settings_service->get_active_addons() as $addon ) {
72 if ( ! $addon->cookie_consent->are_cookie_states_accepted( $addon->get_cookie_types() )
73 || cookiebot_addons_enabled_cache_plugin() ) {
74 $addon->load_addon_configuration();
75 ++$addons_enabled_counter;
76 }
77 }
78
79 /**
80 * After WordPress is fully loaded
81 *
82 * Run buffer output actions - this runs after scanning of every addons
83 */
84 add_action( 'parse_request', array( $this, 'run_buffer_output_manipulations' ) );
85 }
86
87 /**
88 * Runs every added action hooks to manipulate script tag
89 *
90 * @throws Exception
91 * @since 1.3.0
92 */
93 public function run_buffer_output_manipulations() {
94 /**
95 * @var $buffer_output Buffer_Output_Interface
96 */
97 $buffer_output = $this->settings_service->container->get( 'Buffer_Output_Interface' );
98
99 if ( $buffer_output->has_action() ) {
100 $buffer_output->run_actions();
101 }
102 }
103 }
104