Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/google-site-kit/includes/Core/Admin/Pointer.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
/**
3
+
* Class Google\Site_Kit\Core\Admin\Pointer
4
+
*
5
+
* @package Google\Site_Kit
6
+
* @copyright 2022 Google LLC
7
+
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
8
+
* @link https://sitekit.withgoogle.com
9
+
*/
10
+
11
+
namespace Google\Site_Kit\Core\Admin;
12
+
13
+
/**
14
+
* Class representing a single pointer.
15
+
*
16
+
* @since 1.83.0
17
+
* @access private
18
+
* @ignore
19
+
*/
20
+
final class Pointer {
21
+
22
+
/**
23
+
* Unique pointer slug.
24
+
*
25
+
* @since 1.83.0
26
+
* @var string
27
+
*/
28
+
private $slug;
29
+
30
+
/**
31
+
* Pointer arguments.
32
+
*
33
+
* @since 1.83.0
34
+
* @var array
35
+
*/
36
+
private $args = array();
37
+
38
+
/**
39
+
* Constructor.
40
+
*
41
+
* @since 1.83.0
42
+
*
43
+
* @param string $slug Unique pointer slug.
44
+
* @param array $args {
45
+
* Associative array of pointer arguments.
46
+
*
47
+
* @type string $title Required. Pointer title.
48
+
* @type string $content Required. Pointer content. May contain inline HTML tags.
49
+
* @type string $target_id Required. ID of the element the pointer should be attached to.
50
+
* @type string|array $position Optional. Position of the pointer. Can be 'top', 'bottom', 'left', 'right',
51
+
* or an array of `edge` and `align`. Default 'top'.
52
+
* @type callable $active_callback Optional. Callback function to determine whether the pointer is active in
53
+
* the current context. The current admin screen's hook suffix is passed to
54
+
* the callback. Default is that the pointer is active unconditionally.
55
+
* }
56
+
*/
57
+
public function __construct( $slug, array $args ) {
58
+
$this->slug = $slug;
59
+
$this->args = wp_parse_args(
60
+
$args,
61
+
array(
62
+
'title' => '',
63
+
'content' => '',
64
+
'target_id' => '',
65
+
'position' => 'top',
66
+
'active_callback' => null,
67
+
'buttons' => null,
68
+
'class' => '',
69
+
)
70
+
);
71
+
}
72
+
73
+
/**
74
+
* Gets the pointer slug.
75
+
*
76
+
* @since 1.83.0
77
+
*
78
+
* @return string Unique pointer slug.
79
+
*/
80
+
public function get_slug() {
81
+
return $this->slug;
82
+
}
83
+
84
+
/**
85
+
* Gets the pointer title.
86
+
*
87
+
* @since 1.83.0
88
+
*
89
+
* @return string Pointer title.
90
+
*/
91
+
public function get_title() {
92
+
return $this->args['title'];
93
+
}
94
+
95
+
/**
96
+
* Gets the pointer buttons.
97
+
*
98
+
* @since 1.166.0
99
+
*
100
+
* @return string Pointer buttons.
101
+
*/
102
+
public function get_buttons() {
103
+
return $this->args['buttons'];
104
+
}
105
+
106
+
/**
107
+
* Gets the pointer custom class.
108
+
*
109
+
* @since 1.166.0
110
+
*
111
+
* @return string|array Pointer custom class.
112
+
*/
113
+
public function get_class() {
114
+
return $this->args['class'];
115
+
}
116
+
117
+
/**
118
+
* Gets the pointer content.
119
+
*
120
+
* @since 1.83.0
121
+
*
122
+
* @return string Pointer content.
123
+
*/
124
+
public function get_content() {
125
+
if ( is_callable( $this->args['content'] ) ) {
126
+
return call_user_func( $this->args['content'] );
127
+
} else {
128
+
return '<p>' . wp_kses( $this->args['content'], 'googlesitekit_admin_pointer' ) . '</p>';
129
+
}
130
+
}
131
+
132
+
/**
133
+
* Gets the pointer target ID.
134
+
*
135
+
* @since 1.83.0
136
+
*
137
+
* @return string Pointer target ID.
138
+
*/
139
+
public function get_target_id() {
140
+
return $this->args['target_id'];
141
+
}
142
+
143
+
/**
144
+
* Gets the pointer position.
145
+
*
146
+
* @since 1.83.0
147
+
*
148
+
* @return string|array Pointer position.
149
+
*/
150
+
public function get_position() {
151
+
return $this->args['position'];
152
+
}
153
+
154
+
/**
155
+
* Checks whether the pointer is active.
156
+
*
157
+
* This method executes the active callback in order to determine whether the pointer should be active or not.
158
+
*
159
+
* @since 1.83.0
160
+
*
161
+
* @param string $hook_suffix The current admin screen hook suffix.
162
+
* @return bool True if the pointer is active, false otherwise.
163
+
*/
164
+
public function is_active( $hook_suffix ) {
165
+
if ( empty( $this->args['title'] ) || empty( $this->args['content'] ) || empty( $this->args['target_id'] ) ) {
166
+
return false;
167
+
}
168
+
169
+
if ( ! is_callable( $this->args['active_callback'] ) ) {
170
+
return true;
171
+
}
172
+
173
+
return (bool) call_user_func( $this->args['active_callback'], $hook_suffix );
174
+
}
175
+
}
176
+