-
Notifications
You must be signed in to change notification settings - Fork 3
/
route.php
54 lines (38 loc) · 1.11 KB
/
route.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
<?php
namespace tangible\template_system;
use tangible\template_system;
template_system::$state->admin_route_info = null;
function get_admin_route_info() {
// Cached
if (!empty(template_system::$state->admin_route_info)) {
return template_system::$state->admin_route_info;
}
global $pagenow;
$info = [
'type' => '',
'edit' => false,
'new' => false,
'single' => false,
'archive' => false,
];
if ('post.php' == $pagenow && !empty($_GET['post'])) {
// Edit single post
$this_post = get_post($_GET['post']);
if (!empty($this_post)) {
$info['type'] = $this_post->post_type;
$info['edit'] = true;
$info['single'] = true;
}
} elseif ('post-new.php' == $pagenow && !empty($_GET['post_type'])) {
// New post
$info['type'] = $_GET['post_type'];
$info['edit'] = true;
$info['single'] = true;
$info['new'] = true;
} elseif ('edit.php' == $pagenow && !empty($_GET['post_type'])) {
// Archive
$info['type'] = $_GET['post_type'];
$info['archive'] = true;
}
return template_system::$state->admin_route_info = $info;
};