PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.16
Yatra – Travel Booking & Tour Operator Software v3.0.16
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
← All changes | templates/shortcodes/trip-search.php +63 -7 3.0.3 → 3.0.16 View file →
@@ -27,8 +27,12 @@
27 27 'destination' => isset($_GET['destination']) ? sanitize_text_field(wp_unslash((string) $_GET['destination'])) : '',
28 28 'activity' => isset($_GET['activity']) ? sanitize_text_field(wp_unslash((string) $_GET['activity'])) : '',
29 29 'duration' => isset($_GET['duration']) ? sanitize_text_field(wp_unslash((string) $_GET['duration'])) : '',
30 30 'budget' => isset($_GET['budget']) ? sanitize_text_field(wp_unslash((string) $_GET['budget'])) : '',
31 + // Pre-fill the date picker from the URL, but only if it is a real Y-m-d date.
32 + 'available_date' => isset($_GET['available_date'])
33 + ? \Yatra\Helpers\TripListingFilterBuilder::normalizeAvailableDate((string) wp_unslash($_GET['available_date']))
34 + : '',
31 35 ];
32 36
33 37 $dur_initial_min = $dmin;
34 38 $dur_initial_max = $dmax;
@@ -87,8 +91,27 @@
87 91 (int) $dmDur[1],
88 92 (int) $dmDur[2]
89 93 );
90 94 }
95 +
96 +// Per-field visibility is owned entirely by the SearchShortcode: for each field
97 +// an explicit shortcode attribute (e.g. [yatra_search budget="no"]) wins, and
98 +// when omitted it inherits the global Settings → Search & Listing toggle. The
99 +// resolved result is handed to this template in $field_visibility. This template
100 +// is purely presentational — it never reads the settings itself. Missing keys
101 +// default to visible, so the bar still renders if loaded without the shortcode.
102 +$field_visibility = (isset($field_visibility) && is_array($field_visibility)) ? $field_visibility : [];
103 +$show_keyword = (bool) ($field_visibility['keyword'] ?? true);
104 +$show_destination = (bool) ($field_visibility['destination'] ?? true);
105 +$show_activities = (bool) ($field_visibility['activities'] ?? true);
106 +$show_duration = (bool) ($field_visibility['duration'] ?? true);
107 +$show_budget = (bool) ($field_visibility['budget'] ?? true);
108 +$show_date = (bool) ($field_visibility['date'] ?? false);
109 +$date_min = current_time('Y-m-d');
110 +
111 +// Tracks whether a field has been rendered yet, so a divider is only emitted
112 +// BETWEEN visible fields (no leading/trailing/double dividers when some are off).
113 +$yatra_search_rendered = false;
91 114 ?>
92 115
93 116 <div class="yatra-trip-search-shortcode" data-listing-url="<?php echo esc_url($listing_url); ?>">
94 117 <div class="yatra-horizontal-search">
@@ -93,8 +116,9 @@
93 116 <div class="yatra-trip-search-shortcode" data-listing-url="<?php echo esc_url($listing_url); ?>">
94 117 <div class="yatra-horizontal-search">
95 118 <div class="yatra-horizontal-search-container">
96 119 <div class="yatra-search-bar">
120 + <?php if ($show_keyword) : ?>
97 121 <div class="yatra-search-keyword-segment">
98 122 <label class="screen-reader-text" for="yatra-trip-search-s"><?php esc_html_e('Search trips', 'yatra'); ?></label>
99 123 <div class="yatra-search-keyword-inner">
100 124 <span class="yatra-search-keyword-leading" aria-hidden="true"><?php echo yatra_svg_icon('search'); ?></span>
@@ -113,11 +137,12 @@
113 137 >
114 138 </div>
115 139 </div>
116 140 </div>
141 + <?php $yatra_search_rendered = true; endif; ?>
117 142
118 - <div class="yatra-search-divider"></div>
119 -
143 + <?php if ($show_destination) : ?>
144 + <?php if ($yatra_search_rendered) : ?><div class="yatra-search-divider"></div><?php endif; ?>
120 145 <div class="yatra-search-dropdown" data-dropdown="destination">
121 146 <div class="yatra-dropdown-trigger">
122 147 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
123 148 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z"/>
@@ -160,11 +185,39 @@
160 185 <?php endif; ?>
161 186 </div>
162 187 </div>
163 188 </div>
189 + <?php $yatra_search_rendered = true; endif; ?>
164 190
165 - <div class="yatra-search-divider"></div>
191 + <?php if ($show_date) : ?>
192 + <?php if ($yatra_search_rendered) : ?><div class="yatra-search-divider"></div><?php endif; ?>
193 + <div class="yatra-search-date-segment">
194 + <label class="screen-reader-text" for="yatra-trip-search-date"><?php esc_html_e('Travel date', 'yatra'); ?></label>
195 + <div class="yatra-search-date-inner">
196 + <span class="yatra-search-date-leading" aria-hidden="true">
197 + <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
198 + <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" 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"/>
199 + </svg>
200 + </span>
201 + <div class="yatra-search-date-stack">
202 + <span class="yatra-dropdown-label"><?php esc_html_e('Date', 'yatra'); ?></span>
203 + <input
204 + type="date"
205 + id="yatra-trip-search-date"
206 + name="available_date"
207 + class="yatra-search-date-input"
208 + autocomplete="off"
209 + placeholder="<?php esc_attr_e('Any date', 'yatra'); ?>"
210 + min="<?php echo esc_attr($date_min); ?>"
211 + value="<?php echo esc_attr($active_filters['available_date']); ?>"
212 + >
213 + </div>
214 + </div>
215 + </div>
216 + <?php $yatra_search_rendered = true; endif; ?>
166 217
218 + <?php if ($show_activities) : ?>
219 + <?php if ($yatra_search_rendered) : ?><div class="yatra-search-divider"></div><?php endif; ?>
167 220 <div class="yatra-search-dropdown" data-dropdown="activities">
168 221 <div class="yatra-dropdown-trigger">
169 222 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
170 223 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
@@ -206,11 +259,12 @@
206 259 <?php endif; ?>
207 260 </div>
208 261 </div>
209 262 </div>
263 + <?php $yatra_search_rendered = true; endif; ?>
210 264
211 - <div class="yatra-search-divider"></div>
212 -
265 + <?php if ($show_duration) : ?>
266 + <?php if ($yatra_search_rendered) : ?><div class="yatra-search-divider"></div><?php endif; ?>
213 267 <div class="yatra-search-dropdown" data-dropdown="duration" data-duration-min="<?php echo esc_attr((string) $dmin); ?>" data-duration-max="<?php echo esc_attr((string) $dmax); ?>">
214 268 <div class="yatra-dropdown-trigger">
215 269 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
216 270 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 018 0z"/>
@@ -241,11 +295,12 @@
241 295 </div>
242 296 </div>
243 297 </div>
244 298 </div>
299 + <?php $yatra_search_rendered = true; endif; ?>
245 300
246 - <div class="yatra-search-divider"></div>
247 -
301 + <?php if ($show_budget) : ?>
302 + <?php if ($yatra_search_rendered) : ?><div class="yatra-search-divider"></div><?php endif; ?>
248 303 <div class="yatra-search-dropdown" data-dropdown="budget">
249 304 <div class="yatra-dropdown-trigger">
250 305 <svg width="20" height="20" fill="none" stroke="currentColor" viewBox="0 0 24 24">
251 306 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/>
@@ -270,8 +325,9 @@
270 325 <div class="yatra-dropdown-option selected" data-value=""><?php esc_html_e('No price data yet', 'yatra'); ?></div>
271 326 <?php endif; ?>
272 327 </div>
273 328 </div>
329 + <?php $yatra_search_rendered = true; endif; ?>
274 330
275 331 <div class="yatra-search-button-container">
276 332 <button type="button" class="yatra-search-main-btn">
277 333 <?php esc_html_e('Search', 'yatra'); ?>