post_type ?? ''; if (in_array($current_screen->id ?? '', ['admin_page_' . Resources::PAGE, 'admin_page_' . Onboarding::PAGE], true)) return 'daytidy'; // Don't do anything if the post type is not DayTidy Post Type if (!in_array($post_type, $this->postTypes(), true)) return $parent_file; return 'daytidy'; } /** * @param string|null $submenu_file * @return string */ public function submenu(?string $submenu_file): ?string { global $current_screen; $post_type = $current_screen->post_type ?? ''; if (($current_screen->id ?? '') === 'admin_page_' . Resources::PAGE) return 'edit.php?post_type=' . Booking::PT; if (($current_screen->id ?? '') === 'admin_page_' . Onboarding::PAGE) return 'daytidy-settings'; // Don't do anything if the post type is not DayTidy Post Type if (!in_array($post_type, $this->postTypes(), true)) return $submenu_file; if ($post_type === Coupon::PT) return 'edit.php?post_type=' . Booking::PT; if ($post_type === Notification::PT) return NotificationsMenu::PAGE; return 'edit.php?post_type=' . $post_type; } /** * @return string[] */ private function postTypes(): array { $post_types = []; foreach ([Offering::PT, View::PT, Booking::PT, Coupon::PT, Notification::PT] as $post_type) { if (post_type_exists($post_type)) $post_types[] = $post_type; } return $post_types; } }