Files
2026-03-12 14:16:29 +01:00

1003 lines
26 KiB
PHP

<?php
if (!defined('ABSPATH')) {
exit;
}
use Elementor\Controls_Manager;
use Elementor\Group_Control_Typography;
use Elementor\Group_Control_Text_Shadow;
use Elementor\Group_Control_Text_Stroke;
use Elementor\Group_Control_Border;
use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
class Elementor_Number_Box extends \Elementor\Widget_Base {
public function get_name() {
return 'number-box';
}
public function get_title() {
return esc_html__( 'Number Box', 'elementor-addon' );
}
public function get_icon() {
return 'eicon-number-field';
}
public function get_categories() {
return [ 'basic' ];
}
public function get_keywords() {
return [ 'number', 'box', 'counter' ];
}
public function get_style_depends() {
return [ 'elementor-addon-main-css' ];
}
public function get_script_depends() {
return [ 'elementor-addon-main-js' ];
}
protected function register_controls() {
$this->start_controls_section(
'section_number',
[
'label' => esc_html__( 'Number Box', 'elementor-addon' ),
]
);
$this->add_control(
'number_text',
[
'label' => esc_html__( 'Number', 'elementor-addon' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'default' => '1',
'placeholder' => esc_html__( 'Enter number', 'elementor-addon' ),
]
);
$this->add_control(
'view',
[
'label' => esc_html__( 'View', 'elementor-addon' ),
'type' => Controls_Manager::SELECT,
'options' => [
'default' => esc_html__( 'Default', 'elementor-addon' ),
'stacked' => esc_html__( 'Stacked', 'elementor-addon' ),
'framed' => esc_html__( 'Framed', 'elementor-addon' ),
],
'default' => 'default',
'prefix_class' => 'elementor-view-',
]
);
$this->add_control(
'shape',
[
'label' => esc_html__( 'Shape', 'elementor-addon' ),
'type' => Controls_Manager::SELECT,
'options' => [
'square' => esc_html__( 'Square', 'elementor-addon' ),
'rounded' => esc_html__( 'Rounded', 'elementor-addon' ),
'circle' => esc_html__( 'Circle', 'elementor-addon' ),
],
'default' => 'circle',
'condition' => [
'view!' => 'default',
],
'prefix_class' => 'elementor-shape-',
]
);
$this->add_control(
'title_text',
[
'label' => esc_html__( 'Title', 'elementor-addon' ),
'type' => Controls_Manager::TEXT,
'dynamic' => [
'active' => true,
],
'default' => esc_html__( 'This is the heading', 'elementor-addon' ),
'placeholder' => esc_html__( 'Enter your title', 'elementor-addon' ),
'label_block' => true,
]
);
$this->add_control(
'description_text',
[
'label' => esc_html__( 'Description', 'elementor-addon' ),
'type' => Controls_Manager::TEXTAREA,
'dynamic' => [
'active' => true,
],
'default' => esc_html__( 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.', 'elementor-addon' ),
'placeholder' => esc_html__( 'Enter your description', 'elementor-addon' ),
'rows' => 10,
]
);
$this->add_control(
'link',
[
'label' => esc_html__( 'Link', 'elementor-addon' ),
'type' => Controls_Manager::URL,
'dynamic' => [
'active' => true,
],
'separator' => 'before',
]
);
$this->add_control(
'title_size',
[
'label' => esc_html__( 'Title HTML Tag', 'elementor-addon' ),
'type' => Controls_Manager::SELECT,
'options' => [
'h1' => 'H1',
'h2' => 'H2',
'h3' => 'H3',
'h4' => 'H4',
'h5' => 'H5',
'h6' => 'H6',
'div' => 'div',
'span' => 'span',
'p' => 'p',
],
'default' => 'h3',
]
);
$this->end_controls_section();
// Style: Box
$this->start_controls_section(
'section_style_box',
[
'label' => esc_html__( 'Box', 'elementor-addon' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'position',
[
'label' => esc_html__( 'Number Position', 'elementor-addon' ),
'type' => Controls_Manager::CHOOSE,
'default' => 'block-start',
'mobile_default' => 'block-start',
'options' => [
'inline-start' => [
'title' => esc_html__( 'Start', 'elementor-addon' ),
'icon' => 'eicon-h-align-left',
],
'inline-end' => [
'title' => esc_html__( 'End', 'elementor-addon' ),
'icon' => 'eicon-h-align-right',
],
'block-start' => [
'title' => esc_html__( 'Top', 'elementor-addon' ),
'icon' => 'eicon-v-align-top',
],
'block-end' => [
'title' => esc_html__( 'Bottom', 'elementor-addon' ),
'icon' => 'eicon-v-align-bottom',
],
],
'classes' => 'elementor-control-start-end',
'classes_dictionary' => [
'left' => is_rtl() ? 'inline-end' : 'inline-start',
'right' => is_rtl() ? 'inline-start' : 'inline-end',
'top' => 'block-start',
'bottom' => 'block-end',
],
'prefix_class' => 'elementor%s-position-',
]
);
$this->add_responsive_control(
'content_vertical_alignment',
[
'label' => esc_html__( 'Vertical Alignment', 'elementor-addon' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'top' => [
'title' => esc_html__( 'Top', 'elementor-addon' ),
'icon' => 'eicon-v-align-top',
],
'middle' => [
'title' => esc_html__( 'Middle', 'elementor-addon' ),
'icon' => 'eicon-v-align-middle',
],
'bottom' => [
'title' => esc_html__( 'Bottom', 'elementor-addon' ),
'icon' => 'eicon-v-align-bottom',
],
],
'default' => 'top',
'selectors_dictionary' => [
'top' => 'start',
'middle' => 'center',
'bottom' => 'end',
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-wrapper' => 'align-items: {{VALUE}};',
],
'condition' => [
'position' => [ 'left', 'right', 'inline-start', 'inline-end' ],
],
]
);
$this->add_responsive_control(
'text_align',
[
'label' => esc_html__( 'Alignment', 'elementor-addon' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'start' => [
'title' => esc_html__( 'Start', 'elementor-addon' ),
'icon' => 'eicon-text-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'elementor-addon' ),
'icon' => 'eicon-text-align-center',
],
'end' => [
'title' => esc_html__( 'End', 'elementor-addon' ),
'icon' => 'eicon-text-align-right',
],
'justify' => [
'title' => esc_html__( 'Justified', 'elementor-addon' ),
'icon' => 'eicon-text-align-justify',
],
],
'classes' => 'elementor-control-start-end',
'selectors_dictionary' => [
'left' => is_rtl() ? 'end' : 'start',
'right' => is_rtl() ? 'start' : 'end',
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-wrapper' => 'text-align: {{VALUE}};',
],
'separator' => 'after',
]
);
$this->add_responsive_control(
'number_space',
[
'label' => esc_html__( 'Number Spacing', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'default' => [
'size' => 15,
],
'range' => [
'px' => [
'max' => 100,
],
'em' => [
'max' => 10,
],
'rem' => [
'max' => 10,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-wrapper' => 'gap: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'title_bottom_space',
[
'label' => esc_html__( 'Content Spacing', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', 'em', 'rem', 'custom' ],
'range' => [
'px' => [
'max' => 100,
],
'em' => [
'min' => 0,
'max' => 10,
],
'rem' => [
'min' => 0,
'max' => 10,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-title' => 'margin-block-end: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_section();
// Style: Number
$this->start_controls_section(
'section_style_number',
[
'label' => esc_html__( 'Number', 'elementor-addon' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_responsive_control(
'number_box_width',
[
'label' => esc_html__( 'Width', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'min' => 10,
'max' => 500,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-number' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'number_box_height',
[
'label' => esc_html__( 'Height', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vh', 'custom' ],
'range' => [
'px' => [
'min' => 10,
'max' => 500,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-number' => 'height: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_responsive_control(
'number_box_justify',
[
'label' => esc_html__( 'Horizontal Alignment', 'elementor-addon' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => esc_html__( 'Start', 'elementor-addon' ),
'icon' => 'eicon-h-align-left',
],
'center' => [
'title' => esc_html__( 'Center', 'elementor-addon' ),
'icon' => 'eicon-h-align-center',
],
'flex-end' => [
'title' => esc_html__( 'End', 'elementor-addon' ),
'icon' => 'eicon-h-align-right',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} .elementor-number-box-number' => 'display: flex; justify-content: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'number_box_align',
[
'label' => esc_html__( 'Vertical Alignment', 'elementor-addon' ),
'type' => Controls_Manager::CHOOSE,
'options' => [
'flex-start' => [
'title' => esc_html__( 'Top', 'elementor-addon' ),
'icon' => 'eicon-v-align-top',
],
'center' => [
'title' => esc_html__( 'Middle', 'elementor-addon' ),
'icon' => 'eicon-v-align-middle',
],
'flex-end' => [
'title' => esc_html__( 'Bottom', 'elementor-addon' ),
'icon' => 'eicon-v-align-bottom',
],
],
'default' => 'center',
'selectors' => [
'{{WRAPPER}} .elementor-number-box-number' => 'display: flex; align-items: {{VALUE}};',
],
]
);
$this->add_control(
'number_box_bg_color',
[
'label' => esc_html__( 'Background Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .elementor-number-box-number' => 'background-color: {{VALUE}};',
],
'separator' => 'before',
]
);
$this->add_control(
'number_box_text_color',
[
'label' => esc_html__( 'Number Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'selectors' => [
'{{WRAPPER}} .elementor-number-box-number .elementor-number' => 'color: {{VALUE}};',
],
]
);
$this->add_responsive_control(
'number_box_border_radius',
[
'label' => esc_html__( 'Border Radius', 'elementor-addon' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-number' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'separator' => 'after',
]
);
$this->start_controls_tabs( 'number_colors' );
$this->start_controls_tab(
'number_colors_normal',
[
'label' => esc_html__( 'Normal', 'elementor-addon' ),
]
);
$this->add_control(
'primary_color',
[
'label' => esc_html__( 'Primary Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'global' => [
'default' => Global_Colors::COLOR_PRIMARY,
],
'default' => '',
'selectors' => [
'{{WRAPPER}}.elementor-view-stacked .elementor-number' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-view-framed .elementor-number, {{WRAPPER}}.elementor-view-default .elementor-number' => 'color: {{VALUE}}; border-color: {{VALUE}};',
],
]
);
$this->add_control(
'secondary_color',
[
'label' => esc_html__( 'Secondary Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'condition' => [
'view!' => 'default',
],
'selectors' => [
'{{WRAPPER}}.elementor-view-framed .elementor-number' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-view-stacked .elementor-number' => 'color: {{VALUE}};',
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'number_colors_hover',
[
'label' => esc_html__( 'Hover', 'elementor-addon' ),
]
);
$this->add_control(
'hover_primary_color',
[
'label' => esc_html__( 'Primary Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}}.elementor-view-stacked:has(:hover) .elementor-number,
{{WRAPPER}}.elementor-view-stacked:has(:focus) .elementor-number' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-view-framed:has(:hover) .elementor-number,
{{WRAPPER}}.elementor-view-default:has(:hover) .elementor-number,
{{WRAPPER}}.elementor-view-framed:has(:focus) .elementor-number,
{{WRAPPER}}.elementor-view-default:has(:focus) .elementor-number' => 'color: {{VALUE}}; border-color: {{VALUE}};',
],
]
);
$this->add_control(
'hover_secondary_color',
[
'label' => esc_html__( 'Secondary Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'condition' => [
'view!' => 'default',
],
'selectors' => [
'{{WRAPPER}}.elementor-view-framed:has(:hover) .elementor-number,
{{WRAPPER}}.elementor-view-framed:has(:focus) .elementor-number' => 'background-color: {{VALUE}};',
'{{WRAPPER}}.elementor-view-stacked:has(:hover) .elementor-number,
{{WRAPPER}}.elementor-view-stacked:has(:focus) .elementor-number' => 'color: {{VALUE}};',
],
]
);
$this->add_control(
'hover_number_colors_transition_duration',
[
'label' => esc_html__( 'Transition Duration', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 's', 'ms', 'custom' ],
'default' => [
'unit' => 's',
],
'selectors' => [
'{{WRAPPER}} .elementor-number' => 'transition-duration: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'hover_animation',
[
'label' => esc_html__( 'Hover Animation', 'elementor-addon' ),
'type' => Controls_Manager::HOVER_ANIMATION,
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_responsive_control(
'number_size',
[
'label' => esc_html__( 'Size', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'min' => 6,
'max' => 300,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-number' => 'font-size: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'number_typography',
'selector' => '{{WRAPPER}} .elementor-number',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
],
]
);
$this->add_group_control(
Group_Control_Text_Stroke::get_type(),
[
'name' => 'number_stroke',
'selector' => '{{WRAPPER}} .elementor-number',
]
);
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
[
'name' => 'number_shadow',
'selector' => '{{WRAPPER}} .elementor-number',
]
);
$this->add_responsive_control(
'number_padding',
[
'label' => esc_html__( 'Padding', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'selectors' => [
'{{WRAPPER}} .elementor-number' => 'padding: {{SIZE}}{{UNIT}};',
],
'range' => [
'px' => [
'max' => 50,
],
'em' => [
'min' => 0,
'max' => 5,
],
'rem' => [
'min' => 0,
'max' => 5,
],
],
'condition' => [
'view!' => 'default',
],
]
);
$this->add_responsive_control(
'border_width',
[
'label' => esc_html__( 'Border Width', 'elementor-addon' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'selectors' => [
'{{WRAPPER}} .elementor-number' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'view' => 'framed',
],
]
);
$this->add_responsive_control(
'border_radius',
[
'label' => esc_html__( 'Border Radius', 'elementor-addon' ),
'type' => Controls_Manager::DIMENSIONS,
'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ],
'selectors' => [
'{{WRAPPER}} .elementor-number' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
],
'condition' => [
'view!' => 'default',
],
'separator' => 'before',
]
);
$this->end_controls_section();
// Style: Content
$this->start_controls_section(
'section_style_content',
[
'label' => esc_html__( 'Content', 'elementor-addon' ),
'tab' => Controls_Manager::TAB_STYLE,
]
);
$this->add_control(
'heading_title',
[
'label' => esc_html__( 'Title', 'elementor-addon' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'title_typography',
'selector' => '{{WRAPPER}} .elementor-number-box-title, {{WRAPPER}} .elementor-number-box-title a',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
],
]
);
$this->add_group_control(
Group_Control_Text_Stroke::get_type(),
[
'name' => 'text_stroke',
'selector' => '{{WRAPPER}} .elementor-number-box-title',
]
);
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
[
'name' => 'title_shadow',
'selector' => '{{WRAPPER}} .elementor-number-box-title',
]
);
$this->start_controls_tabs( 'number_box_title_colors' );
$this->start_controls_tab(
'number_box_title_colors_normal',
[
'label' => esc_html__( 'Normal', 'elementor-addon' ),
]
);
$this->add_control(
'title_color',
[
'label' => esc_html__( 'Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-number-box-title' => 'color: {{VALUE}};',
],
'global' => [
'default' => Global_Colors::COLOR_PRIMARY,
],
]
);
$this->end_controls_tab();
$this->start_controls_tab(
'number_box_title_colors_hover',
[
'label' => esc_html__( 'Hover', 'elementor-addon' ),
]
);
$this->add_control(
'hover_title_color',
[
'label' => esc_html__( 'Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}}:has(:hover) .elementor-number-box-title,
{{WRAPPER}}:has(:focus) .elementor-number-box-title' => 'color: {{VALUE}};',
],
'global' => [
'default' => Global_Colors::COLOR_PRIMARY,
],
]
);
$this->add_control(
'hover_title_color_transition_duration',
[
'label' => esc_html__( 'Transition Duration', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 's', 'ms', 'custom' ],
'default' => [
'unit' => 's',
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-title' => 'transition-duration: {{SIZE}}{{UNIT}};',
],
]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_responsive_control(
'title_width',
[
'label' => esc_html__( 'Width', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'min' => 10,
'max' => 1000,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-title' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'heading_description',
[
'label' => esc_html__( 'Description', 'elementor-addon' ),
'type' => Controls_Manager::HEADING,
'separator' => 'before',
]
);
$this->add_group_control(
Group_Control_Typography::get_type(),
[
'name' => 'description_typography',
'selector' => '{{WRAPPER}} .elementor-number-box-description',
'global' => [
'default' => Global_Typography::TYPOGRAPHY_TEXT,
],
]
);
$this->add_group_control(
Group_Control_Text_Shadow::get_type(),
[
'name' => 'description_shadow',
'selector' => '{{WRAPPER}} .elementor-number-box-description',
]
);
$this->add_responsive_control(
'description_width',
[
'label' => esc_html__( 'Width', 'elementor-addon' ),
'type' => Controls_Manager::SLIDER,
'size_units' => [ 'px', '%', 'em', 'rem', 'vw', 'custom' ],
'range' => [
'px' => [
'min' => 10,
'max' => 1000,
],
],
'selectors' => [
'{{WRAPPER}} .elementor-number-box-description' => 'width: {{SIZE}}{{UNIT}};',
],
]
);
$this->add_control(
'description_color',
[
'label' => esc_html__( 'Color', 'elementor-addon' ),
'type' => Controls_Manager::COLOR,
'default' => '',
'selectors' => [
'{{WRAPPER}} .elementor-number-box-description' => 'color: {{VALUE}};',
],
'global' => [
'default' => Global_Colors::COLOR_TEXT,
],
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$has_link = ! empty( $settings['link']['url'] );
$html_tag = $has_link ? 'a' : 'span';
$this->add_render_attribute( 'number', 'class', 'elementor-number' );
if ( ! empty( $settings['hover_animation'] ) ) {
$this->add_render_attribute( 'number', 'class', 'elementor-animation-' . $settings['hover_animation'] );
}
$has_number = ! \Elementor\Utils::is_empty( $settings['number_text'] );
$has_content = ! \Elementor\Utils::is_empty( $settings['title_text'] ) || ! \Elementor\Utils::is_empty( $settings['description_text'] );
if ( ! $has_number && ! $has_content ) {
return;
}
if ( $has_link ) {
$this->add_link_attributes( 'link', $settings['link'] );
$this->add_render_attribute( 'number', 'tabindex', '-1' );
if ( ! empty( $settings['title_text'] ) ) {
$this->add_render_attribute( 'number', 'aria-label', $settings['title_text'] );
}
}
$this->add_render_attribute( 'description_text', 'class', 'elementor-number-box-description' );
$this->add_inline_editing_attributes( 'title_text', 'none' );
$this->add_inline_editing_attributes( 'description_text' );
?>
<div class="elementor-number-box-wrapper">
<?php if ( $has_number ) : ?>
<div class="elementor-number-box-number">
<<?php \Elementor\Utils::print_validated_html_tag( $html_tag ); ?> <?php $this->print_render_attribute_string( 'link' ); ?> <?php $this->print_render_attribute_string( 'number' ); ?>>
<?php echo wp_kses_post( $settings['number_text'] ); ?>
</<?php \Elementor\Utils::print_validated_html_tag( $html_tag ); ?>>
</div>
<?php endif; ?>
<?php if ( $has_content ) : ?>
<div class="elementor-number-box-content">
<?php if ( ! \Elementor\Utils::is_empty( $settings['title_text'] ) ) : ?>
<<?php \Elementor\Utils::print_validated_html_tag( $settings['title_size'] ); ?> class="elementor-number-box-title">
<<?php \Elementor\Utils::print_validated_html_tag( $html_tag ); ?> <?php $this->print_render_attribute_string( 'link' ); ?> <?php $this->print_render_attribute_string( 'title_text' ); ?>>
<?php echo wp_kses_post( $settings['title_text'] ); ?>
</<?php \Elementor\Utils::print_validated_html_tag( $html_tag ); ?>>
</<?php \Elementor\Utils::print_validated_html_tag( $settings['title_size'] ); ?>>
<?php endif; ?>
<?php if ( ! \Elementor\Utils::is_empty( $settings['description_text'] ) ) : ?>
<p <?php $this->print_render_attribute_string( 'description_text' ); ?>>
<?php echo wp_kses_post( $settings['description_text'] ); ?>
</p>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<?php
}
protected function content_template() {
?>
<#
var hasNumber = !! settings.number_text;
var hasContent = settings.title_text || settings.description_text;
if ( ! hasNumber && ! hasContent ) {
return;
}
var hasLink = settings.link?.url,
htmlTag = hasLink ? 'a' : 'span',
titleSizeTag = elementor.helpers.validateHTMLTag( settings.title_size );
view.addRenderAttribute( 'number', 'class', 'elementor-number' );
if ( '' !== settings.hover_animation ) {
view.addRenderAttribute( 'number', 'class', 'elementor-animation-' + settings.hover_animation );
}
if ( hasLink ) {
view.addRenderAttribute( 'link', 'href', elementor.helpers.sanitizeUrl( settings.link?.url ) );
view.addRenderAttribute( 'number', 'tabindex', '-1' );
if ( '' !== settings.title_text ) {
view.addRenderAttribute( 'number', 'aria-label', settings.title_text );
}
}
view.addRenderAttribute( 'description_text', 'class', 'elementor-number-box-description' );
view.addInlineEditingAttributes( 'title_text', 'none' );
view.addInlineEditingAttributes( 'description_text' );
#>
<div class="elementor-number-box-wrapper">
<# if ( hasNumber ) { #>
<div class="elementor-number-box-number">
<{{{ htmlTag }}} {{{ view.getRenderAttributeString( 'link' ) }}} {{{ view.getRenderAttributeString( 'number' ) }}}>
{{{ elementor.helpers.sanitize( settings.number_text ) }}}
</{{{ htmlTag }}}>
</div>
<# } #>
<# if ( hasContent ) { #>
<div class="elementor-number-box-content">
<# if ( settings.title_text ) { #>
<{{{ titleSizeTag }}} class="elementor-number-box-title">
<{{{ htmlTag }}} {{{ view.getRenderAttributeString( 'link' ) }}} {{{ view.getRenderAttributeString( 'title_text' ) }}}>
{{{ elementor.helpers.sanitize( settings.title_text ) }}}
</{{{ htmlTag }}}>
</{{{ titleSizeTag }}}>
<# } #>
<# if ( settings.description_text ) { #>
<p {{{ view.getRenderAttributeString( 'description_text' ) }}}>{{{ elementor.helpers.sanitize( settings.description_text ) }}}</p>
<# } #>
</div>
<# } #>
</div>
<?php
}
}