PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.8.9.5
Advanced Custom Fields: Extended v0.8.9.5
0.9.2.6 0.9.2.5 0.8.6 0.8.6.1 0.8.6.3 0.8.6.5 0.8.6.6 0.8.6.7 0.8.6.8 0.8.6.9 0.8.7 0.8.7.1 0.8.7.2 0.8.7.3 0.8.7.4 0.8.7.5 0.8.7.6 0.8.8 0.8.8.1 0.8.8.10 0.8.8.11 0.8.8.2 0.8.8.3 0.8.8.4 0.8.8.5 0.8.8.6 0.8.8.7 0.8.8.8 0.8.8.9 0.8.9 0.8.9.1 0.8.9.2 0.8.9.3 0.8.9.4 0.8.9.5 0.9 0.9.0.1 0.9.0.2 0.9.0.3 0.9.0.4 0.9.0.5 0.9.0.6 0.9.0.7 0.9.0.8 0.9.0.9 0.9.1 0.9.1.1 0.9.2 0.9.2.1 0.9.2.2 0.9.2.3 0.9.2.4 trunk 0.5 0.5.1 0.5.2 0.5.2.1 0.5.2.3 0.5.5 0.5.5.1 0.5.8 0.5.8.1 0.6 0.6.0.1 0.6.0.2 0.6.1 0.6.3 0.6.5 0.6.7 0.6.7.2 0.7 0.7.0.3 0.7.5 0.7.5.5 0.7.8 0.7.9 0.7.9.3 0.7.9.4 0.7.9.9.8 0.7.9.9.9 0.8 0.8.1 0.8.2 0.8.3 0.8.3.1 0.8.4 0.8.4.1 0.8.4.5 0.8.4.6 0.8.5 0.8.5.5
acf-extended / includes / settings.php
acf-extended / includes Last commit date
admin 3 years ago field-groups 3 years ago fields 3 years ago fields-settings 3 years ago locations 3 years ago modules 2 years ago screens 3 years ago acfe-deprecated-functions.php 2 years ago acfe-field-functions.php 3 years ago acfe-field-group-functions.php 3 years ago acfe-file-functions.php 3 years ago acfe-form-functions.php 3 years ago acfe-helper-functions.php 3 years ago acfe-meta-functions.php 3 years ago acfe-post-functions.php 3 years ago acfe-screen-functions.php 3 years ago acfe-template-functions.php 3 years ago acfe-term-functions.php 3 years ago acfe-user-functions.php 3 years ago acfe-wp-functions.php 3 years ago assets.php 3 years ago compatibility-6.0.php 2 years ago compatibility.php 3 years ago field-extend.php 3 years ago field.php 3 years ago hooks.php 3 years ago init.php 3 years ago local-meta.php 3 years ago module-acf.php 3 years ago module-db.php 3 years ago module-l10n.php 3 years ago module-legacy.php 3 years ago module-manager.php 3 years ago module-post.php 2 years ago module-posts.php 3 years ago module-upgrades.php 3 years ago module.php 3 years ago multilang.php 3 years ago settings.php 3 years ago third-party.php 3 years ago upgrades.php 3 years ago
settings.php
356 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 if(!class_exists('acfe_settings')):
8
9 class acfe_settings{
10
11 // vars
12 public $settings = array();
13
14 /**
15 * construct
16 */
17 function __construct(){
18 $this->settings = get_option('acfe', array());
19 }
20
21
22 /**
23 * get
24 *
25 * @param $selector
26 * @param $default
27 *
28 * @return mixed|null
29 */
30 function get($selector = null, $default = null){
31 return $this->array_get($this->settings, $selector, $default);
32 }
33
34
35 /**
36 * set
37 *
38 * @param $selector
39 * @param $value
40 * @param $append
41 *
42 * @return $this|false
43 */
44 function set($selector = null, $value = null, $append = false){
45
46 if($value === null){
47 return false;
48 }
49
50 if($append){
51 $this->array_append($this->settings, $selector, $value);
52
53 }else{
54 $this->array_set($this->settings, $selector, $value);
55 }
56
57 $this->update();
58
59 return $this;
60
61 }
62
63
64 /**
65 * clear
66 *
67 * @param $selector
68 *
69 * @return $this
70 */
71 function clear($selector = null){
72
73 $this->array_clear($this->settings, $selector);
74 $this->update();
75
76 return $this;
77
78 }
79
80
81 /**
82 * delete
83 *
84 * @param $selector
85 *
86 * @return $this
87 */
88 function delete($selector = null){
89
90 // single
91 if(strpos($selector, '.') === false){
92 unset($this->settings[ $selector ]);
93
94 // array
95 }else{
96 $this->array_remove($this->settings, $selector);
97 }
98
99 $this->update();
100
101 return $this;
102
103 }
104
105
106 /**
107 * append
108 *
109 * @param $selector
110 * @param $value
111 *
112 * @return $this|false
113 */
114 function append($selector = null, $value = null){
115
116 if($selector === null && $value === null){
117 return false;
118 }
119
120 // allow simple append without selector
121 if($value === null){
122
123 $value = $selector;
124 $selector = null;
125
126 }
127
128 return $this->set($selector, $value, true);
129
130 }
131
132
133 /**
134 * array_get
135 *
136 * @param $array
137 * @param $key
138 * @param $default
139 *
140 * @return mixed|null
141 */
142 function array_get($array, $key, $default = null){
143
144 if(empty($key)){
145 return $array;
146 }
147
148 if(!is_array($key)){
149 $key = explode('.', $key);
150 }
151
152 $count = count($key);
153 $i=-1;
154
155 foreach($key as $segment){
156
157 $i++;
158
159 if(!isset($array[ $segment ])){
160 continue;
161 }
162
163 if($i+1 === $count){
164 return $array[ $segment ];
165 }
166
167 unset($key[$i]);
168
169 return $this->array_get($array[ $segment ], $key, $default);
170
171 }
172
173 return $default;
174
175 }
176
177
178 /**
179 * array_set
180 *
181 * @param $array
182 * @param $key
183 * @param $value
184 *
185 * @return array|mixed
186 */
187 function array_set(&$array, $key, $value){
188
189 if(empty($key)){
190 return $array = $value;
191 }
192
193 $keys = explode('.', $key);
194
195 while(count($keys) > 1){
196
197 $key = array_shift($keys);
198
199 if(!isset($array[ $key ]) || !is_array($array[ $key ])){
200 $array[ $key ] = array();
201 }
202
203 $array =& $array[ $key ];
204
205 }
206
207 $array[ array_shift($keys) ] = $value;
208
209 return $array;
210
211 }
212
213
214 /**
215 * array_append
216 *
217 * @param $array
218 * @param $key
219 * @param $value
220 *
221 * @return mixed
222 */
223 function array_append(&$array, $key, $value){
224
225 $get = $this->array_get($array, $key);
226
227 $old = acf_get_array($get);
228 $value = acf_get_array($value);
229
230 $value = array_merge($old, $value);
231
232 $this->array_set($array, $key, $value);
233
234 return $array;
235
236 }
237
238
239 /**
240 * array_clear
241 *
242 * @param $array
243 * @param $key
244 *
245 * @return mixed
246 */
247 function array_clear(&$array, $key){
248
249 $get = $this->array_get($array, $key);
250
251 if($get === null){
252 return $array;
253 }
254
255 $value = null;
256
257 if(is_array($get)){
258 $value = array();
259 }
260
261 $this->array_set($array, $key, $value);
262
263 return $array;
264
265 }
266
267
268 /**
269 * array_remove
270 *
271 * @param $array
272 * @param $keys
273 */
274 function array_remove(&$array, $keys){
275
276 $original =& $array;
277
278 foreach((array) $keys as $key){
279
280 $parts = explode('.', $key);
281
282 while(count($parts) > 1){
283
284 $part = array_shift($parts);
285
286 if(isset($array[ $part ]) && is_array($array[ $part ])){
287 $array =& $array[ $part ];
288 }
289
290 }
291
292 unset($array[ array_shift($parts) ]);
293
294 // clean up after each pass
295 $array =& $original;
296
297 }
298
299 }
300
301
302 /**
303 * update
304 */
305 function update(){
306 update_option('acfe', $this->settings, 'true');
307 }
308
309 }
310
311 endif;
312
313
314 /**
315 * acfe_get_settings
316 *
317 * @param $selector
318 * @param $default
319 *
320 * @return mixed
321 */
322 function acfe_get_settings($selector = null, $default = null){
323 return acf_get_instance('acfe_settings')->get($selector, $default);
324 }
325
326
327 /**
328 * acfe_update_settings
329 *
330 * @param $selector
331 * @param $value
332 *
333 * @return mixed
334 */
335 function acfe_update_settings($selector = null, $value = null){
336
337 if($value === null){
338 $value = $selector;
339 $selector = null;
340 }
341
342 return acf_get_instance('acfe_settings')->set($selector, $value);
343
344 }
345
346
347 /**
348 * acfe_delete_settings
349 *
350 * @param $selector
351 *
352 * @return mixed
353 */
354 function acfe_delete_settings($selector = null){
355 return acf_get_instance('acfe_settings')->delete($selector);
356 }