<?php
/**
* Elementor Single Widget
* @package Prinox Tools
* @since 1.0.0
*/
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
class Prinox_Cta extends Widget_Base {
/**
* Get widget name.
*
* Retrieve Elementor widget name.
*
* @since 1.0.0
* @access public
*
* @return string Widget name.
*/
public function get_name() {
return 'prionx-cta--id';
}
/**
* Get widget title.
*
* Retrieve Elementor widget title.
*
* @since 1.0.0
* @access public
*
* @return string Widget title.
*/
public function get_title() {
return esc_html__( 'Prinox CTA', 'prinox-tools' );
}
/**
* Get widget icon.
*
* Retrieve Elementor widget icon.
*
* @since 1.0.0
* @access public
*
* @return string Widget icon.
*/
public function get_icon() {
return 'mg-custom-icon';
}
/**
* Get widget categories.
*
* Retrieve the list of categories the Elementor widget belongs to.
*
* @since 1.0.0
* @access public
*
* @return array Widget categories.
*/
public function get_categories() {
return [ 'prinox_widgets' ];
}
protected function register_controls() {
$this->start_controls_section(
'prinox_faq_option',
[
'label' => esc_html__( 'FAQ Option', 'prinox-tools' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'title-bg',
'label' => esc_html__( 'Background', 'prinox-tools' ),
'types' => [ 'classic' ],
'exclude' => [ 'color' ],
'selector' => '{{WRAPPER}} .cta-section h2 span:before',
]
);
$this->add_control(
'title', [
'label' => esc_html__( 'Title', 'prinox-tools' ),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
]
);
$this->add_control(
'description', [
'label' => esc_html__( 'Description', 'prinox-tools' ),
'type' => Controls_Manager::TEXTAREA,
'label_block' => true,
]
);
$repeater = new Repeater();
$repeater->add_control(
'title', [
'label' => esc_html__( 'Title', 'prinox-tools' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$repeater->add_control(
'number', [
'label' => esc_html__( 'Number', 'prinox-tools' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$repeater->add_control(
'symbole', [
'label' => esc_html__( 'Symbole', 'prinox-tools' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$this->add_control(
'counters',
[
'label' => esc_html__( 'Add Counter Item', 'prinox-tools' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ title }}}',
]
);
$this->add_control(
'btn_label', [
'label' => esc_html__( 'Button Label', 'prinox-tools' ),
'type' => Controls_Manager::TEXT,
'label_block' => true,
]
);
$this->add_control(
'btn_link', [
'label' => esc_html__( 'Button Link', 'prinox-tools' ),
'type' => Controls_Manager::URL,
'label_block' => true,
]
);
$this->add_control(
'cta_img', [
'label' => esc_html__( 'Cta Image 1', 'prinox-tools' ),
'type' => Controls_Manager::MEDIA,
'label_block' => true,
]
);
$this->add_control(
'cta_img2', [
'label' => esc_html__( 'Cta Image 2', 'prinox-tools' ),
'type' => Controls_Manager::MEDIA,
'label_block' => true,
]
);
$this->end_controls_section();
$this->start_controls_section(
'cta_style',
[
'label' => __( 'CTA Style', 'prinox-tools' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'cta_bg_color',
'label' => esc_html__( 'CTA Background Color', 'prinox-tools' ),
'types' => [ 'classic', 'gradient'],
'exclude' => [
'image',
],
'selector' => '{{WRAPPER}} .cta-section .inner-container::before',
]
);
$this->add_control(
'title_h',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Title', 'prinox-tools' ),
'separator' => 'before',
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__('Title Color', 'prinox-tools'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .cta-section h2' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'label' => esc_html__( 'Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .cta-section h2',
]
);
$this->add_control(
'text_h',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Text', 'prinox-tools' ),
'separator' => 'before',
]
);
$this->add_control(
'text_color',
[
'label' => esc_html__('Text Color', 'prinox-tools'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .cta-section .text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'text_typography',
'label' => esc_html__( 'Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .cta-section .text',
]
);
$this->add_control(
'counter_h',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Counter', 'prinox-tools' ),
'separator' => 'before',
]
);
$this->add_control(
'count_number_color',
[
'label' => esc_html__('Count Number Color', 'prinox-tools'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .cta-section .counter-boxed .counter' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'count_number_typography',
'label' => esc_html__( 'Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .cta-section .counter-boxed .counter',
]
);
$this->add_control(
'counter_title_h',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Counter Title', 'prinox-tools' ),
'separator' => 'before',
]
);
$this->add_control(
'count_title_color',
[
'label' => esc_html__('Count Title Color', 'prinox-tools'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .cta-section .counter-boxed .counter-text' => 'color: {{VALUE}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'count_title_typography',
'label' => esc_html__( 'Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .cta-section .counter-boxed .counter-text',
]
);
$this->add_control(
'counter_border_h',
[
'type' => Controls_Manager::HEADING,
'label' => esc_html__( 'Border Color', 'prinox-tools' ),
'separator' => 'before',
]
);
$this->add_control(
'counter_border_color',
[
'label' => esc_html__('Border Color', 'prinox-tools'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .cta-section .counter-boxed .counter::before' => 'background-color: {{VALUE}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'cta_button',
[
'label' => __( 'Button', 'prinox-tools' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'button_typography',
'label' => esc_html__( 'Button Typography', 'prinox-tools' ),
'selector' => '{{WRAPPER}} .cta-section .start-btn',
]
);
$this->add_control(
'button_padding',
[
'label' => esc_html__( 'Padding', 'prinox-tools' ),
'type' => \Elementor\Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .cta-section .start-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->start_controls_tabs('button_style_tabs');
//Default style tab start
$this->start_controls_tab(
'btn_style_default',
[
'label' => esc_html__('Normal', 'prinox-tools'),
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'button_bg',
'label' => esc_html__( 'Background', 'prinox-tools' ),
'types' => [ 'classic', 'gradient'],
'exclude' => [
'image',
],
'selector' => '{{WRAPPER}} .cta-section .start-btn',
]
);
$this->add_control(
'button_default_text_color',
[
'label' => esc_html__('Text Color', 'prinox-tools'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .cta-section .start-btn' => 'color: {{VALUE}};',
],
'separator' => 'before',
]
);
$this->end_controls_tab();
//Hover style tab start
$this->start_controls_tab(
'btn_style_hover',
[
'label' => esc_html__('Hover', 'prinox-tools'),
]
);
$this->add_group_control(
Group_Control_Background::get_type(),
[
'name' => 'button_hover_bg',
'label' => esc_html__( 'Background', 'prinox-tools' ),
'types' => [ 'classic', 'gradient'],
'selector' => '{{WRAPPER}} .cta-section .start-btn:hover',
'exclude' => [
'image',
],
]
);
$this->add_control(
'button_hover_text_color',
[
'label' => esc_html__('Text Color', 'prinox-tools'),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .theme-btn.start-btn:hover' => 'color: {{VALUE}};',
],
'separator' => 'before',
]
);
$this->end_controls_tabs();
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
?>
<!-- CTA Section -->
<section class="cta-section">
<div class="auto-container">
<div class="inner-container">
<h2><?php echo wp_kses( $settings['title'], true );?></h2>
<div class="text"><?php echo wp_kses( $settings['description'], true );?></div>
<!-- Counter Boxed -->
<div class="counter-boxed">
<div class="row clearfix">
<?php foreach($settings['counters'] as $item):?>
<!-- Counter Column -->
<div class="counter-block col-lg-4 col-md-6 col-sm-12">
<div class="inner-box">
<div class="counter"><span class="odometer" data-count="<?php echo esc_attr($item['number']);?>"></span> <?php echo esc_html($item['symbole']);?></div>
<div class="counter-text"><?php echo wp_kses( $item['title'], true );?></div>
</div>
</div>
<?php endforeach;?>
</div>
</div>
<!-- End Counter Boxed -->
<?php if($settings['btn_label']):?>
<!-- Button Box -->
<div class="button-box">
<a href="<?php echo esc_url($settings['btn_link']['url']);?>" class="theme-btn start-btn"><?php echo esc_html( $settings['btn_label'] )?> <i class="flaticon-next-2"></i></a>
</div>
<?php endif;?>
<?php if($settings['cta_img']['url']):?>
<!-- Icon One -->
<div class="icon-one">
<img src="<?php echo esc_url($settings['cta_img']['url']);?>" alt="<?php echo esc_attr($settings['cta_img']['alt']);?>" />
</div>
<!-- Icon Two -->
<?php endif;?>
<?php if($settings['cta_img2']['url']):?>
<div class="icon-two">+
<img src="<?php echo esc_url($settings['cta_img2']['url']);?>" alt="<?php echo esc_attr($settings['cta_img2']['alt']);?>" />
</div>
<?php endif;?>
</div>
</div>
</section>
<!-- End CTA Section -->
<?php
}
}
Plugin::instance()->widgets_manager->register( new Prinox_Cta() );