PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.11
Yatra – Travel Booking & Tour Operator Software v3.0.11
3.0.16 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 All 84 releases
yatra / templates / partials / single-trip / hero.php

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

338 lines 19.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5 $booking_disabled = isset($trip) && method_exists($trip, 'isBookingDisabled') && $trip->isBookingDisabled();
6 $yatra_hero_dp_flags = function_exists('yatra_get_dynamic_pricing_display_flags') ? yatra_get_dynamic_pricing_display_flags() : [
7 'show_savings_badge' => true,
8 ];
9 ?>
10 <div class="yatra-trip-hero-new" itemscope itemtype="https://schema.org/TouristTrip">
11 <div class="yatra-hero-header">
12 <nav class="yatra-hero-breadcrumb" aria-label="<?php echo esc_attr__('Breadcrumb', 'yatra'); ?>" itemscope itemtype="https://schema.org/BreadcrumbList">
13 <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
14 <a href="<?php echo esc_url(home_url('/')); ?>" itemprop="item">
15 <span itemprop="name"><?php echo esc_html__('Home', 'yatra'); ?></span>
16 </a>
17 <meta itemprop="position" content="1" />
18 </span>
19 <span class="yatra-hero-breadcrumb-separator">›</span>
20 <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
21 <a href="<?php echo esc_url(home_url('/' . \Yatra\Services\SettingsService::getTripBase() . '/')); ?>" itemprop="item">
22 <span itemprop="name"><?php echo esc_html__('Trips', 'yatra'); ?></span>
23 </a>
24 <meta itemprop="position" content="2" />
25 </span>
26 <span class="yatra-hero-breadcrumb-separator">›</span>
27 <span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
28 <span class="yatra-hero-breadcrumb-current" itemprop="name"><?php echo esc_html($trip->getTitle()); ?></span>
29 <meta itemprop="position" content="3" />
30 </span>
31 </nav>
32 <h1 class="yatra-trip-hero-title-new" itemprop="name"><?php echo esc_html($trip->getTitle()); ?></h1>
33 <div class="yatra-hero-meta">
34 <?php // Rating is expressed via JSON-LD (Product.aggregateRating) in SEOService — no microdata here, which Google rejected on a TouristTrip parent. ?>
35 <div class="yatra-hero-rating">
36 <?php if ($trip->getAverageRating() > 0 || $trip->getReviewCount() > 0): ?>
37 <?php
38 $hero_avg = (float) $trip->getAverageRating();
39 $hero_full = (int) floor($hero_avg);
40 $hero_half = ($hero_avg - $hero_full) >= 0.3;
41 ?>
42 <div class="yatra-rating-stars">
43 <?php for ($i = 1; $i <= 5; $i++) : ?>
44 <?php
45 if ($i <= $hero_full) {
46 $hero_star_class = 'yatra-star filled';
47 } elseif ($i === $hero_full + 1 && $hero_half) {
48 $hero_star_class = 'yatra-star half';
49 } else {
50 $hero_star_class = 'yatra-star';
51 }
52 ?>
53 <span class="<?php echo esc_attr($hero_star_class); ?>" aria-label="<?php echo esc_attr(sprintf(
54 /* translators: %d: star rating number (1-5). */
55 _n('%d star', '%d stars', $i, 'yatra'),
56 $i
57 )); ?>">�
58 </span>
59 <?php endfor; ?>
60 </div>
61 <span class="yatra-rating-number"><?php echo esc_html(number_format($trip->getAverageRating(), 1)); ?></span>
62 <span class="yatra-rating-text">
63 <span><?php echo esc_html($trip->getReviewCount()); ?></span>
64 <?php echo esc_html(_n('Review', 'Reviews', $trip->getReviewCount(), 'yatra')); ?>
65 </span>
66 <?php else: ?>
67 <div class="yatra-rating-stars yatra-no-rating">
68 <?php for ($i = 1; $i <= 5; $i++): ?>
69 <span class="yatra-star" aria-label="<?php echo esc_attr(sprintf(
70 /* translators: %d: star rating number (1-5). */
71 _n('%d star', '%d stars', $i, 'yatra'),
72 $i
73 )); ?>">�
74 </span>
75 <?php endfor; ?>
76 </div>
77 <span class="yatra-rating-text yatra-no-reviews"><?php echo esc_html__('No reviews yet', 'yatra'); ?></span>
78 <?php endif; ?>
79 </div>
80 <?php if (!empty($trip->getStartingLocation())): ?>
81 <div class="yatra-hero-location" itemprop="location" itemscope itemtype="https://schema.org/Place">
82 <?php echo yatra_svg_icon('map-pin', 'yatra-icon-sm'); ?>
83 <span itemprop="name"><?php echo esc_html($trip->getStartingLocation()); ?></span>
84 </div>
85 <?php endif; ?>
86 <?php if (!empty($trip->getDurationDays())): ?>
87 <div class="yatra-hero-duration" itemprop="duration">
88 <?php echo yatra_svg_icon('clock', 'yatra-icon-sm'); ?>
89 <span>
90 <?php
91 if (!empty($trip->getDurationNights()) && $trip->getDurationNights() > 0) {
92 echo esc_html(sprintf(
93 /* translators: 1: number of days, 2: number of nights. */
94 _n('%1$d day %2$d night', '%1$d days %2$d nights', $trip->getDurationDays(), 'yatra'),
95 $trip->getDurationDays(),
96 $trip->getDurationNights()
97 ));
98 } else {
99 echo esc_html(sprintf(
100 /* translators: %d: number of days. */
101 _n('%d day', '%d days', $trip->getDurationDays(), 'yatra'),
102 $trip->getDurationDays()
103 ));
104 }
105 ?>
106 </span>
107 </div>
108 <?php endif; ?>
109 <?php if (!empty($trip->getSeasonalAvailability())): ?>
110 <div class="yatra-hero-season">
111 <?php echo yatra_svg_icon('calendar', 'yatra-icon-sm'); ?>
112 <span><?php echo esc_html($trip->getSeasonalAvailability()); ?></span>
113 </div>
114 <?php endif; ?>
115 </div>
116 </div>
117
118 <?php
119 // Determine hero images
120 // 1. If featured image is set, use it as main image
121 // 2. If no featured image, use first gallery image as main
122 // 3. Side images are gallery images (up to 3)
123
124 // Gallery images are already URLs from SingleTripController
125 $gallery_image_urls = isset($trip->gallery_images) && is_array($trip->gallery_images) ? $trip->gallery_images : [];
126
127 $has_featured = !empty($trip->featured_image_url);
128
129 // Main image: featured image OR first gallery image
130 $main_image_url = '';
131 if ($has_featured) {
132 $main_image_url = $trip->featured_image_url;
133 // If featured is set, side images are first 3 gallery images
134 $side_images = array_slice($gallery_image_urls, 0, 3);
135 } else {
136 // No featured image - use first gallery as main
137 $main_image_url = !empty($gallery_image_urls[0]) ? $gallery_image_urls[0] : '';
138 // Side images start from index 1
139 $side_images = array_slice($gallery_image_urls, 1, 3);
140 }
141
142 // Create combined gallery array for modal (featured + gallery images)
143 $all_gallery_images = [];
144 if ($has_featured) {
145 $all_gallery_images[] = $main_image_url;
146 }
147 $all_gallery_images = array_merge($all_gallery_images, $gallery_image_urls);
148
149 // Set global variable for content-gallery template
150 global $yatra_hero_gallery_images;
151 $yatra_hero_gallery_images = $all_gallery_images;
152
153 $total_images = count($all_gallery_images);
154 ?>
155 <div class="yatra-hero-images">
156 <div class="yatra-hero-main-image" itemprop="image" itemscope itemtype="https://schema.org/ImageObject">
157 <?php if (isset($trip->discount_percentage) && $trip->discount_percentage > 0 && !empty($yatra_hero_dp_flags['show_savings_badge'])): ?>
158 <div class="yatra-hero-discount-tag" itemprop="offers" itemscope itemtype="https://schema.org/Offer">
159 <?php echo esc_html__('SAVE UP TO', 'yatra'); ?> <?php echo esc_html($trip->discount_percentage); ?>%
160 <meta itemprop="discount" content="<?php echo esc_attr($trip->discount_percentage); ?>">
161 <meta itemprop="discountCurrency" content="<?php echo esc_attr(\Yatra\Services\SettingsService::getCurrency()); ?>">
162 </div>
163 <?php endif; ?>
164
165 <!-- Media Badges -->
166 <div class="yatra-hero-media-badges">
167 <?php
168 $image_count = count($all_gallery_images);
169 $video_count = count($trip->videos ?? []);
170 $youtube_count = count($trip->youtube_videos ?? []);
171 $tour_count = count($trip->virtual_tours ?? []);
172 $doc_count = count($trip->documents ?? []);
173
174 if ($image_count > 0): ?>
175 <span class="yatra-media-badge yatra-media-badge-image">
176 <?php echo yatra_svg_icon('camera', 'yatra-media-badge-icon'); ?>
177 <span class="yatra-media-badge-count"><?php echo esc_html($image_count); ?></span>
178 </span>
179 <?php endif; ?>
180
181 <?php if ($video_count > 0): ?>
182 <span class="yatra-media-badge yatra-media-badge-video">
183 <?php echo yatra_svg_icon('play', 'yatra-media-badge-icon'); ?>
184 <span class="yatra-media-badge-count"><?php echo esc_html($video_count); ?></span>
185 </span>
186 <?php endif; ?>
187
188 <?php if ($youtube_count > 0): ?>
189 <span class="yatra-media-badge yatra-media-badge-youtube">
190 <?php echo yatra_svg_icon('video', 'yatra-media-badge-icon'); ?>
191 <span class="yatra-media-badge-count"><?php echo esc_html($youtube_count); ?></span>
192 </span>
193 <?php endif; ?>
194
195 <?php if ($tour_count > 0): ?>
196 <span class="yatra-media-badge yatra-media-badge-tour">
197 <?php echo yatra_svg_icon('globe', 'yatra-media-badge-icon'); ?>
198 <span class="yatra-media-badge-count"><?php echo esc_html($tour_count); ?></span>
199 </span>
200 <?php endif; ?>
201
202 <?php if ($doc_count > 0): ?>
203 <span class="yatra-media-badge yatra-media-badge-document">
204 <?php echo yatra_svg_icon('file-text', 'yatra-media-badge-icon'); ?>
205 <span class="yatra-media-badge-count"><?php echo esc_html($doc_count); ?></span>
206 </span>
207 <?php endif; ?>
208 </div>
209
210 <?php if (!empty($main_image_url)): ?>
211 <a href="#" class="yatra-hero-main-img-link" data-gallery="hero-gallery" data-image-index="0">
212 <img src="<?php echo esc_url($main_image_url); ?>"
213 alt="<?php echo esc_attr(sprintf(
214 /* translators: %s: trip title. */
215 __('Main image for %s', 'yatra'),
216 $trip->getTitle()
217 )); ?>"
218 title="<?php echo esc_attr($trip->getTitle()); ?>"
219 itemprop="url" content="<?php echo esc_url($main_image_url); ?>"
220 data-yatra-src="<?php echo esc_url($main_image_url); ?>"
221 data-no-lazy="1"
222 class="yatra-hero-main-img">
223 </a>
224 <meta itemprop="contentUrl" content="<?php echo esc_url($main_image_url); ?>">
225 <meta itemprop="encodingFormat" content="image/jpeg">
226 <meta itemprop="width" content="1200">
227 <meta itemprop="height" content="630">
228 <?php else: ?>
229 <img src="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>"
230 alt="<?php echo esc_attr(sprintf(
231 /* translators: %s: trip title. */
232 __('Placeholder image for %s', 'yatra'),
233 $trip->getTitle()
234 )); ?>"
235 title="<?php echo esc_attr($trip->getTitle()); ?>"
236 itemprop="url" content="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>"
237 class="yatra-hero-main-img">
238 <meta itemprop="contentUrl" content="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>">
239 <meta itemprop="encodingFormat" content="image/svg+xml">
240 <?php endif; ?>
241
242 <!-- Quick Media Switcher -->
243 <div class="yatra-hero-media-switcher">
244 <button type="button" class="yatra-media-switcher-btn yatra-media-switcher-active" data-media="images">
245 <?php echo yatra_svg_icon('camera', 'yatra-media-switcher-icon'); ?>
246 <span><?php echo esc_html__('Images', 'yatra'); ?></span>
247 </button>
248 <?php if ($video_count > 0): ?>
249 <button type="button" class="yatra-media-switcher-btn" data-media="videos">
250 <?php echo yatra_svg_icon('play', 'yatra-media-switcher-icon'); ?>
251 <span><?php echo esc_html__('Videos', 'yatra'); ?></span>
252 </button>
253 <?php endif; ?>
254 <?php if ($youtube_count > 0): ?>
255 <button type="button" class="yatra-media-switcher-btn" data-media="youtube">
256 <?php echo yatra_svg_icon('video', 'yatra-media-switcher-icon'); ?>
257 <span><?php echo esc_html__('Video', 'yatra'); ?></span>
258 </button>
259 <?php endif; ?>
260 <?php if ($tour_count > 0): ?>
261 <button type="button" class="yatra-media-switcher-btn" data-media="tours">
262 <?php echo yatra_svg_icon('globe', 'yatra-media-switcher-icon'); ?>
263 <span><?php echo esc_html__('360°', 'yatra'); ?></span>
264 </button>
265 <?php endif; ?>
266 <?php if ($doc_count > 0): ?>
267 <button type="button" class="yatra-media-switcher-btn" data-media="documents">
268 <?php echo yatra_svg_icon('file-text', 'yatra-media-switcher-icon'); ?>
269 <span><?php echo esc_html__('Documents', 'yatra'); ?></span>
270 </button>
271 <?php endif; ?>
272 </div>
273
274 <!-- Media Data for JavaScript -->
275 <script type="application/json" id="yatra-hero-media-data">
276 <?php echo json_encode([
277 'images' => $all_gallery_images,
278 'videos' => $trip->videos ?? [],
279 'youtube_videos' => $trip->youtube_videos ?? [],
280 'virtual_tours' => $trip->virtual_tours ?? [],
281 'documents' => $trip->documents ?? []
282 ]); ?>
283 </script>
284
285 <?php if (!$booking_disabled): ?>
286 <!-- Book Now Button on Right Side of Main Image -->
287 <div class="yatra-hero-book-now-container">
288 <a href="#booking" id="yatra-hero-book-now-btn" class="yatra-hero-book-now-btn">
289 <svg width="18" height="18" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
290 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
291 d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
292 </svg>
293 <?php echo esc_html__('Book Now', 'yatra'); ?>
294 - <?php echo esc_html(yatra_format_price($base_price)); ?>
295 </a>
296 </div>
297 <?php endif; ?>
298 </div>
299 <div class="yatra-hero-side-images">
300 <?php if (!empty($side_images)): ?>
301 <?php foreach ($side_images as $index => $img_url): ?>
302 <div class="yatra-side-image-item">
303 <img src="<?php echo esc_url($img_url); ?>"
304 alt="<?php echo esc_attr__('Gallery Image', 'yatra'); ?>"
305 data-yatra-src="<?php echo esc_url($img_url); ?>"
306 data-no-lazy="1">
307 <?php if ($index === 0 && function_exists('yatra_wishlist_enabled') && yatra_wishlist_enabled() && !empty($trip->id)) : ?>
308 <button type="button" class="yatra-favorite-btn"
309 data-trip-id="<?php echo esc_attr((string) $trip->id); ?>"
310 title="<?php esc_attr_e('Save to wishlist', 'yatra'); ?>"
311 aria-label="<?php echo esc_attr__('Save to wishlist', 'yatra'); ?>">
312 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
313 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>
314 </svg>
315 </button>
316 <?php endif; ?>
317 <?php if ($index === count($side_images) - 1 && $total_images > 4): ?>
318 <button type="button" class="yatra-view-all-photos-btn yatra-gallery-play-btn"
319 data-gallery="hero-gallery">
320 <?php echo yatra_svg_icon('camera', 'yatra-icon-sm'); ?>
321 <?php echo sprintf(
322 /* translators: %d: total number of photos in the trip gallery. */
323 esc_html__('View all %d photos', 'yatra'),
324 $total_images
325 ); ?>
326 </button>
327 <?php endif; ?>
328 </div>
329 <?php endforeach; ?>
330 <?php else: ?>
331 <div class="yatra-side-image-item">
332 <img src="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>"
333 alt="<?php echo esc_attr__('Gallery Image', 'yatra'); ?>">
334 </div>
335 <?php endif; ?>
336 </div>
337 </div>
338 </div>