Advanced Woo Search - Version 1.78

Version Description

  • Update - Better plurals search support
  • Add - Divi theme seamless integration
  • Add - Wholesale plugin support
Download this release

Release Info

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

Code changes from version 1.77 to 1.78

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: 1.77
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: 3.6.0
12
  */
13
 
14
 
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
17
  }
18
 
19
- define( 'AWS_VERSION', '1.77' );
20
 
21
 
22
  define( 'AWS_DIR', dirname( __FILE__ ) );
@@ -106,6 +106,7 @@ final class AWS_Main {
106
  include_once( 'includes/class-aws-admin-fields.php' );
107
  include_once( 'includes/class-aws-admin.php' );
108
  include_once( 'includes/class-aws-cache.php' );
 
109
  include_once( 'includes/class-aws-table.php' );
110
  include_once( 'includes/class-aws-markup.php' );
111
  include_once( 'includes/class-aws-search.php' );
@@ -142,6 +143,7 @@ final class AWS_Main {
142
  */
143
  public function init() {
144
  $this->cache = AWS_Cache::factory();
 
145
  }
146
 
147
  /*
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
+ Version: 1.78
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: 3.7.0
12
  */
13
 
14
 
16
  exit;
17
  }
18
 
19
+ define( 'AWS_VERSION', '1.78' );
20
 
21
 
22
  define( 'AWS_DIR', dirname( __FILE__ ) );
106
  include_once( 'includes/class-aws-admin-fields.php' );
107
  include_once( 'includes/class-aws-admin.php' );
108
  include_once( 'includes/class-aws-cache.php' );
109
+ include_once( 'includes/class-aws-plurals.php' );
110
  include_once( 'includes/class-aws-table.php' );
111
  include_once( 'includes/class-aws-markup.php' );
112
  include_once( 'includes/class-aws-search.php' );
143
  */
144
  public function init() {
145
  $this->cache = AWS_Cache::factory();
146
+ AWS_Integrations::instance();
147
  }
148
 
149
  /*
assets/css/common.css CHANGED
@@ -426,4 +426,21 @@
426
  }
427
  .aws-search-result .aws_search_more a:hover {
428
  background: #f5f5f5;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
429
  }
426
  }
427
  .aws-search-result .aws_search_more a:hover {
428
  background: #f5f5f5;
429
+ }
430
+
431
+
432
+ /* Integrations */
433
+
434
+ .et_search_outer .aws-container {
435
+ width: 60%;
436
+ }
437
+ .et_search_outer .aws-container .aws-search-form {
438
+ max-width: 100% !important;
439
+ }
440
+ .et_vertical_nav .et_search_outer .aws-container {
441
+ width: auto;
442
+ margin-right: 20px;
443
+ }
444
+ .et_fixed_nav .et-fixed-header .et_search_outer .aws-container {
445
+ margin-top: 5px;
446
  }
includes/class-aws-integrations.php CHANGED
@@ -72,6 +72,16 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
72
  add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) );
73
  add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) );
74
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
 
