PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 7.1.4
Admin Columns v7.1.4
7.1.4 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
Image 2 days ago Select 2 days ago Arrays.php 2 days ago AvailableTranslations.php 2 days ago Creatable.php 2 days ago Dashicon.php 2 days ago Date.php 2 days ago Html.php 2 days ago Icon.php 2 days ago Image.php 2 days ago LocalFile.php 2 days ago Mbstring.php 2 days ago MediaIdResolver.php 2 days ago Menu.php 2 days ago Network.php 2 days ago Post.php 2 days ago Strings.php 2 days ago Taxonomy.php 2 days ago User.php 2 days ago UserRoles.php 2 days ago WpDateFormat.php 2 days ago
Arrays.php
151 lines
1 <?php
2
3 declare(strict_types=1);
4
5 namespace AC\Helper;
6
7 use AC\Formatter\ImplodeRecursive;
8 use AC\Type\Value;
9
10 class Arrays extends Creatable
11 {
12 public function add_nested_value(array $keys, $value, array $result = []): array
13 {
14 $key = array_shift($keys);
15
16 if ($keys) {
17 $value = $this->add_nested_value(
18 $keys,
19 $value,
20 isset($result[$key]) && is_array($result[$key]) ? $result[$key] : []
21 );
22 }
23
24 $result[$key] = $value;
25
26 return $result;
27 }
28
29 public function get_nested_value(array $array, array $keys)
30 {
31 foreach ($keys as $key) {
32 if (! isset($array[$key])) {
33 return null;
34 }
35
36 $array = $array[$key];
37 }
38
39 return $array;
40 }
41
42 /**
43 * @deprecated 7.0
44 */
45 public function implode_recursive(string $glue, array $pieces): string
46 {
47 _deprecated_function(__METHOD__, '7.0', ImplodeRecursive::class);
48
49 $value = (new ImplodeRecursive($glue))->format(new Value($pieces));
50
51 return (string)$value;
52 }
53
54 /**
55 * Indents any object as long as it has a unique id and that of its parent.
56 */
57 public function indent(
58 array $array,
59 int $parentId = 0,
60 string $parentKey = 'post_parent',
61 string $selfKey = 'ID',
62 string $childrenKey = 'children'
63 ): array {
64 $indent = [];
65
66 $i = 0;
67 foreach ($array as $v) {
68 if ($v->$parentKey == $parentId) {
69 $indent[$i] = $v;
70 $indent[$i]->$childrenKey = $this->indent($array, $v->$selfKey, $parentKey, $selfKey);
71
72 $i++;
73 }
74 }
75
76 return $indent;
77 }
78
79 /**
80 * Remove empty values from array
81 */
82 public function filter(array $array): array
83 {
84 return array_filter($array, [Strings::create(), 'is_not_empty']);
85 }
86
87 /**
88 * Insert element into array at specific position
89 */
90 public function insert(array $array, array $insert, $position): array
91 {
92 $new = [];
93 foreach ($array as $key => $value) {
94 $new[$key] = $value;
95 if ($key === $position) {
96 $new = array_merge($new, $insert);
97 }
98 }
99
100 return $new;
101 }
102
103 public function is_associative($array): bool
104 {
105 _deprecated_function(__METHOD__, '7.0');
106
107 if (! is_array($array)) {
108 return false;
109 }
110
111 foreach ($array as $key => $value) {
112 if (is_string($key)) {
113 return true;
114 }
115 }
116
117 return false;
118 }
119
120 /**
121 * @deprecated 7.0
122 */
123 public function get_duplicates(): array
124 {
125 _deprecated_function(__METHOD__, '7.0');
126
127 return [];
128 }
129
130 /**
131 * @deprecated 7.0
132 */
133 public function get_integers_from_mixed(): array
134 {
135 _deprecated_function(__METHOD__, '7.0');
136
137 return [];
138 }
139
140 /**
141 * @deprecated 7.0
142 */
143 public function key_replace(): array
144 {
145 _deprecated_function(__METHOD__, '7.0');
146
147 return [];
148 }
149
150 }
151