| @@ -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; |
| @@ -100,8 +104,10 @@ | ||
| 100 | 104 | $show_destination = (bool) ($field_visibility['destination'] ?? true); |
| 101 | 105 | $show_activities = (bool) ($field_visibility['activities'] ?? true); |
| 102 | 106 | $show_duration = (bool) ($field_visibility['duration'] ?? true); |
| 103 | 107 | $show_budget = (bool) ($field_visibility['budget'] ?? true); |
| 108 | +$show_date = (bool) ($field_visibility['date'] ?? false); | |
| 109 | +$date_min = current_time('Y-m-d'); | |
| 104 | 110 | |
| 105 | 111 | // Tracks whether a field has been rendered yet, so a divider is only emitted |
| 106 | 112 | // BETWEEN visible fields (no leading/trailing/double dividers when some are off). |
| 107 | 113 | $yatra_search_rendered = false; |
| @@ -176,8 +182,35 @@ | ||
| 176 | 182 | <?php endforeach; ?> |
| 177 | 183 | <?php else : ?> |
| 178 | 184 | <div class="yatra-dropdown-option selected" data-value="" data-search-text=""><?php esc_html_e('All destinations', 'yatra'); ?></div> |
| 179 | 185 | <?php endif; ?> |
| 186 | + </div> | |
| 187 | + </div> | |
| 188 | + </div> | |
| 189 | + <?php $yatra_search_rendered = true; endif; ?> | |
| 190 | + | |
| 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 | + > | |
| 180 | 213 | </div> |
| 181 | 214 | </div> |
| 182 | 215 | </div> |
| 183 | 216 | <?php $yatra_search_rendered = true; endif; ?> |