PluginProbe
WP Directory Kit / 1.5.9
WP Directory Kit v1.5.9
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / elementor-elements / classes / wdk-elementor-base.php

wdk-elementor-base.php in WP Directory Kit 1.5.9, at elementor-elements/classes/wdk-elementor-base.php

981 lines 49.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Wdk\Elementor\Widgets;
4
5 use Elementor\Widget_Base;
6 use Elementor\Controls_Manager;
7 use Elementor\Utils;
8 use Elementor\Typography;
9 use Elementor\Editor;
10 use Elementor\Plugin;
11 use Elementor\Repeater;
12 use Elementor\Core\Schemes;
13 use Elementor\Group_Control_Typography;
14 use Elementor\Group_Control_Border;
15 use Elementor\Group_Control_Box_Shadow;
16 use Elementor\Group_Control_Css_Filter;
17
18 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
19
20 /**
21 * @since 1.1.0
22 */
23 class WdkElementorBase extends Widget_Base {
24 /**
25 * data array
26 *
27 * @var array
28 */
29 protected $data = array();
30 protected $WMVC = NULL;
31
32 public function __construct($data = array(), $args = null) {
33
34 /* load icons for tabs in edit mode */
35 wp_enqueue_style( 'wdk-elementor-main', WPDIRECTORYKIT_URL. 'elementor-elements/assets/css/wdk-main.css' );
36
37 if ($this->is_edit_mode_load()) {
38 $this->enqueue_styles_scripts();
39 }
40
41
42 $this->WMVC = &wdk_get_instance();
43 $this->WMVC->model('listingfield_m');
44 $this->WMVC->model('listing_m');
45 $this->WMVC->load_helper('listing');
46 parent::__construct($data, $args);
47 }
48
49 /**
50 * Retrieve the widget name.
51 *
52 * @since 1.1.0
53 *
54 * @access public
55 *
56 * @return string Widget name.
57 */
58 public function get_name() {
59 return 'wdk-base';
60 }
61
62 /**
63 * Retrieve the widget title.
64 *
65 * @since 1.1.0
66 *
67 * @access public
68 *
69 * @return string Widget title.
70 */
71 public function get_title() {
72 return esc_html__( 'Wdk Widget Name', 'wpdirectorykit' );
73 }
74
75 /**
76 * Retrieve the widget icon.
77 *
78 * @since 1.1.0
79 *
80 * @access public
81 *
82 * @return string Widget icon.
83 */
84 public function get_icon() {
85 return '';
86 }
87
88 /**
89 * Retrieve the list of categories the widget belongs to.
90 *
91 * Used to determine where to display the widget in the editor.
92 *
93 * Note that currently Elementor supports only one category.
94 * When multiple categories passed, Elementor uses the first one.
95 *
96 * @since 1.1.0
97 *
98 * @access public
99 *
100 * @return array Widget categories.
101 */
102 public function get_categories() {
103 return [ 'wdk-elementor' ];
104 }
105
106 /**
107 * Register the widget controls.
108 *
109 * Adds different input fields to allow the user to change and customize the widget settings.
110 *
111 * @since 1.1.0
112 *
113 * @access protected
114 */
115 protected function register_controls() {
116 /* TAB_STYLE */
117 $this->start_controls_section(
118 'section_form_css',
119 [
120 'label' => esc_html__( 'Custom сss', 'wpdirectorykit' ),
121 'tab' => Controls_Manager::TAB_STYLE,
122 ]
123 );
124
125 $this->add_control(
126 'custom_css_title',
127 [
128 'raw' => esc_html__( 'Add your own custom CSS here', 'wpdirectorykit' ),
129 'type' => Controls_Manager::RAW_HTML,
130 ]
131 );
132
133 $this->add_control(
134 'custom_css',
135 [
136 'type' => Controls_Manager::CODE,
137 'label' => esc_html__( 'Custom CSS', 'wpdirectorykit' ),
138 'language' => 'css',
139 'render_type' => 'ui',
140 'show_label' => false,
141 'separator' => 'none',
142 ]
143 );
144
145 $this->add_control(
146 'custom_css_description',
147 [
148 'raw' => esc_html__( 'Use "selector" to target wrapper element. Examples:<br>selector {color: red;} // For main element<br>selector .child-element {margin: 10px;} // For child element<br>.my-class {text-align: center;} // Or use any custom selector', 'wpdirectorykit' ),
149 'type' => Controls_Manager::RAW_HTML,
150 'content_classes' => 'elementor-descriptor',
151 ]
152 );
153
154 $this->end_controls_section();
155
156
157 }
158
159 /**
160 * Render the widget output on the frontend.
161 *
162 * Written in PHP and used to generate the final HTML.
163 *
164 * @since 1.1.0
165 *
166 * @access protected
167 */
168 protected function render() {
169 $this->enqueue_styles_scripts();
170 $this->add_page_settings_css();
171 }
172
173
174 public function view($view_file = '', $element = NULL, $print = false)
175 {
176 if(empty($view_file)) return false;
177 $file = false;
178
179 if(is_child_theme() && file_exists(get_stylesheet_directory().'/wpdirectorykit/elementor-elements/views/'.$view_file.'.php'))
180 {
181 $file = get_stylesheet_directory().'/wpdirectorykit/elementor-elements/views/'.$view_file.'.php';
182 }
183 elseif(file_exists(get_template_directory().'/wpdirectorykit/elementor-elements/views/'.$view_file.'.php'))
184 {
185 $file = get_template_directory().'/wpdirectorykit/elementor-elements/views/'.$view_file.'.php';
186 }
187 elseif(file_exists(WPDIRECTORYKIT_PATH.'elementor-elements/views/'.$view_file.'.php'))
188 {
189 $file = WPDIRECTORYKIT_PATH.'elementor-elements/views/'.$view_file.'.php';
190 }
191
192 if($file)
193 {
194 extract($element);
195 if($print) {
196 include $file;
197 } else {
198 ob_start();
199 include $file;
200 return ob_get_clean();
201 }
202 }
203 else
204 {
205 if($print) {
206 echo 'View file not found in: '.esc_html(WPDIRECTORYKIT_PATH.'elementor-elements/views/'.$view_file.'.php');
207 } else {
208 return 'View file not found in: '.esc_html(WPDIRECTORYKIT_PATH.'elementor-elements/views/'.$view_file.'.php');
209 }
210 }
211 }
212
213 public function generate_renders_tabs($selectors = array(), $tab_prefix='', $enable_options = array(), $disable_options = array()) {
214 /* margin */
215 //$options = ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition','image_size_control','image_fit_control', 'height', 'width','font-size','css_filters','background_group','hover_animation'];
216 $options = ['typo','color','background','border','border_radius','padding','shadow']; // default
217
218 /* defined */
219 if(is_string($enable_options)){
220 switch($enable_options) {
221 case 'block': $enable_options = ['typo','color','background','border','border_radius','padding','shadow','transition'];
222 break;
223 case 'text-block': $enable_options = ['align','typo','color','background','border','border_radius','padding','shadow','transition'];
224 break;
225 case 'text': $enable_options = ['align','typo','color','background','border','border_radius','padding','shadow','transition'];
226 break;
227 case 'full': $enable_options = ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition'];
228 break;
229 default: $enable_options = ['margin','align','typo','color','background','border','border_radius','padding','shadow','transition'];
230
231 break;
232 }
233 }
234
235
236 /* enable options */
237 if(!empty($enable_options)){
238 $options = $enable_options;
239 }
240 $options_flip = array_flip($options);
241 /* disable options */
242 if(!empty($disable_options)){
243 foreach ($disable_options as $value) {
244 if(isset($options_flip[$value]))
245 unset($options[$options_flip[$value]]);
246 }
247 }
248 $tabs_enable = true;
249 if(wmvc_count($selectors) == 1){
250 $tabs_enable = false;
251 }
252 if($tabs_enable)
253 $this->start_controls_tabs( $tab_prefix.'_style' );
254 foreach($selectors as $key => $selector)
255 $this->_generate_tabs($selector, $key, $tab_prefix, $options, $tabs_enable);
256 if($tabs_enable)
257 $this->end_controls_tabs();
258
259 }
260
261 public function _generate_tabs($selector='', $prefix = '', $type='', $options = array(), $tabs_enable = true) {
262 if(empty($selector)) return false;
263
264 if(empty($prefix) || $prefix == 'normal'){
265 $selector = $selector;
266 $prefix = 'normal';
267 }
268 else
269 $selector = sprintf($selector,':'.$prefix);
270
271 if($tabs_enable)
272 $this->start_controls_tab(
273 $type.'_'.$prefix.'_style',
274 [
275 'label' => ucfirst($prefix),
276 ]
277 );
278
279 if(in_array('typo',$options))
280 $this->add_group_control(
281 Group_Control_Typography::get_type(),
282 [
283 'name' => $type.'_typo'.$prefix,
284 'selector' => $selector,
285 ]
286 );
287
288 if(in_array('align',$options))
289 $this->add_responsive_control(
290 $type.'_align'.$prefix,
291 [
292 'label' => esc_html__( 'Alignment', 'wpdirectorykit' ),
293 'type' => Controls_Manager::CHOOSE,
294 'options' => [
295 'left' => [
296 'title' => esc_html__( 'Left', 'wpdirectorykit' ),
297 'icon' => 'eicon-text-align-left',
298 ],
299 'center' => [
300 'title' => esc_html__( 'Center', 'wpdirectorykit' ),
301 'icon' => 'eicon-text-align-center',
302 ],
303 'right' => [
304 'title' => esc_html__( 'Right', 'wpdirectorykit' ),
305 'icon' => 'eicon-text-align-right',
306 ],
307 'justify' => [
308 'title' => esc_html__( 'Justified', 'wpdirectorykit' ),
309 'icon' => 'eicon-text-align-justify',
310 ],
311 ],
312 'selectors' => [
313 $selector => 'text-align: {{VALUE}};',
314 ],
315 ]
316 );
317
318 if(in_array('color',$options))
319 $this->add_responsive_control(
320 $type.'_color'.$prefix,
321 [
322 'label' => esc_html__( 'Color', 'wpdirectorykit' ),
323 'type' => Controls_Manager::COLOR,
324 'selectors' => [
325 $selector => 'color: {{VALUE}};',
326 ],
327 ]
328 );
329
330 if(in_array('background',$options))
331 $this->add_responsive_control(
332 $type.'_background'.$prefix,
333 [
334 'label' => esc_html__( 'Background', 'wpdirectorykit' ),
335 'type' => Controls_Manager::COLOR,
336 'selectors' => [
337 $selector => 'background-color: {{VALUE}};',
338 ],
339 ]
340 );
341
342 if(in_array('border',$options))
343 $this->add_group_control(
344 Group_Control_Border::get_type(), [
345 'name' => $type.'_border'.$prefix,
346 'selector' => $selector,
347 ]
348 );
349
350 if(in_array('outline',$options)) {
351
352 $this->add_responsive_control(
353 $type.'_outline'.$prefix,
354 [
355 'label' => esc_html_x( 'Outline Type', 'Outline Control', 'wpdirectorykit' ),
356 'type' => \Elementor\Controls_Manager::SELECT,
357 'options' => [
358 '' => esc_html__( 'Default', 'wpdirectorykit' ),
359 'none' => esc_html__( 'None', 'wpdirectorykit' ),
360 'solid' => esc_html_x( 'Solid', 'Outline Control', 'wpdirectorykit' ),
361 'double' => esc_html_x( 'Double', 'Outline Control', 'wpdirectorykit' ),
362 'dotted' => esc_html_x( 'Dotted', 'Outline Control', 'wpdirectorykit' ),
363 'dashed' => esc_html_x( 'Dashed', 'Outline Control', 'wpdirectorykit' ),
364 'groove' => esc_html_x( 'Groove', 'Outline Control', 'wpdirectorykit' ),
365 ],
366 'selectors' => [
367 $selector => 'outline-style: {{VALUE}};',
368 ],
369 ]
370 );
371
372 $this->add_responsive_control(
373 $type.'_outline_width'.$prefix,
374 [
375 'label' => esc_html_x( 'Width', 'Outline Control', 'wpdirectorykit' ),
376 'type' => \Elementor\Controls_Manager::NUMBER,
377 'default' => '',
378 'selectors' => [
379 $selector => 'outline-width: {{VALUE}}px;',
380 ],
381 'condition' => [
382 $type.'_outline'.$prefix.'!' => [ '', 'none' ],
383 ],
384 ]
385 );
386
387 $this->add_responsive_control(
388 $type.'_outline_color'.$prefix,
389 [
390 'label' => esc_html_x( 'Color', 'Outline Control', 'wpdirectorykit' ),
391 'type' => \Elementor\Controls_Manager::COLOR,
392 'default' => '',
393 'selectors' => [
394 $selector => 'outline-color: {{VALUE}};',
395 ],
396 'condition' => [
397 $type.'_outline'.$prefix.'!' => [ '', 'none' ],
398 ],
399 ]
400 );
401
402 $this->add_responsive_control(
403 $type.'_outline_offset'.$prefix,
404 [
405 'label' => esc_html_x( 'Offset', 'Outline Control', 'wpdirectorykit' ),
406 'type' => \Elementor\Controls_Manager::NUMBER,
407 'default' => '',
408 'selectors' => [
409 $selector => 'outline-offset: {{VALUE}}px;',
410 ],
411 'condition' => [
412 $type.'_outline'.$prefix.'!' => [ '', 'none' ],
413 ],
414 ]
415 );
416
417 }
418
419 if(in_array('border_radius',$options))
420 $this->add_responsive_control(
421 $type.'_border_radius'.$prefix,
422 [
423 'label' => esc_html__( 'Border Radius', 'wpdirectorykit' ),
424 'type' => Controls_Manager::DIMENSIONS,
425 'size_units' => [ 'px', '%' ],
426 'selectors' => [
427 $selector => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
428 ],
429 ]
430 );
431
432 if(in_array('padding',$options))
433 $this->add_responsive_control(
434 $type.'_padding'.$prefix,
435 [
436 'label' => esc_html__( 'Padding', 'wpdirectorykit' ),
437 'type' => Controls_Manager::DIMENSIONS,
438 'size_units' => [ 'px', 'em', '%' ],
439 'selectors' => [
440 $selector => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
441 ],
442 ]
443 );
444
445
446 if(in_array('margin',$options))
447 $this->add_responsive_control(
448 $type.'_margin'.$prefix,
449 [
450 'label' => esc_html__( 'Margin', 'wpdirectorykit' ),
451 'type' => Controls_Manager::DIMENSIONS,
452 'size_units' => [ 'px', 'em', '%' ],
453 'selectors' => [
454 $selector => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
455 ],
456 ]
457 );
458
459 if(in_array('shadow',$options))
460 $this->add_group_control(
461 Group_Control_Box_Shadow::get_type(),
462 [
463 'name' => $type.'_box_shadow'.$prefix,
464 'exclude' => [
465 'field_shadow_position',
466 ],
467 'selector' => $selector,
468 ]
469 );
470
471 if(in_array('transition',$options))
472 $this->add_responsive_control(
473 $type.'_transition'.$prefix,
474 [
475 'label' => esc_html__( 'Transition Duration', 'wpdirectorykit' ),
476 'type' => Controls_Manager::SLIDER,
477 'range' => [
478 'px' => [
479 'min' => 0,
480 'max' => 3000,
481 ],
482 ],
483 'selectors' => [
484 $selector => 'transition-duration: {{SIZE}}ms',
485 ],
486 ]
487 );
488 if(in_array('width',$options))
489 $this->add_responsive_control(
490 $type.'_width'.$prefix,
491 [
492 'label' => esc_html__( 'Width', 'wpdirectorykit' ),
493 'type' => Controls_Manager::SLIDER,
494 'range' => [
495 'px' => [
496 'min' => 0,
497 'max' => 3000,
498 ],
499 ],
500 'size_units' => [ 'px', 'em', '%' ],
501 'selectors' => [
502 $selector => 'width: {{SIZE}}{{UNIT}}',
503 ],
504 ]
505 );
506 if(in_array('height',$options))
507 $this->add_responsive_control(
508 $type.'_height'.$prefix,
509 [
510 'label' => esc_html__( 'height', 'wpdirectorykit' ),
511 'type' => Controls_Manager::SLIDER,
512 'range' => [
513 'px' => [
514 'min' => 0,
515 'max' => 3000,
516 ],
517 ],
518 'size_units' => [ 'px', 'em', '%' ],
519 'selectors' => [
520 $selector => 'height: {{SIZE}}{{UNIT}}',
521 ],
522 ]
523 );
524
525 if(in_array('font-size',$options))
526 $this->add_responsive_control(
527 $type.'_font_size'.$prefix,
528 [
529 'label' => esc_html__( 'Font Size', 'wpdirectorykit' ),
530 'type' => Controls_Manager::SLIDER,
531 'size_units' => [ 'px', 'em', '%' ],
532 'range' => [
533 'px' => [
534 'min' => 0,
535 'max' => 150,
536 ],
537 'vw' => [
538 'min' => 0,
539 'max' => 100,
540 ],
541 '%' => [
542 'min' => 0,
543 'max' => 100,
544 ],
545 ],
546 'selectors' => [
547 $selector => 'font-size: {{SIZE}}{{UNIT}};',
548 ],
549 ]
550 );
551
552
553 if (in_array('image_size_control', $options)) {
554 $this->add_responsive_control(
555 $type.'_image_size_control_max_heigth'.$prefix,
556 [
557 'label' => esc_html__('Max Height', 'wpdirectorykit'),
558 'type' => Controls_Manager::SLIDER,
559 'range' => [
560 'px' => [
561 'min' => 10,
562 'max' => 1500,
563 ],
564 'vw' => [
565 'min' => 0,
566 'max' => 100,
567 ],
568 '%' => [
569 'min' => 0,
570 'max' => 100,
571 ],
572 ],
573 'size_units' => [ 'px', 'vw','%' ],
574 'selectors' => [
575 $selector => 'max-height: {{SIZE}}{{UNIT}}',
576 ],
577
578 ]
579 );
580
581 $this->add_responsive_control(
582 $type.'_image_size_control_max_width'.$prefix,
583 [
584 'label' => esc_html__('Max Width', 'wpdirectorykit'),
585 'type' => Controls_Manager::SLIDER,
586 'range' => [
587 'px' => [
588 'min' => 10,
589 'max' => 1500,
590 ],
591 'vw' => [
592 'min' => 0,
593 'max' => 100,
594 ],
595 '%' => [
596 'min' => 0,
597 'max' => 100,
598 ],
599 ],
600 'size_units' => [ 'px', 'vw','%' ],
601 'selectors' => [
602 $selector => 'max-width: {{SIZE}}{{UNIT}}',
603 ],
604
605 ]
606 );
607
608 $this->add_responsive_control(
609 $type.'_image_size_control_heigth'.$prefix,
610 [
611 'label' => esc_html__('Height', 'wpdirectorykit'),
612 'type' => Controls_Manager::SLIDER,
613 'range' => [
614 'px' => [
615 'min' => 10,
616 'max' => 1500,
617 ],
618 'vw' => [
619 'min' => 0,
620 'max' => 100,
621 ],
622 '%' => [
623 'min' => 0,
624 'max' => 100,
625 ],
626 ],
627 'size_units' => [ 'px', 'vw','%' ],
628 'selectors' => [
629 $selector => 'height: {{SIZE}}{{UNIT}}',
630 ],
631
632 ]
633 );
634
635 $this->add_responsive_control(
636 $type.'_image_size_control_width'.$prefix,
637 [
638 'label' => esc_html__('Width', 'wpdirectorykit'),
639 'type' => Controls_Manager::SLIDER,
640 'range' => [
641 'px' => [
642 'min' => 10,
643 'max' => 1500,
644 ],
645 'vw' => [
646 'min' => 0,
647 'max' => 100,
648 ],
649 '%' => [
650 'min' => 0,
651 'max' => 100,
652 ],
653 ],
654 'size_units' => [ 'px', 'vw','%' ],
655 'selectors' => [
656 $selector => 'width: {{SIZE}}{{UNIT}}',
657 ],
658
659 ]
660 );
661 }
662
663
664 if (in_array('image_fit_control', $options)) {
665
666
667 $this->add_control(
668 $type.'_image_fit_control'.$prefix,
669 [
670 'label' => esc_html__( 'Fit', 'wpdirectorykit' ),
671 'type' => \Elementor\Controls_Manager::SELECT,
672 'options' => [
673 '' => esc_html__( 'Default', 'wpdirectorykit' ),
674 'fill' => esc_html__( 'Fill', 'wpdirectorykit' ),
675 'contain' => esc_html__( 'Contain', 'wpdirectorykit' ),
676 'cover' => esc_html__( 'Cover', 'wpdirectorykit' ),
677 'none' => esc_html__( 'None', 'wpdirectorykit' ),
678 'scale-down' => esc_html__( 'Scale down', 'wpdirectorykit' ),
679 ],
680 'selectors' => [
681 $selector => 'object-fit: {{VALUE}};',
682 ],
683 ]
684 );
685 $this->add_control(
686 $type.'_image_fit_control_position'.$prefix,
687 [
688 'label' => esc_html__( 'Fit Position', 'wpdirectorykit' ),
689 'type' => \Elementor\Controls_Manager::SELECT,
690 'options' => [
691 '' => esc_html__( 'Default', 'wpdirectorykit' ),
692 'top' => esc_html__( 'Top', 'wpdirectorykit' ),
693 'bottom' => esc_html__( 'Bottom', 'wpdirectorykit' ),
694 'left' => esc_html__( 'Left', 'wpdirectorykit' ),
695 'right' => esc_html__( 'Right', 'wpdirectorykit' ),
696 'center' => esc_html__( 'Center', 'wpdirectorykit' ),
697 ],
698 'selectors' => [
699 $selector => 'object-position: {{VALUE}};',
700 ],
701 ]
702 );
703
704 }
705
706 if (in_array('css_filters', $options)) {
707 $this->add_group_control(
708 \Elementor\Group_Control_Css_Filter::get_type(),
709 [
710 'name' => $type.'_css_filters'.$prefix,
711 'selector' => $selector,
712 ]
713 );
714 }
715
716 if (in_array('background_group', $options)) {
717 $this->add_group_control(
718 \Elementor\Group_Control_Background::get_type(),
719 [
720 'name' => $type.'_background_group'.$prefix,
721 'label' => esc_html__( 'Background group', 'wpdirectorykit' ),
722 'types' => [ 'classic', 'gradient', 'video' ],
723 'selector' => $selector,
724 ]
725 );
726 $this->add_control(
727 $type.'_background_group_hr'.$prefix,
728 [
729 'type' => \Elementor\Controls_Manager::DIVIDER,
730 ]
731 );
732 }
733
734 if (in_array('hover_animation', $options) && $prefix == 'hover') {
735 $this->add_control(
736 $type.'_hover_animation'.$prefix,
737 [
738 'label' => esc_html__( 'Hover Animation', 'wpdirectorykit' ),
739 'type' => \Elementor\Controls_Manager::SELECT2,
740 'multiple' => false,
741 'options' => [
742 'grow' => esc_html__( 'Grow', 'wpdirectorykit' ),
743 'shrink' => esc_html__( 'Shrink', 'wpdirectorykit' ),
744 'pulse' => esc_html__( 'Pulse', 'wpdirectorykit' ),
745 'pulse-grow' => esc_html__( 'Pulse Grow', 'wpdirectorykit' ),
746 'pulse-shrink' => esc_html__( 'Pulse Shrink', 'wpdirectorykit' ),
747 'push' => esc_html__( 'Push', 'wpdirectorykit' ),
748 'pop' => esc_html__( 'Pop', 'wpdirectorykit' ),
749 'bounce-in' => esc_html__( 'Bounce In', 'wpdirectorykit' ),
750 'bounce-out' => esc_html__( 'Bounce Out', 'wpdirectorykit' ),
751 'rotate' => esc_html__( 'Rotate', 'wpdirectorykit' ),
752 'grow-rotate' => esc_html__( 'Grow Rotate', 'wpdirectorykit' ),
753 'float' => esc_html__( 'Float', 'wpdirectorykit' ),
754 'sink' => esc_html__( 'Sink', 'wpdirectorykit' ),
755 'bob' => esc_html__( 'Bob', 'wpdirectorykit' ),
756 'hang' => esc_html__( 'Hang', 'wpdirectorykit' ),
757 'skew' => esc_html__( 'Skew', 'wpdirectorykit' ),
758 'skew-forward' => esc_html__( 'Skew Forward', 'wpdirectorykit' ),
759 'skew-backward' => esc_html__( 'Skew Backward', 'wpdirectorykit' ),
760 'wobble-vertical' => esc_html__( 'Wobble Vertical', 'wpdirectorykit' ),
761 'wobble-horizontal' => esc_html__( 'wobble Horizontal', 'wpdirectorykit' ),
762 'wobble-to-bottom-right' => esc_html__( 'Wobble To Bottom Right', 'wpdirectorykit' ),
763 'wobble-to-top-right' => esc_html__( 'Wobble To Top Eight', 'wpdirectorykit' ),
764 'wobble-top' => esc_html__( 'Wobble Top', 'wpdirectorykit' ),
765 'wobble-bottom' => esc_html__( 'Wobble Bottom', 'wpdirectorykit' ),
766 'wobble-skew' => esc_html__( 'Wobble Skew', 'wpdirectorykit' ),
767 'buzz' => esc_html__( 'Buzz', 'wpdirectorykit' ),
768 'buzz-out' => esc_html__( 'Buzz Out', 'wpdirectorykit' ),
769 ],
770 'selectors_dictionary' => [
771 'grow' => 'animation-name: wdk-hover-animation-grow;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;',
772 'shrink' => 'animation-name: wdk-hover-animation-shrink;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;',
773 'pulse' => 'animation-name: wdk-hover-animation-pulse;animation-duration: 1s; animation-timing-function: linear;animation-iteration-count: infinite;',
774 'pulse-grow' => 'animation-name: wdk-hover-animation-pulse-grow; animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: infinite;animation-direction: alternate;',
775 'pulse-shrink' => 'animation-name: wdk-hover-animation-pulse-shrink;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: infinite;animation-direction: alternate;',
776 'push' => 'animation-name: wdk-hover-animation-push;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;',
777 'pop' => 'animation-name: wdk-hover-animation-pop;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;',
778 'bounce-in' => 'animation-name: wdk-hover-animation-bounce-in;animation-duration: 0.5s;animation-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);;animation-iteration-count: 1;',
779 'bounce-out' => 'animation-name: wdk-hover-animation-bounce-out;animation-duration: 0.5s;animation-timing-function: cubic-bezier(0.47, 2.02, 0.31, -0.36);animation-iteration-count: 1;',
780 'rotate' => 'animation-name: wdk-hover-animation-rotate;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;',
781 'grow-rotate' => 'animation-name: wdk-hover-animation-grow;animation-duration: 0.3s;animation-timing-function: linear;animation-iteration-count: 1;',
782 'float' => 'animation-name: wdk-hover-animation-float;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;',
783 'sink' => 'animation-name: wdk-hover-animation-sink;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;',
784 'bob' => 'animation-name: wdk-hover-animation-bob-float, wdk-hover-animation-bob;animation-duration: .3s, 1.5s;animation-delay: 0s, .3s;animation-timing-function: ease-out, ease-in-out;animation-iteration-count: 1, infinite;animation-fill-mode: forwards;animation-direction: normal, alternate;',
785 'hang' => 'animation-name: wdk-hover-animation-hang-sink, wdk-hover-animation-hang;animation-duration: .3s, 1.5s;animation-delay: 0s, .3s;animation-timing-function: ease-out, ease-in-out;animation-iteration-count: 1, infinite;animation-fill-mode: forwards;animation-direction: normal, alternate;',
786 'skew' => 'animation-name: wdk-hover-animation-skew;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;',
787 'skew-forward' => 'animation-name: wdk-hover-animation-skew-forward;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;transform-origin: 0 100%;',
788 'skew-backward' => 'animation-name: wdk-hover-animation-skew-backward;animation-duration: 0.3s;animation-timing-function: ease-out;animation-iteration-count: 1;transform-origin: 0 100%;',
789 'wobble-vertical' => 'animation-name: wdk-hover-animation-wobble-vertical;animation-duration: 1s;animation-timing-function: ease-in-out; animation-iteration-count: 1;',
790 'wobble-horizontal' => 'animation-name: wdk-hover-animation-wobble-horizontal; animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;',
791 'wobble-to-bottom-right' => 'animation-name: wdk-hover-animation-wobble-to-bottom-right;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;',
792 'wobble-to-top-right' => 'animation-name: wdk-hover-animation-wobble-to-top-right;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;',
793 'wobble-top' => 'transform-origin: 0 100%;animation-name: wdk-hover-animation-wobble-top;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;',
794 'wobble-bottom' => 'transform-origin: 100% 0;animation-name: wdk-hover-animation-wobble-bottom;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;',
795 'wobble-skew' => 'animation-name: wdk-hover-animation-wobble-skew;animation-duration: 1s;animation-timing-function: ease-in-out;animation-iteration-count: 1;',
796 'buzz' => 'animation-name: wdk-hover-animation-buzz;animation-duration: 0.15s;animation-timing-function: linear;animation-iteration-count: infinite;',
797 'buzz-out' => 'animation-name: wdk-hover-animation-buzz-out;animation-duration: 0.75s;animation-timing-function: linear;animation-iteration-count: 1;',
798 ],
799 'default' => '',
800 'selectors' => [
801 $selector => '{{VALUE}};',
802 ],
803 'render_type' => 'template'
804 ]
805 );
806 }
807
808 if($tabs_enable)
809 $this->end_controls_tab();
810 }
811
812
813 /**
814 * @param $post_css Post
815 */
816 public function add_page_settings_css() {
817 $settings = $this->get_settings();
818
819 if(!isset($settings['custom_css']))
820 return;
821
822 $custom_css = $settings['custom_css'];
823 $custom_css = trim( $custom_css );
824
825 if ( empty( $custom_css ) ) {
826 return;
827 }
828
829 // Add a css comment
830 $custom_css_file = '/* Start custom CSS for page-settings */' .
831 str_replace( 'selector', '#wdk_el_' . $this->get_id_int(), $custom_css ).
832 str_replace( 'selector', '.elementor-element.elementor-element-' . $this->get_id(), $custom_css ).
833 '/* End custom CSS */';
834
835
836 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText
837 echo '<style>'.wmvc_xss_clean($custom_css_file).'</style>';
838 }
839
840 private function break_css($css)
841 {
842
843 $results = array();
844 preg_match_all('/(.+?)\s?\{\s?(.+?)\s?\}/', $css, $matches);
845 foreach($matches[0] AS $i=>$original)
846 foreach(explode(';', $matches[2][$i]) AS $attr)
847 if (strlen(trim($attr)) > 0) // for missing semicolon on last element, which is legal
848 {
849 list($name, $value) = explode(':', $attr);
850 $results[$matches[1][$i]][trim($name)] = trim($value);
851 }
852 return $results;
853 }
854
855 public function generate_icon($icon, $attributes = [], $tag = 'i' ){
856 if ( empty( $icon['library'] ) ) {
857 return false;
858 }
859 $output = '';
860 // handler SVG Icon
861 if ( 'svg' === $icon['library'] ) {
862 $output = \Elementor\Icons_Manager::render_uploaded_svg_icon( $icon['value'] );
863 } else {
864 $output = $this->render_icon_html( $icon, $attributes, $tag );
865 }
866
867 return $output;
868 }
869
870 public function render_icon_html( $icon, $attributes = [], $tag = 'i' ) {
871 $icon_types = \Elementor\Icons_Manager::get_icon_manager_tabs();
872 if ( isset( $icon_types[ $icon['library'] ]['render_callback'] ) && is_callable( $icon_types[ $icon['library'] ]['render_callback'] ) ) {
873 return call_user_func_array( $icon_types[ $icon['library'] ]['render_callback'], [ $icon, $attributes, $tag ] );
874 }
875
876 if ( empty( $attributes['class'] ) ) {
877 $attributes['class'] = $icon['value'];
878 } else {
879 if ( is_array( $attributes['class'] ) ) {
880 $attributes['class'][] = $icon['value'];
881 } else {
882 $attributes['class'] .= ' ' . $icon['value'];
883 }
884 }
885 return '<' . $tag . ' ' . Utils::render_html_attributes( $attributes ) . '></' . $tag . '>';
886 }
887
888 public static function render_svg_icon( $value ) {
889 if ( ! isset( $value['id'] ) ) {
890 return '';
891 }
892
893 return Svg_Handler::get_inline_svg( $value['id'] );
894 }
895
896 public function enqueue_styles_scripts() {
897
898 }
899
900 public function is_edit_mode_load() {
901
902 if (isset($this->is_edit_mode) && null !== $this->is_edit_mode ) {
903 return $this->is_edit_mode;
904 }
905
906 // Ajax request as Editor mode
907 $actions = array(
908 'elementor',
909 // Templates
910 'elementor_get_templates',
911 'elementor_save_template',
912 'elementor_get_template',
913 'elementor_delete_template',
914 'elementor_export_template',
915 'elementor_import_template',
916 );
917
918 if (isset($_REQUEST['action']) && in_array($_REQUEST['action'], $actions)) {
919 return true;
920 }
921
922 if (isset($_REQUEST['elementor-preview'])) {
923 return true;
924 }
925
926 return false;
927 }
928
929
930
931 /**
932 * Adding Go Premium message to all widgets
933 *
934 * @since 1.4.2
935 */
936 public function insert_pro_message($section = 1)
937 {
938 if(!function_exists('run_wdk_membership')){
939 $this->start_controls_section(
940 'wdk_section_pro',
941 [
942 'label' => __('Go Premium for More Features', 'wpdirectorykit'),
943 'tab' => $section,
944 ]
945 );
946
947 $this->add_control(
948 'wdk_control_get_pro',
949 [
950 'label' => __('Unlock more possibilities', 'wpdirectorykit'),
951 'type' => \Elementor\Controls_Manager::CHOOSE,
952 'options' => [
953 '1' => [
954 'title' => '',
955 'icon' => 'fa fa-unlock-alt',
956 ],
957 ],
958 'default' => '1',
959 'toggle' => false,
960 /* translators: 1: Tag with link open, 2: close link tag. */
961 'description' => '<span class="wdk_control_get_pro">'.wdk_sprintf(esc_html__(' %1$sGet our Addons%2$s for more awesome elements and powerful features!','wpdirectorykit'),'<a href="//wpdirectorykit.com/plugins.html" target="_blank">','</a>').'</span>'
962
963 ]
964 );
965
966 $this->end_controls_section();
967 }
968 }
969
970 public function editing_element($key, $toolbar = 'basic', $attr = array()) {
971 $this->add_inline_editing_attributes( $key, $toolbar );
972 foreach ($attr as $key_attr => $value_attr) {
973 $this->add_render_attribute( $key, $key_attr, $value_attr );
974 }
975
976 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.NonSingularStringLiteralText
977 echo $this->get_render_attribute_string( $key );
978 }
979
980 }
981