1 | <?php |
||
11 | class Helper { |
||
12 | |||
13 | /** |
||
14 | * Get a value formatted for end-users |
||
15 | * |
||
16 | * @param int $object_id Object id to get value for (e.g. post_id, term_id etc.) |
||
17 | * @param string $container_type Container type to search in |
||
18 | * @param string $field_name Field name |
||
19 | * @return mixed |
||
20 | */ |
||
21 | public static function get_value( $object_id, $container_type, $field_name ) { |
||
37 | |||
38 | /** |
||
39 | * Set value for a field |
||
40 | * |
||
41 | * @param int $object_id Object id to get value for (e.g. post_id, term_id etc.) |
||
42 | * @param string $container_type Container type to search in |
||
43 | * @param string $field_name Field name |
||
44 | * @param array $value Refer to Complex_Field::set_value_tree() in case you wish to update a complex field |
||
45 | * @return bool |
||
46 | */ |
||
47 | public static function set_value( $object_id, $container_type, $field_name, $value ) { |
||
71 | |||
72 | /** |
||
73 | * Shorthand for get_post_meta(). |
||
74 | * Uses the ID of the current post in the loop. |
||
75 | * |
||
76 | * @param string $name Custom field name. |
||
77 | * @return mixed Meta value. |
||
78 | */ |
||
79 | public static function get_the_post_meta( $name ) { |
||
82 | |||
83 | /** |
||
84 | * Get post meta field for a post. |
||
85 | * |
||
86 | * @param int $id Post ID. |
||
87 | * @param string $name Custom field name. |
||
88 | * @return mixed Meta value. |
||
89 | */ |
||
90 | public static function get_post_meta( $id, $name ) { |
||
93 | |||
94 | /** |
||
95 | * Set post meta field for a post. |
||
96 | * |
||
97 | * @param int $id Post ID |
||
98 | * @param string $name Custom field name |
||
99 | * @param array $value |
||
100 | * @return bool Success |
||
101 | */ |
||
102 | public static function set_post_meta( $id, $name, $value ) { |
||
105 | |||
106 | /** |
||
107 | * Get theme option field value. |
||
108 | * |
||
109 | * @param string $name Custom field name |
||
110 | * @return mixed Option value |
||
111 | */ |
||
112 | public static function get_theme_option( $name ) { |
||
115 | |||
116 | /** |
||
117 | * Set theme option field value. |
||
118 | * |
||
119 | * @param string $name Field name |
||
120 | * @param array $value |
||
121 | * @return bool Success |
||
122 | */ |
||
123 | public static function set_theme_option( $name, $value ) { |
||
126 | |||
127 | /** |
||
128 | * Get term meta field for a term. |
||
129 | * |
||
130 | * @param int $id Term ID. |
||
131 | * @param string $name Custom field name. |
||
132 | * @return mixed Meta value. |
||
133 | */ |
||
134 | public static function get_term_meta( $id, $name ) { |
||
137 | |||
138 | /** |
||
139 | * Set term meta field for a term. |
||
140 | * |
||
141 | * @param int $id Term ID |
||
142 | * @param string $name Field name |
||
143 | * @param array $value |
||
144 | * @return bool Success |
||
145 | */ |
||
146 | public static function set_term_meta( $id, $name, $value ) { |
||
149 | |||
150 | /** |
||
151 | * Get user meta field for a user. |
||
152 | * |
||
153 | * @param int $id User ID. |
||
154 | * @param string $name Custom field name. |
||
155 | * @return mixed Meta value. |
||
156 | */ |
||
157 | public static function get_user_meta( $id, $name ) { |
||
160 | |||
161 | /** |
||
162 | * Set user meta field for a user. |
||
163 | * |
||
164 | * @param int $id User ID |
||
165 | * @param string $name Field name |
||
166 | * @param array $value |
||
167 | * @return bool Success |
||
168 | */ |
||
169 | public static function set_user_meta( $id, $name, $value ) { |
||
172 | |||
173 | /** |
||
174 | * Get comment meta field for a comment. |
||
175 | * |
||
176 | * @param int $id Comment ID. |
||
177 | * @param string $name Custom field name. |
||
178 | * @return mixed Meta value. |
||
179 | */ |
||
180 | public static function get_comment_meta( $id, $name ) { |
||
183 | |||
184 | /** |
||
185 | * Set comment meta field for a comment. |
||
186 | * |
||
187 | * @param int $id Comment ID |
||
188 | * @param string $name Field name |
||
189 | * @param array $value |
||
190 | * @return bool Success |
||
191 | */ |
||
192 | public static function set_comment_meta( $id, $name, $value ) { |
||
195 | |||
196 | /** |
||
197 | * Recursive sorting function by array key. |
||
198 | * |
||
199 | * @param array &$array The input array. |
||
200 | * @param int $sort_flags Flags for controlling sorting behavior. |
||
201 | * @return array Sorted array. |
||
202 | */ |
||
203 | public static function ksort_recursive( &$array, $sort_flags = SORT_REGULAR ) { |
||
213 | } |
||
214 |