File: /mnt/data/dreamsrent-wp/wp-content/plugins/dreamsrent-widgets/widgets/class-contactbox.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_contactbox extends Widget_Base {
/**
* Retrieve the widget name.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'dreamsrent_elementor_contactbox';
}
/**
* Retrieve the widget title.
*
* @since 1.0.0
*
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return __( 'DR Contact 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' ];
}
/**
* 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(
'icon_style',
[
'label' => __( 'Icon Style', 'dreamsrent_elementor' ),
'type' => Controls_Manager::SELECT,
'default' => 'feather-phone-call',
'options' => [
'feather-phone-call' => __( 'Phone', 'dreamsrent_elementor' ),
'feather-mail' => __( 'Email', 'dreamsrent_elementor' ),
'feather-map-pin' => __( 'Map', 'dreamsrent_elementor' ),
'feather-clock' => __( 'Clock', 'dreamsrent_elementor' ),
],
]
);
$this->add_control(
'title',
[
'label' => __( 'Title', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXT,
"default" => __( 'Phone Number', 'dreamsrent_elementor' ),
]
);
$this->add_control(
'desc',
[
'label' => __( 'Description', 'dreamsrent_elementor' ),
'type' => Controls_Manager::TEXTAREA,
"default" => __( '(888) 888-8888', 'dreamsrent_elementor' ),
]
);
$this->end_controls_section();
// Style tab: Title
$this->start_controls_section(
'contactbox_title_style',
[
'label' => __( 'Title', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'contactbox_title_color',
[
'label' => __( 'Title Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-contact-info h3' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'contactbox_title_typography',
'label' => __( 'Title Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .single-contact-info h3',
]
);
$this->end_controls_section();
// Style tab: Description / Link
$this->start_controls_section(
'contactbox_desc_style',
[
'label' => __( 'Description', 'dreamsrent_elementor' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'contactbox_desc_color',
[
'label' => __( 'Description Color', 'dreamsrent_elementor' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .single-contact-info a' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'contactbox_desc_typography',
'label' => __( 'Description Typography', 'dreamsrent_elementor' ),
'selector' => '{{WRAPPER}} .single-contact-info a',
]
);
$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="contact-info-area">
<div class="single-contact-info flex-fill">
<span><i class="<?php echo esc_attr( $settings['icon_style'] ); ?>"></i></span>
<h3><?php echo esc_html( $settings['title'] ); ?></h3>
<?php if ( $settings['icon_style'] == 'feather-phone-call' ) { ?>
<a href="tel:<?php echo esc_attr( $settings['desc'] ); ?>"><?php echo esc_html( $settings['desc'] ); ?></a>
<?php } elseif ( $settings['icon_style'] == 'feather-mail' ) { ?>
<a href="mailto:<?php echo esc_attr( $settings['desc'] ); ?>"><?php echo esc_html( $settings['desc'] ); ?></a>
<?php } else { ?>
<a href="javascript:void(0);"><?php echo esc_html( $settings['desc'] ); ?></a>
<?php } ?>
</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() {
?>
<?php
}
}