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