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->setupPageEnvironment('singular', [ 'title' => __('My Account', 'yatra'), 'post_type' => 'page', 'post_name' => $base, ]); $this->setQueryVars([ 'yatra_account_page' => $page, ]); $GLOBALS['yatra_loading_react_account_page'] = true; return $this->selectTemplate('account-page', null, 'account'); } /** * @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; } } }