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