ListScreens.php
1.52 KB
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
<?php
namespace AC;
class ListScreens implements Registrable {
public function register() {
add_action( 'init', [ $this, 'register_list_screens' ], 1000 ); // run after all post types are registered
}
public function register_list_screens() {
$list_screens = [];
foreach ( $this->get_post_types() as $post_type ) {
$list_screens[] = new ListScreen\Post( $post_type );
}
$list_screens[] = new ListScreen\Media();
$list_screens[] = new ListScreen\Comment();
if ( ! is_multisite() ) {
$list_screens[] = new ListScreen\User();
}
foreach ( $list_screens as $list_screen ) {
$this->register_list_screen( $list_screen );
}
do_action( 'ac/list_screens', $this );
}
/**
* @param ListScreen $list_screen
*
* @return self
*/
public function register_list_screen( ListScreen $list_screen ) {
ListScreenTypes::instance()->register_list_screen( $list_screen );
return $this;
}
/**
* Get a list of post types for which Admin Columns is active
* @return array List of post type keys (e.g. post, page)
* @since 1.0
*/
public function get_post_types() {
$post_types = get_post_types( [
'_builtin' => false,
'show_ui' => true,
] );
foreach ( [ 'post', 'page' ] as $builtin ) {
if ( post_type_exists( $builtin ) ) {
$post_types[ $builtin ] = $builtin;
}
}
/**
* Filter the post types for which Admin Columns is active
*
* @param array $post_types List of active post type names
*
* @since 2.0
*/
return apply_filters( 'ac/post_types', $post_types );
}
}