Advanced Woo Search - Version 1.60

Version Description

  • Update cron job action
  • Update Protected Categories plugin integration
  • Update B2B Market plugin integration
  • Add WC Marketplace plugin integration
  • Add new option to disable auto sync for index page
  • Add aws_filter_yikes_woo_products_tabs_sync filter
  • Add aws_search_data_params filter
  • Add aws_search_pre_filter_products filter
Download this release

Release Info

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

Code changes from version 1.59 to 1.60

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.59
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.59' );
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.60
7
  Author: ILLID
8
  Author URI: https://advanced-woo-search.com/
9
  Text Domain: aws
16
  exit;
17
  }
18
 
19
+ define( 'AWS_VERSION', '1.60' );
20
 
21
 
22
  define( 'AWS_DIR', dirname( __FILE__ ) );
includes/class-aws-integrations.php CHANGED
@@ -47,7 +47,12 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
47
  add_action( 'aws_search_start', array( $this, 'b2b_set_filter' ) );
48
  }
49
 
50
- if ( class_exists( 'WC_PPC_Util' ) ) {
 
 
 
 
 
51
  add_action( 'aws_search_start', array( $this, 'wc_ppc_set_filter' ) );
52
  }
53
 
@@ -55,6 +60,12 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
55
  add_filter( 'woocommerce_currency_symbol', array( $this, 'dfrapi_set_currency_symbol_filter' ), 10, 2 );
56
  }
57
 
 
 
 
 
 
 
58
  add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) );
59
  add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) );
60
 
@@ -65,51 +76,57 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
65
  */
66
  public function b2b_set_filter() {
67
 
68
- if ( is_user_logged_in() ) {
 
 
 
 
 
 
 
 
69
 
 
 
 
 
 
70
  $user = wp_get_current_user();
71
  $role = ( array ) $user->roles;
72
  $user_role = $role[0];
73
-
74
- if ( $user_role ) {
75
-
76
- $args = array(
77
- 'posts_per_page' => - 1,
78
- 'post_type' => 'customer_groups',
79
- 'post_status' => 'publish',
80
- );
81
-
82
- $posts = get_posts( $args );
83
- $customer_groups = array();
84
-
85
- foreach ( $posts as $customer_group ) {
86
- $customer_groups[$customer_group->post_name] = $customer_group->ID;
87
  }
 
 
88
 
89
- if ( isset( $customer_groups[$user_role] ) ) {
90
- $curret_customer_group_id = $customer_groups[$user_role];
91
 
92
- $whitelist = get_post_meta( $curret_customer_group_id, 'bm_conditional_all_products', true );
 
93
 
94
- if ( $whitelist && $whitelist === 'off' ) {
95
 
96
- $products_to_exclude = get_post_meta( $curret_customer_group_id, 'bm_conditional_products', false );
97
- $cats_to_exclude = get_post_meta( $curret_customer_group_id, 'bm_conditional_categories', false );
98
 
99
- if ( $products_to_exclude && ! empty( $products_to_exclude ) ) {
 
100
 
101
- foreach( $products_to_exclude as $product_to_exclude ) {
102
- $this->data['exclude_products'][] = trim( $product_to_exclude, ',' );
103
- }
104
 
 
 
105
  }
106
 
107
- if ( $cats_to_exclude && ! empty( $cats_to_exclude ) ) {
108
 
109
- foreach( $cats_to_exclude as $cat_to_exclude ) {
110
- $this->data['exclude_categories'][] = trim( $cat_to_exclude, ',' );
111
- }
112
 
 
 
113
  }
114
 
115
  }
@@ -194,6 +211,93 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
194
 
195
  }
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  /*
198
  * Exclude product categories
199
  */
47
  add_action( 'aws_search_start', array( $this, 'b2b_set_filter' ) );
48
  }
49
 
50
+ // Protected categories
51
+ if ( class_exists( 'WC_PPC_Util' )
52
+ && method_exists( 'WC_PPC_Util', 'showing_protected_categories' )
53
+ && method_exists( 'WC_PPC_Util', 'to_category_visibilities' )
54
+ && method_exists( 'WC_PPC_Util', 'get_product_categories' )
55
+ ) {
56
  add_action( 'aws_search_start', array( $this, 'wc_ppc_set_filter' ) );
57
  }
58
 
60
  add_filter( 'woocommerce_currency_symbol', array( $this, 'dfrapi_set_currency_symbol_filter' ), 10, 2 );
61
  }
62
 
63
+ // WC Marketplace - https://wc-marketplace.com/
64
+ if ( defined( 'WCMp_PLUGIN_VERSION' ) ) {
65
+ add_filter( 'aws_search_data_params', array( $this, 'wc_marketplace_filter' ), 10, 3 );
66
+ add_filter( 'aws_search_pre_filter_products', array( $this, 'wc_marketplace_products_filter' ), 10, 2 );
67
+ }
68
+
69
  add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) );
