PluginProbe
Forumax – AI Powered Advanced Community Forum Plugin / 2.5.0
Forumax – AI Powered Advanced Community Forum Plugin v2.5.0
2.5.0 2.4.4 2.4.3 2.4.2 2.4.1 2.4.0 trunk 1.0.8 1.1.0 1.2.1 1.2.2 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.4.0 1.4.1 2.0.0 All 30 releases
bbp-core / includes / Elementor / Search.php

Search.php in Forumax – AI Powered Advanced Community Forum Plugin 2.5.0, at includes/Elementor/Search.php

788 lines 21.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace admin\Elementor;
4
5 use Elementor\Controls_Manager;
6 use Elementor\Group_Control_Typography;
7 use Elementor\Widget_Base;
8 use Elementor\Group_Control_Border;
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 class Search extends Widget_Base {
16 public function get_name() {
17 return 'ama_search';
18 }
19
20 public function get_title() {
21 return esc_html__( 'Search (Forumax)', 'forumax' );
22 }
23
24 public function get_icon() {
25 return 'bbpc_icon_ama_search eicon-search';
26 }
27
28 public function get_style_depends() {
29 return [ 'ama-core-style', 'bbpc-el-widgets' ];
30 }
31
32 public function get_script_depends() {
33 return [ 'bbpc-frontend' ];
34 }
35
36 public function get_categories() {
37 return [ 'forumax' ];
38 }
39
40 protected function register_controls() {
41
42 $this->start_controls_section(
43 'search_form_sec', [
44 'label' => esc_html__( 'Form', 'forumax' ),
45 ]
46 );
47
48 $this->add_control(
49 'placeholder', [
50 'label' => esc_html__( 'Placeholder', 'forumax' ),
51 'type' => Controls_Manager::TEXT,
52 'label_block' => true,
53 'default' => 'Search for Topics....',
54 ]
55 );
56
57 $this->add_control(
58 'search_post_type', [
59 'label' => esc_html__( 'Post Type', 'forumax' ),
60 'type' => Controls_Manager::SELECT,
61 'default' => 'all',
62 'options' => [
63 'all' => esc_html__( 'All (Forums, Topics & Replies)', 'forumax' ),
64 'forum' => esc_html__( 'Forum', 'forumax' ),
65 'topic' => esc_html__( 'Topic', 'forumax' ),
66 'reply' => esc_html__( 'Reply', 'forumax' ),
67 'post' => esc_html__( 'Post', 'forumax' ),
68 'page' => esc_html__( 'Page', 'forumax' ),
69 'docs' => esc_html__( 'Docs', 'forumax' ),
70 ],
71 ]
72 );
73
74 $this->add_control(
75 'is_ajax_search', [
76 'label' => esc_html__( 'AJAX Live Search', 'forumax' ),
77 'description' => esc_html__( 'Show search results instantly as users type without page reload.', 'forumax' ),
78 'type' => Controls_Manager::SWITCHER,
79 'return_value' => 'yes',
80 'default' => 'yes',
81 ]
82 );
83
84 $this->add_control(
85 'search_highlight', [
86 'label' => esc_html__( 'Highlight Keywords', 'forumax' ),
87 'description' => esc_html__( 'Highlight the matching keyword in search results.', 'forumax' ),
88 'type' => Controls_Manager::SWITCHER,
89 'return_value' => 'yes',
90 'default' => '',
91 'condition' => [
92 'is_ajax_search' => 'yes',
93 ],
94 ]
95 );
96
97 // select controls
98 $this->add_control(
99 'submit_btn_type', [
100 'label' => __( 'Search Type', 'forumax' ),
101 'type' => \Elementor\Controls_Manager::SELECT,
102 'default' => 'icon',
103 'options' => [
104 'icon' => __( 'Icon', 'forumax' ),
105 'text' => __( 'Text', 'forumax' )
106 ],
107 ]
108 );
109
110 $this->add_control(
111 'submit_btn_icon', [
112 'label' => __( 'Submit Button Icon', 'forumax' ),
113 'type' => \Elementor\Controls_Manager::ICONS,
114 'default' => [
115 'value' => 'fas fa-search',
116 'library' => 'fa-solid',
117 ],
118 'condition' => [
119 'submit_btn_type' => 'icon'
120 ]
121 ]
122 );
123
124 $this->add_control(
125 'submit_btn_text', [
126 'label' => esc_html__( 'Submit Button Text', 'forumax' ),
127 'type' => Controls_Manager::TEXT,
128 'label_block' => true,
129 'default' => __( 'Search', 'forumax' ),
130 'condition' => [
131 'submit_btn_type' => 'text'
132 ]
133 ]
134 );
135
136 $this->add_control(
137 'submit_btn_align', [
138 'label' => __( 'Submit Alignment', 'forumax' ),
139 'type' => \Elementor\Controls_Manager::CHOOSE,
140 'options' => [
141 'left' => [
142 'title' => __( 'Left', 'forumax' ),
143 'icon' => 'fa fa-align-left',
144 ],
145 'right' => [
146 'title' => __( 'Right', 'forumax' ),
147 'icon' => 'fa fa-align-right',
148 ],
149 ],
150 'toggle' => false,
151 'default' => 'left',
152 ]
153 );
154
155 $this->add_control(
156 'is_keywords', [
157 'label' => esc_html__( 'Keywords', 'forumax' ),
158 'type' => \Elementor\Controls_Manager::SWITCHER,
159 'return_value' => 'yes',
160 'default' => 'yes',
161 'separator' => 'before',
162 ]
163 );
164
165 $this->add_control(
166 'keywords_label',
167 [
168 'label' => esc_html__( 'Keywords Label', 'forumax' ),
169 'type' => Controls_Manager::TEXT,
170 'label_block' => true,
171 'default' => 'Popular:',
172 'condition' => [
173 'is_keywords' => 'yes'
174 ]
175 ]
176 );
177
178 $this->add_control(
179 'keywords_align', [
180 'label' => __( 'Keywords Alignment', 'forumax' ),
181 'type' => \Elementor\Controls_Manager::CHOOSE,
182 'options' => [
183 'left' => [
184 'title' => __( 'Left', 'forumax' ),
185 'icon' => 'fa fa-align-left',
186 ],
187 'center' => [
188 'title' => __( 'Center', 'forumax' ),
189 'icon' => 'fa fa-align-center',
190 ],
191 'right' => [
192 'title' => __( 'Right', 'forumax' ),
193 'icon' => 'fa fa-align-right',
194 ],
195 ],
196 'toggle' => false,
197 'default' => 'center'
198 ]
199 );
200
201 $keywords = new \Elementor\Repeater();
202
203 $keywords->add_control(
204 'title', [
205 'label' => __( 'Title', 'forumax' ),
206 'type' => \Elementor\Controls_Manager::TEXT,
207 'label_block' => true,
208 ]
209 );
210
211 $this->add_control(
212 'keywords',
213 [
214 'label' => __( 'Repeater List', 'forumax' ),
215 'type' => \Elementor\Controls_Manager::REPEATER,
216 'fields' => $keywords->get_controls(),
217 'default' => [
218 [
219 'title' => __( 'Keyword #1', 'forumax' ),
220 ],
221 [
222 'title' => __( 'Keyword #2', 'forumax' ),
223 ],
224 ],
225 'title_field' => '{{{ title }}}',
226 'prevent_empty' => false,
227 'condition' => [
228 'is_keywords' => 'yes'
229 ]
230 ]
231 );
232
233 $this->end_controls_section();
234
235 /**
236 * Style Keywords
237 * Global
238 */
239 $this->start_controls_section(
240 'style_form', [
241 'label' => esc_html__( 'Form', 'forumax' ),
242 'tab' => Controls_Manager::TAB_STYLE,
243 ]
244 );
245
246 $this->add_control(
247 'input_heading_form', [
248 'label' => esc_html__( 'Input', 'forumax' ),
249 'type' => Controls_Manager::HEADING
250 ]
251 );
252
253 $this->add_control(
254 'color_text', [
255 'label' => esc_html__( 'Text Color', 'forumax' ),
256 'type' => Controls_Manager::COLOR,
257 'selectors' => [
258 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper input' => 'color: {{VALUE}};',
259 ]
260 ]
261 );
262
263 $this->add_control(
264 'color_placeholder', [
265 'label' => esc_html__( 'Placeholder Color', 'forumax' ),
266 'type' => Controls_Manager::COLOR,
267 'selectors' => [
268 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper input::placeholder' => 'color: {{VALUE}};',
269 ],
270 ]
271 );
272
273 $this->add_group_control(
274 Group_Control_Border::get_type(), [
275 'name' => 'input_border',
276 'label' => esc_html__( 'Border', 'forumax' ),
277 'selector' => '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper input',
278 ]
279 );
280
281 $this->add_control(
282 'input_bg_color', [
283 'label' => esc_html__( 'Background Color', 'forumax' ),
284 'type' => Controls_Manager::COLOR,
285 'selectors' => [
286 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper input' => 'background-color: {{VALUE}};',
287 ],
288 ]
289 );
290
291 $this->add_group_control(
292 Group_Control_Typography::get_type(), [
293 'name' => 'typography_placeholder',
294 'label' => esc_html__( 'Typography', 'forumax' ),
295 'selector' => '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper input::placeholder, .bbpc_search_form_wrapper .input-wrapper input',
296 ]
297 );
298
299 $this->add_responsive_control(
300 'input-padding', [
301 'label' => esc_html__( 'Padding', 'forumax' ),
302 'type' => Controls_Manager::DIMENSIONS,
303 'size_units' => [ 'px', '%', 'em' ],
304 'selectors' => [
305 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper input' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
306 ]
307 ]
308 );
309
310 $this->add_responsive_control(
311 'input-border-radius', [
312 'label' => __( 'Border Radius', 'forumax' ),
313 'type' => Controls_Manager::DIMENSIONS,
314 'size_units' => [ 'px', '%', 'em' ],
315 'selectors' => [
316 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper input' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
317 ],
318 ]
319 );
320
321 $this->add_control(
322 'submit_heading_form', [
323 'label' => esc_html__( 'Submit', 'forumax' ),
324 'type' => Controls_Manager::HEADING,
325 'separator' => 'before'
326 ]
327 );
328
329 $this->add_control(
330 'color_icon', [
331 'label' => esc_html__( 'Button Color', 'forumax' ),
332 'type' => Controls_Manager::COLOR,
333 'selectors' => [
334 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper button' => 'color: {{VALUE}};',
335 ],
336 ]
337 );
338
339
340 $this->add_control(
341 'search_bg',
342 [
343 'label' => __( 'Background', 'forumax' ),
344 'type' => \Elementor\Controls_Manager::COLOR,
345 'selectors' => [
346 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper button' => 'background: {{VALUE}}',
347 ],
348 ]
349 );
350
351 $this->add_responsive_control(
352 'btn-padding', [
353 'label' => esc_html__( 'Padding', 'forumax' ),
354 'type' => Controls_Manager::DIMENSIONS,
355 'size_units' => [ 'px', '%', 'em' ],
356 'selectors' => [
357 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper button' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
358 ]
359 ]
360 );
361
362 $this->add_responsive_control(
363 'btn-border-radius', [
364 'label' => __( 'Border Radius', 'forumax' ),
365 'type' => Controls_Manager::DIMENSIONS,
366 'size_units' => [ 'px', '%', 'em' ],
367 'selectors' => [
368 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper button' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
369 ],
370 ]
371 );
372
373 // slider controls
374 $this->add_control(
375 'typography_btn', [
376 'label' => esc_html__( 'Icon Size', 'forumax' ),
377 'type' => Controls_Manager::SLIDER,
378 'range' => [
379 'px' => [
380 'min' => 10,
381 'max' => 100,
382 ],
383 ],
384 'selectors' => [
385 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper button i' => 'font-size: {{SIZE}}{{UNIT}};'
386 ],
387 'condition' => [
388 'submit_btn_type' => 'icon'
389 ],
390 ]
391 );
392
393
394 // Spacing slider when icon is on the LEFT.
395 $this->add_control(
396 'submit_btn_align_left', [
397 'label' => esc_html__( 'Spacing', 'forumax' ),
398 'type' => Controls_Manager::SLIDER,
399 'range' => [
400 'px' => [
401 'min' => 0,
402 'max' => 100,
403 ],
404 ],
405 'selectors' => [
406 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper .submit-btn-left' => 'left: {{SIZE}}{{UNIT}};',
407 ],
408 'condition' => [
409 'submit_btn_align' => 'left',
410 ],
411 ]
412 );
413
414 // Spacing slider when icon is on the RIGHT.
415 $this->add_control(
416 'submit_btn_align_right', [
417 'label' => esc_html__( 'Spacing', 'forumax' ),
418 'type' => Controls_Manager::SLIDER,
419 'range' => [
420 'px' => [
421 'min' => 0,
422 'max' => 100,
423 ],
424 ],
425 'selectors' => [
426 '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper .submit-btn-right' => 'right: {{SIZE}}{{UNIT}};',
427 ],
428 'condition' => [
429 'submit_btn_align' => 'right',
430 ],
431 ]
432 );
433
434 // typography controls
435 $this->add_group_control(
436 Group_Control_Typography::get_type(), [
437 'name' => 'typography_btn',
438 'label' => esc_html__( 'Typography', 'forumax' ),
439 'condition' => [
440 'submit_btn_type' => 'text'
441 ],
442 'selector' => '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper button',
443 ]
444 );
445
446 $this->end_controls_section();
447
448 $this->start_controls_section(
449 'style_keywords', [
450 'label' => esc_html__( 'Keywords', 'forumax' ),
451 'tab' => Controls_Manager::TAB_STYLE,
452 ]
453 );
454
455 $this->add_control(
456 'margin_keywords', [
457 'label' => __( 'Margin', 'forumax' ),
458 'description' => __( 'Margin around the keywords block', 'forumax' ),
459 'type' => Controls_Manager::DIMENSIONS,
460 'size_units' => [ 'px', '%', 'em' ],
461 'selectors' => [ '{{WRAPPER}} .bbpc-search-keyword ul li' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
462 'separator' => 'before',
463 'default' => [
464 'unit' => 'px',
465 ],
466 ]
467 );
468
469 $this->add_control(
470 'color_keywords_label', [
471 'label' => esc_html__( 'Label Color', 'forumax' ),
472 'type' => Controls_Manager::COLOR,
473 'selectors' => [
474 '{{WRAPPER}} .bbpc-search-keyword span.bbpc-search-keywords-label' => 'color: {{VALUE}};',
475 ],
476 ]
477 );
478
479 $this->add_group_control(
480 \Elementor\Group_Control_Typography::get_type(),
481 [
482 'name' => 'keyword_label_typography',
483 'label' => __( 'Label Typography', 'forumax' ),
484 'selector' => '{{WRAPPER}} .bbpc-search-keyword span.bbpc-search-keywords-label',
485 ]
486 );
487
488 $this->start_controls_tabs(
489 'bbpc_tabs_keywords_style'
490 );
491
492 $this->start_controls_tab(
493 'bbpc_keywords_style',
494 [
495 'label' => esc_html__( 'Normal', 'forumax' ),
496 ]
497 );
498
499 $this->add_control(
500 'bbpc_color_keywords', [
501 'label' => esc_html__( 'Keyword Color', 'forumax' ),
502 'type' => Controls_Manager::COLOR,
503 'separator' => 'before',
504 'selectors' => [
505 '{{WRAPPER}} .bbpc-search-keyword ul li a' => 'color: {{VALUE}};',
506 ],
507 ]
508 );
509
510 $this->add_control(
511 'bbpc_color_keywords_bg', [
512 'label' => esc_html__( 'Background Color', 'forumax' ),
513 'type' => Controls_Manager::COLOR,
514 'separator' => 'after',
515 'selectors' => [
516 '{{WRAPPER}} .bbpc-search-keyword ul li a' => 'background: {{VALUE}};',
517 ],
518 ]
519 );
520
521 $this->end_controls_tab();
522
523 $this->start_controls_tab(
524 'bbpc_keywords_style_hover',
525 [
526 'label' => esc_html__( 'Hover', 'forumax' ),
527 ]
528 );
529
530 $this->add_control(
531 'bbpc_color_keywords_hover', [
532 'label' => esc_html__( 'Keyword Color', 'forumax' ),
533 'type' => Controls_Manager::COLOR,
534 'selectors' => [
535 '{{WRAPPER}} .bbpc-search-keyword ul li a:hover' => 'color: {{VALUE}};',
536 ],
537 ]
538 );
539
540 $this->add_control(
541 'bbpc_color_keywords_bg_hover', [
542 'label' => esc_html__( 'Background Color', 'forumax' ),
543 'type' => Controls_Manager::COLOR,
544 'selectors' => [
545 '{{WRAPPER}} .bbpc-search-keyword ul li a:hover' => 'background: {{VALUE}};',
546 ],
547 ]
548 );
549
550 $this->end_controls_tabs();
551
552
553 $this->add_group_control(
554 Group_Control_Typography::get_type(), [
555 'name' => 'typography_keywords',
556 'label' => esc_html__( 'Typography', 'forumax' ),
557 'selector' => '{{WRAPPER}} .bbpc-search-keyword ul li a',
558 ]
559 );
560
561 $this->add_control(
562 'keywords_padding', [
563 'label' => __( 'Padding', 'forumax' ),
564 'type' => Controls_Manager::DIMENSIONS,
565 'size_units' => [ 'px', '%', 'em' ],
566 'selectors' => [ '{{WRAPPER}} .bbpc-search-keyword ul li a' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
567 'default' => [
568 'unit' => 'px',
569 ],
570 ]
571 );
572
573 $this->add_control(
574 'border_radius', [
575 'label' => __( 'Border Radius', 'forumax' ),
576 'type' => Controls_Manager::DIMENSIONS,
577 'size_units' => [ 'px', '%', 'em' ],
578 'selectors' => [ '{{WRAPPER}} .bbpc-search-keyword ul li a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};' ],
579 'default' => [
580 'unit' => 'px',
581 ],
582 ]
583 );
584
585 $this->end_controls_section();
586
587 /**
588 * Style — AJAX Search Results
589 */
590 $this->start_controls_section(
591 'style_search_results', [
592 'label' => esc_html__( 'Search Results', 'forumax' ),
593 'tab' => Controls_Manager::TAB_STYLE,
594 'condition' => [
595 'is_ajax_search' => 'yes',
596 ],
597 ]
598 );
599
600 $this->add_control(
601 'results_heading_panel', [
602 'label' => esc_html__( 'Panel', 'forumax' ),
603 'type' => Controls_Manager::HEADING,
604 ]
605 );
606
607 $this->add_control(
608 'results_bg_color', [
609 'label' => esc_html__( 'Background Color', 'forumax' ),
610 'type' => Controls_Manager::COLOR,
611 'selectors' => [
612 '{{WRAPPER}} .bbpc-search-result-container' => 'background-color: {{VALUE}};',
613 ],
614 ]
615 );
616
617 $this->add_group_control(
618 Group_Control_Border::get_type(), [
619 'name' => 'results_border',
620 'label' => esc_html__( 'Border', 'forumax' ),
621 'selector' => '{{WRAPPER}} .bbpc-search-result-container',
622 ]
623 );
624
625 $this->add_responsive_control(
626 'results_border_radius', [
627 'label' => esc_html__( 'Border Radius', 'forumax' ),
628 'type' => Controls_Manager::DIMENSIONS,
629 'size_units' => [ 'px', '%', 'em' ],
630 'selectors' => [
631 '{{WRAPPER}} .bbpc-search-result-container' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
632 ],
633 ]
634 );
635
636 $this->add_control(
637 'results_heading_items', [
638 'label' => esc_html__( 'Result Items', 'forumax' ),
639 'type' => Controls_Manager::HEADING,
640 'separator' => 'before',
641 ]
642 );
643
644 $this->add_control(
645 'results_title_color', [
646 'label' => esc_html__( 'Title Color', 'forumax' ),
647 'type' => Controls_Manager::COLOR,
648 'selectors' => [
649 '{{WRAPPER}} .bbpc-search-result-container .bbpc-result-title' => 'color: {{VALUE}};',
650 ],
651 ]
652 );
653
654 $this->add_control(
655 'results_meta_color', [
656 'label' => esc_html__( 'Meta Color', 'forumax' ),
657 'type' => Controls_Manager::COLOR,
658 'selectors' => [
659 '{{WRAPPER}} .bbpc-search-result-container .bbpc-result-type' => 'color: {{VALUE}};',
660 '{{WRAPPER}} .bbpc-search-result-container .bbpc-breadcrumb-item' => 'color: {{VALUE}};',
661 '{{WRAPPER}} .bbpc-search-result-container .bbpc-result-icon' => 'color: {{VALUE}};',
662 ],
663 ]
664 );
665
666 $this->add_control(
667 'results_hover_bg', [
668 'label' => esc_html__( 'Hover Background', 'forumax' ),
669 'type' => Controls_Manager::COLOR,
670 'selectors' => [
671 '{{WRAPPER}} .bbpc-search-result-container .search-result-item:hover' => 'background-color: {{VALUE}};',
672 ],
673 ]
674 );
675
676 $this->add_control(
677 'results_heading_empty', [
678 'label' => esc_html__( 'Empty State', 'forumax' ),
679 'type' => Controls_Manager::HEADING,
680 'separator' => 'before',
681 ]
682 );
683
684 $this->add_control(
685 'results_empty_title_color', [
686 'label' => esc_html__( 'Title Color', 'forumax' ),
687 'type' => Controls_Manager::COLOR,
688 'selectors' => [
689 '{{WRAPPER}} .bbpc-search-result-container .bbpc-not-found-text' => 'color: {{VALUE}};',
690 ],
691 ]
692 );
693
694 $this->add_control(
695 'results_empty_hint_color', [
696 'label' => esc_html__( 'Hint Color', 'forumax' ),
697 'type' => Controls_Manager::COLOR,
698 'selectors' => [
699 '{{WRAPPER}} .bbpc-search-result-container .bbpc-search-empty-hint' => 'color: {{VALUE}};',
700 ],
701 ]
702 );
703
704 $this->end_controls_section();
705
706 }
707
708 protected function render() {
709 $settings = $this->get_settings();
710 $widget_id = 'frmx-search-' . $this->get_id();
711 $input_id = $widget_id . '-input';
712 $result_id = $widget_id . '-result';
713 $post_type_id = $widget_id . '-post-type';
714
715 /*
716 * $btn_position holds the raw saved value: 'left' or 'right'.
717 * It is used directly — no inversion needed — so the span class
718 * and the input-wrapper class both reflect the actual chosen side.
719 */
720 $btn_position = $settings['submit_btn_align'] ?? 'left';
721
722 $search_post_type = ! empty( $settings['search_post_type'] ) ? $settings['search_post_type'] : 'all';
723 $is_ajax_search = ! empty( $settings['is_ajax_search'] ) ? 'true' : 'false';
724 $search_highlight = ! empty( $settings['search_highlight'] ) ? 'true' : 'false';
725 ?>
726
727 <div class="bbpc-search-overlay" data-widget-id="<?php echo esc_attr( $widget_id ); ?>"></div>
728
729 <form
730 action="<?php echo esc_url( bbp_get_search_url() ); ?>"
731 role="search"
732 method="get"
733 class="bbpc_search_form_wrapper"
734 data-widget-id="<?php echo esc_attr( $widget_id ); ?>"
735 data-input-id="<?php echo esc_attr( $input_id ); ?>"
736 data-result-id="<?php echo esc_attr( $result_id ); ?>"
737 >
738 <div class="form-group">
739 <div class="input-wrapper <?php echo esc_attr( $btn_position ); ?>">
740
741 <span class="submit-btn-<?php echo esc_attr( $btn_position ); ?>">
742 <button type="submit">
743 <?php
744 $submit_btn = $settings['submit_btn_type'] ?? 'icon';
745 if ( 'icon' === $submit_btn ) {
746 \Elementor\Icons_Manager::render_icon( $settings['submit_btn_icon'], [ 'aria-hidden' => 'true' ] );
747 } else {
748 echo esc_html( $settings['submit_btn_text'] );
749 }
750 ?>
751 </button>
752 </span>
753
754 <!-- bbPress search request sentinel -->
755 <input type="hidden" name="action" value="bbp-search-request" />
756
757 <input
758 type="search"
759 id="<?php echo esc_attr( $input_id ); ?>"
760 class="frmx-search-input"
761 autocomplete="off"
762 name="bbp_search"
763 placeholder="<?php echo esc_attr( $settings['placeholder'] ); ?>"
764 data-post-type="<?php echo esc_attr( $search_post_type ); ?>"
765 data-ajax-search="<?php echo esc_attr( $is_ajax_search ); ?>"
766 data-highlight="<?php echo esc_attr( $search_highlight ); ?>"
767 data-result-id="<?php echo esc_attr( $result_id ); ?>"
768 >
769
770 <!-- Ajax Search Loading Spinner -->
771 <?php include( 'Search/search-spinner.php' ); ?>
772
773 <!-- WPML Language Code -->
774 <?php if ( defined( 'ICL_LANGUAGE_CODE' ) ) : ?>
775 <input type="hidden" name="lang" value="<?php echo esc_attr( ICL_LANGUAGE_CODE ); ?>"/>
776 <?php endif; ?>
777 </div>
778 </div>
779 <?php
780 // Pass unique result ID to the partials via a local variable.
781 $frmx_result_id = $result_id;
782 include 'Search/ajax-sarch-results.php';
783 include 'Search/keywords.php';
784 ?>
785 </form>
786 <?php
787 }
788 }