PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 2.3.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v2.3.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 7 years ago plugin-controller.php 7 years ago
plugin-controller.php
89 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 plugins one by one and load configuration if it is active
58 *
59 * @var $plugin Cookiebot_Addons_Interface
60 */
61 foreach ( $this->settings_service->get_active_addons() as $plugin ) {
62 $plugin->load_configuration();
63 }
64
65 /**
66 * After WordPress is fully loaded
67 *
68 * Run buffer output actions - this runs after scanning of every addons
69 */
70 add_action( 'parse_request', array( $this, 'run_buffer_output_manipulations' ) );
71 }
72
73 /**
74 * Runs every added action hooks to manipulate script tag
75 *
76 * @since 1.3.0
77 */
78 public function run_buffer_output_manipulations() {
79 /**
80 * @var $buffer_output Buffer_Output_Interface
81 */
82 $buffer_output = $this->settings_service->container->get( 'Buffer_Output_Interface' );
83
84 if ( $buffer_output->has_action() ) {
85 $buffer_output->run_actions();
86 }
87 }
88 }
89