PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.2.13
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.2.13
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 / config / Settings_Config.php
cookiebot / src / addons / config Last commit date
Settings_Config.php 3 years ago
Settings_Config.php
696 lines
1 <?php
2
3 namespace cybot\cookiebot\addons\config;
4
5 use cybot\cookiebot\addons\controller\addons\Base_Cookiebot_Addon;
6 use cybot\cookiebot\addons\controller\addons\Base_Cookiebot_Plugin_Addon;
7 use cybot\cookiebot\addons\controller\addons\Base_Cookiebot_Theme_Addon;
8 use cybot\cookiebot\addons\controller\addons\jetpack\Jetpack;
9 use cybot\cookiebot\addons\controller\addons\jetpack\widget\Base_Jetpack_Widget;
10 use cybot\cookiebot\lib\Settings_Page_Tab;
11 use cybot\cookiebot\lib\Settings_Service_Interface;
12 use cybot\cookiebot\lib\Cookiebot_WP;
13 use Exception;
14 use InvalidArgumentException;
15 use ReflectionClass;
16 use function cybot\cookiebot\lib\asset_url;
17 use function cybot\cookiebot\lib\cookiebot_addons_get_dropdown_languages;
18 use function cybot\cookiebot\lib\get_view_html;
19 use function cybot\cookiebot\lib\include_view;
20
21 class Settings_Config {
22 /**
23 * @var Settings_Service_Interface
24 */
25 protected $settings_service;
26
27 const ADMIN_SLUG = 'cookiebot-addons';
28 const LANGUAGE_DROPDOWN_OPTION_REPLACE = '%optionname%';
29 const JETPACK_DEFAULT_LANGUAGE_DROPDOWN = 'cookiebot_jetpack_addon[%optionname%][placeholder][languages][site-default]';
30 const ADDONS_DEFAULT_LANGUAGE_DROPDOWN = 'cookiebot_available_addons[%optionname%][placeholder][languages][site-default]';
31 // Templates
32 const INFO_HEADER_TEMPLATE = 'admin/settings/prior-consent/partials/info-tab-header.php';
33 const EXTRA_INFO_TEMPLATE = 'admin/settings/prior-consent/partials/extra-information.php';
34 const JETPACK_TAB_HEADER_TEMPLATE = 'admin/settings/prior-consent/jetpack-widgets/tab-header.php';
35 const JETPACK_WIDGET_TAB_TEMPLATE = 'admin/settings/prior-consent/jetpack-widgets/tab.php';
36 const PLACEHOLDER_TEMPLATE = 'admin/settings/prior-consent/partials/placeholder-submitboxes.php';
37 const DEFAULT_PLACEHOLDER_TEMPLATE = 'admin/settings/prior-consent/partials/placeholder-submitbox-default.php';
38 const AVAILABLE_TAB_HEADER_TEMPLATE = 'admin/settings/prior-consent/available-addons/tab-header.php';
39 const AVAILABLE_ADDONS_TAB_TEMPLATE = 'admin/settings/prior-consent/available-addons/tab.php';
40 const UNAVAILABLE_TAB_HEADER_TEMPLATE = 'admin/settings/prior-consent/unavailable-addons/tab-header.php';
41 const UNAVAILABLE_ADDONS_TAB_TEMPLATE = 'admin/settings/prior-consent/unavailable-addons/field.php';
42 // Other
43 const INFO_ICON_ASSET_URL = 'img/icons/info.svg';
44
45 /**
46 * Settings_Config constructor.
47 *
48 * @param Settings_Service_Interface $settings_service
49 *
50 * @since 1.3.0
51 */
52 public function __construct( Settings_Service_Interface $settings_service ) {
53 $this->settings_service = $settings_service;
54 }
55
56 /**
57 * Load data for settings page
58 *
59 * @since 1.3.0
60 */
61 public function load() {
62 add_action( 'admin_menu', array( $this, 'add_submenu' ), 2 );
63 add_action( 'admin_init', array( $this, 'register_settings' ) );
64 add_action( 'admin_enqueue_scripts', array( $this, 'add_wp_admin_style_script' ) );
65 add_action(
66 'update_option_cookiebot_available_addons',
67 array(
68 $this,
69 'post_hook_available_addons_update_option',
70 ),
71 10,
72 3
73 );
74 }
75
76 /**
77 * Registers submenu in options menu.
78 *
79 * @since 1.3.0
80 */
81 public function add_submenu() {
82 add_submenu_page(
83 'cookiebot',
84 esc_html__( 'Plugins', 'cookiebot' ),
85 esc_html__( 'Plugins', 'cookiebot' ),
86 'manage_options',
87 'cookiebot-addons',
88 array(
89 $this,
90 'setting_page',
91 ),
92 2
93 );
94 }
95
96 /**
97 * Load css styling to the settings page
98 *
99 * @throws InvalidArgumentException
100 * @since 1.3.0
101 */
102 public function add_wp_admin_style_script( $hook ) {
103 if ( $hook !== 'cookiebot_page_cookiebot-addons' ) {
104 return;
105 }
106
107 wp_enqueue_script(
108 'cookiebot_tiptip_js',
109 asset_url( 'js/backend/jquery.tipTip.js' ),
110 array( 'jquery' ),
111 '1.8',
112 true
113 );
114 wp_enqueue_script(
115 'cookiebot_addons_custom_js',
116 asset_url( 'js/backend/prior-consent-settings.js' ),
117 array( 'jquery' ),
118 '1.8',
119 true
120 );
121 wp_localize_script(
122 'cookiebot_addons_custom_js',
123 'php',
124 array( 'remove_link' => ' <a href="" class="submitdelete deletion">' . esc_html__( 'Remove language', 'cookiebot' ) . '</a>' )
125 );
126 wp_enqueue_style(
127 'cookiebot_addons_custom_css',
128 asset_url( 'css/backend/addons_page.css' ),
129 null,
130 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
131 );
132 wp_enqueue_style(
133 'cookiebot_admin_css',
134 asset_url( 'css/backend/cookiebot_admin_main.css' ),
135 null,
136 Cookiebot_WP::COOKIEBOT_PLUGIN_VERSION
137 );
138 }
139
140 /**
141 * Registers addons for settings page.
142 *
143 * @throws Exception
144 * @since 1.3.0
145 */
146 public function register_settings() {
147 global $pagenow;
148
149 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
150 if ( ( isset( $_GET['page'] ) && $_GET['page'] === 'cookiebot-addons' ) || $pagenow === 'options.php' ) {
151 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
152 if ( isset( $_GET['tab'] ) && 'unavailable_addons' === $_GET['tab'] ) {
153 $this->register_unavailable_addons();
154 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
155 } elseif ( isset( $_GET['tab'] ) && 'available_addons' === $_GET['tab'] ) {
156 $this->register_available_addons();
157 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
158 } elseif ( isset( $_GET['tab'] ) && 'jetpack' === $_GET['tab'] ) {
159 $this->register_jetpack_addon();
160 } else {
161 $this->register_addons_info();
162 }
163
164 if ( $pagenow === 'options.php' ) {
165 $this->register_jetpack_addon();
166 $this->register_available_addons();
167 }
168 }
169 }
170
171 /**
172 * Register addons info
173 *
174 * @throws Exception
175 * @since 1.3.0
176 */
177 private function register_addons_info() {
178 add_settings_section(
179 'info_addons',
180 '',
181 array(
182 $this,
183 'header_addons_info',
184 ),
185 'cookiebot-addons'
186 );
187 }
188
189 /**
190 * Returns header for info tab
191 *
192 * @since 1.3.0
193 */
194 public function header_addons_info() {
195 include_view( self::INFO_HEADER_TEMPLATE );
196 }
197
198 /**
199 * Register available addons
200 *
201 * @throws Exception
202 * @since 1.3.0
203 */
204 private function register_available_addons() {
205 add_settings_section(
206 'available_addons',
207 '',
208 array(
209 $this,
210 'header_available_addons',
211 ),
212 'cookiebot-addons'
213 );
214
215 /** @var Base_Cookiebot_Addon $addon */
216 foreach ( $this->settings_service->get_addons() as $addon ) {
217 if ( $addon->is_addon_installed() && $addon->is_addon_activated() ) {
218 add_settings_field(
219 $addon::OPTION_NAME,
220 get_view_html(
221 $this::EXTRA_INFO_TEMPLATE,
222 array(
223 'label' => $addon::ADDON_NAME,
224 'extra_information_lines' => $addon->get_extra_information(),
225 )
226 ),
227 array(
228 $this,
229 'available_addon_callback',
230 ),
231 'cookiebot-addons',
232 'available_addons',
233 array(
234 'addon' => $addon,
235 )
236 );
237
238 register_setting(
239 'cookiebot_available_addons',
240 'cookiebot_available_addons',
241 array(
242 $this,
243 'sanitize_cookiebot',
244 )
245 );
246 }
247 }
248 }
249
250 /**
251 * Register jetpack addon - new tab for jetpack specific settings
252 *
253 * @throws Exception
254 * @since 1.3.0
255 */
256 private function register_jetpack_addon() {
257 add_settings_section(
258 'jetpack_addon',
259 '',
260 array(
261 $this,
262 'jetpack_addons_header_callback',
263 ),
264 'cookiebot-addons'
265 );
266
267 /** @var Jetpack $addon */
268 foreach ( $this->settings_service->get_addons() as $addon ) {
269 if ( 'Jetpack' === ( new ReflectionClass( $addon ) )->getShortName() &&
270 $addon->is_addon_installed() && $addon->is_addon_activated() ) {
271 foreach ( $addon->get_widgets() as $widget ) {
272 add_settings_field(
273 $widget->get_widget_option_name(),
274 get_view_html(
275 $this::EXTRA_INFO_TEMPLATE,
276 array(
277 'label' => $widget->get_label(),
278 'extra_information_lines' => $widget->get_extra_information(),
279 )
280 ),
281 array(
282 $this,
283 'jetpack_addon_callback',
284 ),
285 'cookiebot-addons',
286 'jetpack_addon',
287 array(
288 'widget' => $widget,
289 'addon' => $addon,
290 )
291 );
292
293 register_setting( 'cookiebot_jetpack_addon', 'cookiebot_jetpack_addon' );
294 }
295 }
296 }
297 }
298
299 /**
300 * Registers unavailabe addons
301 *
302 * @throws Exception
303 * @version 2.1.3
304 * @since 1.3.0
305 */
306 private function register_unavailable_addons() {
307 add_settings_section(
308 'unavailable_addons',
309 '',
310 array(
311 $this,
312 'unavailable_addons_header_callback',
313 ),
314 'cookiebot-addons'
315 );
316
317 $addons = $this->settings_service->get_addons();
318
319 /** @var Base_Cookiebot_Addon $addon */
320 foreach ( $addons as $addon ) {
321 if ( ! $addon->is_addon_installed() || ! $addon->is_addon_activated() ) {
322 // not installed plugins
323 add_settings_field(
324 $addon::ADDON_NAME,
325 get_view_html(
326 $this::EXTRA_INFO_TEMPLATE,
327 array(
328 'label' => $addon::ADDON_NAME,
329 'extra_information_lines' => $addon->get_extra_information(),
330 )
331 ),
332 array(
333 $this,
334 'unavailable_addon_settings_field_callback',
335 ),
336 'cookiebot-addons',
337 'unavailable_addons',
338 array( 'addon' => $addon )
339 );
340 register_setting( $addon::OPTION_NAME, 'cookiebot_unavailable_addons' );
341 }
342 }
343 }
344
345 /**
346 * Jetpack tab - header
347 *
348 * @throws InvalidArgumentException
349 * @since 1.3.0
350 */
351 public function jetpack_addons_header_callback() {
352 include_view( self::JETPACK_TAB_HEADER_TEMPLATE );
353 }
354
355 /**
356 * Jetpack tab - widget callback
357 *
358 * @param $args array Information about the widget addon and the option
359 *
360 * @throws InvalidArgumentException
361 * @since 1.3.0
362 */
363 public function jetpack_addon_callback( $args ) {
364 $widget = isset( $args['widget'] ) ? $args['widget'] : null;
365 $addon = isset( $args['addon'] ) ? $args['addon'] : null;
366
367 if ( ! is_a( $widget, Base_Jetpack_Widget::class ) ) {
368 throw new InvalidArgumentException();
369 }
370
371 if ( ! is_a( $addon, Base_Cookiebot_Addon::class ) ) {
372 throw new InvalidArgumentException();
373 }
374
375 $widget_is_enabled = $widget->is_widget_enabled();
376 $widget_placeholder_is_enabled = $widget->is_widget_placeholder_enabled();
377 $widget_default_placeholder = $widget->get_widget_default_placeholder();
378 $widget_option_name = $widget->get_widget_option_name();
379 $widget_placeholders_array = $widget->get_widget_placeholders();
380 $widget_placeholders_array_keys = array_keys( $widget_placeholders_array );
381 $first_placeholder_language = isset( $widget_placeholders_array_keys[0] )
382 ? $widget_placeholders_array_keys[0]
383 : null;
384 $site_default_languages_dropdown_html = cookiebot_addons_get_dropdown_languages(
385 'placeholder_select_language',
386 str_replace(
387 self::LANGUAGE_DROPDOWN_OPTION_REPLACE,
388 $widget_option_name,
389 self::JETPACK_DEFAULT_LANGUAGE_DROPDOWN
390 ),
391 'site-default'
392 );
393 $widget_placeholders = array_map(
394 function (
395 $language,
396 $placeholder
397 ) use (
398 $widget_option_name,
399 $first_placeholder_language
400 ) {
401 $removable = $first_placeholder_language !== $language;
402 $option_name = str_replace(
403 array( self::LANGUAGE_DROPDOWN_OPTION_REPLACE, 'site-default' ),
404 array( $widget_option_name, $language ),
405 self::JETPACK_DEFAULT_LANGUAGE_DROPDOWN
406 );
407 $languages_dropdown_html = cookiebot_addons_get_dropdown_languages(
408 'placeholder_select_language',
409 $option_name,
410 $language
411 );
412 return array(
413 'name' => $option_name,
414 'removable' => $removable,
415 'language' => $language,
416 'placeholder' => $placeholder,
417 'languages_dropdown_html' => $languages_dropdown_html,
418 );
419 },
420 array_keys( $widget_placeholders_array ),
421 array_values( $widget_placeholders_array )
422 );
423 $placeholder_helper = $addon->get_placeholder_helper();
424 $placeholders_html = $widget->widget_has_placeholder()
425 ? get_view_html(
426 self::PLACEHOLDER_TEMPLATE,
427 array(
428 'placeholders' => $widget_placeholders,
429 'placeholder_helper' => $placeholder_helper,
430 'info_icon' => asset_url( self::INFO_ICON_ASSET_URL ),
431 )
432 )
433 : get_view_html(
434 self::DEFAULT_PLACEHOLDER_TEMPLATE,
435 array(
436 'site_default_languages_dropdown_html' => $site_default_languages_dropdown_html,
437 'name' => str_replace(
438 self::LANGUAGE_DROPDOWN_OPTION_REPLACE,
439 $widget_option_name,
440 self::JETPACK_DEFAULT_LANGUAGE_DROPDOWN
441 ),
442 'default_placeholder' => $widget_default_placeholder,
443 'placeholder_helper' => $placeholder_helper,
444 'info_icon' => asset_url( self::INFO_ICON_ASSET_URL ),
445 )
446 );
447
448 $view_args = array(
449 'widget_option_name' => $widget_option_name,
450 'widget_is_enabled' => $widget_is_enabled,
451 'widget_cookie_types' => $widget->get_widget_cookie_types(),
452 'widget_placeholder_is_enabled' => $widget_placeholder_is_enabled,
453 'placeholders_html' => $placeholders_html,
454 );
455
456 include_view( self::JETPACK_WIDGET_TAB_TEMPLATE, $view_args );
457 }
458
459 /**
460 * Returns header for installed plugins
461 *
462 * @since 1.3.0
463 */
464 public function header_available_addons() {
465 include_view( self::AVAILABLE_TAB_HEADER_TEMPLATE );
466 }
467
468 /**
469 * Available addon callback:
470 * - checkbox to enable
471 * - select field for cookie type
472 *
473 * @param $args
474 *
475 * @throws InvalidArgumentException
476 * @since 1.3.0
477 */
478 public function available_addon_callback( $args ) {
479 $addon = isset( $args['addon'] ) ? $args['addon'] : null;
480
481 if ( ! is_a( $addon, Base_Cookiebot_Addon::class ) ) {
482 throw new InvalidArgumentException();
483 }
484
485 $site_default_languages_dropdown_html = cookiebot_addons_get_dropdown_languages(
486 'placeholder_select_language',
487 str_replace(
488 self::LANGUAGE_DROPDOWN_OPTION_REPLACE,
489 $addon::OPTION_NAME,
490 self::ADDONS_DEFAULT_LANGUAGE_DROPDOWN
491 ),
492 'site-default'
493 );
494 $addon_placeholders_array = $addon->get_placeholders();
495 $addon_placeholders_array_keys = array_keys( $addon_placeholders_array );
496 $first_placeholder_language = isset( $addon_placeholders_array_keys[0] )
497 ? $addon_placeholders_array_keys[0]
498 : null;
499 $addon_placeholders = array_map(
500 function (
501 $language,
502 $placeholder
503 ) use (
504 $addon,
505 $first_placeholder_language
506 ) {
507 $removable = $first_placeholder_language !== $language;
508 $option_name = str_replace(
509 array( self::LANGUAGE_DROPDOWN_OPTION_REPLACE, 'site-default' ),
510 array( $addon::OPTION_NAME, $language ),
511 self::ADDONS_DEFAULT_LANGUAGE_DROPDOWN
512 );
513 $languages_dropdown_html = cookiebot_addons_get_dropdown_languages(
514 'placeholder_select_language',
515 $option_name,
516 $language
517 );
518 return array(
519 'name' => $option_name,
520 'removable' => $removable,
521 'language' => $language,
522 'placeholder' => $placeholder,
523 'languages_dropdown_html' => $languages_dropdown_html,
524 );
525 },
526 $addon_placeholders_array_keys,
527 $addon_placeholders_array
528 );
529 $placeholder_helper = $addon->get_placeholder_helper();
530 $addon_extra_options_html = $addon->get_extra_addon_options_html();
531 $placeholders_html = $addon->has_placeholder()
532 ? get_view_html(
533 self::PLACEHOLDER_TEMPLATE,
534 array(
535 'placeholders' => $addon_placeholders,
536 'placeholder_helper' => $placeholder_helper,
537 'info_icon' => asset_url( self::INFO_ICON_ASSET_URL ),
538 )
539 )
540 : get_view_html(
541 self::DEFAULT_PLACEHOLDER_TEMPLATE,
542 array(
543 'site_default_languages_dropdown_html' => $site_default_languages_dropdown_html,
544 'name' => str_replace(
545 self::LANGUAGE_DROPDOWN_OPTION_REPLACE,
546 $addon::OPTION_NAME,
547 self::ADDONS_DEFAULT_LANGUAGE_DROPDOWN
548 ),
549 'default_placeholder' => $addon::DEFAULT_PLACEHOLDER_CONTENT,
550 'placeholder_helper' => $placeholder_helper,
551 'info_icon' => asset_url( self::INFO_ICON_ASSET_URL ),
552 )
553 );
554
555 $view_args = array(
556 'addon_option_name' => $addon::OPTION_NAME,
557 'addon_is_enabled' => $addon->is_addon_enabled(),
558 'addon_cookie_types' => $addon->get_cookie_types(),
559 'addon_placeholder_is_enabled' => $addon->is_placeholder_enabled(),
560 'placeholders_html' => $placeholders_html,
561 'addon_extra_options_html' => $addon_extra_options_html,
562 );
563
564 include_view( self::AVAILABLE_ADDONS_TAB_TEMPLATE, $view_args );
565 }
566
567 /**
568 * Returns header for unavailable plugins
569 *
570 * @throws InvalidArgumentException
571 * @since 1.3.0
572 */
573 public function unavailable_addons_header_callback() {
574 include_view( self::UNAVAILABLE_TAB_HEADER_TEMPLATE );
575 }
576
577 /**
578 * @param $args
579 *
580 * @throws InvalidArgumentException
581 */
582 public function unavailable_addon_settings_field_callback( $args ) {
583 $addon = $args['addon'];
584
585 if ( ! is_a( $addon, Base_Cookiebot_Addon::class ) ) {
586 throw new InvalidArgumentException();
587 }
588
589 $message = '';
590 if ( ! $addon->is_addon_installed() ) {
591 if ( is_a( $addon, Base_Cookiebot_Plugin_Addon::class ) ) {
592 $message = __( 'The plugin is not installed.', 'cookiebot' );
593 }
594 if ( is_a( $addon, Base_Cookiebot_Theme_Addon::class ) ) {
595 $message = __( 'The theme is not installed.', 'cookiebot' );
596 }
597 } elseif ( ! $addon->is_addon_activated() ) {
598 if ( is_a( $addon, Base_Cookiebot_Plugin_Addon::class ) ) {
599 $message = __( 'The plugin is not activated.', 'cookiebot' );
600 }
601 if ( is_a( $addon, Base_Cookiebot_Theme_Addon::class ) ) {
602 $message = __( 'The theme is not activated.', 'cookiebot' );
603 }
604 }
605
606 $view_args = array(
607 'message' => $message,
608 );
609 include_view( self::UNAVAILABLE_ADDONS_TAB_TEMPLATE, $view_args );
610 }
611
612 /**
613 * Build up settings page
614 *
615 * @throws InvalidArgumentException
616 * @since 1.3.0
617 */
618 public function setting_page() {
619 $addons_info_tab = new Settings_Page_Tab(
620 'addons_info',
621 esc_html__( 'Info', 'cookiebot' ),
622 'info_addons',
623 'cookiebot-addons',
624 false
625 );
626 $available_addons_tab = new Settings_Page_Tab(
627 'available_addons',
628 esc_html__( 'Available Add-ons', 'cookiebot' ),
629 'cookiebot_available_addons',
630 'cookiebot-addons'
631 );
632 $unavailable_addons_tab = new Settings_Page_Tab(
633 'unavailable_addons',
634 esc_html__( 'Unavailable Add-ons', 'cookiebot' ),
635 'cookiebot_not_installed_options',
636 'cookiebot-addons',
637 false
638 );
639 $settings_page_tabs = array(
640 $addons_info_tab,
641 $available_addons_tab,
642 $unavailable_addons_tab,
643 );
644 if ( is_plugin_active( Jetpack::PLUGIN_FILE_PATH ) ) {
645 $settings_page_tabs[] = new Settings_Page_Tab(
646 'jetpack',
647 esc_html__( 'Jetpack', 'cookiebot' ),
648 'cookiebot_jetpack_addon',
649 'cookiebot-addons'
650 );
651 }
652 $active_tab = array_reduce(
653 $settings_page_tabs,
654 function ( $active_tab, Settings_Page_Tab $settings_page_tab ) {
655 if ( ! is_null( $active_tab ) ) {
656 return $active_tab;
657 }
658 if ( $settings_page_tab->is_active() ) {
659 return $settings_page_tab;
660 }
661 return null;
662 },
663 null
664 );
665 if ( ! $active_tab ) {
666 $addons_info_tab->set_is_active( true );
667 $active_tab = $addons_info_tab;
668 }
669 $view_args = array(
670 'settings_page_tabs' => $settings_page_tabs,
671 'active_tab' => $active_tab,
672 );
673 include_view( 'admin/settings/prior-consent/page.php', $view_args );
674 }
675
676 /**
677 * Post action hook after enabling the addon on the settings page.
678 *
679 * @param $old_value
680 * @param $value
681 * @param $option_name
682 *
683 * @throws Exception
684 * @since 2.2.0
685 */
686 public function post_hook_available_addons_update_option( $value ) {
687 if ( is_array( $value ) ) {
688 foreach ( $value as $addon_option_name => $addon_settings ) {
689 if ( isset( $addon_settings['enabled'] ) ) {
690 $this->settings_service->post_hook_after_enabling_addon_on_settings_page( $addon_option_name );
691 }
692 }
693 }
694 }
695 }
696