Advanced Woo Search - Version 1.24

Version Description

  • Add plurals support
  • Fix Polylang plugin conflict
  • Fix SKU search bug
  • Add function for cron job
Download this release

Release Info

Developer Mihail Barinov
Plugin Icon 128x128 Advanced Woo Search
Version 1.24
Comparing to
See all releases

Code changes from version 1.23 to 1.24

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.23
7
  Author: ILLID
8
  Author URI: https://advanced-woo-search.com/
9
  Text Domain: aws
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
14
  exit;
15
  }
16
 
17
- define( 'AWS_VERSION', '1.23' );
18
 
19
 
20
  define( 'AWS_DIR', dirname( __FILE__ ) );
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
+ Version: 1.24
7
  Author: ILLID
8
  Author URI: https://advanced-woo-search.com/
9
  Text Domain: aws
14
  exit;
15
  }
16
 
17
+ define( 'AWS_VERSION', '1.24' );
18
 
19
 
20
  define( 'AWS_DIR', dirname( __FILE__ ) );
assets/js/admin.js CHANGED
@@ -53,6 +53,7 @@ jQuery(document).ready(function ($) {
53
  // Sync finished
54
  syncStatus = 'finished';
55
 
 
56
  console.log( "Reindex finished!" );
57
 
58
  $reindexBlock.removeClass('loading');
53
  // Sync finished
54
  syncStatus = 'finished';
55
 
56
+ console.log( response.data );
57
  console.log( "Reindex finished!" );
58
 
59
  $reindexBlock.removeClass('loading');
assets/js/common.js CHANGED
@@ -25,7 +25,7 @@
25
 
26
  searchFor = $searchField.val();
27
  searchFor = searchFor.trim();
28
- searchFor = searchFor.replace( /[`~!@#$%^&*()_|+\?;:'",.<>\{\}\[\]\\\/]/gi, '' );
29
  searchFor = searchFor.replace( /\s\s+/g, ' ' );
30
 
31
  for ( var i = 0; i < requests.length; i++ ) {
25
 
26
  searchFor = $searchField.val();
27
  searchFor = searchFor.trim();
28
+ searchFor = searchFor.replace( /[`~!@#$%^&*()\-_|+\?;:'",.<>\{\}\[\]\\\/]/gi, '' );
29
  searchFor = searchFor.replace( /\s\s+/g, ' ' );
30
 
31
  for ( var i = 0; i < requests.length; i++ ) {
includes/class-aws-search-page.php CHANGED
@@ -96,7 +96,7 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
96
 
97
  $new_posts = array();
98
 
99
- $search_query = str_replace( array( '.', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '|', '+', '\\', '?', ';', ':', '"', ',', '<', '>', '{', '}', '/' ), '', $query->query_vars['s'] );
100
  $posts_array = aws_search( $search_query );
101
 
102
  $query->found_posts = count( $posts_array['products'] );
96
 
97
  $new_posts = array();
98
 
99
+ $search_query = str_replace( array( '.', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '|', '+', '\\', '?', ';', ':', '"', ',', '<', '>', '{', '}', '/' ), '', $query->query_vars['s'] );
100
  $posts_array = aws_search( $search_query );
101
 
102
  $query->found_posts = count( $posts_array['products'] );
includes/class-aws-search.php CHANGED
@@ -193,8 +193,8 @@ if ( ! class_exists( 'AWS_Search' ) ) :
193
  $relevance_title_like = 40 + 2 * $search_term_len;
194
  $relevance_content_like = 35 + 1 * $search_term_len;
195
 
196
-
197
- $like = '%' . $wpdb->esc_like( $search_term ) . '%';
198
 
199
  if ( $search_term_len > 1 ) {
200
  $search_array[] = $wpdb->prepare( '( term LIKE %s )', $like );
@@ -231,6 +231,11 @@ if ( ! class_exists( 'AWS_Search' ) ) :
231
  $relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term LIKE %s ) then 5 else 0 end )", $like );
232
  break;
233
 
 
 
 
 
 
234
  }
235
 
236
  }
@@ -264,7 +269,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
264
  }
265
 
266
 
267
- if ( $reindex_version && version_compare( $reindex_version, '1.20', '>=' ) ) {
268
  if ( has_filter('wpml_current_language') ) {
269
  $current_lang = apply_filters( 'wpml_current_language', NULL );
270
  if ( $current_lang ) {
193
  $relevance_title_like = 40 + 2 * $search_term_len;
194
  $relevance_content_like = 35 + 1 * $search_term_len;
195
 
196
+ $search_term_like = preg_replace( '/(s|es|ies)$/i', '', $search_term );
197
+ $like = '%' . $wpdb->esc_like( $search_term_like ) . '%';
198
 
199
  if ( $search_term_len > 1 ) {
200
  $search_array[] = $wpdb->prepare( '( term LIKE %s )', $like );
231
  $relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term LIKE %s ) then 5 else 0 end )", $like );
232
  break;
233
 
234
+ case 'sku':
235
+ $relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term = '%s' ) then 300 else 0 end )", $search_term );
236
+ $relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term LIKE %s ) then 50 else 0 end )", $like );
237
+ break;
238
+
239
  }
