FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
wordpress-plugin/src/UI/LabelComponent.php at main · simpleanalytics/wordpress-plugin · GitHub
simpleanalytics
/
wordpress-plugin
Public
Notifications
You must be signed in to change notification settings
Fork
7
Star
4
Code
Issues
2
Pull requests
1
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
wordpress-plugin
/
src
/
UI
/
LabelComponent.php
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (56 loc) · 1.3 KB
Breadcrumbs
wordpress-plugin
/
src
/
UI
/
LabelComponent.php
Copy path
File metadata and controls
62 lines (56 loc) · 1.3 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace
SimpleAnalytics
\
UI
;
use
SimpleAnalytics
\
Support
\
Str
;
class
LabelComponent
{
/**
* @readonly
* @var string
*/
private
$
value
;
/**
* @readonly
* @var string|null
*/
private
$
docs
;
/**
* @readonly
* @var string|null
*/
private
$
for
;
/**
* @readonly
* @var string
*/
private
$
as
=
'
label
'
;
public
function
__construct
(
string
$
value
, ?
string
$
docs
, ?
string
$
for
=
null
,
string
$
as
=
'
label
'
)
{
$
this
->
value
=
$
value
;
$
this
->
docs
=
$
docs
;
$
this
->
for
=
$
for
;
$
this
->
as
=
$
as
;
}
public
function
__invoke
():
void
{
$
attributes
= [
'
class
'
=>
'
block text-sm font-medium leading-6 text-gray-900
'
,
];
if
(
$
this
->
as
===
'
label
'
) {
$
attributes
[
'
for
'
] =
esc_attr
(
$
this
->
for
);
}
echo
sprintf
(
'
<%1$s %2$s>%3$s%4$s</%1$s>
'
,
$
this
->
as
,
Str::
htmlAttributes
(
$
attributes
),
esc_html
(
$
this
->
value
),
$
this
->
docs
?
$
this
->
renderDocsLink
() :
''
);
}
protected
function
renderDocsLink
():
string
{
return
sprintf
(
'
<a href="%s" target="_blank" class="text-primary">(docs)</a>
'
,
esc_url
(
$
this
->
docs
)
);
}
}
Back
|
FazBrowse Home
|
New Git URL