Advanced Woo Search - Version 1.85

Version Description

  • Add - Seamless integration with Divi builder
  • Add - Seamless integration for Shopkeeper theme
  • Add - aws_js_seamless_selectors filter
  • Update - When fail index process will start from latest added product, not from the start
  • Update - Search results box layout fixes
  • Update - qTranslate plugin fix
  • Fix - Synonyms support for phrases
Download this release

Release Info

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

Code changes from version 1.84 to 1.85

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.84
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,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
16
  exit;
17
  }
18
 
19
- define( 'AWS_VERSION', '1.84' );
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.85
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.8.0
12
  */
13
 
14
 
16
  exit;
17
  }
18
 
19
+ define( 'AWS_VERSION', '1.85' );
20
 
21
 
22
  define( 'AWS_DIR', dirname( __FILE__ ) );
assets/css/common.css CHANGED
@@ -2,12 +2,11 @@
2
  position: relative;
3
  width: 100%;
4
  float: none !important;
5
-
6
- display: -webkit-box;
7
- display: -moz-box;
8
- display: -ms-flexbox;
9
- display: -webkit-flex;
10
- display: flex;
11
  align-items: stretch;
12
  height: 44px;
13
  }
@@ -443,4 +442,7 @@
443
  }
444
  .et_fixed_nav .et-fixed-header .et_search_outer .aws-container {
445
  margin-top: 5px;
 
 
 
446
  }
2
  position: relative;
3
  width: 100%;
4
  float: none !important;
5
+ display: -webkit-box !important;
6
+ display: -moz-box !important;
7
+ display: -ms-flexbox !important;
8
+ display: -webkit-flex !important;
9
+ display: flex !important;
 
10
  align-items: stretch;
11
  height: 44px;
12
  }
442
  }
443
  .et_fixed_nav .et-fixed-header .et_search_outer .aws-container {
444
  margin-top: 5px;
445
+ }
446
+ .et_pb_menu__search .aws-container {
447
+ width: 100%;
448
  }
assets/js/common.js CHANGED
@@ -274,7 +274,7 @@
274
  var top = 0;
275
  var left = 0;
276
 
