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 / single-destination.php

single-destination.php in Yatra – Travel Booking & Tour Operator Software 3.0.2.9, at templates/single-destination.php

296 lines 16.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Single Destination Template
4 *
5 * Displays individual destination page with associated trips
6 * Uses global $destination object (similar to WordPress $post)
7 *
8 * @package Yatra
9 * @global object $destination Destination data object
10 */
11
12 // Prevent direct access
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 // Access global $destination object
18 global $destination;
19
20 // Debug: Check what data we have
21 if (defined('WP_DEBUG') && WP_DEBUG) {
22 }
23
24 // Bail if no destination data - return proper 404
25 if (!$destination) {
26 global $wp_query;
27 $wp_query->set_404();
28 status_header(404);
29 get_template_part(404);
30 exit;
31 }
32
33 // Set up page title
34 add_filter('wp_title', function($title) {
35 global $destination;
36 return esc_html($destination->name) . ' - ' . get_bloginfo('name');
37 }, 10, 1);
38
39 yatra_get_header();
40 ?>
41
42 <div class="yatra-single-destination" style="max-width: 1200px; margin: 0 auto; padding: 40px 20px;">
43 <!-- Destination Header -->
44 <div class="destination-header" style="margin-bottom: 40px;">
45 <h1 style="font-size: 2.5rem; margin-bottom: 16px; color: #1f2937;">
46 <?php echo esc_html($destination->name); ?>
47 </h1>
48
49 <?php if (!empty($destination->description)): ?>
50 <div class="destination-description" style="font-size: 1.125rem; color: #6b7280; line-height: 1.6;">
51 <?php echo wp_kses_post($destination->description); ?>
52 </div>
53 <?php endif; ?>
54 </div>
55
56 <!-- Destination Icon/Image -->
57 <?php if (!empty($destination->icon)): ?>
58 <div class="destination-media" style="margin-bottom: 40px;">
59 <?php
60 $icon = maybe_unserialize($destination->icon);
61 $image_url = '';
62 $icon_class = '';
63
64 if (is_array($icon)) {
65 $type = $icon['type'] ?? $icon[0] ?? '';
66 $value = $icon['value'] ?? $icon[1] ?? '';
67
68 if ($type === 'image' && !empty($value)) {
69 if (is_numeric($value)) {
70 $maybe_url = wp_get_attachment_image_url((int) $value, 'large');
71 if (!empty($maybe_url)) {
72 $image_url = $maybe_url;
73 }
74 } elseif (is_string($value) && filter_var($value, FILTER_VALIDATE_URL)) {
75 $image_url = $value;
76 }
77 } elseif ($type === 'icon' && !empty($value) && is_string($value)) {
78 $icon_class = $value;
79 }
80 }
81 ?>
82
83 <?php if (!empty($image_url)): ?>
84 <div class="destination-image" style="width: 100%; max-width: 600px; margin: 0 auto;">
85 <img src="<?php echo esc_url($image_url); ?>"
86 alt="<?php echo esc_attr($destination->name); ?>"
87 style="width: 100%; height: auto; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.1);">
88 </div>
89 <?php elseif (!empty($icon_class)): ?>
90 <div class="destination-icon" style="text-align: center; padding: 60px; background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%); border-radius: 12px; margin: 0 auto; max-width: 400px;">
91 <div style="font-size: 4rem; color: #4b5563;">
92 <?php echo yatra_svg_icon($icon_class, 'destination-large-icon'); ?>
93 </div>
94 </div>
95 <?php endif; ?>
96 </div>
97 <?php endif; ?>
98
99 <!-- Destination Stats -->
100 <?php if (!empty($destination->trips_count) || !empty($destination->avg_rating)): ?>
101 <div class="destination-stats" style="display: flex; gap: 24px; margin-bottom: 40px; justify-content: center; flex-wrap: wrap;">
102 <?php if (!empty($destination->trips_count)): ?>
103 <div class="stat-item" style="text-align: center; padding: 20px; background: #f8fafc; border-radius: 8px; min-width: 120px;">
104 <div style="font-size: 2rem; font-weight: bold; color: #059669; margin-bottom: 4px;">
105 <?php echo esc_html($destination->trips_count); ?>
106 </div>
107 <div style="color: #6b7280; font-size: 0.875rem;">
108 <?php echo esc_html(_n('Trip', 'Trips', (int)$destination->trips_count, 'yatra')); ?>
109 </div>
110 </div>
111 <?php endif; ?>
112
113 <?php if (!empty($destination->avg_rating)): ?>
114 <div class="stat-item" style="text-align: center; padding: 20px; background: #f8fafc; border-radius: 8px; min-width: 120px;">
115 <div style="font-size: 2rem; font-weight: bold; color: #f59e0b; margin-bottom: 4px;">
116 <?php echo esc_html(number_format($destination->avg_rating, 1)); ?>
117 </div>
118 <div style="color: #6b7280; font-size: 0.875rem;">
119 <?php esc_html_e('Rating', 'yatra'); ?>
120 </div>
121 </div>
122 <?php endif; ?>
123
124 <?php if (!empty($destination->starting_price)): ?>
125 <div class="stat-item" style="text-align: center; padding: 20px; background: #f8fafc; border-radius: 8px; min-width: 120px;">
126 <div style="font-size: 1.5rem; font-weight: bold; color: #2563eb; margin-bottom: 4px;">
127 <?php echo esc_html($destination->starting_price); ?>
128 </div>
129 <div style="color: #6b7280; font-size: 0.875rem;">
130 <?php esc_html_e('From', 'yatra'); ?>
131 </div>
132 </div>
133 <?php endif; ?>
134 </div>
135 <?php endif; ?>
136
137 <!-- Available Trips -->
138 <div class="destination-trips" style="margin-top: 60px;">
139 <h2 style="font-size: 2rem; margin-bottom: 24px; color: #1f2937; text-align: center;">
140 <?php esc_html_e('Available Trips', 'yatra'); ?>
141 </h2>
142
143 <?php if (!empty($destination->trips) && is_array($destination->trips)): ?>
144 <div class="yatra-trip-grid">
145 <?php foreach ($destination->trips as $trip): ?>
146 <div class="yatra-trip-card">
147 <div class="yatra-trip-image">
148 <?php if (!empty($trip->featured_image_url)): ?>
149 <img src="<?php echo esc_url($trip->featured_image_url); ?>" alt="<?php echo esc_attr($trip->title ?? $trip->name ?? __('Trip', 'yatra')); ?>">
150 <?php else: ?>
151 <img src="<?php echo esc_url(plugins_url('assets/images/trip-placeholder.svg', YATRA_PLUGIN_FILE)); ?>" alt="<?php echo esc_attr($trip->title ?? $trip->name ?? __('Trip', 'yatra')); ?>">
152 <?php endif; ?>
153
154 <?php if (!empty($trip->discount_percentage) && $trip->discount_percentage > 0): ?>
155 <div class="yatra-discount-badge">
156 <?php
157 printf(
158 /* translators: %s: discount percentage */
159 esc_html__('%s%% OFF', 'yatra'),
160 esc_html($trip->discount_percentage)
161 );
162 ?>
163 </div>
164 <?php endif; ?>
165
166 <?php if (function_exists('yatra_wishlist_enabled') && yatra_wishlist_enabled() && !empty($trip->id)) : ?>
167 <button type="button" class="yatra-favorite-btn yatra-similar-favorite-btn" data-trip-id="<?php echo esc_attr((string) $trip->id); ?>" title="<?php esc_attr_e('Save to wishlist', 'yatra'); ?>">
168 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
169 <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"/>
170 </svg>
171 </button>
172 <?php endif; ?>
173 </div>
174
175 <div class="yatra-trip-content">
176 <div class="yatra-trip-meta">
177 <span class="yatra-trip-location"><?php echo esc_html($trip->location ?? $destination->name); ?></span>
178 <?php if (!empty($trip->duration)): ?>
179 <span class="yatra-trip-separator">•</span>
180 <span class="yatra-trip-duration"><?php echo esc_html($trip->duration); ?> <?php esc_html_e('Days', 'yatra'); ?></span>
181 <?php endif; ?>
182 <?php if (!empty($trip->difficulty)): ?>
183 <span class="yatra-trip-separator">•</span>
184 <span class="yatra-trip-difficulty"><?php echo esc_html($trip->difficulty); ?></span>
185 <?php endif; ?>
186 </div>
187
188 <h3 class="yatra-trip-title">
189 <a href="<?php echo esc_url($trip->permalink ?? ''); ?>">
190 <?php echo esc_html($trip->title ?? $trip->name ?? __('Untitled Trip', 'yatra')); ?>
191 </a>
192 </h3>
193
194 <?php if (!empty($trip->activities) && is_array($trip->activities)): ?>
195 <div class="yatra-trip-highlights">
196 <?php foreach (array_slice($trip->activities, 0, 3) as $activity): ?>
197 <span class="yatra-highlight-badge"><?php echo esc_html($activity->name ?? ''); ?></span>
198 <?php endforeach; ?>
199 </div>
200 <?php endif; ?>
201
202 <div class="yatra-trip-rating">
203 <div class="yatra-rating-stars">
204 <svg width="16" height="16" fill="#fbbf24" viewBox="0 0 24 24">
205 <path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
206 </svg>
207 <span class="yatra-rating-value"><?php echo esc_html(number_format($trip->average_rating ?? 0, 1)); ?></span>
208 </div>
209 <span class="yatra-reviews-count">(<?php echo esc_html($trip->review_count ?? 0); ?> <?php esc_html_e('reviews', 'yatra'); ?>)</span>
210 </div>
211
212 <div class="yatra-trip-footer">
213 <div class="yatra-trip-price">
214 <?php
215 // Apply dynamic pricing if module is enabled
216 $display_original_price = $trip->original_price ?? 0;
217 $display_effective_price = $trip->effective_price_min ?? $trip->original_price ?? 0;
218
219 if (apply_filters('yatra_dynamic_pricing_enabled', false)) {
220 if (!empty($display_original_price)) {
221 $display_original_price = apply_filters('yatra_trip_display_price', $display_original_price, $trip->id ?? 0, [
222 'departure_date' => null,
223 'spots_remaining' => null,
224 ]);
225 }
226 if (!empty($display_effective_price)) {
227 $display_effective_price = apply_filters('yatra_trip_display_price', $display_effective_price, $trip->id ?? 0, [
228 'departure_date' => null,
229 'spots_remaining' => null,
230 ]);
231 }
232 }
233 ?>
234 <?php if (!empty($display_original_price) && !empty($display_effective_price) && $display_original_price > $display_effective_price): ?>
235 <div class="yatra-original-price"><?php echo esc_html(yatra_format_price($display_original_price)); ?></div>
236 <?php endif; ?>
237 <div class="yatra-current-price">
238 <?php
239 if (!empty($display_effective_price)) {
240 echo esc_html(yatra_format_price($display_effective_price));
241 } else {
242 echo esc_html__('Price on request', 'yatra');
243 }
244 ?>
245 </div>
246 <div class="yatra-price-note"><?php esc_html_e('per person', 'yatra'); ?></div>
247 </div>
248 <a href="<?php echo esc_url($trip->permalink ?? ''); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta yatra-card-view-btn">
249 <?php echo yatra_svg_icon('file-text', 'yatra-btn-icon'); ?>
250 <span><?php esc_html_e('View Details', 'yatra'); ?></span>
251 </a>
252 </div>
253 </div>
254 </div>
255 <?php endforeach; ?>
256 </div>
257 <?php else: ?>
258 <div style="text-align: center; padding: 40px; background: #f9fafb; border-radius: 12px; margin-bottom: 40px;">
259 <p style="color: #6b7280; margin: 0 0 16px 0;">
260 <?php esc_html_e('No trips are currently available for this destination.', 'yatra'); ?>
261 </p>
262 <a href="<?php echo esc_url(home_url('/' . \Yatra\Services\SettingsService::getTripBase() . '/')); ?>"
263 style="color: #2563eb; text-decoration: none; font-weight: 500;">
264 <?php esc_html_e('Browse all trips', 'yatra'); ?>
265 </a>
266 </div>
267 <?php endif; ?>
268
269 <div style="text-align: center;">
270 <a href="<?php echo esc_url(add_query_arg(['destination' => urlencode($destination->slug)], home_url('/' . \Yatra\Services\SettingsService::getTripBase() . '/'))); ?>"
271 class="yatra-btn"
272 style="display: inline-flex; align-items: center; gap: 8px; padding: 12px 24px; background: #059669; color: white; text-decoration: none; border-radius: 6px; font-weight: 600; transition: background-color 0.2s;">
273 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
274 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
275 </svg>
276 <?php esc_html_e('View All Trips to', 'yatra'); ?> <?php echo esc_html($destination->name); ?>
277 </a>
278 </div>
279 </div>
280
281 <!-- Back to Destinations -->
282 <div style="text-align: center; margin-top: 60px; padding-top: 40px; border-top: 1px solid #e5e7eb;">
283 <a href="<?php echo esc_url(home_url('/' . \Yatra\Services\SettingsService::getString('destination_base', 'destination') . '/')); ?>"
284 style="color: #6b7280; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;">
285 <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
286 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
287 </svg>
288 <?php esc_html_e('Back to All Destinations', 'yatra'); ?>
289 </a>
290 </div>
291 </div>
292
293 <?php
294 yatra_get_footer();
295 ?>
296