| 1 |
<?php |
| 2 |
if (!defined('ABSPATH')) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
$root_id = isset($root_id) ? (string) $root_id : ''; |
| 7 |
$root_class = isset($root_class) ? (string) $root_class : ''; |
| 8 |
$display_id = isset($display_id) ? (string) $display_id : ''; |
| 9 |
$display_class = isset($display_class) ? (string) $display_class : ''; |
| 10 |
$display_attrs = (isset($display_attrs) && is_array($display_attrs)) ? $display_attrs : []; |
| 11 |
$dropdown_id = isset($dropdown_id) ? (string) $dropdown_id : ''; |
| 12 |
$dropdown_class = isset($dropdown_class) ? (string) $dropdown_class : ''; |
| 13 |
$display_text = isset($display_text) ? (string) $display_text : ''; |
| 14 |
$icon_html = isset($icon_html) ? (string) $icon_html : ''; |
| 15 |
$rows = (isset($rows) && is_array($rows)) ? $rows : []; |
| 16 |
|
| 17 |
$render_attrs = static function(array $attrs): string { |
| 18 |
$out = ''; |
| 19 |
foreach ($attrs as $key => $value) { |
| 20 |
if ($value === null) { |
| 21 |
continue; |
| 22 |
} |
| 23 |
if ($value === true) { |
| 24 |
$out .= ' ' . esc_attr((string) $key); |
| 25 |
continue; |
| 26 |
} |
| 27 |
if ($value === false) { |
| 28 |
continue; |
| 29 |
} |
| 30 |
$out .= ' ' . esc_attr((string) $key) . '="' . esc_attr((string) $value) . '"'; |
| 31 |
} |
| 32 |
return $out; |
| 33 |
}; |
| 34 |
|
| 35 |
$container_attrs = (isset($container_attrs) && is_array($container_attrs)) ? $container_attrs : []; |
| 36 |
$dropdown_attrs = (isset($dropdown_attrs) && is_array($dropdown_attrs)) ? $dropdown_attrs : []; |
| 37 |
?> |
| 38 |
|
| 39 |
<div<?php echo $root_id ? ' id="' . esc_attr($root_id) . '"' : ''; ?> class="<?php echo esc_attr(trim('yatra-traveler-selector ' . $root_class)); ?>"<?php echo $render_attrs($container_attrs); ?>> |
| 40 |
<div class="yatra-booking-field-icon"> |
| 41 |
<?php echo $icon_html; ?> |
| 42 |
</div> |
| 43 |
|
| 44 |
<div<?php echo $display_id ? ' id="' . esc_attr($display_id) . '"' : ''; ?> class="<?php echo esc_attr(trim('yatra-traveler-selector-display ' . $display_class)); ?>"<?php echo $render_attrs($display_attrs); ?>> |
| 45 |
<?php echo esc_html($display_text); ?> |
| 46 |
</div> |
| 47 |
|
| 48 |
<svg class="yatra-select-arrow yatra-traveler-selector-arrow" width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 49 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/> |
| 50 |
</svg> |
| 51 |
|
| 52 |
<div<?php echo $dropdown_id ? ' id="' . esc_attr($dropdown_id) . '"' : ''; ?> class="<?php echo esc_attr(trim('yatra-traveler-selector-dropdown ' . $dropdown_class)); ?>"<?php echo $render_attrs($dropdown_attrs); ?>> |
| 53 |
<?php foreach ($rows as $row): |
| 54 |
$row_label = isset($row['label']) ? (string) $row['label'] : ''; |
| 55 |
$row_subtitle = isset($row['subtitle']) ? (string) $row['subtitle'] : ''; |
| 56 |
$row_price_html = isset($row['price_html']) ? (string) $row['price_html'] : ''; |
| 57 |
$row_attrs = (isset($row['row_attrs']) && is_array($row['row_attrs'])) ? $row['row_attrs'] : []; |
| 58 |
$minus_attrs = (isset($row['minus_attrs']) && is_array($row['minus_attrs'])) ? $row['minus_attrs'] : []; |
| 59 |
$plus_attrs = (isset($row['plus_attrs']) && is_array($row['plus_attrs'])) ? $row['plus_attrs'] : []; |
| 60 |
$input_attrs = (isset($row['input_attrs']) && is_array($row['input_attrs'])) ? $row['input_attrs'] : []; |
| 61 |
$minus_disabled = !empty($row['minus_disabled']); |
| 62 |
$plus_disabled = !empty($row['plus_disabled']); |
| 63 |
?> |
| 64 |
<div class="yatra-quantity-row"<?php echo $render_attrs($row_attrs); ?>> |
| 65 |
<div class="yatra-quantity-label"> |
| 66 |
<span class="yatra-quantity-title"><?php echo esc_html($row_label); ?></span> |
| 67 |
<?php if (!empty($row_subtitle)): ?> |
| 68 |
<span class="yatra-quantity-subtitle"><?php echo esc_html($row_subtitle); ?></span> |
| 69 |
<?php endif; ?> |
| 70 |
<?php if (!empty($row_price_html)): ?> |
| 71 |
<?php echo wp_kses_post($row_price_html); ?> |
| 72 |
<?php endif; ?> |
| 73 |
</div> |
| 74 |
<div class="yatra-quantity-controls"> |
| 75 |
<button type="button" class="yatra-quantity-btn yatra-quantity-minus yatra-qty-btn yatra-qty-minus"<?php echo $minus_disabled ? ' disabled' : ''; ?><?php echo $render_attrs($minus_attrs); ?>> |
| 76 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 77 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"/> |
| 78 |
</svg> |
| 79 |
</button> |
| 80 |
|
| 81 |
<input type="number" |
| 82 |
class="yatra-quantity-input yatra-availability-category yatra-qty-input" |
| 83 |
readonly |
| 84 |
id="<?php echo isset($input_attrs['id']) ? esc_attr($input_attrs['id']) : ''; ?>" |
| 85 |
name="<?php echo isset($input_attrs['name']) ? esc_attr($input_attrs['name']) : ''; ?>" |
| 86 |
value="<?php echo isset($input_attrs['value']) ? esc_attr($input_attrs['value']) : '0'; ?>" |
| 87 |
min="<?php echo isset($input_attrs['min']) ? esc_attr($input_attrs['min']) : '0'; ?>" |
| 88 |
max="<?php echo isset($input_attrs['max']) ? esc_attr($input_attrs['max']) : '999'; ?>" |
| 89 |
data-item="<?php echo isset($input_attrs['data-item']) ? esc_attr($input_attrs['data-item']) : ''; ?>" |
| 90 |
data-category="<?php echo isset($input_attrs['data-category']) ? esc_attr($input_attrs['data-category']) : ''; ?>" |
| 91 |
data-price="<?php echo isset($input_attrs['data-price']) ? esc_attr($input_attrs['data-price']) : ''; ?>" |
| 92 |
data-pricing-mode="<?php echo isset($input_attrs['data-pricing-mode']) ? esc_attr($input_attrs['data-pricing-mode']) : ''; ?>" |
| 93 |
data-group-overflow="<?php echo isset($input_attrs['data-group-overflow']) ? esc_attr($input_attrs['data-group-overflow']) : 'block'; ?>" |
| 94 |
data-max-pax="<?php echo isset($input_attrs['data-max-pax']) ? esc_attr($input_attrs['data-max-pax']) : ''; ?>" |
| 95 |
data-category-label="<?php echo isset($input_attrs['data-category-label']) ? esc_attr($input_attrs['data-category-label']) : ''; ?>"> |
| 96 |
|
| 97 |
<button type="button" class="yatra-quantity-btn yatra-quantity-plus yatra-qty-btn yatra-qty-plus"<?php echo $plus_disabled ? ' disabled' : ''; ?><?php echo $render_attrs($plus_attrs); ?>> |
| 98 |
<svg width="16" height="16" fill="none" stroke="currentColor" viewBox="0 0 24 24"> |
| 99 |
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/> |
| 100 |
</svg> |
| 101 |
</button> |
| 102 |
</div> |
| 103 |
</div> |
| 104 |
<?php endforeach; ?> |
| 105 |
</div> |
| 106 |
</div> |
| 107 |
|