70
  add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) );
71
 
76
  */
77
  public function b2b_set_filter() {
78
 
79
+ $args = array(
80
+ 'posts_per_page' => - 1,
81
+ 'post_type' => 'customer_groups',
82
+ 'post_status' => 'publish',
83
+ );
84
+
85
+ $posts = get_posts( $args );
86
+ $customer_groups = array();
87
+ $user_role = '';
88
 
89
+ foreach ( $posts as $customer_group ) {
90
+ $customer_groups[$customer_group->post_name] = $customer_group->ID;
91
+ }
92
+
93
+ if ( is_user_logged_in() ) {
94
  $user = wp_get_current_user();
95
  $role = ( array ) $user->roles;
96
  $user_role = $role[0];
97
+ } else {
98
+ $guest_slugs = array( 'Gast', 'Gäste', 'Guest', 'Guests', 'gast', 'gäste', 'guest', 'guests' );
99
+ foreach( $customer_groups as $customer_group_key => $customer_group_id ) {
100
+ if ( in_array( $customer_group_key, $guest_slugs ) ) {
101
+ $user_role = $customer_group_key;
 
 
 
 
 
 
 
 
 
102
  }
103
+ }
104
+ }
105
 
106
+ if ( $user_role ) {
 
107
 
108
+ if ( isset( $customer_groups[$user_role] ) ) {
109
+ $curret_customer_group_id = $customer_groups[$user_role];
110
 
111
+ $whitelist = get_post_meta( $curret_customer_group_id, 'bm_conditional_all_products', true );
112
 
113
+ if ( $whitelist && $whitelist === 'off' ) {
 
114
 
115
+ $products_to_exclude = get_post_meta( $curret_customer_group_id, 'bm_conditional_products', false );
116
+ $cats_to_exclude = get_post_meta( $curret_customer_group_id, 'bm_conditional_categories', false );
117
 
118
+ if ( $products_to_exclude && ! empty( $products_to_exclude ) ) {
 
 
119
 
120
+ foreach( $products_to_exclude as $product_to_exclude ) {
121
+ $this->data['exclude_products'][] = trim( $product_to_exclude, ',' );
122
  }
123
 
124
+ }
125
 
126
+ if ( $cats_to_exclude && ! empty( $cats_to_exclude ) ) {
 
 
127
 
128
+ foreach( $cats_to_exclude as $cat_to_exclude ) {
129
+ $this->data['exclude_categories'][] = trim( $cat_to_exclude, ',' );
130
  }
131
 
132
  }
211
 
212
  }
213
 
214
+ /*
215
+ * WC Marketplace plugin support
216
+ */
217
+ public function wc_marketplace_filter( $data, $post_id, $product ) {
218
+
219
+ $wcmp_spmv_map_id = get_post_meta( $post_id, '_wcmp_spmv_map_id', true );
220
+
221
+ if ( $wcmp_spmv_map_id ) {
222
+
223
+ if ( isset( $data['wcmp_price'] ) && isset( $data['wcmp_price'][$wcmp_spmv_map_id] ) ) {
224
+
225
+ if ( $product->get_price() < $data['wcmp_price'][$wcmp_spmv_map_id] ) {
226
+ $data['wcmp_price'][$wcmp_spmv_map_id] = $product->get_price();
227
+ $data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] = $post_id;
228
+ }
229
+
230
+ } else {
231
+ $data['wcmp_price'][$wcmp_spmv_map_id] = $product->get_price();
232
+ }
233
+
234
+ $data['wcmp_spmv_product_id'][$wcmp_spmv_map_id][] = $post_id;
235
+
236
+ }
237
+
238
+ return $data;
239
+
240
+ }
241
+
242
+ /*
243
+ * WC Marketplace plugin products filter
244
+ */
245
+ public function wc_marketplace_products_filter( $products_array, $data ) {
246
+
247
+ $wcmp_spmv_exclude_ids = array();
248
+
249
+ if ( isset( $data['wcmp_spmv_product_id'] ) ) {
250
+
251
+ foreach( $data['wcmp_spmv_product_id'] as $wcmp_spmv_map_id => $wcmp_spmv_product_id ) {
252
+
253
+ if ( count( $wcmp_spmv_product_id ) > 1 ) {
254
+
255
+ if ( isset( $data['wcmp_lowest_price_id'] ) && isset( $data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] ) ) {
256
+
257
+ foreach ( $wcmp_spmv_product_id as $wcmp_spmv_product_id_n ) {
258
+
259
+ if ( $wcmp_spmv_product_id_n === $data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] ) {
260
+ continue;
261
+ }
262
+
263
+ $wcmp_spmv_exclude_ids[] = $wcmp_spmv_product_id_n;
264
+
265
+ }
266
+
267
+ } else {
268
+
269
+ foreach ( $wcmp_spmv_product_id as $key => $wcmp_spmv_product_id_n ) {
270
+
271
+ if ( $key === 0 ) {
272
+ continue;
273
+ }
274
+
275
+ $wcmp_spmv_exclude_ids[] = $wcmp_spmv_product_id_n;
276
+
277
+ }
278
+
279
+ }
280
+
281
+ }
282
+
283
+ }
284
+
285
+ }
286
+
287
+ $new_product_array = array();
288
+
289
+ foreach( $products_array as $key => $pr_arr ) {
290
+
291
+ if ( ! in_array( $pr_arr['id'], $wcmp_spmv_exclude_ids ) ) {
292
+ $new_product_array[] = $pr_arr;
293
+ }
294
+
295
+ }
296
+
297
+ return $new_product_array;
298
+
299
+ }
300
+
301
  /*
302
  * Exclude product categories
303
  */
