Version Description
( 2022-04-25 ) = * Update - Tested with WC 6.4 * Update - Support for Avada theme and Avada Builder * Dev - Add aws_relevance_scores filter
Download this release
Release Info
Developer | Mihail Barinov |
Plugin | Advanced Woo Search |
Version | 2.53 |
Comparing to | |
See all releases |
Code changes from version 2.52 to 2.53
- advanced-woo-search.php +3 -3
- includes/class-aws-helpers.php +28 -0
- includes/class-aws-integrations.php +5 -123
- includes/class-aws-search.php +24 -13
- includes/modules/class-aws-avada.php +199 -0
- readme.txt +7 -2
advanced-woo-search.php
CHANGED
@@ -3,12 +3,12 @@
|
|
3 |
/*
|
4 |
Plugin Name: Advanced Woo Search
|
5 |
Description: Advance ajax WooCommerce product search.
|
6 |
-
Version: 2.
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: advanced-woo-search
|
10 |
WC requires at least: 3.0.0
|
11 |
-
WC tested up to: 6.
|
12 |
*/
|
13 |
|
14 |
|
@@ -96,7 +96,7 @@ final class AWS_Main {
|
|
96 |
*/
|
97 |
private function define_constants() {
|
98 |
|
99 |
-
$this->define( 'AWS_VERSION', '2.
|
100 |
|
101 |
$this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
|
102 |
$this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
|
3 |
/*
|
4 |
Plugin Name: Advanced Woo Search
|
5 |
Description: Advance ajax WooCommerce product search.
|
6 |
+
Version: 2.53
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: advanced-woo-search
|
10 |
WC requires at least: 3.0.0
|
11 |
+
WC tested up to: 6.4.0
|
12 |
*/
|
13 |
|
14 |
|
96 |
*/
|
97 |
private function define_constants() {
|
98 |
|
99 |
+
$this->define( 'AWS_VERSION', '2.53' );
|
100 |
|
101 |
$this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
|
102 |
$this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
|
includes/class-aws-helpers.php
CHANGED
@@ -968,6 +968,34 @@ if ( ! class_exists( 'AWS_Helpers' ) ) :
|
|
968 |
|
969 |
}
|
970 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
}
|
972 |
|
973 |
endif;
|
968 |
|
969 |
}
|
970 |
|
971 |
+
/**
|
972 |
+
* Get array of relevance scores
|
973 |
+
* @return array $relevance_array
|
974 |
+
*/
|
975 |
+
static public function get_relevance_scores( $data ) {
|
976 |
+
|
977 |
+
$relevance_array = array(
|
978 |
+
'title' => 200,
|
979 |
+
'content' => 100,
|
980 |
+
'id' => 300,
|
981 |
+
'sku' => 300,
|
982 |
+
'other' => 35
|
983 |
+
);
|
984 |
+
|
985 |
+
/**
|
986 |
+
* Change relevance scores for product search fields
|
987 |
+
* @since 2.53
|
988 |
+
* @param array $relevance_array Array of relevance scores
|
989 |
+
* @param array $data Array of search query related data
|
990 |
+
*/
|
991 |
+
$relevance_array_filtered = apply_filters( 'aws_relevance_scores', $relevance_array, $data );
|
992 |
+
|
993 |
+
$relevance_array = shortcode_atts( $relevance_array, $relevance_array_filtered, 'aws_relevance_scores' );
|
994 |
+
|
995 |
+
return $relevance_array;
|
996 |
+
|
997 |
+
}
|
998 |
+
|
999 |
}
|
1000 |
|
1001 |
endif;
|
includes/class-aws-integrations.php
CHANGED
@@ -100,11 +100,6 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
100 |
add_action( 'wp_head', array( $this, 'oceanwp_head_action' ) );
|
101 |
}
|
102 |
|
103 |
-
// Avada theme
|
104 |
-
if ( class_exists( 'Avada' ) ) {
|
105 |
-
add_action( 'wp_head', array( $this, 'avada_head_action' ) );
|
106 |
-
}
|
107 |
-
|
108 |
// Twenty Twenty theme
|
109 |
if ( function_exists( 'twentytwenty_theme_support' ) ) {
|
110 |
add_action( 'wp_head', array( $this, 'twenty_twenty_head_action' ) );
|
@@ -230,12 +225,6 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
230 |
add_filter( "option_psad_shop_page_enable", array( $this, 'psad_filter' ) );
|
231 |
}
|
232 |
|
233 |
-
if ( 'Avada' === $this->current_theme ) {
|
234 |
-
add_filter( 'aws_posts_per_page', array( $this, 'avada_posts_per_page' ), 2 );
|
235 |
-
add_filter( 'aws_products_order_by', array( $this, 'avada_aws_products_order_by' ), 1 );
|
236 |
-
add_filter( 'post_class', array( $this, 'avada_post_class' ) );
|
237 |
-
}
|
238 |
-
|
239 |
if ( 'Electro' === $this->current_theme ) {
|
240 |
add_filter( 'aws_searchbox_markup', array( $this, 'electro_searchbox_markup' ), 1, 2 );
|
241 |
}
|
@@ -372,6 +361,11 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
372 |
include_once( AWS_DIR . '/includes/modules/class-aws-astra.php' );
|
373 |
}
|
374 |
|
|
|
|
|
|
|
|
|
|
|
375 |
}
|
376 |
|
377 |
/*
|
@@ -674,47 +668,6 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
674 |
|
675 |
<?php }
|
676 |
|
677 |
-
/*
|
678 |
-
* Avada wp theme
|
679 |
-
*/
|
680 |
-
public function avada_head_action() { ?>
|
681 |
-
|
682 |
-
<style>
|
683 |
-
|
684 |
-
.fusion-flyout-search .aws-container {
|
685 |
-
margin: 0 auto;
|
686 |
-
padding: 0;
|
687 |
-
width: 100%;
|
688 |
-
width: calc(100% - 40px);
|
689 |
-
max-width: 600px;
|
690 |
-
position: absolute;
|
691 |
-
top: 40%;
|
692 |
-
left: 20px;
|
693 |
-
right: 20px;
|
694 |
-
}
|
695 |
-
|
696 |
-
</style>
|
697 |
-
|
698 |
-
<script>
|
699 |
-
|
700 |
-
window.addEventListener('load', function() {
|
701 |
-
var awsSearch = document.querySelectorAll(".fusion-menu .fusion-main-menu-search a, .fusion-flyout-menu-icons .fusion-icon-search");
|
702 |
-
if ( awsSearch ) {
|
703 |
-
for (var i = 0; i < awsSearch.length; i++) {
|
704 |
-
awsSearch[i].addEventListener('click', function() {
|
705 |
-
window.setTimeout(function(){
|
706 |
-
document.querySelector(".fusion-menu .fusion-main-menu-search .aws-search-field, .fusion-flyout-search .aws-search-field").focus();
|
707 |
-
}, 100);
|
708 |
-
}, false);
|
709 |
-
}
|
710 |
-
}
|
711 |
-
|
712 |
-
}, false);
|
713 |
-
|
714 |
-
</script>
|
715 |
-
|
716 |
-
<?php }
|
717 |
-
|
718 |
/*
|
719 |
* Twenty Twenty theme
|
720 |
*/
|
@@ -1875,77 +1828,6 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
|
|
1875 |
return $value;
|
1876 |
}
|
1877 |
|
1878 |
-
/*
|
1879 |
-
* Avada theme posts per page option
|
1880 |
-
*/
|
1881 |
-
public function avada_posts_per_page( $posts_per_page ) {
|
1882 |
-
$num = 12;
|
1883 |
-
$search_page_res_per_page = AWS()->get_settings( 'search_page_res_per_page' );
|
1884 |
-
if ( $search_page_res_per_page ) {
|
1885 |
-
$num = intval( $search_page_res_per_page );
|
1886 |
-
}
|
1887 |
-
$posts_per_page = isset( $_GET['product_count'] ) && intval( sanitize_text_field( $_GET['product_count'] ) ) ? intval( sanitize_text_field( $_GET['product_count'] ) ) : $num;
|
1888 |
-
return $posts_per_page;
|
1889 |
-
}
|
1890 |
-
|
1891 |
-
/*
|
1892 |
-
* Avada theme order by options
|
1893 |
-
*/
|
1894 |
-
public function avada_aws_products_order_by( $order_by ) {
|
1895 |
-
|
1896 |
-
$order_by_new = '';
|
1897 |
-
|
1898 |
-
if ( isset( $_GET['product_orderby'] ) ) {
|
1899 |
-
switch( sanitize_text_field( $_GET['product_orderby'] ) ) {
|
1900 |
-
case 'name':
|
1901 |
-
$order_by_new = 'title';
|
1902 |
-
break;
|
1903 |
-
case 'price':
|
1904 |
-
$order_by_new = 'price';
|
1905 |
-
break;
|
1906 |
-
case 'date':
|
1907 |
-
$order_by_new = 'date';
|
1908 |
-
break;
|
1909 |
-
case 'popularity':
|
1910 |
-
$order_by_new = 'popularity';
|
1911 |
-
break;
|
1912 |
-
case 'rating':
|
1913 |
-
$order_by_new = 'rating';
|
1914 |
-
break;
|
1915 |
-
}
|
1916 |
-
}
|
1917 |
-
|
1918 |
-
if ( isset( $_GET['product_order'] ) && $order_by_new ) {
|
1919 |
-
$product_order = sanitize_text_field( $_GET['product_order'] );
|
1920 |
-
if ( in_array( $product_order, array( 'asc', 'desc' ) ) ) {
|
1921 |
-
$order_by_new = $order_by_new . '-' . $product_order;
|
1922 |
-
}
|
1923 |
-
|
1924 |
-
}
|
1925 |
-
|
1926 |
-
if ( $order_by_new ) {
|
1927 |
-
$order_by = $order_by_new;
|
1928 |
-
}
|
1929 |
-
|
1930 |
-
return $order_by;
|
1931 |
-
|
1932 |
-
}
|
1933 |
-
|
1934 |
-
/*
|
1935 |
-
* Avada theme fix for product variations inside list products view
|
1936 |
-
*/
|
1937 |
-
public function avada_post_class( $classes ) {
|
1938 |
-
if ( 'product_variation' === get_post_type() ) {
|
1939 |
-
if ( isset( $_SERVER['QUERY_STRING'] ) ) {
|
1940 |
-
parse_str( sanitize_text_field( wp_unslash( $_SERVER['QUERY_STRING'] ) ), $params );
|
1941 |
-
if ( isset( $params['product_view'] ) && $params['product_view'] ) {
|
1942 |
-
$classes[] = 'product-' . $params['product_view'] . '-view';
|
1943 |
-
}
|
1944 |
-
}
|
1945 |
-
}
|
1946 |
-
return $classes;
|
1947 |
-
}
|
1948 |
-
|
1949 |
/*
|
1950 |
* Electro them update search form markup
|
1951 |
*/
|
100 |
add_action( 'wp_head', array( $this, 'oceanwp_head_action' ) );
|
101 |
}
|
102 |
|
|
|
|
|
|
|
|
|
|
|
103 |
// Twenty Twenty theme
|
104 |
if ( function_exists( 'twentytwenty_theme_support' ) ) {
|
105 |
add_action( 'wp_head', array( $this, 'twenty_twenty_head_action' ) );
|
225 |
add_filter( "option_psad_shop_page_enable", array( $this, 'psad_filter' ) );
|
226 |
}
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
if ( 'Electro' === $this->current_theme ) {
|
229 |
add_filter( 'aws_searchbox_markup', array( $this, 'electro_searchbox_markup' ), 1, 2 );
|
230 |
}
|
361 |
include_once( AWS_DIR . '/includes/modules/class-aws-astra.php' );
|
362 |
}
|
363 |
|
364 |
+
// Avada theme
|
365 |
+
if ( class_exists( 'Avada' ) || 'Avada' === $this->current_theme ) {
|
366 |
+
include_once( AWS_DIR . '/includes/modules/class-aws-avada.php' );
|
367 |
+
}
|
368 |
+
|
369 |
}
|
370 |
|
371 |
/*
|
668 |
|
669 |
<?php }
|
670 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
/*
|
672 |
* Twenty Twenty theme
|
673 |
*/
|
1828 |
return $value;
|
1829 |
}
|
1830 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1831 |
/*
|
1832 |
* Electro them update search form markup
|
1833 |
*/
|
includes/class-aws-search.php
CHANGED
@@ -305,15 +305,26 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
305 |
*/
|
306 |
$this->data['search_terms'] = apply_filters( 'aws_search_terms', $this->data['search_terms'] );
|
307 |
|
|
|
308 |
|
309 |
foreach ( $this->data['search_terms'] as $search_term ) {
|
310 |
|
311 |
$search_term_len = strlen( $search_term );
|
312 |
|
313 |
-
$relevance_title =
|
314 |
-
$
|
315 |
-
|
316 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
|
318 |
$search_term_norm = AWS_Plurals::singularize( $search_term );
|
319 |
|
@@ -353,23 +364,23 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
353 |
break;
|
354 |
|
355 |
case 'category':
|
356 |
-
$relevance_array['category'][] = $wpdb->prepare( "( case when ( term_source = 'category' AND term = '%s' ) then
|
357 |
-
$relevance_array['category'][] = $wpdb->prepare( "( case when ( term_source = 'category' AND term LIKE %s ) then
|
358 |
break;
|
359 |
|
360 |
case 'tag':
|
361 |
-
$relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term = '%s' ) then
|
362 |
-
$relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term LIKE %s ) then
|
363 |
break;
|
364 |
|
365 |
case 'sku':
|
366 |
-
$relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term = '%s' ) then
|
367 |
-
$relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term LIKE %s ) then
|
368 |
break;
|
369 |
|
370 |
case 'id':
|
371 |
-
$relevance_array['id'][] = $wpdb->prepare( "( case when ( term_source = 'id' AND term = '%s' ) then
|
372 |
-
$relevance_array['id'][] = $wpdb->prepare( "( case when ( term_source = 'id' AND term LIKE %s ) then
|
373 |
break;
|
374 |
|
375 |
}
|
@@ -464,7 +475,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
464 |
* @param array $query Query string
|
465 |
*/
|
466 |
$sql = apply_filters( 'aws_search_query_string', $sql );
|
467 |
-
|
468 |
$this->data['sql'] = $sql;
|
469 |
|
470 |
$posts_ids = $this->get_posts_ids( $sql );
|
305 |
*/
|
306 |
$this->data['search_terms'] = apply_filters( 'aws_search_terms', $this->data['search_terms'] );
|
307 |
|
308 |
+
$relevance_scores = AWS_Helpers::get_relevance_scores( $this->data );
|
309 |
|
310 |
foreach ( $this->data['search_terms'] as $search_term ) {
|
311 |
|
312 |
$search_term_len = strlen( $search_term );
|
313 |
|
314 |
+
$relevance_title = $relevance_scores['title'] + 20 * $search_term_len;
|
315 |
+
$relevance_title_like = $relevance_scores['title'] / 5 + 2 * $search_term_len;
|
316 |
+
|
317 |
+
$relevance_content = $relevance_scores['content'] + 4 * $search_term_len;
|
318 |
+
$relevance_content_like = $relevance_scores['content'] + 1 * $search_term_len;
|
319 |
+
|
320 |
+
$relevance_id = $relevance_scores['id'];
|
321 |
+
$relevance_id_like = $relevance_scores['id'] / 10;
|
322 |
+
|
323 |
+
$relevance_sku = $relevance_scores['sku'];
|
324 |
+
$relevance_sku_like = $relevance_scores['sku'] / 5;
|
325 |
+
|
326 |
+
$relevance_other = $relevance_scores['other'];
|
327 |
+
$relevance_other_like = $relevance_scores['other'] / 5;
|
328 |
|
329 |
$search_term_norm = AWS_Plurals::singularize( $search_term );
|
330 |
|
364 |
break;
|
365 |
|
366 |
case 'category':
|
367 |
+
$relevance_array['category'][] = $wpdb->prepare( "( case when ( term_source = 'category' AND term = '%s' ) then {$relevance_other} else 0 end )", $search_term );
|
368 |
+
$relevance_array['category'][] = $wpdb->prepare( "( case when ( term_source = 'category' AND term LIKE %s ) then {$relevance_other_like} else 0 end )", $like );
|
369 |
break;
|
370 |
|
371 |
case 'tag':
|
372 |
+
$relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term = '%s' ) then {$relevance_other} else 0 end )", $search_term );
|
373 |
+
$relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term LIKE %s ) then {$relevance_other_like} else 0 end )", $like );
|
374 |
break;
|
375 |
|
376 |
case 'sku':
|
377 |
+
$relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term = '%s' ) then {$relevance_sku} else 0 end )", $search_term );
|
378 |
+
$relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term LIKE %s ) then {$relevance_sku_like} else 0 end )", $like );
|
379 |
break;
|
380 |
|
381 |
case 'id':
|
382 |
+
$relevance_array['id'][] = $wpdb->prepare( "( case when ( term_source = 'id' AND term = '%s' ) then {$relevance_id} else 0 end )", $search_term );
|
383 |
+
$relevance_array['id'][] = $wpdb->prepare( "( case when ( term_source = 'id' AND term LIKE %s ) then {$relevance_id_like} else 0 end )", $like );
|
384 |
break;
|
385 |
|
386 |
}
|
475 |
* @param array $query Query string
|
476 |
*/
|
477 |
$sql = apply_filters( 'aws_search_query_string', $sql );
|
478 |
+
|
479 |
$this->data['sql'] = $sql;
|
480 |
|
481 |
$posts_ids = $this->get_posts_ids( $sql );
|
includes/modules/class-aws-avada.php
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Avada theme integration
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly.
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! class_exists( 'AWS_Avada' ) ) :
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class
|
14 |
+
*/
|
15 |
+
class AWS_Avada {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Main AWS_Avada Instance
|
19 |
+
*
|
20 |
+
* Ensures only one instance of AWS_Avada is loaded or can be loaded.
|
21 |
+
*
|
22 |
+
* @static
|
23 |
+
* @return AWS_Avada - Main instance
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Main AWS_Avada Instance
|
29 |
+
*
|
30 |
+
* Ensures only one instance of AWS_Avada is loaded or can be loaded.
|
31 |
+
*
|
32 |
+
* @static
|
33 |
+
* @return AWS_Avada - Main instance
|
34 |
+
*/
|
35 |
+
public static function instance() {
|
36 |
+
if ( is_null( self::$_instance ) ) {
|
37 |
+
self::$_instance = new self();
|
38 |
+
}
|
39 |
+
return self::$_instance;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Constructor
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
|
47 |
+
if ( AWS()->get_settings( 'seamless' ) === 'true' ) {
|
48 |
+
add_action( 'wp_head', array( $this, 'avada_head_action' ) );
|
49 |
+
}
|
50 |
+
|
51 |
+
add_filter( 'aws_posts_per_page', array( $this, 'avada_posts_per_page' ), 2 );
|
52 |
+
add_filter( 'aws_products_order_by', array( $this, 'avada_aws_products_order_by' ), 1 );
|
53 |
+
add_filter( 'post_class', array( $this, 'avada_post_class' ) );
|
54 |
+
add_action( 'fusion_builder_before_init', array( $this, 'avada_builder_elements' ) );
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
/*
|
59 |
+
* Avada wp theme
|
60 |
+
*/
|
61 |
+
public function avada_head_action() { ?>
|
62 |
+
|
63 |
+
<style>
|
64 |
+
|
65 |
+
.fusion-flyout-search .aws-container {
|
66 |
+
margin: 0 auto;
|
67 |
+
padding: 0;
|
68 |
+
width: 100%;
|
69 |
+
width: calc(100% - 40px);
|
70 |
+
max-width: 600px;
|
71 |
+
position: absolute;
|
72 |
+
top: 40%;
|
73 |
+
left: 20px;
|
74 |
+
right: 20px;
|
75 |
+
}
|
76 |
+
|
77 |
+
.fusion-overlay-search .aws-container {
|
78 |
+
width: 100%;
|
79 |
+
}
|
80 |
+
|
81 |
+
.fusion-secondary-menu-search .aws-container {
|
82 |
+
margin-left: 10px;
|
83 |
+
}
|
84 |
+
|
85 |
+
</style>
|
86 |
+
|
87 |
+
<script>
|
88 |
+
|
89 |
+
window.addEventListener('load', function() {
|
90 |
+
var awsSearch = document.querySelectorAll(".fusion-menu .fusion-main-menu-search a, .fusion-flyout-menu-icons .fusion-icon-search");
|
91 |
+
if ( awsSearch ) {
|
92 |
+
for (var i = 0; i < awsSearch.length; i++) {
|
93 |
+
awsSearch[i].addEventListener('click', function() {
|
94 |
+
window.setTimeout(function(){
|
95 |
+
document.querySelector(".fusion-menu .fusion-main-menu-search .aws-search-field, .fusion-flyout-search .aws-search-field").focus();
|
96 |
+
}, 100);
|
97 |
+
}, false);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
}, false);
|
102 |
+
|
103 |
+
</script>
|
104 |
+
|
105 |
+
<?php }
|
106 |
+
|
107 |
+
/*
|
108 |
+
* Avada theme posts per page option
|
109 |
+
*/
|
110 |
+
public function avada_posts_per_page( $posts_per_page ) {
|
111 |
+
$num = 12;
|
112 |
+
$search_page_res_per_page = AWS()->get_settings( 'search_page_res_per_page' );
|
113 |
+
if ( $search_page_res_per_page ) {
|
114 |
+
$num = intval( $search_page_res_per_page );
|
115 |
+
}
|
116 |
+
$posts_per_page = isset( $_GET['product_count'] ) && intval( sanitize_text_field( $_GET['product_count'] ) ) ? intval( sanitize_text_field( $_GET['product_count'] ) ) : $num;
|
117 |
+
return $posts_per_page;
|
118 |
+
}
|
119 |
+
|
120 |
+
/*
|
121 |
+
* Avada theme order by options
|
122 |
+
*/
|
123 |
+
public function avada_aws_products_order_by( $order_by ) {
|
124 |
+
|
125 |
+
$order_by_new = '';
|
126 |
+
|
127 |
+
if ( isset( $_GET['product_orderby'] ) ) {
|
128 |
+
switch( sanitize_text_field( $_GET['product_orderby'] ) ) {
|
129 |
+
case 'name':
|
130 |
+
$order_by_new = 'title';
|
131 |
+
break;
|
132 |
+
case 'price':
|
133 |
+
$order_by_new = 'price';
|
134 |
+
break;
|
135 |
+
case 'date':
|
136 |
+
$order_by_new = 'date';
|
137 |
+
break;
|
138 |
+
case 'popularity':
|
139 |
+
$order_by_new = 'popularity';
|
140 |
+
break;
|
141 |
+
case 'rating':
|
142 |
+
$order_by_new = 'rating';
|
143 |
+
break;
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
if ( isset( $_GET['product_order'] ) && $order_by_new ) {
|
148 |
+
$product_order = sanitize_text_field( $_GET['product_order'] );
|
149 |
+
if ( in_array( $product_order, array( 'asc', 'desc' ) ) ) {
|
150 |
+
$order_by_new = $order_by_new . '-' . $product_order;
|
151 |
+
}
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
if ( $order_by_new ) {
|
156 |
+
$order_by = $order_by_new;
|
157 |
+
}
|
158 |
+
|
159 |
+
return $order_by;
|
160 |
+
|
161 |
+
}
|
162 |
+
|
163 |
+
/*
|
164 |
+
* Avada theme fix for product variations inside list products view
|
165 |
+
*/
|
166 |
+
public function avada_post_class( $classes ) {
|
167 |
+
if ( 'product_variation' === get_post_type() ) {
|
168 |
+
if ( isset( $_SERVER['QUERY_STRING'] ) ) {
|
169 |
+
parse_str( sanitize_text_field( wp_unslash( $_SERVER['QUERY_STRING'] ) ), $params );
|
170 |
+
if ( isset( $params['product_view'] ) && $params['product_view'] ) {
|
171 |
+
$classes[] = 'product-' . $params['product_view'] . '-view';
|
172 |
+
}
|
173 |
+
}
|
174 |
+
}
|
175 |
+
return $classes;
|
176 |
+
}
|
177 |
+
|
178 |
+
/*
|
179 |
+
* Register search element for Avada Builder
|
180 |
+
*/
|
181 |
+
function avada_builder_elements() {
|
182 |
+
|
183 |
+
fusion_builder_map(
|
184 |
+
array(
|
185 |
+
'name' => esc_attr__( 'AWS Search', 'advanced-woo-search' ),
|
186 |
+
'shortcode' => 'aws_search_form',
|
187 |
+
'icon' => 'fusiona-search',
|
188 |
+
'help_url' => 'https://advanced-woo-search.com/',
|
189 |
+
'params' => array(),
|
190 |
+
)
|
191 |
+
);
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
}
|
196 |
+
|
197 |
+
endif;
|
198 |
+
|
199 |
+
AWS_Avada::instance();
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: Mihail Barinov
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GSE37FC4Y7CEY
|
4 |
Tags: widget, plugin, woocommerce, search, product search, woocommerce search, ajax search, live search, custom search, ajax, shortcode, better search, relevance search, relevant search, search by sku, search plugin, shop, store, wordpress search, wp ajax search, wp search, wp search plugin, sidebar, ecommerce, merketing, products, category search, instant-search, search highlight, woocommerce advanced search, woocommerce live search, WooCommerce Plugin, woocommerce product search
|
5 |
Requires at least: 4.0
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -167,6 +167,11 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
|
|
167 |
|
168 |
== Changelog ==
|
169 |
|
|
|
|
|
|
|
|
|
|
|
170 |
= 2.52 ( 2022-04-11 ) =
|
171 |
* Update - Search results styles
|
172 |
* Update - Product description scrapper for search results
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GSE37FC4Y7CEY
|
4 |
Tags: widget, plugin, woocommerce, search, product search, woocommerce search, ajax search, live search, custom search, ajax, shortcode, better search, relevance search, relevant search, search by sku, search plugin, shop, store, wordpress search, wp ajax search, wp search, wp search plugin, sidebar, ecommerce, merketing, products, category search, instant-search, search highlight, woocommerce advanced search, woocommerce live search, WooCommerce Plugin, woocommerce product search
|
5 |
Requires at least: 4.0
|
6 |
+
Tested up to: 6.0
|
7 |
+
Stable tag: 2.53
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
167 |
|
168 |
== Changelog ==
|
169 |
|
170 |
+
= 2.53 ( 2022-04-25 ) =
|
171 |
+
* Update - Tested with WC 6.4
|
172 |
+
* Update - Support for Avada theme and Avada Builder
|
173 |
+
* Dev - Add aws_relevance_scores filter
|
174 |
+
|
175 |
= 2.52 ( 2022-04-11 ) =
|
176 |
* Update - Search results styles
|
177 |
* Update - Product description scrapper for search results
|