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