includes/class-aws-search.php CHANGED
@@ -483,6 +483,15 @@ if ( ! class_exists( 'AWS_Search' ) ) :
483
  continue;
484
  }
485
 
 
 
 
 
 
 
 
 
 
486
  $post_data = get_post( $post_id );
487
 
488
  $title = $product->get_title();
@@ -566,6 +575,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
566
  // $tags = $product->get_tags( ',' );
567
 
568
  $new_result = array(
 
569
  'title' => $title,
570
  'excerpt' => $excerpt,
571
  'link' => get_permalink( $post_id ),
@@ -586,6 +596,14 @@ if ( ! class_exists( 'AWS_Search' ) ) :
586
 
587
  }
588
 
 
 
 
 
 
 
 
 
589
  return $products_array;
590
 
591
  }
483
  continue;
484
  }
485
 
486
+ /**
487
+ * Filter additional product data
488
+ * @since 1.60
489
+ * @param array $this->data Additional data
490
+ * @param int $post_id Product id
491
+ * @param object $product Product
492
+ */
493
+ $this->data = apply_filters( 'aws_search_data_params', $this->data, $post_id, $product );
494
+
495
  $post_data = get_post( $post_id );
496
 
497
  $title = $product->get_title();
575
  // $tags = $product->get_tags( ',' );
576
 
577
  $new_result = array(
578
+ 'id' => $post_id,
579
  'title' => $title,
580
  'excerpt' => $excerpt,
581
  'link' => get_permalink( $post_id ),
596
 
597
  }
598
 
599
+ /**
600
+ * Filter products array before output
601
+ * @since 1.60
602
+ * @param array $products_array Products array
603
+ * @param array $this->data Additional data
604
+ */
605
+ $products_array = apply_filters( 'aws_search_pre_filter_products', $products_array, $this->data );
606
+
607
  return $products_array;
608
 
609
  }
includes/class-aws-table.php CHANGED
@@ -185,7 +185,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
185
  // Fallback if re-index failed by timeout in this iteration
186
  if ( ! isset( $meta['attemps'] ) || ( isset( $meta['attemps'] ) && $meta['attemps'] < $max_cron_attemps ) ) {
187
  if ( ! wp_next_scheduled( 'aws_reindex_table', array( 'inner' ) ) ) {
188
- wp_schedule_single_event( time() + 700, 'aws_reindex_table', array( 'inner' ) );
189
  }
190
  }
191
 
@@ -662,7 +662,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
662
  */
