PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.8
Yatra – Travel Booking & Tour Operator Software v3.0.2.8
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 / templates / single-trip.php

single-trip.php in Yatra – Travel Booking & Tour Operator Software 3.0.2.8, at templates/single-trip.php

204 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Single Trip Template - Clean Version
4 *
5 * Industry-standard trip single page design following Laravel patterns.
6 * Uses global $trip object (similar to WordPress $post).
7 * All data comes from SingleTripController - no business logic in template.
8 *
9 * @package Yatra
10 * @global object $trip Trip data object (set by AppServiceProvider)
11 */
12
13 // Prevent direct access
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17
18 // Access global $trip object (similar to WordPress $post)
19 global $trip;
20
21 // Bail if no trip data - return proper 404
22 if (!$trip) {
23 global $wp_query;
24 $wp_query->set_404();
25 status_header(404);
26 get_template_part(404);
27 exit;
28 }
29
30 // Document title and meta tags are handled by Yatra\Managers\SEOManager (document_title + wp_head).
31
32 yatra_get_header();
33
34 // Calculate pricing data using helper functions
35 $pricing_data = yatra_single_trip_calculate_base_price($trip);
36 $base_price = $pricing_data['base_price'];
37 $has_availability = $pricing_data['has_availability'];
38 $has_traveler_pricing = $pricing_data['has_traveler_pricing'];
39 $pricing_type = $pricing_data['pricing_type'];
40
41 // Get group discounts data
42 $group_discounts = yatra_single_trip_get_group_discounts($trip->id);
43
44 // Prepare variables for templates
45 $destinations = isset($trip->destinations) ? $trip->destinations : [];
46 $activities = isset($trip->activities) ? $trip->activities : [];
47 $trip_categories = isset($trip->trip_categories) ? $trip->trip_categories : [];
48
49 // Set up global itinerary gallery data for modal (simple URL array like hero)
50 global $yatra_itinerary_gallery_images;
51 $yatra_itinerary_gallery_images = [];
52 $itinerary_days = $trip->getItineraryDays();
53 if (!empty($itinerary_days)) {
54 foreach ($itinerary_days as $day) {
55 if (!empty($day['entries'])) {
56 foreach ($day['entries'] as $entry) {
57 // Add gallery images
58 if (!empty($entry['gallery']) && is_array($entry['gallery'])) {
59 foreach ($entry['gallery'] as $media) {
60 // Always use full-size URL for gallery popup
61 $yatra_itinerary_gallery_images[] = $media['url'] ?? '';
62 }
63 }
64 // Add video thumbnail
65 if (!empty($entry['video_url'])) {
66 $video_url = esc_url($entry['video_url']);
67 $video_id = '';
68 $thumbnail_url = '';
69
70 // Extract video ID and thumbnail
71 if (strpos($video_url, 'youtube.com') !== false || strpos($video_url, 'youtu.be') !== false) {
72 // YouTube thumbnail extraction
73 preg_match('/(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([^&\n?#]+)/', $video_url, $matches);
74 $video_id = $matches[1] ?? '';
75 $thumbnail_url = "https://img.youtube.com/vi/{$video_id}/maxresdefault.jpg";
76 } elseif (strpos($video_url, 'vimeo.com') !== false) {
77 // Vimeo thumbnail extraction
78 preg_match('#vimeo\.com\/.*?(\d+)#', $video_url, $matches);
79 $video_id = $matches[1] ?? '';
80 if ($video_id) {
81 // Get Vimeo thumbnail via oEmbed API
82 $oembed_url = "https://vimeo.com/api/oembed.json?url=" . urlencode($video_url);
83 $response = wp_remote_get($oembed_url);
84 if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200) {
85 $body = wp_remote_retrieve_body($response);
86 $data = json_decode($body, true);
87 if ($data && isset($data['thumbnail_url'])) {
88 $thumbnail_url = $data['thumbnail_url'];
89 }
90 }
91
92 // Fallback if API fails
93 if (empty($thumbnail_url)) {
94 $thumbnail_url = 'https://i.vimeocdn.com/video/' . $video_id . '_640.jpg';
95 }
96 }
97 }
98
99 if ($thumbnail_url) {
100 $yatra_itinerary_gallery_images[] = $thumbnail_url;
101 }
102 }
103 }
104 }
105 }
106 }
107 ?>
108
109 <!-- Flatpickr CSS -->
110 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
111 <!-- Flatpickr JS -->
112 <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
113
114 <!-- Trip pricing/availability for JS: merged in wp_localize_script (yatra-trip) so apiUrl/nonce/wishlist are not overwritten. -->
115 <script>
116 window.yatraVars = {
117 nonce: '<?php echo wp_create_nonce('wp_rest'); ?>'
118 };
119 </script>
120
121 <!-- Downloads JavaScript -->
122 <?php
123 $downloads = $trip->getDownloadableItems();
124 if (!empty($downloads)):
125 ?>
126 <script src="<?php echo esc_url(plugin_dir_url(dirname(__FILE__)) . 'assets/js/api-helper.js'); ?>"></script>
127 <script src="<?php echo esc_url(plugin_dir_url(dirname(__FILE__)) . 'assets/js/downloads-list.js'); ?>"></script>
128 <?php endif; ?>
129
130 <div class="yatra-single-trip">
131
132 <!-- Hero Section -->
133 <?php yatra_get_template('partials/single-trip/hero', ['trip' => $trip, 'base_price' => $base_price]); ?>
134
135 <!-- Category, Activity, Destination Tags -->
136 <?php if (!empty($trip_categories) || !empty($activities) || !empty($destinations)): ?>
137 <?php yatra_get_template('partials/single-trip/tags', ['trip' => $trip, 'trip_categories' => $trip_categories, 'activities' => $activities, 'destinations' => $destinations]); ?>
138 <?php endif; ?>
139
140 <!-- Quick Facts Bar -->
141 <?php yatra_get_template('partials/single-trip/quick-facts', ['trip' => $trip]); ?>
142
143 <!-- Trip Attributes -->
144 <?php
145 $attributes = $trip->getAttributes();
146 if (!empty($attributes)):
147 ?>
148 <?php yatra_get_template('partials/single-trip/trip-attributes', ['trip' => $trip]); ?>
149 <?php endif; ?>
150
151 <!-- Sticky Navigation Bar -->
152 <?php yatra_get_template('partials/single-trip/sticky-nav', ['trip' => $trip, 'base_price' => $base_price, 'has_availability' => $has_availability, 'has_traveler_pricing' => $has_traveler_pricing]); ?>
153
154 <!-- Hero Gallery Modal -->
155 <?php yatra_get_template('partials/single-trip/gallery-modal', ['trip' => $trip]); ?>
156
157 <!-- Itinerary Gallery Modal -->
158 <?php yatra_get_template('partials/single-trip/itinerary-gallery-modal', ['trip' => $trip]); ?>
159
160 <!-- Main Container -->
161 <div class="yatra-trip-container">
162 <!-- Main Content -->
163 <div class="yatra-trip-main">
164 <!-- Dynamic Frontend Tabs -->
165 <?php \Yatra\Controllers\SingleTripController::renderFrontendTabs($trip); ?>
166 </div>
167
168 <!-- Sidebar - Booking Card -->
169 <?php yatra_get_template('partials/single-trip/content-sidebar', ['trip' => $trip, 'has_availability' => $has_availability, 'has_traveler_pricing' => $has_traveler_pricing, 'base_price' => $base_price, 'pricing_type' => $pricing_type]); ?>
170 </div>
171
172 <!-- Group Discount Section -->
173 <?php if ($group_discounts['has_group_discounts'] && !empty($group_discounts['group_discounts_data'])): ?>
174 <?php yatra_get_template('partials/single-trip/group-discounts', ['trip' => $trip, 'group_discounts_data' => $group_discounts['group_discounts_data']]); ?>
175 <?php endif; ?>
176
177 <!-- Reviews Section - Full Width (before similar trips for social proof) -->
178 <?php if (yatra_reviews_enabled()): ?>
179 <?php yatra_get_template('partials/single-trip/reviews', ['trip' => $trip]); ?>
180 <?php endif; ?>
181
182 <!-- Similar Trips Section -->
183 <?php
184 $similar_trips = $trip->getSimilarTrips();
185 if (!empty($similar_trips)):
186 ?>
187 <?php yatra_get_template('partials/single-trip/similar-trips', ['trip' => $trip]); ?>
188 <?php endif; ?>
189 </div>
190
191 <!-- Mobile Sticky Sidebar -->
192 <?php yatra_get_template('partials/single-trip/sticky-sidebar', [
193 'trip' => $trip,
194 'has_availability' => $has_availability,
195 'has_traveler_pricing' => $has_traveler_pricing,
196 'base_price' => $base_price,
197 'pricing_type' => $pricing_type
198 ]); ?>
199
200 <!-- Enquiry Modal -->
201 <?php yatra_get_template('partials/single-trip/enquiry-modal', ['trip' => $trip]); ?>
202
203 <?php yatra_get_footer(); ?>
204