PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.0.19
Admin Columns v7.0.19
7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Helper / Arrays.php
codepress-admin-columns / classes / Helper Last commit date
Select 1 month ago Arrays.php 1 month ago Creatable.php 1 month ago Date.php 1 month ago File.php 1 month ago Html.php 1 month ago Icon.php 1 month ago Image.php 1 month ago Mbstring.php 1 month ago Media.php 1 month ago Menu.php 1 month ago Network.php 1 month ago Post.php 1 month ago Strings.php 1 month ago Taxonomy.php 1 month ago Translations.php 1 month ago User.php 1 month ago UserRoles.php 1 month ago
Arrays.php
147 lines
1 <?php
2
3 namespace AC\Helper;
4
5 use AC\Formatter\ImplodeRecursive;
6 use AC\Type\Value;
7
8 class Arrays extends Creatable
9 {
10
11 public function add_nested_value(array $keys, $value, array $result = []): array
12 {
13 $key = array_shift($keys);
14
15 if ($keys) {
16 $value = $this->add_nested_value(
17 $keys,
18 $value,
19 is_array($result[$key]) ? $result[$key] : []
20 );
21 }
22
23 $result[$key] = $value;
24
25 return $result;
26 }
27
28 public function get_nested_value(array $array, array $keys)
29 {
30 foreach ($keys as $key) {
31 if ( ! isset($array[$key])) {
32 return null;
33 }
34
35 $array = $array[$key];
36 }
37
38 return $array;
39 }
40
41 /**
42 * @deprecated 7.0
43 */
44 public function implode_recursive(string $glue, array $pieces): string
45 {
46 _deprecated_function(__METHOD__, '7.0', ImplodeRecursive::class);
47
48 return (new ImplodeRecursive($glue))->format(new Value($pieces));
49 }
50
51 /**
52 * Indents any object as long as it has a unique id and that of its parent.
53 */
54 public function indent(
55 array $array,
56 int $parentId = 0,
57 string $parentKey = 'post_parent',
58 string $selfKey = 'ID',
59 string $childrenKey = 'children'
60 ): array {
61 $indent = [];
62
63 $i = 0;
64 foreach ($array as $v) {
65 if ($v->$parentKey == $parentId) {
66 $indent[$i] = $v;
67 $indent[$i]->$childrenKey = $this->indent($array, $v->$selfKey, $parentKey, $selfKey);
68
69 $i++;
70 }
71 }
72
73 return $indent;
74 }
75
76 /**
77 * Remove empty values from array
78 */
79 public function filter(array $array): array
80 {
81 return array_filter($array, [Strings::create(), 'is_not_empty']);
82 }
83
84 /**
85 * Insert element into array at specific position
86 */
87 public function insert(array $array, array $insert, $position): array
88 {
89 $new = [];
90 foreach ($array as $key => $value) {
91 $new[$key] = $value;
92 if ($key === $position) {
93 $new = array_merge($new, $insert);
94 }
95 }
96
97 return $new;
98 }
99
100 public function is_associative($array): bool
101 {
102 _deprecated_function(__METHOD__, '7.0');
103
104 if ( ! is_array($array)) {
105 return false;
106 }
107
108 foreach ($array as $key => $value) {
109 if (is_string($key)) {
110 return true;
111 }
112 }
113
114 return false;
115 }
116
117 /**
118 * @deprecated 7.0
119 */
120 public function get_duplicates(): array
121 {
122 _deprecated_function(__METHOD__, '7.0');
123
124 return [];
125 }
126
127 /**
128 * @deprecated 7.0
129 */
130 public function get_integers_from_mixed(): array
131 {
132 _deprecated_function(__METHOD__, '7.0');
133
134 return [];
135 }
136
137 /**
138 * @deprecated 7.0
139 */
140 public function key_replace(): array
141 {
142 _deprecated_function(__METHOD__, '7.0');
143
144 return [];
145 }
146
147 }