PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.15
Yatra – Travel Booking & Tour Operator Software v3.0.15
3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 All 83 releases
yatra / app / Hooks / MigrationAdminNoticeHooks.php

MigrationAdminNoticeHooks.php in Yatra – Travel Booking & Tour Operator Software 3.0.15, at app/Hooks/MigrationAdminNoticeHooks.php

66 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Yatra\Hooks;
6
7 use Yatra\Migration\MigrationProgress;
8 use Yatra\Migration\ProMigrationReadiness;
9
10 /**
11 * WordPress admin notice when legacy Yatra 2.x / Pro 2.x data exists and migration is incomplete.
12 * Intentionally not dismissible so upgrades are not missed; use Tools → Migration when done.
13 */
14 class MigrationAdminNoticeHooks
15 {
16 public static function init(): void
17 {
18 if (!is_admin()) {
19 return;
20 }
21
22 add_action('admin_notices', [self::class, 'renderNotice'], 20);
23 }
24
25 public static function renderNotice(): void
26 {
27 if (!current_user_can('manage_options')) {
28 return;
29 }
30
31 if (!class_exists(MigrationProgress::class)) {
32 return;
33 }
34
35 $migration = new MigrationProgress();
36 if (!$migration->legacyMigrationNeedsAttention()) {
37 return;
38 }
39
40 $toolsUrl = admin_url('admin.php?page=yatra&subpage=tools&tools_tab=migration');
41
42 echo '<div class="notice notice-warning yatra-legacy-migration-notice"><p>';
43 echo '<strong>' . esc_html__('Yatra: Data migration required', 'yatra') . '</strong> — ';
44 echo esc_html__(
45 'Legacy Yatra 2.x or Yatra Pro 2.x data was detected. Open Tools → Migration to move trips, bookings, and settings into Yatra 3.x.',
46 'yatra'
47 );
48 echo '</p>';
49
50 $pro = ProMigrationReadiness::getState();
51 if (!$pro['ready'] && $pro['warning_message'] !== '') {
52 echo '<p><strong>' . esc_html__('Yatra Pro:', 'yatra') . '</strong> ';
53 echo esc_html($pro['warning_message']);
54 echo '</p>';
55 }
56
57 echo '<p>';
58 printf(
59 '<a class="button button-primary" href="%s">%s</a>',
60 esc_url($toolsUrl),
61 esc_html__('Open Tools → Migration', 'yatra')
62 );
63 echo '</p></div>';
64 }
65 }
66