Advanced Woo Search - Version 2.34

Version Description

( 2021-08-16 ) = * Add - New options for products search results page * Update - Support for WPML plugin. Use default product language if no translation and fallback to default language option is enabled * Fix - Error with special characters inside regular expressions * Fix - Error during database creation that was caused by wrong COLLATION value * Fix - Search results page output for Avada theme

Download this release

Release Info

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

Code changes from version 2.33 to 2.34

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: 2.33
7
  Author: ILLID
8
  Author URI: https://advanced-woo-search.com/
9
  Text Domain: advanced-woo-search
@@ -96,7 +96,7 @@ final class AWS_Main {
96
  */
97
  private function define_constants() {
98
 
99
- $this->define( 'AWS_VERSION', '2.33' );
100
 
101
  $this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
102
  $this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
+ Version: 2.34
7
  Author: ILLID
8
  Author URI: https://advanced-woo-search.com/
9
  Text Domain: advanced-woo-search
96
  */
97
  private function define_constants() {
98
 
99
+ $this->define( 'AWS_VERSION', '2.34' );
100
 
101
  $this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
102
  $this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
assets/js/common.js CHANGED
@@ -79,7 +79,7 @@ AwsHooks.filters = AwsHooks.filters || {};
79
  requests[i].abort();
80
  }
81
 
82
- if ( d.showPage == 'ajax_off' ) {
83
  return;
84
  }
85
 
@@ -531,6 +531,7 @@ AwsHooks.filters = AwsHooks.filters || {};
531
  lang : ( self.data('lang') !== undefined ) ? self.data('lang') : false,
532
  showLoader: ( self.data('show-loader') !== undefined ) ? self.data('show-loader') : true,
533
  showMore: ( self.data('show-more') !== undefined ) ? self.data('show-more') : true,
 
534
  showPage: ( self.data('show-page') !== undefined ) ? self.data('show-page') : true,
535
  showClear: ( self.data('show-clear') !== undefined ) ? self.data('show-clear') : false,
536
  mobileScreen: ( self.data('mobile-screen') !== undefined ) ? self.data('mobile-screen') : false,
79
  requests[i].abort();
80
  }
81
 
82
+ if ( ! d.ajaxSearch ) {
83
  return;
84
  }
85
 
531
  lang : ( self.data('lang') !== undefined ) ? self.data('lang') : false,
532
  showLoader: ( self.data('show-loader') !== undefined ) ? self.data('show-loader') : true,
533
  showMore: ( self.data('show-more') !== undefined ) ? self.data('show-more') : true,
534
+ ajaxSearch: ( self.data('ajax-search') !== undefined ) ? self.data('ajax-search') : true,
535
  showPage: ( self.data('show-page') !== undefined ) ? self.data('show-page') : true,
536
  showClear: ( self.data('show-clear') !== undefined ) ? self.data('show-clear') : false,
537
  mobileScreen: ( self.data('mobile-screen') !== undefined ) ? self.data('mobile-screen') : false,
includes/admin/class-aws-admin-options.php CHANGED
@@ -301,6 +301,51 @@ if ( ! class_exists( 'AWS_Admin_Options' ) ) :
301
  )
302
  );
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  $options['performance'][] = array(
305
  "name" => __( "Search options", "advanced-woo-search" ),
306
  "type" => "heading"
@@ -415,6 +460,18 @@ if ( ! class_exists( 'AWS_Admin_Options' ) ) :
415
  "type" => "number"
416
  );
417
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  $options['form'][] = array(
419
  "name" => __( "Show loader", "advanced-woo-search" ),
420
  "desc" => __( "Show loader animation while searching.", "advanced-woo-search" ),
@@ -463,19 +520,6 @@ if ( ! class_exists( 'AWS_Admin_Options' ) ) :
463
  )
464
  );
465
 
