Field_Interface.php
4.94 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
namespace FakerPress\Fields;
/**
* Interface for Fields.
*
* @since 0.5.1
*/
interface Field_Interface {
/**
* The slug of field we dealing with.
*
* @since 0.5.1
*
* @return string Slug of field.
*/
public function get_slug();
/**
* The slug of field we dealing with.
*
* @since 0.5.1
*
* @return string Slug of field.
*/
public function get_id();
/**
* The slug of field we dealing with.
*
* @since 0.5.1
*
* @param string|null $value ID of this field.
*
* @return string Slug of field.
*/
public function set_id( $value );
/**
* Composes and return the html id of a field based on it's parents and it's own ID.
*
* @since 0.5.1
*
* @param string|null $suffix Something to be appended to the end of the html id.
*
* @return string HTML ID of the field.
*/
public function get_html_id( $suffix = null );
/**
* Settings for this field object.
*
* @since 0.5.1
*
* @param string $format Which format we should return the HTML. Options: `string` or `array`.
*
* @return string|array The string holding the HTML of this field.
*/
public function get_html( $format = 'string' );
/**
* Get the instance of template that will be used to render this field.
*
* @since 0.5.1
*
* @return Template Instance of the template class used to rende templates.
*/
public function get_template();
/**
* Settings for this field object.
*
* @since 0.5.1
*
* @return array Settings for the field.
*/
public function get_settings();
/**
* A given setting from the settings on this field.
*
* @since 0.5.2
*
* @param array|string $index Index passed to fp_array_get.
* @param mixed $default Default value for the setting.
*
* @return mixed Setting you are looking for.
*/
public function get_setting( $index, $default = null );
/**
* Configure this field and it's childs.
*
* @since 0.5.1
*
* @param array $args Which settings will be use configure this field.
*
* @return Field_Interface Returns an instance of itself be able to chain calls.
*/
public function setup( array $args = [] );
/**
* Get field instance priority.
*
* @since 0.5.1
*
* @return int Which priority this field currently have.
*/
public function get_priority();
/**
* Array of children fields.
*
* @since 0.5.1
*
* @return array Returns the children fields which must implement Field_Interface.
*/
public function get_children();
/**
* Finds a children from this field instance.
*
* @since 0.5.2
*
* @uses wp_filter_object_list
*
* @param Field_Interface|array|string|int $search Search for a given children to remove.
* @param string $operator Optional. The logical operation to perform. 'or' means
* only one element from the array needs to match; 'and'
* means all elements must match; 'not' means no elements may
* match. Default 'and'.
*
* @return Field_Interface|array Returns an instance of itself be able to chain calls.
*/
public function find_children( $search, $operator = 'and' );
/**
* Add a children to this field instance.
*
* @since 0.5.1
*
* @param Field_Interface|array $children Which settings will be use
*
* @return Field_Interface Returns an instance of itself be able to chain calls.
*/
public function add_children( $children );
/**
* Remove a children from this field instance.
*
* @since 0.5.1
*
* @uses Field_Interface::find_children
*
* @param Field_Interface|array|string|int $search Search for a given children to remove.
* @param string $operator Optional. The logical operation to perform. 'or' means
* only one element from the array needs to match; 'and'
* means all elements must match; 'not' means no elements may
* match. Default 'and'.
*
* @return Field_Interface|array Returns an instance of itself be able to chain calls.
*/
public function remove_children( $search = [], $operator = 'and' );
/**
* Sort this Field's children array by priority
*
* @since 0.5.1
*
* @return Field_Interface Returns an instance of itself be able to chain calls.
*/
public function sort_children();
/**
* Parent field object.
*
* @since 0.5.1
*
* @return Field_Interface|null Returns a parent field or null if not present.
*/
public function get_parent();
/**
* Set the parent field object.
*
* @since 0.5.1
*
* @param Field_Interface $parent Which field is the parent of this one.
*
* @return Field_Interface Returns an instance of itself be able to chain calls.
*/
public function set_parent( Field_Interface $parent );
}