PluginProbe
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.6.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.6.0
4.7.3 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 All 93 releases
cookiebot / addons / controller / addons / jetpack / jetpack.php

jetpack.php in Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode 3.6.0, at addons/controller/addons/jetpack/jetpack.php

408 lines 8.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace cookiebot_addons\controller\addons\jetpack;
4
5 use cookiebot_addons\controller\addons\jetpack\widget\Google_Maps_Widget;
6 use cookiebot_addons\controller\addons\jetpack\widget\Facebook_Widget;
7 use cookiebot_addons\controller\addons\jetpack\widget\Googleplus_Badge_Widget;
8 use cookiebot_addons\controller\addons\jetpack\widget\Goodreads_Widget;
9 use cookiebot_addons\controller\addons\jetpack\widget\Internet_Defense_league_Widget;
10 use cookiebot_addons\controller\addons\jetpack\widget\Twitter_Timeline_Widget;
11 use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
12 use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
13 use cookiebot_addons\lib\Cookie_Consent_Interface;
14 use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
15 use cookiebot_addons\lib\Settings_Service_Interface;
16
17 /**
18 * This class is used to support jetpack in cookiebot
19 *
20 * Class Jetpack
21 * @package cookiebot_addons\controller\addons\jetpack
22 *
23 * @since 1.3.0
24 */
25 class Jetpack implements Cookiebot_Addons_Interface {
26
27 /**
28 * @var Settings_Service_Interface
29 *
30 * @since 1.3.0
31 */
32 protected $settings;
33
34 /**
35 * @var Script_Loader_Tag_Interface
36 *
37 * @since 1.3.0
38 */
39 protected $script_loader_tag;
40
41 /**
42 * @var Cookie_Consent_Interface
43 *
44 * @since 1.3.0
45 */
46 public $cookie_consent;
47
48 /**
49 * @var Buffer_Output_Interface
50 *
51 * @since 1.3.0
52 */
53 protected $buffer_output;
54
55 protected $widgets = array();
56
57 /**
58 * Jetpack constructor.
59 *
60 * @param $settings Settings_Service_Interface
61 * @param $script_loader_tag Script_Loader_Tag_Interface
62 * @param $cookie_consent Cookie_Consent_Interface
63 * @param $buffer_output Buffer_Output_Interface
64 *
65 * @since 1.2.0
66 */
67 public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
68 $this->settings = $settings;
69 $this->script_loader_tag = $script_loader_tag;
70 $this->cookie_consent = $cookie_consent;
71 $this->buffer_output = $buffer_output;
72
73 // set widgets
74 if($this->is_addon_enabled()) {
75 $this->set_widgets();
76 }
77 }
78
79 /**
80 * Loads addon configuration
81 *
82 * @since 1.3.0
83 */
84 public function load_configuration() {
85 // load widgets
86 $this->load_widgets();
87 }
88
89 /**
90 * Sets every widget into this class
91 *
92 * @since 1.8.0
93 */
94 public function set_widgets() {
95 /**
96 * Load configuration for google maps widget
97 *
98 * @since 1.2.0
99 */
100 $this->widgets[] = new Google_Maps_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
101
102 /**
103 * Load configuration for internet defense league widget
104 *
105 * @since 1.2.0
106 */
107 $this->widgets[] = new Internet_Defense_league_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
108
109 /**
110 * Load configuration for visitor cookies
111 *
112 * @since 1.2.0
113 */
114 $this->widgets[] = new Visitor_Cookies( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
115
116 /**
117 * Load configuration for twitter timeline widget
118 *
119 * @since 1.2.0
120 */
121 $this->widgets[] = new Twitter_Timeline_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
122
123 /**
124 * Load configuration for goodreads widget
125 *
126 * @since 1.2.0
127 */
128 $this->widgets[] = new Goodreads_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
129
130 /**
131 * Load configuration for facebook widget
132 *
133 * @since 1.2.0
134 */
135 $this->widgets[] = new Facebook_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
136
137 /**
138 * If jetpack version is lower than 7 than add googleplus badge widget
139 *
140 * @since 2.2.1
141 */
142 if( version_compare($this->get_addon_version(), '7', '<' ) ) {
143 /**
144 * Load configuration for googleplus badge widget
145 *
146 * @since 1.2.0
147 */
148 $this->widgets[] = new Googleplus_Badge_Widget( $this->settings, $this->script_loader_tag, $this->cookie_consent, $this->buffer_output, $this->get_widget_option() );
149 }
150 }
151
152 /**
153 * Load widgets configuration
154 *
155 * @since 1.8.0
156 */
157 public function load_widgets() {
158 foreach( $this->get_widgets() as $widget ) {
159 $widget->load_configuration();
160 }
161 }
162
163 /**
164 * Return addon/plugin name
165 *
166 * @return string
167 *
168 * @since 1.3.0
169 */
170 public function get_addon_name() {
171 return 'Jetpack';
172 }
173
174 /**
175 * Option name in the database
176 *
177 * @return string
178 *
179 * @since 1.3.0
180 */
181 public function get_option_name() {
182 return 'jetpack';
183 }
184
185 /**
186 * Returns widget option key for in the database
187 *
188 * @return string
189 *
190 * @since 1.3.0
191 */
192 public function get_widget_option() {
193 return 'cookiebot_jetpack_addon';
194 }
195
196 /**
197 * Plugin file name
198 *
199 * @return string
200 *
201 * @since 1.3.0
202 */
203 public function get_plugin_file() {
204 return 'jetpack/jetpack.php';
205 }
206
207 /**
208 * Returns checked cookie types
209 * @return mixed
210 *
211 * @since 1.3.0
212 */
213 public function get_cookie_types() {
214 return $this->settings->get_cookie_types( $this->get_option_name(), $this->get_default_cookie_types() );
215 }
216
217 /**
218 * Returns default cookie types
219 * @return array
220 *
221 * @since 1.5.0
222 */
223 public function get_default_cookie_types() {
224 return array( 'statistics' );
225 }
226
227 /**
228 * Check if plugin is activated and checked in the backend
229 *
230 * @since 1.3.0
231 */
232 public function is_addon_enabled() {
233 return $this->settings->is_addon_enabled( $this->get_option_name() );
234 }
235
236 /**
237 * Checks if addon is installed
238 *
239 * @since 1.3.0
240 */
241 public function is_addon_installed() {
242 return $this->settings->is_addon_installed( $this->get_plugin_file() );
243 }
244
245 /**
246 * Checks if addon is activated
247 *
248 * @since 1.3.0
249 */
250 public function is_addon_activated() {
251 return $this->settings->is_addon_activated( $this->get_plugin_file() );
252 }
253
254 /**
255 * Retrieves current installed version of the addon
256 *
257 * @return bool
258 *
259 * @since 2.2.1
260 */
261 public function get_addon_version() {
262 return $this->settings->get_addon_version( $this->get_plugin_file() );
263 }
264
265 /**
266 * Returns all supported widgets
267 *
268 * @return array
269 *
270 * @since 1.3.0
271 */
272 public function get_widgets() {
273 return $this->widgets;
274 }
275
276 /**
277 * Default placeholder content
278 *
279 * @return string
280 *
281 * @since 1.8.0
282 */
283 public function get_default_placeholder() {
284 return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
285 }
286
287 /**
288 * Get placeholder content
289 *
290 * This function will check following features:
291 * - Current language
292 *
293 * @param $src
294 *
295 * @return bool|mixed
296 *
297 * @since 1.8.0
298 */
299 public function get_placeholder( $src = '' ) {
300 return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
301 }
302
303 /**
304 * Checks if it does have custom placeholder content
305 *
306 * @return mixed
307 *
308 * @since 1.8.0
309 */
310 public function has_placeholder() {
311 return $this->settings->has_placeholder( $this->get_option_name() );
312 }
313
314 /**
315 * returns all placeholder contents
316 *
317 * @return mixed
318 *
319 * @since 1.8.0
320 */
321 public function get_placeholders() {
322 return $this->settings->get_placeholders( $this->get_option_name() );
323 }
324
325 /**
326 * Return true if the placeholder is enabled
327 *
328 * @return mixed
329 *
330 * @since 1.8.0
331 */
332 public function is_placeholder_enabled() {
333 return $this->settings->is_placeholder_enabled( $this->get_option_name() );
334 }
335
336 /**
337 * Adds extra information under the label
338 *
339 * @return string
340 *
341 * @since 1.8.0
342 */
343 public function get_extra_information() {
344 return false;
345 }
346
347 /**
348 * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
349 *
350 * @return boolean
351 *
352 * @since 1.8.0
353 */
354 public function get_svn_url() {
355 return 'http://plugins.svn.wordpress.org/jetpack/trunk/jetpack.php';
356 }
357
358 /**
359 * Placeholder helper overlay in the settings page.
360 *
361 * @return string
362 *
363 * @since 1.8.0
364 */
365 public function get_placeholder_helper() {
366 return '<p>Merge tags you can use in the placeholder text:</p><ul><li>%cookie_types - Lists required cookie types</li><li>[renew_consent]text[/renew_consent] - link to display cookie settings in frontend</li></ul>';
367 }
368
369
370 /**
371 * Returns parent class or false
372 *
373 * @return string|bool
374 *
375 * @since 2.1.3
376 */
377 public function get_parent_class() {
378 return get_parent_class( $this );
379 }
380
381 /**
382 * Action after enabling the addon on the settings page
383 *
384 * @since 2.2.0
385 */
386 public function post_hook_after_enabling() {
387 //do nothing
388 }
389
390 /**
391 * Cookiebot plugin is deactivated
392 *
393 * @since 2.2.0
394 */
395 public function plugin_deactivated() {
396 //do nothing
397 }
398
399 /**
400 * @return mixed
401 *
402 * @since 2.4.5
403 */
404 public function extra_available_addon_option() {
405 //do nothing
406 }
407 }
408