File: /home/frenchy/refonte2023/wordpress/wp-content/themes/gimont/elementor/widgets/heading-icon.php
<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Utils;
use Elementor\Group_Control_Border;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
class Gimont_Elementor_Heading_Icon extends Widget_Base {
public function get_name() {
return 'gimont_elementor_heading_icon';
}
public function get_title() {
return esc_html__( 'Heading Icon', 'gimont' );
}
public function get_icon() {
return 'eicon-editor-h3';
}
public function get_categories() {
return [ 'gimont' ];
}
public function get_script_depends() {
return [ '' ];
}
// Add Your Controll In This Function
protected function register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => esc_html__( 'Content', 'gimont' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'title',
[
'label' => esc_html__( 'Title', 'gimont' ),
'type' => \Elementor\Controls_Manager::TEXTAREA,
'rows' => 3,
'default' => esc_html__( 'Download city government recent documents', 'gimont' ),
'placeholder' => esc_html__( 'Type your title here', 'gimont' ),
]
);
$this->add_control(
'title_align',
[
'label' => esc_html__( 'Title Alignment', 'gimont' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => esc_html__( 'Left', 'gimont' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'gimont' ),
'icon' => 'eicon-text-align-center',
],
'right' => [
'title' => esc_html__( 'Right', 'gimont' ),
'icon' => 'eicon-text-align-right',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .ova-heading-icon .title' => 'text-align: {{VALUE}};',
],
]
);
$this->add_control(
'icon',
[
'label' => esc_html__( 'Icon', 'gimont' ),
'type' => \Elementor\Controls_Manager::ICONS,
'default' => [
'value' => 'gimonticon gimonticon-file',
'library' => 'all',
],
]
);
$this->add_control(
'item_align',
[
'label' => esc_html__( 'Item Alignment', 'gimont' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => esc_html__( 'Left', 'gimont' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'gimont' ),
'icon' => 'eicon-text-align-center',
],
'flex-end' => [
'title' => esc_html__( 'Right', 'gimont' ),
'icon' => 'eicon-text-align-right',
],
],
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .ova-heading-icon .wrapper' => 'justify-content: {{VALUE}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'general_style_section',
[
'label' => esc_html__( 'General', 'gimont' ),
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'general_padding',
[
'label' => esc_html__( 'Padding', 'gimont' ),
'type' => \Elementor\Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'selectors' => [
'{{WRAPPER}} .ova-heading-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'general_background',
[
'label' => esc_html__( 'Background', 'gimont' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-heading-icon' => 'background: {{VALUE}}',
],
]
);
$this->end_controls_section();
/*Title*/
$this->start_controls_section(
'title_style_section',
[
'label' => esc_html__( 'Title', 'gimont' ),
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'title_margin',
[
'label' => esc_html__( 'Margin', 'gimont' ),
'type' => \Elementor\Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'selectors' => [
'{{WRAPPER}} .ova-heading-icon .title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'selector' => '{{WRAPPER}} .ova-heading-icon .title',
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Color', 'gimont' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-heading-icon .title' => 'color: {{VALUE}}',
],
]
);
$this->end_controls_section();
/*Icon*/
$this->start_controls_section(
'icon_style_section',
[
'label' => esc_html__( 'Icon', 'gimont' ),
'tab' => \Elementor\Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'icon_size',
[
'label' => esc_html__( 'Size', 'gimont' ),
'type' => \Elementor\Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 5,
],
'%' => [
'min' => 0,
'max' => 100,
],
],
'selectors' => [
'{{WRAPPER}} .ova-heading-icon .icon' => 'font-size: {{SIZE}}{{UNIT}};',
'{{WRAPPER}} .ova-heading-icon .icon svg' => 'width: {{SIZE}}{{UNIT}};height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'icon_color',
[
'label' => esc_html__( 'Color', 'gimont' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .ova-heading-icon .icon' => 'color: {{VALUE}}',
'{{WRAPPER}} .ova-heading-icon .icon svg' => 'fill: {{VALUE}}',
],
]
);
$this->end_controls_section();
}
// Render Template Here
protected function render() {
$settings = $this->get_settings();
$title = $settings['title'];
$icon = $settings['icon'];
?>
<div class="ova-heading-icon">
<div class="wrapper">
<h3 class="title"><?php echo esc_html( $title ); ?></h3>
<div class="icon">
<?php \Elementor\Icons_Manager::render_icon( $icon, [ 'aria-hidden' => 'true' ] ); ?>
</div>
</div>
</div>
<?php
}
}
$widgets_manager->register( new Gimont_Elementor_Heading_Icon() );