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

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