466
- $options['form'][] = array(
467
- "name" => __( "Search Results", "advanced-woo-search" ),
468
- "desc" => __( "Choose how to view search results.", "advanced-woo-search" ),
469
- "id" => "show_page",
470
- "value" => 'true',
471
- "type" => "radio",
472
- 'choices' => array(
473
- 'true' => __( 'Both ajax search results and search results page', 'advanced-woo-search' ),
474
- 'false' => __( 'Only ajax search results ( no search results page )', 'advanced-woo-search' ),
475
- 'ajax_off' => __( 'Only search results page ( no ajax search results )', 'advanced-woo-search' )
476
- )
477
- );
478
-
479
  $options['form'][] = array(
480
  "name" => __( "Form Styling", "advanced-woo-search" ),
481
  "desc" => __( "Choose search form layout", "advanced-woo-search" ) . '<br>' . __( "Filter button will be visible only if you have more than one active filter for current search form instance.", "advanced-woo-search" ),
301
  )
302
  );
303
 
304
+ $options['general'][] = array(
305
+ "name" => __( "Search results page", "advanced-woo-search" ),
306
+ "type" => "heading"
307
+ );
308
+
309
+ $options['general'][] = array(
310
+ "name" => __( "Enable results page", "advanced-woo-search" ),
311
+ "desc" => __( "Show plugin search results on a separated search results page. Will use your current theme products search results page template.", "advanced-woo-search" ),
312
+ "id" => "search_page",
313
+ "value" => 'true',
314
+ "type" => "radio",
315
+ 'choices' => array(
316
+ 'true' => __( 'On', 'advanced-woo-search' ),
317
+ 'false' => __( 'Off', 'advanced-woo-search' ),
318
+ )
319
+ );
320
+
321
+ $options['general'][] = array(
322
+ "name" => __( "Max number of results", "advanced-woo-search" ),
323
+ "desc" => __( "Maximal total number of search results. Larger values can lead to slower search speed.", "advanced-woo-search" ),
324
+ "id" => "search_page_res_num",
325
+ "value" => 100,
326
+ "type" => "number"
327
+ );
328
+
329
+ $options['general'][] = array(
330
+ "name" => __( "Results per page", "advanced-woo-search" ),
331
+ "desc" => __( "Number of search results per page. Empty or 0 - use theme default value.", "advanced-woo-search" ),
332
+ "id" => "search_page_res_per_page",
333
+ "value" => '',
334
+ "type" => "number"
335
+ );
336
+
337
+ $options['general'][] = array(
338
+ "name" => __( "Change query hook", "advanced-woo-search" ),
339
+ "desc" => __( "If you have any problems with correct products results on the search results page - try to change this option.", "advanced-woo-search" ),
340
+ "id" => "search_page_query",
341
+ "value" => 'default',
342
+ "type" => "radio",
343
+ 'choices' => array(
344
+ 'default' => __( 'Default', 'advanced-woo-search' ),
345
+ 'posts_pre_query' => __( 'posts_pre_query', 'advanced-woo-search' ),
346
+ )
347
+ );
348
+
349
  $options['performance'][] = array(
350
  "name" => __( "Search options", "advanced-woo-search" ),
351
  "type" => "heading"
460
  "type" => "number"
461
  );
462
 
463
+ $options['form'][] = array(
464
+ "name" => __( "AJAX search", "advanced-woo-search" ),
465
+ "desc" => __( "Use or not live search feature.", "advanced-woo-search" ),
466
+ "id" => "enable_ajax",
467
+ "value" => 'true',
468
+ "type" => "radio",
469
+ 'choices' => array(
470
+ 'true' => __( 'On', 'advanced-woo-search' ),
471
+ 'false' => __( 'Off', 'advanced-woo-search' ),
472
+ )
473
+ );
474
+
475
  $options['form'][] = array(
476
  "name" => __( "Show loader", "advanced-woo-search" ),
477
  "desc" => __( "Show loader animation while searching.", "advanced-woo-search" ),
520
  )
521
  );
522
 
 
 
 
 
 
 
 
 
 
 
 
 
 
523
  $options['form'][] = array(
524
  "name" => __( "Form Styling", "advanced-woo-search" ),
525
  "desc" => __( "Choose search form layout", "advanced-woo-search" ) . '<br>' . __( "Filter button will be visible only if you have more than one active filter for current search form instance.", "advanced-woo-search" ),
includes/class-aws-cache.php CHANGED
@@ -115,6 +115,15 @@ if ( ! class_exists( 'AWS_Cache' ) ) :
115
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
116
  dbDelta( $sql );
117
 
 
 
 
 
 
 
 
 
 
118
  }
