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

666 lines
26 KiB
PHP

<?php namespace Elementor;
class restly_counterv3_Widget extends Widget_Base {
public function get_name() {
return 'restly_counterv3';
}
public function get_title() {
return esc_html__( 'Restly Counter v3', 'restlycore' );
}
public function get_icon() {
return 'eicon-counter';
}
public function get_categories() {
return ['restly'];
}
protected function register_controls() {
//Content tab start
$this->start_controls_section(
'restly_counter_options',
[
'label' => esc_html__( 'Restly Counter', 'restlycore' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$repeater = new \Elementor\Repeater();
$repeater->add_control(
'title', [
'label' => esc_html__( 'Title', 'restlycore' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__( 'Apps Project Complate' , 'restlycore' ),
'label_block' => true,
'dynamic' => [
'active' => true,
],
]
);
$repeater->add_control(
'number',
[
'label' => esc_html__( 'Count Number', 'restlycore' ),
'type' => \Elementor\Controls_Manager::NUMBER,
'min' => 1,
'max' => 1000000,
'step' => 1,
'default' => 3504,
]
);
$repeater->add_control(
'symble', [
'label' => esc_html__( 'Symble', 'restlycore' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => '+',
'label_block' => true,
]
);
$repeater->add_control(
'icon',
[
'label' => esc_html__( 'Icon', 'restlycore' ),
'type' => \Elementor\Controls_Manager::ICONS,
'default' => [
'value' => 'fas fa-warehouse',
'library' => 'solid',
],
]
);
$this->add_control(
'items',
[
'label' => esc_html__( 'Counter Items', 'restlycore' ),
'type' => \Elementor\Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'default' => [
[
'title' => esc_html__( 'Apps Project Complate', 'restlycore' ),
'number' => 3504,
'symble' => '+',
'icon' => '',
],
],
'title_field' => '{{{ title }}}',
]
);
$this->add_control(
'container',
[
'label' => esc_html__( 'Container', 'restlycore' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'restlycore' ),
'label_off' => esc_html__( 'Hide', 'restlycore' ),
'return_value' => 'yes',
'default' => 'yes',
]
);
$this->add_control(
'desktop_col',
[
'label' => __( 'Columns On Desktop', 'restlycore' ),
'type' => Controls_Manager::SELECT,
'default' => 'col-xl-4',
'options' => [
'col-xl-12' => __( '1 Column', 'restlycore' ),
'col-xl-6' => __( '2 Column', 'restlycore' ),
'col-xl-4' => __( '3 Column', 'restlycore' ),
'col-xl-3' => __( '4 Column', 'restlycore' ),
'col-xl-2' => __( '6 Column', 'restlycore' ),
],
]
);
$this->add_control(
'laptop_col',
[
'label' => __( 'Columns for Laptop', 'restlycore' ),
'type' => Controls_Manager::SELECT,
'default' => 'col-lg-4',
'options' => [
'col-lg-12' => __( '1 Column', 'restlycore' ),
'col-lg-6' => __( '2 Column', 'restlycore' ),
'col-lg-4' => __( '3 Column', 'restlycore' ),
'col-lg-3' => __( '4 Column', 'restlycore' ),
'col-lg-2' => __( '6 Column', 'restlycore' ),
],
]
);
$this->add_control(
'tab_col',
[
'label' => __( 'Columns On Tablet', 'restlycore' ),
'type' => Controls_Manager::SELECT,
'default' => 'col-md-4',
'options' => [
'col-md-12' => __( '1 Column', 'restlycore' ),
'col-md-6' => __( '2 Column', 'restlycore' ),
'col-md-4' => __( '3 Column', 'restlycore' ),
'col-md-3' => __( '4 Column', 'restlycore' ),
'col-md-2' => __( '6 Column', 'restlycore' ),
],
]
);
$this->add_control(
'extra_col',
[
'label' => __( 'Columns On Extra Tablet', 'restlycore' ),
'type' => Controls_Manager::SELECT,
'default' => 'col-sm-6',
'options' => [
'col-sm-12' => __( '1 Column', 'restlycore' ),
'col-sm-6' => __( '2 Column', 'restlycore' ),
'col-sm-4' => __( '3 Column', 'restlycore' ),
'col-sm-3' => __( '4 Column', 'restlycore' ),
'col-sm-2' => __( '6 Column', 'restlycore' ),
],
]
);
$this->add_control(
'note',
[
'label' => __( 'Additional Options', 'restlycore' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_responsive_control(
'icon_position',
[
'label' => __( 'icon Position', 'restlycore' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'row' => [
'title' => __( 'Left', 'restlycore' ),
'icon' => 'eicon-h-align-left',
],
'column' => [
'title' => __( 'Top', 'restlycore' ),
'icon' => 'eicon-v-align-top',
],
'row-reverse' => [
'title' => __( 'Right', 'restlycore' ),
'icon' => 'eicon-h-align-right',
],
'column-reverse' => [
'title' => __( 'Bottom', 'restlycore' ),
'icon' => 'eicon-v-align-bottom',
],
],
'default' => 'row',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .success-item.style-six' => 'flex-direction: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'justify_position',
[
'label' => __( 'justify Content', 'restlycore' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => __( 'Left', 'restlycore' ),
'icon' => 'eicon-justify-start-h',
],
'center' => [
'title' => __( 'Center', 'restlycore' ),
'icon' => 'eicon-justify-center-h',
],
'flex-end' => [
'title' => __( 'Right', 'restlycore' ),
'icon' => 'eicon-justify-end-h',
],
'space-between' => [
'title' => __( 'Space Between', 'restlycore' ),
'icon' => 'eicon-justify-space-between-h',
],
'space-around' => [
'title' => __( 'Space Around', 'restlycore' ),
'icon' => 'eicon-justify-space-around-h',
],
'space-evenly' => [
'title' => __( 'Space Evenly', 'restlycore' ),
'icon' => 'eicon-justify-space-evenly-h',
],
],
'default' => 'center',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .success-item.style-six' => 'justify-content: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'align_position',
[
'label' => __( 'Align Item', 'restlycore' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => __( 'Top', 'restlycore' ),
'icon' => ' eicon-align-start-v',
],
'flex-end' => [
'title' => __( 'Bottom', 'restlycore' ),
'icon' => 'eicon-align-end-v',
],
'center' => [
'title' => __( 'Center', 'restlycore' ),
'icon' => 'eicon-align-center-h',
],
],
'default' => 'center',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .success-item.style-six' => 'align-items: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'alignment',
[
'label' => __( 'Text Alignment', 'restlycore' ),
'type' => \Elementor\Controls_Manager::CHOOSE,
'options' => [
'left' => [
'title' => __( 'Left', 'restlycore' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => __( 'Center', 'restlycore' ),
'icon' => 'eicon-text-align-center',
],
'justify' => [
'title' => __( 'Justify', 'restlycore' ),
'icon' => 'eicon-text-align-justify',
],
'right' => [
'title' => __( 'Right', 'restlycore' ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'left',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .success-item.style-six' => 'text-align: {{VALUE}}',
],
]
);
$this->end_controls_section();
// START CSS
$this->start_controls_section(
'box_css_options',
[
'label' => esc_html__( 'Counter Box', 'restlycore' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
\Elementor\Group_Control_Background::get_type(),
[
'name' => 'box_bg',
'label' => esc_html__( 'Background', 'restlycore' ),
'types' => [ 'classic', 'gradient', 'video' ],
'selector' => '{{WRAPPER}} .restly-counter-v3-wrapper',
]
);
$this->add_group_control(
\Elementor\Group_Control_Border::get_type(),
[
'name' => 'box_border',
'label' => esc_html__( 'Border', 'restlycore' ),
'selector' => '{{WRAPPER}} .restly-counter-v3-wrapper',
]
);
$this->add_responsive_control(
'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-counter-v3-wrapper' => 'border-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Box_Shadow::get_type(),
[
'name' => 'box_shadow',
'label' => esc_html__( 'Box Shadow', 'restlycore' ),
'selector' => '{{WRAPPER}} .restly-counter-v3-wrapper',
]
);
$this->add_responsive_control(
'box_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-counter-v3-wrapper' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'box_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-counter-v3-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'content_css_options',
[
'label' => esc_html__( 'Content', 'restlycore' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_group_control(
\Elementor\Group_Control_Background::get_type(),
[
'name' => 'content_bg',
'label' => esc_html__( 'Background', 'restlycore' ),
'types' => [ 'classic', 'gradient', 'video' ],
'selector' => '{{WRAPPER}} .success-item.style-six',
]
);
$this->add_group_control(
\Elementor\Group_Control_Border::get_type(),
[
'name' => 'content_border',
'label' => esc_html__( 'Border', 'restlycore' ),
'selector' => '{{WRAPPER}} .success-item.style-six',
]
);
$this->add_responsive_control(
'content_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}} .success-item.style-six' => 'border-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Box_Shadow::get_type(),
[
'name' => 'content_shadow',
'label' => esc_html__( 'Box Shadow', 'restlycore' ),
'selector' => '{{WRAPPER}} .success-item.style-six',
]
);
$this->add_responsive_control(
'content_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .success-item.style-six' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'content_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .success-item.style-six' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->start_controls_tabs(
'content_tabs'
);
$this->start_controls_tab(
'icon_tab',
[
'label' => __( 'Icon', 'restlycore' ),
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'icon_typo',
'label' => esc_html__( 'Typography', 'restlycore' ),
'selector' => '{{WRAPPER}} .success-item.style-six .icon',
]
);
$this->add_responsive_control(
'icon_color',
[
'label' => esc_html__( 'Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .success-item.style-six .icon' => 'color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'icon_bg',
[
'label' => esc_html__( 'Background Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .success-item.style-six .icon' => 'background-color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'icon_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .success-item.style-six .icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'icon_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .success-item.style-six .icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'number_tab',
[
'label' => __( 'Number', 'restlycore' ),
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'number_typo',
'label' => esc_html__( 'Typography', 'restlycore' ),
'selector' => '{{WRAPPER}} .success-item.style-six .count-text',
]
);
$this->add_responsive_control(
'number_color',
[
'label' => esc_html__( 'Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .success-item.style-six .count-text' => 'color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'number_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .success-item.style-six .count-text' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'number_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .success-item.style-six .count-text' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'title_tab',
[
'label' => __( 'Title', 'restlycore' ),
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'title_typo',
'label' => esc_html__( 'Typography', 'restlycore' ),
'selector' => '{{WRAPPER}} .success-item.style-six .counter-title',
]
);
$this->add_responsive_control(
'title_color',
[
'label' => esc_html__( 'Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .success-item.style-six .counter-title' => 'color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'title_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .success-item.style-six .counter-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'title_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .success-item.style-six .counter-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->end_controls_section();
}
//Render
protected function render() {
$settings = $this->get_settings_for_display();
$unique = rand(35245545, 541541745);
$column = $settings['desktop_col'] . ' ' . $settings['laptop_col'] . ' ' . $settings['tab_col'] . ' ' . $settings['extra_col'];
ob_start();
echo '
<script>
jQuery(document).ready(function($) {
"use strict";
$(".timer-'.esc_attr($unique).'").countTo();
$(".count-process-'.esc_attr($unique).'").appear(function() {
$(".timer-'.esc_attr($unique).'").countTo();
}, {
accY: -200
});
});
</script>
';
?>
<div class="restly-counter-v3-wrapper">
<div class="<?php echo esc_attr( $settings['container'] == 'yes' ? 'container container-1250' : 'no-container' ); ?>">
<div class="row g-0 justify-content-center">
<?php foreach($settings['items'] as $item ) : ?>
<div class="<?php echo esc_attr($column); ?>">
<div class="success-item style-six">
<?php if( $item['icon']) : ?>
<div class="icon">
<?php \Elementor\Icons_Manager::render_icon( $item['icon'], [ 'aria-hidden' => 'true' ] ); ?>
</div>
<?php endif; ?>
<div class="content count-process-<?php echo esc_attr($unique); ?>">
<div class="count-numners">
<span class="count-text plus timer-<?php echo esc_attr($unique); ?>" data-speed="5000" data-to="<?php echo esc_attr($item['number']); ?>" style=""><?php echo esc_html($item['number'] ); ?></span>
<span class="count-text"><?php echo esc_html($item['symble']); ?></span>
</div>
<?php if( $item['title'] ) {
echo '<span class="counter-title">'. esc_html( $item['title'] ) .'</span>';
} ?>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
<?php
echo ob_get_clean();
}
}
Plugin::instance()->widgets_manager->register( new restly_counterv3_Widget );