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 / ProgressBar / Render.php

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

222 lines 7.5 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\ProgressBar;
9
10 use DateTime;
11 use DateTimeZone;
12 use RadiusTheme\SB\Elementor\Helper\RenderHelpers;
13 use RadiusTheme\SB\Helpers\Fns;
14 use RadiusTheme\SB\Elementor\Render\GeneralAddons;
15
16 // Do not allow directly accessing this file.
17 if ( ! defined( 'ABSPATH' ) ) {
18 exit( 'This script cannot be accessed directly.' );
19 }
20
21 /**
22 * Render class.
23 *
24 * @package RadiusTheme\SB
25 */
26 class Render extends GeneralAddons {
27 /**
28 * Main render function for displaying content.
29 *
30 * @param array $data Data to be passed to the template.
31 * @param array $settings Widget settings.
32 *
33 * @return string
34 */
35 public function display_content( $data, $settings ) {
36 $this->settings = $settings;
37 $data = wp_parse_args( $this->get_template_args( $data['id'] ), $data );
38 $data = apply_filters( 'rtsb/general/progress_bar/args/' . $data['unique_name'], $data );
39 $data['content'] = Fns::load_template( $data['template'], $data, true );
40
41 return $this->addon_view( $data, $settings );
42 }
43 /**
44 * Retrieves template arguments based on widget settings.
45 *
46 * @return array
47 */
48 private function get_template_args( $id ) {
49 return [
50 'has_label' => ! empty( $this->settings['display_progress_label'] ) && ! empty( $this->settings['progress_label'] ),
51 'wrapper_class' => $this->generate_wrapper_class(),
52 'rtsb_progress_bar_html' => $this->render_progress_bar(),
53 ];
54 }
55 /**
56 * Function to render progressbar.
57 *
58 * @return string
59 */
60 public function render_progress_bar() {
61 $layout = $this->settings['layout_style'] ?? 'rtsb-countdown-layout1';
62 $progress_count = $this->settings['progress_count'] ?? 80;
63 $animation_duration = $this->settings['progress_bar_transition'] ?? 1500;
64 $has_label = ! empty( $this->settings['display_progress_label'] ) && ! empty( $this->settings['progress_label'] );
65 $has_count = ! empty( $this->settings['display_progress_count'] ) && ! empty( $this->settings['progress_count'] );
66 ob_start();
67 ?>
68 <div class="rtsb-progressbar-<?php echo esc_attr( $layout ); ?>-container">
69
70 <?php if ( ( 'rtsb-progress-bar-layout1' === $layout || 'rtsb-progress-bar-layout4' === $layout ) && $has_label ) { ?>
71 <div class="rtsb-progressbar-label-wrap">
72 <h4 class="rtsb-pb-label"><?php echo esc_html( $this->settings['progress_label'] ); ?></h4>
73 </div>
74 <?php } ?>
75
76 <div class="<?php echo esc_attr( $this->layout_class() ); ?>" data-layout="<?php echo esc_attr( $this->layout_class( true ) ); ?>" data-count="<?php echo esc_attr( $progress_count ); ?>" data-duration="<?php echo esc_attr( $animation_duration ); ?>">
77
78 <?php if ( 'rtsb-progress-bar-layout1' === $layout ) { ?>
79 <?php if ( $has_count ) { ?>
80 <span class="rtsb-pb-count-wrap">
81 <span class="rtsb-pb-count">0</span>
82 <span class="postfix">%</span>
83 </span>
84 <?php } ?>
85 <span class="rtsb-pb-line-fill"></span>
86 <?php } ?>
87 <?php if ( 'rtsb-progress-bar-layout4' === $layout ) { ?>
88 <span class="rtsb-pb-line-fill">
89 <?php if ( $has_count ) { ?>
90 <span class="rtsb-pb-count-wrap">
91 <span class="rtsb-pb-count"><?php echo esc_html( $this->settings['progress_count'] ); ?></span>
92 <span class="postfix">%</span>
93 </span>
94 <?php } ?>
95 </span>
96 <?php } ?>
97 <?php if ( 'rtsb-progress-bar-layout5' === $layout ) { ?>
98 <?php
99 if ( $has_label ) {
100 ?>
101 <div class="rtsb-progressbar-label-wrap">
102 <h4 class="rtsb-pb-label"><?php echo esc_html( $this->settings['progress_label'] ); ?></h4>
103 </div>
104 <?php } ?>
105 <div class="rtsb-pb-line-fill">
106 <?php if ( $has_count ) { ?>
107 <span class="rtsb-pb-count-wrap">
108 <span class="rtsb-pb-count"><?php echo esc_html( $this->settings['progress_count'] ); ?></span>
109 <span class="postfix">%</span>
110 </span>
111 <?php } ?>
112 </div>
113 <?php } ?>
114 <?php if ( 'rtsb-progress-bar-layout2' === $layout ) { ?>
115 <div class="rtsb-pb-circle-pie">
116 <div class="rtsb-pb-circle-left rtsb-pb-circle-half"></div>
117 <div class="rtsb-pb-circle-right rtsb-pb-circle-half"></div>
118 </div>
119
120 <div class="rtsb-pb-circle-inner"></div>
121
122 <div class="rtsb-pb-circle-inner-content">
123 <?php if ( $has_count ) { ?>
124 <span class="rtsb-pb-count-wrap">
125 <span class="rtsb-pb-count"><?php echo esc_html( $this->settings['progress_count'] ); ?></span>
126 <span class="postfix">%</span>
127 </span>
128 <?php } ?>
129 </div>
130 <?php } ?>
131
132
133 <?php if ( 'rtsb-progress-bar-layout3' === $layout ) { ?>
134 <div class="rtsb-pb-circle">
135 <div class="rtsb-pb-circle-pie">
136 <div class="rtsb-pb-circle-half" ref={circle_half}></div>
137 </div>
138 <div class="rtsb-pb-circle-inner"></div>
139 </div>
140
141 <div class="rtsb-pb-circle-inner-content">
142 <?php if ( $has_count ) : ?>
143 <span class="rtsb-pb-count-wrap">
144 <span class="rtsb-pb-count"><?php echo esc_html( $this->settings['progress_count'] ); ?></span>
145 <span class="postfix">%</span>
146 </span>
147 <?php endif; ?>
148 </div>
149 <?php } ?>
150
151 </div>
152
153 <?php if ( ( 'rtsb-progress-bar-layout2' === $layout ) && $has_label ) { ?>
154 <div class="rtsb-progressbar-label-wrap">
155 <h4 class="rtsb-pb-label"><?php echo esc_html( $this->settings['progress_label'] ); ?></h4>
156 </div>
157 <?php } ?>
158
159 <?php if ( ( 'rtsb-progress-bar-layout3' === $layout ) && $has_label ) { ?>
160 <div class="rtsb-progressbar-label-wrap">
161 <h4 class="rtsb-pb-label"><?php echo esc_html( $this->settings['progress_label'] ); ?></h4>
162 </div>
163 <?php } ?>
164 </div>
165 <?php
166 return ob_get_clean();
167 }
168 /**
169 * Function to render layout class.
170 *
171 * @return string
172 */
173 public function layout_class( $data_attribute = false ) {
174 $data_layout = 'line';
175 $layout_class = 'rtsb-progressbar';
176 if ( ! empty( $this->settings['layout_style'] ) ) {
177 if ( self::progress_bar_style_line_layout( $this->settings['layout_style'] ) ) {
178 $layout_class .= ' rtsb-pb-line';
179 } elseif ( 'rtsb-progress-bar-layout2' === $this->settings['layout_style'] ) {
180 $layout_class .= ' rtsb-pb-circle';
181 $data_layout = 'circle';
182 } elseif ( 'rtsb-progress-bar-layout3' === $this->settings['layout_style'] ) {
183 $layout_class .= ' rtsb-pb-half_circle';
184 $data_layout = 'half_circle';
185 }
186 if ( $this->settings['display_progress_stripe'] ) {
187 $layout_class .= ' rtsb-pb-line-stripe';
188 }
189 if ( $data_attribute ) {
190 return $data_layout;
191 }
192 }
193 return $layout_class;
194 }
195 /**
196 * Function to generate wrapper class.
197 *
198 * @return string
199 */
200 public function generate_wrapper_class() {
201 $wrapper_class = '';
202 if ( ! empty( $this->settings['layout_style'] ) ) {
203 if ( self::progress_bar_style_line_layout( $this->settings['layout_style'] ) ) {
204 $wrapper_class = 'rtsb-prgressbar-style-line';
205 } elseif ( 'rtsb-progress-bar-layout2' === $this->settings['layout_style'] ) {
206 $wrapper_class = 'rtsb-prgressbar-style-circle';
207 } elseif ( 'rtsb-progress-bar-layout3' === $this->settings['layout_style'] ) {
208 $wrapper_class = 'rtsb-prgressbar-style-half_circle';
209 }
210 }
211 return $wrapper_class;
212 }
213
214 public static function progress_bar_style_line_layout( $layout ) {
215 $line_layouts = [ 'rtsb-progress-bar-layout1','rtsb-progress-bar-layout4','rtsb-progress-bar-layout5' ];
216 if ( in_array( $layout, $line_layouts, true ) ) {
217 return true;
218 }
219 return false;
220 }
221 }
222