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