77
  /*
@@ -375,8 +385,61 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
375
 
376
  }
377
 
378
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
 
380
- endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
 
382
- AWS_Integrations::instance();
72
  add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) );
73
  add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) );
74
 
75
+ // Seamless integration
76
+ if ( AWS()->get_settings( 'seamless' ) === 'true' ) {
77
+ add_filter( 'et_html_main_header', array( $this, 'et_html_main_header' ) );
78
+ }
79
+
80
+ // Wholesale plugin hide certain products
81
+ if ( class_exists( 'WooCommerceWholeSalePrices' ) ) {
82
+ add_filter( 'aws_search_results_products', array( $this,'wholesale_hide_products' ) );
83
+ }
84
+
85
  }
86
 
87
  /*
385
 
386
  }
387
 
388
+ /*
389
+ * Divi theme seamless integration for header
390
+ */
391
+ public function et_html_main_header( $html ) {
392
+ if ( function_exists( 'aws_get_search_form' ) ) {
393
+ $pattern = '/(<form.*?<\/form>)/i';
394
+ $form = aws_get_search_form(false);
395
+ $html = '<style>.aws-container { float: right;margin-right: 40px;margin-top: 20px; }</style>' . $html;
396
+ $html = trim(preg_replace('/\s\s+/', ' ', $html));
397
+ $html = preg_replace( $pattern, $form, $html );
398
+ }
399
+ return $html;
400
+ }
401
+
402
+ /*
403
+ * Wholesale plugin hide products
404
+ */
405
+ public function wholesale_hide_products( $products ) {
406
+
407
+ $user_role = 'all';
408
+ if ( is_user_logged_in() ) {
409
+ $user = wp_get_current_user();
410
+ $roles = ( array ) $user->roles;
411
+ $user_role = $roles[0];
412
+ }
413
 
414
+ $all_registered_wholesale_roles = unserialize( get_option( 'wwp_options_registered_custom_roles' ) );
415
+ if ( ! is_array( $all_registered_wholesale_roles ) ) {
416
+ $all_registered_wholesale_roles = array();
417
+ }
418
+
419
+ $new_products_array = array();
420
+
421
+ foreach( $products as $product ) {
422
+
423
+ $custom_fields = get_post_meta( $product['id'], 'wwpp_product_wholesale_visibility_filter' );
424
+ $custom_price = get_post_meta( $product['id'], 'wholesale_customer_wholesale_price' );
425
+
426
+ if ( $custom_fields && ! empty( $custom_fields ) && $custom_fields[0] !== 'all' && $custom_fields[0] !== $user_role ) {
427
+ continue;
428
+ }
429
+
430
+ if ( is_user_logged_in() && !empty( $all_registered_wholesale_roles ) && isset( $all_registered_wholesale_roles[$user_role] )
431
+ && get_option( 'wwpp_settings_only_show_wholesale_products_to_wholesale_users', false ) === 'yes' && ! $custom_price ) {
432
+ continue;
433
+ }
434
+
435
+ $new_products_array[] = $product;
436
+
437
+ }
438
+
439
+ return $new_products_array;
440
+
441
+ }
442
+
443
+ }
444
 
