ListScreens.php
1.05 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
<?php
namespace ACA\MetaBox\Service;
use AC;
use AC\Groups;
use AC\Registerable;
use ACA\MetaBox\ListScreen;
class ListScreens implements Registerable {
public function register(): void
{
add_action( 'ac/list_screens', [ $this, 'register_list_screens' ] );
add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_groups' ] );
}
public function register_list_screen_groups( Groups $groups ) {
$groups->register_group( 'metabox', 'MetaBox', 7 );
}
public function register_list_screens() {
$list_screens = [];
$post_type_mapping = [
'meta-box' => ListScreen\MetaBox::class,
'mb-taxonomy' => ListScreen\Taxonomy::class,
'mb-relationship' => ListScreen\Relationship::class,
'mb-post-type' => ListScreen\PostType::class,
];
foreach ( $post_type_mapping as $post_type => $class_name ) {
if ( post_type_exists( $post_type ) ) {
$list_screens[] = new $class_name();
}
}
foreach ( $list_screens as $list_screen ) {
AC\ListScreenTypes::instance()->register_list_screen( $list_screen );
}
}
}