PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
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.16, at templates/partials/single-trip/hero.php

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