119
 
120
  /*
115
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
116
  dbDelta( $sql );
117
 
118
+ if ( $wpdb->last_error ) {
119
+
120
+ if ( strpos( $wpdb->last_error, 'COLLATION' ) !== false ) {
121
+ $sql = str_replace( " COLLATE $wpdb->collate", '', $sql );
122
+ dbDelta( $sql );
123
+ }
124
+
125
+ }
126
+
127
  }
128
 
129
  /*
includes/class-aws-integrations.php CHANGED
@@ -229,6 +229,7 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
229
  add_filter( 'aws_posts_per_page', array( $this, 'avada_posts_per_page' ), 1 );
230
  add_filter( 'aws_products_order_by', array( $this, 'avada_aws_products_order_by' ), 1 );
231
  add_filter( 'post_class', array( $this, 'avada_post_class' ) );
 
232
  }
233
 
234
  if ( 'Electro' === $this->current_theme ) {
@@ -336,6 +337,11 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
336
  include_once( AWS_DIR . '/includes/modules/class-aws-wpbakery.php' );
337
  }
338
 
 
 
 
 
 
339
  }
340
 
341
  /*
@@ -1779,6 +1785,14 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
1779
  return $classes;
1780
  }
1781
 
 
 
 
 
 
 
 
 
1782
  /*
1783
  * Electro them update search form markup
1784
  */
229
  add_filter( 'aws_posts_per_page', array( $this, 'avada_posts_per_page' ), 1 );
230
  add_filter( 'aws_products_order_by', array( $this, 'avada_aws_products_order_by' ), 1 );
231
  add_filter( 'post_class', array( $this, 'avada_post_class' ) );
232
+ add_filter( 'aws_search_page_custom_data', array( $this, 'avada_modify_s_page_query' ) );
233
  }
234
 
235
  if ( 'Electro' === $this->current_theme ) {
337
  include_once( AWS_DIR . '/includes/modules/class-aws-wpbakery.php' );
338
  }
339
 
340
+ // WPML plugin
341
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
342
+ include_once( AWS_DIR . '/includes/modules/class-aws-wpml.php' );
343
+ }
344
+
345
  }
346
 
347
  /*
1785
  return $classes;
1786
  }
1787
 
1788
+ /*
1789
+ * Avada theme fix search page query
1790
+ */
1791
+ public function avada_modify_s_page_query( $data ) {
1792
+ $data['force_ids'] = true;
1793
+ return $data;
1794
+ }
1795
+
1796
  /*
1797
  * Electro them update search form markup
1798
  */
includes/class-aws-markup.php CHANGED
@@ -32,7 +32,8 @@ if ( ! class_exists( 'AWS_Markup' ) ) :
32
  $min_chars = AWS()->get_settings( 'min_chars' );
33
  $show_loader = AWS()->get_settings( 'show_loader' );
34
  $show_more = AWS()->get_settings( 'show_more' );
35
- $show_page = AWS()->get_settings( 'show_page' );
 
36
  $show_clear = AWS()->get_settings( 'show_clear' );
37
  $mobile_screen = AWS()->get_settings( 'mobile_overlay' );
38
  $use_analytics = AWS()->get_settings( 'use_analytics' );
@@ -60,6 +61,7 @@ if ( ! class_exists( 'AWS_Markup' ) ) :
60
  'data-show-loader' => $show_loader,
61
  'data-show-more' => $show_more,
62
  'data-show-page' => $show_page,
 
63
  'data-show-clear' => $show_clear,
64
  'data-mobile-screen' => $mobile_screen,
65
  'data-use-analytics' => $use_analytics,
32
  $min_chars = AWS()->get_settings( 'min_chars' );
33
  $show_loader = AWS()->get_settings( 'show_loader' );
34
  $show_more = AWS()->get_settings( 'show_more' );
