| @@ -38,11 +38,13 @@ | ||
| 38 | 38 | |
| 39 | 39 | return; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - // Check if we're on a single trip page | |
| 42 | + // Check if we're on a single trip page (use query var, not global $trip — | |
| 43 | + // the booking template also assigns $trip at global scope, which would | |
| 44 | + // otherwise leak this menu into the booking page admin bar). | |
| 43 | 45 | global $trip; |
| 44 | - if (!empty($trip) && !empty($trip->id)) { | |
| 46 | + if (function_exists('yatra_is_single_trip') && yatra_is_single_trip() && !empty($trip) && !empty($trip->id)) { | |
| 45 | 47 | // Build the edit URL for the trip |
| 46 | 48 | $edit_url = admin_url('admin.php?page=yatra&subpage=trips&action=edit&id=' . (int) $trip->id); |
| 47 | 49 | |
| 48 | 50 | // Add the Edit Trip node |
| @@ -94,8 +96,9 @@ | ||
| 94 | 96 | 'id' => $node_id, |
| 95 | 97 | 'title' => $title, |
| 96 | 98 | 'href' => $edit_url, |
| 97 | 99 | 'meta' => [ |
| 100 | + /* translators: %s: object type label (e.g. trip, booking). */ | |
| 98 | 101 | 'title' => sprintf(__('Edit this %s in Yatra admin', 'yatra'), $type), |
| 99 | 102 | ], |
| 100 | 103 | ]); |
| 101 | 104 | } |