PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.6.2
Spider Elements – Premium Elementor Widgets & Addons Library v1.6.2
trunk 1.0.0 1.1.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 1.8.0 1.9.0
spider-elements / widgets / Counter.php
spider-elements / widgets Last commit date
templates 1 year ago Accordion.php 1 year ago Alerts_Box.php 1 year ago Before_after.php 1 year ago Blog_Grid.php 1 year ago Cheat_Sheet.php 1 year ago Counter.php 1 year ago Icon_Box.php 1 year ago Integrations.php 1 year ago List_Item.php 1 year ago Tabs.php 1 year ago Team_Carousel.php 1 year ago Testimonial.php 1 year ago Timeline.php 1 year ago Video_Playlist.php 1 year ago Video_Popup.php 1 year ago
Counter.php
460 lines
1 <?php
2 /**
3 * Use namespace to avoid conflict
4 */
5
6 namespace SPEL\Widgets;
7
8 use Elementor\Group_Control_Typography;
9 use Elementor\Widget_Base;
10 use Elementor\Controls_Manager;
11
12 // Exit if accessed directly
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Class Team
19 *
20 * @package spider\Widgets
21 * @since 1.0.0
22 */
23 class Counter extends Widget_Base {
24
25 public function get_name(): string
26 {
27 return 'spe_counter'; // ID of the widget (Don't change this name)
28 }
29
30 public function get_title(): string
31 {
32 return esc_html__( 'Counter', 'spider-elements' );
33 }
34
35 public function get_icon(): string
36 {
37 return 'eicon-counter spel-icon';
38 }
39
40 public function get_keywords(): array
41 {
42 return [ 'spider', 'Counter', 'Progress bar', ];
43 }
44
45 public function get_categories(): array
46 {
47 return [ 'spider-elements' ];
48 }
49
50 /**
51 * Name: get_style_depends()
52 * Desc: Register the required CSS dependencies for the frontend.
53 */
54 public function get_style_depends(): array
55 {
56 return [ 'spel-main' ];
57 }
58
59 /**
60 * Name: get_script_depends()
61 * Desc: Register the required JS dependencies for the frontend.
62 */
63 public function get_script_depends(): array
64 {
65 return [ 'spel-el-widgets', 'counterup', 'waypoint' ];
66 }
67
68 /**
69 * Name: register_controls()
70 * Desc: Register controls for these widgets
71 * Params: no params
72 * Return: @void
73 * Since: @1.0.0
74 * Package: @spider-elements
75 * Author: spider-themes
76 */
77 protected function register_controls(): void
78 {
79 $this->elementor_content_control();
80 $this->counter_style_control();
81 }
82
83
84 /**
85 * Name: elementor_content_control()
86 * Desc: Register the Content Tab output on the Elementor editor.
87 * Params: no params
88 * Return: @void
89 * Since: @1.0.0
90 * Package: @spider-elements
91 * Author: spider-themes
92 */
93
94 private function counter_layout_option(): array
95 {
96
97 if ( spel_is_premium() ) {
98 $options = [
99 '1' => [
100 'icon' => 'counter1',
101 'title' => esc_html__( '01 : Counter', 'spider-elements' )
102 ],
103 '2' => [
104 'icon' => 'counter2',
105 'title' => esc_html__( '02 : Counter', 'spider-elements' )
106 ],
107 ];
108 } else {
109 $options = [
110 '1' => [
111 'icon' => 'counter1',
112 'title' => esc_html__( '01 : Counter', 'spider-elements' )
113 ],
114 '2' => [
115 'icon' => 'counter2 spel-pro-label',
116 'title' => esc_html__( 'spel-pro-label', 'spider-elements' )
117 ],
118 ];
119 }
120
121 return $options;
122 }
123
124
125 public function elementor_content_control(): void
126 {
127
128
129 //==================== Select Preset Skin ====================//
130 $this->start_controls_section(
131 'counter_preset', [
132 'label' => esc_html__( 'Preset Skin', 'spider-elements' ),
133 ]
134 );
135
136
137 $this->add_control(
138 'style',
139 [
140 'label' => esc_html__( 'Counter Style', 'spider-elements' ),
141 'type' => Controls_Manager::CHOOSE,
142 'options' => $this->counter_layout_option(),
143 'default' => '1',
144 ]
145 );
146
147 $this->end_controls_section(); // End Preset Skin
148
149
150 //=================== Counter ===================//
151 $this->start_controls_section(
152 'sec_counter', [
153 'label' => esc_html__( 'Counter', 'spider-elements' ),
154 ]
155 );
156
157 $this->add_control(
158 'counter_value', [
159 'label' => esc_html__( 'Value', 'spider-elements' ),
160 'type' => Controls_Manager::NUMBER,
161 'default' => 85,
162 'min' => 0,
163 'max' => 100,
164 ]
165 );
166
167 // Control for Number Prefix & Suffix
168 $this->add_control(
169 'counter_prefix', [
170 'label' => esc_html__( 'Number Prefix', 'spider-elements' ),
171 'type' => \Elementor\Controls_Manager::TEXT,
172 ]
173 );
174
175 $this->add_control(
176 'counter_suffix', [
177 'label' => esc_html__( 'Number Suffix', 'spider-elements' ),
178 'type' => \Elementor\Controls_Manager::TEXT,
179 'default' => '%',
180 ]
181 );
182
183 $this->add_control(
184 'counter_text', [
185 'label' => esc_html__( 'Title', 'spider-elements' ),
186 'type' => Controls_Manager::TEXT,
187 'default' => esc_html__( 'User research', 'spider-elements' ),
188 ]
189 );
190
191 $this->end_controls_section(); //End Counter
192
193 }
194
195
196 /**
197 * Name: counter_style_control()
198 * Desc: Register the Style Tab output on the Elementor editor.
199 * Params: no params
200 * Return: @void
201 * Since: @1.0.0
202 * Package: @spider-elements
203 * Author: spider-themes
204 */
205 public function counter_style_control(): void
206 {
207
208 //===================== Counter Style ============================//
209 $this->start_controls_section(
210 'style_counter', [
211 'label' => esc_html__( 'Counter', 'spider-elements' ),
212 'tab' => Controls_Manager::TAB_STYLE,
213 ]
214 );
215
216 $this->add_group_control(
217 \Elementor\Group_Control_Background::get_type(),
218 [
219 'name' => 'style_bg',
220 'types' => [ 'classic', 'gradient' ],
221 'exclude' => [ 'image' ],
222 'selector' => '{{WRAPPER}} .skill_item_two .radial-progress',
223 'condition' => [
224 'style' => [ '2' ]
225 ]
226 ]
227 );
228
229 $this->add_control(
230 'style_radius',
231 [
232 'label' => esc_html__( 'Border Radius', 'spider-elements' ),
233 'type' => Controls_Manager::DIMENSIONS,
234 'size_units' => [ 'px' ],
235 'selectors' => [
236 '{{WRAPPER}} .skill_item_two .radial-progress' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
237 ],
238 'condition' => [
239 'style' => [ '2' ]
240 ]
241 ]
242 );
243
244 $this->add_responsive_control(
245 'counter_circle_size',
246 [
247 'label' => esc_html__( 'Size', 'spider-elements' ),
248 'type' => Controls_Manager::SLIDER,
249 'size_units' => [ 'px' ],
250 'range' => [
251 'px' => [
252 'min' => 50,
253 'max' => 500,
254 'step' => 1,
255 ],
256 ],
257 'default' => [
258 'unit' => 'px',
259 'size' => 100,
260 ],
261 'selectors' => [
262 '{{WRAPPER}} .skill_item svg.radial-progress' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};'
263 ],
264 'separator' => 'after',
265 ]
266 );
267
268 $this->add_control(
269 'fill_color',
270 [
271 'label' => esc_html__( 'Fill Color', 'spider-elements' ),
272 'type' => Controls_Manager::COLOR,
273 'selectors' => [
274 '{{WRAPPER}} svg.radial-progress circle.incomplete' => 'stroke: {{VALUE}};',
275 ],
276 ]
277 );
278
279 $this->add_control(
280 'stroke_color',
281 [
282 'label' => esc_html__( 'Stroke Color', 'spider-elements' ),
283 'type' => Controls_Manager::COLOR,
284 'selectors' => [
285 '{{WRAPPER}} .radial-progress .complete' => 'stroke: {{VALUE}};',
286 ],
287 ]
288 );
289
290 $this->add_responsive_control(
291 'counter_circle_stroke_width', [
292 'label' => esc_html__( 'Stroke Width', 'spider-elements' ),
293 'type' => Controls_Manager::SLIDER,
294 'size_units' => [ 'px' ],
295 'range' => [
296 'px' => [
297 'min' => 0,
298 'max' => 100,
299 'step' => 1,
300 ],
301 ],
302 'default' => [
303 'unit' => 'px',
304 'size' => 6,
305 ],
306 'selectors' => [
307 '{{WRAPPER}} svg.radial-progress circle' => 'stroke-width: {{SIZE}}{{UNIT}}',
308 ],
309 'separator' => 'before',
310 ]
311 );
312
313 $this->end_controls_section();
314
315
316 // Control for percent color
317 $this->start_controls_section(
318 'number_style', [
319 'label' => esc_html__( 'Number', 'spider-elements' ),
320 'tab' => Controls_Manager::TAB_STYLE,
321 ]
322 );
323
324 $this->add_group_control(
325 Group_Control_Typography::get_type(), [
326 'name' => 'number_typo',
327 'selector' => '{{WRAPPER}} .counters-container .skill_item .counter-wrap,
328 {{WRAPPER}} .skill_item_two .skill_pr .counter2-wrap',
329 ]
330
331 );
332
333 $this->add_control(
334 'number_color',
335 [
336 'label' => esc_html__( 'Color', 'spider-elements' ),
337 'type' => Controls_Manager::COLOR,
338 'selectors' => [
339 '{{WRAPPER}} .counters-container .skill_item .counter-wrap' => 'color: {{VALUE}};',
340 '{{WRAPPER}} .skill_item_two .skill_pr .counter2-wrap' => 'color: {{VALUE}};',
341 ],
342 ]
343 );
344
345 $this->add_responsive_control(
346 'prefix_suffix_size',
347 [
348 'label' => esc_html__( 'Number Gap', 'spider-elements' ),
349 'type' => Controls_Manager::SLIDER,
350 'size_units' => [ 'px', 'em', 'rem', '%' ],
351 'range' => [
352 'px' => [
353 'min' => 0,
354 'max' => 500,
355 'step' => 1,
356 ],
357 'em' => [
358 'min' => 0,
359 'max' => 50,
360 'step' => 0.1,
361 ],
362 'rem' => [
363 'min' => 0,
364 'max' => 50,
365 'step' => 0.1,
366 ],
367 '%' => [
368 'min' => 0,
369 'max' => 100,
370 'step' => 1,
371 ],
372 ],
373 'selectors' => [
374 '{{WRAPPER}} .counter-wrap' => 'gap: {{SIZE}}{{UNIT}};',
375 '{{WRAPPER}} .counter2-wrap' => 'gap: {{SIZE}}{{UNIT}};'
376 ],
377 'separator' => 'before',
378 ]
379 );
380
381 $this->end_controls_section();
382
383 // Control for text color
384 $this->start_controls_section(
385 'counter_title', [
386 'label' => esc_html__( 'Title', 'spider-elements' ),
387 'tab' => Controls_Manager::TAB_STYLE,
388 ]
389 );
390
391 $this->add_group_control(
392 Group_Control_Typography::get_type(), [
393 'name' => 'counter_text_typo',
394 'selector' => '{{WRAPPER}} .counters-container .spel_counter_title,
395 {{WRAPPER}} .skill_item .spel_counter_title'
396 ]
397 );
398
399 $this->add_control(
400 'counter_text_color',
401 [
402 'label' => esc_html__( 'Color', 'spider-elements' ),
403 'type' => Controls_Manager::COLOR,
404 'selectors' => [
405 '{{WRAPPER}} .skill_item .spel_counter_title' => 'color: {{VALUE}};',
406 '{{WRAPPER}} .counters-container .spel_counter_title' => 'color: {{VALUE}};',
407 ],
408 ]
409 );
410
411 $this->add_responsive_control(
412 'counter_text_margin',
413 [
414 'label' => esc_html__( 'Margin Top', 'spider-elements' ),
415 'type' => Controls_Manager::SLIDER,
416 'size_units' => [ 'px', '%' ],
417 'range' => [
418 'px' => [
419 'min' => 0,
420 'max' => 100,
421 'step' => 1,
422 ],
423 ],
424 'default' => [
425 'size' => 6,
426 ],
427 'selectors' => [
428 '{{WRAPPER}} .skill_item .spel_counter_title' => 'margin-top: {{SIZE}}{{UNIT}}',
429 '{{WRAPPER}} .counters-container .spel_counter_title' => 'margin-top: {{SIZE}}{{UNIT}}',
430
431 ],
432 ]
433 );
434 $this->end_controls_section();
435
436 }
437
438 /**
439 * Name: elementor_render()
440 * Desc: Render the widget output on the frontend.
441 * Params: no params
442 * Return: @void
443 * Since: @1.0.0
444 * Package: @spider-elements
445 * Author: spider-themes
446 */
447 protected function render(): void
448 {
449 $settings = $this->get_settings_for_display();
450 extract( $settings ); //extract all settings array to variables converted to name of key
451
452 //================= Template Parts =================//
453 if (spel_is_premium()) {
454 include "templates/counter/counter-{$settings['style']}.php";
455 } else {
456 include "templates/counter/counter-1.php";
457 }
458
459 }
460 }