| 1 |
<?php |
| 2 |
/** |
| 3 |
* Login Shortcode Template |
| 4 |
* |
| 5 |
* @package Yatra |
| 6 |
* @var array $atts Shortcode attributes |
| 7 |
* @var string $redirect_url Redirect URL after login |
| 8 |
*/ |
| 9 |
|
| 10 |
// Prevent direct access |
| 11 |
if (!defined('ABSPATH')) { |
| 12 |
exit; |
| 13 |
} |
| 14 |
|
| 15 |
// Get and validate variables |
| 16 |
$atts = get_query_var('yatra_login_atts', []); |
| 17 |
$redirect_url = get_query_var('yatra_redirect_url', home_url('/' . \Yatra\Services\SettingsService::getAccountBase())); |
| 18 |
|
| 19 |
// Generate unique form ID for this instance |
| 20 |
$form_id = 'yatra-login-form-' . uniqid(); |
| 21 |
|
| 22 |
// Security nonce |
| 23 |
$login_nonce = wp_create_nonce('yatra_login_nonce'); |
| 24 |
?> |
| 25 |
|
| 26 |
<div class="yatra-login-shortcode" data-form-id="<?php echo esc_attr($form_id); ?>"> |
| 27 |
<div class="yatra-login-container"> |
| 28 |
<div class="yatra-login-header"> |
| 29 |
<h2 class="yatra-login-title"><?php echo esc_html($atts['title']); ?></h2> |
| 30 |
<?php if (!empty($atts['subtitle'])): ?> |
| 31 |
<p class="yatra-login-subtitle"><?php echo esc_html($atts['subtitle']); ?></p> |
| 32 |
<?php endif; ?> |
| 33 |
</div> |
| 34 |
|
| 35 |
<div class="yatra-login-form-container"> |
| 36 |
<form class="yatra-login-form" id="<?php echo esc_attr($form_id); ?>" method="post" action="" data-ajax="true"> |
| 37 |
<?php wp_nonce_field('yatra_login_action', 'yatra_login_nonce', true, true); ?> |
| 38 |
<div class="yatra-form-group"> |
| 39 |
<label for="yatra-login-username" class="yatra-form-label"> |
| 40 |
<?php esc_html_e('Email or Username', 'yatra'); ?> |
| 41 |
</label> |
| 42 |
<input |
| 43 |
type="text" |
| 44 |
id="<?php echo esc_attr($form_id); ?>-username" |
| 45 |
name="log" |
| 46 |
class="yatra-form-input" |
| 47 |
placeholder="<?php esc_attr_e('Enter your email or username', 'yatra'); ?>" |
| 48 |
required |
| 49 |
autocomplete="username" |
| 50 |
maxlength="60" |
| 51 |
pattern="([a-zA-Z0-9._%+\\-]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,})|([a-zA-Z0-9._\\-]{3,20})" |
| 52 |
title="<?php esc_attr_e('Enter a valid email address or username', 'yatra'); ?>" |
| 53 |
> |
| 54 |
</div> |
| 55 |
|
| 56 |
<div class="yatra-form-group"> |
| 57 |
<label for="<?php echo esc_attr($form_id); ?>-password" class="yatra-form-label"> |
| 58 |
<?php esc_html_e('Password', 'yatra'); ?> |
| 59 |
</label> |
| 60 |
<div class="yatra-password-input-group"> |
| 61 |
<input |
| 62 |
type="password" |
| 63 |
id="<?php echo esc_attr($form_id); ?>-password" |
| 64 |
name="pwd" |
| 65 |
class="yatra-form-input" |
| 66 |
placeholder="<?php esc_attr_e('Enter your password', 'yatra'); ?>" |
| 67 |
required |
| 68 |
autocomplete="current-password" |
| 69 |
maxlength="72" |
| 70 |
title="<?php esc_attr_e('Enter your password', 'yatra'); ?>" |
| 71 |
> |
| 72 |
<button type="button" class="yatra-password-toggle" aria-label="<?php esc_attr_e('Toggle password visibility', 'yatra'); ?>" data-target="<?php echo esc_attr($form_id); ?>-password"> |
| 73 |
<?php echo yatra_svg_icon('eye', 'yatra-eye-icon'); ?> |
| 74 |
<?php echo yatra_svg_icon('eye-off', 'yatra-eye-off-icon'); ?> |
| 75 |
</button> |
| 76 |
</div> |
| 77 |
</div> |
| 78 |
|
| 79 |
<?php if ($atts['remember_me'] === 'yes'): ?> |
| 80 |
<div class="yatra-form-group yatra-form-checkbox"> |
| 81 |
<div class="yatra-checkbox-wrapper"> |
| 82 |
<label class="yatra-checkbox-label" for="<?php echo esc_attr($form_id); ?>-remember"> |
| 83 |
<input type="checkbox" name="rememberme" id="<?php echo esc_attr($form_id); ?>-remember" value="forever"> |
| 84 |
<span class="yatra-checkbox-custom"> |
| 85 |
<svg class="yatra-check-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" aria-hidden="true"> |
| 86 |
<path d="M20 6L9 17L4 12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
| 87 |
</svg> |
| 88 |
</span> |
| 89 |
<span class="yatra-checkbox-text"><?php esc_html_e('Remember me', 'yatra'); ?></span> |
| 90 |
</label> |
| 91 |
</div> |
| 92 |
</div> |
| 93 |
<?php endif; ?> |
| 94 |
|
| 95 |
<div class="yatra-form-actions"> |
| 96 |
<button type="submit" class="yatra-btn yatra-btn-primary yatra-btn-full" id="<?php echo esc_attr($form_id); ?>-submit"> |
| 97 |
<span class="yatra-btn-text"><?php esc_html_e('Login', 'yatra'); ?></span> |
| 98 |
<span class="yatra-btn-loading" style="display: none;"> |
| 99 |
<?php esc_html_e('Logging in...', 'yatra'); ?> |
| 100 |
</span> |
| 101 |
</button> |
| 102 |
</div> |
| 103 |
|
| 104 |
<input type="hidden" name="redirect_to" value="<?php echo esc_url($redirect_url); ?>"> |
| 105 |
<input type="hidden" name="form_id" value="<?php echo esc_attr($form_id); ?>"> |
| 106 |
</form> |
| 107 |
|
| 108 |
<?php if ($atts['show_forgot_password'] === 'yes'): ?> |
| 109 |
<div class="yatra-forgot-password"> |
| 110 |
<a href="<?php echo esc_url(wp_lostpassword_url()); ?>" class="yatra-link"> |
| 111 |
<?php esc_html_e('Forgot your password?', 'yatra'); ?> |
| 112 |
</a> |
| 113 |
</div> |
| 114 |
<?php endif; ?> |
| 115 |
|
| 116 |
<?php if ($atts['show_register'] === 'yes' && get_option('users_can_register')): ?> |
| 117 |
<div class="yatra-register-prompt"> |
| 118 |
<p> |
| 119 |
<?php esc_html_e("Don't have an account?", 'yatra'); ?> |
| 120 |
<a href="<?php echo esc_url(wp_registration_url()); ?>" class="yatra-link yatra-link-bold"> |
| 121 |
<?php esc_html_e('Sign up', 'yatra'); ?> |
| 122 |
</a> |
| 123 |
</p> |
| 124 |
</div> |
| 125 |
<?php endif; ?> |
| 126 |
</div> |
| 127 |
|
| 128 |
<div class="yatra-login-footer"> |
| 129 |
<div class="yatra-login-security"> |
| 130 |
<div class="yatra-security-icon"> |
| 131 |
<?php echo yatra_svg_icon('shield', 'yatra-security-icon-svg'); ?> |
| 132 |
</div> |
| 133 |
<p class="yatra-security-text"> |
| 134 |
<?php esc_html_e('Your login information is secure and encrypted.', 'yatra'); ?> |
| 135 |
</p> |
| 136 |
</div> |
| 137 |
</div> |
| 138 |
</div> |
| 139 |
</div> |
| 140 |
|