| @@ -29,9 +29,9 @@ | ||
| 29 | 29 | return [ 'ama-core-style', 'bbpc-el-widgets' ]; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function get_script_depends() { |
| 33 | - return [ 'bbpc-frontend-js', 'bbpc-frontend-js' ]; | |
| 33 | + return [ 'bbpc-frontend' ]; | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | public function get_categories() { |
| 37 | 37 | return [ 'forumax' ]; |
| @@ -57,10 +57,11 @@ | ||
| 57 | 57 | $this->add_control( |
| 58 | 58 | 'search_post_type', [ |
| 59 | 59 | 'label' => esc_html__( 'Post Type', 'forumax' ), |
| 60 | 60 | 'type' => Controls_Manager::SELECT, |
| 61 | - 'default' => 'forum', | |
| 61 | + 'default' => 'all', | |
| 62 | 62 | 'options' => [ |
| 63 | + 'all' => esc_html__( 'All (Forums, Topics & Replies)', 'forumax' ), | |
| 63 | 64 | 'forum' => esc_html__( 'Forum', 'forumax' ), |
| 64 | 65 | 'topic' => esc_html__( 'Topic', 'forumax' ), |
| 65 | 66 | 'reply' => esc_html__( 'Reply', 'forumax' ), |
| 66 | 67 | 'post' => esc_html__( 'Post', 'forumax' ), |
| @@ -75,9 +76,9 @@ | ||
| 75 | 76 | 'label' => esc_html__( 'AJAX Live Search', 'forumax' ), |
| 76 | 77 | 'description' => esc_html__( 'Show search results instantly as users type without page reload.', 'forumax' ), |
| 77 | 78 | 'type' => Controls_Manager::SWITCHER, |
| 78 | 79 | 'return_value' => 'yes', |
| 79 | - 'default' => '', | |
| 80 | + 'default' => 'yes', | |
| 80 | 81 | ] |
| 81 | 82 | ); |
| 82 | 83 | |
| 83 | 84 | $this->add_control( |
| @@ -111,9 +112,9 @@ | ||
| 111 | 112 | 'label' => __( 'Submit Button Icon', 'forumax' ), |
| 112 | 113 | 'type' => \Elementor\Controls_Manager::ICONS, |
| 113 | 114 | 'default' => [ |
| 114 | 115 | 'value' => 'fas fa-search', |
| 115 | - 'library' => 'solid', | |
| 116 | + 'library' => 'fa-solid', | |
| 116 | 117 | ], |
| 117 | 118 | 'condition' => [ |
| 118 | 119 | 'submit_btn_type' => 'icon' |
| 119 | 120 | ] |
| @@ -582,8 +583,127 @@ | ||
| 582 | 583 | ); |
| 583 | 584 | |
| 584 | 585 | $this->end_controls_section(); |
| 585 | 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 | + | |
| 586 | 706 | } |
| 587 | 707 | |
| 588 | 708 | protected function render() { |
| 589 | 709 | $settings = $this->get_settings(); |
| @@ -598,9 +718,9 @@ | ||
| 598 | 718 | * and the input-wrapper class both reflect the actual chosen side. |
| 599 | 719 | */ |
| 600 | 720 | $btn_position = $settings['submit_btn_align'] ?? 'left'; |
| 601 | 721 | |
| 602 | - $search_post_type = ! empty( $settings['search_post_type'] ) ? $settings['search_post_type'] : 'forum'; | |
| 722 | + $search_post_type = ! empty( $settings['search_post_type'] ) ? $settings['search_post_type'] : 'all'; | |
| 603 | 723 | $is_ajax_search = ! empty( $settings['is_ajax_search'] ) ? 'true' : 'false'; |
| 604 | 724 | $search_highlight = ! empty( $settings['search_highlight'] ) ? 'true' : 'false'; |
| 605 | 725 | ?> |
| 606 | 726 | |
| @@ -606,9 +726,9 @@ | ||
| 606 | 726 | |
| 607 | 727 | <div class="bbpc-search-overlay" data-widget-id="<?php echo esc_attr( $widget_id ); ?>"></div> |
| 608 | 728 | |
| 609 | 729 | <form |
| 610 | - action="<?php echo esc_url( home_url( '/' ) ); ?>" | |
| 730 | + action="<?php echo esc_url( bbp_get_search_url() ); ?>" | |
| 611 | 731 | role="search" |
| 612 | 732 | method="get" |
| 613 | 733 | class="bbpc_search_form_wrapper" |
| 614 | 734 | data-widget-id="<?php echo esc_attr( $widget_id ); ?>" |
| @@ -630,14 +750,17 @@ | ||
| 630 | 750 | ?> |
| 631 | 751 | </button> |
| 632 | 752 | </span> |
| 633 | 753 | |
| 754 | + <!-- bbPress search request sentinel --> | |
| 755 | + <input type="hidden" name="action" value="bbp-search-request" /> | |
| 756 | + | |
| 634 | 757 | <input |
| 635 | 758 | type="search" |
| 636 | 759 | id="<?php echo esc_attr( $input_id ); ?>" |
| 637 | 760 | class="frmx-search-input" |
| 638 | 761 | autocomplete="off" |
| 639 | - name="s" | |
| 762 | + name="bbp_search" | |
| 640 | 763 | placeholder="<?php echo esc_attr( $settings['placeholder'] ); ?>" |
| 641 | 764 | data-post-type="<?php echo esc_attr( $search_post_type ); ?>" |
| 642 | 765 | data-ajax-search="<?php echo esc_attr( $is_ajax_search ); ?>" |
| 643 | 766 | data-highlight="<?php echo esc_attr( $search_highlight ); ?>" |
| @@ -650,15 +773,8 @@ | ||
| 650 | 773 | <!-- WPML Language Code --> |
| 651 | 774 | <?php if ( defined( 'ICL_LANGUAGE_CODE' ) ) : ?> |
| 652 | 775 | <input type="hidden" name="lang" value="<?php echo esc_attr( ICL_LANGUAGE_CODE ); ?>"/> |
| 653 | 776 | <?php endif; ?> |
| 654 | - | |
| 655 | - <input | |
| 656 | - type="hidden" | |
| 657 | - id="<?php echo esc_attr( $post_type_id ); ?>" | |
| 658 | - name="post_type" | |
| 659 | - value="<?php echo esc_attr( $search_post_type ); ?>" | |
| 660 | - /> | |
| 661 | 777 | </div> |
| 662 | 778 | </div> |
| 663 | 779 | <?php |
| 664 | 780 | // Pass unique result ID to the partials via a local variable. |