| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yatra\Core\Shortcodes; |
| 4 |
|
| 5 |
|
| 6 |
defined('ABSPATH') || exit; |
| 7 |
|
| 8 |
/** |
| 9 |
* Shortcode search class. |
| 10 |
*/ |
| 11 |
class Search |
| 12 |
{ |
| 13 |
|
| 14 |
/** |
| 15 |
* Get the shortcode content. |
| 16 |
* |
| 17 |
* @param array $atts Shortcode attributes. |
| 18 |
* @return string |
| 19 |
*/ |
| 20 |
public static function get($atts) |
| 21 |
{ |
| 22 |
return \Yatra_Shortcodes::shortcode_wrapper(array(__CLASS__, 'output'), $atts); |
| 23 |
} |
| 24 |
|
| 25 |
/** |
| 26 |
* Output the shortcode. |
| 27 |
* |
| 28 |
* @param array $atts Shortcode attributes. |
| 29 |
*/ |
| 30 |
public static function output($atts) |
| 31 |
{ |
| 32 |
$search_type = isset($atts['type']) ? sanitize_text_field($atts['type']) : 'advanced'; |
| 33 |
|
| 34 |
$duration = yatra_get_duration_ranges_for_filter(); |
| 35 |
|
| 36 |
$min_days = $duration->min_days ?? 0; |
| 37 |
|
| 38 |
$max_days = $duration->max_days ?? 0; |
| 39 |
|
| 40 |
$price = yatra_get_price_ranges_for_filter(); |
| 41 |
|
| 42 |
$min_price = $price->min_price ?? 0; |
| 43 |
|
| 44 |
$max_price = $price->max_price ?? 0; |
| 45 |
|
| 46 |
yatra_get_template('parts/advanced-search.php', |
| 47 |
[ |
| 48 |
'min_price' => $min_price, 'max_price' => $max_price, 'min_days' => $min_days, 'max_days' => $max_days, 'search_type' => $search_type |
| 49 |
] |
| 50 |
); |
| 51 |
wp_enqueue_script('yatra-search-script'); |
| 52 |
wp_enqueue_style('yatra-search-style'); |
| 53 |
|
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
} |
| 58 |
|