35
+ $ajax_search = AWS()->get_settings( 'enable_ajax' );
36
+ $show_page = AWS()->get_settings( 'search_page' );
37
  $show_clear = AWS()->get_settings( 'show_clear' );
38
  $mobile_screen = AWS()->get_settings( 'mobile_overlay' );
39
  $use_analytics = AWS()->get_settings( 'use_analytics' );
61
  'data-show-loader' => $show_loader,
62
  'data-show-more' => $show_more,
63
  'data-show-page' => $show_page,
64
+ 'data-ajax-search' => $ajax_search,
65
  'data-show-clear' => $show_clear,
66
  'data-mobile-screen' => $mobile_screen,
67
  'data-use-analytics' => $use_analytics,
includes/class-aws-search-page.php CHANGED
@@ -88,6 +88,15 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
88
  // FacetWP support
89
  add_filter( 'facetwp_pre_filtered_post_ids', array( $this, 'facetwp_pre_filtered_post_ids' ), 10, 2 );
90
 
 
 
 
 
 
 
 
 
 
91
  }
92
 
93
  /**
@@ -146,7 +155,7 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
146
 
147
  $post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true : false;
148
 
149
- if ( $post_type_product && isset( $_GET['type_aws'] ) && isset( $query->query_vars['s'] ) && $query->query && isset( $query->query['fields'] ) && $query->query['fields'] == 'ids' &&
150
  ( ( isset( $this->data['force_ids'] ) && $this->data['force_ids'] ) || ( isset( $this->data['is_elementor'] ) && $this->data['is_elementor'] ) || ( isset( $this->data['is_divi_s_page'] ) && $this->data['is_divi_s_page'] ) )
151
  )
152
  {
@@ -582,6 +591,39 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
582
 
583
  }
584
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
585
  }
586
 
587
 
88
  // FacetWP support
89
  add_filter( 'facetwp_pre_filtered_post_ids', array( $this, 'facetwp_pre_filtered_post_ids' ), 10, 2 );
90
 
91
+ // Total number of search results
92
+ add_filter( 'aws_page_results', array( $this, 'aws_page_results' ), 1 );
93
+
94
+ // Number of search results per page
95
+ add_filter( 'aws_posts_per_page', array( $this, 'aws_posts_per_page' ), 1 );
96
+
97
+ // Change default search page query
98
+ add_filter( 'aws_search_page_custom_data', array( $this, 'aws_search_page_custom_data' ), 1 );
99
+
100
  }
101
 
102
  /**
155
 
156
  $post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true : false;
157
 
158
+ if ( $post_type_product && isset( $_GET['type_aws'] ) && isset( $query->query_vars['s'] ) && $query->query &&
159
  ( ( isset( $this->data['force_ids'] ) && $this->data['force_ids'] ) || ( isset( $this->data['is_elementor'] ) && $this->data['is_elementor'] ) || ( isset( $this->data['is_divi_s_page'] ) && $this->data['is_divi_s_page'] ) )
160
  )
161
  {
591
 
592
  }
593
 
594
+ /*
595
+ * Total maximal number of search results for results pages
596
+ */
597
+ public function aws_page_results( $num ) {
598
+ $search_page_res_num = AWS()->get_settings( 'search_page_res_num' );
599
+ if ( $search_page_res_num ) {
600
+ $num = intval( $search_page_res_num );
601
+ }
602
+ return $num;
603
+ }
604
+
605
+ /*
606
+ * Number of search results per page
607
+ */
608
+ public function aws_posts_per_page( $num ) {
609
+ $search_page_res_per_page = AWS()->get_settings( 'search_page_res_per_page' );
610
+ if ( $search_page_res_per_page ) {
611
+ $num = intval( $search_page_res_per_page );
612
+ }
613
+ return $num;
614
+ }
615
+
616
+ /*
617
+ * Change default search page query
618
+ */
619
+ public function aws_search_page_custom_data( $data ) {
620
+ $search_page_query = AWS()->get_settings( 'search_page_query' );
621
+ if ( $search_page_query && $search_page_query === 'posts_pre_query' ) {
622
+ $data['force_ids'] = true;
623
+ }
624
+ return $data;
625
+ }
626
+
627
  }
628
 
