isValidAccountPage($page)) { return false; } $tab = $this->accountPageToReactTab($page); $path = UrlParser::getCleanRequestPath(); if ($path !== $base && str_starts_with($path, $base . '/')) { wp_safe_redirect(add_query_arg('tab', $tab, home_url('/' . $base . '/'))); exit; } $currentTab = isset($_GET['tab']) ? sanitize_key((string) $_GET['tab']) : ''; if ($currentTab !== '' && $currentTab !== $tab) { wp_safe_redirect(add_query_arg('tab', $tab)); exit; } $this->prevent404(); $this->setQueryVars([ 'yatra_account_page' => $page, ]); $template_path = YATRA_PLUGIN_PATH . 'templates/account-page.php'; if (!file_exists($template_path)) { $this->logError("Account page template not found: {$template_path}"); return false; } $GLOBALS['yatra_loading_react_account_page'] = true; include $template_path; $this->exit(); return true; } /** * @return list */ private function validAccountPages(): array { return [ 'dashboard', 'profile', 'bookings', 'payments', 'documents', 'saved-trips', 'wishlist', 'settings', ]; } private function isValidAccountPage(string $page): bool { return in_array($page, $this->validAccountPages(), true); } private function accountPageToReactTab(string $page): string { switch ($page) { case 'wishlist': return 'saved-trips'; case 'settings': return 'profile'; default: return $page; } } }