PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
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 2.0.11 All 82 releases
yatra / templates / shortcodes / activity.php

activity.php in Yatra – Travel Booking & Tour Operator Software trunk, at templates/shortcodes/activity.php

178 lines 9.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Activity Shortcode Template
4 *
5 * This template displays activities in a grid layout with comprehensive information
6 * including pricing, ratings, duration, and other relevant details.
7 *
8 * @package Yatra
9 * @var array $atts Shortcode attributes
10 * @var array $activities Array of activity data
11 * @var int $current_page Current page number
12 * @var int $max_pages Maximum number of pages
13 * @var int $total_found Total number of activities found
14 * @var int $per_page Number of activities per page
15 */
16
17 // Prevent direct access
18 if (!defined('ABSPATH')) {
19 exit;
20 }
21
22
23 $columns = (int) $atts['columns'];
24 $column_class = 'yatra-activity-grid-' . min(max($columns, 1), 6);
25 ?>
26
27 <div class="yatra-activity-shortcode" data-atts='<?php echo esc_attr(json_encode($atts)); ?>'>
28 <div class="yatra-activity-header">
29 <?php if (!empty($atts['title'])): ?>
30 <h2 class="yatra-activity-title"><?php echo esc_html($atts['title']); ?></h2>
31 <?php else: ?>
32 <h2 class="yatra-activity-title"><?php esc_html_e('Activity Listings', 'yatra'); ?></h2>
33 <?php endif; ?>
34 <?php if (!empty($activities)): ?>
35 <div class="yatra-activity-count">
36 <?php
37 printf(
38 /* translators: 1: number of activities shown, 2: total activities available. */
39 esc_html__('Showing %1$d of %2$d activities', 'yatra'),
40 (int) count($activities),
41 (int) $total_found
42 );
43 ?>
44 </div>
45 <?php endif; ?>
46 </div>
47
48 <?php if (!empty($activities)): ?>
49 <div class="yatra-activity-grid <?php echo esc_attr($column_class); ?>">
50 <?php foreach ($activities as $activity): ?>
51 <div class="yatra-category-card">
52 <div class="yatra-category-card-image-wrapper">
53 <?php if (!empty($activity['image'])): ?>
54 <a href="<?php echo esc_url($activity['link']); ?>">
55 <img src="<?php echo esc_url($activity['image']); ?>" alt="<?php echo esc_attr($activity['term']->name); ?>" class="yatra-category-card-image">
56 </a>
57 <?php else: ?>
58 <a href="<?php echo esc_url($activity['link']); ?>">
59 <img src="<?php echo YATRA_PLUGIN_URL; ?>assets/images/placeholder.png" alt="<?php echo esc_attr($activity['term']->name); ?>" class="yatra-category-card-image">
60 </a>
61 <?php endif; ?>
62
63 <!-- Overlay Content on Image -->
64 <div class="yatra-category-card-overlay">
65 <div class="yatra-category-card-content">
66 <h3 class="yatra-category-card-title">
67 <a href="<?php echo esc_url($activity['link']); ?>" class="yatra-category-card-title-link"><?php echo esc_html($activity['term']->name); ?></a>
68 </h3>
69
70 <div class="yatra-category-card-stats">
71 <!-- Rating -->
72 <div class="category-stat rating">
73 <span class="category-stat-icon">
74 <svg width="16" height="16" fill="currentColor" viewBox="0 0 20 20">
75 <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" />
76 </svg>
77 </span>
78 <span class="category-stat-value"><?php echo esc_html(number_format(!empty($activity['avg_rating']) ? $activity['avg_rating'] : 0, 1)); ?></span>
79 </div>
80
81 <!-- Trip Count -->
82 <div class="category-stat trips">
83 <span class="category-stat-icon">
84 <svg width="16" height="16" fill="currentColor" viewBox="0 0 24 24">
85 <path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/>
86 </svg>
87 </span>
88 <span class="category-stat-value">
89 <?php
90 $trip_count = !empty($activity['trip_count']) ? $activity['trip_count'] : 0;
91 echo esc_html($trip_count) . ' ' . _n('Trip', 'Trips', $trip_count, 'yatra');
92 ?>
93 </span>
94 </div>
95
96 <!-- Price (if available) -->
97 <?php if (!empty($activity['min_price'])): ?>
98 <div class="category-stat price">
99 <span class="category-stat-icon">$</span>
100 <span class="category-stat-value">
101 <?php esc_html_e('From', 'yatra'); ?> <?php echo esc_html(yatra_format_price((float) $activity['min_price'])); ?>
102 </span>
103 </div>
104 <?php endif; ?>
105 </div>
106 </div>
107 </div>
108
109 <!-- Featured Badge -->
110 <?php if (isset($activity['term']->featured) && $activity['term']->featured == 1): ?>
111 <div class="yatra-category-featured-badge">
112 <?php esc_html_e('Featured', 'yatra'); ?>
113 </div>
114 <?php endif; ?>
115 </div>
116 </div>
117 <?php endforeach; ?>
118 </div>
119 <?php elseif ($total_found > 0): ?>
120 <!-- No activities on this page, but activities exist on other pages -->
121 <div class="yatra-activity-empty-page">
122 <p><?php esc_html_e('No activities found on this page. Try navigating to other pages.', 'yatra'); ?></p>
123 </div>
124 <?php else: ?>
125 <!-- No activities found at all -->
126 <div class="yatra-activity-empty">
127 <div class="yatra-empty-icon">
128 <?php echo yatra_svg_icon('activity', 'yatra-empty-icon-svg'); ?>
129 </div>
130 <h3><?php esc_html_e('No Activities Found', 'yatra'); ?></h3>
131 <p><?php esc_html_e('We couldn\'t find any activities. Please check back later or browse our trips directly.', 'yatra'); ?></p>
132 <a href="<?php echo esc_url(get_post_type_archive_link('trip')); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta">
133 <?php echo yatra_svg_icon('globe', 'yatra-btn-icon'); ?>
134 <span><?php esc_html_e('Browse All Trips', 'yatra'); ?></span>
135 </a>
136 </div>
137 <?php endif; ?>
138
139 <?php if ($atts['show_pagination'] === 'yes' && isset($max_pages) && $max_pages > 1): ?>
140 <div class="yatra-activity-pagination">
141 <?php
142 $current_url = remove_query_arg('activity_page', $_SERVER['REQUEST_URI']);
143 $current_url = preg_replace('/&activity_page=[^&]*/', '', $current_url);
144
145 // Previous page
146 if ($current_page > 1):
147 $prev_url = add_query_arg('activity_page', $current_page - 1, $current_url);
148 ?>
149 <a href="#" class="yatra-pagination-link yatra-pagination-prev" data-page="<?php echo esc_attr($current_page - 1); ?>">
150 <?php echo yatra_svg_icon('chevron-left', ''); ?>
151 <?php esc_html_e('Previous', 'yatra'); ?>
152 </a>
153 <?php endif; ?>
154
155 <?php
156 // Show all page numbers - no ellipsis
157 for ($i = 1; $i <= $max_pages; $i++):
158 $is_current = $i === $current_page;
159 ?>
160 <a href="#" class="yatra-pagination-link <?php echo $is_current ? 'yatra-pagination-current' : ''; ?>" data-page="<?php echo esc_attr($i); ?>">
161 <?php echo esc_html($i); ?>
162 </a>
163 <?php endfor; ?>
164
165 <?php
166 // Next page
167 if ($current_page < $max_pages):
168 $next_url = add_query_arg('activity_page', $current_page + 1, $current_url);
169 ?>
170 <a href="#" class="yatra-pagination-link yatra-pagination-next" data-page="<?php echo esc_attr($current_page + 1); ?>">
171 <?php esc_html_e('Next', 'yatra'); ?>
172 <?php echo yatra_svg_icon('chevron-right', ''); ?>
173 </a>
174 <?php endif; ?>
175 </div>
176 <?php endif; ?>
177 </div>
178