Version Description
- Fix bug with not working stop-words for taxonomies
- Fix bug with hided search form if its parent node has fixed layout
- Add second argument for the_title and the_content filters
- Update view of settings page
Download this release
Release Info
Developer | Mihail Barinov |
Plugin | Advanced Woo Search |
Version | 1.40 |
Comparing to | |
See all releases |
Code changes from version 1.39 to 1.40
- advanced-woo-search.php +2 -2
- assets/js/common.js +1 -0
- includes/class-aws-helpers.php +27 -1
- includes/class-aws-search.php +9 -3
- includes/class-aws-table.php +5 -22
- includes/options.php +34 -28
- readme.txt +7 -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.40
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: aws
|
16 |
exit;
|
17 |
}
|
18 |
|
19 |
+
define( 'AWS_VERSION', '1.40' );
|
20 |
|
21 |
|
22 |
define( 'AWS_DIR', dirname( __FILE__ ) );
|
assets/js/common.js
CHANGED
@@ -389,6 +389,7 @@
|
|
389 |
$( d.resultBlock ).on( 'mouseenter', '.aws_result_item', function() {
|
390 |
methods.removeHovered();
|
391 |
$(this).addClass('hovered');
|
|
|
392 |
});
|
393 |
|
394 |
|
389 |
$( d.resultBlock ).on( 'mouseenter', '.aws_result_item', function() {
|
390 |
methods.removeHovered();
|
391 |
$(this).addClass('hovered');
|
392 |
+
$searchField.trigger('mouseenter');
|
393 |
});
|
394 |
|
395 |
|
includes/class-aws-helpers.php
CHANGED
@@ -51,7 +51,7 @@ if ( ! class_exists( 'AWS_Helpers' ) ) :
|
|
51 |
|
52 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) {
|
53 |
|
54 |
-
$sql = "SELECT
|
55 |
|
56 |
$indexed_products = $wpdb->query( $sql );
|
57 |
|
@@ -104,6 +104,32 @@ if ( ! class_exists( 'AWS_Helpers' ) ) :
|
|
104 |
|
105 |
}
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
/*
|
108 |
* Strip shortcodes
|
109 |
*/
|
51 |
|
52 |
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) {
|
53 |
|
54 |
+
$sql = "SELECT COUNT(*) FROM {$table_name} GROUP BY ID;";
|
55 |
|
56 |
$indexed_products = $wpdb->query( $sql );
|
57 |
|
104 |
|
105 |
}
|
106 |
|
107 |
+
/*
|
108 |
+
* Replace stopwords
|
109 |
+
*/
|
110 |
+
static public function filter_stopwords( $str_array ) {
|
111 |
+
|
112 |
+
$stopwords = AWS()->get_settings( 'stopwords' );
|
113 |
+
|
114 |
+
if ( $stopwords && $str_array && ! empty( $str_array ) ) {
|
115 |
+
$stopwords_array = explode( ',', $stopwords );
|
116 |
+
if ( $stopwords_array && ! empty( $stopwords_array ) ) {
|
117 |
+
|
118 |
+
$stopwords_array = array_map( 'trim', $stopwords_array );
|
119 |
+
|
120 |
+
foreach ( $str_array as $str_word => $str_count ) {
|
121 |
+
if ( in_array( $str_word, $stopwords_array ) ) {
|
122 |
+
unset( $str_array[$str_word] );
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
return $str_array;
|
130 |
+
|
131 |
+
}
|
132 |
+
|
133 |
/*
|
134 |
* Strip shortcodes
|
135 |
*/
|
includes/class-aws-search.php
CHANGED
@@ -567,9 +567,15 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
567 |
$excludes = '';
|
568 |
$search_query = '';
|
569 |
|
570 |
-
|
571 |
-
|
572 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
573 |
}
|
574 |
|
575 |
$search_query .= sprintf( ' AND ( %s )', implode( ' OR ', $search_array ) );
|
567 |
$excludes = '';
|
568 |
$search_query = '';
|
569 |
|
570 |
+
$filtered_terms = AWS_Helpers::filter_stopwords( array_count_values( $this->data['search_terms'] ) );
|
571 |
+
|
572 |
+
if ( $filtered_terms && ! empty( $filtered_terms ) ) {
|
573 |
+
foreach ( $this->data['search_terms'] as $search_term ) {
|
574 |
+
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
575 |
+
$search_array[] = $wpdb->prepare('( name LIKE %s )', $like);
|
576 |
+
}
|
577 |
+
} else {
|
578 |
+
return $result_array;
|
579 |
}
|
580 |
|
581 |
$search_query .= sprintf( ' AND ( %s )', implode( ' OR ', $search_array ) );
|
includes/class-aws-table.php
CHANGED
@@ -262,8 +262,8 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
262 |
|
263 |
$sku = $product->get_sku();
|
264 |
|
265 |
-
$title = apply_filters( 'the_title', get_the_title( $data['id'] ) );
|
266 |
-
$content = apply_filters( 'the_content', get_post_field( 'post_content', $data['id'] ) );
|
267 |
$excerpt = get_post_field( 'post_excerpt', $data['id'] );
|
268 |
|
269 |
|
@@ -389,8 +389,8 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
389 |
$translated_post_data['lang'] = $lang_obj->language_code;
|
390 |
$translated_post_data['terms'] = array();
|
391 |
|
392 |
-
$translated_title = apply_filters( 'the_title', get_the_title( $translated_post->ID ) );
|
393 |
-
$translated_content = apply_filters( 'the_content', get_post_field( 'post_content', $translated_post->ID ) );
|
394 |
$translated_excerpt = get_post_field( 'post_excerpt', $translated_post->ID );
|
395 |
|
396 |
$translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
|
@@ -623,8 +623,6 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
623 |
*/
|
624 |
private function extract_terms( $str ) {
|
625 |
|
626 |
-
$stopwords = AWS()->get_settings( 'stopwords' );
|
627 |
-
|
628 |
$str = AWS_Helpers::html2txt( $str );
|
629 |
|
630 |
// Avoid single A-Z.
|
@@ -678,22 +676,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
678 |
$str = trim( preg_replace( '/\s+/', ' ', $str ) );
|
679 |
|
680 |
$str_array = array_count_values( explode( ' ', $str ) );
|
681 |
-
|
682 |
-
|
683 |
-
if ( $stopwords && $str_array && ! empty( $str_array ) ) {
|
684 |
-
$stopwords_array = explode( ',', $stopwords );
|
685 |
-
if ( $stopwords_array && ! empty( $stopwords_array ) ) {
|
686 |
-
$stopwords_array = array_map( 'trim', $stopwords_array );
|
687 |
-
|
688 |
-
foreach ( $str_array as $str_word => $str_count ) {
|
689 |
-
if ( in_array( $str_word, $stopwords_array ) ) {
|
690 |
-
unset( $str_array[$str_word] );
|
691 |
-
}
|
692 |
-
}
|
693 |
-
|
694 |
-
}
|
695 |
-
}
|
696 |
-
|
697 |
|
698 |
return $str_array;
|
699 |
|
262 |
|
263 |
$sku = $product->get_sku();
|
264 |
|
265 |
+
$title = apply_filters( 'the_title', get_the_title( $data['id'] ), $data['id'] );
|
266 |
+
$content = apply_filters( 'the_content', get_post_field( 'post_content', $data['id'] ), $data['id'] );
|
267 |
$excerpt = get_post_field( 'post_excerpt', $data['id'] );
|
268 |
|
269 |
|
389 |
$translated_post_data['lang'] = $lang_obj->language_code;
|
390 |
$translated_post_data['terms'] = array();
|
391 |
|
392 |
+
$translated_title = apply_filters( 'the_title', get_the_title( $translated_post->ID ), $translated_post->ID );
|
393 |
+
$translated_content = apply_filters( 'the_content', get_post_field( 'post_content', $translated_post->ID ), $translated_post->ID );
|
394 |
$translated_excerpt = get_post_field( 'post_excerpt', $translated_post->ID );
|
395 |
|
396 |
$translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
|
623 |
*/
|
624 |
private function extract_terms( $str ) {
|
625 |
|
|
|
|
|
626 |
$str = AWS_Helpers::html2txt( $str );
|
627 |
|
628 |
// Avoid single A-Z.
|
676 |
$str = trim( preg_replace( '/\s+/', ' ', $str ) );
|
677 |
|
678 |
$str_array = array_count_values( explode( ' ', $str ) );
|
679 |
+
$str_array = AWS_Helpers::filter_stopwords( $str_array );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
680 |
|
681 |
return $str_array;
|
682 |
|
includes/options.php
CHANGED
@@ -110,6 +110,40 @@ $options['form'][] = array(
|
|
110 |
|
111 |
// Search Results Settings
|
112 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
$options['results'][] = array(
|
114 |
"name" => __( "Show image", "aws" ),
|
115 |
"desc" => __( "Show product image for each search result.", "aws" ),
|
@@ -134,26 +168,6 @@ $options['results'][] = array(
|
|
134 |
)
|
135 |
);
|
136 |
|
137 |
-
$options['results'][] = array(
|
138 |
-
"name" => __( "Description source", "aws" ),
|
139 |
-
"desc" => __( "From where to take product description.<br>If first source is empty data will be taken from other sources.", "aws" ),
|
140 |
-
"id" => "desc_source",
|
141 |
-
"value" => 'content',
|
142 |
-
"type" => "radio",
|
143 |
-
'choices' => array(
|
144 |
-
'content' => __( 'Content', 'aws' ),
|
145 |
-
'excerpt' => __( 'Excerpt', 'aws' ),
|
146 |
-
)
|
147 |
-
);
|
148 |
-
|
149 |
-
$options['results'][] = array(
|
150 |
-
"name" => __( "Description length", "aws" ),
|
151 |
-
"desc" => __( "Maximal allowed number of words for product description.", "aws" ),
|
152 |
-
"id" => "excerpt_length",
|
153 |
-
"value" => 20,
|
154 |
-
"type" => "number"
|
155 |
-
);
|
156 |
-
|
157 |
$options['results'][] = array(
|
158 |
"name" => __( "Description content", "aws" ),
|
159 |
"desc" => __( "What to show in product description?", "aws" ),
|
@@ -237,12 +251,4 @@ $options['results'][] = array(
|
|
237 |
'true' => __( 'On', 'aws' ),
|
238 |
'false' => __( 'Off', 'aws' ),
|
239 |
)
|
240 |
-
);
|
241 |
-
|
242 |
-
$options['results'][] = array(
|
243 |
-
"name" => __( "Max number of results", "aws" ),
|
244 |
-
"desc" => __( "Maximum number of displayed search results.", "aws" ),
|
245 |
-
"id" => "results_num",
|
246 |
-
"value" => 10,
|
247 |
-
"type" => "number"
|
248 |
);
|
110 |
|
111 |
// Search Results Settings
|
112 |
|
113 |
+
|
114 |
+
$options['results'][] = array(
|
115 |
+
"name" => __( "Description source", "aws" ),
|
116 |
+
"desc" => __( "From where to take product description.<br>If first source is empty data will be taken from other sources.", "aws" ),
|
117 |
+
"id" => "desc_source",
|
118 |
+
"value" => 'content',
|
119 |
+
"type" => "radio",
|
120 |
+
'choices' => array(
|
121 |
+
'content' => __( 'Content', 'aws' ),
|
122 |
+
'excerpt' => __( 'Excerpt', 'aws' ),
|
123 |
+
)
|
124 |
+
);
|
125 |
+
|
126 |
+
$options['results'][] = array(
|
127 |
+
"name" => __( "Description length", "aws" ),
|
128 |
+
"desc" => __( "Maximal allowed number of words for product description.", "aws" ),
|
129 |
+
"id" => "excerpt_length",
|
130 |
+
"value" => 20,
|
131 |
+
"type" => "number"
|
132 |
+
);
|
133 |
+
|
134 |
+
$options['results'][] = array(
|
135 |
+
"name" => __( "Max number of results", "aws" ),
|
136 |
+
"desc" => __( "Maximum number of displayed search results.", "aws" ),
|
137 |
+
"id" => "results_num",
|
138 |
+
"value" => 10,
|
139 |
+
"type" => "number"
|
140 |
+
);
|
141 |
+
|
142 |
+
$options['results'][] = array(
|
143 |
+
"name" => __( "View", "aws" ),
|
144 |
+
"type" => "heading"
|
145 |
+
);
|
146 |
+
|
147 |
$options['results'][] = array(
|
148 |
"name" => __( "Show image", "aws" ),
|
149 |
"desc" => __( "Show product image for each search result.", "aws" ),
|
168 |
)
|
169 |
);
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
$options['results'][] = array(
|
172 |
"name" => __( "Description content", "aws" ),
|
173 |
"desc" => __( "What to show in product description?", "aws" ),
|
251 |
'true' => __( 'On', 'aws' ),
|
252 |
'false' => __( 'Off', 'aws' ),
|
253 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
);
|
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: 4.9.5
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -77,6 +77,12 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
|
|
77 |
|
78 |
== Changelog ==
|
79 |
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
= 1.39 =
|
81 |
* Add option to disable ajax search results
|
82 |
|
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: 4.9.5
|
7 |
+
Stable tag: 1.40
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
77 |
|
78 |
== Changelog ==
|
79 |
|
80 |
+
= 1.40 =
|
81 |
+
* Fix bug with not working stop-words for taxonomies
|
82 |
+
* Fix bug with hided search form if its parent node has fixed layout
|
83 |
+
* Add second argument for the_title and the_content filters
|
84 |
+
* Update view of settings page
|
85 |
+
|
86 |
= 1.39 =
|
87 |
* Add option to disable ajax search results
|
88 |
|