PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / trunk
Advanced Custom Fields: Extended vtrunk
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 1 month ago field-groups 1 month ago fields 1 month ago fields-settings 1 month ago forms 1 month ago locations 1 month ago modules 1 month ago screens 1 month ago acfe-deprecated-functions.php 2 years ago acfe-field-functions.php 1 month ago acfe-field-group-functions.php 1 month ago acfe-file-functions.php 1 year ago acfe-form-functions.php 1 month ago acfe-helper-array-functions.php 1 month ago acfe-helper-functions.php 1 month ago acfe-helper-multi-functions.php 1 month ago acfe-helper-string-functions.php 1 month ago acfe-meta-functions.php 1 month ago acfe-post-functions.php 1 month ago acfe-screen-functions.php 1 month ago acfe-template-functions.php 1 month ago acfe-term-functions.php 1 month ago acfe-user-functions.php 1 month ago acfe-wp-functions.php 3 years ago assets.php 1 month ago compatibility-acf-5.8.php 2 months ago compatibility-acf-5.9.php 1 month ago compatibility-acf-6.5.php 1 month ago compatibility.php 1 month ago field-extend.php 2 months ago field.php 2 months ago hooks.php 1 month ago init.php 1 month ago local-meta.php 3 years ago media.php 1 month ago module-acf.php 1 month ago module-db.php 1 month ago module-l10n.php 1 month ago module-legacy.php 3 years ago module-manager.php 2 months ago module-post.php 1 month ago module-posts.php 2 months ago module-upgrades.php 3 years ago module.php 1 month ago multilang.php 1 month ago revisions.php 2 months ago screen.php 1 month ago settings.php 1 month ago template-tags.php 1 month ago third-party.php 3 years ago upgrades.php 1 month ago
settings.php
303 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 return acfe_get($array, $key, $default);
144 }
145
146
147 /**
148 * array_set
149 *
150 * @param $array
151 * @param $key
152 * @param $value
153 *
154 * @return void
155 */
156 function array_set(&$array, $key, $value){
157 acfe_set($array, $key, $value);
158 }
159
160
161 /**
162 * array_append
163 *
164 * @param $array
165 * @param $key
166 * @param $value
167 *
168 * @return mixed
169 */
170 function array_append(&$array, $key, $value){
171
172 $get = $this->array_get($array, $key);
173
174 $old = acfe_as_array($get);
175 $value = acfe_as_array($value);
176
177 $value = array_merge($old, $value);
178
179 $this->array_set($array, $key, $value);
180
181 return $array;
182
183 }
184
185
186 /**
187 * array_clear
188 *
189 * @param $array
190 * @param $key
191 *
192 * @return mixed
193 */
194 function array_clear(&$array, $key){
195
196 $get = $this->array_get($array, $key);
197
198 if($get === null){
199 return $array;
200 }
201
202 $value = null;
203
204 if(is_array($get)){
205 $value = array();
206 }
207
208 $this->array_set($array, $key, $value);
209
210 return $array;
211
212 }
213
214
215 /**
216 * array_remove
217 *
218 * @param $array
219 * @param $keys
220 */
221 function array_remove(&$array, $keys){
222
223 $original =& $array;
224
225 foreach((array) $keys as $key){
226
227 $parts = explode('.', $key);
228
229 while(count($parts) > 1){
230
231 $part = array_shift($parts);
232
233 if(isset($array[ $part ]) && is_array($array[ $part ])){
234 $array =& $array[ $part ];
235 }
236
237 }
238
239 unset($array[ array_shift($parts) ]);
240
241 // clean up after each pass
242 $array =& $original;
243
244 }
245
246 }
247
248
249 /**
250 * update
251 */
252 function update(){
253 update_option('acfe', $this->settings, 'true');
254 }
255
256 }
257
258 endif;
259
260
261 /**
262 * acfe_get_settings
263 *
264 * @param $selector
265 * @param $default
266 *
267 * @return mixed
268 */
269 function acfe_get_settings($selector = null, $default = null){
270 return acf_get_instance('acfe_settings')->get($selector, $default);
271 }
272
273
274 /**
275 * acfe_update_settings
276 *
277 * @param $selector
278 * @param $value
279 *
280 * @return mixed
281 */
282 function acfe_update_settings($selector = null, $value = null){
283
284 if($value === null){
285 $value = $selector;
286 $selector = null;
287 }
288
289 return acf_get_instance('acfe_settings')->set($selector, $value);
290
291 }
292
293
294 /**
295 * acfe_delete_settings
296 *
297 * @param $selector
298 *
299 * @return mixed
300 */
301 function acfe_delete_settings($selector = null){
302 return acf_get_instance('acfe_settings')->delete($selector);
303 }