File: /mnt/data/dreamsrent-wp-demo/wp-content/plugins/dreamsrent-widgets/widgets/class-contactform.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_contactform extends Widget_Base {
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'dreamsrent_elementor_contactform';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'DR Contact Form', 'dreamsrent_elementor' );
}
/**
* Retrieve the widget icon.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'eicon-icon-box';
}
/**
* 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(
'title',
[
'label' => __( 'Title', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
"default" => __( 'Get in touch!', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'img',
[
'label' => __( 'Image', 'dreamsrent_elementor' ),
'type' => Controls_Manager::MEDIA,
'default' => [
'url' => Utils::get_placeholder_image_src(),
],
]
);
$this->add_control(
'desc',
[
'label' => __( 'Contact Form Short code', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXTAREA,
"default" => __( '', 'dreamsrent_elementor' ),
]
);
$this->end_controls_section();
// Style tab: Title
$this->start_controls_section(
'contactform_title_style',
[
'label' => __( 'Title', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'contactform_title_color',
[
'label' => __( 'Title Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .form-info-area h1' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'contactform_title_typography',
'label' => __( 'Title Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .form-info-area h1',
]
);
$this->end_controls_section();
// Style tab: Content
$this->start_controls_section(
'contactform_content_style',
[
'label' => __( 'Content', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'contactform_content_color',
[
'label' => __( 'Content Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .form-info-area' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'contactform_content_typography',
'label' => __( 'Content Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .form-info-area',
]
);
$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(); ?>
<div class="container">
<div class="contact-section pt-0">
<div class="form-info-area" data-aos="fade-down" data-aos-duration="1200" data-aos-delay="0.5">
<div class="row">
<div class="col-lg-6 d-flex">
<img src="<?php echo esc_url( $settings['img']['url'] ); ?>" class="img-fluid" alt="<?php echo esc_attr__( 'Contact', 'dreamsrent_elementor' ); ?>">
</div>
<div class="col-lg-6">
<h1><?php echo esc_html( $settings['title'] ); ?></h1>
<?php echo esc_html( $settings['desc'] ); ?>
</div>
</div>
</div>
</div>
</div>
<?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>
</div>
</div>
<?php
}
}