PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.65
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.65
51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Search / Search.php

Search.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.65, at includes/widgets/Search/Search.php

2,092 lines 71.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace King_Addons;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Icons_Manager;
7 use Elementor\Widget_Base;
8 use Elementor\Group_Control_Typography;
9 use Elementor\Group_Control_Box_Shadow;
10
11 if (!defined('ABSPATH')) {
12 exit; // Exit if accessed directly.
13 }
14
15
16
17 class Search extends Widget_Base
18 {
19
20
21 public function get_name(): string
22 {
23 return 'king-addons-search';
24 }
25
26 public function get_title(): string
27 {
28 return esc_html__('Search (AJAX, live results, filters)', 'king-addons');
29 }
30
31 public function get_icon(): string
32 {
33 return 'king-addons-icon king-addons-search';
34 }
35
36 public function get_script_depends(): array
37 {
38 return [KING_ADDONS_ASSETS_UNIQUE_KEY . '-search-script'];
39 }
40
41 public function get_style_depends(): array
42 {
43 return [
44 KING_ADDONS_ASSETS_UNIQUE_KEY . '-search-style',
45 KING_ADDONS_ASSETS_UNIQUE_KEY . '-general-general',
46 ];
47 }
48
49 public function get_categories(): array
50 {
51 return ['king-addons'];
52 }
53
54 public function get_keywords(): array
55 {
56 return ['search', 'search bar', 'bar', 'field', 'site', 'ajax', 'live', 'ajax search', 'live search', 'results',
57 'king addons', 'king', 'addons', 'kingaddons', 'king-addons'];
58 }
59
60 public function get_custom_help_url()
61 {
62 return 'mailto:bug@kingaddons.com?subject=Bug Report - King Addons&body=Please describe the issue';
63 }
64
65 public function add_section_style_ajax(): void
66 {
67 $this->start_controls_section(
68 'section_style_ajax',
69 [
70 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Ajax (live results)', 'king-addons'),
71 'tab' => Controls_Manager::TAB_STYLE,
72 'condition' => [
73 'ajax_search' => 'yes',
74 ],
75 ]
76 );
77
78 $this->add_control(
79 'heading_list',
80 [
81 'label' => esc_html__('Search List', 'king-addons'),
82 'type' => Controls_Manager::HEADING,
83 ]
84 );
85
86 $this->add_control(
87 'background_color',
88 [
89 'label' => esc_html__('Background Color', 'king-addons'),
90 'type' => Controls_Manager::COLOR,
91 'default' => '#FFFFFF',
92 'selectors' => [
93 '{{WRAPPER}} .king-addons-data-fetch' => 'background-color: {{VALUE}};',
94 ],
95 ]
96 );
97
98 $this->add_control(
99 'background_color_hover',
100 [
101 'label' => esc_html__('Background Color (Hover)', 'king-addons'),
102 'type' => Controls_Manager::COLOR,
103 'default' => '#F6F6F6',
104 'selectors' => [
105 '{{WRAPPER}} .king-addons-data-fetch ul li:hover' => 'background-color: {{VALUE}};',
106 ],
107 ]
108 );
109
110 $this->add_group_control(
111 Group_Control_Box_Shadow::get_type(),
112 [
113 'name' => 'ajax_box_shadow',
114 'selector' => '{{WRAPPER}} .king-addons-data-fetch'
115 ]
116 );
117
118 $this->add_control(
119 'search_list_item_transition_duration',
120 [
121 'label' => esc_html__('Transition Duration (ms)', 'king-addons'),
122 'type' => Controls_Manager::NUMBER,
123 'default' => 500,
124 'min' => 0,
125 'step' => 50,
126 'selectors' => [
127 '{{WRAPPER}} .king-addons-data-fetch ul li' => 'transition-duration: {{VALUE}}ms',
128 ],
129 ]
130 );
131
132 $this->add_responsive_control(
133 'slider_content_hr',
134 [
135 'label' => esc_html__('Horizontal Position', 'king-addons'),
136 'type' => Controls_Manager::CHOOSE,
137 'label_block' => false,
138 'options' => [
139 'left' => [
140 'title' => esc_html__('Left', 'king-addons'),
141 'icon' => 'eicon-h-align-left',
142 ],
143 'center' => [
144 'title' => esc_html__('Center', 'king-addons'),
145 'icon' => 'eicon-h-align-center',
146 ],
147 'right' => [
148 'title' => esc_html__('Right', 'king-addons'),
149 'icon' => 'eicon-h-align-right',
150 ]
151 ],
152 'selectors_dictionary' => [
153 'left' => 'left: 0; right: auto;',
154 'center' => 'left: 50%; transform: translateX(-50%)',
155 'right' => 'right: 0; left: auto;'
156 ],
157 'selectors' => [
158 '{{WRAPPER}} .king-addons-data-fetch' => '{{VALUE}};',
159 ],
160 'separator' => 'before'
161 ]
162 );
163
164 $this->add_responsive_control(
165 'search_list_width',
166 [
167 'label' => esc_html__('Container Width', 'king-addons'),
168 'type' => Controls_Manager::SLIDER,
169 'size_units' => ['px', '%', 'vw'],
170 'range' => [
171 'px' => [
172 'min' => 0,
173 'max' => 2000,
174 ],
175 '%' => [
176 'min' => 50,
177 'max' => 200,
178 ],
179 'vw' => [
180 'min' => 0,
181 'max' => 100,
182 ],
183 ],
184 'default' => [
185 'unit' => '%',
186 'size' => 100,
187 ],
188 'selectors' => [
189 '{{WRAPPER}} .king-addons-data-fetch' => 'width: {{SIZE}}{{UNIT}};',
190 ],
191 'separator' => 'before'
192 ]
193 );
194
195 $this->add_responsive_control(
196 'search_list_max_height',
197 [
198 'label' => esc_html__('Max Height', 'king-addons'),
199 'type' => Controls_Manager::SLIDER,
200 'size_units' => ['px', 'vh'],
201 'range' => [
202 'px' => [
203 'min' => 0,
204 'max' => 1000,
205 ],
206 'vh' => [
207 'min' => 0,
208 'max' => 100,
209 ],
210 ],
211 'default' => [
212 'unit' => 'px',
213 'size' => 350,
214 ],
215 'selectors' => [
216 '{{WRAPPER}} .king-addons-data-fetch ul' => 'max-height: {{SIZE}}{{UNIT}};',
217 ],
218 'separator' => 'before'
219 ]
220 );
221
222 $this->add_responsive_control(
223 'search_list_top_distance',
224 [
225 'label' => esc_html__('Top Distance', 'king-addons'),
226 'type' => Controls_Manager::SLIDER,
227 'size_units' => ['px', 'vh'],
228 'range' => [
229 'px' => [
230 'min' => 0,
231 'max' => 50,
232 ],
233 'vh' => [
234 'min' => 0,
235 'max' => 10,
236 ],
237 ],
238 'default' => [
239 'unit' => 'px',
240 'size' => 5,
241 ],
242 'selectors' => [
243 '{{WRAPPER}} .king-addons-data-fetch' => 'margin-top: {{SIZE}}{{UNIT}};',
244 ]
245 ]
246 );
247
248 $this->add_control(
249 'list_item_title',
250 [
251 'label' => esc_html__('List Item', 'king-addons'),
252 'type' => Controls_Manager::HEADING,
253 'separator' => 'before'
254 ]
255 );
256
257 $this->add_responsive_control(
258 'search_list_item_bottom_distance',
259 [
260 'label' => esc_html__('Bottom Distance', 'king-addons'),
261 'type' => Controls_Manager::SLIDER,
262 'size_units' => ['px', 'vh'],
263 'range' => [
264 'px' => [
265 'min' => 0,
266 'max' => 50,
267 ],
268 'vh' => [
269 'min' => 0,
270 'max' => 10,
271 ],
272 ],
273 'default' => [
274 'unit' => 'px',
275 'size' => 5,
276 ],
277 'selectors' => [
278 '{{WRAPPER}} .king-addons-data-fetch ul li:not(:last-child)' => 'margin-bottom: {{SIZE}}{{UNIT}};',
279 ]
280 ]
281 );
282
283 $this->add_responsive_control(
284 'search_list_item_padding',
285 [
286 'label' => esc_html__('Padding', 'king-addons'),
287 'type' => Controls_Manager::DIMENSIONS,
288 'default' => [
289 'top' => 2,
290 'right' => 2,
291 'bottom' => 2,
292 'left' => 2,
293 ],
294 'size_units' => ['px'],
295 'selectors' => [
296 '{{WRAPPER}} .king-addons-data-fetch ul li' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
297 ]
298 ]
299 );
300
301 $this->add_control(
302 'heading_title',
303 [
304 'label' => esc_html__('Title', 'king-addons'),
305 'type' => Controls_Manager::HEADING,
306 'separator' => 'before'
307 ]
308 );
309
310 $this->add_control(
311 'title_color',
312 [
313 'label' => esc_html__('Color', 'king-addons'),
314 'type' => Controls_Manager::COLOR,
315 'default' => '#222222',
316 'selectors' => [
317 '{{WRAPPER}} .king-addons-data-fetch a.king-addons-ajax-title' => 'color: {{VALUE}};',
318 ],
319 ]
320 );
321
322 $this->add_group_control(
323 Group_Control_Typography::get_type(),
324 [
325 'name' => 'title_typography',
326 'selector' => '{{WRAPPER}} .king-addons-data-fetch a.king-addons-ajax-title',
327 ]
328 );
329
330 $this->add_responsive_control(
331 'title_distance',
332 [
333 'label' => esc_html__('Distance', 'king-addons'),
334 'type' => Controls_Manager::SLIDER,
335 'size_units' => ['px'],
336 'range' => [
337 'px' => [
338 'min' => 0,
339 'max' => 50,
340 ]
341 ],
342 'default' => [
343 'unit' => 'px',
344 'size' => 2,
345 ],
346 'selectors' => [
347 '{{WRAPPER}} .king-addons-ajax-search-content a.king-addons-ajax-title' => 'margin-bottom: {{SIZE}}{{UNIT}};',
348 ]
349 ]
350 );
351
352 $this->add_control(
353 'heading_description',
354 [
355 'label' => esc_html__('Description', 'king-addons'),
356 'type' => Controls_Manager::HEADING,
357 'separator' => 'before'
358 ]
359 );
360
361 $this->add_control(
362 'description_color',
363 [
364 'label' => esc_html__('Color', 'king-addons'),
365 'type' => Controls_Manager::COLOR,
366 'default' => '#757575',
367 'selectors' => [
368 '{{WRAPPER}} .king-addons-data-fetch p a' => 'color: {{VALUE}};',
369 '{{WRAPPER}} .king-addons-search-admin-notice' => 'color: {{VALUE}};'
370 ],
371 ]
372 );
373
374 $this->add_group_control(
375 Group_Control_Typography::get_type(),
376 [
377 'name' => 'description_typography',
378 'selector' => '{{WRAPPER}} .king-addons-data-fetch p a, {{WRAPPER}} .king-addons-search-admin-notice',
379 'fields_options' => [
380 'typography' => [
381 'default' => 'custom',
382 ],
383 'font_size' => [
384 'default' => [
385 'size' => '14',
386 'unit' => 'px',
387 ],
388 ]
389 ],
390 ]
391 );
392
393 $this->add_responsive_control(
394 'description_distance',
395 [
396 'label' => esc_html__('Distance', 'king-addons'),
397 'type' => Controls_Manager::SLIDER,
398 'size_units' => ['px'],
399 'range' => [
400 'px' => [
401 'min' => 0,
402 'max' => 50,
403 ]
404 ],
405 'default' => [
406 'unit' => 'px',
407 'size' => 2,
408 ],
409 'selectors' => [
410 '{{WRAPPER}} .king-addons-ajax-search-content p.king-addons-ajax-desc' => 'margin-bottom: {{SIZE}}{{UNIT}};',
411 ]
412 ]
413 );
414
415 $this->add_control(
416 'heading_image',
417 [
418 'label' => esc_html__('Image', 'king-addons'),
419 'type' => Controls_Manager::HEADING,
420 'separator' => 'before',
421 'condition' => [
422 'show_ajax_thumbnails' => 'yes'
423 ]
424 ]
425 );
426
427 $this->add_responsive_control(
428 'image_width',
429 [
430 'label' => esc_html__('Width', 'king-addons'),
431 'type' => Controls_Manager::SLIDER,
432 'size_units' => ['px', '%'],
433 'range' => [
434 'px' => [
435 'min' => 0,
436 'max' => 300,
437 ],
438 '%' => [
439 'min' => 0,
440 'max' => 100,
441 ],
442 ],
443 'default' => [
444 'unit' => 'px',
445 'size' => 150,
446 ],
447 'selectors' => [
448 '{{WRAPPER}} .king-addons-data-fetch a.king-addons-ajax-img-wrap' => 'width: {{SIZE}}{{UNIT}};',
449 '{{WRAPPER}} .king-addons-data-fetch .king-addons-ajax-search-content' => 'width: calc(100% - {{SIZE}}{{UNIT}});',
450 ],
451 'condition' => [
452 'show_ajax_thumbnails' => 'yes'
453 ]
454 ]
455 );
456
457 $this->add_responsive_control(
458 'image_distance',
459 [
460 'label' => esc_html__('Distance', 'king-addons'),
461 'type' => Controls_Manager::SLIDER,
462 'size_units' => ['px'],
463 'range' => [
464 'px' => [
465 'min' => 0,
466 'max' => 50,
467 ]
468 ],
469 'default' => [
470 'unit' => 'px',
471 'size' => 10,
472 ],
473 'selectors' => [
474 '{{WRAPPER}} .king-addons-data-fetch a.king-addons-ajax-img-wrap' => 'margin-right: {{SIZE}}{{UNIT}};',
475 ],
476 'condition' => [
477 'show_ajax_thumbnails' => 'yes'
478 ]
479 ]
480 );
481
482 $this->add_control(
483 'view_result_text_heading',
484 [
485 'label' => esc_html__('View Result', 'king-addons'),
486 'type' => Controls_Manager::HEADING,
487 'separator' => 'before'
488 ]
489 );
490
491 $this->add_control(
492 'view_result_text_color',
493 [
494 'label' => esc_html__('Color', 'king-addons'),
495 'type' => Controls_Manager::COLOR,
496 'default' => '#FFFFFF',
497 'selectors' => [
498 '{{WRAPPER}} a.king-addons-view-result' => 'color: {{VALUE}};',
499 ],
500 ]
501 );
502
503 $this->add_control(
504 'view_result_text_color_hr',
505 [
506 'label' => esc_html__('Color (Hover)', 'king-addons'),
507 'type' => Controls_Manager::COLOR,
508 'default' => '#FFFFFF',
509 'selectors' => [
510 '{{WRAPPER}} a.king-addons-view-result:hover' => 'color: {{VALUE}};',
511 ],
512 ]
513 );
514
515 $this->add_control(
516 'view_result_text_bg_color',
517 [
518 'label' => esc_html__('Background Color', 'king-addons'),
519 'type' => Controls_Manager::COLOR,
520 'default' => '#5B03FF',
521 'selectors' => [
522 '{{WRAPPER}} a.king-addons-view-result' => 'background-color: {{VALUE}};',
523 ],
524 ]
525 );
526
527 $this->add_control(
528 'view_result_text_bg_color_hr',
529 [
530 'label' => esc_html__('Background Color (Hover)', 'king-addons'),
531 'type' => Controls_Manager::COLOR,
532 'default' => '#5B03FF',
533 'selectors' => [
534 '{{WRAPPER}} a.king-addons-view-result:hover' => 'background-color: {{VALUE}};',
535 ],
536 ]
537 );
538
539 $this->add_group_control(
540 Group_Control_Typography::get_type(),
541 [
542 'name' => 'view_result_typography',
543 'selector' => '{{WRAPPER}} a.king-addons-view-result',
544 'fields_options' => [
545 'typography' => [
546 'default' => 'custom',
547 ],
548 'font_family' => [
549 'default' => 'Roboto',
550 ],
551 'font_size' => [
552 'default' => [
553 'size' => '14',
554 'unit' => 'px',
555 ]
556 ]
557 ]
558 ]
559 );
560
561 $this->add_control(
562 'view_result_transition_duration',
563 [
564 'label' => esc_html__('Transition Duration (ms)', 'king-addons'),
565 'type' => Controls_Manager::NUMBER,
566 'default' => 500,
567 'min' => 0,
568 'step' => 50,
569 'selectors' => [
570 '{{WRAPPER}} a.king-addons-view-result' => 'transition-duration: {{VALUE}}ms',
571 ],
572 ]
573 );
574
575 $this->add_control(
576 'view_result_border_radius',
577 [
578 'label' => esc_html__('Border Radius', 'king-addons'),
579 'type' => Controls_Manager::DIMENSIONS,
580 'default' => [
581 'top' => 2,
582 'right' => 2,
583 'bottom' => 2,
584 'left' => 2,
585 ],
586 'size_units' => ['px', '%'],
587 'selectors' => [
588 '{{WRAPPER}} a.king-addons-view-result' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
589 ]
590 ]
591 );
592
593 $this->add_responsive_control(
594 'view_result_padding',
595 [
596 'label' => esc_html__('Padding', 'king-addons'),
597 'type' => Controls_Manager::DIMENSIONS,
598 'default' => [
599 'top' => 5,
600 'right' => 10,
601 'bottom' => 5,
602 'left' => 10,
603 ],
604 'size_units' => ['px'],
605 'selectors' => [
606 '{{WRAPPER}} a.king-addons-view-result' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
607 ]
608 ]
609 );
610
611 $this->add_control(
612 'heading_close_btn',
613 [
614 'label' => esc_html__('Close Button', 'king-addons'),
615 'type' => Controls_Manager::HEADING,
616 'separator' => 'before'
617 ]
618 );
619
620 $this->add_control(
621 'close_btn_color',
622 [
623 'label' => esc_html__('Color', 'king-addons'),
624 'type' => Controls_Manager::COLOR,
625 'default' => '#E8E8E8',
626 'selectors' => [
627 '{{WRAPPER}} .king-addons-data-fetch .king-addons-close-search' => 'color: {{VALUE}};',
628 ],
629 ]
630 );
631
632 $this->add_responsive_control(
633 'close_btn_size',
634 [
635 'label' => esc_html__('Size', 'king-addons'),
636 'type' => Controls_Manager::SLIDER,
637 'size_units' => ['px'],
638 'range' => [
639 'px' => [
640 'min' => 0,
641 'max' => 50,
642 ]
643 ],
644 'default' => [
645 'unit' => 'px',
646 'size' => 14,
647 ],
648 'selectors' => [
649 '{{WRAPPER}} .king-addons-data-fetch .king-addons-close-search::before' => 'font-size: {{SIZE}}{{UNIT}};',
650 '{{WRAPPER}} .king-addons-data-fetch .king-addons-close-search' => 'height: {{SIZE}}{{UNIT}};',
651 ]
652 ]
653 );
654
655 $this->add_responsive_control(
656 'close_btn_position',
657 [
658 'label' => esc_html__('Distance', 'king-addons'),
659 'type' => Controls_Manager::SLIDER,
660 'size_units' => ['px'],
661 'range' => [
662 'px' => [
663 'min' => 0,
664 'max' => 50,
665 ]
666 ],
667 'default' => [
668 'unit' => 'px',
669 'size' => 10,
670 ],
671 'selectors' => [
672 '{{WRAPPER}} .king-addons-data-fetch .king-addons-close-search' => 'top: {{SIZE}}{{UNIT}}; right: {{SIZE}}{{UNIT}};',
673 ]
674 ]
675 );
676
677 $this->add_control(
678 'scrollbar_heading',
679 [
680 'label' => esc_html__('Scrollbar', 'king-addons'),
681 'type' => Controls_Manager::HEADING,
682 'separator' => 'before'
683 ]
684 );
685
686 $this->add_control(
687 'scrollbar_color',
688 [
689 'label' => esc_html__('Color', 'king-addons'),
690 'type' => Controls_Manager::COLOR,
691 'default' => '#E8E8E8',
692 'selectors' => [
693 '{{WRAPPER}} .king-addons-data-fetch ul::-webkit-scrollbar-thumb' => 'border-left-color: {{VALUE}};',
694 ],
695 ]
696 );
697
698 $this->add_responsive_control(
699 'scrollbar_width',
700 [
701 'label' => esc_html__('Width', 'king-addons'),
702 'type' => Controls_Manager::SLIDER,
703 'size_units' => ['px'],
704 'range' => [
705 'px' => [
706 'min' => 0,
707 'max' => 10,
708 ]
709 ],
710 'default' => [
711 'unit' => 'px',
712 'size' => 3,
713 ],
714 'selectors' => [
715 '{{WRAPPER}} .king-addons-data-fetch ul::-webkit-scrollbar-thumb' => 'border-left-width: {{SIZE}}{{UNIT}};',
716 '{{WRAPPER}} .king-addons-data-fetch ul::-webkit-scrollbar' => 'width: calc({{SIZE}}{{UNIT}} + 3px);',
717 ]
718 ]
719 );
720
721 $this->add_control(
722 'no_results_heading',
723 [
724 'label' => esc_html__('No Results', 'king-addons'),
725 'type' => Controls_Manager::HEADING,
726 'separator' => 'before'
727 ]
728 );
729
730 $this->add_control(
731 'no_results_color',
732 [
733 'label' => esc_html__('Color', 'king-addons'),
734 'type' => Controls_Manager::COLOR,
735 'default' => '#222222',
736 'selectors' => [
737 '{{WRAPPER}} .king-addons-data-fetch .king-addons-no-results' => 'color: {{VALUE}};',
738 ],
739 ]
740 );
741
742 $this->add_group_control(
743 Group_Control_Typography::get_type(),
744 [
745 'name' => 'no_results_typography',
746 'selector' => '{{WRAPPER}} .king-addons-data-fetch .king-addons-no-results',
747 ]
748 );
749
750 $this->add_responsive_control(
751 'no_results_height',
752 [
753 'label' => esc_html__('Height', 'king-addons'),
754 'type' => Controls_Manager::SLIDER,
755 'size_units' => ['px', 'vh'],
756 'range' => [
757 'px' => [
758 'min' => 0,
759 'max' => 1000,
760 ],
761 'vh' => [
762 'min' => 0,
763 'max' => 100,
764 ],
765 ],
766 'default' => [
767 'unit' => 'vh',
768 'size' => 20,
769 ],
770 'selectors' => [
771 '{{WRAPPER}} .king-addons-data-fetch .king-addons-no-results' => 'height: {{SIZE}}{{UNIT}};',
772 ]
773 ]
774 );
775
776 $this->add_control(
777 'search_results_box_border_size',
778 [
779 'label' => esc_html__('Border Size', 'king-addons'),
780 'type' => Controls_Manager::DIMENSIONS,
781 'default' => [
782 'top' => 1,
783 'right' => 1,
784 'bottom' => 1,
785 'left' => 1,
786 ],
787 'size_units' => ['px'],
788 'selectors' => [
789 '{{WRAPPER}} .king-addons-data-fetch' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
790 ],
791 'separator' => 'before',
792 ]
793 );
794
795 $this->add_control(
796 'search_results_box_border_radius',
797 [
798 'label' => esc_html__('Border Radius', 'king-addons'),
799 'type' => Controls_Manager::DIMENSIONS,
800 'default' => [
801 'top' => 2,
802 'right' => 2,
803 'bottom' => 2,
804 'left' => 2,
805 ],
806 'size_units' => ['px', '%'],
807 'selectors' => [
808 '{{WRAPPER}} .king-addons-data-fetch' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
809 ],
810 'separator' => 'after',
811 ]
812 );
813
814 $this->add_responsive_control(
815 'search_results_box_padding',
816 [
817 'label' => esc_html__('Padding', 'king-addons'),
818 'type' => Controls_Manager::DIMENSIONS,
819 'default' => [
820 'top' => 2,
821 'right' => 2,
822 'bottom' => 2,
823 'left' => 2,
824 ],
825 'size_units' => ['px'],
826 'selectors' => [
827 '{{WRAPPER}} .king-addons-data-fetch ul' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
828 ],
829 'separator' => 'before'
830 ]
831 );
832
833
834
835
836 $this->end_controls_section();
837
838
839 }
840
841 public function add_section_ajax_pagination()
842 {
843 }
844
845 public function add_section_style_ajax_pagination()
846 {
847 }
848
849 public function add_control_search_query(): void
850 {
851 $search_post_type = array_merge(['all' => esc_html__('All', 'king-addons')], Core::getCustomTypes('post', false));
852
853 foreach ($search_post_type as $key => $value) {
854 if ('all' != $key) {
855 $search_post_type['pro-' . $key] = $value . ' (Pro)';
856
857 if ('post' != $key && 'page' != $key && 'product' != $key && 'e-landing-page' != $key && !king_addons_freemius()->can_use_premium_code__premium_only()) {
858 $search_post_type['pro-' . $key] = $value . ' (Pro)';
859 }
860
861 unset($search_post_type[$key]);
862 }
863 }
864
865 $this->add_control(
866 'search_query',
867 [
868 'label' => esc_html__('Select Query', 'king-addons'),
869 'type' => Controls_Manager::SELECT,
870 'label_block' => false,
871 'options' => $search_post_type,
872 'default' => 'all',
873 ]
874 );
875 }
876
877 public function add_control_select_category(): void
878 {
879 $this->add_control(
880 'select_category',
881 [
882 'label' => esc_html__('Category Filter', 'king-addons') . ' <i class="eicon-pro-icon"></i>',
883 'type' => Controls_Manager::SWITCHER,
884 'separator' => 'before',
885 'classes' => 'king-addons-pro-control',
886 ]
887 );
888 }
889
890 public function add_control_all_cat_text()
891 {
892 }
893
894 public function add_control_ajax_search(): void
895 {
896 $this->add_control(
897 'ajax_search',
898 [
899 'label' => esc_html__('Enable Ajax Search (live results)', 'king-addons'),
900 'type' => Controls_Manager::SWITCHER,
901 'separator' => 'before'
902 ]
903 );
904 }
905
906 public function add_control_number_of_results()
907 {
908 }
909
910 public function add_control_show_password_protected(): void
911 {
912 if (current_user_can('administrator')) {
913 $this->add_control(
914 'ajax_show_ps_pt',
915 [
916 'label' => esc_html__('Show Password Protected', 'king-addons'),
917 'type' => Controls_Manager::SWITCHER,
918 'description' => esc_html__('Only for users with capability to read private posts', 'king-addons'),
919 'condition' => [
920 'ajax_search' => 'yes'
921 ],
922 'render_type' => 'template',
923 ]
924 );
925 }
926 }
927
928 public function add_control_open_in_new_page(): void
929 {
930 $this->add_control(
931 'ajax_search_link_target',
932 [
933 'label' => esc_html__('Open Link in New Tab', 'king-addons'),
934 'type' => Controls_Manager::SWITCHER,
935 'condition' => [
936 'ajax_search' => 'yes'
937 ]
938 ]
939 );
940 }
941
942 public function add_control_show_ajax_thumbnails(): void
943 {
944 $this->add_control(
945 'show_ajax_thumbnails',
946 [
947 'label' => esc_html__('Show Ajax Thumbnails', 'king-addons'),
948 'type' => Controls_Manager::SWITCHER,
949 'render_type' => 'template',
950 'condition' => [
951 'ajax_search' => 'yes'
952 ]
953 ]
954 );
955 }
956
957 public function add_control_exclude_posts_without_thumbnail(): void
958 {
959 $this->add_control(
960 'exclude_posts_without_thumbnail',
961 [
962 'label' => esc_html__('Exclude Results without Thumbnails', 'king-addons'),
963 'type' => Controls_Manager::SWITCHER,
964 'render_type' => 'template',
965 'condition' => [
966 'ajax_search' => 'yes',
967 'show_ajax_thumbnails' => 'yes'
968 ]
969 ]
970 );
971 }
972
973 public function add_control_show_description(): void
974 {
975 $this->add_control(
976 'show_description',
977 [
978 'label' => esc_html__('Show Description', 'king-addons'),
979 'type' => Controls_Manager::SWITCHER,
980 'default' => 'yes',
981 'render_type' => 'template',
982 'condition' => [
983 'ajax_search' => 'yes'
984 ]
985 ]
986 );
987 }
988
989 public function add_control_number_of_words_in_excerpt(): void
990 {
991 $this->add_control(
992 'number_of_words_in_excerpt',
993 [
994 'label' => esc_html__('Description Number of Words', 'king-addons'),
995 'type' => Controls_Manager::NUMBER,
996 'min' => 5,
997 'step' => 1,
998 'default' => 30,
999 'render_type' => 'template',
1000 'condition' => [
1001 'ajax_search' => 'yes',
1002 'show_description' => 'yes'
1003 ]
1004 ]
1005 );
1006 }
1007
1008 public function add_control_show_view_result_btn(): void
1009 {
1010 $this->add_control(
1011 'show_view_result_btn',
1012 [
1013 'label' => esc_html__('Show View Results Button', 'king-addons'),
1014 'type' => Controls_Manager::SWITCHER,
1015 'render_type' => 'template',
1016 'condition' => [
1017 'ajax_search' => 'yes'
1018 ]
1019 ]
1020 );
1021 }
1022
1023 public function add_control_view_result_text(): void
1024 {
1025 $this->add_control(
1026 'view_result_text',
1027 [
1028 'label' => esc_html__('View Results', 'king-addons'),
1029 'type' => Controls_Manager::TEXT,
1030 'dynamic' => [
1031 'active' => true,
1032 ],
1033 'default' => esc_html__('View Results', 'king-addons'),
1034 'condition' => [
1035 'show_view_result_btn' => 'yes',
1036 'ajax_search' => 'yes'
1037 ]
1038 ]
1039 );
1040 }
1041
1042 public function add_control_no_results_text(): void
1043 {
1044 $this->add_control(
1045 'no_results_text',
1046 [
1047 'label' => esc_html__('No Results Text', 'king-addons'),
1048 'type' => Controls_Manager::TEXT,
1049 'dynamic' => [
1050 'active' => true,
1051 ],
1052 'default' => esc_html__('No Results Found', 'king-addons'),
1053 'condition' => [
1054 'ajax_search' => 'yes'
1055 ]
1056 ]
1057 );
1058 }
1059
1060 protected function register_controls(): void
1061 {
1062
1063 $this->start_controls_section(
1064 'section_search',
1065 [
1066 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Search', 'king-addons'),
1067 ]
1068 );
1069
1070 $this->add_control_search_query();
1071
1072 Core::renderUpgradeProNotice($this, Controls_Manager::RAW_HTML, 'search', 'search_query', ['pro-post', 'pro-page', 'pro-product', 'pro-product', 'pro-e-landing-page']);
1073
1074 if (!king_addons_freemius()->can_use_premium_code__premium_only()) {
1075 $this->add_control(
1076 'search_query_up_pro_notice',
1077 [
1078 'raw' => 'This option is available<br> in the <strong><a href="https://kingaddons.com/pricing/?utm_source=kng-module-search-settings-upgrade-pro&utm_medium=plugin&utm_campaign=kng" target="_blank">Pro version</a></strong>',
1079 'type' => Controls_Manager::RAW_HTML,
1080 'content_classes' => 'king-addons-pro-notice',
1081 'condition' => [
1082 'search_query!' => ['all', 'post', 'page', 'product', 'e-landing-page', 'pro-post', 'pro-page', 'pro-product', 'pro-product', 'pro-e-landing-page'],
1083 ]
1084 ]
1085 );
1086 }
1087
1088 /** @noinspection DuplicatedCode */
1089 $this->add_control_select_category();
1090
1091 $this->add_control_all_cat_text();
1092
1093 $this->add_control_ajax_search();
1094
1095 $this->add_control_number_of_results();
1096
1097 $this->add_control_show_password_protected();
1098
1099 $this->add_control_open_in_new_page();
1100
1101 $this->add_control_show_ajax_thumbnails();
1102
1103 $this->add_control_exclude_posts_without_thumbnail();
1104
1105 $this->add_control_show_view_result_btn();
1106
1107 $this->add_control_view_result_text();
1108
1109 $this->add_control_show_description();
1110
1111 $this->add_control_number_of_words_in_excerpt();
1112
1113 $this->add_control_no_results_text();
1114
1115 $this->add_control(
1116 'search_placeholder',
1117 [
1118 'label' => esc_html__('Placeholder', 'king-addons'),
1119 'type' => Controls_Manager::TEXT,
1120 'dynamic' => [
1121 'active' => true,
1122 ],
1123 'default' => esc_html__('Search...', 'king-addons'),
1124 'separator' => 'before',
1125 ]
1126 );
1127
1128 $this->add_control(
1129 'search_aria_label',
1130 [
1131 'label' => esc_html__('Aria Label', 'king-addons'),
1132 'type' => Controls_Manager::TEXT,
1133 'dynamic' => [
1134 'active' => true,
1135 ],
1136 'default' => esc_html__('Search', 'king-addons'),
1137 'separator' => 'before',
1138 ]
1139 );
1140
1141 $this->add_control(
1142 'search_btn',
1143 [
1144 'label' => esc_html__('Button', 'king-addons'),
1145 'type' => Controls_Manager::SWITCHER,
1146 'default' => 'yes',
1147 'separator' => 'before',
1148 ]
1149 );
1150
1151 $this->add_control(
1152 'search_btn_style',
1153 [
1154 'label' => esc_html__('Style', 'king-addons'),
1155 'type' => Controls_Manager::SELECT,
1156 'default' => 'inner',
1157 'options' => [
1158 'inner' => esc_html__('Inner', 'king-addons'),
1159 'outer' => esc_html__('Outer', 'king-addons'),
1160 ],
1161 'prefix_class' => 'king-addons-search-form-style-',
1162 'render_type' => 'template',
1163 'condition' => [
1164 'search_btn' => 'yes',
1165 ],
1166 ]
1167 );
1168
1169 $this->add_control(
1170 'search_btn_disable_click',
1171 [
1172 'label' => esc_html__('Disable Button Click', 'king-addons'),
1173 'type' => Controls_Manager::SWITCHER,
1174 'condition' => [
1175 'search_btn_style' => 'inner',
1176 'search_btn' => 'yes',
1177 ],
1178 ]
1179 );
1180
1181 $this->add_control(
1182 'search_btn_type',
1183 [
1184 'label' => esc_html__('Type', 'king-addons'),
1185 'type' => Controls_Manager::SELECT,
1186 'default' => 'icon',
1187 'options' => [
1188 'text' => esc_html__('Text', 'king-addons'),
1189 'icon' => esc_html__('Icon', 'king-addons'),
1190 ],
1191 'render_type' => 'template',
1192 'condition' => [
1193 'search_btn' => 'yes',
1194 ],
1195 ]
1196 );
1197
1198 $this->add_control(
1199 'search_btn_text',
1200 [
1201 'label' => esc_html__('Text', 'king-addons'),
1202 'type' => Controls_Manager::TEXT,
1203 'dynamic' => [
1204 'active' => true,
1205 ],
1206 'default' => 'Go',
1207 'condition' => [
1208 'search_btn_type' => 'text',
1209 'search_btn' => 'yes',
1210 ],
1211 ]
1212 );
1213
1214 $this->add_control(
1215 'search_btn_icon',
1216 [
1217 'label' => esc_html__('Select Icon', 'king-addons'),
1218 'type' => Controls_Manager::ICONS,
1219 'skin' => 'inline',
1220 'label_block' => false,
1221 'default' => [
1222 'value' => 'fas fa-search',
1223 'library' => 'fa-solid',
1224 ],
1225 'condition' => [
1226 'search_btn_type' => 'icon',
1227 'search_btn' => 'yes',
1228 ],
1229 ]
1230 );
1231
1232 $this->add_responsive_control(
1233 'search_btn_icon_size',
1234 [
1235 'label' => esc_html__('Icon Size (px)', 'king-addons'),
1236 'type' => Controls_Manager::NUMBER,
1237 'step' => 1,
1238 'min' => 0,
1239 'default' => 16,
1240 'selectors' => [
1241 '{{WRAPPER}} .king-addons-search-form-submit i' => 'font-size: {{VALUE}}px; width: {{VALUE}}px;',
1242 '{{WRAPPER}} .king-addons-search-form-submit img' => 'width: {{VALUE}}px; height: {{VALUE}}px;',
1243 '{{WRAPPER}} .king-addons-search-form-submit svg' => 'width: {{VALUE}}px; height: {{VALUE}}px;'
1244 ],
1245 'condition' => [
1246 'search_btn_type' => 'icon',
1247 'search_btn' => 'yes',
1248 ],
1249 ]
1250 );
1251
1252 $this->end_controls_section();
1253
1254 $this->add_section_ajax_pagination();
1255
1256 Core::renderProFeaturesSection($this, '', Controls_Manager::RAW_HTML, 'search', [
1257 'More Than 2 Results in Ajax Search',
1258 'Ajax Search Results Pagination (Load More)',
1259 'Enable Taxonomy & Category Filter',
1260 'Custom Search Query: Only Posts or Pages',
1261 'Custom Search Query: Only Custom Post Types',
1262 ]);
1263
1264 $this->start_controls_section(
1265 'section_style_input',
1266 [
1267 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Input Field', 'king-addons'),
1268 'tab' => Controls_Manager::TAB_STYLE,
1269 ]
1270 );
1271
1272 $this->start_controls_tabs('tabs_input_colors');
1273
1274 $this->start_controls_tab(
1275 'tab_input_normal_colors',
1276 [
1277 'label' => esc_html__('Normal', 'king-addons'),
1278 ]
1279 );
1280
1281 $this->add_control(
1282 'input_color',
1283 [
1284 'label' => esc_html__('Color', 'king-addons'),
1285 'type' => Controls_Manager::COLOR,
1286 'default' => '#333333',
1287 'selectors' => [
1288 '{{WRAPPER}} .king-addons-search-form-input' => 'color: {{VALUE}};',
1289 ],
1290 ]
1291 );
1292
1293 $this->add_control(
1294 'input_bg_color',
1295 [
1296 'label' => esc_html__('Background Color', 'king-addons'),
1297 'type' => Controls_Manager::COLOR,
1298 'default' => '#ffffff',
1299 'selectors' => [
1300 '{{WRAPPER}} .king-addons-search-form-input' => 'background-color: {{VALUE}};',
1301 ],
1302 ]
1303 );
1304
1305 $this->add_control(
1306 'input_placeholder_color',
1307 [
1308 'label' => esc_html__('Placeholder Color', 'king-addons'),
1309 'type' => Controls_Manager::COLOR,
1310 'default' => '#9e9e9e',
1311 'selectors' => [
1312 '{{WRAPPER}} .king-addons-search-form-input::-webkit-input-placeholder' => 'color: {{VALUE}};',
1313 '{{WRAPPER}} .king-addons-search-form-input::-moz-placeholder' => 'color: {{VALUE}};',
1314 '{{WRAPPER}} .king-addons-search-form-input:-moz-placeholder' => 'color: {{VALUE}};',
1315 '{{WRAPPER}} .king-addons-search-form-input::placeholder' => 'color: {{VALUE}};',
1316 ],
1317 ]
1318 );
1319
1320 $this->add_control(
1321 'input_border_color',
1322 [
1323 'label' => esc_html__('Border Color', 'king-addons'),
1324 'type' => Controls_Manager::COLOR,
1325 'default' => '#E8E8E8',
1326 'selectors' => [
1327 '{{WRAPPER}} .king-addons-search-form-input' => 'border-color: {{VALUE}};',
1328 '{{WRAPPER}} .king-addons-data-fetch' => 'border-color: {{VALUE}};'
1329 ],
1330 ]
1331 );
1332
1333 $this->add_group_control(
1334 Group_Control_Box_Shadow::get_type(),
1335 [
1336 'name' => 'input_box_shadow',
1337 'selector' => '{{WRAPPER}} .king-addons-search-form-input-wrap'
1338 ]
1339 );
1340
1341 $this->end_controls_tab();
1342
1343 $this->start_controls_tab(
1344 'tab_input_focus_colors',
1345 [
1346 'label' => esc_html__('Focus', 'king-addons'),
1347 ]
1348 );
1349
1350 $this->add_control(
1351 'input_focus_color',
1352 [
1353 'label' => esc_html__('Color', 'king-addons'),
1354 'type' => Controls_Manager::COLOR,
1355 'default' => '#333333',
1356 'selectors' => [
1357 '{{WRAPPER}}.king-addons-search-form-input-focus .king-addons-search-form-input' => 'color: {{VALUE}};',
1358 ],
1359 ]
1360 );
1361
1362 $this->add_control(
1363 'input_focus_bg_color',
1364 [
1365 'label' => esc_html__('Background Color', 'king-addons'),
1366 'type' => Controls_Manager::COLOR,
1367 'default' => '#ffffff',
1368 'selectors' => [
1369 '{{WRAPPER}}.king-addons-search-form-input-focus .king-addons-search-form-input' => 'background-color: {{VALUE}};',
1370 ],
1371 ]
1372 );
1373
1374 $this->add_control(
1375 'input_focus_placeholder_color',
1376 [
1377 'label' => esc_html__('Placeholder Color', 'king-addons'),
1378 'type' => Controls_Manager::COLOR,
1379 'default' => '#9e9e9e',
1380 'selectors' => [
1381 '{{WRAPPER}}.king-addons-search-form-input-focus .king-addons-search-form-input::-webkit-input-placeholder' => 'color: {{VALUE}};',
1382 '{{WRAPPER}}.king-addons-search-form-input-focus .king-addons-search-form-input::-moz-placeholder' => 'color: {{VALUE}};',
1383 '{{WRAPPER}}.king-addons-search-form-input-focus .king-addons-search-form-input:-moz-placeholder' => 'color: {{VALUE}};',
1384 '{{WRAPPER}}.king-addons-search-form-input-focus .king-addons-search-form-input::placeholder' => 'color: {{VALUE}};',
1385 ],
1386 ]
1387 );
1388
1389 $this->add_control(
1390 'input_focus_border_color',
1391 [
1392 'label' => esc_html__('Border Color', 'king-addons'),
1393 'type' => Controls_Manager::COLOR,
1394 'default' => '#E8E8E8',
1395 'selectors' => [
1396 '{{WRAPPER}}.king-addons-search-form-input-focus .king-addons-search-form-input' => 'border-color: {{VALUE}};',
1397 ],
1398 ]
1399 );
1400
1401 $this->add_group_control(
1402 Group_Control_Box_Shadow::get_type(),
1403 [
1404 'name' => 'input_focus_box_shadow',
1405 'selector' => '{{WRAPPER}}.king-addons-search-form-input-focus .king-addons-search-form-input-wrap'
1406 ]
1407 );
1408
1409 $this->end_controls_tab();
1410
1411 $this->end_controls_tabs();
1412
1413 $this->add_control(
1414 'input_typography_divider',
1415 [
1416 'type' => Controls_Manager::DIVIDER,
1417 'style' => 'thick',
1418 ]
1419 );
1420
1421 $this->add_group_control(
1422 Group_Control_Typography::get_type(),
1423 [
1424 'name' => 'input_typography',
1425 'selector' => '{{WRAPPER}} .king-addons-search-form-input, {{WRAPPER}} .king-addons-category-select-wrap, {{WRAPPER}} .king-addons-category-select',
1426 ]
1427 );
1428
1429 $this->add_responsive_control(
1430 'input_align',
1431 [
1432 'label' => esc_html__('Alignment', 'king-addons'),
1433 'type' => Controls_Manager::CHOOSE,
1434 'label_block' => false,
1435 'default' => 'left',
1436 'options' => [
1437 'left' => [
1438 'title' => esc_html__('Left', 'king-addons'),
1439 'icon' => 'eicon-text-align-left',
1440 ],
1441 'center' => [
1442 'title' => esc_html__('Center', 'king-addons'),
1443 'icon' => 'eicon-text-align-center',
1444 ],
1445 'right' => [
1446 'title' => esc_html__('Right', 'king-addons'),
1447 'icon' => 'eicon-text-align-right',
1448 ],
1449 ],
1450 'selectors' => [
1451 '{{WRAPPER}} .king-addons-search-form-input' => 'text-align: {{VALUE}};',
1452 ],
1453 'separator' => 'before',
1454 ]
1455 );
1456
1457 $this->add_control(
1458 'input_border_size',
1459 [
1460 'label' => esc_html__('Border Size', 'king-addons'),
1461 'type' => Controls_Manager::DIMENSIONS,
1462 'default' => [
1463 'top' => 1,
1464 'right' => 1,
1465 'bottom' => 1,
1466 'left' => 1,
1467 ],
1468 'size_units' => ['px'],
1469 'selectors' => [
1470 '{{WRAPPER}} .king-addons-search-form-input' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1471 '{{WRAPPER}} .king-addons-data-fetch' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
1472 ],
1473 'separator' => 'before',
1474 ]
1475 );
1476
1477 $this->add_control(
1478 'input_border_radius',
1479 [
1480 'label' => esc_html__('Border Radius', 'king-addons'),
1481 'type' => Controls_Manager::DIMENSIONS,
1482 'default' => [
1483 'top' => 2,
1484 'right' => 2,
1485 'bottom' => 2,
1486 'left' => 2,
1487 ],
1488 'size_units' => ['px', '%'],
1489 'selectors' => [
1490 '{{WRAPPER}} .king-addons-search-form-input' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1491 '{{WRAPPER}} .king-addons-data-fetch' => 'border-radius: 0 0 {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
1492 ],
1493 'separator' => 'after',
1494 ]
1495 );
1496
1497 $this->add_responsive_control(
1498 'input_padding',
1499 [
1500 'label' => esc_html__('Padding', 'king-addons'),
1501 'type' => Controls_Manager::DIMENSIONS,
1502 'default' => [
1503 'top' => 15,
1504 'right' => 15,
1505 'bottom' => 15,
1506 'left' => 15,
1507 ],
1508 'size_units' => ['px'],
1509 'selectors' => [
1510 '{{WRAPPER}} .king-addons-search-form-input' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1511 '{{WRAPPER}} .king-addons-category-select-wrap::before' => 'right: {{RIGHT}}{{UNIT}};',
1512 '{{WRAPPER}} .king-addons-category-select' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
1513 ],
1514 ]
1515 );
1516
1517 $this->end_controls_section();
1518
1519 $this->start_controls_section(
1520 'section_style_select',
1521 [
1522 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Taxonomy Filter', 'king-addons'),
1523 'tab' => Controls_Manager::TAB_STYLE,
1524 'condition' => [
1525 'select_category' => 'yes',
1526 ],
1527 ]
1528 );
1529
1530 $this->add_control(
1531 'select_color',
1532 [
1533 'label' => esc_html__('Color', 'king-addons'),
1534 'type' => Controls_Manager::COLOR,
1535 'default' => '#333333',
1536 'selectors' => [
1537 '{{WRAPPER}} .king-addons-category-select-wrap' => 'color: {{VALUE}};',
1538 '{{WRAPPER}} .king-addons-category-select' => 'color: {{VALUE}};'
1539 ],
1540 ]
1541 );
1542
1543 $this->add_control(
1544 'select_bg_color',
1545 [
1546 'label' => esc_html__('Background Color', 'king-addons'),
1547 'type' => Controls_Manager::COLOR,
1548 'default' => '#ffffff',
1549 'selectors' => [
1550 '{{WRAPPER}} .king-addons-category-select' => 'background-color: {{VALUE}};',
1551 ],
1552 ]
1553 );
1554
1555 $this->add_control(
1556 'select_border_color',
1557 [
1558 'label' => esc_html__('Border Color', 'king-addons'),
1559 'type' => Controls_Manager::COLOR,
1560 'default' => '#E8E8E8',
1561 'selectors' => [
1562 '{{WRAPPER}} .king-addons-category-select' => 'border-color: {{VALUE}};'
1563 ],
1564 ]
1565 );
1566
1567 $this->add_control(
1568 'select_border_size',
1569 [
1570 'label' => esc_html__('Border Size', 'king-addons'),
1571 'type' => Controls_Manager::DIMENSIONS,
1572 'default' => [
1573 'top' => 1,
1574 'right' => 1,
1575 'bottom' => 1,
1576 'left' => 1,
1577 ],
1578 'size_units' => ['px'],
1579 'selectors' => [
1580 '{{WRAPPER}} .king-addons-category-select' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
1581 ],
1582 'separator' => 'before',
1583 ]
1584 );
1585
1586 $this->add_control(
1587 'select_border_radius',
1588 [
1589 'label' => esc_html__('Border Radius', 'king-addons'),
1590 'type' => Controls_Manager::DIMENSIONS,
1591 'default' => [
1592 'top' => 2,
1593 'right' => 2,
1594 'bottom' => 2,
1595 'left' => 2,
1596 ],
1597 'size_units' => ['px', '%'],
1598 'selectors' => [
1599 '{{WRAPPER}} .king-addons-category-select' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
1600 '{{WRAPPER}} .king-addons-category-select-wrap' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1601 ],
1602 'separator' => 'after',
1603 ]
1604 );
1605
1606 $this->add_responsive_control(
1607 'select_width',
1608 [
1609 'label' => esc_html__('Select Width', 'king-addons'),
1610 'type' => Controls_Manager::SLIDER,
1611 'size_units' => ['px', '%'],
1612 'range' => [
1613 'px' => [
1614 'min' => 0,
1615 'max' => 400,
1616 ],
1617 ],
1618 'default' => [
1619 'unit' => 'px',
1620 'size' => 230,
1621 ],
1622 'selectors' => [
1623 '{{WRAPPER}} .king-addons-category-select-wrap' => 'width: {{SIZE}}{{UNIT}};',
1624 ],
1625 'separator' => 'before',
1626 ]
1627 );
1628
1629 $this->add_control(
1630 'options_heading',
1631 [
1632 'label' => esc_html__('Options', 'king-addons'),
1633 'type' => Controls_Manager::HEADING,
1634 ]
1635 );
1636
1637 $this->add_responsive_control(
1638 'option_font_size',
1639 [
1640 'label' => esc_html__('Font Size', 'king-addons'),
1641 'type' => Controls_Manager::SLIDER,
1642 'size_units' => ['px', '%'],
1643 'range' => [
1644 'px' => [
1645 'min' => 0,
1646 'max' => 25,
1647 ],
1648 ],
1649 'default' => [
1650 'unit' => 'px',
1651 'size' => 12,
1652 ],
1653 'selectors' => [
1654 '{{WRAPPER}} .king-addons-category-select option' => 'font-size: {{SIZE}}{{UNIT}};',
1655 ]
1656 ]
1657 );
1658
1659 $this->add_control(
1660 'optgroup_heading',
1661 [
1662 'label' => esc_html__('Options Group', 'king-addons'),
1663 'type' => Controls_Manager::HEADING,
1664 ]
1665 );
1666
1667 $this->add_responsive_control(
1668 'optgroup_font_size',
1669 [
1670 'label' => esc_html__('Font Size', 'king-addons'),
1671 'type' => Controls_Manager::SLIDER,
1672 'size_units' => ['px', '%'],
1673 'range' => [
1674 'px' => [
1675 'min' => 0,
1676 'max' => 25,
1677 ],
1678 ],
1679 'default' => [
1680 'unit' => 'px',
1681 'size' => 12,
1682 ],
1683 'selectors' => [
1684 '{{WRAPPER}} .king-addons-category-select optgroup' => 'font-size: {{SIZE}}{{UNIT}};',
1685 ]
1686 ]
1687 );
1688
1689 $this->end_controls_section();
1690
1691 $this->start_controls_section(
1692 'section_style_btn',
1693 [
1694 'label' => KING_ADDONS_ELEMENTOR_ICON . esc_html__('Button', 'king-addons'),
1695 'tab' => Controls_Manager::TAB_STYLE,
1696 'condition' => [
1697 'search_btn' => 'yes',
1698 ],
1699 ]
1700 );
1701
1702 $this->start_controls_tabs('tabs_btn_colors');
1703
1704 $this->start_controls_tab(
1705 'tab_btn_normal_colors',
1706 [
1707 'label' => esc_html__('Normal', 'king-addons'),
1708 ]
1709 );
1710
1711 $this->add_control(
1712 'btn_text_color',
1713 [
1714 'type' => Controls_Manager::COLOR,
1715 'label' => esc_html__('Text/Icon Color', 'king-addons'),
1716 'default' => '#ffffff',
1717 'selectors' => [
1718 '{{WRAPPER}} .king-addons-search-form-submit' => 'color: {{VALUE}};',
1719 '{{WRAPPER}} .king-addons-search-form-submit svg' => 'fill: {{VALUE}};'
1720 ],
1721 ]
1722 );
1723
1724 $this->add_control(
1725 'btn_bg_color',
1726 [
1727 'type' => Controls_Manager::COLOR,
1728 'label' => esc_html__('Background Color', 'king-addons'),
1729 'default' => '#5B03FF',
1730 'selectors' => [
1731 '{{WRAPPER}} .king-addons-search-form-submit' => 'background-color: {{VALUE}};',
1732 ],
1733 ]
1734 );
1735
1736 $this->add_control(
1737 'btn_border_color',
1738 [
1739 'type' => Controls_Manager::COLOR,
1740 'label' => esc_html__('Border Color', 'king-addons'),
1741 'default' => '#E8E8E8',
1742 'selectors' => [
1743 '{{WRAPPER}} .king-addons-search-form-submit' => 'border-color: {{VALUE}};',
1744 ],
1745 ]
1746 );
1747
1748 $this->add_group_control(
1749 Group_Control_Box_Shadow::get_type(),
1750 [
1751 'name' => 'btn_box_shadow',
1752 'selector' => '{{WRAPPER}} .king-addons-search-form-submit',
1753 'condition' => [
1754 'search_btn_style' => 'outer',
1755 ],
1756 ]
1757 );
1758
1759 $this->end_controls_tab();
1760
1761 $this->start_controls_tab(
1762 'tab_btn_hover_colors',
1763 [
1764 'label' => esc_html__('Hover', 'king-addons'),
1765 ]
1766 );
1767
1768
1769 $this->add_control(
1770 'btn_hv_text_color',
1771 [
1772 'type' => Controls_Manager::COLOR,
1773 'label' => esc_html__('Text/Icon Color', 'king-addons'),
1774 'default' => '#ffffff',
1775 'selectors' => [
1776 '{{WRAPPER}} .king-addons-search-form-submit:hover' => 'color: {{VALUE}};',
1777 '{{WRAPPER}} .king-addons-search-form-submit:hover svg' => 'fill: {{VALUE}};'
1778 ],
1779 ]
1780 );
1781
1782 $this->add_control(
1783 'btn_hv_bg_color',
1784 [
1785 'type' => Controls_Manager::COLOR,
1786 'label' => esc_html__('Background Color', 'king-addons'),
1787 'default' => '#4e00e0',
1788 'selectors' => [
1789 '{{WRAPPER}} .king-addons-search-form-submit:hover' => 'background-color: {{VALUE}};',
1790 ],
1791 ]
1792 );
1793
1794 $this->add_control(
1795 'btn_hv_border_color',
1796 [
1797 'type' => Controls_Manager::COLOR,
1798 'label' => esc_html__('Border Color', 'king-addons'),
1799 'default' => '#E8E8E8',
1800 'selectors' => [
1801 '{{WRAPPER}} .king-addons-search-form-submit:hover' => 'border-color: {{VALUE}};',
1802 ],
1803 ]
1804 );
1805
1806 $this->add_group_control(
1807 Group_Control_Box_Shadow::get_type(),
1808 [
1809 'name' => 'btn_hv_box_shadow',
1810 'selector' => '{{WRAPPER}} .king-addons-search-form-submit:hover',
1811 'condition' => [
1812 'search_btn_style' => 'outer',
1813 ],
1814 ]
1815 );
1816
1817 $this->end_controls_tab();
1818
1819 $this->end_controls_tabs();
1820
1821 $this->add_responsive_control(
1822 'btn_width',
1823 [
1824 'label' => esc_html__('Width', 'king-addons'),
1825 'type' => Controls_Manager::SLIDER,
1826 'size_units' => ['px'],
1827 'range' => [
1828 'px' => [
1829 'min' => 0,
1830 'max' => 300,
1831 ],
1832 ],
1833 'default' => [
1834 'unit' => 'px',
1835 'size' => 125,
1836 ],
1837 'selectors' => [
1838 '{{WRAPPER}} .king-addons-search-form-submit' => 'min-width: {{SIZE}}{{UNIT}};',
1839 ],
1840 'separator' => 'before',
1841 ]
1842 );
1843
1844 $this->add_responsive_control(
1845 'btn_height',
1846 [
1847 'label' => esc_html__('Height', 'king-addons'),
1848 'type' => Controls_Manager::SLIDER,
1849 'size_units' => ['px'],
1850 'range' => [
1851 'px' => [
1852 'min' => 0,
1853 'max' => 100,
1854 ],
1855 ],
1856 'default' => [
1857 'unit' => 'px',
1858 'size' => 50,
1859 ],
1860 'selectors' => [
1861 '{{WRAPPER}}.king-addons-search-form-style-outer .king-addons-search-form-submit' => 'height: {{SIZE}}{{UNIT}};',
1862 ],
1863 'condition' => [
1864 'search_btn_style' => 'outer',
1865 ],
1866 ]
1867 );
1868
1869 $this->add_control(
1870 'btn_gutter',
1871 [
1872 'type' => Controls_Manager::SLIDER,
1873 'label' => esc_html__('Gutter', 'king-addons'),
1874 'size_units' => ['px'],
1875 'range' => [
1876 'px' => [
1877 'min' => 0,
1878 'max' => 100,
1879 ]
1880 ],
1881 'default' => [
1882 'unit' => 'px',
1883 'size' => 10,
1884 ],
1885 'selectors' => [
1886 '{{WRAPPER}}.king-addons-search-form-style-outer.king-addons-search-form-position-right .king-addons-search-form-submit' => 'margin-left: {{SIZE}}{{UNIT}};',
1887 '{{WRAPPER}}.king-addons-search-form-style-outer.king-addons-search-form-position-left .king-addons-search-form-submit' => 'margin-right: {{SIZE}}{{UNIT}};',
1888 ],
1889 'condition' => [
1890 'search_btn_style' => 'outer',
1891 ],
1892 ]
1893 );
1894
1895 $this->add_control(
1896 'btn_position',
1897 [
1898 'label' => esc_html__('Position', 'king-addons'),
1899 'type' => Controls_Manager::CHOOSE,
1900 'label_block' => false,
1901 'default' => 'right',
1902 'options' => [
1903 'left' => [
1904 'title' => esc_html__('Left', 'king-addons'),
1905 'icon' => 'eicon-h-align-left',
1906 ],
1907 'right' => [
1908 'title' => esc_html__('Right', 'king-addons'),
1909 'icon' => 'eicon-h-align-right',
1910 ],
1911 ],
1912 'prefix_class' => 'king-addons-search-form-position-',
1913 'separator' => 'before',
1914 ]
1915 );
1916
1917 $this->add_control(
1918 'btn_typography_divider',
1919 [
1920 'type' => Controls_Manager::DIVIDER,
1921 'style' => 'thick',
1922 ]
1923 );
1924
1925 $this->add_group_control(
1926 Group_Control_Typography::get_type(),
1927 [
1928 'name' => 'btn_typography',
1929 'label' => esc_html__('Typography', 'king-addons'),
1930 'selector' => '{{WRAPPER}} .king-addons-search-form-submit',
1931 ]
1932 );
1933
1934 $this->add_control(
1935 'btn_border_size',
1936 [
1937 'label' => esc_html__('Border Size', 'king-addons'),
1938 'type' => Controls_Manager::DIMENSIONS,
1939 'default' => [
1940 'top' => 0,
1941 'right' => 0,
1942 'bottom' => 0,
1943 'left' => 0,
1944 ],
1945 'size_units' => ['px'],
1946 'selectors' => [
1947 '{{WRAPPER}} .king-addons-search-form-submit' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1948 ],
1949 'separator' => 'before',
1950 ]
1951 );
1952
1953 $this->add_control(
1954 'btn_border_radius',
1955 [
1956 'label' => esc_html__('Border Radius', 'king-addons'),
1957 'type' => Controls_Manager::DIMENSIONS,
1958 'default' => [
1959 'top' => 0,
1960 'right' => 0,
1961 'bottom' => 0,
1962 'left' => 0,
1963 ],
1964 'size_units' => ['px', '%'],
1965 'selectors' => [
1966 '{{WRAPPER}} .king-addons-search-form-submit' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
1967 ],
1968 ]
1969 );
1970
1971 $this->add_control(
1972 'btn_padding',
1973 [
1974 'label' => esc_html__('Padding', 'king-addons'),
1975 'type' => Controls_Manager::DIMENSIONS,
1976 'default' => [
1977 'top' => 0,
1978 'right' => 0,
1979 'bottom' => 0,
1980 'left' => 0,
1981 ],
1982 'size_units' => ['px'],
1983 'selectors' => [
1984 '{{WRAPPER}} .king-addons-search-form-submit' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
1985 ],
1986 'separator' => 'before',
1987 ]
1988 );
1989
1990 $this->end_controls_section();
1991
1992 $this->add_section_style_ajax();
1993
1994 $this->add_section_style_ajax_pagination();
1995
1996 }
1997
1998 public function render_search_pagination($settings)
1999 {
2000 }
2001
2002 protected function render_search_submit_btn(): void
2003 {
2004 $settings = $this->get_settings();
2005
2006 $this->add_render_attribute(
2007 'button', [
2008 'class' => 'king-addons-search-form-submit',
2009 'aria-label' => $settings['search_aria_label'],
2010 'type' => 'submit',
2011 ]
2012 );
2013
2014 if ($settings['search_btn_disable_click']) {
2015 $this->add_render_attribute('button', 'disabled');
2016 }
2017
2018 if ('yes' === $settings['search_btn']) : ?>
2019
2020 <button <?php echo $this->get_render_attribute_string('button'); ?>>
2021 <?php if ('icon' === $settings['search_btn_type'] && '' !== $settings['search_btn_icon']['value']) : ?>
2022 <?php Icons_Manager::render_icon($settings['search_btn_icon']); ?>
2023 <?php elseif ('text' === $settings['search_btn_type'] && '' !== $settings['search_btn_text']) : ?>
2024 <?php echo esc_html($settings['search_btn_text']); ?>
2025 <?php endif; ?>
2026 </button>
2027
2028 <?php
2029 endif;
2030 }
2031
2032 protected function render(): void
2033 {
2034 $settings = $this->get_settings();
2035 $this->add_render_attribute(
2036 'input', [
2037 'ajax-search' => $settings['ajax_search'] ?? '',
2038 'class' => 'king-addons-search-form-input',
2039 'exclude-without-thumb' => $settings['exclude_posts_without_thumbnail'] ?? '',
2040 'link-target' => isset($settings['ajax_search_link_target']) && ('yes' === $settings['ajax_search_link_target']) ? '_blank' : '_self',
2041 'name' => 's',
2042 'no-results' => $settings['no_results_text'] ?? '',
2043 'number-of-results' => isset($settings['number_of_results']) && king_addons_freemius()->can_use_premium_code__premium_only() ? $settings['number_of_results'] : 2,
2044 'number-of-words' => $settings['number_of_words_in_excerpt'] ?? '',
2045 'password-protected' => $settings['ajax_show_ps_pt'] ?? 'no',
2046 'placeholder' => $settings['search_placeholder'],
2047 'show-ajax-thumbnails' => $settings['show_ajax_thumbnails'] ?? '',
2048 'show-description' => $settings['show_description'] ?? '',
2049 'show-view-result-btn' => $settings['show_view_result_btn'] ?? '',
2050 'title' => esc_html__('Search', 'king-addons'),
2051 'type' => 'search',
2052 'value' => get_search_query(),
2053 'view-result-text' => $settings['view_result_text'] ?? '',
2054 'king-addons-query-type' => $settings['search_query'],
2055 'king-addons-taxonomy-type' => $settings['query_taxonomy_' . $settings['search_query']] ?? '',
2056 ]
2057 );
2058
2059 ?>
2060 <form role="search" method="get" class="king-addons-search-form" action="<?php echo esc_url(home_url()); ?>">
2061 <div class="king-addons-search-form-input-wrap elementor-clearfix">
2062 <!--suppress HtmlFormInputWithoutLabel -->
2063 <input <?php echo $this->get_render_attribute_string('input'); ?>>
2064 <?php
2065 if ($settings['search_btn_style'] === 'inner') {
2066 $this->render_search_submit_btn();
2067 }
2068 ?>
2069 </div>
2070 <?php
2071
2072 if ($settings['search_btn_style'] === 'outer') {
2073 $this->render_search_submit_btn();
2074 }
2075
2076 ?>
2077 </form>
2078 <div class="king-addons-data-fetch">
2079 <span class="king-addons-close-search"></span>
2080 <ul></ul>
2081 <?php if (!king_addons_freemius()->can_use_premium_code__premium_only() && current_user_can('administrator')) : ?>
2082 <p class="king-addons-search-admin-notice"><?php
2083 echo esc_html__('More than 2 results are available in the ', 'king-addons');
2084 echo '<strong><a href="https://kingaddons.com/pricing/?utm_source=kng-module-search-settings-upgrade-pro&utm_medium=plugin&utm_campaign=kng" target="_blank">' . esc_html__('PRO version', 'king-addons') . '</a></strong>';
2085 echo esc_html__(' of King Addons (this notice is visible to admin users only)', 'king-addons');
2086 ?></p>
2087 <?php endif; ?>
2088 </div>
2089 <?php
2090 }
2091
2092 }