PluginProbe
WPB Addons for Elementor – News Ticker, Timeline, Team & More Widgets / 1.2
WPB Addons for Elementor – News Ticker, Timeline, Team & More Widgets v1.2
trunk 1.0.8.7 1.0.8.8 1.0.8.9 1.0.9 1.2 1.3 1.4 1.5 1.6 1.7
wpb-elementor-addons / templates / counter.php

counter.php in WPB Addons for Elementor – News Ticker, Timeline, Team & More Widgets 1.2, at templates/counter.php

557 lines 15.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @author WpBean
4 * @version 1.0
5 */
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 use Elementor\Controls_Manager;
12 use Elementor\Group_Control_Border;
13 use Elementor\Group_Control_Box_Shadow;
14 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
15 use Elementor\Core\Kits\Documents\Tabs\Global_Typography;
16
17
18 class WPB_EA_CounterUp extends \Elementor\Widget_Base {
19
20 public function get_name() {
21 return 'wpb-ea-counterup-settings';
22 }
23
24 public function get_title() {
25 return esc_html__( 'WPB CounterUp', 'wpb-elementor-addons' );
26 }
27
28 public function get_icon() {
29 return 'eicon-counter';
30 }
31
32 public function get_categories() {
33 return array( 'wpb_ea_widgets' );
34 }
35
36 /**
37 * Retrieve the list of scripts the counter widget depended on.
38 *
39 * Used to set scripts dependencies required to run the widget.
40 *
41 * @since 1.3.0
42 * @access public
43 *
44 * @return array Widget scripts dependencies.
45 */
46 public function get_script_depends() {
47 return array(
48 'wpb-ea-counterup',
49 'wpb-ea-waypoints',
50 'wpb-ea-super-js',
51 );
52 }
53
54 protected function register_controls() {
55 $wpb_ea_primary_color = wpb_ea_get_option( 'wpb_ea_primary_color', 'wpb_ea_style', '#3878ff' );
56
57 $this->start_controls_section(
58 'wpb_ea_counterup_details',
59 array(
60 'label' => esc_html__( 'CounterUp Details', 'wpb-elementor-addons' ),
61 )
62 );
63
64 $repeater = new \Elementor\Repeater();
65
66 $repeater->add_control(
67 'icon_type',
68 array(
69 'label' => esc_html__( 'Type', 'wpb-elementor-addons' ),
70 'type' => \Elementor\Controls_Manager::CHOOSE,
71 'label_block' => true,
72 'default' => 'icon',
73 'options' => array(
74 'icon' => array(
75 'title' => esc_html__( 'Icon', 'wpb-elementor-addons' ),
76 'icon' => 'fa fa-diamond',
77 ),
78 'custom' => array(
79 'title' => esc_html__( 'Image', 'wpb-elementor-addons' ),
80 'icon' => 'fa fa-photo',
81 ),
82 ),
83 )
84 );
85
86 $repeater->add_control(
87 'icon',
88 array(
89 'label' => esc_html__( 'Icon', 'wpb-elementor-addons' ),
90 'type' => \Elementor\Controls_Manager::ICONS,
91 'label_block' => true,
92 'default' => array(
93 'value' => 'fas fa-star',
94 'library' => 'solid',
95 ),
96 'condition' => array(
97 'icon_type' => 'icon',
98 ),
99 )
100 );
101
102 $repeater->add_control(
103 'custom',
104 array(
105 'label' => esc_html__( 'Image', 'wpb-elementor-addons' ),
106 'label_block' => true,
107 'type' => Controls_Manager::MEDIA,
108 'default' => array(),
109 'condition' => array(
110 'icon_type' => 'custom',
111 ),
112 )
113 );
114
115 $repeater->add_control(
116 'title',
117 array(
118 'label' => esc_html__( 'Title', 'wpb-elementor-addons' ),
119 'type' => \Elementor\Controls_Manager::TEXT,
120 'label_block' => true,
121 'default' => 'Type your title',
122 )
123 );
124
125 $repeater->add_control(
126 'number',
127 array(
128 'label' => esc_html__( 'Number', 'wpb-elementor-addons' ),
129 'type' => \Elementor\Controls_Manager::NUMBER,
130 'label_block' => true,
131 'default' => 123456,
132 )
133 );
134
135 $this->add_control(
136 'wpb_ea_counterup_lists',
137 array(
138 'label' => esc_html__( 'CounterUp Items', 'wpb-elementor-addons' ),
139 'type' => \Elementor\Controls_Manager::REPEATER,
140 'default' => array(
141 array(
142 'number' => 6000,
143 'icon' => array(
144 'value' => 'far fa-thumbs-up',
145 'library' => 'regular',
146 ),
147 'title' => esc_html__( 'Happy Clients', 'wpb-elementor-addons' ),
148 ),
149 array(
150 'number' => 9560,
151 'icon' => array(
152 'value' => 'far fa-check-circle',
153 'library' => 'regular',
154 ),
155 'title' => esc_html__( 'Completed Projects', 'wpb-elementor-addons' ),
156 ),
157 array(
158 'number' => 165893,
159 'icon' => array(
160 'value' => 'fas fa-coffee',
161 'library' => 'solid',
162 ),
163 'title' => esc_html__( 'Cups of Coffee', 'wpb-elementor-addons' ),
164 ),
165 array(
166 'number' => 12356789,
167 'icon' => array(
168 'value' => 'fas fa-code',
169 'library' => 'solid',
170 ),
171 'title' => esc_html__( 'Lines of Code', 'wpb-elementor-addons' ),
172 ),
173 ),
174 'fields' => $repeater->get_controls(),
175 'title_field' => '{{title}}',
176 )
177 );
178
179 $this->add_control(
180 'column',
181 array(
182 'label' => esc_html__( 'Column', 'wpb-elementor-addons' ),
183 'type' => Controls_Manager::SELECT,
184 'default' => 4,
185 'options' => array(
186 6 => esc_html__( '6 Columns', 'wpb-elementor-addons' ),
187 4 => esc_html__( '4 Columns', 'wpb-elementor-addons' ),
188 3 => esc_html__( '3 Columns', 'wpb-elementor-addons' ),
189 2 => esc_html__( '2 Columns', 'wpb-elementor-addons' ),
190 1 => esc_html__( '1 Columns', 'wpb-elementor-addons' ),
191 ),
192 )
193 );
194
195 // counnterup icon align
196 $this->add_control(
197 'wpb_ea_counterup_icon_align',
198 array(
199 'label' => '<i class="fa fa-arrows"></i> ' . esc_html__( 'Icon/Image Position', 'wpb-elementor-addons' ),
200 'type' => \Elementor\Controls_Manager::CHOOSE,
201 'options' => array(
202 'left' => array(
203 'title' => esc_html__( 'Left', 'wpb-elementor-addons' ),
204 'icon' => 'fa fa-angle-left',
205 ),
206 'center' => array(
207 'title' => esc_html__( 'Top', 'wpb-elementor-addons' ),
208 'icon' => 'fa fa-angle-up',
209 ),
210 'right' => array(
211 'title' => esc_html__( 'Right', 'wpb-elementor-addons' ),
212 'icon' => 'fa fa-angle-right',
213 ),
214 ),
215 'default' => 'center',
216 )
217 );
218
219 // counnterup icon size
220 $this->add_control(
221 'icon_size',
222 array(
223 'label' => esc_html__( 'Icon Font Size', 'wpb-elementor-addons' ),
224 'type' => \Elementor\Controls_Manager::SLIDER,
225 'range' => array(
226 'px' => array(
227 'min' => 6,
228 'max' => 300,
229 ),
230 ),
231 'default' => array(
232 'size' => 30,
233 ),
234 'selectors' => array(
235 '{{WRAPPER}} .wpb-ea-counterup .wpb-ea-counterup-icon i' => 'font-size: {{SIZE}}{{UNIT}};',
236 '{{WRAPPER}} .wpb-ea-counterup .wpb-ea-counterup-icon img' => 'max-width: {{SIZE}}{{UNIT}};',
237 ),
238 )
239 );
240
241 $this->add_control(
242 'image_size',
243 array(
244 'label' => esc_html__( 'Icon Circle or Image Size', 'wpb-elementor-addons' ),
245 'type' => \Elementor\Controls_Manager::SLIDER,
246 'range' => array(
247 'px' => array(
248 'min' => 6,
249 'max' => 300,
250 ),
251 ),
252 'default' => array(
253 'size' => 70,
254 ),
255 'selectors' => array(
256 '{{WRAPPER}} .wpb-ea-counterup .wpb-ea-counterup-icon i' => 'height: {{SIZE}}{{UNIT}};',
257 '{{WRAPPER}} .wpb-ea-counterup i' => 'width: {{SIZE}}{{UNIT}};',
258 '{{WRAPPER}} .wpb-ea-counterup .wpb-ea-counterup-icon img' => 'max-width: {{SIZE}}{{UNIT}};',
259 ),
260 )
261 );
262
263 // extra CSS class
264 $this->add_control(
265 'extra_css',
266 array(
267 'label' => esc_html__( 'Extra CSS clss', 'wpb-elementor-addons' ),
268 'type' => Controls_Manager::TEXT,
269 'description' => esc_html__( 'Put your extra CSS class if you need.', 'wpb-elementor-addons' ),
270 'placeholder' => esc_html__( 'your-extra-css-class', 'wpb-elementor-addons' ),
271 )
272 );
273
274 $this->end_controls_section();
275
276 /**
277 * -------------------------------------------
278 * counterup style
279 * -------------------------------------------
280 */
281 $this->start_controls_section(
282 'wpb_ea_counterup_box_style_section',
283 array(
284 'label' => esc_html__( 'counterup Box Style', 'wpb-elementor-addons' ),
285 'tab' => Controls_Manager::TAB_STYLE,
286 )
287 );
288
289 // counterup background color
290 $this->add_control(
291 'wpb_ea_counterup_bg_color',
292 array(
293 'label' => esc_html__( 'Background Color', 'wpb-elementor-addons' ),
294 'type' => \Elementor\Controls_Manager::COLOR,
295 'selectors' => array(
296 '{{WRAPPER}} .wpb-ea-counterup' => 'background-color: {{VALUE}};',
297 ),
298 )
299 );
300
301 // counterup box padding
302 $this->add_control(
303 'wpb_ea_counterup_padding',
304 array(
305 'label' => esc_html__( 'Padding', 'wpb-elementor-addons' ),
306 'type' => \Elementor\Controls_Manager::DIMENSIONS,
307 'size_units' => array( 'px', 'em', '%' ),
308 'selectors' => array(
309 '{{WRAPPER}} .wpb-ea-counterup' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
310 ),
311 )
312 );
313
314 // counterup margin
315 $this->add_control(
316 'wpb_ea_counterup_margin',
317 array(
318 'label' => esc_html__( 'Margin', 'wpb-elementor-addons' ),
319 'type' => \Elementor\Controls_Manager::DIMENSIONS,
320 'size_units' => array( 'px', 'em', '%' ),
321 'selectors' => array(
322 '{{WRAPPER}} .wpb-ea-counterup' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
323 ),
324 )
325 );
326
327 // counterup border
328 $this->add_group_control(
329 Group_Control_Border::get_type(),
330 array(
331 'name' => 'wpb_ea_counterup_border',
332 'label' => esc_html__( 'Border Type', 'wpb-elementor-addons' ),
333 'selector' => '{{WRAPPER}} .wpb-ea-counterup',
334 )
335 );
336
337 // counterup border radius
338 $this->add_control(
339 'wpb_ea_counterup_border_radius',
340 array(
341 'label' => esc_html__( 'Border Radius', 'wpb-elementor-addons' ),
342 'type' => Controls_Manager::SLIDER,
343 'range' => array(
344 'px' => array(
345 'max' => 50,
346 ),
347 ),
348 'default' => array(
349 'unit' => 'px',
350 'size' => 5,
351 ),
352 'selectors' => array(
353 '{{WRAPPER}} .wpb-ea-counterup' => 'border-radius: {{SIZE}}px;',
354 ),
355 )
356 );
357
358 // counterup box shadow
359 $this->add_group_control(
360 Group_Control_Box_Shadow::get_type(),
361 array(
362 'name' => 'wpb_ea_counterup_box_shadow',
363 'selectors' => array(
364 '{{WRAPPER}} .wpb-ea-counterup',
365 ),
366 )
367 );
368
369 $this->end_controls_section();
370
371 /**
372 * -------------------------------------------
373 * color & typography
374 * -------------------------------------------
375 */
376 $this->start_controls_section(
377 'wpb_ea_counterup_typography_section',
378 array(
379 'label' => esc_html__( 'Content Style', 'wpb-elementor-addons' ),
380 'tab' => Controls_Manager::TAB_STYLE,
381 )
382 );
383
384 // counterup icon style
385 $this->add_control(
386 'wpb_ea_counterup_icon_style',
387 array(
388 'label' => esc_html__( 'Icon Style', 'wpb-elementor-addons' ),
389 'type' => Controls_Manager::HEADING,
390 )
391 );
392
393 // counterup icon color
394 $this->add_control(
395 'wpb_ea_counterup_icon_color',
396 array(
397 'label' => esc_html__( 'Color', 'wpb-elementor-addons' ),
398 'type' => \Elementor\Controls_Manager::COLOR,
399 'default' => '#fff',
400 'selectors' => array(
401 '{{WRAPPER}} .wpb-ea-counterup i' => 'color: {{VALUE}};',
402 ),
403 )
404 );
405
406 // counterup icon color
407 $this->add_control(
408 'wpb_ea_counterup_icon_bg_color',
409 array(
410 'label' => esc_html__( 'Background Color', 'wpb-elementor-addons' ),
411 'type' => \Elementor\Controls_Manager::COLOR,
412 'default' => $wpb_ea_primary_color,
413 'selectors' => array(
414 '{{WRAPPER}} .wpb-ea-counterup-icon i' => 'background-color: {{VALUE}};',
415 ),
416 )
417 );
418
419 // counterup number style
420 $this->add_control(
421 'wpb_ea_counterup_number_style',
422 array(
423 'label' => esc_html__( 'Number Style', 'wpb-elementor-addons' ),
424 'type' => Controls_Manager::HEADING,
425 'separator' => 'before',
426 )
427 );
428
429 // counterup number color
430 $this->add_control(
431 'wpb_ea_counterup_number_color',
432 array(
433 'type' => \Elementor\Controls_Manager::COLOR,
434 'label' => esc_html__( 'Color', 'wpb-elementor-addons' ),
435 'default' => '#333',
436 'selectors' => array(
437 '{{WRAPPER}} .wpb-ea-counterup h3.wpb-ea-counterup-number' => 'color: {{VALUE}};',
438 ),
439 )
440 );
441
442 // counterup number typography
443 $this->add_group_control(
444 \Elementor\Group_Control_Typography::get_type(),
445 array(
446 'name' => 'wpb_ea_counterup_number_typography',
447 'global' => array(
448 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
449 ),
450 'selector' => '{{WRAPPER}} .wpb-ea-counterup h3.wpb-ea-counterup-number',
451 'exclude' => array(
452 'text_transform', // font_family, font_size, font_weight, text_transform, font_style, text_decoration, line_height, letter_spacing
453 ),
454 )
455 );
456
457 // counterup number margin
458 $this->add_control(
459 'wpb_ea_counterup_number_margin',
460 array(
461 'label' => esc_html__( 'Margin', 'wpb-elementor-addons' ),
462 'type' => \Elementor\Controls_Manager::DIMENSIONS,
463 'size_units' => array( 'px', 'em', '%' ),
464 'selectors' => array(
465 '{{WRAPPER}} .wpb-ea-counterup h3.wpb-ea-counterup-number' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
466 ),
467 )
468 );
469
470 // counterup title style
471 $this->add_control(
472 'wpb_ea_counterup_title_style',
473 array(
474 'label' => esc_html__( 'Title Style', 'wpb-elementor-addons' ),
475 'type' => Controls_Manager::HEADING,
476 'separator' => 'before',
477 )
478 );
479
480 // counterup title color
481 $this->add_control(
482 'wpb_ea_counterup_title_color',
483 array(
484 'type' => \Elementor\Controls_Manager::COLOR,
485 'label' => esc_html__( 'Title color', 'wpb-elementor-addons' ),
486 'default' => '#525151',
487 'selectors' => array(
488 '{{WRAPPER}} .wpb-ea-counterup-title' => 'color: {{VALUE}};',
489 ),
490 )
491 );
492
493 // counterup title typography
494 $this->add_group_control(
495 \Elementor\Group_Control_Typography::get_type(),
496 array(
497 'name' => 'wpb_ea_counterup_title_typography',
498 'global' => array(
499 'default' => Global_Typography::TYPOGRAPHY_PRIMARY,
500 ),
501 'selector' => '{{WRAPPER}} .wpb-ea-counterup-title',
502 )
503 );
504
505 // counterup title margin
506 $this->add_control(
507 'wpb_ea_counterup_title_margin',
508 array(
509 'label' => esc_html__( 'Margin', 'wpb-elementor-addons' ),
510 'type' => \Elementor\Controls_Manager::DIMENSIONS,
511 'size_units' => array( 'px', 'em', '%' ),
512 'selectors' => array(
513 '{{WRAPPER}} .wpb-ea-counterup-title' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
514 ),
515 )
516 );
517
518 $this->end_controls_section();
519 }
520
521 protected function render() {
522 $settings = $this->get_settings_for_display();
523 $extra_css = $settings['extra_css'];
524 if ( $extra_css ) {
525 $extra_css = $extra_css . ' ';
526 }
527
528 if ( is_array( $settings['wpb_ea_counterup_lists'] ) ) :
529 $column = 12 / $settings['column'];
530 $column_class = apply_filters( 'wpb_ea_counterup_column_class', 'col-lg-' . esc_attr( $column ) . ' col-md-6' );
531
532 echo '<div class="' . esc_attr( $extra_css ) . 'wpb-ea-counterup-items ea-row">';
533 foreach ( $settings['wpb_ea_counterup_lists'] as $list ) :
534 echo '<div class="' . esc_attr( $column_class ) . '">';
535 echo '<div class="wpb-ea-counterup wpb-ea-counterup-icon-' . esc_attr( $settings['wpb_ea_counterup_icon_align'] ) . '">';
536 echo '<span class="wpb-ea-counterup-icon counterup-icon-text-' . esc_attr( $settings['wpb_ea_counterup_icon_align'] ) . '">';
537 if ( ! empty( $list['icon'] ) && ( $list['icon_type'] == 'icon' ) ) :
538 \Elementor\Icons_Manager::render_icon( $list['icon'], array( 'aria-hidden' => 'true' ) );
539 endif;
540 if ( ! empty( $list['custom'] ) && ( $list['icon_type'] == 'custom' ) ) :
541 echo wp_get_attachment_image( $list['custom']['id'], 'thumbnail' );
542 endif;
543 echo '</span>';
544 if ( ! empty( $list['number'] ) || ( $list['title'] ) ) :
545 echo '<div class="wpb-ea-counterup-content">';
546 $list['number'] ? printf( '<h3 class="wpb-ea-counterup-number">%s</h3>', esc_html( $list['number'] ) ) : '';
547 $list['title'] ? printf( '<span class="wpb-ea-counterup-title">%s</span>', esc_html( $list['title'] ) ) : '';
548 echo '</div>';
549 endif;
550 echo '</div>';
551 echo '</div>';
552 endforeach;
553 echo '</div>';
554 endif;
555 }
556 }
557