| @@ -46,33 +46,24 @@ | ||
| 46 | 46 | $this->sendErrorResponse(403, __('Security check failed', 'yatra')); |
| 47 | 47 | return false; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - // Load the login page template with error handling | |
| 51 | - $template_path = YATRA_PLUGIN_PATH . 'templates/login-page.php'; | |
| 52 | - | |
| 53 | - if (!file_exists($template_path)) { | |
| 50 | + // Configure $wp_query + virtual WP_Post (covers FSE block-theme rendering). | |
| 51 | + $this->setupPageEnvironment('singular', [ | |
| 52 | + 'title' => __('Login', 'yatra'), | |
| 53 | + 'post_type' => 'page', | |
| 54 | + 'post_name' => 'login', | |
| 55 | + ]); | |
| 54 | 56 | |
| 55 | - | |
| 57 | + // Security headers | |
| 58 | + $this->setSecurityHeaders(); | |
| 59 | + | |
| 60 | + if (!$this->selectTemplate('login-page', null, 'login')) { | |
| 56 | 61 | // Fallback to shortcode if template is missing |
| 57 | 62 | return $this->handleFallback(); |
| 58 | 63 | } |
| 59 | 64 | |
| 60 | - try { | |
| 61 | - // Set up WordPress environment | |
| 62 | - $this->setupWordPressEnvironment(); | |
| 63 | - | |
| 64 | - // Security headers | |
| 65 | - $this->setSecurityHeaders(); | |
| 66 | - | |
| 67 | - // Include the template | |
| 68 | - include $template_path; | |
| 69 | - exit; | |
| 70 | - | |
| 71 | - } catch (\Exception $e) { | |
| 72 | - | |
| 73 | - return $this->handleFallback(); | |
| 74 | - } | |
| 65 | + return true; | |
| 75 | 66 | } |
| 76 | 67 | |
| 77 | 68 | /** |
| 78 | 69 | * Get the route pattern for this handler |
| @@ -105,37 +96,8 @@ | ||
| 105 | 96 | } |
| 106 | 97 | |
| 107 | 98 | set_transient($transient_key, $attempts + 1, 5 * MINUTE_IN_SECONDS); |
| 108 | 99 | return true; |
| 109 | - } | |
| 110 | - | |
| 111 | - /** | |
| 112 | - * Setup WordPress environment for the login page | |
| 113 | - */ | |
| 114 | - private function setupWordPressEnvironment(): void | |
| 115 | - { | |
| 116 | - global $wp_query; | |
| 117 | - | |
| 118 | - // Prevent 404 | |
| 119 | - $wp_query->is_404 = false; | |
| 120 | - $wp_query->is_page = true; | |
| 121 | - $wp_query->is_singular = true; | |
| 122 | - | |
| 123 | - // Set proper headers | |
| 124 | - status_header(200); | |
| 125 | - | |
| 126 | - // Set page title and metadata | |
| 127 | - $wp_query->set('page_title', __('Login', 'yatra')); | |
| 128 | - $wp_query->set('meta_description', __('Login to your Yatra account', 'yatra')); | |
| 129 | - | |
| 130 | - // Set up post data for compatibility | |
| 131 | - $wp_query->set('post', (object) [ | |
| 132 | - 'ID' => 0, | |
| 133 | - 'post_title' => __('Login', 'yatra'), | |
| 134 | - 'post_content' => '', | |
| 135 | - 'post_type' => 'page', | |
| 136 | - 'post_status' => 'publish' | |
| 137 | - ]); | |
| 138 | 100 | } |
| 139 | 101 | |
| 140 | 102 | /** |
| 141 | 103 | * Set security headers |