File: /mnt/data/dreamsrent-wp/wp-content/plugins/dreamsrent-widgets/widgets/class-howworks.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_howworks extends Widget_Base {
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'dreamsrent_elementor_howworks';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'DR How works box', '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" => __( 'Business rental', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'style',
[
'label' => __( 'Style', 'dreamsrent_elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'secondary',
'options' => [
'secondary' => __( 'Style 1', 'dreamsrent_elementor' ),
'warning' => __( 'Style 2', 'dreamsrent_elementor' ),
'dark' => __( 'Style 3', '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' => __( 'Description', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXTAREA,
"default" => __( 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque ', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'class',
[
'label' => __( 'Class', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
]
);
$this->end_controls_section();
// Style: Title
$this->start_controls_section(
'howworks_title_style',
[
'label' => __( 'Title', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'howworks_title_color',
[
'label' => __( 'Text Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .services-group .services-content h3' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'howworks_title_typography',
'label' => __( 'Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .services-group .services-content h3',
]
);
$this->add_responsive_control(
'howworks_title_margin',
[
'label' => __( 'Margin', 'dreamsrent_elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .services-group .services-content h3' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'howworks_title_padding',
[
'label' => __( 'Padding', 'dreamsrent_elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .services-group .services-content h3' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
// Style: Description
$this->start_controls_section(
'howworks_desc_style',
[
'label' => __( 'Description', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'howworks_desc_color',
[
'label' => __( 'Text Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .services-group .services-content p' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'howworks_desc_typography',
'label' => __( 'Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .services-group .services-content p',
]
);
$this->add_responsive_control(
'howworks_desc_margin',
[
'label' => __( 'Margin', 'dreamsrent_elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .services-group .services-content p' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'howworks_desc_padding',
[
'label' => __( 'Padding', 'dreamsrent_elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .services-group .services-content p' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$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="services-group">
<div class="services-icon border-<?php echo $settings['style']; ?> ">
<img class="icon-img bg-<?php echo $settings['style']; ?>" src="<?php echo $settings['img']['url']; ?>" alt="">
</div>
<div class="services-content">
<h3><?php echo $settings['title']; ?></h3>
<p><?php echo $settings['desc']; ?></p>
</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
}
}