277
- if ( bodyPosition === 'relative' ) {
278
  top = offset.top + $(self).innerHeight() - bodyOffset.top;
279
  left = offset.left - bodyOffset.left;
280
  } else {
274
  var top = 0;
275
  var left = 0;
276
 
277
+ if ( bodyPosition === 'relative' || bodyPosition === 'absolute' ) {
278
  top = offset.top + $(self).innerHeight() - bodyOffset.top;
279
  left = offset.left - bodyOffset.left;
280
  } else {
includes/class-aws-helpers.php CHANGED
@@ -519,10 +519,44 @@ if ( ! class_exists( 'AWS_Helpers' ) ) :
519
  if ( $synonym_array && ! empty( $synonym_array ) ) {
520
  $synonym_array = array_map( array( 'AWS_Helpers', 'normalize_string' ), $synonym_array );
521
  foreach ( $synonym_array as $synonym_item ) {
 
522
  if ( $synonym_item && isset( $str_array[$synonym_item] ) ) {
523
  $new_str_array = array_merge( $new_str_array, $synonym_array );
524
  break;
525
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
526
  }
527
  }
528
 
519
  if ( $synonym_array && ! empty( $synonym_array ) ) {
520
  $synonym_array = array_map( array( 'AWS_Helpers', 'normalize_string' ), $synonym_array );
521
  foreach ( $synonym_array as $synonym_item ) {
522
+
523
  if ( $synonym_item && isset( $str_array[$synonym_item] ) ) {
524
  $new_str_array = array_merge( $new_str_array, $synonym_array );
525
  break;
526
  }
527
+
528
+ if ( $synonym_item && preg_match( '/\s/',$synonym_item ) ) {
529
+ $synonym_words = explode( ' ', $synonym_item );
530
+ if ( $synonym_words && ! empty( $synonym_words ) ) {
531
+
532
+ $str_array_keys = array_keys( $str_array );
533
+ $synonym_prev_word_pos = 0;
534
+ $use_this = true;
535
+
536
+ foreach ( $synonym_words as $synonym_word ) {
537
+ if ( $synonym_word && isset( $str_array[$synonym_word] ) ) {
538
+ $synonym_current_word_pos = array_search( $synonym_word, $str_array_keys );
539
+ $synonym_prev_word_pos = $synonym_prev_word_pos ? $synonym_prev_word_pos : $synonym_current_word_pos;
540
+
541
+ if ( ( $synonym_prev_word_pos !== $synonym_current_word_pos ) && ++$synonym_prev_word_pos !== $synonym_current_word_pos ) {
542
+ $use_this = false;
543
+ break;
544
+ }
545
+
546
+ } else {
547
+ $use_this = false;
548
+ break;
549
+ }
550
+ }
551
+
552
+ if ( $use_this ) {
553
+ $new_str_array = array_merge( $new_str_array, $synonym_array );
554
+ break;
555
+ }
556
+
557
+ }
558
+ }
559
+
560
  }
561
  }
562
 
includes/class-aws-integrations.php CHANGED
@@ -79,9 +79,17 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
79
 
80
  // Seamless integration
81
  if ( AWS()->get_settings( 'seamless' ) === 'true' ) {
 
 
 
82
  add_filter( 'et_html_main_header', array( $this, 'et_html_main_header' ) );
83
  add_filter( 'et_html_slide_header', array( $this, 'et_html_main_header' ) );
84
  add_filter( 'generate_navigation_search_output', array( $this, 'generate_navigation_search_output' ) );
 
 
 
 
 
85
  }
86
 
87
  // Wholesale plugin hide certain products
@@ -464,6 +472,86 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
464
  return $html;
465
  }
466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
467
  /*
468
  * Wholesale plugin hide products
469
  */
79
 
80
  // Seamless integration
81
  if ( AWS()->get_settings( 'seamless' ) === 'true' ) {
82
+
83
+ add_filter( 'aws_js_seamless_selectors', array( $this, 'js_seamless_selectors' ) );
84
+
85
  add_filter( 'et_html_main_header', array( $this, 'et_html_main_header' ) );
86
  add_filter( 'et_html_slide_header', array( $this, 'et_html_main_header' ) );
87
  add_filter( 'generate_navigation_search_output', array( $this, 'generate_navigation_search_output' ) );
88
+ add_filter( 'et_pb_search_shortcode_output', array( $this, 'divi_builder_search_module' ) );
89
+ add_filter( 'et_pb_menu_shortcode_output', array( $this, 'divi_builder_search_module' ) );
90
+ add_filter( 'et_pb_fullwidth_menu_shortcode_output', array( $this, 'divi_builder_search_module' ) );
91
+ add_action( 'wp_head', array( $this, 'head_js_integration' ) );
92
+
93
  }
94
 
95
  // Wholesale plugin hide certain products
472
  return $html;
473
  }
474
 
475
+ /*
476
+ * Divi builder replace search module
477
+ */
478
+ public function divi_builder_search_module( $output ) {
479
+ if ( function_exists( 'aws_get_search_form' ) && is_string( $output ) ) {
480
+
481
+ $pattern = '/(<form[\s\S]*?<\/form>)/i';
482
+ $form = aws_get_search_form(false);
483
+
484
+ if ( strpos( $output, 'aws-container' ) !== false ) {
485
+ $pattern = '/(<div class="aws-container"[\s\S]*?<form.*?<\/form><\/div>)/i';
486
+ }
487
+
488
+ $output = trim(preg_replace('/\s\s+/', ' ', $output));
489
+ $output = preg_replace( $pattern, $form, $output );
490
+
491
+ }
492
+ return $output;
493
+ }
494
+
495
+ /*
496
+ * Selector filter of js seamless
497
+ */
498
+ public function js_seamless_selectors( $selectors ) {
499
+
500
+ // shopkeeper theme
501
+ if ( function_exists( 'shopkeeper_theme_setup' ) ) {
502
+ $selectors[] = '.site-search .woocommerce-product-search';
503
+ }
504
+
505
+ return $selectors;
506
+
507
+ }
508
+
509
+ /*
510
+ * Js seamless integration method
511
+ */
512
+ public function head_js_integration() {
513
+
514
+ /**
515
+ * Filter seamless integrations js selectors for forms
516
+ * @since 1.85
517
+ * @param array $forms Array of css selectors
518
+ */
519
+ $forms = apply_filters( 'aws_js_seamless_selectors', array() );
520
+
521
+ if ( ! is_array( $forms ) || empty( $forms ) ) {
522
+ return;
523
+ }
524
+
525
+ $forms_selector = implode( ',', $forms );
526
+
527
+ ?>
528
+
529
+ <script>
530
+ window.addEventListener('load', function() {
531
+ var forms = document.querySelectorAll("<?php echo $forms_selector; ?>");
532
+
533
+ var awsFormHtml = <?php echo json_encode( str_replace( 'aws-container', 'aws-container aws-js-seamless', aws_get_search_form( false ) ) ); ?>;
534
+
535
+ if ( forms ) {
536
+
537
+ for ( var i = 0; i < forms.length; i++ ) {
538
+ if ( forms[i].parentNode.outerHTML.indexOf('aws-container') === -1 ) {
539
+ forms[i].outerHTML = awsFormHtml;
540
+ }
541
+ }
542
+
543
+ window.setTimeout(function(){
544
+ jQuery('.aws-js-seamless').each( function() {
545
+ jQuery(this).aws_search();
546
+ });
547
+ }, 1000);
548
+
549
+ }
550
+ }, false);
551
+ </script>
552
+
553
+ <?php }
554
+
555
  /*
556
  * Wholesale plugin hide products
557
  */
includes/class-aws-table.php CHANGED
@@ -72,6 +72,15 @@ if ( ! class_exists( 'AWS_Table' ) ) :
72
  $index_meta = $data ? $data : $_POST['data'];
73
  $status = false;
74
 
 
 
 
 
 
 
 
 
 
75
  // No current index going on. Let's start over
76
  if ( 'start' === $index_meta ) {
77
  $status = 'start';
@@ -135,6 +144,8 @@ if ( ! class_exists( 'AWS_Table' ) ) :
135
  $index_meta['offset'] = $index_meta['found_posts'];
136
  }
137
 
 
 
138
  } else {
139
  // We are done (with this site)
140
 
@@ -144,6 +155,8 @@ if ( ! class_exists( 'AWS_Table' ) ) :
144
 
145
  update_option( 'aws_reindex_version', AWS_VERSION );
146
 
 
 
147
  }
