| 1 |
<?php |
| 2 |
/** |
| 3 |
* Login Page Template |
| 4 |
* |
| 5 |
* Production-optimized template for rendering the login page |
| 6 |
* |
| 7 |
* @package Yatra |
| 8 |
* @version 1.0.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
// Prevent direct access |
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
// Security: Check if user is already logged in and redirect securely |
| 17 |
$current_user = wp_get_current_user(); |
| 18 |
if ($current_user->ID > 0) { |
| 19 |
// Use safe redirect with nonce verification |
| 20 |
$redirect_url = apply_filters('yatra_login_redirect_url', home_url('/' . \Yatra\Services\SettingsService::getAccountBase()), $current_user); |
| 21 |
wp_safe_redirect($redirect_url); |
| 22 |
exit; |
| 23 |
} |
| 24 |
|
| 25 |
// Performance: Only enqueue assets when needed |
| 26 |
if (!wp_style_is('yatra-login-page', 'registered')) { |
| 27 |
wp_enqueue_style( |
| 28 |
'yatra-login-page', |
| 29 |
YATRA_PLUGIN_URL . 'assets/css/pages/login-page.css', |
| 30 |
['yatra-login-shortcode'], // Dependency on shortcode styles |
| 31 |
YATRA_VERSION |
| 32 |
); |
| 33 |
} |
| 34 |
|
| 35 |
// Security: Add CSP headers if available |
| 36 |
if (!headers_sent()) { |
| 37 |
header('X-Content-Type-Options: nosniff'); |
| 38 |
header('X-Frame-Options: SAMEORIGIN'); |
| 39 |
header('Referrer-Policy: strict-origin-when-cross-origin'); |
| 40 |
} |
| 41 |
|
| 42 |
// Performance: Set cache control headers |
| 43 |
if (!headers_sent()) { |
| 44 |
header('Cache-Control: public, max-age=300'); // 5 minutes cache |
| 45 |
} |
| 46 |
|
| 47 |
// SEO: Set page metadata |
| 48 |
$page_title = __('Login - Yatra', 'yatra'); |
| 49 |
$page_description = __('Login to your Yatra account to manage your bookings and travel experiences.', 'yatra'); |
| 50 |
|
| 51 |
?> |
| 52 |
<!DOCTYPE html> |
| 53 |
<html <?php language_attributes(); ?>> |
| 54 |
<head> |
| 55 |
<meta charset="<?php bloginfo('charset'); ?>"> |
| 56 |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> |
| 57 |
<meta name="description" content="<?php echo esc_attr($page_description); ?>"> |
| 58 |
<meta name="robots" content="noindex, nofollow"> |
| 59 |
<title><?php echo esc_html($page_title); ?></title> |
| 60 |
|
| 61 |
<!-- Preload critical resources --> |
| 62 |
<link rel="preload" href="<?php echo esc_url(YATRA_PLUGIN_URL . 'assets/css/shortcodes/login-shortcode.css'); ?>" as="style"> |
| 63 |
|
| 64 |
<?php wp_head(); ?> |
| 65 |
</head> |
| 66 |
<body <?php body_class('yatra-login-page'); ?>> |
| 67 |
|
| 68 |
<?php wp_body_open(); ?> |
| 69 |
|
| 70 |
<!-- Skip to main content for accessibility --> |
| 71 |
<a href="#yatra-login-main" class="skip-link screen-reader-text"> |
| 72 |
<?php esc_html_e('Skip to content', 'yatra'); ?> |
| 73 |
</a> |
| 74 |
|
| 75 |
<div class="yatra-login-page-wrapper"> |
| 76 |
<div class="yatra-login-page-container"> |
| 77 |
<header class="yatra-login-page-header"> |
| 78 |
<div class="yatra-login-page-logo"> |
| 79 |
<?php if (function_exists('the_custom_logo') && get_custom_logo()) : ?> |
| 80 |
<?php the_custom_logo(); ?> |
| 81 |
<?php else : ?> |
| 82 |
<h1 class="site-title"> |
| 83 |
<a href="<?php echo esc_url(home_url('/')); ?>" rel="home"> |
| 84 |
<?php echo esc_html(get_bloginfo('name')); ?> |
| 85 |
</a> |
| 86 |
</h1> |
| 87 |
<?php endif; ?> |
| 88 |
</div> |
| 89 |
<div class="yatra-login-page-nav"> |
| 90 |
<nav aria-label="<?php esc_attr_e('Main navigation', 'yatra'); ?>"> |
| 91 |
<a href="<?php echo esc_url(home_url('/')); ?>" class="yatra-back-home"> |
| 92 |
<?php esc_html_e('← Back to Home', 'yatra'); ?> |
| 93 |
</a> |
| 94 |
</nav> |
| 95 |
</div> |
| 96 |
</header> |
| 97 |
|
| 98 |
<div class="yatra-login-page-content"> |
| 99 |
<?php echo do_shortcode('[yatra_login]'); ?> |
| 100 |
</div> |
| 101 |
|
| 102 |
<div class="yatra-login-page-footer"> |
| 103 |
<p>© <?php echo date('Y'); ?> <?php bloginfo('name'); ?>. <?php esc_html_e('All rights reserved.', 'yatra'); ?></p> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
</div> |
| 107 |
|
| 108 |
<?php wp_footer(); ?> |
| 109 |
</body> |
| 110 |
</html> |
| 111 |
|