File: /mnt/data/dreamstour-wp/wp-content/plugins/dreamstour-widgets/widgets/class-hero-banner-2.php
<?php
namespace Dreamstourelementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use \Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit;
class DTS_hero_banner_two extends Widget_Base {
public function get_name() {
return 'dreamstour_elementor_hero_banner_two';
}
public function get_title() {
return __( 'Dreams Tours Hero Banner 2', 'dreamstour_elementor' );
}
public function get_icon() {
return 'eicon-banner';
}
public function get_categories() {
return [ 'dreamstourelemetortheme' ];
}
public function get_script_depends() {
return [ 'dreamstourelementor-elementor' ];
}
protected function register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => __( 'Content', 'dreamstour_elementor' ),
]
);
$this->add_control(
'title',
[
'label' => __( 'Title', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Booking a tour can be an exciting way to <br> explore a new destination!', 'dreamstour_elementor' ),
]
);
$this->add_control(
'subtitle',
[
'label' => __( 'Subtitle', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Your ultimate destination for all things help you celebrate & remember tour experience.', 'dreamstour_elementor' ),
]
);
$this->add_control(
'background_image',
[
'label' => __( 'Background Image', 'dreamstour_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [ 'url' => Utils::get_placeholder_image_src() ],
]
);
$this->add_control(
'search_page_url',
[
'label' => __( 'Search Results Page URL', 'dreamstour_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => '/tour-list/',
'description' => __( 'Enter the URL where search results should be displayed', 'dreamstour_elementor' ),
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings();
$search_page_url = !empty($settings['search_page_url']) ? $settings['search_page_url'] : '/tour-list/';
?>
<!-- Hero Section -->
<section class="hero-sec-six" style="background-image: url('<?php echo esc_url( !empty($settings['background_image']['url']) ? $settings['background_image']['url'] : '' ); ?>');">
<div class="container">
<div class="hero-content">
<div class="row align-items-center">
<div class="col-md-12">
<div class="banner-content wow fadeInUp mb-4" data-wow-delay="0.3">
<h1 class="text-white display-5 mb-2"><?php echo wp_kses_post( $settings['title'] ); ?></h1>
<p class="text-white"><?php echo esc_html( $settings['subtitle'] ); ?></p>
</div>
<div class="banner-form card mb-0">
<div class="card-body">
<div class="banner-form">
<form class="d-lg-flex" id="tour-search-form" action="<?php echo esc_url(home_url($search_page_url)); ?>" method="get">
<div class="d-flex form-info">
<div class="form-item dropdown">
<div data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false" role="menu">
<label class="form-label fs-14 text-default mb-1"><?php esc_html_e('Where would like to go?', 'dreamstour_elementor' ); ?></label>
<input type="text" class="form-control" name="destination" value="<?php echo isset($_GET['destination']) ? esc_attr($_GET['destination']) : ''; ?>" placeholder="Enter destination">
<p class="fs-12 mb-0"><?php esc_html_e('Enter destination', 'dreamstour_elementor' ); ?></p>
</div>
</div>
<div class="form-item">
<label class="form-label fs-14 text-default mb-1"><?php esc_html_e('Check In', 'dreamstour_elementor' ); ?></label>
<input type="text" class="form-control datetimepicker" name="check_in" value="<?php echo isset($_GET['check_in']) ? esc_attr($_GET['check_in']) : ''; ?>" placeholder="Check-in date">
<p class="fs-12 mb-0"><?php esc_html_e('Select date', 'dreamstour_elementor' ); ?></p>
</div>
<div class="form-item dropdown">
<div data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false" role="menu">
<label class="form-label fs-14 text-default mb-1"><?php esc_html_e('Duration (Days)', 'dreamstour_elementor'); ?></label>
<input type="text" class="form-control" id="durationInput" name="duration" placeholder="<?php esc_attr_e('Select duration', 'dreamstour_elementor'); ?>" readonly value="<?php echo isset($_GET['duration']) ? esc_attr($_GET['duration']) : ''; ?>">
<input type="hidden" id="durationIdInput" name="tour_duration_days" value="<?php echo isset($_GET['tour_duration_days']) ? esc_attr($_GET['tour_duration_days']) : ''; ?>">
<p class="fs-12 mb-0"><?php esc_html_e('Select duration in days', 'dreamstour_elementor'); ?></p>
</div>
<div class="dropdown-menu dropdown-md p-0">
<ul id="durationList">
<!-- Add an option to clear selection -->
<li class="border-bottom">
<a class="dropdown-item" href="javascript:void(0);" data-value="" data-name=""><?php esc_html_e('Clear selection', 'dreamstour_elementor'); ?></a>
</li>
<?php
// ✅ Fetch all duration terms
$duration_days = get_terms(array(
'taxonomy' => 'tour_duration_days',
'hide_empty' => false,
));
if (!empty($duration_days) && !is_wp_error($duration_days)) {
// ✅ Sort numerically by number in term name (e.g., 1 Day, 2 Days...)
usort($duration_days, function ($a, $b) {
$a_num = (int) filter_var($a->name, FILTER_SANITIZE_NUMBER_INT);
$b_num = (int) filter_var($b->name, FILTER_SANITIZE_NUMBER_INT);
return $a_num - $b_num;
});
// ✅ Display sorted list
foreach ($duration_days as $term) {
$selected = (isset($_GET['tour_duration_days']) && $_GET['tour_duration_days'] == $term->term_id) ? 'selected' : '';
echo '<li class="border-bottom">
<a class="dropdown-item ' . esc_attr($selected) . '" href="javascript:void(0);"
data-value="' . esc_attr($term->term_id) . '"
data-name="' . esc_attr($term->name) . '">' . esc_html($term->name) . '</a>
</li>';
}
}
?>
</ul>
</div>
</div>
<div class="form-item dropdown w-100">
<div data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false" role="menu" class="w-100">
<label class="form-label fs-14 text-default mb-1"><?php esc_html_e('Travellers', 'dreamstour_elementor' ); ?></label>
<h6 class="mb-0"><span class="traveller-count"><?php echo isset($_GET['travellers']) ? intval($_GET['travellers']) : 1; ?></span> <span class="fw-normal fs-14"><?php esc_html_e('Persons', 'dreamstour_elementor' ); ?></span></h6>
<p class="fs-12 mb-0"><span class="adult-count"><?php echo isset($_GET['adults']) ? intval($_GET['adults']) : 1; ?></span> Adult</p>
<input type="hidden" name="travellers" id="travellers-input" value="<?php echo isset($_GET['travellers']) ? intval($_GET['travellers']) : 1; ?>">
<input type="hidden" name="adults" id="adults-input" value="<?php echo isset($_GET['adults']) ? intval($_GET['adults']) : 1; ?>">
<input type="hidden" name="children" id="children-input" value="<?php echo isset($_GET['children']) ? intval($_GET['children']) : 0; ?>">
<input type="hidden" name="infants" id="infants-input" value="<?php echo isset($_GET['infants']) ? intval($_GET['infants']) : 0; ?>">
</div>
<!-- Traveller dropdown menu -->
<div class="dropdown-menu dropdown-menu-end dropdown-xl p-3">
<h5 class="mb-3"><?php esc_html_e('Select Travelers & Class', 'dreamstour_elementor' ); ?></h5>
<!-- Adults -->
<div class="mb-3 border br-10 info-item pb-1">
<div class="col-md-12">
<div class="mb-3 d-flex align-items-center justify-content-between">
<label class="form-label text-gray-9 mb-2"><?php esc_html_e('Adults', 'dreamstour_elementor' ); ?></label>
<div class="custom-increment">
<div class="input-group">
<span class="input-group-btn float-start">
<button type="button" class="quantity-left-minus btn btn-light btn-number" data-type="minus" data-field="adults">
<span><i class="isax isax-minus"></i></span>
</button>
</span>
<input type="text" name="adults_count" class="input-number adults-count" value="<?php echo isset($_GET['adults']) ? intval($_GET['adults']) : 1; ?>" min="1" max="20">
<span class="input-group-btn float-end">
<button type="button" class="quantity-right-plus btn btn-light btn-number" data-type="plus" data-field="adults">
<span><i class="isax isax-add"></i></span>
</button>
</span>
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="mb-3 d-flex align-items-center justify-content-between">
<label class="form-label text-gray-9 mb-2"><?php esc_html_e('Children', 'dreamstour_elementor' ); ?> <span class="text-default fw-normal">(<?php esc_html_e(' 2-12 Yrs', 'dreamstour_elementor' ); ?> )</span></label>
<div class="custom-increment">
<div class="input-group">
<span class="input-group-btn float-start">
<button type="button" class="quantity-left-minus btn btn-light btn-number" data-type="minus" data-field="children">
<span><i class="isax isax-minus"></i></span>
</button>
</span>
<input type="text" name="children_count" class="input-number children-count" value="<?php echo isset($_GET['children']) ? intval($_GET['children']) : 0; ?>" min="0" max="10">
<span class="input-group-btn float-end">
<button type="button" class="quantity-right-plus btn btn-light btn-number" data-type="plus" data-field="children">
<span><i class="isax isax-add"></i></span>
</button>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="d-flex justify-content-end">
<a href="javascript:void(0);" class="btn btn-light btn-sm me-2 cancel-travellers"><?php esc_html_e('Cancel', 'dreamstour_elementor' ); ?></a>
<button type="button" class="btn btn-primary btn-sm apply-travellers"><?php esc_html_e('Apply', 'dreamstour_elementor' ); ?></button>
</div>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary search-btn rounded"><?php esc_html_e('Search', 'dreamstour_elementor' ); ?></button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- /Hero Section -->
<?php
}
}