| @@ -17,13 +17,13 @@ | ||
| 17 | 17 | return 'ama_search'; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function get_title() { |
| 21 | - return esc_html__( 'Search (Forumax)', 'forumax' ); | |
| 21 | + return esc_html__( 'Forumax Search', 'forumax' ); | |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | public function get_icon() { |
| 25 | - return 'bbpc_icon_ama_search eicon-search'; | |
| 25 | + return 'bbpc_icon_ama_search'; | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function get_style_depends() { |
| 29 | 29 | return [ 'ama-core-style', 'bbpc-el-widgets' ]; |
| @@ -53,48 +53,8 @@ | ||
| 53 | 53 | 'default' => 'Search for Topics....', |
| 54 | 54 | ] |
| 55 | 55 | ); |
| 56 | 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' => '', | |
| 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 | 57 | // select controls |
| 98 | 58 | $this->add_control( |
| 99 | 59 | 'submit_btn_type', [ |
| 100 | 60 | 'label' => __( 'Search Type', 'forumax' ), |
| @@ -137,19 +97,19 @@ | ||
| 137 | 97 | 'submit_btn_align', [ |
| 138 | 98 | 'label' => __( 'Submit Alignment', 'forumax' ), |
| 139 | 99 | 'type' => \Elementor\Controls_Manager::CHOOSE, |
| 140 | 100 | 'options' => [ |
| 141 | - 'left' => [ | |
| 101 | + 'right' => [ | |
| 142 | 102 | 'title' => __( 'Left', 'forumax' ), |
| 143 | 103 | 'icon' => 'fa fa-align-left', |
| 144 | 104 | ], |
| 145 | - 'right' => [ | |
| 105 | + 'left' => [ | |
| 146 | 106 | 'title' => __( 'Right', 'forumax' ), |
| 147 | 107 | 'icon' => 'fa fa-align-right', |
| 148 | 108 | ], |
| 149 | 109 | ], |
| 150 | 110 | 'toggle' => false, |
| 151 | - 'default' => 'left', | |
| 111 | + 'default' => 'left' | |
| 152 | 112 | ] |
| 153 | 113 | ); |
| 154 | 114 | |
| 155 | 115 | $this->add_control( |
| @@ -390,9 +350,9 @@ | ||
| 390 | 350 | ] |
| 391 | 351 | ); |
| 392 | 352 | |
| 393 | 353 | |
| 394 | - // Spacing slider when icon is on the LEFT. | |
| 354 | + // slider controls | |
| 395 | 355 | $this->add_control( |
| 396 | 356 | 'submit_btn_align_left', [ |
| 397 | 357 | 'label' => esc_html__( 'Spacing', 'forumax' ), |
| 398 | 358 | 'type' => Controls_Manager::SLIDER, |
| @@ -397,22 +357,23 @@ | ||
| 397 | 357 | 'label' => esc_html__( 'Spacing', 'forumax' ), |
| 398 | 358 | 'type' => Controls_Manager::SLIDER, |
| 399 | 359 | 'range' => [ |
| 400 | 360 | 'px' => [ |
| 401 | - 'min' => 0, | |
| 361 | + 'min' => 10, | |
| 402 | 362 | 'max' => 100, |
| 403 | 363 | ], |
| 404 | 364 | ], |
| 405 | 365 | 'selectors' => [ |
| 406 | - '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper .submit-btn-left' => 'left: {{SIZE}}{{UNIT}};', | |
| 366 | + '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper .submit-btn-left' => 'right: {{SIZE}}{{UNIT}};', | |
| 407 | 367 | ], |
| 408 | 368 | 'condition' => [ |
| 409 | - 'submit_btn_align' => 'left', | |
| 369 | + 'submit_btn_align' => 'left' | |
| 410 | 370 | ], |
| 411 | 371 | ] |
| 412 | 372 | ); |
| 413 | 373 | |
| 414 | - // Spacing slider when icon is on the RIGHT. | |
| 374 | + | |
| 375 | + // slider controls | |
| 415 | 376 | $this->add_control( |
| 416 | 377 | 'submit_btn_align_right', [ |
| 417 | 378 | 'label' => esc_html__( 'Spacing', 'forumax' ), |
| 418 | 379 | 'type' => Controls_Manager::SLIDER, |
| @@ -417,17 +378,17 @@ | ||
| 417 | 378 | 'label' => esc_html__( 'Spacing', 'forumax' ), |
| 418 | 379 | 'type' => Controls_Manager::SLIDER, |
| 419 | 380 | 'range' => [ |
| 420 | 381 | 'px' => [ |
| 421 | - 'min' => 0, | |
| 382 | + 'min' => 10, | |
| 422 | 383 | 'max' => 100, |
| 423 | 384 | ], |
| 424 | 385 | ], |
| 425 | 386 | 'selectors' => [ |
| 426 | - '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper .submit-btn-right' => 'right: {{SIZE}}{{UNIT}};', | |
| 387 | + '{{WRAPPER}} .bbpc_search_form_wrapper .input-wrapper .submit-btn-right' => 'left: {{SIZE}}{{UNIT}};', | |
| 427 | 388 | ], |
| 428 | 389 | 'condition' => [ |
| 429 | - 'submit_btn_align' => 'right', | |
| 390 | + 'submit_btn_align' => 'right' | |
| 430 | 391 | ], |
| 431 | 392 | ] |
| 432 | 393 | ); |
| 433 | 394 | |
| @@ -586,84 +547,52 @@ | ||
| 586 | 547 | |
| 587 | 548 | } |
| 588 | 549 | |
| 589 | 550 | protected function render() { |
| 590 | - $settings = $this->get_settings(); | |
| 591 | - $widget_id = 'frmx-search-' . $this->get_id(); | |
| 592 | - $input_id = $widget_id . '-input'; | |
| 593 | - $result_id = $widget_id . '-result'; | |
| 594 | - $post_type_id = $widget_id . '-post-type'; | |
| 595 | - | |
| 596 | - /* | |
| 597 | - * $btn_position holds the raw saved value: 'left' or 'right'. | |
| 598 | - * It is used directly — no inversion needed — so the span class | |
| 599 | - * and the input-wrapper class both reflect the actual chosen side. | |
| 600 | - */ | |
| 601 | - $btn_position = $settings['submit_btn_align'] ?? 'left'; | |
| 602 | - | |
| 603 | - $search_post_type = ! empty( $settings['search_post_type'] ) ? $settings['search_post_type'] : 'all'; | |
| 604 | - $is_ajax_search = ! empty( $settings['is_ajax_search'] ) ? 'true' : 'false'; | |
| 605 | - $search_highlight = ! empty( $settings['search_highlight'] ) ? 'true' : 'false'; | |
| 551 | + $settings = $this->get_settings(); | |
| 552 | + $title_tag = ! empty( $settings['title_tag'] ) ? $settings['title_tag'] : 'h2'; | |
| 553 | + $cross_position = $settings['submit_btn_align'] ?? 'right'; | |
| 554 | + if ( $cross_position == 'right' ) { | |
| 555 | + $cross_position = 'left'; | |
| 556 | + } else { | |
| 557 | + $cross_position = 'right'; | |
| 558 | + } | |
| 606 | 559 | ?> |
| 607 | - | |
| 608 | - <div class="bbpc-search-overlay" data-widget-id="<?php echo esc_attr( $widget_id ); ?>"></div> | |
| 609 | - | |
| 610 | - <form | |
| 611 | - action="<?php echo esc_url( bbp_get_search_url() ); ?>" | |
| 612 | - role="search" | |
| 613 | - method="get" | |
| 614 | - class="bbpc_search_form_wrapper" | |
| 615 | - data-widget-id="<?php echo esc_attr( $widget_id ); ?>" | |
| 616 | - data-input-id="<?php echo esc_attr( $input_id ); ?>" | |
| 617 | - data-result-id="<?php echo esc_attr( $result_id ); ?>" | |
| 618 | - > | |
| 619 | - <div class="form-group"> | |
| 620 | - <div class="input-wrapper <?php echo esc_attr( $btn_position ); ?>"> | |
| 621 | - | |
| 622 | - <span class="submit-btn-<?php echo esc_attr( $btn_position ); ?>"> | |
| 623 | - <button type="submit"> | |
| 560 | + | |
| 561 | + <div class="bbpc-search-overlay"></div> | |
| 562 | + | |
| 563 | + <form action="<?php echo esc_url( home_url( '/' ) ) ?>" role="search" method="get" class="bbpc_search_form_wrapper"> | |
| 564 | + <div class="form-group"> | |
| 565 | + <div class="input-wrapper <?php echo esc_attr( $cross_position ); ?>"> | |
| 566 | + | |
| 567 | + <span class="submit-btn-<?php echo esc_attr( $settings['submit_btn_align'] ?? 'left' ); ?>"> | |
| 568 | + <button type="submit"> | |
| 624 | 569 | <?php |
| 625 | 570 | $submit_btn = $settings['submit_btn_type'] ?? 'icon'; |
| 626 | - if ( 'icon' === $submit_btn ) { | |
| 571 | + if ( $submit_btn == 'icon' ) { | |
| 627 | 572 | \Elementor\Icons_Manager::render_icon( $settings['submit_btn_icon'], [ 'aria-hidden' => 'true' ] ); |
| 628 | 573 | } else { |
| 629 | 574 | echo esc_html( $settings['submit_btn_text'] ); |
| 630 | 575 | } |
| 631 | 576 | ?> |
| 632 | - </button> | |
| 577 | + </button> | |
| 633 | 578 | </span> |
| 634 | 579 | |
| 635 | - <!-- bbPress search request sentinel --> | |
| 636 | - <input type="hidden" name="action" value="bbp-search-request" /> | |
| 580 | + <input type='search' id="searchInput" autocomplete="off" name="s" placeholder="<?php echo esc_attr( $settings['placeholder'] ) ?>"> | |
| 637 | 581 | |
| 638 | - <input | |
| 639 | - type="search" | |
| 640 | - id="<?php echo esc_attr( $input_id ); ?>" | |
| 641 | - class="frmx-search-input" | |
| 642 | - autocomplete="off" | |
| 643 | - name="bbp_search" | |
| 644 | - placeholder="<?php echo esc_attr( $settings['placeholder'] ); ?>" | |
| 645 | - data-post-type="<?php echo esc_attr( $search_post_type ); ?>" | |
| 646 | - data-ajax-search="<?php echo esc_attr( $is_ajax_search ); ?>" | |
| 647 | - data-highlight="<?php echo esc_attr( $search_highlight ); ?>" | |
| 648 | - data-result-id="<?php echo esc_attr( $result_id ); ?>" | |
| 649 | - > | |
| 650 | - | |
| 651 | - <!-- Ajax Search Loading Spinner --> | |
| 582 | + <!-- Ajax Search Loading Spinner --> | |
| 652 | 583 | <?php include( 'Search/search-spinner.php' ); ?> |
| 653 | 584 | |
| 654 | - <!-- WPML Language Code --> | |
| 585 | + <!-- WPML Language Code --> | |
| 655 | 586 | <?php if ( defined( 'ICL_LANGUAGE_CODE' ) ) : ?> |
| 656 | - <input type="hidden" name="lang" value="<?php echo esc_attr( ICL_LANGUAGE_CODE ); ?>"/> | |
| 587 | + <input type="hidden" name="lang" value="<?php echo esc_attr( ICL_LANGUAGE_CODE ); ?>"/> | |
| 657 | 588 | <?php endif; ?> |
| 658 | - </div> | |
| 659 | - </div> | |
| 660 | - <?php | |
| 661 | - // Pass unique result ID to the partials via a local variable. | |
| 662 | - $frmx_result_id = $result_id; | |
| 663 | - include 'Search/ajax-sarch-results.php'; | |
| 664 | - include 'Search/keywords.php'; | |
| 665 | - ?> | |
| 666 | - </form> | |
| 589 | + | |
| 590 | + <input type="hidden" id="hidden_post_type" name="post_type" value="docs"/> | |
| 591 | + </div> | |
| 592 | + </div> | |
| 593 | + <?php include( 'Search/ajax-sarch-results.php' ); ?> | |
| 594 | + <?php include( 'Search/keywords.php' ); ?> | |
| 595 | + </form> | |
| 667 | 596 | <?php |
| 668 | 597 | } |
| 669 | 598 | } |