|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Elements: Input. |
|
4
|
|
|
* |
|
5
|
|
|
* Represents an Input text box. |
|
6
|
|
|
* |
|
7
|
|
|
* @since 3.11.0 |
|
8
|
|
|
* @package Wordlift |
|
9
|
|
|
* @subpackage Wordlift/admin |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Define the {@link Wordlift_Admin_Input_Element} class. |
|
14
|
|
|
* |
|
15
|
|
|
* @since 3.11.0 |
|
16
|
|
|
* @package Wordlift |
|
17
|
|
|
* @subpackage Wordlift/admin |
|
18
|
|
|
*/ |
|
19
|
|
|
class Wordlift_Admin_Input_Element implements Wordlift_Admin_Element { |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Output the HTML for an input box type settings_page |
|
23
|
|
|
* |
|
24
|
|
|
* @param array { |
|
25
|
|
|
* Parameters controlling the result. |
|
26
|
|
|
* |
|
27
|
|
|
* @type string name The name attribute of the input element. Mandatory. |
|
28
|
|
|
* |
|
29
|
|
|
* @type string id The id attribute of the input element. Optional. |
|
30
|
|
|
* @type string id The id attribute of the input element. |
|
31
|
|
|
* Optional, randomly generated one is used if not supplied. |
|
32
|
|
|
* @type string value The value of the input element. |
|
33
|
|
|
* Optional, defaults to empty string. |
|
34
|
|
|
* @type bool readonly Indicates whether the input is read only. |
|
35
|
|
|
* Optional, defaults to read-write |
|
36
|
|
|
* @type string css_class The class attribute for the input element. |
|
37
|
|
|
* If empty string no class attribute will be added. |
|
38
|
|
|
* Optional, defaults to empty string. |
|
39
|
|
|
* @type string description The descriptio text to be displayed below the element. |
|
40
|
|
|
* Can include some HTML element. |
|
41
|
|
|
* If empty string no description will be displayed. |
|
42
|
|
|
* Optional, defaults to empty string. |
|
43
|
|
|
* } |
|
44
|
|
|
*/ |
|
45
|
|
|
public function render( $args ) { |
|
46
|
|
|
|
|
47
|
|
|
/* |
|
48
|
|
|
* Parse the arguments and merge with default values. |
|
49
|
|
|
* Name intentionally do not have a default as it has to be in SyncEvent |
|
50
|
|
|
* with form handling code |
|
51
|
|
|
*/ |
|
52
|
|
|
$params = wp_parse_args( $args, array( |
|
53
|
|
|
'id' => uniqid( 'wl-input-' ), |
|
54
|
|
|
'value' => '', |
|
55
|
|
|
'readonly' => false, |
|
56
|
|
|
'css_class' => '', |
|
57
|
|
|
'description' => '', |
|
58
|
|
|
) ); |
|
59
|
|
|
|
|
60
|
|
|
// Set the readonly and class attributes and the description. |
|
61
|
|
|
$readonly = $params['readonly'] ? ' readonly="readonly"' : ''; |
|
62
|
|
|
$css_class = ! empty( $params['css_class'] ) ? ' class="' . esc_attr( $params['css_class'] ) . '"' : ''; |
|
63
|
|
|
$description = ! empty( $params['description'] ) ? '<p>' . wp_kses( $params['description'], array( 'a' => array( 'href' => array() ) ) ) . '</p>' : ''; |
|
64
|
|
|
|
|
65
|
|
|
?> |
|
66
|
|
|
|
|
67
|
|
|
<input type="text" |
|
68
|
|
|
id="<?php echo esc_attr( $params['id'] ); ?>" |
|
69
|
|
|
name="<?php echo esc_attr( $params['name'] ); ?>" |
|
70
|
|
|
value="<?php echo esc_attr( $params['value'] ); ?>" |
|
71
|
|
|
<?php echo $readonly; ?> |
|
72
|
|
|
<?php echo $css_class; ?> |
|
73
|
|
|
/> |
|
74
|
|
|
<?php echo $description; ?> |
|
75
|
|
|
|
|
76
|
|
|
<?php |
|
77
|
|
|
|
|
78
|
|
|
return $this; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
} |
|
82
|
|
|
|