629
 
includes/class-aws-search.php CHANGED
@@ -422,7 +422,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
422
  $current_lang = apply_filters( 'aws_search_current_lang', $current_lang );
423
 
424
  if ( $current_lang && $reindex_version && version_compare( $reindex_version, '1.20', '>=' ) ) {
425
- $query['lang'] = $wpdb->prepare( " AND ( lang LIKE %s OR lang = '' )", $current_lang );
426
  }
427
 
428
  /**
@@ -581,7 +581,6 @@ if ( ! class_exists( 'AWS_Search' ) ) :
581
 
582
  }
583
 
584
-
585
  if ( $show_price === 'true' && ( $product->is_in_stock() || ( ! $product->is_in_stock() && $show_outofstockprice === 'true' ) ) ) {
586
  $price = $product->get_price_html();
587
  $price = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "<span>$2</span>", $price);
@@ -709,6 +708,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
709
 
710
  foreach( $this->data['search_terms'] as $search_in ) {
711
 
 
712
  $exact_words[] = '\b' . $search_in . '\b';
713
 
714
  if ( strlen( $search_in ) > 1 ) {
@@ -773,6 +773,8 @@ if ( ! class_exists( 'AWS_Search' ) ) :
773
 
774
  foreach( $this->data['search_terms'] as $search_in ) {
775
 
 
 
776
  if ( strlen( $search_in ) > 1 ) {
777
  $pattern[] = '(' . $search_in . ')+';
778
  } else {
422
  $current_lang = apply_filters( 'aws_search_current_lang', $current_lang );
423
 
424
  if ( $current_lang && $reindex_version && version_compare( $reindex_version, '1.20', '>=' ) ) {
425
+ $query['lang'] = $wpdb->prepare( " AND ( lang LIKE %s OR lang = '' )", '%' . $wpdb->esc_like( $current_lang ) . '%' );
426
  }
427
 
428
  /**
581
 
582
  }
583
 
 
584
  if ( $show_price === 'true' && ( $product->is_in_stock() || ( ! $product->is_in_stock() && $show_outofstockprice === 'true' ) ) ) {
585
  $price = $product->get_price_html();
586
  $price = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "<span>$2</span>", $price);
708
 
709
  foreach( $this->data['search_terms'] as $search_in ) {
710
 
711
+ $search_in = preg_quote( $search_in, '/' );
712
  $exact_words[] = '\b' . $search_in . '\b';
713
 
714
  if ( strlen( $search_in ) > 1 ) {
773
 
774
  foreach( $this->data['search_terms'] as $search_in ) {
775
 
776
+ $search_in = preg_quote( $search_in, '/' );
777
+
778
  if ( strlen( $search_in ) > 1 ) {
779
  $pattern[] = '(' . $search_in . ')+';
780
  } else {
includes/class-aws-table.php CHANGED
@@ -333,6 +333,15 @@ if ( ! class_exists( 'AWS_Table' ) ) :
333
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
334
  dbDelta( $sql );
335
 
 
 
 
 
 
 
 
 
 
336
  do_action( 'aws_create_index_table' );
337
 
338
  }
333
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
334
  dbDelta( $sql );
335
 
336
+ if ( $wpdb->last_error ) {
337
+
338
+ if ( strpos( $wpdb->last_error, 'COLLATION' ) !== false ) {
339
+ $sql = str_replace( " COLLATE $wpdb->collate", '', $sql );
340
+ dbDelta( $sql );
341
+ }
342
+
343
+ }
344
+
345
  do_action( 'aws_create_index_table' );
346
 
347
  }
includes/class-aws-versions.php CHANGED
@@ -384,6 +384,40 @@ if ( ! class_exists( 'AWS_Versions' ) ) :
384
 
385
  }
386
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
387
  }
388
 
389
  update_option( 'aws_plugin_ver', AWS_VERSION );
384
 
385
  }
386
 
387
+ if ( version_compare( $current_version, '2.34', '<' ) ) {
388
+
389
+ $settings = get_option( 'aws_settings' );
390
+
391
+ if ( $settings ) {
392
+
393
+ if ( isset( $settings['show_page'] ) && ! isset( $settings['search_page'] ) ) {
394
+ $search_page_val = $settings['show_page'] === 'false' ? 'false' : 'true';
395
+ $settings['search_page'] = $search_page_val;
396
+ }
397
+
398
+ if ( isset( $settings['show_page'] ) && ! isset( $settings['enable_ajax'] ) ) {
399
+ $search_page_val = $settings['show_page'] === 'ajax_off' ? 'false' : 'true';
400
+ $settings['enable_ajax'] = $search_page_val;
401
+ }
402
+
403
+ if ( ! isset( $settings['search_page_res_num'] ) ) {
404
+ $settings['search_page_res_num'] = '100';
405
+ }
406
+
407
+ if ( ! isset( $settings['search_page_res_per_page'] ) ) {
408
+ $settings['search_page_res_per_page'] = '';
409
+ }
410
+
411
+ if ( ! isset( $settings['search_page_query'] ) ) {
412
+ $settings['search_page_query'] = 'default';
413
+ }
414
+
415
+ update_option( 'aws_settings', $settings );
416
+
417
+ }
418
+
419
+ }
420
+
421
  }
422
 
423
  update_option( 'aws_plugin_ver', AWS_VERSION );
includes/modules/class-aws-wpml.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * AWS plugin integration for WPML
5
+ */
6
+
7
+ if (!defined('ABSPATH')) {
8
+ exit; // Exit if accessed directly.
9
+ }
10
+
11
+ if (!class_exists('AWS_WPML')) :
12
+
13
+ /**
14
+ * Class for main plugin functions
15
+ */
16
+ class AWS_WPML {
17
+
18
+ /**
19
+ * @var AWS_WPML The single instance of the class
20
+ */
21
+ protected static $_instance = null;
22
+
23
+ private $data = array();
24
+
25
+ /**
26
+ * Main AWS_WPML Instance
27
+ *
28
+ * Ensures only one instance of AWS_WPML is loaded or can be loaded.
29
+ *
30
+ * @static
31
+ * @return AWS_WPML - Main instance
32
+ */
33
+ public static function instance()
34
+ {
35
+ if (is_null(self::$_instance)) {
36
+ self::$_instance = new self();
37
+ }
38
+ return self::$_instance;
39
+ }
40
+
41
+ /**
42
+ * Constructor
43
+ */
44
+ public function __construct() {
45
+
46
+ add_filter( 'aws_indexed_data', array( $this, 'indexed_data_trans_fallback' ), 1, 2 );
47
+
48
+ }
49
+
50
+ /*
51
+ * Use translation if available or fallback to default language ( if enabled )
52
+ */
53
+ public function indexed_data_trans_fallback( $data, $id ) {
54
+
55
+ global $sitepress;
56
+
57
+ $product_sync = false;
58
+ $default_lang = '';
59
+ $all_languages = array();
60
+ $translations = array();
61
+
62
+ if ( function_exists( 'wpml_get_setting' ) ) {
63
+ $custom_posts_sync = wpml_get_setting('custom_posts_sync_option', false );
64
+ if ( $custom_posts_sync ) {
65
+ $product_sync = isset( $custom_posts_sync['product'] ) && $custom_posts_sync['product'] == 2;
66
+ }
67
+ }
68
+
69
+ if ( has_filter( 'wpml_default_language' ) ) {
70
+ $default_lang = apply_filters('wpml_default_language', NULL );
71
+ }
72
+
73
+ if ( has_filter( 'wpml_post_language_details' ) ) {
74
+ $current_lang_details = apply_filters( 'wpml_post_language_details', NULL, $id );
75
+ }
76
+
77
+ if ( has_filter( 'wpml_active_languages' ) ) {
78
+ $all_languages_a = apply_filters( 'wpml_active_languages', NULL );
79
+ if ( ! empty( $all_languages_a ) ) {
80
+ foreach ( $all_languages_a as $lang_item ) {
81
+ $lang_item_code = $lang_item['language_code'];
82
+ $all_languages[$lang_item_code] = $lang_item_code;
83
+ }
84
+ }
85
+ }
86
+
87
+ if ( ! empty( $all_languages ) && $data['lang'] === $default_lang && $sitepress && method_exists( $sitepress, 'get_element_trid' ) && method_exists( $sitepress, 'get_element_translations' ) ) {
88
+
89
+ if ( $product_sync ) {
90
+
91
+ $trid = $sitepress->get_element_trid( $id, 'post_product' );
92
+ if ( $trid ) {
93
+ $translations = $sitepress->get_element_translations( $trid ) ;
94
+ }
95
+
96
+ foreach( $all_languages as $lang_code ) {
97
+ if ( ! empty( $translations ) && isset( $translations[$lang_code] ) ) {
98
+ continue;
99
+ }
100
+ $data['lang'] .= ' ' . $lang_code;
101
+ }
102
+
103
+ }
104
+
105
+ }
106
+
107
+ return $data;
108
+
109
+ }
110
+
111
+ }
112
+
113
+ endif;
114
+
115
+ AWS_WPML::instance();
languages/advanced-woo-search.pot CHANGED
@@ -253,21 +253,6 @@ msgstr ""
253
  msgid "Full screen search on focus. Will not work if the search form is inside the block with position: fixed."
