PluginProbe ʕ •ᴥ•ʔ
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.2.0
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.2.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 / src / lib / Settings_Page_Tab.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
Settings_Page_Tab.php
139 lines
1 <?php
2
3 namespace cybot\cookiebot\lib;
4
5 use InvalidArgumentException;
6
7 class Settings_Page_Tab {
8
9 /**
10 * @var string
11 */
12 private $name;
13 /**
14 * @var string
15 */
16 private $label;
17 /**
18 * @var string
19 */
20 private $settings_fields_option_group;
21 /**
22 * @var string
23 */
24 private $page_name;
25 /**
26 * @var bool
27 */
28 private $is_active;
29 /**
30 * @var bool
31 */
32 private $has_submit_button;
33
34 /**
35 * @param $name
36 * @param $label
37 * @param $settings_fields_option_group
38 * @param $page_name
39 * @param bool $has_submit_button
40 *
41 * @throws InvalidArgumentException
42 */
43 public function __construct(
44 $name,
45 $label,
46 $settings_fields_option_group,
47 $page_name,
48 $has_submit_button = true
49 ) {
50 if ( ! is_string( $name ) || empty( $name ) ) {
51 throw new InvalidArgumentException( 'The constructor argument "name" is a required string ' );
52 }
53 if ( ! is_string( $label ) || empty( $label ) ) {
54 throw new InvalidArgumentException( 'The constructor argument "label" is a required string ' );
55 }
56 if ( ! is_string( $settings_fields_option_group ) || empty( $settings_fields_option_group ) ) {
57 throw new InvalidArgumentException( 'The constructor argument "settings_fields_option_group" is a required string ' );
58 }
59 if ( ! is_string( $page_name ) || empty( $page_name ) ) {
60 throw new InvalidArgumentException( 'The constructor argument "page_name" is a required string ' );
61 }
62
63 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
64 $this->is_active = isset( $_GET['tab'] ) && $_GET['tab'] === $name;
65 $this->name = $name;
66 $this->label = $label;
67 $this->settings_fields_option_group = $settings_fields_option_group;
68 $this->page_name = $page_name;
69 $this->has_submit_button = $has_submit_button;
70 }
71
72 /**
73 * @return string
74 */
75 public function get_name() {
76 return $this->name;
77 }
78
79 /**
80 * @return string
81 */
82 public function get_label() {
83 return $this->label;
84 }
85
86 /**
87 * @return string
88 */
89 public function get_settings_fields_option_group() {
90 return $this->settings_fields_option_group;
91 }
92
93 /**
94 * @return string
95 */
96 public function get_page_name() {
97 return $this->page_name;
98 }
99
100 /**
101 * @return bool
102 */
103 public function is_active() {
104 return $this->is_active;
105 }
106
107 /**
108 * @param bool $is_active
109 */
110 public function set_is_active( $is_active ) {
111 $this->is_active = $is_active;
112 }
113
114 public function get_tab_href() {
115 $query = http_build_query(
116 array(
117 'page' => $this->page_name,
118 'tab' => $this->name,
119 )
120 );
121 return admin_url( 'admin.php?' . $query );
122 }
123
124 /**
125 * @return string
126 */
127 public function get_classes() {
128 return $this->is_active ? 'nav-tab nav-tab-active' : 'nav-tab';
129 }
130
131 /**
132 * @return bool
133 */
134 public function has_submit_button() {
135 return $this->has_submit_button;
136 }
137
138 }
139