PluginProbe
Borderless – Addons and Templates for Elementor / trunk
Borderless – Addons and Templates for Elementor vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 All 78 releases
borderless / modules / elementor / widgets / progress-bar.php

progress-bar.php in Borderless – Addons and Templates for Elementor trunk, at modules/elementor/widgets/progress-bar.php

422 lines 12.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Borderless\Widgets;
4
5 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
6
7 use \Elementor\Controls_Manager;
8 use \Elementor\Group_Control_Background;
9 use \Elementor\Group_Control_Box_Shadow;
10 use \Elementor\Group_Control_Typography;
11 use \Elementor\Core\Kits\Documents\Tabs\Global_Typography;
12 use \Elementor\Widget_Base;
13
14 class Progress_Bar extends Widget_Base {
15
16 public function get_name() {
17 return 'borderless-elementor-progress-bar';
18 }
19
20 public function get_title() {
21 return esc_html__( 'Progress Bar', 'borderless' );
22 }
23
24 public function get_icon() {
25 return 'borderless-icon-progress-bar';
26 }
27
28 public function get_categories() {
29 return [ 'borderless' ];
30 }
31
32 public function get_keywords() {
33 return [
34 'progress bar',
35 'bar',
36 'borderless',
37 'borderless progress bar',
38 'borderless bar'
39 ];
40 }
41
42 public function get_custom_help_url() {
43 return 'https://wpborderless.com/';
44 }
45
46 public function get_style_depends() {
47 return [ 'borderless-elementor-style' ];
48 }
49
50 public function get_script_depends() {
51 return [
52 'borderless-elementor-appear-script',
53 'borderless-elementor-progressbar-script',
54 ];
55 }
56
57 protected function _register_controls() {
58
59 /*-----------------------------------------------------------------------------------*/
60 /* *. Layout
61 /*-----------------------------------------------------------------------------------*/
62 $this->start_controls_section(
63 'borderless_elementor_section_progress_bar_layout',
64 [
65 'label' => esc_html__( 'Layout', 'borderless' ),
66 'tab' => Controls_Manager::TAB_CONTENT,
67 ]
68 );
69
70 $this->add_control(
71 'borderless_elementor_progress_bar_title',
72 [
73 'label' => esc_html__( 'Title', 'borderless' ),
74 'type' => Controls_Manager::TEXT,
75 'dynamic' => [ 'active' => true ],
76 ]
77 );
78
79 $this->add_control(
80 'borderless_elementor_progress_bar_counter_value',
81 [
82 'label' => esc_html__( 'Counter Value', 'borderless' ),
83 'type' => Controls_Manager::SLIDER,
84 'size_units' => [ '%' ],
85 'range' => [
86 '%' => [
87 'min' => 1,
88 'max' => 100,
89 ],
90 ],
91 'default' => [
92 'unit' => '%',
93 'size' => 50,
94 ],
95 'separator' => 'before',
96 ]
97 );
98
99 $this->add_control(
100 'borderless_elementor_progress_bar_animation_duration',
101 [
102 'label' => __( 'Animation Duration', 'borderless' ),
103 'type' => Controls_Manager::SLIDER,
104 'size_units' => [ 'px' ],
105 'range' => [
106 'px' => [
107 'min' => 1000,
108 'max' => 10000,
109 'step' => 100,
110 ],
111 ],
112 'default' => [
113 'unit' => 'px',
114 'size' => 1500,
115 ],
116 'separator' => 'before',
117 ]
118 );
119
120 $this->end_controls_section();
121
122
123 /*-----------------------------------------------------------------------------------*/
124 /* *. Layout - Style
125 /*-----------------------------------------------------------------------------------*/
126 $this->start_controls_section(
127 'borderless_elementor_section_progress_bar_styles_general',
128 [
129 'label' => esc_html__( 'General', 'borderless' ),
130 'tab' => Controls_Manager::TAB_STYLE,
131 ]
132 );
133
134 $this->add_control(
135 'borderless_elementor_progress_bar_alignment',
136 [
137 'label' => __( 'Alignment', 'borderless' ),
138 'type' => Controls_Manager::CHOOSE,
139 'options' => [
140 'borderless-elementor-progress-bar-alignment-left' => [
141 'title' => __( 'Left', 'borderless' ),
142 'icon' => 'fa fa-align-left',
143 ],
144 'borderless-elementor-progress-bar-alignment-center' => [
145 'title' => __( 'Center', 'borderless' ),
146 'icon' => 'fa fa-align-center',
147 ],
148 'borderless-elementor-progress-bar-alignment-right' => [
149 'title' => __( 'Right', 'borderless' ),
150 'icon' => 'fa fa-align-right',
151 ],
152 ],
153 'default' => 'borderless-elementor-progress-bar-alignment-center',
154 ]
155 );
156
157 $this->add_control(
158 'borderless_elementor_progress_bar_size',
159 [
160 'label' => __( 'Size', 'borderless' ),
161 'type' => Controls_Manager::SLIDER,
162 'size_units' => [ '%' ],
163 'range' => [
164 '%' => [
165 'min' => 1,
166 'max' => 100,
167 'step' => 1,
168 ],
169 ],
170 'default' => [
171 'unit' => '%',
172 'size' => 100,
173 ],
174 'selectors' => [
175 '{{WRAPPER}} .borderless-elementor-progress-bar' => 'width: {{SIZE}}{{UNIT}};',
176 ],
177 'separator' => 'before',
178 ]
179 );
180
181 $this->add_control(
182 'borderless_elementor_progress_bar_stroke_width',
183 [
184 'label' => __( 'Stroke Width', 'borderless' ),
185 'type' => Controls_Manager::SLIDER,
186 'size_units' => [ 'px' ],
187 'range' => [
188 'px' => [
189 'min' => 0,
190 'max' => 100,
191 'step' => 1,
192 ],
193 ],
194 'default' => [
195 'unit' => 'px',
196 'size' => 2,
197 ],
198 'separator' => 'before',
199 ]
200 );
201
202 $this->add_control(
203 'borderless_elementor_progress_bar_stroke_color_style',
204 [
205 'label' => __( 'Stroke Color Style', 'borderless' ),
206 'type' => Controls_Manager::SELECT,
207 'default' => 'borderless-elementor-progress-bar-stroke-solid-color',
208 'options' => [
209 'borderless-elementor-progress-bar-stroke-solid-color' => __( 'Solid', 'borderless' ),
210 'borderless-elementor-progress-bar-stroke-gradient-color' => __( 'Gradient', 'borderless' ),
211 ],
212 ]
213 );
214
215 $this->add_control(
216 'borderless_elementor_progress_bar_stroke_color',
217 [
218 'label' => __( 'Stroke Color', 'borderless' ),
219 'type' => Controls_Manager::COLOR,
220 'default' => '#000',
221 'condition' => [
222 'borderless_elementor_progress_bar_stroke_color_style' => 'borderless-elementor-progress-bar-stroke-solid-color',
223 ],
224 ]
225 );
226
227 $this->add_control(
228 'borderless_elementor_progress_bar_stroke_color_from',
229 [
230 'label' => __( 'Stroke Color From', 'borderless' ),
231 'type' => Controls_Manager::COLOR,
232 'default' => '#000',
233 'condition' => [
234 'borderless_elementor_progress_bar_stroke_color_style' => 'borderless-elementor-progress-bar-stroke-gradient-color',
235 ],
236 ]
237 );
238
239 $this->add_control(
240 'borderless_elementor_progress_bar_stroke_color_to',
241 [
242 'label' => __( 'Stroke Color To', 'borderless' ),
243 'type' => Controls_Manager::COLOR,
244 'default' => '#000',
245 'condition' => [
246 'borderless_elementor_progress_bar_stroke_color_style' => 'borderless-elementor-progress-bar-stroke-gradient-color',
247 ],
248 ]
249 );
250
251 $this->add_control(
252 'borderless_elementor_progress_bar_trail_width',
253 [
254 'label' => __( 'Trail Width', 'borderless' ),
255 'type' => Controls_Manager::SLIDER,
256 'size_units' => [ 'px' ],
257 'range' => [
258 'px' => [
259 'min' => 0,
260 'max' => 100,
261 'step' => 1,
262 ],
263 ],
264 'default' => [
265 'unit' => 'px',
266 'size' => 2,
267 ],
268 'separator' => 'before',
269 ]
270 );
271
272 $this->add_control(
273 'borderless_elementor_progress_bar_trail_color',
274 [
275 'label' => __( 'Trail Color', 'borderless' ),
276 'type' => Controls_Manager::COLOR,
277 'default' => '#eee',
278 ]
279 );
280
281 $this->add_control(
282 'borderless_elementor_progress_bar_background_color',
283 [
284 'label' => __( 'Background Color', 'borderless' ),
285 'type' => Controls_Manager::COLOR,
286 'default' => '#fff',
287 'selectors' => [
288 '{{WRAPPER}} .borderless-elementor-progress-bar' => 'background-color: {{VALUE}}',
289 ],
290 'separator' => 'before',
291 ]
292 );
293
294 $this->add_group_control(
295 Group_Control_Box_Shadow::get_type(),
296 [
297 'name' => 'borderless_elementor_progress_bar_box_shadow',
298 'label' => __( 'Box Shadow', 'borderless' ),
299 'selector' => '{{WRAPPER}} .borderless-elementor-progress-bar',
300 'separator'=> 'before',
301 ]
302 );
303
304 $this->end_controls_section();
305
306
307 /*-----------------------------------------------------------------------------------*/
308 /* *. Typography - Style
309 /*-----------------------------------------------------------------------------------*/
310 $this->start_controls_section(
311 'borderless_section_circular_progress_bar_typography',
312 [
313 'label' => __( 'Typography', 'borderless' ),
314 'tab' => Controls_Manager::TAB_STYLE,
315 ]
316 );
317
318 $this->add_group_control(
319 Group_Control_Typography::get_type(),
320 [
321 'name' => 'borderless_elementor_progress_bar_title_typography',
322 'label' => __( 'Title', 'borderless' ),
323 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY ],
324 'selector'=> '{{WRAPPER}} .borderless-elementor-progress-bar .progressbar-text div .borderless-elementor-progress-bar-title',
325 ]
326 );
327
328 $this->add_control(
329 'borderless_elementor_progress_bar_title_color',
330 [
331 'label' => __( 'Title Color', 'borderless' ),
332 'type' => Controls_Manager::COLOR,
333 'default' => '',
334 'selectors' => [
335 '{{WRAPPER}} .borderless-elementor-progress-bar .progressbar-text div .borderless-elementor-progress-bar-title' => 'color: {{VALUE}}',
336 ],
337 'separator'=> 'after',
338 ]
339 );
340
341 $this->add_group_control(
342 Group_Control_Typography::get_type(),
343 [
344 'name' => 'borderless_elementor_progress_bar_counter_typography',
345 'label' => __( 'Counter', 'borderless' ),
346 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY ],
347 'selector' => '{{WRAPPER}} .borderless-elementor-progress-bar .progressbar-text div .borderless-elementor-progress-bar-counter-value',
348 ]
349 );
350
351 $this->add_control(
352 'borderless_elementor_progress_bar_counter_color',
353 [
354 'label' => __( 'Counter Color', 'borderless' ),
355 'type' => Controls_Manager::COLOR,
356 'default' => '',
357 'separator'=> 'after',
358 ]
359 );
360
361 $this->add_group_control(
362 Group_Control_Typography::get_type(),
363 [
364 'name' => 'borderless_elementor_progress_bar_postfix_typography',
365 'label' => __( 'Postfix', 'borderless' ),
366 'global' => [ 'default' => Global_Typography::TYPOGRAPHY_PRIMARY ],
367 'selector' => '{{WRAPPER}} .borderless-elementor-progress-bar .progressbar-text div .borderless-elementor-progress-bar-counter-postfix',
368 ]
369 );
370
371 $this->add_control(
372 'borderless_elementor_progress_bar_postfix_color',
373 [
374 'label' => __( 'Postfix Color', 'borderless' ),
375 'type' => Controls_Manager::COLOR,
376 'default' => '',
377 'selectors' => [
378 '{{WRAPPER}} .borderless-elementor-progress-bar .progressbar-text div .borderless-elementor-progress-bar-counter-postfix' => 'color: {{VALUE}}',
379 ],
380 ]
381 );
382
383 $this->end_controls_section();
384 }
385
386 /*-----------------------------------------------------------------------------------*/
387 /* *. Render
388 /*-----------------------------------------------------------------------------------*/
389 protected function render() {
390 $settings = $this->get_settings_for_display();
391
392 // Sanitize and escape the Title field to prevent stored XSS
393 $raw_title = $settings['borderless_elementor_progress_bar_title'];
394 $clean_title = sanitize_text_field( $raw_title );
395 $safe_title = esc_js( $clean_title );
396
397 if ( 'borderless-elementor-progress-bar-stroke-solid-color' === $settings['borderless_elementor_progress_bar_stroke_color_style'] ) {
398 $stroke_color_style = 'stroke_color_mode="solid" stroke_color="' . esc_attr( $settings['borderless_elementor_progress_bar_stroke_color'] ) . '"';
399 } else {
400 $stroke_color_style = 'stroke_color_mode="gradient" '
401 . 'stroke_color="' . esc_attr( $settings['borderless_elementor_progress_bar_stroke_color'] ) . '" '
402 . 'stroke_color_from="' . esc_attr( $settings['borderless_elementor_progress_bar_stroke_color_from'] ) . '" '
403 . 'stroke_color_to="' . esc_attr( $settings['borderless_elementor_progress_bar_stroke_color_to'] ) . '"';
404 }
405
406 echo '<div class="borderless-elementor-progress-bar-widget ' . esc_attr( $settings['borderless_elementor_progress_bar_alignment'] ) . '">
407 <div class="borderless-elementor-progress-bar ' . esc_attr( $settings['borderless_elementor_progress_bar_shape'] ) . '"
408 title="' . $safe_title . '"
409 counter_value="' . esc_attr( $settings['borderless_elementor_progress_bar_counter_value']['size'] ) . '"
410 ' . $stroke_color_style . '
411 trail_color="' . esc_attr( $settings['borderless_elementor_progress_bar_trail_color'] ) . '"
412 counter_color="' . esc_attr( $settings['borderless_elementor_progress_bar_counter_color'] ) . '"
413 stroke_width="' . esc_attr( $settings['borderless_elementor_progress_bar_stroke_width']['size'] ) . '"
414 trail_width="' . esc_attr( $settings['borderless_elementor_progress_bar_trail_width']['size'] ) . '"
415 animation_duration="' . esc_attr( $settings['borderless_elementor_progress_bar_animation_duration']['size'] ) . '">
416 </div>
417 </div>';
418 }
419
420 protected function _content_template() {}
421 }
422