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 / includes / Admin / extension / Features_Badge_bkp.php
spider-elements / includes / Admin / extension Last commit date
Features_Badge.php 1 year ago Features_Badge_bkp.php 1 year ago Heading_Highlighted.php 1 year ago
Features_Badge_bkp.php
1928 lines
1 <?php
2 namespace SPEL\includes\Admin\extension;
3
4 use Elementor\Control_Media;
5 use Elementor\Controls_Manager;
6 use Elementor\Core\Files\CSS\Post;
7 use Elementor\Core\Kits\Documents\Tabs\Global_Colors;
8 use Elementor\Element_Base;
9 use Elementor\Group_Control_Background;
10 use Elementor\Group_Control_Border;
11 use Elementor\Group_Control_Box_Shadow;
12 use Elementor\Group_Control_Text_Shadow;
13 use Elementor\Group_Control_Typography;
14
15 if (!defined('ABSPATH')) {
16 exit; // Exit if accessed directly
17 }
18
19 /**
20 * Register Advance Features Control Tab
21 * Container & Section Features
22 */
23 class Features_Badge_BKP {
24
25 /**
26 * Class Constructor Functions.
27 */
28 public function __construct() {
29
30 // Enqueue the required JS file.
31 //add_action( 'elementor/preview/enqueue_scripts', [ $this, 'enqueue_scripts' ] );
32 //add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_styles' ] );
33
34 // Creates Premium Global Badge tab at the end of layout/content tab.
35 add_action( 'elementor/element/section/section_layout/after_section_end', [$this, 'register_controls' ], 10 );
36 add_action( 'elementor/element/column/section_advanced/after_section_end', [ $this, 'register_controls' ], 10 );
37 add_action( 'elementor/element/common/_section_style/after_section_end', [ $this, 'register_controls' ], 10 );
38
39 // Editor Hooks.
40 add_action( 'elementor/section/print_template', [ $this, 'print_template' ], 10, 2 );
41 add_action( 'elementor/column/print_template', [ $this, 'print_template' ], 10, 2 );
42 add_action( 'elementor/widget/print_template', [ $this, 'print_template' ], 10, 2 );
43
44 // Frontend Hooks.
45 add_action( 'elementor/frontend/section/before_render', [ $this, 'before_render'] );
46 add_action( 'elementor/frontend/column/before_render', [ $this, 'before_render' ] );
47 add_action( 'elementor/widget/before_render_content', [ $this, 'before_render' ], 10, 1 );
48
49 //add_action( 'elementor/frontend/before_render', [ $this, 'check_script_enqueue' ) );
50
51 add_action( 'elementor/element/container/section_layout/after_section_end', [ $this, 'register_controls' ], 10 );
52 add_action( 'elementor/container/print_template', [ $this, 'print_template' ], 10, 2 );
53 add_action( 'elementor/frontend/container/before_render', [ $this, 'before_render' ] );
54 }
55
56 /**
57 * Enqueue scripts.
58 *
59 * Registers required dependencies for the extension and enqueues them.
60 *
61 * @since 1.6.5
62 * @access public
63 */
64 public function enqueue_scripts(): void
65 {
66
67 if ( ! wp_script_is( 'lottie-js', 'enqueued' ) ) {
68 wp_enqueue_script( 'lottie-js' );
69 }
70
71 if ( ! wp_script_is( 'pa-anime', 'enqueued' ) ) {
72 wp_enqueue_script( 'pa-anime' );
73 }
74
75 if ( ! wp_script_is( 'pa-badge', 'enqueued' ) ) {
76 wp_enqueue_script( 'pa-badge' );
77 }
78 }
79
80 /**
81 * Enqueue styles.
82 *
83 * Registers required dependencies for the extension and enqueues them.
84 *
85 * @since 2.6.5
86 * @access public
87 */
88 public function enqueue_styles(): void
89 {
90
91 if ( ! wp_style_is( 'pa-global', 'enqueued' ) ) {
92 wp_enqueue_style( 'pa-global' );
93 }
94 }
95
96 /**
97 * Register Global badge controls.
98 *
99 * @param object $element for current element.
100 *@since 1.0.0
101 * @access public
102 */
103 public function register_controls( object $element ): void
104 {
105 $tab = 'common' !== $element->get_name() ? Controls_Manager::TAB_LAYOUT : Controls_Manager::TAB_CONTENT;
106
107 $element->start_controls_section(
108 'section_premium_badge',
109 [
110 'label' => __( 'Global Badge', 'premium-addons-pro' ),
111 'tab' => $tab,
112 ]
113 );
114
115 $this->add_content_controls( $element );
116
117 $element->add_control(
118 'pa_badge_heading',
119 [
120 'label' => esc_html__( 'Style & Layout', 'premium-addons-pro' ),
121 'separator' => 'before',
122 'type' => Controls_Manager::HEADING,
123 'condition' => [
124 'premium_global_badge_switcher' => 'yes',
125 ],
126 ]
127 );
128
129 $element->start_controls_tabs( 'pa_style_tabs' );
130
131 // Display section.
132 $element->start_controls_tab(
133 'pa_display_controls',
134 [
135 'label' => __( 'Layout', 'premium-addons-pro' ),
136 'condition' => [
137 'premium_global_badge_switcher' => 'yes',
138 ],
139 ]
140 );
141
142 $this->add_display_controls( $element );
143
144 $element->end_controls_tab();
145
146 // Style section.
147 $element->start_controls_tab(
148 'pa_style_controls',
149 [
150 'label' => __( 'Style', 'premium-addons-pro' ),
151 'condition' => [
152 'premium_global_badge_switcher' => 'yes',
153 ],
154 ]
155 );
156
157 $this->add_style_controls( $element );
158
159 $element->end_controls_tab();
160
161 // Icon style section.
162 $element->start_controls_tab(
163 'pa_icon_styles',
164 [
165 'label' => __( 'Icon', 'premium-addons-pro' ),
166 'condition' => [
167 'premium_global_badge_switcher' => 'yes',
168 'pa_badge_icon_enable' => 'yes',
169 ],
170 ]
171 );
172
173 $this->add_icon_style( $element );
174
175 $element->end_controls_tab();
176
177 // Svg layer style section.
178 $element->start_controls_tab(
179 'pa_svg_layer_style',
180 [
181 'label' => __( 'SVG Layer', 'premium-addons-pro' ),
182 'condition' => [
183 'premium_global_badge_switcher' => 'yes',
184 'pa_badge_svg_enabled' => 'yes',
185 'pa_badge_type' => 'custom',
186 ],
187 ]
188 );
189
190 $this->add_svg_layer_style( $element );
191
192 $element->end_controls_tab();
193
194 $element->end_controls_tabs();
195 $element->end_controls_section();
196 }
197
198 /**
199 * Add content controls.
200 *
201 * @access public
202 * @since 2.7.0
203 *
204 * @param object $element elementor element.
205 */
206 public function add_content_controls( $element ): void
207 {
208
209 $element->add_control(
210 'premium_global_badge_switcher',
211 array(
212 'label' => __( 'Enable Global Badge', 'premium-addons-pro' ),
213 'type' => Controls_Manager::SWITCHER,
214 'prefix_class' => 'premium-gbadge-',
215 'render_type' => 'template',
216 )
217 );
218
219 $element->add_control(
220 'pa_badge_notice',
221 array(
222 'type' => Controls_Manager::RAW_HTML,
223 'raw' => __( 'How to use Premium Global Badge for Elementor »', 'premium-addons-pro' ),
224 'content_classes' => 'elementor-panel-alert elementor-panel-alert-info',
225 'condition' => array(
226 'premium_global_badge_switcher' => 'yes',
227 ),
228 )
229 );
230
231 $element->add_control(
232 'pa_badge_text',
233 array(
234 'label' => __( 'Text', 'premium-addons-pro' ),
235 'type' => Controls_Manager::TEXT,
236 'default' => 'New',
237 'dynamic' => array( 'active' => true ),
238 'label_block' => true,
239 'condition' => array(
240 'premium_global_badge_switcher' => 'yes',
241 ),
242 )
243 );
244
245 $element->add_control(
246 'pa_badge_type',
247 array(
248 'label' => __( 'Style', 'premium-addons-pro' ),
249 'type' => Controls_Manager::SELECT,
250 'prefix_class' => 'premium-gbadge-',
251 'options' => array(
252 'stripe' => __( 'Stripe', 'premium-addons-pro' ),
253 'flag' => __( 'Flag', 'premium-addons-pro' ),
254 'tri' => __( 'Triangle', 'premium-addons-pro' ),
255 'circle' => __( 'Circle', 'premium-addons-pro' ),
256 'bookmark' => __( 'Bookmark', 'premium-addons-pro' ),
257 'custom' => __( 'Custom Layout', 'premium-addons-pro' ),
258 ),
259 'default' => 'stripe',
260 'condition' => array(
261 'premium_global_badge_switcher' => 'yes',
262 ),
263 )
264 );
265
266 $element->add_control(
267 'pa_badge_icon_enable',
268 array(
269 'label' => __( 'Icon', 'premium-addons-pro' ),
270 'type' => Controls_Manager::SWITCHER,
271 'render_type' => 'template',
272 'condition' => array(
273 'premium_global_badge_switcher' => 'yes',
274 ),
275 )
276 );
277
278 $element->add_control(
279 'pa_icon_type',
280 array(
281 'label' => __( 'Icon Type', 'premium-addons-pro' ),
282 'type' => Controls_Manager::SELECT,
283 'render_type' => 'template',
284 'options' => array(
285 'icon' => __( 'Icon', 'premium-addons-pro' ),
286 'image' => __( 'Image', 'premium-addons-pro' ),
287 'lottie' => __( 'Lottie', 'premium-addons-pro' ),
288 ),
289 'default' => 'icon',
290 'condition' => array(
291 'premium_global_badge_switcher' => 'yes',
292 'pa_badge_icon_enable' => 'yes',
293 ),
294 )
295 );
296
297 $element->add_control(
298 'pa_badge_icon',
299 array(
300 'label' => __( 'Choose Icon', 'premium-addons-pro' ),
301 'type' => Controls_Manager::ICONS,
302 'default' => array(
303 'value' => 'fas fa-mouse-pointer',
304 'library' => 'solid',
305 ),
306 'condition' => array(
307 'premium_global_badge_switcher' => 'yes',
308 'pa_icon_type' => 'icon',
309 'pa_badge_icon_enable' => 'yes',
310 ),
311 )
312 );
313
314 $element->add_control(
315 'pa_badge_img',
316 array(
317 'label' => __( 'Choose Image', 'premium-addons-pro' ),
318 'type' => Controls_Manager::MEDIA,
319 'condition' => array(
320 'premium_global_badge_switcher' => 'yes',
321 'pa_icon_type' => 'image',
322 'pa_badge_icon_enable' => 'yes',
323
324 ),
325 )
326 );
327
328 $element->add_control(
329 'pa_badge_lottie_url',
330 array(
331 'label' => __( 'Animation JSON URL', 'premium-addons-pro' ),
332 'type' => Controls_Manager::TEXT,
333 'description' => 'Get JSON code URL from <a href="https://lottiefiles.com/" target="_blank">here</a>',
334 'label_block' => true,
335 'condition' => array(
336 'premium_global_badge_switcher' => 'yes',
337 'pa_icon_type' => 'lottie',
338 'pa_badge_icon_enable' => 'yes',
339
340 ),
341 )
342 );
343
344 $element->add_control(
345 'pa_badge_loop',
346 array(
347 'label' => __( 'Loop', 'premium-addons-pro' ),
348 'type' => Controls_Manager::SWITCHER,
349 'return_value' => 'true',
350 'default' => 'true',
351 'condition' => array(
352 'premium_global_badge_switcher' => 'yes',
353 'pa_icon_type' => 'lottie',
354 'pa_badge_icon_enable' => 'yes',
355 ),
356 )
357 );
358
359 $element->add_control(
360 'pa_badge_reverse',
361 array(
362 'label' => __( 'Reverse', 'premium-addons-pro' ),
363 'type' => Controls_Manager::SWITCHER,
364 'return_value' => 'true',
365 'condition' => array(
366 'premium_global_badge_switcher' => 'yes',
367 'pa_icon_type' => 'lottie',
368 'pa_badge_icon_enable' => 'yes',
369 ),
370 )
371 );
372
373 $element->add_control(
374 'pa_badge_clip_enabled',
375 array(
376 'label' => __( 'Enable Clip Path', 'premium-addons-pro' ),
377 'type' => Controls_Manager::SWITCHER,
378 'render_type' => 'template',
379 'condition' => array(
380 'premium_global_badge_switcher' => 'yes',
381 'pa_badge_type' => 'custom',
382 ),
383 )
384 );
385
386 $element->add_control(
387 'pa_badge_path',
388 array(
389 'label' => __( 'Path Value', 'premium-addons-pro' ),
390 'type' => Controls_Manager::TEXTAREA,
391 'description' => 'Get Clip Path code from <a href="https://bennettfeely.com/clippy/" target="_blank">Clippy</a>.',
392 'placeholder' => __( 'Paste your Path code here. EX: polygon(50% 0%, 0% 100%, 100% 100%)', 'premium-addons-pro' ),
393 'label_block' => true,
394 'condition' => array(
395 'premium_global_badge_switcher' => 'yes',
396 'pa_badge_type' => 'custom',
397 'pa_badge_clip_enabled' => 'yes',
398 ),
399 'selectors' => array(
400 '{{WRAPPER}}.premium-gbadge-custom > .premium-global-badge-{{ID}}' => 'filter:blur(.25px); clip-path: {{VALUE}}; -webkit-clip-path: {{VALUE}}; -ms-clip-path: {{VALUE}};',
401 ),
402 )
403 );
404
405 $element->add_control(
406 'pa_badge_svg_enabled',
407 array(
408 'label' => __( 'Add SVG Layer', 'premium-addons-pro' ),
409 'type' => Controls_Manager::SWITCHER,
410 'render_type' => 'template',
411 'condition' => array(
412 'premium_global_badge_switcher' => 'yes',
413 'pa_badge_type' => 'custom',
414 ),
415 )
416 );
417
418 $element->add_control(
419 'pa_badge_svg',
420 array(
421 'label' => __( 'SVG Code', 'premium-addons-pro' ),
422 'type' => Controls_Manager::CODE,
423 'description' => 'Get Blob SVG code from <a href="https://www.blobmaker.app/" target="_blank">Blobmaker</a>, <a href="https://blobs.app/" target="_blank">Blobs</a> or <a href="https://squircley.app/" target="_blank">Squircley</a>.',
424 'label_block' => true,
425 'condition' => array(
426 'premium_global_badge_switcher' => 'yes',
427 'pa_badge_type' => 'custom',
428 'pa_badge_svg_enabled' => 'yes',
429 ),
430 )
431 );
432
433 $this->add_floating_effects_controls( $element );
434 }
435
436 /**
437 * Add display controls.
438 *
439 * @access public
440 * @since 2.7.0
441 *
442 * @param object $element elementor element.
443 */
444 public function add_display_controls( $element ) {
445
446 /** Display & Position */
447 $element->add_control(
448 'pa_badge_display',
449 array(
450 'label' => __( 'Display', 'premium-addons-pro' ),
451 'type' => Controls_Manager::CHOOSE,
452 'prefix_class' => 'premium-gbadge-',
453 'toggle' => false,
454 'options' => array(
455 'row' => array(
456 'title' => __( 'Inline', 'premium-addons-pro' ),
457 'icon' => 'eicon-ellipsis-h',
458 ),
459 'column' => array(
460 'title' => __( 'Block', 'premium-addons-pro' ),
461 'icon' => 'eicon-ellipsis-v',
462 ),
463 ),
464 'default' => 'row',
465 'condition' => array(
466 'premium_global_badge_switcher' => 'yes',
467 'pa_badge_icon_enable' => 'yes',
468 ),
469 'selectors' => array(
470 '{{WRAPPER}}.premium-gbadge-yes .premium-global-badge-{{ID}} .premium-badge-container' => 'flex-direction: {{VALUE}};',
471 ),
472 )
473 );
474
475 $element->add_control(
476 'pa_badge_hor',
477 array(
478 'label' => __( 'Horizontal Position', 'premium-addons-pro' ),
479 'type' => Controls_Manager::CHOOSE,
480 'prefix_class' => 'premium-gbadge-',
481 'toggle' => false,
482 'options' => array(
483 'left' => array(
484 'title' => __( 'Left', 'premium-addons-pro' ),
485 'icon' => 'eicon-h-align-left',
486 ),
487 'right' => array(
488 'title' => __( 'Right', 'premium-addons-pro' ),
489 'icon' => 'eicon-h-align-right',
490 ),
491 ),
492 'default' => 'right',
493 'condition' => array(
494 'premium_global_badge_switcher' => 'yes',
495 ),
496 'selectors' => array(
497 '{{WRAPPER}}:not(.premium-gbadge-flag):not(.premium-gbadge-bookmark):not(.premium-gbadge-circle):not(.premium-gbadge-custom) .premium-global-badge-{{ID}}, {{WRAPPER}}.premium-gbadge-custom > .premium-gbadge-svg-{{ID}}' => '{{VALUE}}: 0;',
498 '{{WRAPPER}}.premium-gbadge-circle .premium-global-badge-{{ID}}, {{WRAPPER}}.premium-gbadge-custom .premium-global-badge-{{ID}}' => '{{VALUE}}: 8px;',
499 '{{WRAPPER}}.premium-gbadge-bookmark .premium-global-badge-{{ID}}' => '{{VALUE}}: 20px;',
500 ),
501 )
502 );
503
504 $element->add_control(
505 'pa_badge_ver',
506 array(
507 'label' => __( 'Vertical Position', 'premium-addons-pro' ),
508 'type' => Controls_Manager::CHOOSE,
509 'toggle' => false,
510 'prefix_class' => 'premium-gbadge-',
511 'options' => array(
512 'top' => array(
513 'title' => __( 'Top', 'premium-addons-pro' ),
514 'icon' => 'eicon-v-align-top',
515 ),
516 'bottom' => array(
517 'title' => __( 'Bottom', 'premium-addons-pro' ),
518 'icon' => 'eicon-v-align-bottom',
519 ),
520 ),
521 'default' => 'top',
522 'condition' => array(
523 'premium_global_badge_switcher' => 'yes',
524 'pa_badge_type' => array( 'custom', 'circle' ),
525 ),
526 'selectors' => array(
527 '{{WRAPPER}}:not(.premium-gbadge-flag):not(.premium-gbadge-circle):not(.premium-gbadge-custom) .premium-global-badge-{{ID}}, {{WRAPPER}}.premium-gbadge-custom > .premium-gbadge-svg-{{ID}}' => '{{VALUE}}: 0;',
528 '{{WRAPPER}}.premium-gbadge-circle .premium-global-badge-{{ID}}, {{WRAPPER}}.premium-gbadge-custom .premium-global-badge-{{ID}}' => '{{VALUE}}: 8px;',
529 ),
530 )
531 );
532
533 $element->add_responsive_control(
534 'pa_badge_hor_offset',
535 array(
536 'label' => __( 'Horizontal Offset', 'premium-addons-pro' ),
537 'type' => Controls_Manager::SLIDER,
538 'size_units' => array( 'px', '%' ),
539 'range' => array(
540 'px' => array(
541 'min' => 0,
542 'max' => 200,
543 ),
544 ),
545 'condition' => array(
546 'premium_global_badge_switcher' => 'yes',
547 'pa_badge_type!' => array( 'flag', 'stripe' ),
548 ),
549 'selectors' => array(
550 '{{WRAPPER}}.premium-gbadge-flag .premium-global-badge-{{ID}}' => 'top: {{SIZE}}{{UNIT}};',
551 '{{WRAPPER}}.premium-gbadge-circle .premium-global-badge-{{ID}}' => '{{pa_badge_hor.VALUE}}: {{SIZE}}{{UNIT}};',
552 '{{WRAPPER}}.premium-gbadge-custom .premium-global-badge-{{ID}}' => '{{pa_badge_hor.VALUE}}: {{SIZE}}{{UNIT}};',
553 '{{WRAPPER}}.premium-gbadge-bookmark .premium-global-badge-{{ID}}' => '{{pa_badge_hor.VALUE}}: {{SIZE}}{{UNIT}};',
554 '{{WRAPPER}}.premium-gbadge-tri .premium-global-badge-{{ID}} .premium-badge-container' => 'left: {{SIZE}}px;',
555 ),
556 )
557 );
558
559 $element->add_responsive_control(
560 'pa_badge_ver_offset',
561 array(
562 'label' => __( 'Vertical Offset', 'premium-addons-pro' ),
563 'type' => Controls_Manager::SLIDER,
564 'size_units' => array( 'px', '%' ),
565 'range' => array(
566 'px' => array(
567 'min' => 0,
568 'max' => 200,
569 ),
570 ),
571 'condition' => array(
572 'premium_global_badge_switcher' => 'yes',
573 'pa_badge_type!' => array( 'bookmark', 'stripe' ),
574 ),
575 'selectors' => array(
576 '{{WRAPPER}}.premium-gbadge-flag .premium-global-badge-{{ID}}' => 'top: {{SIZE}}{{UNIT}};',
577 '{{WRAPPER}}.premium-gbadge-circle .premium-global-badge-{{ID}}' => '{{pa_badge_ver.VALUE}}: {{SIZE}}{{UNIT}};',
578 '{{WRAPPER}}.premium-gbadge-custom .premium-global-badge-{{ID}}' => '{{pa_badge_ver.VALUE}}: {{SIZE}}{{UNIT}};',
579 '{{WRAPPER}}.premium-gbadge-tri.premium-gbadge-left .premium-global-badge-{{ID}} .premium-badge-container' => 'bottom: {{SIZE}}px;',
580 '{{WRAPPER}}.premium-gbadge-tri.premium-gbadge-right .premium-global-badge-{{ID}} .premium-badge-container' => 'top: {{SIZE}}px;',
581 ),
582 )
583 );
584
585 $indent_class = is_rtl() ? '.premium-badge-text' : '.premium-badge-icon';
586
587 $element->add_responsive_control(
588 'pa_badge_spacing',
589 array(
590 'label' => __( 'Spacing', 'premium-addons-pro' ),
591 'type' => Controls_Manager::SLIDER,
592 'size_units' => array( 'px', 'em' ),
593 'range' => array(
594 'px' => array(
595 'min' => 0,
596 'max' => 100,
597 ),
598 ),
599 'condition' => array(
600 'premium_global_badge_switcher' => 'yes',
601 'pa_badge_icon_enable' => 'yes',
602 ),
603 'selectors' => array(
604 '{{WRAPPER}}.premium-gbadge-row .premium-global-badge-{{ID}} ' . $indent_class => 'text-indent: {{SIZE}}{{UNIT}};',
605 '{{WRAPPER}}.premium-gbadge-column .premium-global-badge-{{ID}} .premium-badge-icon' => 'margin-bottom: {{SIZE}}{{UNIT}};',
606 ),
607 )
608 );
609
610 $element->add_responsive_control(
611 'pa_badge_rotate',
612 array(
613 'label' => __( 'Rotate (Degrees)', 'premium-addons-pro' ),
614 'type' => Controls_Manager::SLIDER,
615 'size_units' => array( 'deg' ),
616 'default' => array(
617 'unit' => 'deg',
618 'size' => 0,
619 ),
620 'range' => array(
621 'deg' => array(
622 'min' => -180,
623 'max' => 180,
624 ),
625 ),
626 'selectors' => array(
627 '{{WRAPPER}} .premium-global-badge-{{ID}}' => 'transform: rotate({{SIZE}}deg)',
628 ),
629 'condition' => array(
630 'premium_global_badge_switcher' => 'yes',
631 'pa_badge_type' => 'custom',
632 'pa_badge_ftranslate!' => 'yes',
633 'pa_badge_frotate!' => 'yes',
634 ),
635 )
636 );
637 }
638
639 /**
640 * Add style controls.
641 *
642 * @access public
643 * @since 2.7.0
644 *
645 * @param object $element elementor element.
646 */
647 public function add_style_controls( $element ) {
648
649 /** Style */
650 $element->add_responsive_control(
651 'pa_badge_size',
652 array(
653 'label' => __( 'Size', 'premium-addons-pro' ),
654 'type' => Controls_Manager::SLIDER,
655 'size_units' => array( 'px', 'em' ),
656 'range' => array(
657 'px' => array(
658 'min' => 0,
659 'max' => 200,
660 ),
661 ),
662 'condition' => array(
663 'premium_global_badge_switcher' => 'yes',
664 'pa_badge_type!' => array( 'bookmark', 'stripe', 'flag', 'circle' ),
665 ),
666 'selectors' => array(
667 '{{WRAPPER}}.premium-gbadge-tri.premium-gbadge-left > .premium-global-badge-{{ID}}' => 'border-top-width: {{SIZE}}{{UNIT}}; border-bottom-width: {{SIZE}}{{UNIT}}; border-right-width: {{SIZE}}{{UNIT}};',
668 '{{WRAPPER}}.premium-gbadge-tri.premium-gbadge-right > .premium-global-badge-{{ID}}' => 'border-left-width: {{SIZE}}{{UNIT}}; border-bottom-width: {{SIZE}}{{UNIT}}; border-right-width: {{SIZE}}{{UNIT}};',
669 '{{WRAPPER}}.premium-gbadge-custom > .premium-global-badge-{{ID}}' => 'width: {{SIZE}}{{UNIT}}; height: {{SIZE}}{{UNIT}};',
670 ),
671 )
672 );
673
674 $element->add_responsive_control(
675 'pa_badge_margin',
676 array(
677 'label' => __( 'Text Margin', 'premium-addons-pro' ),
678 'type' => Controls_Manager::DIMENSIONS,
679 'size_units' => array( 'px', 'em', '%' ),
680 'condition' => array(
681 'premium_global_badge_switcher' => 'yes',
682 'pa_badge_type' => 'custom',
683 ),
684 'selectors' => array(
685 '{{WRAPPER}}.premium-gbadge-custom > .premium-global-badge-{{ID}} .premium-badge-container' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
686 ),
687 )
688 );
689
690 $element->add_control(
691 'pa_badge_color',
692 array(
693 'label' => __( 'Color', 'premium-addons-pro' ),
694 'type' => Controls_Manager::COLOR,
695 'global' => array(
696 'default' => Global_Colors::COLOR_SECONDARY,
697 ),
698 'condition' => array(
699 'premium_global_badge_switcher' => 'yes',
700 ),
701 'selectors' => array(
702 '{{WRAPPER}} .premium-global-badge-{{ID}} .premium-badge-text' => 'color: {{VALUE}};',
703 ),
704 )
705 );
706
707 $element->add_group_control(
708 Group_Control_Background::get_type(),
709 array(
710 'name' => 'pa_badge_bg',
711 'types' => array( 'classic', 'gradient' ),
712 'fields_options' => array(
713 'background' => array(
714 'default' => 'classic',
715 ),
716 'color' => array(
717 'global' => array(
718 'default' => Global_Colors::COLOR_PRIMARY,
719 ),
720 ),
721 ),
722 'condition' => array(
723 'premium_global_badge_switcher' => 'yes',
724 'pa_badge_type!' => array( 'bookmark', 'tri', 'flag' ),
725 ),
726 'selector' => '{{WRAPPER}} .premium-global-badge-{{ID}} .premium-badge-container',
727 )
728 );
729
730 $element->add_control(
731 'pa_badge_bgcolor',
732 array(
733 'label' => __( 'Background Color', 'premium-addons-pro' ),
734 'type' => Controls_Manager::COLOR,
735 'default' => '#6EC1E4',
736 'condition' => array(
737 'premium_global_badge_switcher' => 'yes',
738 'pa_badge_type' => array( 'bookmark', 'tri', 'flag' ),
739 ),
740 'selectors' => array(
741 '{{WRAPPER}}.premium-gbadge-flag .premium-global-badge-{{ID}} .premium-badge-container, {{WRAPPER}}.premium-gbadge-bookmark .premium-global-badge-{{ID}}' => 'background-color: {{VALUE}};',
742 '{{WRAPPER}}.premium-gbadge-tri.premium-gbadge-left .premium-global-badge-{{ID}}' => 'border-top-color:{{VALUE}};',
743 '{{WRAPPER}}.premium-gbadge-flag.premium-gbadge-right .premium-global-badge-{{ID}}:after' => 'border-left-color: {{VALUE}};',
744 '{{WRAPPER}}.premium-gbadge-flag.premium-gbadge-left .premium-global-badge-{{ID}}:after, {{WRAPPER}}.premium-gbadge-tri.premium-gbadge-right .premium-global-badge-{{ID}}' => 'border-right-color:{{VALUE}};',
745 '{{WRAPPER}}.premium-gbadge-bookmark > .premium-global-badge-{{ID}}:after' => 'border-right-color:{{VALUE}}; border-left-color:{{VALUE}};',
746 ),
747 )
748 );
749
750 $element->add_group_control(
751 Group_Control_Text_Shadow::get_type(),
752 array(
753 'name' => 'pa_badge_text_shadow',
754 'condition' => array(
755 'premium_global_badge_switcher' => 'yes',
756 ),
757 'selector' => '{{WRAPPER}} .premium-global-badge-{{ID}}',
758 )
759 );
760
761 $element->add_group_control(
762 Group_Control_Box_Shadow::get_type(),
763 array(
764 'name' => 'pa_badge_shadow',
765 'condition' => array(
766 'premium_global_badge_switcher' => 'yes',
767 'pa_badge_type!' => 'tri',
768 ),
769 'selector' => '{{WRAPPER}}:not(.premium-gbadge-bookmark) .premium-global-badge-{{ID}} .premium-badge-container, {{WRAPPER}}.premium-gbadge-bookmark .premium-global-badge-{{ID}}',
770 )
771 );
772
773 $element->add_group_control(
774 Group_Control_Typography::get_type(),
775 array(
776 'name' => 'pa_badge_typo',
777 'condition' => array(
778 'premium_global_badge_switcher' => 'yes',
779 'pa_badge_type!' => 'bookmark',
780 ),
781 'selector' => '{{WRAPPER}}:not(.premium-gbadge-stripe) .premium-global-badge-{{ID}},
782 {{WRAPPER}}.premium-gbadge-stripe > .premium-global-badge-{{ID}} .premium-badge-container,
783 {{WRAPPER}}.premium-gbadge-custom > .premium-global-badge-{{ID}} .premium-badge-container ',
784 )
785 );
786
787 $element->add_group_control(
788 Group_Control_Typography::get_type(),
789 array(
790 'name' => 'pa_bookmark_typo',
791 'condition' => array(
792 'premium_global_badge_switcher' => 'yes',
793 'pa_badge_type' => 'bookmark',
794 ),
795 'fields_options' => array(
796 'font_size' => array(
797 'selectors' => array(
798 '{{WRAPPER}}.premium-gbadge-bookmark > .premium-global-badge-{{ID}}' => 'width: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
799 '{{WRAPPER}}.premium-gbadge-bookmark > .premium-global-badge-{{ID}} .premium-badge-text' => 'font-size: {{SIZE}}{{UNIT}}; line-height: {{SIZE}}{{UNIT}};',
800 '{{WRAPPER}}.premium-gbadge-bookmark > .premium-global-badge-{{ID}}:after' => 'border-left-width: calc( {{SIZE}}{{UNIT}} / 2); border-right-width: calc( {{SIZE}}{{UNIT}} / 2);',
801 ),
802 ),
803 'line_height' => array(
804 'default' => array(
805 'size' => '32',
806 'unit' => 'px',
807 ),
808 'selectors' => array(
809 '{{WRAPPER}}.premium-gbadge-bookmark > .premium-global-badge-{{ID}}' => 'width: {{SIZE}}{{UNIT}};',
810 '{{WRAPPER}}.premium-gbadge-bookmark > .premium-global-badge-{{ID}}:after' => 'border-left-width: calc( {{SIZE}}{{UNIT}} / 2); border-right-width: calc( {{SIZE}}{{UNIT}} / 2);',
811 ),
812 ),
813 ),
814 'selector' => '{{WRAPPER}}.premium-gbadge-bookmark > .premium-global-badge-{{ID}}',
815 )
816 );
817
818 $element->add_control(
819 'bookmark_notice',
820 array(
821 'type' => Controls_Manager::RAW_HTML,
822 'raw' => __( 'Use <b>Line Height</b> to control the bookmark size.', 'premium-addons-pro' ),
823 'content_classes' => 'papro-upgrade-notice',
824 'condition' => array(
825 'premium_global_badge_switcher' => 'yes',
826 'pa_badge_type' => 'bookmark',
827 ),
828 )
829 );
830
831 $element->add_group_control(
832 Group_Control_Border::get_type(),
833 array(
834 'name' => 'pa_badge_border',
835 'selector' => '{{WRAPPER}} .premium-global-badge-{{ID}} .premium-badge-container',
836 'condition' => array(
837 'premium_global_badge_switcher' => 'yes',
838 'pa_badge_type!' => array( 'bookmark', 'tri', 'stripe', 'flag' ),
839 'pa_badge_clip_enabled!' => 'yes',
840 ),
841 )
842 );
843
844 $element->add_control(
845 'pa_badge_border_rad',
846 array(
847 'label' => __( 'Border Radius', 'premium-addons-pro' ),
848 'type' => Controls_Manager::SLIDER,
849 'size_units' => array( 'px', '%', 'em' ),
850 'condition' => array(
851 'premium_global_badge_switcher' => 'yes',
852 'pa_badge_adv_radius!' => 'yes',
853 'pa_badge_clip_enabled!' => 'yes',
854 'pa_badge_type!' => array( 'bookmark', 'tri', 'stripe' ),
855 ),
856 'selectors' => array(
857 '{{WRAPPER}}:not(.premium-gbadge-flag) .premium-global-badge-{{ID}} .premium-badge-container' => 'border-radius: {{SIZE}}{{UNIT}};',
858 '{{WRAPPER}}.premium-gbadge-flag.premium-gbadge-left .premium-global-badge-{{ID}} .premium-badge-container' => 'border-radius: {{SIZE}}{{UNIT}} {{SIZE}}{{UNIT}} {{SIZE}}{{UNIT}} 0;',
859 '{{WRAPPER}}.premium-gbadge-flag.premium-gbadge-right .premium-global-badge-{{ID}} .premium-badge-container' => 'border-radius: {{SIZE}}{{UNIT}} {{SIZE}}{{UNIT}} 0 {{SIZE}}{{UNIT}} ;',
860 ),
861 )
862 );
863
864 $element->add_control(
865 'pa_badge_adv_radius',
866 array(
867 'label' => __( 'Advanced Border Radius', 'premium-addons-pro' ),
868 'type' => Controls_Manager::SWITCHER,
869 'description' => __( 'Apply custom radius values. Get the radius value from ', 'premium-addons-pro' ) . '<a href="https://9elements.github.io/fancy-border-radius/" target="_blank">here</a>',
870 'condition' => array(
871 'premium_global_badge_switcher' => 'yes',
872 'pa_badge_clip_enabled!' => 'yes',
873 'pa_badge_type!' => array( 'bookmark', 'tri', 'stripe', 'flag' ),
874 ),
875 )
876 );
877
878 $element->add_control(
879 'pa_badge_adv_radius_val',
880 array(
881 'label' => __( 'Border Radius', 'premium-addons-pro' ),
882 'type' => Controls_Manager::TEXT,
883 'selectors' => array(
884 '{{WRAPPER}} .premium-global-badge-{{ID}} .premium-badge-container' => 'border-radius: {{VALUE}};',
885 ),
886 'condition' => array(
887 'pa_badge_adv_radius' => 'yes',
888 'pa_badge_clip_enabled!' => 'yes',
889 'pa_badge_type!' => array( 'bookmark', 'tri', 'stripe', 'flag' ),
890 ),
891 )
892 );
893
894 $element->add_control(
895 'pa_badge_zindex',
896 array(
897 'label' => __( 'Z-Index', 'premium-addons-pro' ),
898 'type' => Controls_Manager::NUMBER,
899 'step' => 1,
900 'description' => __( 'Default is 5', 'premium-addons-pro' ),
901 'selectors' => array(
902 '{{WRAPPER}} .premium-global-badge-{{ID}}' => 'z-index: {{VALUE}}',
903 ),
904 'condition' => array(
905 'premium_global_badge_switcher' => 'yes',
906 ),
907 )
908 );
909
910 $element->add_responsive_control(
911 'pa_badge_padding',
912 array(
913 'label' => __( 'Padding', 'premium-addons-pro' ),
914 'type' => Controls_Manager::DIMENSIONS,
915 'size_units' => array( 'px', 'em' ),
916 'condition' => array(
917 'premium_global_badge_switcher' => 'yes',
918 'pa_badge_type!' => array( 'bookmark', 'tri' ),
919 ),
920 'selectors' => array(
921 '{{WRAPPER}} .premium-global-badge-{{ID}} .premium-badge-container' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
922 ),
923 )
924 );
925
926 $element->add_responsive_control(
927 'pa_badge_padding_bookmark',
928 array(
929 'label' => __( 'Padding', 'premium-addons-pro' ),
930 'type' => Controls_Manager::DIMENSIONS,
931 'allowed_dimensions' => 'vertical',
932 'size_units' => array( 'px', 'em' ),
933 'condition' => array(
934 'premium_global_badge_switcher' => 'yes',
935 'pa_badge_type' => 'bookmark',
936 ),
937 'selectors' => array(
938 '{{WRAPPER}}.premium-gbadge-bookmark .premium-global-badge-{{ID}}' => 'padding: {{TOP}}{{UNIT}} 0 {{BOTTOM}}{{UNIT}} 0;',
939 ),
940 )
941 );
942 }
943
944 /**
945 * Add icon style controls.
946 *
947 * @access public
948 * @since 2.7.0
949 *
950 * @param object $element elementor element.
951 */
952 public function add_icon_style( $element ) {
953
954 $element->add_control(
955 'pa_badge_icon_color',
956 array(
957 'label' => __( 'Icon Color', 'premium-addons-pro' ),
958 'type' => Controls_Manager::COLOR,
959 'global' => array(
960 'default' => Global_Colors::COLOR_SECONDARY,
961 ),
962 'condition' => array(
963 'premium_global_badge_switcher' => 'yes',
964 'pa_badge_icon_enable' => 'yes',
965 'pa_icon_type' => 'icon',
966 ),
967 'selectors' => array(
968 '{{WRAPPER}} .premium-global-badge-{{ID}} .premium-badge-icon' => 'color: {{VALUE}}; fill: {{VALUE}};',
969 ),
970 )
971 );
972
973 $element->add_responsive_control(
974 'pa_badge_icon_size',
975 array(
976 'label' => __( 'Icon Size', 'premium-addons-pro' ),
977 'type' => Controls_Manager::SLIDER,
978 'size_units' => array( 'px', 'em' ),
979 'range' => array(
980 'px' => array(
981 'min' => 0,
982 'max' => 500,
983 ),
984 ),
985 'condition' => array(
986 'premium_global_badge_switcher' => 'yes',
987 'pa_badge_icon_enable' => 'yes',
988 ),
989 'selectors' => array(
990 '{{WRAPPER}}:not(.premium-gbadge-bookmark) > .premium-global-badge-{{ID}} .premium-badge-icon' => 'font-size: {{SIZE}}{{UNIT}}; line-height:{{SIZE}}{{UNIT}}',
991 '{{WRAPPER}}.premium-gbadge-bookmark > .premium-global-badge-{{ID}} .premium-badge-icon' => 'font-size: {{SIZE}}{{UNIT}};',
992 '{{WRAPPER}} > .premium-global-badge-{{ID}} .premium-badge-icon, {{WRAPPER}} > .premium-global-badge-{{ID}} .premium-lottie-animation, {{WRAPPER}}:not(.premium-gbadge-bookmark) > .premium-global-badge-{{ID}} .premium-badge-img ' => 'width:{{SIZE}}{{UNIT}}; height:{{SIZE}}{{UNIT}};',
993 ),
994 )
995 );
996
997 $element->add_control(
998 'pa_badge_icon_rad',
999 array(
1000 'label' => __( 'Border Radius', 'premium-addons-pro' ),
1001 'type' => Controls_Manager::SLIDER,
1002 'size_units' => array( 'px', '%', 'em' ),
1003 'condition' => array(
1004 'premium_global_badge_switcher' => 'yes',
1005 'pa_badge_icon_enable' => 'yes',
1006 'pa_icon_type!' => 'icon',
1007 ),
1008 'selectors' => array(
1009 '{{WRAPPER}} .premium-global-badge-{{ID}} .premium-badge-img, {{WRAPPER}} .premium-global-badge-{{ID}} .premium-lottie-animation svg' => 'border-radius: {{SIZE}}{{UNIT}};',
1010 ),
1011 )
1012 );
1013 }
1014
1015 /**
1016 * Add svg layer style controls.
1017 *
1018 * @access public
1019 * @since 2.7.0
1020 *
1021 * @param object $element elementor element.
1022 */
1023 public function add_svg_layer_style( $element ) {
1024 $element->add_responsive_control(
1025 'pa_badge_svg_size',
1026 array(
1027 'label' => __( 'Layer Size', 'premium-addons-pro' ),
1028 'type' => Controls_Manager::SLIDER,
1029 'size_units' => array( 'px', 'em' ),
1030 'range' => array(
1031 'px' => array(
1032 'min' => 0,
1033 'max' => 500,
1034 ),
1035 ),
1036 'condition' => array(
1037 'premium_global_badge_switcher' => 'yes',
1038 'pa_badge_svg_enabled' => 'yes',
1039 'pa_badge_type' => 'custom',
1040 ),
1041 'selectors' => array(
1042 '{{WRAPPER}}.premium-gbadge-custom > .premium-gbadge-svg-{{ID}}' => 'width:{{SIZE}}{{UNIT}}; height:{{SIZE}}{{UNIT}};',
1043 ),
1044 )
1045 );
1046
1047 $element->add_responsive_control(
1048 'pa_badge_svg_hor',
1049 array(
1050 'label' => __( 'SVG Horizontal Offset', 'premium-addons-pro' ),
1051 'type' => Controls_Manager::SLIDER,
1052 'size_units' => array( 'px', '%', 'em' ),
1053 'range' => array(
1054 'px' => array(
1055 'min' => -200,
1056 'max' => 200,
1057 ),
1058 ),
1059 'condition' => array(
1060 'premium_global_badge_switcher' => 'yes',
1061 'pa_badge_svg_enabled' => 'yes',
1062 'pa_badge_type' => 'custom',
1063 ),
1064 'selectors' => array(
1065 '{{WRAPPER}}.premium-gbadge-custom > .premium-gbadge-svg-{{ID}}' => '{{pa_badge_hor.VALUE}}: {{SIZE}}{{UNIT}};',
1066 ),
1067 )
1068 );
1069
1070 $element->add_responsive_control(
1071 'pa_badge_svg_ver',
1072 array(
1073 'label' => __( 'SVG Vertical Offset', 'premium-addons-pro' ),
1074 'type' => Controls_Manager::SLIDER,
1075 'size_units' => array( 'px', '%', 'em' ),
1076 'range' => array(
1077 'px' => array(
1078 'min' => -200,
1079 'max' => 200,
1080 ),
1081 ),
1082 'condition' => array(
1083 'premium_global_badge_switcher' => 'yes',
1084 'pa_badge_svg_enabled' => 'yes',
1085 'pa_badge_type' => 'custom',
1086 ),
1087 'selectors' => array(
1088 '{{WRAPPER}}.premium-gbadge-custom > .premium-gbadge-svg-{{ID}}' => '{{pa_badge_ver.VALUE}}: {{SIZE}}{{UNIT}};',
1089 ),
1090 )
1091 );
1092
1093 $element->add_control(
1094 'pa_badge_svg_zindex',
1095 array(
1096 'label' => __( 'Z-Index', 'premium-addons-pro' ),
1097 'type' => Controls_Manager::NUMBER,
1098 'step' => 1,
1099 'description' => __( 'Default is 2', 'premium-addons-pro' ),
1100 'selectors' => array(
1101 '{{WRAPPER}}.premium-gbadge-custom > .premium-gbadge-svg-{{ID}}' => 'z-index: {{VALUE}}',
1102 ),
1103 'condition' => array(
1104 'premium_global_badge_switcher' => 'yes',
1105 'pa_badge_svg_enabled' => 'yes',
1106 'pa_badge_type' => 'custom',
1107 ),
1108 )
1109 );
1110 }
1111
1112 /**
1113 * Add floating effects controls.
1114 *
1115 * @access public
1116 * @since 2.7.0
1117 *
1118 * @param object $element elementor element.
1119 */
1120 public function add_floating_effects_controls( $element ) {
1121
1122 $element->add_control(
1123 'pa_badge_effects',
1124 array(
1125 'label' => __( 'Floating Effects', 'premium-addons-pro' ),
1126 'type' => Controls_Manager::SWITCHER,
1127 'condition' => array(
1128 'premium_global_badge_switcher' => 'yes',
1129 ),
1130 )
1131 );
1132
1133 $float_conditions = array(
1134 'pa_badge_effects' => 'yes',
1135 'premium_global_badge_switcher' => 'yes',
1136 );
1137
1138 $element->add_control(
1139 'pa_badge_ftranslate',
1140 array(
1141 'label' => __( 'Translate', 'premium-addons-pro' ),
1142 'type' => Controls_Manager::SWITCHER,
1143 'condition' => array_merge(
1144 $float_conditions,
1145 array(
1146 'pa_badge_type!' => 'stripe',
1147 )
1148 ),
1149 )
1150 );
1151
1152 $element->add_control(
1153 'pa_badge_ftranslatex',
1154 array(
1155 'label' => __( 'Translate X', 'premium-addons-pro' ),
1156 'type' => Controls_Manager::SLIDER,
1157 'default' => array(
1158 'sizes' => array(
1159 'start' => -5,
1160 'end' => 5,
1161 ),
1162 'unit' => 'px',
1163 ),
1164 'range' => array(
1165 'px' => array(
1166 'min' => -100,
1167 'max' => 100,
1168 ),
1169 ),
1170 'labels' => array(
1171 __( 'From', 'premium-addons-pro' ),
1172 __( 'To', 'premium-addons-pro' ),
1173 ),
1174 'scales' => 1,
1175 'handles' => 'range',
1176 'condition' => array_merge(
1177 $float_conditions,
1178 array(
1179 'pa_badge_ftranslate' => 'yes',
1180 'pa_badge_type!' => 'stripe',
1181 )
1182 ),
1183 )
1184 );
1185
1186 $element->add_control(
1187 'pa_badge_ftranslatey',
1188 array(
1189 'label' => __( 'Translate Y', 'premium-addons-pro' ),
1190 'type' => Controls_Manager::SLIDER,
1191 'default' => array(
1192 'sizes' => array(
1193 'start' => -5,
1194 'end' => 5,
1195 ),
1196 'unit' => 'px',
1197 ),
1198 'range' => array(
1199 'px' => array(
1200 'min' => -100,
1201 'max' => 100,
1202 ),
1203 ),
1204 'labels' => array(
1205 __( 'From', 'premium-addons-pro' ),
1206 __( 'To', 'premium-addons-pro' ),
1207 ),
1208 'scales' => 1,
1209 'handles' => 'range',
1210 'condition' => array_merge(
1211 $float_conditions,
1212 array(
1213 'pa_badge_ftranslate' => 'yes',
1214 'pa_badge_type!' => 'stripe',
1215 )
1216 ),
1217 )
1218 );
1219
1220 $element->add_control(
1221 'pa_badge_ftranslate_speed',
1222 array(
1223 'label' => __( 'Speed', 'premium-addons-pro' ),
1224 'type' => Controls_Manager::SLIDER,
1225 'range' => array(
1226 'px' => array(
1227 'min' => 0,
1228 'max' => 10,
1229 'step' => 0.1,
1230 ),
1231 ),
1232 'default' => array(
1233 'size' => 1,
1234 ),
1235 'condition' => array_merge(
1236 $float_conditions,
1237 array(
1238 'pa_badge_ftranslate' => 'yes',
1239 'pa_badge_type!' => 'stripe',
1240 )
1241 ),
1242 )
1243 );
1244
1245 $element->add_control(
1246 'pa_badge_frotate',
1247 array(
1248 'label' => __( 'Rotate', 'premium-addons-pro' ),
1249 'type' => Controls_Manager::SWITCHER,
1250 'condition' => array_merge(
1251 $float_conditions,
1252 array(
1253 'pa_badge_type!' => 'stripe',
1254 )
1255 ),
1256 )
1257 );
1258
1259 $element->add_control(
1260 'pa_badge_frotatex',
1261 array(
1262 'label' => __( 'Rotate X', 'premium-addons-pro' ),
1263 'type' => Controls_Manager::SLIDER,
1264 'default' => array(
1265 'sizes' => array(
1266 'start' => 0,
1267 'end' => 45,
1268 ),
1269 'unit' => 'deg',
1270 ),
1271 'range' => array(
1272 'deg' => array(
1273 'min' => -180,
1274 'max' => 180,
1275 ),
1276 ),
1277 'labels' => array(
1278 __( 'From', 'premium-addons-pro' ),
1279 __( 'To', 'premium-addons-pro' ),
1280 ),
1281 'scales' => 1,
1282 'handles' => 'range',
1283 'condition' => array_merge(
1284 $float_conditions,
1285 array(
1286 'pa_badge_frotate' => 'yes',
1287 'pa_badge_type!' => 'stripe',
1288 )
1289 ),
1290 )
1291 );
1292
1293 $element->add_control(
1294 'pa_badge_frotatey',
1295 array(
1296 'label' => __( 'Rotate Y', 'premium-addons-pro' ),
1297 'type' => Controls_Manager::SLIDER,
1298 'default' => array(
1299 'sizes' => array(
1300 'start' => 0,
1301 'end' => 45,
1302 ),
1303 'unit' => 'deg',
1304 ),
1305 'range' => array(
1306 'deg' => array(
1307 'min' => -180,
1308 'max' => 180,
1309 ),
1310 ),
1311 'labels' => array(
1312 __( 'From', 'premium-addons-pro' ),
1313 __( 'To', 'premium-addons-pro' ),
1314 ),
1315 'scales' => 1,
1316 'handles' => 'range',
1317 'condition' => array_merge(
1318 $float_conditions,
1319 array(
1320 'pa_badge_frotate' => 'yes',
1321 'pa_badge_type!' => 'stripe',
1322 )
1323 ),
1324 )
1325 );
1326
1327 $element->add_control(
1328 'pa_badge_frotatez',
1329 array(
1330 'label' => __( 'Rotate Z', 'premium-addons-pro' ),
1331 'type' => Controls_Manager::SLIDER,
1332 'default' => array(
1333 'sizes' => array(
1334 'start' => 0,
1335 'end' => 45,
1336 ),
1337 'unit' => 'deg',
1338 ),
1339 'range' => array(
1340 'deg' => array(
1341 'min' => -180,
1342 'max' => 180,
1343 ),
1344 ),
1345 'labels' => array(
1346 __( 'From', 'premium-addons-pro' ),
1347 __( 'To', 'premium-addons-pro' ),
1348 ),
1349 'scales' => 1,
1350 'handles' => 'range',
1351 'condition' => array_merge(
1352 $float_conditions,
1353 array(
1354 'pa_badge_frotate' => 'yes',
1355 'pa_badge_type!' => 'stripe',
1356 )
1357 ),
1358 )
1359 );
1360
1361 $element->add_control(
1362 'pa_badge_frotate_speed',
1363 array(
1364 'label' => __( 'Speed', 'premium-addons-pro' ),
1365 'type' => Controls_Manager::SLIDER,
1366 'range' => array(
1367 'px' => array(
1368 'min' => 0,
1369 'max' => 10,
1370 'step' => 0.1,
1371 ),
1372 ),
1373 'default' => array(
1374 'size' => 1,
1375 ),
1376 'condition' => array_merge(
1377 $float_conditions,
1378 array(
1379 'pa_badge_frotate' => 'yes',
1380 'pa_badge_type!' => 'stripe',
1381 )
1382 ),
1383 )
1384 );
1385
1386 $element->add_control(
1387 'pa_badge_fopacity',
1388 array(
1389 'label' => __( 'Opacity', 'premium-addons-pro' ),
1390 'type' => Controls_Manager::SWITCHER,
1391 'condition' => $float_conditions,
1392 )
1393 );
1394
1395 $element->add_control(
1396 'pa_badge_fopacity_value',
1397 array(
1398 'label' => __( 'Value', 'premium-addons-pro' ),
1399 'type' => Controls_Manager::SLIDER,
1400 'default' => array(
1401 'sizes' => array(
1402 'start' => 0,
1403 'end' => 50,
1404 ),
1405 'unit' => '%',
1406 ),
1407 'labels' => array(
1408 __( 'From', 'premium-addons-pro' ),
1409 __( 'To', 'premium-addons-pro' ),
1410 ),
1411 'scales' => 1,
1412 'handles' => 'range',
1413 'condition' => array_merge(
1414 $float_conditions,
1415 array(
1416 'pa_badge_fopacity' => 'yes',
1417 )
1418 ),
1419 )
1420 );
1421
1422 $element->add_control(
1423 'pa_badge_fopacity_speed',
1424 array(
1425 'label' => __( 'Speed', 'premium-addons-pro' ),
1426 'type' => Controls_Manager::SLIDER,
1427 'range' => array(
1428 'px' => array(
1429 'min' => 0,
1430 'max' => 10,
1431 'step' => 0.1,
1432 ),
1433 ),
1434 'default' => array(
1435 'size' => 1,
1436 ),
1437 'condition' => array_merge(
1438 $float_conditions,
1439 array(
1440 'pa_badge_fopacity' => 'yes',
1441 )
1442 ),
1443 )
1444 );
1445
1446 $element->add_control(
1447 'pa_badge_fblur',
1448 array(
1449 'label' => __( 'Blur', 'premium-addons-pro' ),
1450 'type' => Controls_Manager::SWITCHER,
1451 'condition' => $float_conditions,
1452 )
1453 );
1454
1455 $element->add_control(
1456 'pa_badge_fblur_value',
1457 array(
1458 'label' => __( 'Value', 'premium-addons-pro' ),
1459 'type' => Controls_Manager::SLIDER,
1460 'default' => array(
1461 'sizes' => array(
1462 'start' => 0,
1463 'end' => 1,
1464 ),
1465 'unit' => 'px',
1466 ),
1467 'range' => array(
1468 'px' => array(
1469 'min' => 0,
1470 'max' => 3,
1471 'step' => 0.1,
1472 ),
1473 ),
1474 'labels' => array(
1475 __( 'From', 'premium-addons-pro' ),
1476 __( 'To', 'premium-addons-pro' ),
1477 ),
1478 'scales' => 1,
1479 'handles' => 'range',
1480 'condition' => array_merge(
1481 $float_conditions,
1482 array(
1483 'pa_badge_fblur' => 'yes',
1484 )
1485 ),
1486 )
1487 );
1488
1489 $element->add_control(
1490 'pa_badge_fblur_speed',
1491 array(
1492 'label' => __( 'Speed', 'premium-addons-pro' ),
1493 'type' => Controls_Manager::SLIDER,
1494 'range' => array(
1495 'px' => array(
1496 'min' => 0,
1497 'max' => 10,
1498 'step' => 0.1,
1499 ),
1500 ),
1501 'default' => array(
1502 'size' => 1,
1503 ),
1504 'condition' => array_merge(
1505 $float_conditions,
1506 array(
1507 'pa_badge_fblur' => 'yes',
1508 )
1509 ),
1510 )
1511 );
1512
1513 $element->add_control(
1514 'pa_badge_fgrayscale',
1515 array(
1516 'label' => __( 'Grayscale', 'premium-addons-pro' ),
1517 'type' => Controls_Manager::SWITCHER,
1518 'condition' => $float_conditions,
1519 )
1520 );
1521
1522 $element->add_control(
1523 'pa_badge_fgscale_value',
1524 array(
1525 'label' => __( 'Value', 'premium-addons-pro' ),
1526 'type' => Controls_Manager::SLIDER,
1527 'default' => array(
1528 'sizes' => array(
1529 'start' => 0,
1530 'end' => 50,
1531 ),
1532 'unit' => '%',
1533 ),
1534 'labels' => array(
1535 __( 'From', 'premium-addons-pro' ),
1536 __( 'To', 'premium-addons-pro' ),
1537 ),
1538 'scales' => 1,
1539 'handles' => 'range',
1540 'condition' => array_merge(
1541 $float_conditions,
1542 array(
1543 'pa_badge_fgrayscale' => 'yes',
1544 )
1545 ),
1546 )
1547 );
1548
1549 $element->add_control(
1550 'pa_badge_fgscale_speed',
1551 array(
1552 'label' => __( 'Speed', 'premium-addons-pro' ),
1553 'type' => Controls_Manager::SLIDER,
1554 'range' => array(
1555 'px' => array(
1556 'min' => 0,
1557 'max' => 10,
1558 'step' => 0.1,
1559 ),
1560 ),
1561 'default' => array(
1562 'size' => 1,
1563 ),
1564 'condition' => array_merge(
1565 $float_conditions,
1566 array(
1567 'pa_badge_fgrayscale' => 'yes',
1568 )
1569 ),
1570 )
1571 );
1572
1573 $element->add_control(
1574 'pa_badge_disable_on_safari',
1575 array(
1576 'label' => __( 'Disable Floating Effects On Safari', 'premium-addons-pro' ),
1577 'type' => Controls_Manager::SWITCHER,
1578 'prefix_class' => 'pa-badge-disable-fe-',
1579 'separator' => 'before',
1580 'condition' => array(
1581 'premium_global_badge_switcher' => 'yes',
1582 'pa_badge_effects' => 'yes',
1583 ),
1584 )
1585 );
1586 }
1587
1588 /**
1589 * Render Global badge output in the editor.
1590 *
1591 * Written as a Backbone JavaScript template and used to generate the live preview.
1592 *
1593 * @since 2.2.8
1594 * @access public
1595 *
1596 * @param object $template for current template.
1597 * @param object $element for current element.
1598 */
1599 public function print_template( $template, $element ) {
1600
1601 if ( ! $template && 'widget' === $element->get_type() ) {
1602 return;
1603 }
1604
1605 $old_template = $template;
1606 ob_start();
1607 ?>
1608 <#
1609 var isEnabled = 'yes' === settings.premium_global_badge_switcher ? true : false;
1610
1611 if ( isEnabled ) {
1612
1613 var text = settings.pa_badge_text,
1614 iconEnabled = 'yes' === settings.pa_badge_icon_enable ? true : false,
1615 svgEnabled = 'yes' === settings.pa_badge_svg_enabled ? true : false,
1616 floatingEnabled = 'yes' === settings.pa_badge_effects ? true : false,
1617 badgeSettings = {
1618 text : text,
1619 };
1620
1621 if ( svgEnabled ) {
1622 badgeSettings.svgLayer = settings.pa_badge_svg;
1623 }
1624
1625 if ( iconEnabled ) {
1626 var type = settings.pa_icon_type,
1627 icon = {};
1628
1629 badgeSettings.iconType = type;
1630
1631 switch( type ) {
1632 case 'icon':
1633 icon = settings.pa_badge_icon;
1634 break;
1635
1636 case 'image':
1637 icon.url = settings.pa_badge_img.url;
1638 break;
1639
1640 case 'lottie':
1641 icon.url = settings.pa_badge_lottie_url;
1642 icon.loop = settings.pa_badge_loop;
1643 icon.reverse = settings.pa_badge_reverse;
1644 break;
1645
1646 default:
1647 icon = false;
1648 }
1649 } else {
1650 icon = false;
1651 }
1652
1653 badgeSettings.icon = icon;
1654
1655 if ( floatingEnabled ) {
1656 var floatingSettings = {},
1657 filtersEnabled = 'yes' === settings.pa_badge_fblur || 'yes' === settings.pa_badge_fgrayscale ? true : false;
1658
1659 if ( 'yes' === settings.pa_badge_ftranslate ) {
1660
1661 var translateSettings = {
1662 x_param_from: settings.pa_badge_ftranslatex.sizes.start,
1663 x_param_to: settings.pa_badge_ftranslatex.sizes.end,
1664 y_param_from: settings.pa_badge_ftranslatey.sizes.start,
1665 y_param_to: settings.pa_badge_ftranslatey.sizes.end,
1666 speed: settings.pa_badge_ftranslate_speed.size * 1000,
1667 };
1668
1669 floatingSettings.translate = translateSettings;
1670 }
1671
1672 if ( 'yes' === settings.pa_badge_frotate ) {
1673
1674 var rotateSettings = {
1675 x_param_from: settings.pa_badge_frotatex.sizes.start,
1676 x_param_to: settings.pa_badge_frotatex.sizes.end,
1677 y_param_from: settings.pa_badge_frotatey.sizes.start,
1678 y_param_to: settings.pa_badge_frotatey.sizes.end,
1679 z_param_from: settings.pa_badge_frotatez.sizes.start,
1680 z_param_to: settings.pa_badge_frotatez.sizes.end,
1681 speed: settings.pa_badge_frotate_speed.size * 1000,
1682 };
1683
1684 floatingSettings.rotate = rotateSettings;
1685 }
1686
1687 if ( 'yes' === settings.pa_badge_fopacity ) {
1688
1689 var opacitySettings = {
1690 from: settings.pa_badge_fopacity_value.sizes.start / 100,
1691 to: settings.pa_badge_fopacity_value.sizes.end / 100,
1692 speed: settings.pa_badge_fopacity_speed.size * 1000,
1693 };
1694
1695 floatingSettings.opacity = opacitySettings;
1696 }
1697
1698 if ( filtersEnabled ) {
1699 var filtersSettings = {};
1700
1701 if ( 'yes' === settings.pa_badge_fblur ) {
1702
1703 var blurSettings = {
1704 from: 'blur(' + settings.pa_badge_fblur_value.sizes.start + 'px)',
1705 to: 'blur(' + settings.pa_badge_fblur_value.sizes.end + 'px)',
1706 speed: settings.pa_badge_fblur_speed.size * 1000,
1707 };
1708
1709 filtersSettings.blur = blurSettings;
1710 }
1711
1712 if ( 'yes' === settings.pa_badge_fgrayscale ) {
1713 var gscaleSettings = {
1714 from: 'grayscale(' + settings.pa_badge_fgscale_value.sizes.start + '%)',
1715 to: 'grayscale(' + settings.pa_badge_fgscale_value.sizes.end + '%)',
1716 speed: settings.pa_badge_fgscale_speed.size,
1717 };
1718
1719 filtersSettings.gscale = gscaleSettings;
1720 }
1721
1722 floatingSettings.filters = filtersSettings;
1723 }
1724
1725 badgeSettings.floating = floatingSettings;
1726 }
1727
1728 view.addRenderAttribute( 'badge_data', {
1729 'id': 'premium-global-badge-' + view.getID(),
1730 'class': 'premium-global-badge-wrapper',
1731 'data-gbadge': JSON.stringify( badgeSettings )
1732 });
1733 #>
1734 <div {{{ view.getRenderAttributeString( 'badge_data' ) }}}></div>
1735 <#
1736 }
1737 #>
1738
1739 <?php
1740
1741 $slider_content = ob_get_contents();
1742 ob_end_clean();
1743 $template = $slider_content . $old_template;
1744 return $template;
1745 }
1746
1747 /**
1748 * Render Global badge output on the frontend.
1749 *
1750 * Written in PHP and used to collect badge settings and add it as an element attribute.
1751 *
1752 * @access public
1753 * @param object $element for current element.
1754 */
1755 public function before_render( $element ) {
1756
1757 $element_type = $element->get_type();
1758
1759 $id = $element->get_id();
1760
1761 $settings = $element->get_settings_for_display();
1762
1763 $badge_switcher = $settings['premium_global_badge_switcher'];
1764
1765 if ( 'yes' === $badge_switcher ) {
1766
1767 $text = strip_tags( $settings['pa_badge_text'] );
1768 $icon_enabled = 'yes' === $settings['pa_badge_icon_enable'] ? true : false;
1769 $svg_enabled = 'yes' === $settings['pa_badge_svg_enabled'] ? true : false;
1770 $floating_enabled = 'yes' === $settings['pa_badge_effects'] ? true : false;
1771 $badge_settings = array(
1772 'text' => $text,
1773 );
1774
1775 if ( $svg_enabled ) {
1776 $badge_settings['svgLayer'] = $settings['pa_badge_svg'];
1777 }
1778
1779 if ( $icon_enabled ) {
1780 $type = $settings['pa_icon_type'];
1781 $badge_settings['iconType'] = $type;
1782
1783 switch ( $type ) {
1784 case 'icon':
1785 $icon = $settings['pa_badge_icon'];
1786 break;
1787
1788 case 'image':
1789 $icon['url'] = $settings['pa_badge_img']['url'];
1790 $icon['alt'] = Control_Media::get_image_alt( $settings['pa_badge_img'] );
1791 break;
1792
1793 case 'lottie':
1794 $icon['url'] = esc_url( $settings['pa_badge_lottie_url'] );
1795 $icon['loop'] = $settings['pa_badge_loop'];
1796 $icon['reverse'] = $settings['pa_badge_reverse'];
1797 break;
1798
1799 default:
1800 $icon = false;
1801 break;
1802 }
1803 } else {
1804 $icon = false;
1805 }
1806
1807 $badge_settings['icon'] = $icon;
1808
1809 if ( $floating_enabled ) {
1810 $floating_settings = array();
1811 $filters_enabled = 'yes' === $settings['pa_badge_fblur'] || 'yes' === $settings['pa_badge_fgrayscale'] ? true : false;
1812
1813 if ( 'yes' === $settings['pa_badge_ftranslate'] ) {
1814
1815 $translate_settings = array(
1816 'x_param_from' => $settings['pa_badge_ftranslatex']['sizes']['start'],
1817 'x_param_to' => $settings['pa_badge_ftranslatex']['sizes']['end'],
1818 'y_param_from' => $settings['pa_badge_ftranslatey']['sizes']['start'],
1819 'y_param_to' => $settings['pa_badge_ftranslatey']['sizes']['end'],
1820 'speed' => $settings['pa_badge_ftranslate_speed']['size'] * 1000,
1821 );
1822
1823 $floating_settings['translate'] = $translate_settings;
1824 }
1825
1826 if ( 'yes' === $settings['pa_badge_frotate'] ) {
1827
1828 $rotate_settings = array(
1829 'x_param_from' => $settings['pa_badge_frotatex']['sizes']['start'],
1830 'x_param_to' => $settings['pa_badge_frotatex']['sizes']['end'],
1831 'y_param_from' => $settings['pa_badge_frotatey']['sizes']['start'],
1832 'y_param_to' => $settings['pa_badge_frotatey']['sizes']['end'],
1833 'z_param_from' => $settings['pa_badge_frotatez']['sizes']['start'],
1834 'z_param_to' => $settings['pa_badge_frotatez']['sizes']['end'],
1835 'speed' => $settings['pa_badge_frotate_speed']['size'] * 1000,
1836 );
1837
1838 $floating_settings['rotate'] = $rotate_settings;
1839 }
1840
1841 if ( 'yes' === $settings['pa_badge_fopacity'] ) {
1842
1843 $opacity_settings = array(
1844 'from' => $settings['pa_badge_fopacity_value']['sizes']['start'] / 100,
1845 'to' => $settings['pa_badge_fopacity_value']['sizes']['end'] / 100,
1846 'speed' => $settings['pa_badge_fopacity_speed']['size'] * 1000,
1847 );
1848
1849 $floating_settings['opacity'] = $opacity_settings;
1850 }
1851
1852 if ( $filters_enabled ) {
1853 $filters_settings = array();
1854 if ( 'yes' === $settings['pa_badge_fblur'] ) {
1855
1856 $blur_settings = array(
1857 'from' => 'blur(' . $settings['pa_badge_fblur_value']['sizes']['start'] . 'px)',
1858 'to' => 'blur(' . $settings['pa_badge_fblur_value']['sizes']['end'] . 'px)',
1859 'speed' => $settings['pa_badge_fblur_speed']['size'] * 1000,
1860 );
1861
1862 $filters_settings['blur'] = $blur_settings;
1863 }
1864
1865 if ( 'yes' === $settings['pa_badge_fgrayscale'] ) {
1866 $gscale_settings = array(
1867 'from' => 'grayscale(' . $settings['pa_badge_fgscale_value']['sizes']['start'] . '%)',
1868 'to' => 'grayscale(' . $settings['pa_badge_fgscale_value']['sizes']['end'] . '%)',
1869 'speed' => $settings['pa_badge_fgscale_speed']['size'],
1870 );
1871
1872 $filters_settings['gscale'] = $gscale_settings;
1873 }
1874
1875 $floating_settings['filters'] = $filters_settings;
1876 }
1877
1878 $badge_settings['floating'] = $floating_settings;
1879 }
1880
1881 $element->add_render_attribute( '_wrapper', 'data-gbadge', wp_json_encode( $badge_settings ) );
1882
1883 if ( 'widget' === $element_type && \Elementor\Plugin::instance()->editor->is_edit_mode() ) {
1884
1885 $element->add_render_attribute(
1886 'badge' . $id,
1887 array(
1888 'id' => 'premium-global-badge-temp-' . $id,
1889 'data-gbadge' => wp_json_encode( $badge_settings ),
1890 )
1891 );
1892
1893 ?>
1894 <div <?php echo wp_kses_post( $element->get_render_attribute_string( 'badge' . $id ) ); ?>></div>
1895 <?php
1896 }
1897 }
1898 }
1899
1900 /**
1901 * Check Script Enqueue
1902 *
1903 * Check if the script files should be loaded.
1904 *
1905 * @since 2.6.3
1906 * @access public
1907 *
1908 * @param object $element for current element.
1909 */
1910 public function check_script_enqueue( $element ) {
1911
1912 if ( $this->load_script ) {
1913 return;
1914 }
1915
1916 $settings = $element->get_active_settings();
1917
1918 if ( ! empty( $settings[ 'premium_global_badge_switcher' ] ) ) {
1919
1920 $this->enqueue_styles();
1921 $this->enqueue_scripts();
1922
1923 $this->load_script = true;
1924
1925 remove_action( 'elementor/frontend/before_render', array( $this, 'check_script_enqueue' ) );
1926 }
1927 }
1928 }