PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.2.4
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.2.4
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 / lib / Consent_API_Helper.php
cookiebot / src / lib Last commit date
buffer 4 years ago script_loader_tag 4 years ago traits 4 years ago Consent_API_Helper.php 4 years ago Cookie_Consent.php 4 years ago Cookie_Consent_Interface.php 4 years ago Cookiebot_Activated.php 4 years ago Cookiebot_Automatic_Updates.php 4 years ago Cookiebot_Deactivated.php 4 years ago Cookiebot_Javascript_Helper.php 4 years ago Cookiebot_WP.php 3 years ago Dependency_Container.php 4 years ago Settings_Page_Tab.php 4 years ago Settings_Service.php 4 years ago Settings_Service_Interface.php 4 years ago Supported_Languages.php 4 years ago Supported_Regions.php 3 years ago WP_Rocket_Helper.php 4 years ago Widgets.php 4 years ago global-deprecations.php 4 years ago helper.php 4 years ago
Consent_API_Helper.php
144 lines
1 <?php
2
3 namespace cybot\cookiebot\lib;
4
5 use InvalidArgumentException;
6
7 class Consent_API_Helper {
8 public function register_hooks() {
9 //Include integration to WP Consent Level API if available
10 if ( $this->is_wp_consent_api_active() ) {
11 add_action( 'wp_enqueue_scripts', array( $this, 'cookiebot_enqueue_consent_api_scripts' ) );
12 }
13 }
14
15 /**
16 * Cookiebot_WP Check if WP Cookie Consent API is active
17 *
18 * @version 3.5.0
19 * @since 3.5.0
20 */
21 public function is_wp_consent_api_active() {
22 return class_exists( 'WP_CONSENT_API' );
23 }
24
25 /**
26 * Cookiebot_WP Enqueue JS for integration with WP Consent Level API
27 *
28 * @throws InvalidArgumentException
29 * @since 3.5.0
30 * @version 3.5.0
31 */
32 public function cookiebot_enqueue_consent_api_scripts() {
33 wp_register_script(
34 'cookiebot-wp-consent-level-api-integration',
35 asset_url( 'js/frontend/cookiebot-wp-consent-level-api-integration.js' ),
36 null,
37 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION,
38 false
39 );
40 wp_enqueue_script( 'cookiebot-wp-consent-level-api-integration' );
41 wp_localize_script(
42 'cookiebot-wp-consent-level-api-integration',
43 'cookiebot_category_mapping',
44 $this->get_wp_consent_api_mapping()
45 );
46 }
47
48 /**
49 * Cookiebot_WP Get the mapping between Consent Level API and Cookiebot
50 * Returns array where key is the consent level api category and value
51 * is the mapped Cookiebot category.
52 *
53 * @version 3.5.0
54 * @since 3.5.0
55 */
56 public function get_wp_consent_api_mapping() {
57 $default_wp_consent_api_mapping = $this->get_default_wp_consent_api_mapping();
58 $mapping = get_option( 'cookiebot-consent-mapping', $default_wp_consent_api_mapping );
59
60 $mapping = ( '' === $mapping ) ? $default_wp_consent_api_mapping : $mapping;
61
62 foreach ( $default_wp_consent_api_mapping as $k => $v ) {
63 if ( ! isset( $mapping[ $k ] ) ) {
64 $mapping[ $k ] = $v;
65 } else {
66 foreach ( $v as $vck => $vcv ) {
67 if ( ! isset( $mapping[ $k ][ $vck ] ) ) {
68 $mapping[ $k ][ $vck ] = $vcv;
69 }
70 }
71 }
72 }
73
74 return $mapping;
75 }
76
77 /**
78 * Cookiebot_WP Default consent level mappings
79 *
80 * @version 3.5.0
81 * @since 3.5.0
82 */
83 public function get_default_wp_consent_api_mapping() {
84 return array(
85 'n=1;p=1;s=1;m=1' =>
86 array(
87 'preferences' => 1,
88 'statistics' => 1,
89 'statistics-anonymous' => 0,
90 'marketing' => 1,
91 ),
92 'n=1;p=1;s=1;m=0' =>
93 array(
94 'preferences' => 1,
95 'statistics' => 1,
96 'statistics-anonymous' => 1,
97 'marketing' => 0,
98 ),
99 'n=1;p=1;s=0;m=1' =>
100 array(
101 'preferences' => 1,
102 'statistics' => 0,
103 'statistics-anonymous' => 0,
104 'marketing' => 1,
105 ),
106 'n=1;p=1;s=0;m=0' =>
107 array(
108 'preferences' => 1,
109 'statistics' => 0,
110 'statistics-anonymous' => 0,
111 'marketing' => 0,
112 ),
113 'n=1;p=0;s=1;m=1' =>
114 array(
115 'preferences' => 0,
116 'statistics' => 1,
117 'statistics-anonymous' => 0,
118 'marketing' => 1,
119 ),
120 'n=1;p=0;s=1;m=0' =>
121 array(
122 'preferences' => 0,
123 'statistics' => 1,
124 'statistics-anonymous' => 0,
125 'marketing' => 0,
126 ),
127 'n=1;p=0;s=0;m=1' =>
128 array(
129 'preferences' => 0,
130 'statistics' => 0,
131 'statistics-anonymous' => 0,
132 'marketing' => 1,
133 ),
134 'n=1;p=0;s=0;m=0' =>
135 array(
136 'preferences' => 0,
137 'statistics' => 0,
138 'statistics-anonymous' => 0,
139 'marketing' => 0,
140 ),
141 );
142 }
143 }
144