File: /mnt/data/dreamsrent-wp/wp-content/plugins/dreamsrent-widgets/widgets/class-heading1.php
<?php
namespace Dreamsrentelementor\Widgets;
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* Elementor Hello World
*
* Elementor widget for hello world.
*
* @since 1.0.0
*/
class DSR_heading1 extends Widget_Base {
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'dreamsrent_elementor_heading1';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'DR Heading 1', 'dreamsrent_elementor' );
}
/**
* Retrieve the widget icon.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'eicon-post-title';
}
/**
* 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_heading1' ];
}
/**
* 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' => __( 'Title', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'content',
[
'label' => __( 'Content', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
'default' => __( 'Sub Title', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'align',
[
'label' => __( 'Align', 'dreamsrent_elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'text-center',
'options' => [
'text-center' => __( 'Center', 'dreamsrent_elementor' ),
],
]
);
$this->add_control(
'style',
[
'label' => __( 'Style', 'dreamsrent_elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'dark',
'options' => [
'dark' => __( 'Dark', 'dreamsrent_elementor' ),
'white' => __( 'White', 'dreamsrent_elementor' ),
],
]
);
$this->add_control(
'class',
[
'label' => __( 'Class', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
]
);
$this->end_controls_section();
// Style: Title
$this->start_controls_section(
'heading1_title_style',
[
'label' => __( 'Title', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'heading1_title_color',
[
'label' => __( 'Text Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .section-heading h2' => 'color: {{VALUE}};',
'{{WRAPPER}} .section-heading .title' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'heading1_title_typography',
'label' => __( 'Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .section-heading h2, {{WRAPPER}} .section-heading .title',
]
);
$this->add_responsive_control(
'heading1_title_margin',
[
'label' => __( 'Margin', 'dreamsrent_elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .section-heading h2, {{WRAPPER}} .section-heading .title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'heading1_title_padding',
[
'label' => __( 'Padding', 'dreamsrent_elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .section-heading h2, {{WRAPPER}} .section-heading .title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
// Style: Subtitle / Content
$this->start_controls_section(
'heading1_content_style',
[
'label' => __( 'Subtitle', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'heading1_content_color',
[
'label' => __( 'Text Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .section-heading p' => 'color: {{VALUE}};',
'{{WRAPPER}} .section-heading .description' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'heading1_content_typography',
'label' => __( 'Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .section-heading p, {{WRAPPER}} .section-heading .description',
]
);
$this->add_responsive_control(
'heading1_content_margin',
[
'label' => __( 'Margin', 'dreamsrent_elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .section-heading p, {{WRAPPER}} .section-heading .description' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'heading1_content_padding',
[
'label' => __( 'Padding', 'dreamsrent_elementor' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .section-heading p, {{WRAPPER}} .section-heading .description' => '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="section-heading <?php echo $settings['align']; ?>" data-aos="fade-down">
<?php if($settings['style']=='dark') { ?>
<h2><?php echo $settings['title']; ?></h2>
<p><?php echo $settings['content']; ?></p>
<?php } else { ?>
<h2 class="title text-white"><?php echo $settings['title']; ?></h2>
<p class="description text-white"><?php echo $settings['content']; ?></p>
<?php } ?>
</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="dreamsrent_elementor_heading1 {{{ settings.class }}} {{{ settings.align }}} ">
<h3 class="title">{{{ settings.title }}} </h3>
<div class="desc">{{{ settings.content }}}</div>
</div>
<?php
}
}