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

537 lines
20 KiB
PHP

<?php namespace Elementor;
class restly_counter_new_Widget extends Widget_Base {
public function get_name() {
return 'restly_counter_new';
}
public function get_title() {
return esc_html__( 'Restly Counter v2', '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_new_options',
[
'label' => esc_html__( 'Restly Counter', 'restlycore' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'restly_counter_new_icon',
[
'label' => esc_html__( 'Icon', 'restlycore' ),
'type' => \Elementor\Controls_Manager::ICONS,
]
);
$this->add_control(
'restly_counter_new_title',
[
'label' => esc_html__( 'Title', 'restlycore' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__( 'Projects Done', 'restlycore' ),
]
);
$this->add_control(
'restly_counter_new_number',
[
'label' => esc_html__( 'Number', 'restlycore' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__( '520', 'restlycore' ),
]
);
$this->add_control(
'restly_counter_new_symble',
[
'label' => esc_html__( 'Symble', 'restlycore' ),
'type' => \Elementor\Controls_Manager::TEXT,
'default' => esc_html__( '+', 'restlycore' ),
]
);
$this->add_control(
'restly_counter_new_bg_text',
[
'label' => esc_html__( 'Enable Background Text', 'restlycore' ),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => esc_html__( 'Show', 'restlycore' ),
'label_off' => esc_html__( 'Hide', 'restlycore' ),
'return_value' => 'yes',
'default' => 'no',
]
);
$this->add_responsive_control(
'restly_counter_new_bg_ctext',
[
'label' => esc_html__( 'Bg Text Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bg-text.counter-numbers .counter-nmber' => 'color: {{VALUE}}',
],
'condition' => [
'restly_counter_new_bg_text' => 'yes',
],
]
);
$this->add_responsive_control(
'restly_counter_new_bg_sctext',
[
'label' => esc_html__( 'Bg Text Stock Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .bg-text.counter-numbers .counter-nmber' => '-webkit-text-stroke-color: {{VALUE}}',
],
'condition' => [
'restly_counter_new_bg_text' => 'yes',
],
]
);
$this->add_responsive_control(
'restly_counter_new_bg_stock_width',
[
'label' => esc_html__( 'Text Stock Width', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 50,
'step' => .5,
],
],
'selectors' => [
'{{WRAPPER}} .bg-text.counter-numbers .counter-nmber' => '-webkit-text-stroke-width: {{SIZE}}{{UNIT}};',
],
'condition' => [
'restly_counter_new_bg_text' => 'yes',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'restly_counter_new_bg_typo',
'label' => esc_html__( 'Typography', 'restlycore' ),
'selector' => '{{WRAPPER}} .bg-text.counter-numbers .counter-nmber',
'condition' => [
'restly_counter_new_bg_text' => 'yes',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'restly_counter_new_css',
[
'label' => esc_html__( 'Box CSS', 'restlycore' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'restly_cservice_CSS_align',
[
'label' => __( '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',
],
'right' => [
'title' => __( 'Right', 'restlycore' ),
'icon' => 'eicon-text-align-right',
],
],
'default' => 'center',
'toggle' => true,
'selectors' => [
'{{WRAPPER}} .restly-counter-wrapper.new .restly-counter' => 'text-align: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'restly_counter_new_box_hbg',
[
'label' => esc_html__( 'Box Hover Background', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .restly-counter-wrapper.new .restly-counter' => 'background-color: {{VALUE}}',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Box_Shadow::get_type(),
[
'name' => 'restly_counter_new_box_shadow',
'label' => esc_html__( 'Box Shadow', 'restlycore' ),
'selector' => '{{WRAPPER}} .restly-counter-wrapper.new .restly-counter',
]
);
$this->add_responsive_control(
'restly_counter_new_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,
],
],
'default' => [
'unit' => 'px',
'size' => 10,
],
'selectors' => [
'{{WRAPPER}} .restly-counter-wrapper.new .restly-counter' => 'border-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_box_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-counter-wrapper.new .restly-counter' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_box_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .restly-counter-wrapper.new .restly-counter' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'restly_counter_new_css_icon',
[
'label' => esc_html__( 'Icon CSS', 'restlycore' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'restly_counter_new_css_icon_size',
[
'label' => esc_html__( 'Icon SIze', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .counter-new-icon' => 'font-size: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_icon_width',
[
'label' => esc_html__( 'Icon Width', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .counter-new-icon' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_icon_height',
[
'label' => esc_html__( 'Icon Height', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .counter-new-icon' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_icon_radius',
[
'label' => esc_html__( 'Icon Radius', 'restlycore' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px' ],
'range' => [
'px' => [
'min' => 0,
'max' => 100,
'step' => 1,
]
],
'selectors' => [
'{{WRAPPER}} .counter-new-icon' => 'border-radius: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_icon_color',
[
'label' => esc_html__( 'Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .counter-new-icon' => 'color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_icon_bgcolor',
[
'label' => esc_html__( 'Background Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .counter-new-icon' => 'background-color: {{VALUE}}',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_icon_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .counter-new-icon' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_icon_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .counter-new-icon' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
$this->start_controls_section(
'restly_counter_new_css_content',
[
'label' => esc_html__( 'Content CSS', 'restlycore' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'ecolar_class_box_aligment',
[
'label' => __( '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}} .counter-new-content' => 'text-align: {{VALUE}}',
],
]
);
$this->add_control(
'newc2',
[
'label' => __( 'Number CSS', 'restlycore' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_responsive_control(
'restly_counter_new_css_number_color',
[
'label' => esc_html__( 'Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .new .counter-nmber' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'restly_counter_new_css_number_typo',
'label' => esc_html__( 'Typography', 'restlycore' ),
'selector' => '{{WRAPPER}} .new .counter-nmber',
]
);
$this->add_responsive_control(
'restly_counter_new_css_number_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .new .counter-numbers' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_number_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .new .counter-numbers' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_control(
'newc1',
[
'label' => __( 'Title CSS', 'restlycore' ),
'type' => \Elementor\Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_responsive_control(
'restly_counter_new_css_title_color',
[
'label' => esc_html__( 'Color', 'restlycore' ),
'type' => \Elementor\Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .new .resty-counter-title' => 'color: {{VALUE}}',
],
]
);
$this->add_group_control(
\Elementor\Group_Control_Typography::get_type(),
[
'name' => 'restly_counter_new_css_title_typo',
'label' => esc_html__( 'Typography', 'restlycore' ),
'selector' => '{{WRAPPER}} .new .resty-counter-title',
]
);
$this->add_responsive_control(
'restly_counter_new_css_title_margin',
[
'label' => esc_html__( 'Margin', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .new .resty-counter-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'restly_counter_new_css_title_padding',
[
'label' => esc_html__( 'Padding', 'restlycore' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em' ],
'selectors' => [
'{{WRAPPER}} .new .resty-counter-title' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
]
);
$this->end_controls_section();
}
//Render
protected function render() {
$settings = $this->get_settings_for_display();
$unique = rand(35245545, 541541745);
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-wrapper new">
<div class="restly-counter">
<div class="counter-new-icon">
<?php \Elementor\Icons_Manager::render_icon( $settings['restly_counter_new_icon'], [ 'aria-hidden' => 'true' ] ); ?>
</div>
<div class="counter-new-content">
<div class="counter-numbers count-process-<?php echo esc_attr($unique); ?>">
<div class="counter-nmber timer-<?php echo esc_attr($unique); ?>" data-to="<?php echo esc_attr($settings['restly_counter_new_number']); ?>" data-speed="5000"><?php echo esc_html($settings['restly_counter_new_number']); ?></div>
<span class="counter-nmber"><?php echo esc_html($settings['restly_counter_new_symble']); ?></span>
</div>
<h2 class="resty-counter-title"><?php echo esc_html($settings['restly_counter_new_title']); ?></h2>
</div>
<?php if( 'yes' == $settings['restly_counter_new_bg_text']) : ?>
<div class="bg-text counter-numbers count-process-<?php echo esc_attr($unique); ?>">
<div class="counter-nmber"><?php echo esc_html($settings['restly_counter_new_number']); ?></div>
<span class="counter-nmber"><?php echo esc_html($settings['restly_counter_new_symble']); ?></span>
</div>
<?php endif; ?>
</div>
</div>
<?php
echo ob_get_clean();
}
}
Plugin::instance()->widgets_manager->register( new restly_counter_new_Widget );