445
+ endif;
includes/class-aws-plurals.php ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ if ( ! class_exists( 'AWS_Plurals' ) ) :
8
+
9
+ /**
10
+ * Class for plurals words forms
11
+ */
12
+ class AWS_Plurals {
13
+
14
+ /**
15
+ * Singular rules
16
+ *
17
+ * @var array
18
+ */
19
+ protected static $_singular = array(
20
+ '/(s)tatuses$/i' => '\1\2tatus',
21
+ '/^(.*)(menu)s$/i' => '\1\2',
22
+ '/(quiz)zes$/i' => '\\1',
23
+ '/(matr)ices$/i' => '\1ix',
24
+ '/(vert|ind)ices$/i' => '\1ex',
25
+ '/^(ox)en/i' => '\1',
26
+ '/(alias)(es)*$/i' => '\1',
27
+ '/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
28
+ '/([ftw]ax)es/i' => '\1',
29
+ '/(cris|ax|test)es$/i' => '\1is',
30
+ '/(shoe)s$/i' => '\1',
31
+ '/(o)es$/i' => '\1',
32
+ '/ouses$/' => 'ouse',
33
+ '/([^a])uses$/' => '\1us',
34
+ '/([m|l])ice$/i' => '\1ouse',
35
+ '/(x|ch|ss|sh)es$/i' => '\1',
36
+ '/(m)ovies$/i' => '\1\2ovie',
37
+ '/(s)eries$/i' => '\1\2eries',
38
+ '/([^aeiouy]|qu)ies$/i' => '\1y',
39
+ '/(tive)s$/i' => '\1',
40
+ '/(hive)s$/i' => '\1',
41
+ '/(drive)s$/i' => '\1',
42
+ '/([le])ves$/i' => '\1f',
43
+ '/([^rfoa])ves$/i' => '\1fe',
44
+ '/(^analy)ses$/i' => '\1sis',
45
+ '/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
46
+ '/([ti])a$/i' => '\1um',
47
+ '/(p)eople$/i' => '\1\2erson',
48
+ '/(m)en$/i' => '\1an',
49
+ '/(c)hildren$/i' => '\1\2hild',
50
+ '/(n)ews$/i' => '\1\2ews',
51
+ '/eaus$/' => 'eau',
52
+ '/^(.*us)$/' => '\\1',
53
+ '/s$/i' => ''
54
+ );
55
+
56
+ /**
57
+ * Irregular rules
58
+ *
59
+ * @var array
60
+ */
61
+ protected static $_irregular = array(
62
+ 'atlases' => 'atlas',
63
+ 'beefs' => 'beef',
64
+ 'briefs' => 'brief',
65
+ 'brothers' => 'brother',
66
+ 'cafes' => 'cafe',
67
+ 'children' => 'child',
68
+ 'cookies' => 'cookie',
69
+ 'corpuses' => 'corpus',
70
+ 'cows' => 'cow',
71
+ 'criteria' => 'criterion',
72
+ 'ganglions' => 'ganglion',
73
+ 'genies' => 'genie',
74
+ 'genera' => 'genus',
75
+ 'graffiti' => 'graffito',
76
+ 'hoofs' => 'hoof',
77
+ 'loaves' => 'loaf',
78
+ 'men' => 'man',
79
+ 'monies' => 'money',
80
+ 'mongooses' => 'mongoose',
81
+ 'moves' => 'move',
82
+ 'mythoi' => 'mythos',
83
+ 'niches' => 'niche',
84
+ 'numina' => 'numen',
85
+ 'occiputs' => 'occiput',
86
+ 'octopuses' => 'octopus',
87
+ 'opuses' => 'opus',
88
+ 'oxen' => 'ox',
89
+ 'penises' => 'penis',
90
+ 'sexes' => 'sex',
91
+ 'soliloquies' => 'soliloquy',
92
+ 'testes' => 'testis',
93
+ 'trilbys' => 'trilby',
94
+ 'turfs' => 'turf',
95
+ 'potatoes' => 'potato',
96
+ 'heroes' => 'hero',
97
+ 'teeth' => 'tooth',
98
+ 'geese' => 'goose',
99
+ 'feet' => 'foot',
100
+ 'foes' => 'foe',
101
+ 'sieves' => 'sieve',
102
+ 'caches' => 'cache',
103
+ );
104
+
105
+ /**
106
+ * Words that should not be inflected
107
+ *
108
+ * @var array
109
+ */
110
+ protected static $_uninflected = array(
111
+ '.*[nrlm]ese', '.*data', '.*deer', '.*fish', '.*measles', '.*ois',
112
+ '.*pox', '.*sheep', 'feedback', 'stadia', '.*?media',
113
+ 'chassis', 'clippers', 'debris', 'diabetes', 'equipment', 'gallows',
114
+ 'graffiti', 'headquarters', 'information', 'innings', 'news', 'nexus',
115
+ 'pokemon', 'proceedings', 'research', 'sea[- ]bass', 'series', 'species', 'weather'
116
+ );
117
+
118
+ /**
119
+ * Method cache array.
120
+ *
121
+ * @var array
122
+ */
123
+ protected static $_cache = array();
124
+
125
+ /**
126
+ * Cache inflected values, and return if already available
127
+ *
128
+ * @param string $type Inflection type
129
+ * @param string $key Original value
130
+ * @param string|bool $value Inflected value
131
+ * @return string|false Inflected value on cache hit or false on cache miss.
132
+ */
133
+ protected static function _cache($type, $key, $value = false)
134
+ {
135
+ $key = '_' . $key;
136
+ $type = '_' . $type;
137
+ if ($value !== false) {
138
+ static::$_cache[$type][$key] = $value;
139
+ return $value;
140
+ }
141
+ if (!isset(static::$_cache[$type][$key])) {
142
+ return false;
143
+ }
144
+ return static::$_cache[$type][$key];
145
+ }
146
+
147
+ /**
148
+ * Return $word in singular form.
149
+ *
150
+ * @param string $word Word in plural
151
+ * @return string Word in singular
152
+ */
153
+ public static function singularize( $word ) {
154
+
155
+ if ( isset( static::$_cache['singularize'][$word] ) ) {
156
+ return static::$_cache['singularize'][$word];
157
+ }
158
+
159
+ if ( isset( static::$_irregular[$word] ) ) {
160
+ static::$_cache['singularize'][$word] = static::$_irregular[$word];
161
+ return static::$_cache['singularize'][$word];
162
+ }
163
+
164
+ if ( !isset( static::$_cache['uninflected'] ) ) {
165
+ static::$_cache['uninflected'] = '(?:' . implode('|', static::$_uninflected) . ')';
166
+ }
167
+
168
+ if ( preg_match( '/^(' . static::$_cache['uninflected'] . ')$/i', $word, $regs ) ) {
169
+ static::$_cache['singularize'][$word] = $word;
170
+ return $word;
171
+ }
172
+
173
+ if ( preg_match( '/(s|es|ies)$/i', $word, $match ) ) {
174
+ foreach ( static::$_singular as $rule => $replacement ) {
175
+ if ( preg_match($rule, $word ) ) {
176
+ static::$_cache['singularize'][$word] = preg_replace( $rule, $replacement, $word );
177
+ return static::$_cache['singularize'][$word];
178
+ }
179
+ }
180
+ }
181
+
182
+ static::$_cache['singularize'][$word] = $word;
183
+
184
+ return $word;
185
+
186
+ }
187
+
188
+ }
189
+
190
+ endif;
includes/class-aws-search.php CHANGED
@@ -294,8 +294,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
294
  $relevance_title_like = 40 + 2 * $search_term_len;
