| @@ -14,13 +14,14 @@ | ||
| 14 | 14 | $is_keywords = isset($attributes['is_keywords']) ? $attributes['is_keywords'] : true; |
| 15 | 15 | $keywords_label = isset($attributes['keywords_label']) ? $attributes['keywords_label'] : 'Popular:'; |
| 16 | 16 | $keywords_align = isset($attributes['keywords_align']) ? $attributes['keywords_align'] : 'center'; |
| 17 | 17 | $keywords = isset($attributes['keywords']) ? $attributes['keywords'] : [['title' => 'Keyword #1'], ['title' => 'Keyword #2']]; |
| 18 | - $search_post_type = isset($attributes['search_post_type']) ? $attributes['search_post_type'] : 'forum'; | |
| 18 | + $search_post_type = isset($attributes['search_post_type']) ? $attributes['search_post_type'] : 'docs'; | |
| 19 | 19 | |
| 20 | - $is_pro_active = function_exists( 'forumax_is_premium' ) && forumax_is_premium(); | |
| 21 | - $search_highlight = ! empty( $attributes['search_highlight'] ) ? 'true' : 'false'; | |
| 22 | - $is_ajax_search = ! empty( $attributes['is_ajax_search'] ) ? 'true' : 'false'; | |
| 20 | + // AJAX Search and Highlight are Pro-only features. | |
| 21 | + $is_pro_active = class_exists( 'Forumax_Pro' ) && function_exists( 'bc_fs' ) && bc_fs()->can_use_premium_code(); | |
| 22 | + $search_highlight = ( $is_pro_active && ! empty( $attributes['search_highlight'] ) ) ? 'true' : 'false'; | |
| 23 | + $is_ajax_search = ( $is_pro_active && ! empty( $attributes['is_ajax_search'] ) ) ? 'true' : 'false'; | |
| 23 | 24 | |
| 24 | 25 | // Enforce free defaults for Pro-gated attributes. |
| 25 | 26 | if ( ! $is_pro_active ) { |
| 26 | 27 | $search_post_type = 'forum'; |
| @@ -26,18 +27,15 @@ | ||
| 26 | 27 | $search_post_type = 'forum'; |
| 27 | 28 | unset( $attributes['wrapper_max_width'] ); |
| 28 | 29 | } |
| 29 | 30 | |
| 30 | - $unique_id = uniqid( 'bbpc-search-' ); | |
| 31 | - $widget_id = $unique_id; | |
| 32 | - $input_id = $widget_id . '-input'; | |
| 33 | - $result_id = $widget_id . '-result'; | |
| 34 | - $post_type_id = $widget_id . '-post-type'; | |
| 31 | + $unique_id = uniqid('bbpc-search-'); | |
| 35 | 32 | |
| 33 | + $cross_position = $submit_btn_align == 'right' ? 'left' : 'right'; | |
| 36 | 34 | |
| 37 | 35 | // Include dependencies. |
| 38 | 36 | if ( ! wp_style_is( 'bbpc-el-widgets', 'registered' ) ) { |
| 39 | - wp_register_style( 'bbpc-el-widgets', FORUMAX_STYLES . 'frontend/el-widgets.css', array(), FORUMAX_VERSION ); | |
| 37 | + wp_register_style( 'bbpc-el-widgets', FORUMAX_FRONT_ASS . 'css/el-widgets.css' ); | |
| 40 | 38 | } |
| 41 | 39 | wp_enqueue_style( 'bbpc-el-widgets' ); |
| 42 | 40 | |
| 43 | 41 | wp_enqueue_script( 'bbpc-frontend-js', FORUMAX_FRONT_ASS . 'js/frontend.js', array( 'jquery' ), FORUMAX_VERSION, true ); |
| @@ -54,21 +52,13 @@ | ||
| 54 | 52 | |
| 55 | 53 | ob_start(); |
| 56 | 54 | ?> |
| 57 | 55 | <div <?php echo $wrapper_attributes; ?>> |
| 58 | - <div class="bbpc-search-overlay" data-widget-id="<?php echo esc_attr( $widget_id ); ?>"></div> | |
| 56 | + <div class="bbpc-search-overlay"></div> | |
| 59 | 57 | |
| 60 | - <form | |
| 61 | - action="<?php echo esc_url( bbp_get_search_url() ); ?>" | |
| 62 | - role="search" | |
| 63 | - method="get" | |
| 64 | - class="bbpc_search_form_wrapper" | |
| 65 | - data-widget-id="<?php echo esc_attr( $widget_id ); ?>" | |
| 66 | - data-input-id="<?php echo esc_attr( $input_id ); ?>" | |
| 67 | - data-result-id="<?php echo esc_attr( $result_id ); ?>" | |
| 68 | - > | |
| 58 | + <form action="<?php echo esc_url(home_url('/')) ?>" role="search" method="get" class="bbpc_search_form_wrapper"> | |
| 69 | 59 | <div class="form-group"> |
| 70 | - <div class="input-wrapper <?php echo esc_attr( $submit_btn_align ); ?>"> | |
| 60 | + <div class="input-wrapper <?php echo esc_attr($cross_position); ?>"> | |
| 71 | 61 | |
| 72 | 62 | <span class="submit-btn-<?php echo esc_attr($submit_btn_align); ?>"> |
| 73 | 63 | <button type="submit"> |
| 74 | 64 | <?php |
| @@ -85,33 +75,32 @@ | ||
| 85 | 75 | ?> |
| 86 | 76 | </button> |
| 87 | 77 | </span> |
| 88 | 78 | |
| 89 | - <!-- bbPress search request sentinel --> | |
| 90 | - <input type="hidden" name="action" value="bbp-search-request" /> | |
| 91 | - | |
| 92 | - <input type='search' id="<?php echo esc_attr( $input_id ); ?>" class="frmx-search-input" autocomplete="off" name="bbp_search" | |
| 79 | + <input type='search' id="searchInput" autocomplete="off" name="s" | |
| 93 | 80 | placeholder="<?php echo esc_attr( $placeholder ); ?>" |
| 94 | 81 | data-post-type="<?php echo esc_attr( $search_post_type ); ?>" |
| 95 | 82 | data-highlight="<?php echo esc_attr( $search_highlight ); ?>" |
| 96 | - data-ajax-search="<?php echo esc_attr( $is_ajax_search ); ?>" | |
| 97 | - data-result-id="<?php echo esc_attr( $result_id ); ?>"> | |
| 83 | + data-ajax-search="<?php echo esc_attr( $is_ajax_search ); ?>"> | |
| 98 | 84 | |
| 99 | 85 | <!-- Ajax Search Loading Spinner --> |
| 100 | - <span class="spinner" aria-hidden="true"> | |
| 101 | - <svg class="frmx-spinner-icon" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"> | |
| 102 | - <circle cx="12" cy="12" r="10" stroke-opacity="0.2" /> | |
| 103 | - <path d="M12 2a10 10 0 0 1 10 10" /> | |
| 104 | - </svg> | |
| 105 | - </span> | |
| 86 | + <div class="spinner"> | |
| 87 | + <div class="bounce1"></div> | |
| 88 | + <div class="bounce2"></div> | |
| 89 | + <div class="bounce3"></div> | |
| 90 | + </div> | |
| 106 | 91 | |
| 107 | 92 | <!-- WPML Language Code --> |
| 108 | 93 | <?php if (defined('ICL_LANGUAGE_CODE')): ?> |
| 109 | 94 | <input type="hidden" name="lang" value="<?php echo esc_attr(ICL_LANGUAGE_CODE); ?>" /> |
| 110 | 95 | <?php endif; ?> |
| 96 | + | |
| 97 | + <?php if ( ! empty( $search_post_type ) ) : ?> | |
| 98 | + <input type="hidden" id="hidden_post_type" name="post_type" value="<?php echo esc_attr( $search_post_type ); ?>" /> | |
| 99 | + <?php endif; ?> | |
| 111 | 100 | </div> |
| 112 | 101 | </div> |
| 113 | - <div id="<?php echo esc_attr( $result_id ); ?>" class="bbpc-search-result-container" data-noresult="<?php esc_attr_e( 'No Results Found', 'forumax' ); ?>"></div> | |
| 102 | + <div id="bbpc-search-result"></div> | |
| 114 | 103 | |
| 115 | 104 | <?php if ($is_keywords): ?> |
| 116 | 105 | <?php if ( $is_pro_active ): ?> |
| 117 | 106 | <div class="bbpc-search-keyword"> |
| @@ -319,9 +308,9 @@ | ||
| 319 | 308 | <?php endif; ?> |
| 320 | 309 | |
| 321 | 310 | /* Search Results Dropdown */ |
| 322 | 311 | <?php if ( ! empty( $attributes['results_bg_color'] ) ) : ?> |
| 323 | - #<?php echo esc_attr( $unique_id ); ?> #<?php echo esc_attr( $result_id ); ?> { | |
| 312 | + #<?php echo esc_attr( $unique_id ); ?> #bbpc-search-result { | |
| 324 | 313 | background: |
| 325 | 314 | <?php echo esc_attr( $attributes['results_bg_color'] ); ?> |
| 326 | 315 | ; |
| 327 | 316 | } |
| @@ -327,9 +316,9 @@ | ||
| 327 | 316 | } |
| 328 | 317 | <?php endif; ?> |
| 329 | 318 | |
| 330 | 319 | <?php if ( ! empty( $attributes['results_border_color'] ) ) : ?> |
| 331 | - #<?php echo esc_attr( $unique_id ); ?> #<?php echo esc_attr( $result_id ); ?> { | |
| 320 | + #<?php echo esc_attr( $unique_id ); ?> #bbpc-search-result { | |
| 332 | 321 | border-color: |
| 333 | 322 | <?php echo esc_attr( $attributes['results_border_color'] ); ?> |
| 334 | 323 | ; |
| 335 | 324 | } |
| @@ -335,10 +324,10 @@ | ||
| 335 | 324 | } |
| 336 | 325 | <?php endif; ?> |
| 337 | 326 | |
| 338 | 327 | <?php if ( ! empty( $attributes['results_text_color'] ) ) : ?> |
| 339 | - #<?php echo esc_attr( $unique_id ); ?> #<?php echo esc_attr( $result_id ); ?>, | |
| 340 | - #<?php echo esc_attr( $unique_id ); ?> #<?php echo esc_attr( $result_id ); ?> a, | |
| 328 | + #<?php echo esc_attr( $unique_id ); ?> #bbpc-search-result, | |
| 329 | + #<?php echo esc_attr( $unique_id ); ?> #bbpc-search-result a, | |
| 341 | 330 | #<?php echo esc_attr( $unique_id ); ?> .search-result-item a { |
| 342 | 331 | color: |
| 343 | 332 | <?php echo esc_attr( $attributes['results_text_color'] ); ?> |
| 344 | 333 | ; |
| @@ -353,9 +342,9 @@ | ||
| 353 | 342 | } |
| 354 | 343 | <?php endif; ?> |
| 355 | 344 | |
| 356 | 345 | <?php if ( isset( $attributes['results_border_radius'] ) ) : ?> |
| 357 | - #<?php echo esc_attr( $unique_id ); ?> #<?php echo esc_attr( $result_id ); ?> { | |
| 346 | + #<?php echo esc_attr( $unique_id ); ?> #bbpc-search-result { | |
| 358 | 347 | border-radius: |
| 359 | 348 | <?php echo esc_attr( $attributes['results_border_radius'] ); ?>px |
| 360 | 349 | ; |
| 361 | 350 | } |
| @@ -379,5 +368,5 @@ | ||
| 379 | 368 | </style> |
| 380 | 369 | <?php |
| 381 | 370 | return ob_get_clean(); |
| 382 | 371 | } |
| 383 | -} | |
| 372 | +} | |