Files
2024-11-04 20:48:19 +01:00

464 lines
17 KiB
PHP

<?php namespace Elementor;
class restly_contactinfo_box_Widget extends Widget_Base {
public function get_name() {
return 'restly_contactinfo_box';
}
public function get_title() {
return esc_html__( 'Restly Contact Info Box', 'restlycore' );
}
public function get_icon() {
return ' eicon-posts-carousel';
}
public function get_categories() {
return ['restly'];
}
protected function register_controls() {
//Content tab start
$this->start_controls_section(
'restly_contactinfo_box_options',
[
'label' => esc_html__( 'Restly Contact Info Box', 'restlycore' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'restly_contactinfo_box_icons',
[
'label' => esc_html__( 'Icon', 'restlycore' ),
'type' => \Elementor\Controls_Manager::ICONS,
]
);
$this->add_control(
'restly_contactinfo_box_editor',
[
'label' => esc_html__( 'Info', 'restlycore' ),
'type' => \Elementor\Controls_Manager::WYSIWYG,
'default' => __( '<p>27 Division St, New York,
NY 10002,USA</p>', 'restlycore' ),
]
);
$this->add_control(
'restly_contactinfo_line_show',
[
'label' => esc_html__( 'Show Line', 'restlycore' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'restlycore' ),
'label_off' => esc_html__( 'Hide', 'restlycore' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->end_controls_section();
$this->start_controls_section(
'restly_cinfo_box_CSS_box_options',
[
'label' => esc_html__( ' Box', 'restlycore' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'restly_cinfo_box_CSS_box_align',
[
'label' => __( 'Alignment', 'restlycore' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'restlycore' ),
'icon' => 'fa fa-align-left',
],
'center' => [
'title' => __( 'Center', 'restlycore' ),
'icon' => 'fa fa-align-center',
],
'right' => [
'title' => __( 'Right', 'restlycore' ),
'icon' => 'fa fa-align-right',
],
],
'default' => 'center',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .restly-contact-info-box' => 'text-align: {{VALUE}}',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Background::get_type(),
[
'name' => 'restly_cinfo_box_CSS_box_bg',
'label' => esc_html__( 'Background', 'restlycore' ),
'types' => [ 'classic', 'gradient', 'video' ],
'selector' => '{{WRAPPER}} .restly-contact-info-box',
]
);
$this->add_group_control(
\Elementor\Group_Control_Box_Shadow::get_type(),
[
'name' => 'restly_cinfo_box_CSS_box_shadow',
'label' => esc_html__( 'Box Shadow', 'restlycore' ),
'selector' => '{{WRAPPER}} .restly-contact-info-box',
]
);
$this->add_group_control(
\Elementor\Group_Control_Border::get_type(),
[
'name' => 'restly_cinfo_box_CSS_box_border',
'label' => esc_html__( 'Border', 'restlycore' ),
'selector' => '{{WRAPPER}} .restly-contact-info-box',
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_box_radius',
[
'label' => esc_html__( 'Border Radius', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .restly-contact-info-box' => 'border-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_box_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-contact-info-box' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_box_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-contact-info-box' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'restly_cinfo_box_CSS_content_options',
[
'label' => esc_html__( 'Content', 'restlycore' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->start_controls_tabs(
'restly_cinfo_box_content_tabs'
);
$this->start_controls_tab(
'restly_cinfo_box_tabs_icon',
[
'label' => __( 'icon', 'restlycore' ),
]
);
$this->add_responsive_control(
'restly_cinfo_box_icon_color',
[
'label' => esc_html__( 'Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-icon i' => 'color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_icon_size',
[
'label' => esc_html__( 'Icon SIze', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
]
],
'default' => [
'unit' => 'px',
'size' => 40,
],
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-icon i' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_icon_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-icon i' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_icon_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-icon i' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'restly_cinfo_box_tabs_dec',
[
'label' => __( 'Content', 'restlycore' ),
]
);
$this->add_responsive_control(
'restly_cinfo_box_dec_color',
[
'label' => esc_html__( 'Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-dec' => 'color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_dec_acolor',
[
'label' => esc_html__( 'Link Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-dec a' => 'color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_dec_ahcolor',
[
'label' => esc_html__( 'Link Hover Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-dec a:hover' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'restly_cinfo_box_dec_typo',
'label' => esc_html__( 'Typography', 'restlycore' ),
'selector' => '{{WRAPPER}} .restly-cinfo-box-dec',
]
);
$this->add_responsive_control(
'restly_cinfo_box_dec_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-dec' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_dec_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-cinfo-box-dec' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
$this->start_controls_section(
'restly_cinfo_box_CSS_line_options',
[
'label' => esc_html__( 'Line', 'restlycore' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_line_bg',
[
'label' => esc_html__( 'Background Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .cinfo-line' => 'background-color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_line_width',
[
'label' => esc_html__( 'Width', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'unit' => 'px',
'size' => 90,
],
'selectors' => [
'{{WRAPPER}} .cinfo-line' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_line_height',
[
'label' => esc_html__( 'Height', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'range' => [
'px' => [
'min' => 0,
'max' => 300,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'default' => [
'unit' => 'px',
'size' => 113,
],
'selectors' => [
'{{WRAPPER}} .cinfo-line' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_line_left',
[
'label' => esc_html__( 'Left To Right', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'range' => [
'px' => [
'min' => -200,
'max' => 200,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .cinfo-line' => 'right: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_line_top',
[
'label' => esc_html__( 'Top To Bottom', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%' ],
'range' => [
'px' => [
'min' => -200,
'max' => 200,
'step' => 1,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .cinfo-line' => 'top: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_cinfo_box_CSS_line_roted',
[
'label' => esc_html__( 'Rotate', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 360,
'step' => 1,
],
],
'selectors' => [
'{{WRAPPER}} .cinfo-line' => 'transform: rotate({{SIZE}}deg);',
],
'condition' => [
'restly_contactinfo_line_show' => 'yes',
],
]
);
$this->end_controls_section();
}
//Render
protected function render() {
$settings = $this->get_settings_for_display();
ob_start();
?>
<div class="restly-contactinfo-box-wrapper">
<div class="restly-contact-info-box">
<div class="restly-cinfo-box-icon">
<i class="<?php echo esc_attr($settings['restly_contactinfo_box_icons']['value']); ?>"></i>
</div>
<div class="restly-cinfo-box-dec">
<?php echo wp_kses_post($settings['restly_contactinfo_box_editor']); ?>
</div>
<?php if($settings['restly_contactinfo_line_show'] == 'yes'){
echo '<div class="cinfo-line"></div>';
} ?>
</div>
</div>
<?php
echo ob_get_clean();
}
}
Plugin::instance()->widgets_manager->register( new restly_contactinfo_box_Widget );