| @@ -108,10 +108,16 @@ | ||
| 108 | 108 | |
| 109 | 109 | // Set up WordPress hooks |
| 110 | 110 | $this->setupWordPressHooks(); |
| 111 | 111 | |
| 112 | - // Load text domain | |
| 113 | - $this->loadTextDomain(); | |
| 112 | + // Load text domain on `init` — calling load_(plugin_)textdomain before `init` | |
| 113 | + // triggers WP 6.7+ _doing_it_wrong notices (and Loco's "premature text domain" | |
| 114 | + // warning). Use priority 1 so it runs before code that translates on `init`. | |
| 115 | + if (did_action('init')) { | |
| 116 | + $this->loadTextDomain(); | |
| 117 | + } else { | |
| 118 | + add_action('init', [$this, 'loadTextDomain'], 1); | |
| 119 | + } | |
| 114 | 120 | |
| 115 | 121 | } catch (\Throwable $e) { |
| 116 | 122 | // Show admin notice if in admin area |
| 117 | 123 | if (is_admin()) { |
| @@ -247,12 +253,29 @@ | ||
| 247 | 253 | { |
| 248 | 254 | // Register activation/deactivation hooks |
| 249 | 255 | register_activation_hook(YATRA_PLUGIN_FILE, [$this, 'activate']); |
| 250 | 256 | register_deactivation_hook(YATRA_PLUGIN_FILE, [$this, 'deactivate']); |
| 251 | - | |
| 257 | + | |
| 252 | 258 | if (class_exists(\Yatra\Upgrades\FreeUpgradeRunner::class)) { |
| 253 | 259 | \Yatra\Upgrades\FreeUpgradeRunner::register(); |
| 254 | 260 | } |
| 261 | + | |
| 262 | + // On user registration, link any guest bookings made under | |
| 263 | + // the same email. Otherwise a customer who booked as guest | |
| 264 | + // first and then created an account would lose visibility of | |
| 265 | + // that earlier booking from My Account (the rows live with | |
| 266 | + // user_id=0 and the customer page filters by user_id). | |
| 267 | + if (class_exists('\\Yatra\\Services\\CustomerService')) { | |
| 268 | + add_action('user_register', static function ($user_id): void { | |
| 269 | + try { | |
| 270 | + (new \Yatra\Services\CustomerService())->linkGuestBookingsToUser((int) $user_id); | |
| 271 | + } catch (\Throwable $e) { | |
| 272 | + // Never block registration on a reconciliation | |
| 273 | + // failure. The booking remains accessible via the | |
| 274 | + // confirmation email link either way. | |
| 275 | + } | |
| 276 | + }, 20, 1); | |
| 277 | + } | |
| 255 | 278 | } |
| 256 | 279 | |
| 257 | 280 | /** |
| 258 | 281 | * Ensure database tables exist |
| @@ -347,10 +370,13 @@ | ||
| 347 | 370 | if (file_exists(WP_LANG_DIR . '/loco/plugins/yatra-' . $locale . '.mo')) { |
| 348 | 371 | load_textdomain('yatra', WP_LANG_DIR . '/loco/plugins/yatra-' . $locale . '.mo'); |
| 349 | 372 | } |
| 350 | 373 | |
| 351 | - // Load from plugin directory (fallback) | |
| 352 | - load_plugin_textdomain('yatra', false, 'i18n/languages'); | |
| 374 | + // Load from the plugin's own i18n/languages folder (fallback). The 3rd | |
| 375 | + // arg is relative to WP_PLUGIN_DIR, so it MUST include the plugin folder | |
| 376 | + // name — a bare 'i18n/languages' resolves to wp-content/plugins/i18n/ | |
| 377 | + // languages (which doesn't exist), so bundled translations never load. | |
| 378 | + load_plugin_textdomain('yatra', false, dirname(YATRA_PLUGIN_BASENAME) . '/i18n/languages'); | |
| 353 | 379 | } |
| 354 | 380 | |
| 355 | 381 | /** |
| 356 | 382 | * Get container instance |