Version Description
- Fix stopwords
- Fix markup for finded words in products content
Download this release
Release Info
Developer | Mihail Barinov |
Plugin | Advanced Woo Search |
Version | 1.61 |
Comparing to | |
See all releases |
Code changes from version 1.60 to 1.61
- advanced-woo-search.php +2 -2
- includes/class-aws-helpers.php +15 -9
- includes/class-aws-search.php +54 -58
- includes/class-aws-table.php +3 -1
- 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.61
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: aws
|
16 |
exit;
|
17 |
}
|
18 |
|
19 |
+
define( 'AWS_VERSION', '1.61' );
|
20 |
|
21 |
|
22 |
define( 'AWS_DIR', dirname( __FILE__ ) );
|
includes/class-aws-helpers.php
CHANGED
@@ -454,23 +454,29 @@ if ( ! class_exists( 'AWS_Helpers' ) ) :
|
|
454 |
static public function filter_stopwords( $str_array ) {
|
455 |
|
456 |
$stopwords = AWS()->get_settings( 'stopwords' );
|
|
|
|
|
457 |
|
458 |
-
if ( $stopwords
|
459 |
$stopwords_array = explode( ',', $stopwords );
|
460 |
-
|
461 |
|
462 |
-
|
463 |
|
464 |
-
|
465 |
-
if ( in_array( $str_word, $stopwords_array ) ) {
|
466 |
-
unset( $str_array[$str_word] );
|
467 |
-
}
|
468 |
-
}
|
469 |
|
|
|
|
|
|
|
|
|
|
|
470 |
}
|
|
|
|
|
|
|
471 |
}
|
472 |
|
473 |
-
return $
|
474 |
|
475 |
}
|
476 |
|
454 |
static public function filter_stopwords( $str_array ) {
|
455 |
|
456 |
$stopwords = AWS()->get_settings( 'stopwords' );
|
457 |
+
$stopwords_array = array();
|
458 |
+
$new_str_array = array();
|
459 |
|
460 |
+
if ( $stopwords ) {
|
461 |
$stopwords_array = explode( ',', $stopwords );
|
462 |
+
}
|
463 |
|
464 |
+
if ( $str_array && is_array( $str_array ) && ! empty( $str_array ) && $stopwords_array && ! empty( $stopwords_array ) ) {
|
465 |
|
466 |
+
$stopwords_array = array_map( 'trim', $stopwords_array );
|
|
|
|
|
|
|
|
|
467 |
|
468 |
+
foreach ( $str_array as $str_word ) {
|
469 |
+
if ( in_array( $str_word, $stopwords_array ) ) {
|
470 |
+
continue;
|
471 |
+
}
|
472 |
+
$new_str_array[] = $str_word;
|
473 |
}
|
474 |
+
|
475 |
+
} else {
|
476 |
+
$new_str_array = $str_array;
|
477 |
}
|
478 |
|
479 |
+
return $new_str_array;
|
480 |
|
481 |
}
|
482 |
|
includes/class-aws-search.php
CHANGED
@@ -126,6 +126,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
126 |
$search_in_arr = array( 'title' );
|
127 |
}
|
128 |
|
|
|
129 |
$categories_array = array();
|
130 |
$tags_array = array();
|
131 |
|
@@ -135,9 +136,10 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
135 |
$this->data['search_in'] = $search_in_arr;
|
136 |
$this->data['outofstock'] = $outofstock;
|
137 |
|
138 |
-
|
139 |
$search_array = array_unique( explode( ' ', $s ) );
|
140 |
|
|
|
|
|
141 |
if ( is_array( $search_array ) && ! empty( $search_array ) ) {
|
142 |
foreach ( $search_array as $search_term ) {
|
143 |
$search_term = trim( $search_term );
|
@@ -147,69 +149,73 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
147 |
}
|
148 |
}
|
149 |
|
150 |
-
if ( empty( $this->data['search_terms'] ) ) {
|
151 |
-
$this->data['search_terms'][] = '';
|
152 |
-
}
|
153 |
-
|
154 |
-
|
155 |
-
$posts_ids = $this->query_index_table();
|
156 |
-
|
157 |
-
/**
|
158 |
-
* Filters array of products ids
|
159 |
-
*
|
160 |
-
* @since 1.53
|
161 |
-
*
|
162 |
-
* @param array $posts_ids Array of products ids
|
163 |
-
* @param string $s Search query
|
164 |
-
*/
|
165 |
-
$posts_ids = apply_filters( 'aws_search_results_products_ids', $posts_ids, $s );
|
166 |
|
|
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Filters array of products before they displayed in search results
|
172 |
-
*
|
173 |
-
* @since 1.42
|
174 |
-
*
|
175 |
-
* @param array $products_array Array of products results
|
176 |
-
* @param string $s Search query
|
177 |
-
*/
|
178 |
-
$products_array = apply_filters( 'aws_search_results_products', $products_array, $s );
|
179 |
-
|
180 |
-
|
181 |
-
if ( $show_cats === 'true' ) {
|
182 |
-
|
183 |
-
$categories_array = $this->get_taxonomies( 'product_cat' );
|
184 |
|
185 |
/**
|
186 |
-
* Filters array of
|
187 |
*
|
188 |
-
* @since 1.
|
189 |
*
|
190 |
-
* @param array $
|
191 |
* @param string $s Search query
|
192 |
*/
|
193 |
-
$
|
194 |
|
195 |
-
}
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
$tags_array = $this->get_taxonomies( 'product_tag' );
|
200 |
|
201 |
/**
|
202 |
-
* Filters array of
|
203 |
*
|
204 |
* @since 1.42
|
205 |
*
|
206 |
-
* @param array $
|
207 |
* @param string $s Search query
|
208 |
*/
|
209 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
}
|
212 |
|
|
|
213 |
$result_array = array(
|
214 |
'cats' => $categories_array,
|
215 |
'tags' => $tags_array,
|
@@ -679,18 +685,8 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
679 |
|
680 |
}
|
681 |
|
682 |
-
$
|
683 |
-
$
|
684 |
-
|
685 |
-
|
686 |
-
if ( $title_has_exact === 1 || $content_has_exact === 1 ) {
|
687 |
-
$title = preg_replace($exact_pattern, '<strong>${0}</strong>', $title );
|
688 |
-
$content = preg_replace($exact_pattern, '<strong>${0}</strong>', $content );
|
689 |
-
} else {
|
690 |
-
$title = preg_replace($pattern, '<strong>${0}</strong>', $title );
|
691 |
-
$content = preg_replace( $pattern, '<strong>${0}</strong>', $content );
|
692 |
-
}
|
693 |
-
|
694 |
|
695 |
return array(
|
696 |
'title' => $title,
|
@@ -718,10 +714,10 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
718 |
$excludes = '';
|
719 |
$search_query = '';
|
720 |
|
721 |
-
$filtered_terms =
|
722 |
|
723 |
if ( $filtered_terms && ! empty( $filtered_terms ) ) {
|
724 |
-
foreach ( $
|
725 |
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
726 |
$search_array[] = $wpdb->prepare('( name LIKE %s )', $like);
|
727 |
}
|
126 |
$search_in_arr = array( 'title' );
|
127 |
}
|
128 |
|
129 |
+
$products_array = array();
|
130 |
$categories_array = array();
|
131 |
$tags_array = array();
|
132 |
|
136 |
$this->data['search_in'] = $search_in_arr;
|
137 |
$this->data['outofstock'] = $outofstock;
|
138 |
|
|
|
139 |
$search_array = array_unique( explode( ' ', $s ) );
|
140 |
|
141 |
+
$search_array = AWS_Helpers::filter_stopwords( $search_array );
|
142 |
+
|
143 |
if ( is_array( $search_array ) && ! empty( $search_array ) ) {
|
144 |
foreach ( $search_array as $search_term ) {
|
145 |
$search_term = trim( $search_term );
|
149 |
}
|
150 |
}
|
151 |
|
152 |
+
// if ( empty( $this->data['search_terms'] ) ) {
|
153 |
+
// $this->data['search_terms'][] = '';
|
154 |
+
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
+
if ( ! empty( $this->data['search_terms'] ) ) {
|
157 |
|
158 |
+
$posts_ids = $this->query_index_table();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
/**
|
161 |
+
* Filters array of products ids
|
162 |
*
|
163 |
+
* @since 1.53
|
164 |
*
|
165 |
+
* @param array $posts_ids Array of products ids
|
166 |
* @param string $s Search query
|
167 |
*/
|
168 |
+
$posts_ids = apply_filters( 'aws_search_results_products_ids', $posts_ids, $s );
|
169 |
|
|
|
170 |
|
171 |
+
$products_array = $this->get_products( $posts_ids );
|
|
|
|
|
172 |
|
173 |
/**
|
174 |
+
* Filters array of products before they displayed in search results
|
175 |
*
|
176 |
* @since 1.42
|
177 |
*
|
178 |
+
* @param array $products_array Array of products results
|
179 |
* @param string $s Search query
|
180 |
*/
|
181 |
+
$products_array = apply_filters( 'aws_search_results_products', $products_array, $s );
|
182 |
+
|
183 |
+
|
184 |
+
if ( $show_cats === 'true' ) {
|
185 |
+
|
186 |
+
$categories_array = $this->get_taxonomies( 'product_cat' );
|
187 |
+
|
188 |
+
/**
|
189 |
+
* Filters array of product categories before they displayed in search results
|
190 |
+
*
|
191 |
+
* @since 1.42
|
192 |
+
*
|
193 |
+
* @param array $categories_array Array of products categories
|
194 |
+
* @param string $s Search query
|
195 |
+
*/
|
196 |
+
$categories_array = apply_filters( 'aws_search_results_categories', $categories_array, $s );
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
if ( $show_tags === 'true' ) {
|
201 |
+
|
202 |
+
$tags_array = $this->get_taxonomies( 'product_tag' );
|
203 |
+
|
204 |
+
/**
|
205 |
+
* Filters array of product tags before they displayed in search results
|
206 |
+
*
|
207 |
+
* @since 1.42
|
208 |
+
*
|
209 |
+
* @param array $tags_array Array of products tags
|
210 |
+
* @param string $s Search query
|
211 |
+
*/
|
212 |
+
$tags_array = apply_filters( 'aws_search_results_tags', $tags_array, $s );
|
213 |
+
|
214 |
+
}
|
215 |
|
216 |
}
|
217 |
|
218 |
+
|
219 |
$result_array = array(
|
220 |
'cats' => $categories_array,
|
221 |
'tags' => $tags_array,
|
685 |
|
686 |
}
|
687 |
|
688 |
+
$title = preg_replace($pattern, '<strong>${0}</strong>', $title );
|
689 |
+
$content = preg_replace( $pattern, '<strong>${0}</strong>', $content );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
690 |
|
691 |
return array(
|
692 |
'title' => $title,
|
714 |
$excludes = '';
|
715 |
$search_query = '';
|
716 |
|
717 |
+
$filtered_terms = $this->data['search_terms'];
|
718 |
|
719 |
if ( $filtered_terms && ! empty( $filtered_terms ) ) {
|
720 |
+
foreach ( $filtered_terms as $search_term ) {
|
721 |
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
722 |
$search_array[] = $wpdb->prepare('( name LIKE %s )', $like);
|
723 |
}
|
includes/class-aws-table.php
CHANGED
@@ -729,6 +729,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
729 |
|
730 |
// Avoid single A-Z.
|
731 |
//$str = preg_replace( '/\b\w{1}\b/i', " ", $str );
|
|
|
732 |
|
733 |
$str = AWS_Helpers::normalize_string( $str );
|
734 |
|
@@ -776,8 +777,9 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
776 |
*/
|
777 |
$str = apply_filters( 'aws_extracted_string', $str );
|
778 |
|
779 |
-
$str_array =
|
780 |
$str_array = AWS_Helpers::filter_stopwords( $str_array );
|
|
|
781 |
|
782 |
/**
|
783 |
* Filters extracted terms before adding to index table
|
729 |
|
730 |
// Avoid single A-Z.
|
731 |
//$str = preg_replace( '/\b\w{1}\b/i', " ", $str );
|
732 |
+
//if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z]$/i', $term ) ) )
|
733 |
|
734 |
$str = AWS_Helpers::normalize_string( $str );
|
735 |
|
777 |
*/
|
778 |
$str = apply_filters( 'aws_extracted_string', $str );
|
779 |
|
780 |
+
$str_array = explode( ' ', $str );
|
781 |
$str_array = AWS_Helpers::filter_stopwords( $str_array );
|
782 |
+
$str_array = array_count_values( $str_array );
|
783 |
|
784 |
/**
|
785 |
* Filters extracted terms before adding to index table
|
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.0
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -101,6 +101,10 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
|
|
101 |
|
102 |
== Changelog ==
|
103 |
|
|
|
|
|
|
|
|
|
104 |
= 1.60 =
|
105 |
* Update cron job action
|
106 |
* Update Protected Categories plugin integration
|
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.0
|
7 |
+
Stable tag: 1.61
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
101 |
|
102 |
== Changelog ==
|
103 |
|
104 |
+
= 1.61 =
|
105 |
+
* Fix stopwords
|
106 |
+
* Fix markup for finded words in products content
|
107 |
+
|
108 |
= 1.60 =
|
109 |
* Update cron job action
|
110 |
* Update Protected Categories plugin integration
|