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

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