$budget_presets */ if (!defined('ABSPATH')) { exit; } $listing_url = $listing_url ?? home_url('/' . \Yatra\Services\SettingsService::getTripBase() . '/'); $duration_bounds = is_array($duration_bounds ?? null) ? $duration_bounds : ['min' => 1, 'max' => 30]; $budget_presets = is_array($budget_presets ?? null) ? $budget_presets : []; $dmin = max(1, (int) ($duration_bounds['min'] ?? 1)); $dmax = max($dmin, (int) ($duration_bounds['max'] ?? 30)); $active_filters = [ 's' => isset($_GET['s']) ? sanitize_text_field(wp_unslash((string) $_GET['s'])) : '', 'destination' => isset($_GET['destination']) ? sanitize_text_field(wp_unslash((string) $_GET['destination'])) : '', 'activity' => isset($_GET['activity']) ? sanitize_text_field(wp_unslash((string) $_GET['activity'])) : '', 'duration' => isset($_GET['duration']) ? sanitize_text_field(wp_unslash((string) $_GET['duration'])) : '', 'budget' => isset($_GET['budget']) ? sanitize_text_field(wp_unslash((string) $_GET['budget'])) : '', // Pre-fill the date picker from the URL, but only if it is a real Y-m-d date. 'available_date' => isset($_GET['available_date']) ? \Yatra\Helpers\TripListingFilterBuilder::normalizeAvailableDate((string) wp_unslash($_GET['available_date'])) : '', ]; $dur_initial_min = $dmin; $dur_initial_max = $dmax; if ($active_filters['duration'] !== '' && preg_match('/^(\d+)-(\d+)$/', $active_filters['duration'], $dm)) { $dur_initial_min = max($dmin, (int) $dm[1]); $dur_initial_max = min($dmax, max($dur_initial_min, (int) $dm[2])); } $dest_default = __('Destination', 'yatra'); $dest_label = $dest_default; if ($active_filters['destination'] !== '') { foreach ($destinations as $d) { if ((string) ($d->slug ?? '') === $active_filters['destination']) { $dest_label = (string) ($d->name ?? $active_filters['destination']); break; } } if ($dest_label === $dest_default) { $dest_label = $active_filters['destination']; } } $act_default = __('Activity', 'yatra'); $act_label = $act_default; if ($active_filters['activity'] !== '') { foreach ($activities as $a) { if ((string) ($a->slug ?? '') === $active_filters['activity']) { $act_label = (string) ($a->name ?? $active_filters['activity']); break; } } if ($act_label === $act_default) { $act_label = $active_filters['activity']; } } $budget_default = __('Budget', 'yatra'); $budget_label = $budget_default; if ($active_filters['budget'] !== '') { foreach ($budget_presets as $bp) { if ((string) ($bp->value ?? '') === $active_filters['budget']) { $budget_label = (string) ($bp->label ?? $active_filters['budget']); break; } } if ($budget_label === $budget_default) { $budget_label = $active_filters['budget']; } } $dur_display_label = __('Duration', 'yatra'); if ($active_filters['duration'] !== '' && preg_match('/^(\d+)-(\d+)$/', $active_filters['duration'], $dmDur)) { $dur_display_label = sprintf( /* translators: 1: min days, 2: max days */ __('%1$d – %2$d days', 'yatra'), (int) $dmDur[1], (int) $dmDur[2] ); } // Per-field visibility is owned entirely by the SearchShortcode: for each field // an explicit shortcode attribute (e.g. [yatra_search budget="no"]) wins, and // when omitted it inherits the global Settings → Search & Listing toggle. The // resolved result is handed to this template in $field_visibility. This template // is purely presentational — it never reads the settings itself. Missing keys // default to visible, so the bar still renders if loaded without the shortcode. $field_visibility = (isset($field_visibility) && is_array($field_visibility)) ? $field_visibility : []; $show_keyword = (bool) ($field_visibility['keyword'] ?? true); $show_destination = (bool) ($field_visibility['destination'] ?? true); $show_activities = (bool) ($field_visibility['activities'] ?? true); $show_duration = (bool) ($field_visibility['duration'] ?? true); $show_budget = (bool) ($field_visibility['budget'] ?? true); $show_date = (bool) ($field_visibility['date'] ?? false); $date_min = current_time('Y-m-d'); // Tracks whether a field has been rendered yet, so a divider is only emitted // BETWEEN visible fields (no leading/trailing/double dividers when some are off). $yatra_search_rendered = false; ?>