-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathapi.php
192 lines (137 loc) · 3.87 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?php
use AC\Column;
use AC\Container;
use AC\Helper;
use AC\ListScreen;
use AC\ListScreenCollection;
use AC\Type\ListKey;
use AC\Type\ListScreenId;
use AC\Type\Url;
function ac_get_url(string $relative_file_path): string
{
return Container::get_location()->with_suffix($relative_file_path)->get_url();
}
if ( ! function_exists('AC')) {
function AC(): AC\AdminColumns
{
static $ac = null;
if ($ac === null) {
$ac = new AC\AdminColumns();
}
return $ac;
}
}
if ( ! function_exists('ac_helper')) {
function ac_helper(): AC\Helper
{
return new AC\Helper();
}
}
/**
* @since 4.0.0
*/
if ( ! function_exists('ac_get_list_screen')) {
function ac_get_list_screen(string $id): ?ListScreen
{
return Container::get_storage()->find(new ListScreenId($id));
}
}
/**
* Usage: Load after or within the 'wp_loaded' action hook.
* @since 4.0.0
*/
if ( ! function_exists('ac_get_list_screens')) {
function ac_get_list_screens(string $key): ListScreenCollection
{
return Container::get_storage()->find_all_by_key(new ListKey($key));
}
}
/**
* Usage: Load after or within the 'wp_loaded' action hook.
*/
if ( ! function_exists('ac_get_column')) {
function ac_get_column(string $column_name, string $list_screen_id): ?Column
{
try {
$list_id = new ListScreenId($list_screen_id);
} catch (Exception $e) {
return null;
}
$list_screen = Container::get_storage()->find($list_id);
if ( ! $list_screen) {
return null;
}
$column = $list_screen->get_column($column_name);
return $column ?: null;
}
}
/**
* Usage: Load after or within the 'wp_loaded' action hook.
* @return AC\Column[]
* @since 4.2
*/
if ( ! function_exists('ac_get_columns')) {
function ac_get_columns(string $list_screen_id): array
{
try {
$list_id = new ListScreenId($list_screen_id);
} catch (Exception $e) {
return [];
}
$list_screen = Container::get_storage()->find($list_id);
if ( ! $list_screen) {
return [];
}
return iterator_to_array($list_screen->get_columns());
}
}
if ( ! function_exists('ac_format_date')) {
function ac_format_date(string $format, int $timestamp = null, DateTimeZone $timezone = null): ?string
{
return (new Helper\Date())->format_date($format, $timestamp, $timezone) ?: null;
}
}
function ac_get_admin_url(string $slug = null): string
{
_deprecated_function(__METHOD__, '4.5', 'Url\Editor');
return (new Url\Editor($slug))->get_url();
}
function ac_get_admin_network_url(string $slug = null): string
{
_deprecated_function(__METHOD__, '4.5', 'Url\EditorNetwork');
return (new Url\EditorNetwork($slug))->get_url();
}
function ac_register_columns(): void
{
_deprecated_function(__METHOD__, '4.0');
}
function ac_get_site_utm_url(
string $path,
string $utm_medium,
string $utm_content = null,
string $utm_campaign = null
): string {
_deprecated_function(__METHOD__, '6.0', 'AC\Type\UrlUtmTags()');
return (new Url\UtmTags(new Url\Site($path), $utm_medium, $utm_content, $utm_campaign))->get_url();
}
function ac_get_site_documentation_url(string $path = null): string
{
_deprecated_function(__METHOD__, '6.0', 'AC\Type\Url\Documentation()');
return (new Url\Documentation($path))->get_url();
}
function ac_get_site_url(string $path = null): string
{
_deprecated_function(__METHOD__, '6.0', 'AC\Type\Url\Site()');
return (new Url\Site($path))->get_url();
}
if ( ! function_exists('ac_load_columns')) {
function ac_load_columns(): void
{
_deprecated_function(__METHOD__, '4.1');
}
}
function ac_is_pro_active(): bool
{
_deprecated_function(__METHOD__, '6.0');
return defined('ACP_FILE');
}