148
 
149
  }
@@ -528,34 +541,49 @@ if ( ! class_exists( 'AWS_Table' ) ) :
528
  continue;
529
  }
530
 
531
- if ( function_exists( 'qtranxf_isAvailableIn' ) && qtranxf_isAvailableIn( $data['id'], $current_lang ) ) {
532
 
533
- if ( method_exists( $product, 'get_description' ) && method_exists( $product, 'get_name' ) && method_exists( $product, 'get_short_description' ) ) {
534
 
535
- $translated_post_data = array();
536
- $translated_post_data['id'] = $data['id'];
537
- $translated_post_data['in_stock'] = $data['in_stock'];
538
- $translated_post_data['on_sale'] = $data['on_sale'];
539
- $translated_post_data['visibility'] = $data['visibility'];
540
- $translated_post_data['lang'] = $current_lang;
541
- $translated_post_data['terms'] = array();
542
 
543
- $translated_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
544
- $translated_content = qtranxf_use( $current_lang, $product->get_description(), true, true );
545
- $translated_excerpt = qtranxf_use( $current_lang, $product->get_short_description(), true, true );
546
 
547
- $translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
548
- $translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
549
 
550
- $translated_post_data['terms']['title'] = $this->extract_terms( $translated_title );
551
- $translated_post_data['terms']['content'] = $this->extract_terms( $translated_content );
552
- $translated_post_data['terms']['excerpt'] = $this->extract_terms( $translated_excerpt );
553
- $translated_post_data['terms']['sku'] = $this->extract_terms( $sku );
554
- $translated_post_data['terms']['id'] = $this->extract_terms( $ids );
555
 
 
556
 
557
- //Insert translated product data into table
558
- $this->insert_into_table( $translated_post_data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
 
560
  }
561
 
72
  $index_meta = $data ? $data : $_POST['data'];
73
  $status = false;
74
 
75
+ // If something goes wrong during last index start from latest indexed product
76
+ if ( 'start' === $index_meta ) {
77
+ $aws_index_processed = get_transient( 'aws_index_processed' );
78
+
79
+ if ( $aws_index_processed ) {
80
+ $index_meta = $aws_index_processed;
81
+ }
82
+ }
83
+
84
  // No current index going on. Let's start over
85
  if ( 'start' === $index_meta ) {
86
  $status = 'start';
144
  $index_meta['offset'] = $index_meta['found_posts'];
145
  }
146
 
147
+ set_transient( 'aws_index_processed', $index_meta, 60*60 );
148
+
149
  } else {
150
  // We are done (with this site)
151
 
155
 
156
  update_option( 'aws_reindex_version', AWS_VERSION );
157
 
158
+ delete_transient( 'aws_index_processed' );
159
+
160
  }
161
 
162
  }
