ListScreens.php
1.2 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
<?php
namespace ACA\EC\Service;
use AC;
use AC\Registerable;
use ACA\EC\ListScreenFactory;
final class ListScreens implements Registerable {
public function register() {
AC\ListScreenFactory::add( new ListScreenFactory\EventFactory() );
AC\ListScreenFactory::add( new ListScreenFactory\OrganizerFactory() );
AC\ListScreenFactory::add( new ListScreenFactory\VenueFactory() );
if ( post_type_exists( 'tribe_event_series' ) ) {
AC\ListScreenFactory::add( new ListScreenFactory\EventSeriesFactory() );
}
add_action( 'ac/list_screen_groups', [ $this, 'register_list_screen_groups' ] );
add_filter( 'ac/admin/menu_group', [ $this, 'update_menu_list_groups' ], 10, 2 );
}
public function register_list_screen_groups( AC\Groups $groups ): void {
$groups->add( 'events-calendar', 'Events Calendar', 7 );
}
private function get_post_list_keys(): array {
return [
'tribe_organizer',
'tribe_events',
'tribe_event_series',
'tribe_venue',
];
}
public function update_menu_list_groups( string $group, AC\ListScreen $list_screen ): string {
$keys = $this->get_post_list_keys();
if ( in_array( $list_screen->get_key(), $keys, true ) ) {
return 'events-calendar';
}
return $group;
}
}