254
  msgstr ""
255
 
256
- msgid "Search Results"
257
- msgstr ""
258
-
259
- msgid "Choose how to view search results."
260
- msgstr ""
261
-
262
- msgid "Both ajax search results and search results page"
263
- msgstr ""
264
-
265
- msgid "Only ajax search results ( no search results page )"
266
- msgstr ""
267
-
268
- msgid "Only search results page ( no ajax search results )"
269
- msgstr ""
270
-
271
  msgid "Form Styling"
272
  msgstr ""
273
 
@@ -771,4 +756,37 @@ msgid "Index variations"
771
  msgstr ""
772
 
773
  msgid "Index or not content of product variations."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
774
  msgstr ""
253
  msgid "Full screen search on focus. Will not work if the search form is inside the block with position: fixed."
254
  msgstr ""
255
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  msgid "Form Styling"
257
  msgstr ""
258
 
756
  msgstr ""
757
 
758
  msgid "Index or not content of product variations."
759
+ msgstr ""
760
+
761
+ msgid "Search results page"
762
+ msgstr ""
763
+
764
+ msgid "Enable results page"
765
+ msgstr ""
766
+
767
+ msgid "Show plugin search results on a separated search results page. Will use your current theme products search results page template."
768
+ msgstr ""
769
+
770
+ msgid "Maximal total number of search results. Larger values can lead to slower search speed."
771
+ msgstr ""
772
+
773
+ msgid "Results per page"
774
+ msgstr ""
775
+
776
+ msgid "Number of search results per page. Empty or 0 - use theme default value."
777
+ msgstr ""
778
+
779
+ msgid "Change query hook"
780
+ msgstr ""
781
+
782
+ msgid "If you have any problems with correct products results on the search results page - try to change this option."
783
+ msgstr ""
784
+
785
+ msgid "Default"
786
+ msgstr ""
787
+
788
+ msgid "AJAX search"
789
+ msgstr ""
790
+
791
+ msgid "Use or not live search feature."
792
  msgstr ""
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.8
7
- Stable tag: 2.33
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -167,6 +167,13 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
167
 
168
  == Changelog ==
169
 
 
 
 
 
 
 
 
170
  = 2.33 ( 2021-08-02 ) =
171
  * Fix - Parse errors during index process
172
  * Fix - Possible parse errors during AJAX search
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.8
7
+ Stable tag: 2.34
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
167
 
168
  == Changelog ==
169
 
170
+ = 2.34 ( 2021-08-16 ) =
171
+ * Add - New options for products search results page
172
+ * Update - Support for WPML plugin. Use default product language if no translation and fallback to default language option is enabled
173
+ * Fix - Error with special characters inside regular expressions
174
+ * Fix - Error during database creation that was caused by wrong COLLATION value
175
+ * Fix - Search results page output for Avada theme
176
+
177
  = 2.33 ( 2021-08-02 ) =
178
  * Fix - Parse errors during index process
179
  * Fix - Possible parse errors during AJAX search