541
  continue;
542
  }
543
 
544
+ if ( function_exists( 'qtranxf_getAvailableLanguages' ) ) {
545
 
546
+ global $wpdb;
547
 
548
+ $qtrans_content = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $data['id'] ) );
 
 
 
 
 
 
549
 
550
+ if ( $qtrans_content ) {
 
 
551
 
552
+ $languages_title = qtranxf_getAvailableLanguages( $qtrans_content->post_title );
553
+ $languages_content = qtranxf_getAvailableLanguages( $qtrans_content->post_content );
554
 
555
+ if ( ( $languages_title && in_array( $current_lang, $languages_title ) ) || ( $languages_content && in_array( $current_lang, $languages_content ) ) ) {
 
 
 
 
556
 
557
+ if ( method_exists( $product, 'get_description' ) && method_exists( $product, 'get_name' ) && method_exists( $product, 'get_short_description' ) ) {
558
 
559
+ $translated_post_data = array();
560
+ $translated_post_data['id'] = $data['id'];
561
+ $translated_post_data['in_stock'] = $data['in_stock'];
562
+ $translated_post_data['on_sale'] = $data['on_sale'];
563
+ $translated_post_data['visibility'] = $data['visibility'];
564
+ $translated_post_data['lang'] = $current_lang;
565
+ $translated_post_data['terms'] = array();
566
+
567
+ $translated_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
568
+ $translated_content = qtranxf_use( $current_lang, $product->get_description(), true, true );
569
+ $translated_excerpt = qtranxf_use( $current_lang, $product->get_short_description(), true, true );
570
+
571
+ $translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
572
+ $translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
573
+
574
+ $translated_post_data['terms']['title'] = $this->extract_terms( $translated_title );
575
+ $translated_post_data['terms']['content'] = $this->extract_terms( $translated_content );
576
+ $translated_post_data['terms']['excerpt'] = $this->extract_terms( $translated_excerpt );
577
+ $translated_post_data['terms']['sku'] = $this->extract_terms( $sku );
578
+ $translated_post_data['terms']['id'] = $this->extract_terms( $ids );
579
+
580
+
581
+ //Insert translated product data into table
582
+ $this->insert_into_table( $translated_post_data );
583
+
584
+ }
585
+
586
+ }
587
 
588
  }
589
 
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.3
7
- Stable tag: 1.84
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -104,6 +104,15 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
104
 
105
  == Changelog ==
106
 
 
 
 
 
 
 
 
 
 
107
  = 1.84 =
108
  * Update - Add indexes for table
109
  * Update - Cache query sql
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.3
7
+ Stable tag: 1.85
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
104
 
105
  == Changelog ==
106
 
107
+ = 1.85 =
108
+ * Add - Seamless integration with Divi builder
109
+ * Add - Seamless integration for Shopkeeper theme
110
+ * Add - aws_js_seamless_selectors filter
111
+ * Update - When fail index process will start from latest added product, not from the start
112
+ * Update - Search results box layout fixes
113
+ * Update - qTranslate plugin fix
114
+ * Fix - Synonyms support for phrases
115
+
116
  = 1.84 =
117
  * Update - Add indexes for table
118
  * Update - Cache query sql