Version Description
- Add - Relevance search for terms
- Dev Add aws_search_terms_number filter
Download this release
Release Info
Developer | Mihail Barinov |
Plugin | Advanced Woo Search |
Version | 1.73 |
Comparing to | |
See all releases |
Code changes from version 1.72 to 1.73
- advanced-woo-search.php +2 -2
- includes/class-aws-search.php +36 -4
- readme.txt +5 -1
advanced-woo-search.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/*
|
4 |
Plugin Name: Advanced Woo Search
|
5 |
Description: Advance ajax WooCommerce product search.
|
6 |
-
Version: 1.
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: aws
|
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
16 |
exit;
|
17 |
}
|
18 |
|
19 |
-
define( 'AWS_VERSION', '1.
|
20 |
|
21 |
|
22 |
define( 'AWS_DIR', dirname( __FILE__ ) );
|
3 |
/*
|
4 |
Plugin Name: Advanced Woo Search
|
5 |
Description: Advance ajax WooCommerce product search.
|
6 |
+
Version: 1.73
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: aws
|
16 |
exit;
|
17 |
}
|
18 |
|
19 |
+
define( 'AWS_VERSION', '1.73' );
|
20 |
|
21 |
|
22 |
define( 'AWS_DIR', dirname( __FILE__ ) );
|
includes/class-aws-search.php
CHANGED
@@ -730,28 +730,57 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
730 |
|
731 |
$result_array = array();
|
732 |
$search_array = array();
|
|
|
733 |
$excludes = '';
|
734 |
$search_query = '';
|
|
|
735 |
|
736 |
$filtered_terms = $this->data['search_terms'];
|
737 |
$filtered_terms[] = $this->data['s_nonormalize'];
|
738 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
739 |
if ( $filtered_terms && ! empty( $filtered_terms ) ) {
|
|
|
740 |
foreach ( $filtered_terms as $search_term ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
741 |
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
742 |
$search_array[] = $wpdb->prepare('( name LIKE %s )', $like);
|
|
|
|
|
|
|
743 |
}
|
|
|
744 |
} else {
|
|
|
745 |
return $result_array;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
746 |
}
|
747 |
|
748 |
$search_query .= sprintf( ' AND ( %s )', implode( ' OR ', $search_array ) );
|
749 |
|
750 |
/**
|
751 |
* Exclude certain terms from search
|
752 |
-
*
|
753 |
* @since 1.58
|
754 |
-
*
|
755 |
* @param array
|
756 |
*/
|
757 |
$exclude_terms = apply_filters( 'aws_terms_exclude_' . $taxonomy, array() );
|
@@ -765,7 +794,8 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
765 |
distinct($wpdb->terms.name),
|
766 |
$wpdb->terms.term_id,
|
767 |
$wpdb->term_taxonomy.taxonomy,
|
768 |
-
$wpdb->term_taxonomy.count
|
|
|
769 |
FROM
|
770 |
$wpdb->terms
|
771 |
, $wpdb->term_taxonomy
|
@@ -775,7 +805,9 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
775 |
AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id
|
776 |
AND count > 0
|
777 |
{$excludes}
|
778 |
-
|
|
|
|
|
779 |
|
780 |
$sql = trim( preg_replace( '/\s+/', ' ', $sql ) );
|
781 |
|
730 |
|
731 |
$result_array = array();
|
732 |
$search_array = array();
|
733 |
+
$relevance_array = array();
|
734 |
$excludes = '';
|
735 |
$search_query = '';
|
736 |
+
$relevance_query = '';
|
737 |
|
738 |
$filtered_terms = $this->data['search_terms'];
|
739 |
$filtered_terms[] = $this->data['s_nonormalize'];
|
740 |
|
741 |
+
/**
|
742 |
+
* Max number of terms to show
|
743 |
+
* @since 1.73
|
744 |
+
* @param int
|
745 |
+
*/
|
746 |
+
$terms_number = apply_filters( 'aws_search_terms_number', 10 );
|
747 |
+
|
748 |
if ( $filtered_terms && ! empty( $filtered_terms ) ) {
|
749 |
+
|
750 |
foreach ( $filtered_terms as $search_term ) {
|
751 |
+
|
752 |
+
$search_term_len = strlen( $search_term );
|
753 |
+
$relevance = 40 + 2 * $search_term_len;
|
754 |
+
$search_term_norm = preg_replace( '/(s|es|ies)$/i', '', $search_term );
|
755 |
+
|
756 |
+
if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
|
757 |
+
$search_term = $search_term_norm;
|
758 |
+
}
|
759 |
+
|
760 |
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
761 |
$search_array[] = $wpdb->prepare('( name LIKE %s )', $like);
|
762 |
+
|
763 |
+
$relevance_array[] = $wpdb->prepare( "( case when ( name LIKE %s ) then {$relevance} else 0 end )", $like );
|
764 |
+
|
765 |
}
|
766 |
+
|
767 |
} else {
|
768 |
+
|
769 |
return $result_array;
|
770 |
+
|
771 |
+
}
|
772 |
+
|
773 |
+
if ( $relevance_array && ! empty( $relevance_array ) ) {
|
774 |
+
$relevance_query = sprintf( ' (SUM( %s )) ', implode( ' + ', $relevance_array ) );
|
775 |
+
} else {
|
776 |
+
$relevance_query = '0';
|
777 |
}
|
778 |
|
779 |
$search_query .= sprintf( ' AND ( %s )', implode( ' OR ', $search_array ) );
|
780 |
|
781 |
/**
|
782 |
* Exclude certain terms from search
|
|
|
783 |
* @since 1.58
|
|
|
784 |
* @param array
|
785 |
*/
|
786 |
$exclude_terms = apply_filters( 'aws_terms_exclude_' . $taxonomy, array() );
|
794 |
distinct($wpdb->terms.name),
|
795 |
$wpdb->terms.term_id,
|
796 |
$wpdb->term_taxonomy.taxonomy,
|
797 |
+
$wpdb->term_taxonomy.count,
|
798 |
+
{$relevance_query} as relevance
|
799 |
FROM
|
800 |
$wpdb->terms
|
801 |
, $wpdb->term_taxonomy
|
805 |
AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id
|
806 |
AND count > 0
|
807 |
{$excludes}
|
808 |
+
GROUP BY term_id
|
809 |
+
ORDER BY relevance DESC
|
810 |
+
LIMIT 0, {$terms_number}";
|
811 |
|
812 |
$sql = trim( preg_replace( '/\s+/', ' ', $sql ) );
|
813 |
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
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: 5.2
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -103,6 +103,10 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
|
|
106 |
= 1.72 =
|
107 |
* Fix - Tax search exact matching bug
|
108 |
* Fix - Empty tax in search results bug
|
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: 5.2
|
7 |
+
Stable tag: 1.73
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 1.73 =
|
107 |
+
* Add - Relevance search for terms
|
108 |
+
* Dev – Add aws_search_terms_number filter
|
109 |
+
|
110 |
= 1.72 =
|
111 |
* Fix - Tax search exact matching bug
|
112 |
* Fix - Empty tax in search results bug
|