PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 3.9.9
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v3.9.9
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / button / button.php
elementskit-lite / widgets / button Last commit date
button-handler.php 3 years ago button.php 1 year ago
button.php
615 lines
1 <?php
2 namespace Elementor;
3
4 use \Elementor\ElementsKit_Widget_Button_Handler as Handler;
5 use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager;
6
7 if ( ! defined( 'ABSPATH' ) ) exit;
8
9
10 class ElementsKit_Widget_Button extends Widget_Base {
11 use \ElementsKit_Lite\Widgets\Widget_Notice;
12
13 public $base;
14
15 public function get_name() {
16 return Handler::get_name();
17 }
18
19 public function get_title() {
20 return Handler::get_title();
21 }
22
23 public function get_icon() {
24 return Handler::get_icon();
25 }
26
27 public function get_categories() {
28 return Handler::get_categories();
29 }
30
31 public function get_keywords() {
32 return Handler::get_keywords();
33 }
34
35 public function get_help_url() {
36 return 'https://wpmet.com/doc/button/';
37 }
38 protected function is_dynamic_content(): bool {
39 return false;
40 }
41
42 public function has_widget_inner_wrapper(): bool {
43 return ! Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
44 }
45
46 protected function register_controls() {
47
48
49 $this->start_controls_section(
50 'ekit_btn_section_content',
51 array(
52 'label' => esc_html__( 'Content', 'elementskit-lite' ),
53 )
54 );
55
56 $this->add_control(
57 'ekit_btn_text',
58 [
59 'label' =>esc_html__( 'Label', 'elementskit-lite' ),
60 'type' => Controls_Manager::TEXT,
61 'default' =>esc_html__( 'Learn more ', 'elementskit-lite' ),
62 'placeholder' =>esc_html__( 'Learn more ', 'elementskit-lite' ),
63 'dynamic' => [
64 'active' => true,
65 ],
66 ]
67 );
68
69
70 $this->add_control(
71 'ekit_btn_url',
72 [
73 'label' =>esc_html__( 'URL', 'elementskit-lite' ),
74 'type' => Controls_Manager::URL,
75 'placeholder' =>esc_url('https://wpmet.com'),
76 'dynamic' => [
77 'active' => true,
78 ],
79 'default' => [
80 'url' => '#',
81 ],
82 ]
83 );
84
85 $this->add_control(
86 'ekit_btn_section_settings',
87 [
88 'label' => esc_html__( 'Settings', 'elementskit-lite' ),
89 'type' => Controls_Manager::HEADING,
90 'separator' => 'before',
91 ]
92 );
93
94 $this->add_control(
95 'ekit_btn_icons__switch',
96 [
97 'label' => esc_html__('Add icon? ', 'elementskit-lite'),
98 'type' => Controls_Manager::SWITCHER,
99 'default' => 'yes',
100 'label_on' =>esc_html__( 'Yes', 'elementskit-lite' ),
101 'label_off' =>esc_html__( 'No', 'elementskit-lite' ),
102 ]
103 );
104
105 $this->add_control(
106 'ekit_btn_icons',
107 [
108 'label' =>esc_html__( 'Icon', 'elementskit-lite' ),
109 'type' => Controls_Manager::ICONS,
110 'fa4compatibility' => 'ekit_btn_icon',
111 'label_block' => true,
112 'default' => [
113 'value' => '',
114 ],
115 'condition' => [
116 'ekit_btn_icons__switch' => 'yes'
117 ]
118 ]
119 );
120 $this->add_control(
121 'ekit_btn_icon_align',
122 [
123 'label' =>esc_html__( 'Icon Position', 'elementskit-lite' ),
124 'type' => Controls_Manager::SELECT,
125 'default' => 'left',
126 'options' => [
127 'left' =>esc_html__( 'Before', 'elementskit-lite' ),
128 'right' =>esc_html__( 'After', 'elementskit-lite' ),
129 ],
130 'condition' => [
131 'ekit_btn_icons__switch' => 'yes'
132 ]
133 ]
134 );
135 $this->add_responsive_control(
136 'ekit_btn_align',
137 [
138 'label' =>esc_html__( 'Alignment', 'elementskit-lite' ),
139 'type' => Controls_Manager::CHOOSE,
140 'default' => 'center',
141 'options' => [
142 'left' => [
143 'title' =>esc_html__( 'Left', 'elementskit-lite' ),
144 'icon' => 'eicon-text-align-left',
145 ],
146 'center' => [
147 'title' =>esc_html__( 'Center', 'elementskit-lite' ),
148 'icon' => 'eicon-text-align-center',
149 ],
150 'right' => [
151 'title' =>esc_html__( 'Right', 'elementskit-lite' ),
152 'icon' => 'eicon-text-align-right',
153 ],
154 ],
155 'selectors_dictionary' => [
156 'left' => 'justify-content: flex-start;',
157 'center' => 'justify-content: center;',
158 'right' => 'justify-content: flex-end;',
159 ],
160 'prefix_class' => 'elementor-align-%s',
161 'selectors' => [
162 '{{WRAPPER}} .ekit-btn-wraper .elementskit-btn' => '{{VALUE}};',
163 ],
164 ]
165 );
166 $this->add_control(
167 'ekit_btn_class',
168 [
169 'label' => esc_html__( 'Class', 'elementskit-lite' ),
170 'type' => Controls_Manager::TEXT,
171 'dynamic' => [
172 'active' => true,
173 ],
174 'placeholder' => esc_html__( 'Class Name', 'elementskit-lite' ),
175 ]
176 );
177
178 $this->add_control(
179 'ekit_btn_id',
180 [
181 'label' => esc_html__( 'id', 'elementskit-lite' ),
182 'type' => Controls_Manager::TEXT,
183 'dynamic' => [
184 'active' => true,
185 ],
186 'placeholder' => esc_html__( 'ID', 'elementskit-lite' ),
187 ]
188 );
189
190
191 $this->end_controls_section();
192
193
194 $this->start_controls_section(
195 'ekit_btn_section_style',
196 [
197 'label' =>esc_html__( 'Button', 'elementskit-lite' ),
198 'tab' => Controls_Manager::TAB_STYLE,
199 ]
200 );
201
202 $this->add_responsive_control(
203 'width',
204 [
205 'label' => esc_html__( 'Width (%)', 'elementskit-lite' ),
206 'type' => Controls_Manager::SLIDER,
207 'selectors' => [
208 '{{WRAPPER}} .elementskit-btn' => 'width: {{SIZE}}%;',
209 ]
210 ]
211 );
212
213 $this->add_responsive_control(
214 'ekit_btn_text_padding',
215 [
216 'label' =>esc_html__( 'Padding', 'elementskit-lite' ),
217 'type' => Controls_Manager::DIMENSIONS,
218 'size_units' => [ 'px', 'em', '%' ],
219 'selectors' => [
220 '{{WRAPPER}} .elementskit-btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
221 ],
222 ]
223 );
224
225 $this->add_group_control(
226 Group_Control_Typography::get_type(),
227 [
228 'name' => 'ekit_btn_typography',
229 'label' =>esc_html__( 'Typography', 'elementskit-lite' ),
230 'selector' => '{{WRAPPER}} .elementskit-btn',
231 ]
232 );
233
234 $this->add_group_control(
235 Group_Control_Text_Shadow::get_type(),
236 [
237 'name' => 'ekit_btn_shadow',
238 'selector' => '{{WRAPPER}} .elementskit-btn',
239 ]
240 );
241
242 $this->start_controls_tabs( 'ekit_btn_tabs_style' );
243
244 $this->start_controls_tab(
245 'ekit_btn_tabnormal',
246 [
247 'label' =>esc_html__( 'Normal', 'elementskit-lite' ),
248 ]
249 );
250
251 $this->add_control(
252 'ekit_btn_text_color',
253 [
254 'label' =>esc_html__( 'Text Color', 'elementskit-lite' ),
255 'type' => Controls_Manager::COLOR,
256 'default' => '',
257 'selectors' => [
258 '{{WRAPPER}} .elementskit-btn' => 'color: {{VALUE}}; fill: {{VALUE}};',
259 ],
260 ]
261 );
262
263 $this->add_group_control(
264 Group_Control_Background::get_type(),
265 array(
266 'name' => 'ekit_btn_bg_color',
267 'selector' => '{{WRAPPER}} .elementskit-btn',
268 )
269 );
270
271 $this->end_controls_tab();
272
273 $this->start_controls_tab(
274 'ekit_btn_tab_button_hover',
275 [
276 'label' =>esc_html__( 'Hover', 'elementskit-lite' ),
277 ]
278 );
279
280 $this->add_control(
281 'ekit_btn_hover_color',
282 [
283 'label' =>esc_html__( 'Text Color', 'elementskit-lite' ),
284 'type' => Controls_Manager::COLOR,
285 'default' => '#ffffff',
286 'selectors' => [
287 '{{WRAPPER}} .elementskit-btn:hover' => 'color: {{VALUE}}; fill: {{VALUE}};',
288 ],
289 ]
290 );
291
292 $this->add_group_control(
293 Group_Control_Background::get_type(),
294 array(
295 'name' => 'ekit_btn_bg_hover_color',
296 'selector' => '{{WRAPPER}} .elementskit-btn:hover',
297 )
298 );
299
300 $this->end_controls_tab();
301 $this->end_controls_tabs();
302 $this->end_controls_section();
303
304 $this->start_controls_section(
305 'ekit_btn_border_style_tabs',
306 [
307 'label' =>esc_html__( 'Border', 'elementskit-lite' ),
308 'tab' => Controls_Manager::TAB_STYLE,
309 ]
310 );
311
312 $this->add_responsive_control(
313 'ekit_btn_border_style',
314 [
315 'label' => esc_html_x( 'Border Type', 'Border Control', 'elementskit-lite' ),
316 'type' => Controls_Manager::SELECT,
317 'options' => [
318 'none' => esc_html__( 'None', 'elementskit-lite' ),
319 'solid' => esc_html_x( 'Solid', 'Border Control', 'elementskit-lite' ),
320 'double' => esc_html_x( 'Double', 'Border Control', 'elementskit-lite' ),
321 'dotted' => esc_html_x( 'Dotted', 'Border Control', 'elementskit-lite' ),
322 'dashed' => esc_html_x( 'Dashed', 'Border Control', 'elementskit-lite' ),
323 'groove' => esc_html_x( 'Groove', 'Border Control', 'elementskit-lite' ),
324 ],
325 'default' => 'none',
326 'selectors' => [
327 '{{WRAPPER}} .elementskit-btn' => 'border-style: {{VALUE}};',
328 ],
329 ]
330 );
331 $this->add_responsive_control(
332 'ekit_btn_border_dimensions',
333 [
334 'label' => esc_html_x( 'Width', 'Border Control', 'elementskit-lite' ),
335 'type' => Controls_Manager::DIMENSIONS,
336 'condition' => [
337 'ekit_btn_border_style!' => 'none'
338 ],
339 'selectors' => [
340 '{{WRAPPER}} .elementskit-btn' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
341 ],
342 ]
343 );
344 $this->start_controls_tabs( 'xs_tabs_button_border_style' );
345 $this->start_controls_tab(
346 'ekit_btn_tab_border_normal',
347 [
348 'label' =>esc_html__( 'Normal', 'elementskit-lite' ),
349 ]
350 );
351
352 $this->add_control(
353 'ekit_btn_border_color',
354 [
355 'label' => esc_html_x( 'Color', 'Border Control', 'elementskit-lite' ),
356 'type' => Controls_Manager::COLOR,
357 'default' => '',
358 'selectors' => [
359 '{{WRAPPER}} .elementskit-btn' => 'border-color: {{VALUE}};',
360 ],
361 ]
362 );
363 $this->add_responsive_control(
364 'ekit_btn_border_radius',
365 [
366 'label' =>esc_html__( 'Border Radius', 'elementskit-lite' ),
367 'type' => Controls_Manager::DIMENSIONS,
368 'size_units' => [ 'px', '%'],
369 'default' => [
370 'top' => '',
371 'right' => '',
372 'bottom' => '' ,
373 'left' => '',
374 ],
375 'selectors' => [
376 '{{WRAPPER}} .elementskit-btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
377 ],
378 ]
379 );
380 $this->end_controls_tab();
381
382 $this->start_controls_tab(
383 'ekit_btn_tab_button_border_hover',
384 [
385 'label' =>esc_html__( 'Hover', 'elementskit-lite' ),
386 ]
387 );
388 $this->add_control(
389 'ekit_btn_hover_border_color',
390 [
391 'label' => esc_html_x( 'Color', 'Border Control', 'elementskit-lite' ),
392 'type' => Controls_Manager::COLOR,
393 'default' => '',
394 'selectors' => [
395 '{{WRAPPER}} .elementskit-btn:hover' => 'border-color: {{VALUE}};',
396 ],
397 ]
398 );
399 $this->add_responsive_control(
400 'ekit_btn_border_radius_h',
401 [
402 'label' =>esc_html__( 'Border Radius', 'elementskit-lite' ),
403 'type' => Controls_Manager::DIMENSIONS,
404 'size_units' => [ 'px', '%'],
405 'selectors' => [
406 '{{WRAPPER}} .elementskit-btn:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
407 ],
408 ]
409 );
410 $this->end_controls_tab();
411 $this->end_controls_tabs();
412 $this->end_controls_section();
413
414 $this->start_controls_section(
415 'ekit_btn_box_shadow_style',
416 [
417 'label' =>esc_html__( 'Shadow', 'elementskit-lite' ),
418 'tab' => Controls_Manager::TAB_STYLE,
419 ]
420 );
421 $this->add_group_control(
422 Group_Control_Box_Shadow::get_type(),
423 [
424 'name' => 'ekit_btn_box_shadow_group',
425 'selector' => '{{WRAPPER}} .elementskit-btn',
426 ]
427 );
428 $this->add_group_control(
429 Group_Control_Box_Shadow::get_type(),
430 [
431 'name' => 'ekit_btn_hover_box_shadow_group',
432 'label' => esc_html__( 'Hover Box Shadow', 'elementskit-lite' ),
433 'selector' => '{{WRAPPER}} .elementskit-btn:hover',
434 ]
435 );
436
437
438 $this->end_controls_section();
439
440 $this->start_controls_section(
441 'ekit_btn_iconw_style',
442 [
443 'label' =>esc_html__( 'Icon', 'elementskit-lite' ),
444 'tab' => Controls_Manager::TAB_STYLE,
445 'condition' => [
446 'ekit_btn_icons__switch' => 'yes'
447 ]
448 ]
449 );
450 $this->add_responsive_control(
451 'ekit_btn_normal_icon_font_size',
452 array(
453 'label' => esc_html__( 'Font Size', 'elementskit-lite' ),
454 'type' => Controls_Manager::SLIDER,
455 'size_units' => array(
456 'px', 'em', 'rem',
457 ),
458 'range' => array(
459 'px' => array(
460 'min' => 1,
461 'max' => 100,
462 ),
463 ),
464 'default' => [
465 'unit' => 'px',
466 'size' => 14,
467 ],
468 'selectors' => array(
469 '{{WRAPPER}} .elementskit-btn > :is(i, svg)' => 'font-size: {{SIZE}}{{UNIT}};',
470 ),
471 )
472 );
473 $this->add_responsive_control(
474 'ekit_btn_normal_icon_padding_left',
475 [
476 'label' => esc_html__( 'Add space after icon', 'elementskit-lite' ),
477 'type' => Controls_Manager::SLIDER,
478 'size_units' => [ 'px' ],
479 'range' => [
480 'px' => [
481 'min' => 0,
482 'max' => 100,
483 'step' => 1,
484 ],
485 ],
486 'default' => [
487 'unit' => 'px',
488 'size' => 5,
489 ],
490 'selectors' => [
491 '{{WRAPPER}} .elementskit-btn > i, {{WRAPPER}} .elementskit-btn > svg' => 'margin-right: {{SIZE}}{{UNIT}};',
492 '.rtl {{WRAPPER}} .elementskit-btn > i, .rtl {{WRAPPER}} .elementskit-btn > svg' => 'margin-left: {{SIZE}}{{UNIT}}; margin-right: 0;',
493 ],
494 'condition' => [
495 'ekit_btn_icon_align' => 'left'
496 ]
497 ]
498 );
499 $this->add_responsive_control(
500 'ekit_btn_normal_icon_padding_right',
501 [
502 'label' => esc_html__( 'Add space before icon', 'elementskit-lite' ),
503 'type' => Controls_Manager::SLIDER,
504 'size_units' => [ 'px' ],
505 'range' => [
506 'px' => [
507 'min' => 0,
508 'max' => 100,
509 'step' =>1,
510 ],
511 ],
512 'default' => [
513 'unit' => 'px',
514 'size' => 5,
515 ],
516 'selectors' => [
517 '{{WRAPPER}} .elementskit-btn > i, {{WRAPPER}} .elementskit-btn > svg' => 'margin-left: {{SIZE}}{{UNIT}};',
518 '.rtl {{WRAPPER}} .elementskit-btn > i, .rtl {{WRAPPER}} .elementskit-btn > svg' => 'margin-left: 0; margin-right: {{SIZE}}{{UNIT}};',
519 ],
520 'condition' => [
521 'ekit_btn_icon_align' => 'right'
522 ]
523 ]
524 );
525
526 $this->add_responsive_control(
527 'ekit_btn_normal_icon_vertical_align',
528 array(
529 'label' => esc_html__( 'Move icon Vertically', 'elementskit-lite' ),
530 'type' => Controls_Manager::SLIDER,
531 'size_units' => array(
532 'px', 'em', 'rem',
533 ),
534 'range' => array(
535 'px' => array(
536 'min' => -20,
537 'max' => 20,
538 ),
539 'em' => array(
540 'min' => -5,
541 'max' => 5,
542 ),
543 'rem' => array(
544 'min' => -5,
545 'max' => 5,
546 ),
547 ),
548 'selectors' => array(
549 '{{WRAPPER}} .elementskit-btn i, {{WRAPPER}} .elementskit-btn svg' => ' -webkit-transform: translateY({{SIZE}}{{UNIT}}); -ms-transform: translateY({{SIZE}}{{UNIT}}); transform: translateY({{SIZE}}{{UNIT}})',
550 ),
551 )
552 );
553
554 $this->end_controls_section();
555
556 $this->insert_pro_message();
557 }
558
559 protected function render( ) {
560 echo '<div class="ekit-wid-con" >';
561 $this->render_raw();
562 echo '</div>';
563 }
564
565 protected function render_raw( ) {
566 $settings = $this->get_settings_for_display();
567
568 $btn_text = $settings['ekit_btn_text'];
569 $btn_class = ($settings['ekit_btn_class'] != '') ? $settings['ekit_btn_class'] : '';
570 $btn_id = ($settings['ekit_btn_id'] != '') ? $settings['ekit_btn_id'] : '';
571
572 $options_ekit_btn_icon_align = array_keys([
573 'left' => esc_html__( 'Before', 'elementskit-lite' ),
574 'right' => esc_html__( 'After', 'elementskit-lite' ),
575 ]);
576
577 $icon_align = \ElementsKit_Lite\Utils::esc_options($settings['ekit_btn_icon_align'], $options_ekit_btn_icon_align, 'left');
578
579 if ( ! empty( $settings['ekit_btn_url']['url'] ) ) {
580 $this->add_link_attributes( 'button', $settings['ekit_btn_url'] );
581 }
582
583 // Reset Whitespace for this specific widget
584 $btn_class .= ' whitespace--normal';
585
586 $this->add_render_attribute('button', [
587 'class' => 'elementskit-btn ' . $btn_class,
588 'id' => $btn_id
589 ]);
590 ?>
591 <div class="ekit-btn-wraper">
592 <?php if($icon_align == 'right'): ?>
593 <a <?php $this->print_render_attribute_string( 'button' ); ?>>
594 <?php
595 echo esc_html( $btn_text );
596 Icons_Manager::render_icon($settings['ekit_btn_icons']);
597 ?>
598 </a>
599 <?php elseif ($icon_align == 'left') : ?>
600 <a <?php $this->print_render_attribute_string( 'button' ); ?>>
601 <?php
602 Icons_Manager::render_icon($settings['ekit_btn_icons']);
603 echo esc_html( $btn_text );
604 ?>
605 </a>
606 <?php else : ?>
607 <a <?php $this->print_render_attribute_string( 'button' ); ?>>
608 <?php echo esc_html( $btn_text ); ?>
609 </a>
610 <?php endif; ?>
611 </div>
612 <?php
613 }
614 }
615