663
  public function updated_custom_tabs( $meta_id, $object_id, $meta_key, $meta_value ) {
664
 
665
- if ( $meta_key === 'yikes_woo_products_tabs' ) {
666
 
667
  $this->update_table( $object_id );
668
 
@@ -677,10 +677,16 @@ if ( ! class_exists( 'AWS_Table' ) ) :
677
 
678
  global $wpdb;
679
 
 
 
680
  if ( AWS_Helpers::is_table_not_exist() ) {
681
  $this->create_table();
682
  }
683
 
 
 
 
 
684
  $wpdb->delete( $this->table_name, array( 'id' => $product_id ) );
685
 
686
  $posts = get_posts( array(
185
  // Fallback if re-index failed by timeout in this iteration
186
  if ( ! isset( $meta['attemps'] ) || ( isset( $meta['attemps'] ) && $meta['attemps'] < $max_cron_attemps ) ) {
187
  if ( ! wp_next_scheduled( 'aws_reindex_table', array( 'inner' ) ) ) {
188
+ wp_schedule_single_event( time() + 60, 'aws_reindex_table', array( 'inner' ) );
189
  }
190
  }
191
 
662
  */
663
  public function updated_custom_tabs( $meta_id, $object_id, $meta_key, $meta_value ) {
664
 
665
+ if ( $meta_key === 'yikes_woo_products_tabs' && apply_filters( 'aws_filter_yikes_woo_products_tabs_sync', true ) ) {
666
 
667
  $this->update_table( $object_id );
668
 
677
 
678
  global $wpdb;
679
 
680
+ $sunc = AWS()->get_settings( 'autoupdates' );
681
+
682
  if ( AWS_Helpers::is_table_not_exist() ) {
683
  $this->create_table();
684
  }
685
 
686
+ if ( $sunc === 'false' ) {
687
+ return;
688
+ }
689
+
690
  $wpdb->delete( $this->table_name, array( 'id' => $product_id ) );
691
 
692
  $posts = get_posts( array(
includes/class-aws-versions.php CHANGED
@@ -257,6 +257,19 @@ if ( ! class_exists( 'AWS_Versions' ) ) :
257
 
258
  }
259
 
 
 
 
 
 
 
 
 
 
 
 
 
 
260
  }
261
 
262
  update_option( 'aws_plugin_ver', AWS_VERSION );
257
 
258
  }
259
 
260
+ if ( version_compare( $current_version, '1.60', '<' ) ) {
261
+
262
+ $settings = get_option( 'aws_settings' );
263
+
264
+ if ( $settings ) {
265
+ if ( ! isset( $settings['autoupdates'] ) ) {
266
+ $settings['autoupdates'] = 'true';
267
+ update_option( 'aws_settings', $settings );
268
+ }
269
+ }
270
+
271
+ }
272
+
273
  }
274
 
275
  update_option( 'aws_plugin_ver', AWS_VERSION );
includes/options.php CHANGED
@@ -34,6 +34,19 @@ $options['general'][] = array(
34
  )
35
  );
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  $options['general'][] = array(
38
  "name" => __( "Search in", "aws" ),
39
  "desc" => __( "Search source: Drag&drop sources to activate or deactivate them.", "aws" ),
34
  )
35
  );
36
 
37
+ $options['general'][] = array(
38
+ "name" => __( "Sync index table", "aws" ),
39
+ "desc" => __( "Automatically update plugin index table when product content was changed. This means that in search there will be always latest product data.", "aws" ) . '<br>' .
40
+ __( "Turn this off if you have any problems with performance.", "aws" ),
41
+ "id" => "autoupdates",
42
+ "value" => 'true',
43
+ "type" => "radio",
44
+ 'choices' => array(
45
+ 'true' => __( 'On', 'aws' ),
46
+ 'false' => __( 'Off', 'aws' ),
47
+ )
48
+ );
49
+
50
  $options['general'][] = array(
51
  "name" => __( "Search in", "aws" ),
52
  "desc" => __( "Search source: Drag&drop sources to activate or deactivate them.", "aws" ),
languages/aws.pot CHANGED
@@ -128,6 +128,15 @@ msgstr ""
128
  msgid "Cache results"
129
  msgstr ""
130
 
 
 
 
 
 
 
 
 
 
131
  msgid "Main Settings"
132
  msgstr ""
133
 
128
  msgid "Cache results"
129
  msgstr ""
130
 
131
+ msgid "Sync index table"
132
+ msgstr ""
133
+
134
+ msgid "Automatically update plugin index table when product content was changed. This means that in search there will be always latest product data."
135
+ msgstr ""
136
+
137
+ msgid "Turn this off if you have any problems with performance."
138
+ msgstr ""
139
+
140
  msgid "Main Settings"
141
  msgstr ""
142
 
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.59
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -101,6 +101,16 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
101
 
102
  == Changelog ==
103
 
 
 
 
 
 
 
 
 
 
 
104
  = 1.59 =
105
  * Add aws_search_start action
106
  * Update caching naming
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.60
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
101
 
102
  == Changelog ==
103
 
104
+ = 1.60 =
105
+ * Update cron job action
106
+ * Update Protected Categories plugin integration
107
+ * Update B2B Market plugin integration
108
+ * Add WC Marketplace plugin integration
109
+ * Add new option to disable auto sync for index page
110
+ * Add aws_filter_yikes_woo_products_tabs_sync filter
111
+ * Add aws_search_data_params filter
112
+ * Add aws_search_pre_filter_products filter
113
+
114
  = 1.59 =
115
  * Add aws_search_start action
116
  * Update caching naming