PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.2.8
Yatra – Travel Booking & Tour Operator Software v3.0.2.8
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 2.0.10 All 83 releases
yatra / templates / single-activity.php

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

272 lines 14.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Single Activity Template
4 *
5 * Displays individual activity page with associated trips
6 * Uses global $activity object (similar to WordPress $post)
7 *
8 * @package Yatra
9 * @global object $activity Activity data object
10 */
11
12 // Prevent direct access
13 if (!defined('ABSPATH')) {
14 exit;
15 }
16
17 // Access global $activity object
18 global $activity;
19
20 // Debug: Check what data we have
21 if (defined('WP_DEBUG') && WP_DEBUG) {
22 }
23
24 // Bail if no activity data - return proper 404
25 if (!$activity) {
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 $activity;
36 return esc_html($activity->name) . ' - ' . get_bloginfo('name');
37 }, 10, 1);
38
39 yatra_get_header();
40 ?>
41
42 <div class="yatra-single-activity" style="max-width: 1200px; margin: 0 auto; padding: 40px 20px;">
43 <!-- Activity Header -->
44 <div class="activity-header" style="margin-bottom: 40px;">
45 <h1 style="font-size: 2.5rem; margin-bottom: 16px; color: #1f2937;">
46 <?php echo esc_html($activity->name); ?>
47 </h1>
48
49 <?php if (!empty($activity->description)): ?>
50 <div class="activity-description" style="font-size: 1.125rem; color: #6b7280; line-height: 1.6;">
51 <?php echo wp_kses_post($activity->description); ?>
52 </div>
53 <?php endif; ?>
54 </div>
55
56 <!-- Activity Icon/Image -->
57 <?php if (!empty($activity->icon)): ?>
58 <div class="activity-media" style="margin-bottom: 40px;">
59 <?php
60 $icon = maybe_unserialize($activity->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="activity-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($activity->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="activity-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, 'activity-large-icon'); ?>
93 </div>
94 </div>
95 <?php endif; ?>
96 </div>
97 <?php endif; ?>
98
99 <!-- Activity Stats -->
100 <?php if (!empty($activity->trips_count) || !empty($activity->avg_rating)): ?>
101 <div class="activity-stats" style="display: flex; gap: 24px; margin-bottom: 40px; justify-content: center; flex-wrap: wrap;">
102 <?php if (!empty($activity->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($activity->trips_count); ?>
106 </div>
107 <div style="color: #6b7280; font-size: 0.875rem;">
108 <?php echo esc_html(_n('Trip', 'Trips', (int)$activity->trips_count, 'yatra')); ?>
109 </div>
110 </div>
111 <?php endif; ?>
112
113 <?php if (!empty($activity->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($activity->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($activity->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($activity->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="activity-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($activity->trips) && is_array($activity->trips)): ?>
144 <div class="yatra-trip-grid">
145 <?php foreach ($activity->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'); ?>">
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'); ?>">
152 <?php endif; ?>
153
154 <?php if (!empty($trip->discount_percentage) && $trip->discount_percentage > 0): ?>
155 <div class="yatra-discount-badge">
156 <?php echo esc_html($trip->discount_percentage); ?>% OFF
157 </div>
158 <?php endif; ?>
159
160 <?php if (function_exists('yatra_wishlist_enabled') && yatra_wishlist_enabled() && !empty($trip->id)) : ?>
161 <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'); ?>">
162 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
163 <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"/>
164 </svg>
165 </button>
166 <?php endif; ?>
167 </div>
168
169 <div class="yatra-trip-content">
170 <div class="yatra-trip-meta">
171 <span class="yatra-trip-location"><?php echo esc_html($trip->location ?? $activity->name); ?></span>
172 <?php if (!empty($trip->duration)): ?>
173 <span class="yatra-trip-separator"></span>
174 <span class="yatra-trip-duration"><?php echo esc_html($trip->duration); ?> <?php esc_html_e('Days', 'yatra'); ?></span>
175 <?php endif; ?>
176 <?php if (!empty($trip->difficulty)): ?>
177 <span class="yatra-trip-separator"></span>
178 <span class="yatra-trip-difficulty"><?php echo esc_html($trip->difficulty); ?></span>
179 <?php endif; ?>
180 </div>
181
182 <h3 class="yatra-trip-title">
183 <a href="<?php echo esc_url($trip->permalink ?? ''); ?>">
184 <?php echo esc_html($trip->title ?? $trip->name ?? 'Untitled Trip'); ?>
185 </a>
186 </h3>
187
188 <?php if (!empty($trip->destinations) && is_array($trip->destinations)): ?>
189 <div class="yatra-trip-highlights">
190 <?php foreach (array_slice($trip->destinations, 0, 3) as $destination): ?>
191 <span class="yatra-highlight-badge"><?php echo esc_html($destination->name ?? ''); ?></span>
192 <?php endforeach; ?>
193 </div>
194 <?php endif; ?>
195
196 <div class="yatra-trip-rating">
197 <div class="yatra-rating-stars">
198 <svg width="16" height="16" fill="#fbbf24" viewBox="0 0 24 24">
199 <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"/>
200 </svg>
201 <span class="yatra-rating-value"><?php echo esc_html(number_format($trip->average_rating ?? 0, 1)); ?></span>
202 </div>
203 <span class="yatra-reviews-count">(<?php echo esc_html($trip->review_count ?? 0); ?> <?php esc_html_e('reviews', 'yatra'); ?>)</span>
204 </div>
205
206 <div class="yatra-trip-footer">
207 <div class="yatra-trip-price">
208 <?php if (!empty($trip->original_price) && !empty($trip->effective_price_min) && $trip->original_price > $trip->effective_price_min): ?>
209 <div class="yatra-original-price"><?php echo esc_html(yatra_format_price($trip->original_price)); ?></div>
210 <?php endif; ?>
211 <div class="yatra-current-price">
212 <?php
213 if (!empty($trip->effective_price_min)) {
214 echo esc_html(yatra_format_price($trip->effective_price_min));
215 } elseif (!empty($trip->original_price)) {
216 echo esc_html(yatra_format_price($trip->original_price));
217 } else {
218 echo esc_html__('Price on request', 'yatra');
219 }
220 ?>
221 </div>
222 <div class="yatra-price-note"><?php esc_html_e('per person', 'yatra'); ?></div>
223 </div>
224 <a href="<?php echo esc_url($trip->permalink ?? ''); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta yatra-card-view-btn">
225 <?php echo yatra_svg_icon('file-text', 'yatra-btn-icon'); ?>
226 <span><?php esc_html_e('View Details', 'yatra'); ?></span>
227 </a>
228 </div>
229 </div>
230 </div>
231 <?php endforeach; ?>
232 </div>
233 <?php else: ?>
234 <div style="text-align: center; padding: 40px; background: #f9fafb; border-radius: 12px; margin-bottom: 40px;">
235 <p style="color: #6b7280; margin: 0 0 16px 0;">
236 <?php esc_html_e('No trips are currently available with this activity.', 'yatra'); ?>
237 </p>
238 <a href="<?php echo esc_url(home_url('/trip/')); ?>"
239 style="color: #2563eb; text-decoration: none; font-weight: 500;">
240 <?php esc_html_e('Browse all trips', 'yatra'); ?>
241 </a>
242 </div>
243 <?php endif; ?>
244
245 <div style="text-align: center;">
246 <a href="<?php echo esc_url(home_url('/trip/?activity=' . urlencode($activity->slug))); ?>"
247 class="yatra-btn"
248 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;">
249 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
250 <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"/>
251 </svg>
252 <?php esc_html_e('View All Trips with', 'yatra'); ?> <?php echo esc_html($activity->name); ?>
253 </a>
254 </div>
255 </div>
256
257 <!-- Back to Activities -->
258 <div style="text-align: center; margin-top: 60px; padding-top: 40px; border-top: 1px solid #e5e7eb;">
259 <a href="<?php echo esc_url(home_url('/activity/')); ?>"
260 style="color: #6b7280; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;">
261 <svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24">
262 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
263 </svg>
264 <?php esc_html_e('Back to All Activities', 'yatra'); ?>
265 </a>
266 </div>
267 </div>
268
269 <?php
270 yatra_get_footer();
271 ?>
272