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 / api.php
codepress-admin-columns Last commit date
assets 1 day ago classes 1 day ago languages 1 day ago settings 1 day ago templates 1 day ago vendor 1 day ago api.php 1 day ago changelog.txt 1 day ago codepress-admin-columns.php 1 day ago readme.txt 1 day ago
api.php
245 lines
1 <?php
2
3 declare(strict_types=1);
4
5 use AC\Column;
6 use AC\Exception\HookTimingException;
7 use AC\ListScreen;
8 use AC\ListScreenCollection;
9 use AC\ListScreenRepository\Storage;
10 use AC\Plugin\Version;
11 use AC\Registry;
12 use AC\Type\ColumnId;
13 use AC\Type\ListScreenId;
14 use AC\Type\TableId;
15 use AC\Type\Url;
16
17 /**
18 * For usage @see https://docs.admincolumns.com/article/57-code-snippets
19 * List of available template functions:
20 * @method ac_get_list_screens()
21 * @method ac_get_list_screen()
22 * @method ac_get_column()
23 * @method ac_get_columns()
24 * @method AC()
25 */
26
27 if (! function_exists('ac_get_list_screen')) {
28 /**
29 * Return the list table configuration, such as its ID, columns, and settings.
30 * For usage @see https://docs.admincolumns.com/article/57-code-snippets
31 */
32 function ac_get_list_screen(string $id): ?ListScreen
33 {
34 if (! did_action('wp_loaded')) {
35 throw HookTimingException::called_too_early('wp_loaded');
36 }
37
38 $storage = Registry::get(Storage::class);
39
40 if (! $storage instanceof Storage) {
41 return null;
42 }
43
44 try {
45 return $storage->find(new ListScreenId($id));
46 } catch (Throwable $e) {
47 return null;
48 }
49 }
50 }
51
52 if (! function_exists('ac_get_list_screens')) {
53 /**
54 * Returns a collection of all list table configurations for a specific table.
55 * For usage @see https://docs.admincolumns.com/article/57-code-snippets
56 */
57 function ac_get_list_screens(string $table_id): ListScreenCollection
58 {
59 if (! did_action('wp_loaded')) {
60 throw HookTimingException::called_too_early('wp_loaded');
61 }
62
63 $storage = Registry::get(Storage::class);
64
65 if (! $storage instanceof Storage) {
66 return new ListScreenCollection();
67 }
68
69 try {
70 return $storage->find_all_by_table_id(new TableId($table_id));
71 } catch (Throwable $e) {
72 return new ListScreenCollection();
73 }
74 }
75 }
76
77 if (! function_exists('ac_get_column')) {
78 /**
79 * Returns a single column by its name and list screen ID.
80 * For usage @see https://docs.admincolumns.com/article/57-code-snippets
81 */
82 function ac_get_column(string $column_name, string $list_screen_id): ?Column
83 {
84 if (! did_action('wp_loaded')) {
85 throw HookTimingException::called_too_early('wp_loaded');
86 }
87
88 $storage = Registry::get(Storage::class);
89
90 if (! $storage instanceof Storage) {
91 return null;
92 }
93
94 try {
95 $list_screen = $storage->find(new ListScreenId($list_screen_id));
96 } catch (Throwable $e) {
97 return null;
98 }
99
100 if (! $list_screen) {
101 return null;
102 }
103
104 try {
105 return $list_screen->get_column(new ColumnId($column_name));
106 } catch (Throwable $e) {
107 return null;
108 }
109 }
110 }
111
112 if (! function_exists('ac_get_columns')) {
113 /**
114 * Returns all columns for a specific list table.
115 * For usage @see https://docs.admincolumns.com/article/57-code-snippets
116 * @return Column[]
117 */
118 function ac_get_columns(string $list_screen_id): array
119 {
120 if (! did_action('wp_loaded')) {
121 throw HookTimingException::called_too_early('wp_loaded');
122 }
123
124 $storage = Registry::get(Storage::class);
125
126 if (! $storage instanceof Storage) {
127 return [];
128 }
129
130 try {
131 $list_screen = $storage->find(new ListScreenId($list_screen_id));
132 } catch (Throwable $e) {
133 return [];
134 }
135
136 if (! $list_screen) {
137 return [];
138 }
139
140 return iterator_to_array($list_screen->get_columns());
141 }
142 }
143
144 if (! function_exists('AC')) {
145 /**
146 * returns thw AC\AdminColumn object. Contains the plugin version and directory path.
147 */
148 function AC(): AC\AdminColumns
149 {
150 static $ac = null;
151
152 if ($ac === null) {
153 $ac = new AC\AdminColumns(AC_FILE, new Version(AC_VERSION));
154 }
155
156 return $ac;
157 }
158 }
159
160 if (! function_exists('ac_is_pro_active')) {
161 function ac_is_pro_active(): bool
162 {
163 return defined('ACP_VERSION');
164 }
165 }
166
167 function ac_get_admin_url(?string $slug = null): string
168 {
169 _deprecated_function(__METHOD__, '4.5', 'Url\Editor');
170
171 return (new Url\Editor($slug))->get_url();
172 }
173
174 function ac_get_admin_network_url(?string $slug = null): string
175 {
176 _deprecated_function(__METHOD__, '4.5', 'Url\EditorNetwork');
177
178 return (new Url\EditorNetwork($slug))->get_url();
179 }
180
181 function ac_register_columns(): void
182 {
183 _deprecated_function(__METHOD__, '4.0');
184 }
185
186 function ac_get_site_utm_url(
187 string $path,
188 string $utm_medium,
189 ?string $utm_content = null,
190 ?string $utm_campaign = null
191 ): string {
192 _deprecated_function(__METHOD__, '6.0', 'AC\Type\UrlUtmTags()');
193
194 return (new Url\UtmTags(new Url\Site($path), $utm_medium, $utm_content, $utm_campaign))->get_url();
195 }
196
197 function ac_get_site_documentation_url(?string $path = null): string
198 {
199 _deprecated_function(__METHOD__, '6.0', 'AC\Type\Url\Documentation()');
200
201 return (new Url\Documentation($path))->get_url();
202 }
203
204 function ac_get_site_url(?string $path = null): string
205 {
206 _deprecated_function(__METHOD__, '6.0', 'AC\Type\Url\Site()');
207
208 return (new Url\Site($path))->get_url();
209 }
210
211 function ac_get_url(string $relative_file_path): string
212 {
213 _deprecated_function(__FUNCTION__, '7.0.10');
214
215 return '';
216 }
217
218 if (! function_exists('ac_load_columns')) {
219 function ac_load_columns(): void
220 {
221 _deprecated_function(__METHOD__, '4.1');
222 }
223 }
224
225 if (! function_exists('ac_helper')) {
226 /**
227 * @deprecated 7.0.10 Use Helper\X::create() instead.
228 */
229 function ac_helper(): AC\Helper
230 {
231 _deprecated_function(__FUNCTION__, '7.0.10', 'Helper\X::create()');
232
233 return new AC\Helper();
234 }
235 }
236
237 if (! function_exists('ac_format_date')) {
238 function ac_format_date(string $format, ?int $timestamp = null, ?DateTimeZone $timezone = null): ?string
239 {
240 _deprecated_function(__METHOD__, '7.0.10', 'wp_date()');
241
242 return wp_date($format, $timestamp, $timezone ?? new DateTimeZone('UTC')) ?: null;
243 }
244 }
245