File: /mnt/data/dreamsrent-wp-demo/wp-content/plugins/dreamsrent-widgets/widgets/class-banner.php
<?php
namespace Dreamsrentelementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use \Elementor\Utils;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Elementor Hello World
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class DSR_banner extends Widget_Base {
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'dreamsrent_elementor_banner';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'DR Home Banner', 'dreamsrent_elementor' );
}
/**
* Retrieve the widget icon.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'eicon-banner';
}
/**
* Retrieve the list of categories the widget belongs to.
*
* Used to determine where to display the widget in the editor.
*
* Note that currently Elementor supports only one category.
* When multiple categories passed, Elementor uses the first one.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget categories.
*/
public function get_categories() {
return [ 'dreamsrentelemetortheme' ];
}
/**
* Retrieve the list of scripts the widget depended on.
*
* Used to set scripts dependencies required to run the widget.
*
* @since 1.0.0
*
* @access public
*
* @return array Widget scripts dependencies.
*/
public function get_script_depends() {
return [ 'dreamsrent_elementor_service_card' ];
}
/**
* Register the widget controls.
*
* Adds different input fields to allow the user to change and customize the widget settings.
*
* @since 1.0.0
*
* @access protected
*/
protected function register_controls() {
$this->start_controls_section(
'section_content',
[
'label' => __( 'Content', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'subtitle',
[
'label' => __( 'Sub-Title', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
"default" => __( '100% Trusted car rental platform in the World', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'title',
[
'label' => __( 'Title', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
"default" => __( 'Find Your Best', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'title1',
[
'label' => __( 'Title 1', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
"default" => __( 'Dream Car for Rental', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'desc',
[
'label' => __( 'Description', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXTAREA,
"default" => __( 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'background',
[
'label' => __( 'Background Image', 'dreamsrent_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'img',
[
'label' => __( 'Image', 'dreamsrent_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'btn_text',
[
'label' => __( 'Text', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
"default" => __( 'View All Cars', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'btn_link',
[
'label' => __( 'Link', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
"default" => '#',
]
);
$this->add_control(
'class',
[
'label' => __( 'Class', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
]
);
$this->add_control(
'show_search_section',
[
'label' => __( 'Show Search Section', 'dreamsrent_elementor' ),
'type' => Controls_Manager::SWITCHER,
'label_on' => __( 'Show', 'dreamsrent_elementor' ),
'label_off' => __( 'Hide', 'dreamsrent_elementor' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->end_controls_section();
// Style tab: Subtitle
$this->start_controls_section(
'banner_subtitle_style',
[
'label' => __( 'Subtitle', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'banner_subtitle_color',
[
'label' => __( 'Text Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .banner-section .explore-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'banner_subtitle_typography',
'label' => __( 'Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .banner-section .explore-text',
]
);
$this->end_controls_section();
// Style tab: Title
$this->start_controls_section(
'banner_title_style',
[
'label' => __( 'Title', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'banner_title_color',
[
'label' => __( 'Text Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .banner-section h1' => 'color: {{VALUE}};',
'{{WRAPPER}} .banner-section h1 span' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'banner_title_typography',
'label' => __( 'Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .banner-section h1, {{WRAPPER}} .banner-section h1 span',
]
);
$this->end_controls_section();
// Style tab: Description
$this->start_controls_section(
'banner_desc_style',
[
'label' => __( 'Description', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'banner_desc_color',
[
'label' => __( 'Text Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .banner-section .home-banner p' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'banner_desc_typography',
'label' => __( 'Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .banner-section .home-banner p',
]
);
$this->end_controls_section();
// Style tab: Button
$this->start_controls_section(
'banner_button_style',
[
'label' => __( 'Button', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'banner_button_bg_color',
[
'label' => __( 'Background Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .banner-section .btn-view' => 'background-color: {{VALUE}};',
],
]
);
$this->add_control(
'banner_button_text_color',
[
'label' => __( 'Text Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .banner-section .btn-view' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'banner_button_typography',
'label' => __( 'Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .banner-section .btn-view',
]
);
$this->end_controls_section();
}
/**
* Render the widget output on the frontend.
*
* Written in PHP and used to generate the final HTML.
*
* @since 1.0.0
*
* @access protected
*/
protected function render() {
$settings = $this->get_settings();
$home_search_page = dreamsrent_fl_framework_getoptions('home_search_page');
?>
<section class="banner-section banner-slider" style="background-image: url('<?php echo esc_url( $settings['background']['url'] ); ?>');">
<div class="container">
<div class="home-banner">
<div class="row align-items-center">
<div class="col-lg-6" data-aos="fade-down">
<p class="explore-text"> <span><i class="fa-solid fa-thumbs-up me-2"></i></span><?php echo $settings['subtitle']; ?></p>
<h1><?php echo $settings['title']; ?> <br>
<span><?php echo $settings['title1']; ?></span></h1>
<p><?php echo $settings['desc']; ?></p>
<div class="view-all">
<a href="<?php echo $settings['btn_link']; ?>" class="btn btn-view d-inline-flex align-items-center"><?php echo $settings['btn_text']; ?> <span><i class="feather-arrow-right ms-2"></i></span></a>
</div>
</div>
<div class="col-lg-6" data-aos="fade-down">
<div class="banner-imgs">
<img src="<?php echo esc_url( $settings['img']['url'] ); ?>" class="img-fluid aos" alt="<?php echo esc_attr__( 'Banner image', 'dreamsrent_elementor' ); ?>">
</div>
</div>
</div>
</div>
</div>
</section>
<?php if ( 'yes' === $settings['show_search_section'] ) : ?>
<div class="section-search">
<div class="container-fluid">
<div class="search-box-banner">
<?php
$wp_query = new \WP_Query(
array(
'post_type' => 'rental',
'post_status' => 'publish',
'posts_per_page' => '-1'
)
);
?>
<form id="searchForm" method="get" action="<?php echo get_permalink($home_search_page); ?>" >
<ul class="align-items-center">
<li class="column-group-main">
<div class="input-block">
<label><?php echo esc_html__('Pickup Location', 'dreamsrent_elementor'); ?></label>
<div class="group-img">
<select name="location" class="select form-control">
<option value=""><?php echo esc_html__('All Location', 'dreamsrent_elementor'); ?></option>
<?php
$terms = get_terms(array(
'taxonomy' => 'location',
'hide_empty' => false,
));
foreach ($terms as $term) {
?>
<option value="<?php echo esc_attr($term->name); ?>"><?php echo esc_html($term->name); ?></option>
<?php
}
?>
</select>
<span><i class="feather-map-pin"></i></span>
</div>
</div>
</li>
<li class="column-group-main">
<div class="input-block">
<label><?php echo esc_html__('Drop Location', 'dreamsrent_elementor'); ?></label>
<div class="group-img">
<select name="location_drop" class="select form-control">
<option value=""><?php echo esc_html__('All Location', 'dreamsrent_elementor'); ?></option>
<?php
$terms = get_terms(array(
'taxonomy' => 'location',
'hide_empty' => false,
));
foreach ($terms as $term) {
?>
<option value="<?php echo esc_attr($term->name); ?>"><?php echo esc_html($term->name); ?></option>
<?php
}
?>
</select>
<span><i class="feather-map-pin"></i></span>
</div>
</div>
</li>
<!-- <li class="column-group-main">
<div class="input-block date-widget">
<label><?php echo esc_html__('Pickup Date', 'dreamsrent_elementor'); ?></label>
<div class="group-img">
<input type="text" name="pickup_date" id="pickup_date" class="form-control datetimepicker" >
<span><i class="feather-calendar"></i></span>
</div>
</div>
</li>
<li class="column-group-main">
<div class="input-block date-widget">
<label><?php echo esc_html__('Return Date', 'dreamsrent_elementor'); ?></label>
<div class="group-img">
<input type="text" name="return_date" id="enddatePicker" class="form-control datetimepicker" placeholder="">
<span><i class="feather-calendar"></i></span>
</div>
</div>
</li> -->
<li class="column-group-main">
<div class="input-block date-widget">
<label><?php echo esc_html__('Pickup Date', 'dreamsrent_elementor'); ?></label>
<div class="group-img">
<input type="text" name="pickup_date" id="startdatePickerhome" class="form-control datetimepicker">
<span><i class="feather-calendar"></i></span>
</div>
</div>
</li>
<li class="column-group-main">
<div class="input-block time-widget">
<label><?php echo esc_html__('Pickup Time', 'dreamsrent_elementor'); ?></label>
<div class="group-img">
<input type="text" name="pickup_time" id="starttimePickerhome" class="form-control timepicker">
<span><i class="feather-clock"></i></span>
</div>
</div>
</li>
<li class="column-group-main">
<div class="input-block date-widget">
<label><?php echo esc_html__('Return Date', 'dreamsrent_elementor'); ?></label>
<div class="group-img">
<input type="text" name="return_date" id="enddatePickerHome" class="form-control datetimepicker" placeholder="">
<span><i class="feather-calendar"></i></span>
</div>
</li>
<li class="column-group-main">
<div class="input-block time-widget">
<label><?php echo esc_html__('Return Time', 'dreamsrent_elementor'); ?></label>
<div class="group-img">
<input type="text" name="return_time" id="endtimePickerhome" class="form-control timepicker">
<span><i class="feather-clock"></i></span>
</div>
</div>
</li>
<li class="column-group-last">
<div class="input-block pl-0">
<div class="search-btn">
<button class="btn search-button" type="submit"> <i class="fa fa-search" aria-hidden="true"></i><?php echo esc_html__('Search', 'dreamsrent_elementor') ?></button>
</div>
</div>
</li>
</ul>
</form>
</div>
</div>
</div>
<?php endif; ?>
<?php
}
/**
* Render the widget output in the editor.
*
* Written as a Backbone JavaScript template and used to generate the live preview.
*
* @since 1.0.0
*
* @access protected
*/
protected function content_template() {
?>
<div class="dreamsrentelementor_service_card {{{ settings.class }}} ">
<img src="{{{ settings.img.url }}}"></img>
<div class="content ">
<h3 class="title">{{{ settings.title }}}</h3>
<div class="desc">{{{ settings.desc }}}</div>
<a class="dreamsrentelementor_btn dreamsrentelementor_tran" href="{{{ settings.btn_link }}}">{{{ settings.btn_text }}}</a>
</div>
</div>
<?php
}
}