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

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