295
  $relevance_content_like = 35 + 1 * $search_term_len;
296
 
297
-
298
- $search_term_norm = preg_replace( '/(s|es|ies)$/i', '', $search_term );
299
 
300
  if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
301
  $search_term = $search_term_norm;
@@ -751,7 +750,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
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;
294
  $relevance_title_like = 40 + 2 * $search_term_len;
295
  $relevance_content_like = 35 + 1 * $search_term_len;
296
 
297
+ $search_term_norm = AWS_Plurals::singularize( $search_term );
 
298
 
299
  if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
300
  $search_term = $search_term_norm;
750
 
751
  $search_term_len = strlen( $search_term );
752
  $relevance = 40 + 2 * $search_term_len;
753
+ $search_term_norm = AWS_Plurals::singularize( $search_term );
754
 
755
  if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
756
  $search_term = $search_term_norm;
includes/class-aws-table.php CHANGED
@@ -820,7 +820,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
820
  if ( ! empty( $str_array ) && $str_array ) {
821
  foreach( $str_array as $str_item_term => $str_item_num ) {
822
  if ( $str_item_term ) {
823
- $new_array_key = preg_replace( '/(s|es|ies)$/i', '', $str_item_term );
824
 
825
  if ( $new_array_key && strlen( $str_item_term ) > 3 && strlen( $new_array_key ) > 2 ) {
826
  if ( ! isset( $str_new_array[$new_array_key] ) ) {
820
  if ( ! empty( $str_array ) && $str_array ) {
821
  foreach( $str_array as $str_item_term => $str_item_num ) {
822
  if ( $str_item_term ) {
823
+ $new_array_key = AWS_Plurals::singularize( $str_item_term );
824
 
825
  if ( $new_array_key && strlen( $str_item_term ) > 3 && strlen( $new_array_key ) > 2 ) {
826
  if ( ! isset( $str_new_array[$new_array_key] ) ) {
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.77
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -103,6 +103,11 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
106
  = 1.77 =
107
  * Fix - Order by price bug on search results page
108
  * Update - plugin text domain
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.78
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
103
 
104
  == Changelog ==
105
 
106
+ = 1.78 =
107
+ * Update - Better plurals search support
108
+ * Add - Divi theme seamless integration
109
+ * Add - Wholesale plugin support
110
+
111
  = 1.77 =
112
  * Fix - Order by price bug on search results page
113
  * Update - plugin text domain