ListScreens.php
961 Bytes
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
<?php
namespace ACA\BbPress\Service;
use AC;
use AC\ListScreenPost;
use AC\Registerable;
use ACA\BbPress\ListScreenFactory\TopicFactory;
class ListScreens implements Registerable {
public function register(): void
{
add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_group' ] );
add_action( 'ac/admin/menu_group', [ $this, 'update_menu_list_groups' ], 10, 2 );
AC\ListScreenFactory\Aggregate::add( new TopicFactory() );
}
public function register_list_screen_group( AC\Groups $groups ): void {
$groups->add( 'bbpress', __( 'bbPress' ), 8 );
}
private function get_post_list_keys(): array {
return [
'forum',
'reply',
'topic',
];
}
public function update_menu_list_groups( string $group, AC\ListScreen $list_screen ): string {
if ( $list_screen instanceof ListScreenPost && in_array( $list_screen->get_post_type(), $this->get_post_list_keys(), true ) ) {
return 'bbpress';
}
return $group;
}
}