240
 
241
  }
269
  }
270
 
271
 
272
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && $reindex_version && version_compare( $reindex_version, '1.20', '>=' ) ) {
273
  if ( has_filter('wpml_current_language') ) {
274
  $current_lang = apply_filters( 'wpml_current_language', NULL );
275
  if ( $current_lang ) {
includes/class-aws-table.php CHANGED
@@ -38,6 +38,8 @@ if ( ! class_exists( 'AWS_Table' ) ) :
38
 
39
  add_action( 'wp_ajax_aws-reindex', array( $this, 'reindex_table' ) );
40
 
 
 
41
  add_action( 'wp_ajax_aws-cancel-index', array( $this, 'cancel_reindex' ) );
42
 
43
  add_action( 'wp_ajax_aws-clear-cache', array( &$this, 'clear_cache' ) );
@@ -47,7 +49,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
47
  /*
48
  * Reindex plugin table
49
  */
50
- public function reindex_table() {
51
 
52
  global $wpdb;
53
 
@@ -137,7 +139,24 @@ if ( ! class_exists( 'AWS_Table' ) ) :
137
 
138
  }
139
 
140
- wp_send_json_success( $index_meta );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
141
 
142
  }
143
 
@@ -287,7 +306,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
287
 
288
 
289
  // Get translations if exists
290
- if ( has_filter('wpml_element_has_translations') && has_filter('wpml_get_element_translations') ) {
291
 
292
  $is_translated = apply_filters( 'wpml_element_has_translations', NULL, $data['id'], 'post_product' );
293
 
@@ -497,6 +516,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
497
  //$str = preg_replace( '/\b\w{1}\b/i', " ", $str );
498
 
499
  $str = str_replace( array(
 
500
  '_',
501
  '|',
502
  '+',
38
 
39
  add_action( 'wp_ajax_aws-reindex', array( $this, 'reindex_table' ) );
40
 
41
+ add_action( 'aws_reindex_table', array( $this, 'reindex_table_job' ) );
42
+
43
  add_action( 'wp_ajax_aws-cancel-index', array( $this, 'cancel_reindex' ) );
44
 
45
  add_action( 'wp_ajax_aws-clear-cache', array( &$this, 'clear_cache' ) );
49
  /*
50
  * Reindex plugin table
51
  */
52
+ public function reindex_table( $return = false ) {
53
 
54
  global $wpdb;
55
 
139
 
140
  }
141
 
142
+ if ( $return ) {
143
+ return $index_meta;
144
+ } else {
145
+ wp_send_json_success( $index_meta );
146
+ }
147
+
148
+ }
149
+
150
+ /*
151
+ * Cron job function
152
+ */
153
+ public function reindex_table_job() {
154
+
155
+ do {
156
+ $meta = $this->reindex_table( true );
157
+ $offset = (int) isset( $meta['offset'] ) ? $meta['offset'] : 0;
158
+ $start = (int) isset( $meta['start'] ) ? $meta['start'] : 0;
159
+ } while ( !( $offset === 0 && ! $start ) );
160
 
161
  }
162
 
306
 
307
 
308
  // Get translations if exists
309
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter('wpml_element_has_translations') && has_filter('wpml_get_element_translations') ) {
310
 
311
  $is_translated = apply_filters( 'wpml_element_has_translations', NULL, $data['id'], 'post_product' );
312
 
516
  //$str = preg_replace( '/\b\w{1}\b/i', " ", $str );
517
 
518
  $str = str_replace( array(
519
+ '-',
520
  '_',
521
  '|',
522
  '+',
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.8.1
7
- Stable tag: 1.23
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -26,7 +26,9 @@ Advanced Woo Search - powerful live search plugin for WooCommerce. Just start ty
26
  * **Smart ordering** - Search results ordered by the priority of source where they were found
27
  * **Fast** - Nothing extra. Just what you need for proper work
28
  * **WPML**, **WooCommerce Multilingual** support
29
- * Supports variable products
 
 
30
  * Google Analytics support
31
 
32
  = Premium Features =
@@ -74,6 +76,12 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
74
 
75
  == Changelog ==
76
 
 
 
 
 
 
 
77
  = 1.23 =
78
  * Add 'Stop-words list' option
79
 
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.8.1
7
+ Stable tag: 1.24
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
26
  * **Smart ordering** - Search results ordered by the priority of source where they were found
27
  * **Fast** - Nothing extra. Just what you need for proper work
28
  * **WPML**, **WooCommerce Multilingual** support
29
+ * Supports **variable products**
30
+ * **Stop words** - you can specify list of words that will be excluded from search
31
+ * Plurals support
32
  * Google Analytics support
33
 
34
  = Premium Features =
76
 
77
  == Changelog ==
78
 
79
+ = 1.24 =
80
+ * Add plurals support
81
+ * Fix Polylang plugin conflict
82
+ * Fix SKU search bug
83
+ * Add function for cron job
84
+
85
  = 1.23 =
86
  * Add 'Stop-words list' option
87