PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.15
Yatra – Travel Booking & Tour Operator Software v3.0.15
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 / shortcodes / trip.php

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

127 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Tour Shortcode Template
4 *
5 * @package Yatra
6 * @var array $trips Array of trip objects
7 * @var array $atts Shortcode attributes
8 * @var array $query_args WP_Query arguments
9 * @var int $max_pages Maximum number of pages
10 * @var int $current_page Current page number
11 * @var int $total_found Total number of trips found
12 */
13 // Prevent direct access
14 if (!defined('ABSPATH')) {
15 exit;
16 }
17 $columns = (int) $atts['columns'];
18 $column_class = 'yatra-tour-grid-' . min(max($columns, 1), 6);
19 // Extract pagination variables from trips data structure
20 $current_page = $trips['current_page'] ?? $current_page ?? 1;
21 $max_pages = $trips['max_pages'] ?? $max_pages ?? 1;
22 $total_found = (int) ($trips['total_found'] ?? $total_found ?? 0);
23 $trip_items = $trips['trips'] ?? [];
24
25 // Section title: align with activity/destination blocks (always same header structure).
26 if (!empty($atts['title'])) {
27 $display_title = (string) $atts['title'];
28 } elseif (!empty($atts['featured']) && $atts['featured'] === '1') {
29 $display_title = __('Featured Trips', 'yatra');
30 } else {
31 $display_title = __('Our Trips', 'yatra');
32 }
33
34 // Card layout: per-instance override (card_layout attr) falls back to the
35 // site-wide Design setting. Class goes on this wrapper so this listing's layout
36 // is independent of the global default and of other listings on the page.
37 $yatra_listing_layout_class = \Yatra\Providers\FrontendAssetsProvider::listingLayoutClasses(
38 \Yatra\Providers\FrontendAssetsProvider::resolveListingLayout((string) ($atts['card_layout'] ?? ''))
39 );
40 ?>
41 <div class="yatra-tour-shortcode<?php echo $yatra_listing_layout_class ? ' ' . esc_attr($yatra_listing_layout_class) : ''; ?>" data-atts='<?php echo esc_attr(json_encode($atts)); ?>'>
42 <div class="yatra-tour-header">
43 <h2 class="yatra-tour-title"><?php echo esc_html($display_title); ?></h2>
44 <?php if (!empty($trip_items) && $total_found > 0) : ?>
45 <div class="yatra-tour-count">
46 <?php
47 printf(
48 /* translators: 1: number of trips shown, 2: total trips available. */
49 esc_html__('Showing %1$d of %2$d trips', 'yatra'),
50 (int) count($trip_items),
51 (int) $total_found
52 );
53 ?>
54 </div>
55 <?php endif; ?>
56 </div>
57 <?php if (!empty($trip_items)): ?>
58 <div class="yatra-tour-grid <?php echo esc_attr($column_class); ?>">
59 <?php foreach ($trip_items as $trip): ?>
60 <div class="yatra-tour-item">
61 <?php
62 // Load the trip card template
63 include YATRA_PLUGIN_PATH . 'templates/trip-listing-card.php';
64 ?>
65 </div>
66 <?php endforeach; ?>
67 </div>
68 <?php elseif ($total_found > 0): ?>
69 <!-- No trips on this page, but trips exist on other pages -->
70 <div class="yatra-tour-empty-page">
71 <p><?php esc_html_e('No trips found on this page. Try navigating to other pages.', 'yatra'); ?></p>
72 </div>
73 <?php else: ?>
74 <!-- No trips found at all -->
75 <div class="yatra-tour-empty">
76 <div class="yatra-empty-icon">
77 <?php echo yatra_svg_icon('map', 'yatra-empty-icon-svg'); ?>
78 </div>
79 <h3><?php esc_html_e('No Trips Found', 'yatra'); ?></h3>
80 <p><?php esc_html_e('We couldn\'t find any trips matching your criteria. Try adjusting your filters or browse all trips.', 'yatra'); ?></p>
81
82
83
84 <a href="<?php echo esc_url(home_url('/trips')); ?>" class="yatra-btn yatra-btn-primary yatra-archive-card-cta">
85 <?php echo yatra_svg_icon('globe', 'yatra-btn-icon'); ?>
86 <span><?php esc_html_e('Browse All Trips', 'yatra'); ?></span>
87 </a>
88 </div>
89 <?php endif; ?>
90 <?php if ($atts['show_pagination'] === 'yes' && $max_pages > 1): ?>
91 <div class="yatra-tour-pagination">
92 <?php
93 $current_url = remove_query_arg('trip_page', $_SERVER['REQUEST_URI']);
94 $current_url = preg_replace('/&trip_page=[^&]*/', '', $current_url);
95
96 // Previous page
97 if ($current_page > 1):
98 $prev_url = add_query_arg('trip_page', $current_page - 1, $current_url);
99 ?>
100 <a href="#" class="yatra-pagination-link yatra-pagination-prev" data-page="<?php echo esc_attr($current_page - 1); ?>">
101 <?php echo yatra_svg_icon('chevron-left', 'yatra-btn-icon'); ?>
102 <span><?php esc_html_e('Previous', 'yatra'); ?></span>
103 </a>
104 <?php endif; ?>
105 <?php
106 // Show all page numbers - no ellipsis
107 for ($i = 1; $i <= $max_pages; $i++):
108 $is_current = $i === $current_page;
109 ?>
110 <a href="#" class="yatra-pagination-link <?php echo $is_current ? 'yatra-pagination-current' : ''; ?>" data-page="<?php echo esc_attr($i); ?>">
111 <?php echo esc_html($i); ?>
112 </a>
113 <?php endfor; ?>
114 <?php
115 // Next page
116 if ($current_page < $max_pages):
117 $next_url = add_query_arg('trip_page', $current_page + 1, $current_url);
118 ?>
119 <a href="#" class="yatra-pagination-link yatra-pagination-next" data-page="<?php echo esc_attr($current_page + 1); ?>">
120 <span><?php esc_html_e('Next', 'yatra'); ?></span>
121 <?php echo yatra_svg_icon('chevron-right', 'yatra-btn-icon'); ?>
122 </a>
123 <?php endif; ?>
124 </div>
125 <?php endif; ?>
126 </div>
127