PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.2.6
ShopBuilder – WooCommerce Builder For Elementor v3.2.6
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Elementor / Widgets / General / Counter / Render.php

Render.php in ShopBuilder – WooCommerce Builder For Elementor 3.2.6, at app/Elementor/Widgets/General/Counter/Render.php

145 lines 5.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Render class for Advanced Heading widget.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Elementor\Widgets\General\Counter;
9
10 use RadiusTheme\SB\Elementor\Helper\RenderHelpers;
11 use RadiusTheme\SB\Helpers\Fns;
12 use RadiusTheme\SB\Elementor\Render\GeneralAddons;
13
14 // Do not allow directly accessing this file.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit( 'This script cannot be accessed directly.' );
17 }
18
19 /**
20 * Render class.
21 *
22 * @package RadiusTheme\SB
23 */
24 class Render extends GeneralAddons {
25 /**
26 * Main render function for displaying content.
27 *
28 * @param array $data Data to be passed to the template.
29 * @param array $settings Widget settings.
30 *
31 * @return string
32 */
33 public function display_content( $data, $settings ) {
34 $this->settings = $settings;
35 $data = wp_parse_args( $this->get_template_args( $data['id'] ), $data );
36 $data = apply_filters( 'rtsb/general/counter/args/' . $data['unique_name'], $data );
37 $data['content'] = Fns::load_template( $data['template'], $data, true );
38
39 return $this->addon_view( $data, $settings );
40 }
41
42 /**
43 * Retrieves template arguments based on widget settings.
44 *
45 * @return array
46 */
47 private function get_template_args( $id ) {
48 return [
49 'counter_title_html_tag' => $this->settings['counter_title_html_tag'] ?? 'h2',
50 'counter_title' => $this->settings['counter_title'],
51 'counter_count' => $this->settings['counter_count'] ?? '1000',
52 'counter_transition' => $this->settings['counter_transition'] ?? '2000',
53 'icon_position' => $this->settings['counter_icon_position'] ?? 'center',
54 'has_prefix' => ! empty( $this->settings['display_prefix'] ) && ! empty( $this->settings['count_prefix'] ),
55 'has_suffix' => ! empty( $this->settings['display_suffix'] ) && ! empty( $this->settings['count_suffix'] ),
56 'prefix' => $this->settings['count_prefix'] ?? '+',
57 'suffix' => $this->settings['count_suffix'] ?? '+',
58 'icon_html' => $this->render_icon_image(),
59 'icon_type' => $this->settings['counter_icon_type'] ?? 'icon',
60 'icon_bg_type' => ! empty( $this->settings['counter_icon_style_gradient_bg_background'] ) ? $this->settings['counter_icon_style_gradient_bg_background'] : 'classic',
61 'icon_hover_bg_type' => ! empty( $this->settings['counter_icon_style_hover_gradient_bg_background'] ) ? $this->settings['counter_icon_style_hover_gradient_bg_background'] : 'classic',
62 ];
63 }
64
65 /**
66 * Function to render number.
67 *
68 * @param integer $number Position of the separator in settings.
69 *
70 * @return string
71 */
72 public static function render_count_number( $number, $has_prefix, $prefix, $has_suffix, $suffix, $transition ) {
73 ob_start();
74 ?>
75 <div class="rtsb-counter-number-wrap" style="--odo-duration: <?php echo esc_attr( $transition ); ?>ms">
76 <?php if ( $has_prefix ) { ?>
77 <span class="rtsb-counter-prefix"><?php Fns::print_html( $prefix ); ?></span>
78 <?php } ?>
79 <div class="rtsb-count-number rtsb-counter-number" data-count="<?php echo esc_attr( $number ); ?>" data-format="<?php echo esc_attr( '(,ddd)' ); ?>" data-duration="<?php echo esc_attr( $transition ); ?>">
80 <?php
81 $digitCount = strlen( (string) abs( $number ) );
82 $zeroes = str_repeat( 0, $digitCount );
83
84 echo esc_html( preg_replace( '/\B(?=(\d{3})+(?!\d))/', ',', $zeroes ) );
85 ?>
86 </div>
87 <?php if ( $has_suffix ) : ?>
88 <span class="rtsb-counter-suffix"><?php Fns::print_html( $suffix ); ?></span>
89 <?php endif ?>
90 </div>
91 <?php
92 return ob_get_clean();
93 }
94
95 /**
96 * Function to render icon.
97 *
98 * @param string $position icon position ('left' or 'right').
99 * @param array $icon Position of the separator in settings.
100 *
101 * @return string
102 */
103 public static function render_icon( $position, $icon, $icon_position ) {
104 $html = '';
105
106 // Render the left icon.
107 if ( $position === $icon_position ) {
108 $html .= '<span class="icon">' . Fns::icons_manager( $icon ) . '</span>';
109 }
110
111 return $html;
112 }
113
114 /**
115 * Function to render icon image.
116 *
117 * @return string
118 */
119 public function render_icon_image() {
120 $icon_img_html = '';
121
122 $icon = $this->settings['counter_icon'] ?? '';
123
124 if ( ! empty( $icon['value'] ) && 'icon' === $this->settings['counter_icon_type'] ) {
125 $icon_img_html .= '<span class="icon">' . Fns::icons_manager( $icon ) . '</span>';
126 } else {
127 if ( ! empty( $this->settings['counter_image'] ) ) {
128 $c_image_size = RenderHelpers::get_data( $this->settings, 'counter_img_dimension', [] );
129 $c_image_size['crop'] = RenderHelpers::get_data( $this->settings, 'counter_img_crop', [] );
130 $c_image_size = ! empty( $c_image_size ) && is_array( $c_image_size ) ? $c_image_size : [];
131 $image_id = ! empty( $this->settings['counter_image']['id'] ) ? $this->settings['counter_image']['id'] : $this->settings['counter_image'];
132 $icon_img_html .= Fns::get_product_image_html(
133 '',
134 null,
135 RenderHelpers::get_data( $this->settings, 'counter_image_size', 'full' ),
136 $image_id,
137 $c_image_size
138 );
139 }
140 }
141
142 return $icon_img_html;
143 }
144 }
145