PluginProbe ʕ •ᴥ•ʔ
Advanced Custom Fields: Extended / 0.9.2.7
Advanced Custom Fields: Extended v0.9.2.7
0.9.2.7 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 / acfe-helper-array-functions.php
acf-extended / includes Last commit date
admin 3 months ago field-groups 3 months ago fields 1 week ago fields-settings 3 months ago forms 3 months ago locations 3 months ago modules 1 week ago screens 3 months ago acfe-deprecated-functions.php 2 years ago acfe-field-functions.php 3 months ago acfe-field-group-functions.php 3 months ago acfe-file-functions.php 1 year ago acfe-form-functions.php 3 months ago acfe-helper-array-functions.php 3 months ago acfe-helper-functions.php 3 months ago acfe-helper-multi-functions.php 3 months ago acfe-helper-string-functions.php 3 months ago acfe-meta-functions.php 3 months ago acfe-post-functions.php 3 months ago acfe-screen-functions.php 3 months ago acfe-template-functions.php 3 months ago acfe-term-functions.php 3 months ago acfe-user-functions.php 3 months ago acfe-wp-functions.php 3 years ago assets.php 3 months ago compatibility-acf-5.8.php 4 months ago compatibility-acf-5.9.php 3 months ago compatibility-acf-6.5.php 3 months ago compatibility-acf-6.8.6.php 1 week ago compatibility.php 3 months ago field-extend.php 4 months ago field.php 4 months ago hooks.php 3 months ago init.php 3 months ago local-meta.php 3 years ago media.php 3 months ago module-acf.php 3 months ago module-db.php 3 months ago module-l10n.php 3 months ago module-legacy.php 3 years ago module-manager.php 4 months ago module-post.php 3 months ago module-posts.php 4 months ago module-upgrades.php 3 years ago module.php 3 months ago multilang.php 3 months ago revisions.php 4 months ago screen.php 3 months ago settings.php 3 months ago template-tags.php 3 months ago third-party.php 3 years ago upgrades.php 3 months ago
acfe-helper-array-functions.php
1091 lines
1 <?php
2
3 if(!defined('ABSPATH')){
4 exit;
5 }
6
7 /**
8 * acfe_as_array
9 *
10 * Convert a variable to an array if possible, with some basic type checks
11 *
12 * @param $var
13 * @param $delimiter
14 *
15 * @return array
16 */
17 function acfe_as_array($var = false, $delimiter = null){
18
19 // array
20 if(is_array($var)){
21 return $var;
22
23 // basic type check
24 }elseif(!$var && !is_numeric($var)){
25 return array();
26
27 // string
28 }elseif(is_string($var) && $delimiter !== null){
29 return explode($delimiter, $var);
30 }
31
32 // force array
33 return (array) $var;
34
35 }
36
37 /**
38 * acfe_array_map
39 *
40 * Similar to array_map() but with keys and row metadata in the callback.
41 *
42 * @param $array array
43 * @param $callback callable
44 * @param $recursive bool
45 * @param $row array Internal parameter for row context (depth, index, path)
46 *
47 * @return array
48 */
49 function acfe_array_map($array, $callback, $recursive = false, $row = array()){
50
51 // validate
52 if(!is_array($array) || empty($array)){
53 return array();
54 }
55
56 // vars
57 $result = array();
58
59 // prepare row
60 $row = wp_parse_args($row, array(
61 'depth' => 0,
62 'index' => 0,
63 'path' => '',
64 ));
65
66 // loop array
67 foreach($array as $key => $value){
68
69 // update row
70 $current_row = array(
71 'depth' => $row['depth'],
72 'index' => $row['index'],
73 'path' => ($row['path'] !== '' ? "{$row['path']}.{$key}" : (string) $key),
74 );
75
76 // callback
77 $map = $callback($value, $key, $current_row);
78
79 // handle recursive mapping
80 if(is_array($map) && $recursive){
81
82 // call itself with updated row context
83 $map = acfe_array_map($map, $callback, true, array(
84 'depth' => $row['depth']+1,
85 'path' => $current_row['path'],
86 ));
87
88 }
89
90 // update result
91 $result[ $key ] = $map;
92
93 // increment index for next iteration
94 $row['index']++;
95
96 }
97
98 // return
99 return $result;
100
101 }
102
103
104
105 /**
106 * acfe_array_rewrite
107 *
108 * Run a map over each of the items in the array.
109 *
110 * Return false = remove the row from the result
111 * Return true = keep the original row in the result, do not proceed children, even if recursive is enabled
112 * Return array(key => value) = rewrite the item with the new key and value, if recursive is enabled, children will be processed as well
113 *
114 * @param callable $callback
115 * @param array $array
116 *
117 * @return array
118 */
119 function acfe_array_rewrite($array, $callback, $recursive = false){
120
121 // validate
122 if(!is_array($array) || empty($array)){
123 return array();
124 }
125
126 $result = array();
127
128 // stack frames: input array, keys, current index, output reference, parent dot-path, depth
129 $stack = array(array(
130 'input' => $array,
131 'keys' => array_keys($array),
132 'index' => 0,
133 'result' => &$result,
134 'path' => '',
135 'depth' => 0,
136 ));
137
138 while(!empty($stack)){
139
140 $i = count($stack) - 1;
141
142 // frame completed
143 if($stack[$i]['index'] >= count($stack[$i]['keys'])){
144 array_pop($stack);
145 continue;
146 }
147
148 $key = $stack[$i]['keys'][ $stack[$i]['index'] ];
149 $value = $stack[$i]['input'][ $key ];
150 $parent_path = $stack[$i]['path'];
151 $depth = $stack[$i]['depth'];
152
153 // prepare row data for callback
154 $row = array(
155 'depth' => $depth,
156 'index' => $stack[$i]['index'],
157 'path' => ($parent_path !== '' ? $parent_path . '.' . $key : (string) $key),
158 );
159
160 $stack[$i]['index']++;
161
162 // callback
163 $map = $callback($value, $key, $row);
164
165 // string | bool | null etc...
166 if(!is_array($map)){
167
168 // true returns original row
169 // do not proceed children, even if recursive is enabled
170 if($map === true){
171 $stack[$i]['result'][ $key ] = $value;
172 }
173
174 // false, null, string remove the row
175 continue;
176
177 }
178
179 // rewrite rows
180 foreach($map as $map_key => $map_value){
181
182 if(is_array($map_value) && $recursive){
183
184 $stack[$i]['result'][ $map_key ] = array();
185 $child_result = &$stack[$i]['result'][ $map_key ];
186 $child_path = $parent_path !== '' ? $parent_path . '.' . $map_key : (string) $map_key;
187
188 $stack[] = array(
189 'input' => $map_value,
190 'keys' => array_keys($map_value),
191 'index' => 0,
192 'result' => &$child_result,
193 'path' => $child_path,
194 'depth' => $depth + 1,
195 );
196
197 unset($child_result);
198
199 }else{
200 $stack[$i]['result'][ $map_key ] = $map_value;
201 }
202
203 }
204
205 }
206
207 return $result;
208 }
209
210
211 /**
212 * acfe_array_where
213 *
214 * Similar to array_filter(), but with preserved keys and an additional offset parameter in the callback function.
215 *
216 * Iterates over each value in the array passing them to the callback function.
217 * If the callback function returns true, the current value from array is returned into the result array.
218 *
219 * @param array $array
220 * @param callable $callback
221 *
222 * @return array
223 */
224 function acfe_array_where($array, $callback){
225
226 // validate
227 if(!is_array($array)){
228 return array();
229 }
230
231 // result
232 $result = array();
233 $offset = 0;
234
235 // loop
236 foreach($array as $key => $value){
237
238 if($callback($value, $key, $offset)){
239 $result[ $key ] = $value;
240 }
241
242 $offset++;
243 }
244
245 // return
246 return $result;
247 }
248
249
250 /**
251 * acfe_array_first
252 *
253 * Return the first element in an array passing a given truth test
254 *
255 * @param $array
256 * @param $callback
257 * @param $default
258 *
259 * @return mixed|null
260 */
261 function acfe_array_first($array, $callback = null, $default = null){
262
263 // validate
264 if(!is_array($array) || empty($array)){
265 return $default;
266 }
267
268 // no callback, return first item
269 if($callback === null){
270 foreach($array as $item){
271 return $item;
272 }
273 }
274
275 // loop
276 $offset = 0;
277 foreach($array as $key => $value){
278
279 if($callback($value, $key, $offset)){
280 return $value;
281 }
282
283 $offset++;
284 }
285
286 // default
287 return $default;
288 }
289
290
291 /**
292 * acfe_array_last
293 *
294 * Return the last element in an array passing a given truth test
295 *
296 * @param $array
297 * @param $callback
298 * @param $default
299 *
300 * @return false|mixed|null
301 */
302 function acfe_array_last($array, $callback = null, $default = null){
303
304 // validate
305 if(!is_array($array) ||empty($array)){
306 return $default;
307 }
308
309 return acfe_array_first(array_reverse($array, true), $callback, $default);
310 }
311
312
313 /**
314 * acfe_array_key_first
315 *
316 * Returns the first key of an array using a callback function to test each element
317 * Returns null if no element passed the truth test or if the array is empty.
318 *
319 * @param $array
320 * @param $callback
321 *
322 * @return int|string|null
323 */
324 function acfe_array_key_first($array, $callback = null){
325
326 // validate
327 if(!is_array($array) || empty($array)){
328 return null;
329 }
330
331 // no callback, return first key
332 if($callback === null){
333 foreach($array as $key => $value){
334 return $key;
335 }
336 }
337
338 // loop
339 $offset = 0;
340 foreach($array as $key => $value){
341
342 if($callback($value, $key, $offset)){
343 return $key;
344 }
345
346 $offset++;
347 }
348
349 // default
350 return null;
351 }
352
353
354 /**
355 * acfe_array_key_last
356 *
357 * Returns the last key of an array using dot notation
358 *
359 * @param $array
360 * @param $callback
361 *
362 * @return int|string|null
363 */
364 function acfe_array_key_last($array, $callback = null){
365
366 // validate
367 if(!is_array($array) || empty($array)){
368 return null;
369 }
370
371 return acfe_array_key_first(array_reverse($array, true), $callback);
372
373 }
374
375
376 /**
377 * acfe_array_some
378 *
379 * Return true if any item matches the truth test, else false.
380 *
381 * @param array $array
382 * @param callable $callback
383 * @param mixed $true
384 * @param mixed $false
385 *
386 * @return mixed
387 */
388 function acfe_array_some($array, $callback, $true = true, $false = false){
389
390 // validate
391 if(!is_array($array) || empty($array)){
392 return $false;
393 }
394
395 // loop
396 foreach($array as $key => $value){
397 if($callback($value, $key)){
398 return $true;
399 }
400 }
401
402 // return
403 return $false;
404 }
405
406
407 /**
408 * acfe_array_every
409 *
410 * Return true if all items match the truth test, else false.
411 *
412 * @param array $array
413 * @param callable $callback
414 * @param mixed $true
415 * @param mixed $false
416 *
417 * @return bool|mixed
418 */
419 function acfe_array_every($array, $callback, $true = true, $false = false){
420
421 // validate
422 if(!is_array($array) || empty($array)){
423 return $false;
424 }
425
426 // loop
427 foreach($array as $key => $value){
428 if(!$callback($value, $key)){
429 return $false;
430 }
431 }
432
433 // return
434 return $true;
435 }
436
437
438 /**
439 * acfe_array_dot
440 *
441 * Flatten a multidimensional associative array with dots
442 *
443 * Example:
444 *
445 * $array = array(
446 * 'key1' => 'value',
447 * 'key2' => array(
448 * 'subkey1' => true,
449 * 'subkey2' => true,
450 * ),
451 * );
452 *
453 * will result to:
454 *
455 * $array = array(
456 * 'key1' => 'value',
457 * 'key2.subkey1' => true,
458 * 'key2.subkey2' => true,
459 * );
460 *
461 * @param $array
462 *
463 * @return array
464 */
465 function acfe_array_dot($array){
466
467 // basic validation
468 if(!is_array($array) || empty($array)){
469 return array();
470 }
471
472 // results
473 $results = array();
474
475 // stack entries: [current_array, prepend_prefix]
476 $stack = array(array($array, ''));
477
478 // loop stack
479 while(!empty($stack)){
480
481 // extract array & prefix
482 list($current, $prepend) = array_shift($stack);
483
484 foreach($current as $key => $row){
485
486 if(is_array($row) && !empty($row)){
487 $stack[] = array($row, "{$prepend}{$key}.");
488 }else{
489 $results[ $prepend.$key ] = $row;
490 }
491
492 }
493
494 }
495
496 return $results;
497 }
498
499
500 /**
501 * acfe_array_keys_dot
502 *
503 * Flatten a multidimensional array keys with dots
504 *
505 * Example:
506 *
507 * $array = array(
508 * 'key1' => 'value',
509 * 'key2' => array(
510 * 'subkey1' => true,
511 * 'subkey2' => true,
512 * ),
513 * );
514 *
515 * will result to:
516 *
517 * $array = array(
518 * 'key1',
519 * 'key2',
520 * 'key2.subkey1',
521 * 'key2.subkey2',
522 * );
523 *
524 * @param array $array The input array to flatten keys from
525 * @param bool $only_assoc Only allow associative arrays, ignore sequential arrays (numeric keys)
526 *
527 * @return array
528 */
529 function acfe_array_keys_dot($array, $only_assoc = false){
530
531 // basic validation
532 if(!is_array($array) || empty($array)){
533 return array();
534 }
535
536 // results
537 $results = array();
538
539 // stack entries: [current_array, prepend_prefix]
540 $stack = array(
541 array($array, '')
542 );
543
544 // loop stack
545 while(!empty($stack)){
546
547 // extract array & prefix
548 list($current, $prepend) = array_shift($stack);
549
550 foreach($current as $key => $row){
551
552 $results[] = $prepend . $key;
553
554 if(is_array($row) && !empty($row) && (!acf_is_sequential_array($row) || !$only_assoc)){
555 $stack[] = array($row, "{$prepend}{$key}.");
556 }
557
558 }
559
560 }
561
562 return $results;
563
564 }
565
566
567 /**
568 * acfe_array_undot
569 *
570 * Allows to use dot notation in array keys and assign the correct keys
571 *
572 * Example:
573 *
574 * $array = array(
575 * 'my.key' => true
576 * )
577 *
578 * will result to:
579 *
580 * $array = array(
581 * 'my' => array(
582 * 'key' => true
583 * )
584 * )
585 *
586 * @param $array
587 *
588 * @return array|mixed
589 */
590 function acfe_array_undot($array){
591
592 // validate array
593 if(!is_array($array)){
594 return $array;
595 }
596
597 // vars
598 $array2 = array();
599
600 // loop
601 foreach($array as $k => $v){
602 if(is_string($k) && acfe_has($k, '.')){
603
604 $array2[ $k ] = $v;
605 unset($array[ $k ]);
606
607 }
608 }
609
610 // loop dotted array
611 foreach($array2 as $k => $v){
612 acfe_set($array, $k, $v);
613 }
614
615 foreach($array as $k => $v){
616 if(is_array($v)){
617 $array[ $k ] = acfe_array_undot($v);
618 }
619 }
620
621 // return
622 return $array;
623
624 }
625
626
627 /**
628 * acfe_array_flatten
629 *
630 * Flatten a multi-dimensional array into a single level.
631 * Use $depth parameter to specify the maximum depth to flatten. Default is -1 (flatten all levels).
632 *
633 * $array = array(
634 * 'America' => array(
635 * 'us' => 'USA',
636 * 'ca' => 'Canada'
637 * ),
638 * 'Europe' => array(
639 * 'fr' => 'France',
640 * 'it' => 'Italy'
641 * ),
642 * );
643 *
644 * will result to:
645 * $array = array(
646 * 'USA',
647 * 'Canada',
648 * 'France',
649 * 'Italy'
650 * )
651 *
652 * @param array $array The multi-dimensional array to flatten
653 * @param bool $with_keys Whether to preserve keys in the flattened result (default: false)
654 * @param int $depth Maximum depth to flatten (-1 for unlimited)
655 *
656 * @return array
657 */
658 function acfe_array_flatten($array, $with_keys = false, $depth = -1){
659
660 // validate
661 if(!is_array($array)){
662 return array();
663 }
664
665 // prepare
666 $depth = max(-1, (int) $depth);
667 $result = array();
668
669 // loop
670 foreach($array as $k => $item){
671
672 // non-array item, add to result
673 if(!is_array($item)){
674 $with_keys ? $result[ $k ] = $item : $result[] = $item;
675
676 // unlimited depth
677 }elseif($depth === -1){
678 $result = array_merge($result, acfe_array_flatten($item, $with_keys, -1));
679
680 // handle custom depth
681 }elseif($depth > 0){
682 $result = array_merge($result, acfe_array_flatten($item, $with_keys, $depth - 1));
683 }
684
685 }
686
687 // return
688 return $result;
689 }
690
691
692 /**
693 * acfe_parse_args_r
694 *
695 * parse arguments recursively
696 *
697 * @param $a
698 * @param $b
699 *
700 * @return array
701 */
702 function acfe_parse_args_r(&$a, $b){
703
704 $a = (array) $a;
705 $b = (array) $b;
706 $r = $b;
707
708 foreach($a as $k => &$v){
709
710 if(is_array($v) && isset($r[ $k ]) && is_array($r[ $k ]) && acf_is_associative_array($r[ $k ])){
711 $r[ $k ] = acfe_parse_args_r($v, $r[ $k ]);
712 }else{
713 $r[ $k ] = $v;
714 }
715
716 }
717
718 return $r;
719
720 }
721
722
723 /**
724 * acfe_array_keys_r
725 *
726 * Array Keys Recursive
727 *
728 * @param $array
729 *
730 * @return int[]|string[]
731 */
732 function acfe_array_keys_r($array){
733
734 $keys = array_keys($array);
735
736 foreach($array as $i){
737 if(is_array($i)){
738 $keys = array_merge($keys, acfe_array_keys_r($i));
739 }
740 }
741
742 return $keys;
743
744 }
745
746
747 /**
748 * acfe_array_move
749 *
750 * Move the array key from position $a to $b
751 *
752 * @param $array
753 * @param $a
754 * @param $b
755 */
756 function acfe_array_move(&$array, $a, $b){
757
758 $out = array_splice($array, $a, 1);
759 array_splice($array, $b, 0, $out);
760
761 }
762
763
764 /**
765 * acfe_array_collapse
766 *
767 * Collapse an array of arrays into a single array.
768 *
769 * @param $array
770 *
771 * @return array
772 */
773 function acfe_array_collapse($array){
774
775 // vars
776 $results = array();
777
778 // validate
779 if(!is_array($array)){
780 return $results;
781 }
782
783 // loop
784 foreach($array as $values){
785
786 // append
787 if(is_array($values)){
788 $results[] = $values;
789 }
790
791 }
792
793 // return
794 return array_merge(array(), ...$results);
795 }
796
797
798 /**
799 * acfe_array_get
800 *
801 * Search within array using dot mapping
802 *
803 * @param $array
804 * @param $key
805 * @param $default
806 *
807 * @return mixed|null
808 *
809 * @deprecated since 0.9.2.6
810 */
811 function acfe_array_get($array, $key, $default = null){
812
813 acfe_deprecated_function('acfe_array_get()', '0.9.2.6', 'acfe_get()');
814 return acfe_get($array, $key, $default);
815
816 }
817
818 /**
819 * acfe_array_set
820 *
821 * @param $array
822 * @param $keys
823 * @param $value
824 *
825 * @return void
826 *
827 * @deprecated since 0.9.2.6
828 */
829 function acfe_array_set(&$array, $keys, $value = null){
830
831 acfe_deprecated_function('acfe_array_set()', '0.9.2.6', 'acfe_set()');
832 if(func_num_args() === 2){
833 acfe_set($array, $keys);
834 }else{
835 acfe_set($array, $keys, $value);
836 }
837
838 }
839
840
841 /**
842 * acfe_array_unset
843 *
844 * @param $array
845 * @param $keys
846 *
847 * @return void
848 *
849 * @deprecated since 0.9.2.6
850 */
851 function acfe_array_unset(&$array, $keys){
852
853 acfe_deprecated_function('acfe_array_unset()', '0.9.2.6', 'acfe_unset()');
854 acfe_unset($array, $keys);
855
856 }
857
858
859 /**
860 * acfe_array_has
861 *
862 * Perform array_key_exists() with dot notation (operator: AND)
863 *
864 * Usage examples:
865 *
866 * acfe_array_has($array, 'path.key');
867 * acfe_array_has($array, array('path.key', 'path.sub.key'));
868 *
869 * @param $array
870 * @param $paths
871 *
872 * @return bool
873 *
874 * @deprecated since 0.9.2.6
875 */
876 function acfe_array_has($array, $paths){
877
878 acfe_deprecated_function('acfe_array_has()', '0.9.2.6', 'acfe_has()');
879 return acfe_has($array, $paths);
880
881 }
882
883
884 /**
885 * acfe_maybe_get
886 *
887 * Similar to acfe_get() but also works with OBJECTS
888 *
889 * @param array $array
890 * @param int $key
891 * @param null $default
892 *
893 * @return mixed|null
894 *
895 * @deprecated since 0.9.2.6
896 */
897 function acfe_maybe_get($array = array(), $key = 0, $default = null){
898
899 acfe_deprecated_function('acfe_maybe_get()', '0.9.2.6', 'acfe_get()');
900 return acfe_get($array, $key, $default);
901
902 }
903
904
905 /**
906 * acfe_map_array_keys
907 *
908 * Map array keys recursively, allowing to update a row key.
909 * Return false in callback to remove the row.
910 *
911 * @param $array
912 * @param $func
913 *
914 * @return array|false
915 *
916 * @deprecated since 0.9.2.6
917 */
918 function acfe_map_array_keys($array, $func){
919
920 acfe_deprecated_function('acfe_map_array_keys()', '0.9.2.6', 'acfe_array_rewrite()');
921
922 // validate array
923 if(!is_array($array)){
924 return $array;
925 }
926
927 return acfe_array_rewrite($array, function($value, $key) use ($func){
928
929 // callback
930 $return = $func($key, $value);
931
932 // remove row
933 if($return === false || $return === true){
934 return $return;
935 }
936
937 // rewrite key
938 return array($return => $value);
939
940 }, true);
941
942 }
943
944
945 /**
946 * acfe_prefix_array_keys
947 *
948 * Prefix array keys recursively ignoring numeric keys
949 *
950 * @param $array
951 * @param $prefix
952 * @param $ignore
953 *
954 * @return array
955 *
956 * @deprecated since 0.9.2.6
957 */
958 function acfe_prefix_array_keys($array, $prefix, $ignore = array(), $recursive = true){
959
960 acfe_deprecated_function('acfe_prefix_array_keys()', '0.9.2.6', 'acfe_array_rewrite()');
961
962 return acfe_array_rewrite($array, function($value, $key) use ($prefix, $ignore){
963
964 // ignore numeric keys and ignore list
965 if(is_numeric($key) || ($ignore && acfe_contains($ignore, $key))){
966 return array($key => $value);
967 }
968
969 // prefix key
970 return array("{$prefix}{$key}" => $value);
971
972 }, $recursive);
973
974 }
975
976 /**
977 * acfe_unprefix_array_keys
978 *
979 * Prefix array keys recursively ignoring numeric keys
980 *
981 * @param $array
982 * @param $prefix
983 * @param $ignore
984 *
985 * @return array
986 *
987 * @deprecated since 0.9.2.6
988 */
989 function acfe_unprefix_array_keys($array, $prefix, $ignore = array(), $recursive = true){
990
991 acfe_deprecated_function('acfe_unprefix_array_keys()', '0.9.2.6', 'acfe_array_rewrite()');
992
993 return acfe_array_rewrite($array, function($value, $key) use ($prefix, $ignore){
994
995 // ignore numeric keys and ignore list
996 if(is_numeric($key) || ($ignore && acfe_contains($ignore, $key))){
997 return array($key => $value);
998 }
999
1000 // ltrim prefix
1001 $key = acfe_ltrim($key, $prefix);
1002 return array($key => $value);
1003
1004 }, $recursive);
1005
1006 }
1007
1008
1009 /**
1010 * acfe_get_array_flatten
1011 *
1012 * @param $array
1013 * @param $flattened
1014 *
1015 * @return array
1016 *
1017 * @deprecated since 0.9.2.6
1018 */
1019 function acfe_get_array_flatten($array = array(), $flattened = array()){
1020 acfe_deprecated_function('acfe_get_array_flatten()', '0.9.2.6', 'acfe_array_flatten($array, true)');
1021 return acfe_array_flatten($array, true);
1022 }
1023
1024
1025 /**
1026 * acfe_array_insert_before
1027 *
1028 * Insert data before a specific array key
1029 *
1030 * @param $key
1031 * @param array $array
1032 * @param $new_key
1033 * @param $new_value
1034 *
1035 * @return array
1036 *
1037 * @deprecated since 0.9.2.6
1038 */
1039 function acfe_array_insert_before($array, $key, $new_key, $new_value = null){
1040 acfe_deprecated_function('acfe_array_insert_before()', '0.9.2.6', 'acfe_before()');
1041 return acfe_before($array, $key, array($new_key => $new_value));
1042 }
1043
1044
1045 /**
1046 * acfe_array_insert_after
1047 *
1048 * Insert data after a specific array key
1049 *
1050 * @param $key
1051 * @param array $array
1052 * @param $new_key
1053 * @param $new_value
1054 *
1055 * @return array
1056 *
1057 * @deprecatedsince 0.9.2.6
1058 */
1059 function acfe_array_insert_after($array, $key, $new_key, $new_value = null){
1060 acfe_deprecated_function('acfe_array_insert_after()', '0.9.2.6', 'acfe_after()');
1061 return acfe_after($array, $key, array($new_key => $new_value));
1062 }
1063
1064
1065 /**
1066 * acfe_array_to_string
1067 *
1068 * Convert an array to string
1069 *
1070 * @param array $array
1071 *
1072 * @return mixed
1073 *
1074 * @deprecated since 0.9.2.6
1075 */
1076 function acfe_array_to_string($array = array()){
1077
1078 // depreacted
1079 acfe_deprecated_function('acfe_array_to_string()', '0.9.2.6', 'acfe_array_first()');
1080
1081 // validate array
1082 if(!is_array($array)){
1083 return $array;
1084 }
1085
1086 // retrieve the first value of the array that is a string, number or boolean
1087 return acfe_array_first($array, function($val){
1088 return is_string($val) || is_numeric($val) || is_bool($val);
1089 }, false);
1090
1091 }