| @@ -13,10 +13,64 @@ | ||
| 13 | 13 | $current_user = wp_get_current_user(); |
| 14 | 14 | |
| 15 | 15 | // If user is not logged in, redirect to login |
| 16 | 16 | if (!$current_user->ID) { |
| 17 | - $login_url = home_url('/login'); | |
| 18 | - wp_redirect($login_url); | |
| 17 | + // Render the login shortcode inline (no redirect, no dedicated /login endpoint required) | |
| 18 | + status_header(200); | |
| 19 | + nocache_headers(); | |
| 20 | + | |
| 21 | + // Ensure the login shortcode UI assets are loaded even though this page is not a WP post containing the shortcode. | |
| 22 | + wp_enqueue_style( | |
| 23 | + 'yatra-login-shortcode', | |
| 24 | + YATRA_PLUGIN_URL . 'assets/css/shortcodes/login-shortcode.css', | |
| 25 | + [], | |
| 26 | + YATRA_VERSION | |
| 27 | + ); | |
| 28 | + wp_enqueue_script( | |
| 29 | + 'yatra-login-shortcode', | |
| 30 | + YATRA_PLUGIN_URL . 'assets/js/login-shortcode.js', | |
| 31 | + ['jquery', 'wp-i18n'], | |
| 32 | + YATRA_VERSION, | |
| 33 | + true | |
| 34 | + ); | |
| 35 | + // Load JS translations so __() strings in login-shortcode.js are localized | |
| 36 | + // on this standalone account page (mirrors LoginShortcode::enqueueAssets). | |
| 37 | + if (function_exists('wp_set_script_translations')) { | |
| 38 | + wp_set_script_translations( | |
| 39 | + 'yatra-login-shortcode', | |
| 40 | + 'yatra', | |
| 41 | + YATRA_PLUGIN_PATH . 'i18n/languages' | |
| 42 | + ); | |
| 43 | + } | |
| 44 | + wp_localize_script('yatra-login-shortcode', 'yatra_ajax', [ | |
| 45 | + 'ajax_url' => admin_url('admin-ajax.php'), | |
| 46 | + 'nonce' => wp_create_nonce('yatra_login_nonce'), | |
| 47 | + 'rest_url' => esc_url_raw(rest_url('yatra/v1')), | |
| 48 | + 'rest_nonce' => wp_create_nonce('wp_rest'), | |
| 49 | + 'debug' => defined('WP_DEBUG') && WP_DEBUG, | |
| 50 | + 'strings' => [ | |
| 51 | + 'login_error' => __('Login failed. Please try again.', 'yatra'), | |
| 52 | + 'network_error' => __('Network error. Please check your connection.', 'yatra'), | |
| 53 | + 'validation_error' => __('Please fill in all required fields.', 'yatra'), | |
| 54 | + ], | |
| 55 | + ]); | |
| 56 | + ?> | |
| 57 | + <!DOCTYPE html> | |
| 58 | + <html <?php language_attributes(); ?>> | |
| 59 | + <head> | |
| 60 | + <meta charset="<?php bloginfo('charset'); ?>"> | |
| 61 | + <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| 62 | + <title><?php echo esc_html(get_bloginfo('name')) . ' - ' . esc_html__('Login', 'yatra'); ?></title> | |
| 63 | + <?php wp_head(); ?> | |
| 64 | + </head> | |
| 65 | + <body <?php body_class(); ?>> | |
| 66 | + <div class="yatra-login-page-wrapper"> | |
| 67 | + <?php echo do_shortcode('[yatra_login redirect_url="/' . esc_attr(\Yatra\Services\SettingsService::getAccountBase()) . '"]'); ?> | |
| 68 | + </div> | |
| 69 | + <?php wp_footer(); ?> | |
| 70 | + </body> | |
| 71 | + </html> | |
| 72 | + <?php | |
| 19 | 73 | exit; |
| 20 | 74 | } |
| 21 | 75 | |
| 22 | 76 | ?> |