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

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