Advanced Woo Search - Version 2.23

Version Description

( 2021-03-22 ) = * Add - Performance options * Add - Support for TI WooCommerce Wishlist plugin * Add - Support for Fury theme * Add - Support for Salient theme * Add - Support for Bazar theme * Add - Support for Claue theme * Add - Integration for Urna theme * Update - BeRocket AJAX filters plugin support. Fix issue when used slugs for terms instead of IDs inside URL * Update - BeRocket AJAX filter support. Include parent terms filters * Update - Gutenberg block markup * Update - Admin page styles * Fix - If no search sources is set - do not show the products search results * Dev - Add aws_admin_page_options_current filter

Download this release

Release Info

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

Code changes from version 2.22 to 2.23

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: 2.22
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: 5.0.0
12
  */
13
 
14
 
@@ -96,7 +96,7 @@ final class AWS_Main {
96
  */
97
  private function define_constants() {
98
 
99
- $this->define( 'AWS_VERSION', '2.22' );
100
 
101
  $this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
102
  $this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
@@ -116,6 +116,7 @@ final class AWS_Main {
116
  include_once( 'includes/class-aws-cache.php' );
117
  include_once( 'includes/class-aws-plurals.php' );
118
  include_once( 'includes/class-aws-table.php' );
 
119
  include_once( 'includes/class-aws-markup.php' );
120
  include_once( 'includes/class-aws-search.php' );
121
  include_once( 'includes/class-aws-tax-search.php' );
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
+ Version: 2.23
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: 5.1.0
12
  */
13
 
14
 
96
  */
97
  private function define_constants() {
98
 
99
+ $this->define( 'AWS_VERSION', '2.23' );
100
 
101
  $this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
102
  $this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
116
  include_once( 'includes/class-aws-cache.php' );
117
  include_once( 'includes/class-aws-plurals.php' );
118
  include_once( 'includes/class-aws-table.php' );
119
+ include_once( 'includes/class-aws-table-data.php' );
120
  include_once( 'includes/class-aws-markup.php' );
121
  include_once( 'includes/class-aws-search.php' );
122
  include_once( 'includes/class-aws-tax-search.php' );
assets/css/admin.css CHANGED
@@ -63,7 +63,7 @@
63
 
64
  .wp-submenu .current a[href*="page=aws-options&tab=premium"] span,
65
  .wp-submenu a[href*="page=aws-options&tab=premium"]:hover span {
66
- color: rgb(255, 255, 91, 1) !important;
67
  }
68
 
69
  /* Reindex button */
@@ -278,12 +278,20 @@ h1.aws-instance-name {
278
  width: 500px;
279
  }
280
 
 
 
 
281
  .aws-table.aws-table-sources th.aws-active {
282
  width: 30px;
283
  }
284
 
 
 
 
 
285
  .aws-table.aws-table-sources td.aws-active .aws-yes,
286
- .aws-table.aws-table-sources td.aws-active .aws-no{
 
287
  background-color: #26CC06;
288
  padding: 1px 7px;
289
  color: #fff;
@@ -292,11 +300,17 @@ h1.aws-instance-name {
292
  cursor: pointer;
293
  }
294
 
 
 
 
 
 
295
  .aws-table.aws-table-sources td.aws-active .aws-no {
296
  background-color: #CC0606;
297
  }
298
 
299
  .aws-table.aws-table-sources td.aws-active .aws-yes,
 
300
  .aws-table.aws-table-sources td.aws-active.active .aws-no {
301
  display: none;
302
  }
@@ -305,6 +319,15 @@ h1.aws-instance-name {
305
  display: inline;
306
  }
307
 
 
 
 
 
 
 
 
 
 
308
  .aws-table.aws-table-sources td.aws-active:after {
309
  content: "";
310
  display: none;
63
 
64
  .wp-submenu .current a[href*="page=aws-options&tab=premium"] span,
65
  .wp-submenu a[href*="page=aws-options&tab=premium"]:hover span {
66
+ color: rgb(255, 255, 91) !important;
67
  }
68
 
69
  /* Reindex button */
278
  width: 500px;
279
  }
280
 
281
+ .aws-table.aws-table-sources th.aws-actions {
282
+ width: 60px;
283
+ }
284
  .aws-table.aws-table-sources th.aws-active {
285
  width: 30px;
286
  }
287
 
288
+ .aws-table.aws-table-sources td.aws-active {
289
+ text-align: center;
290
+ }
291
+
292
  .aws-table.aws-table-sources td.aws-active .aws-yes,
293
+ .aws-table.aws-table-sources td.aws-active .aws-no,
294
+ .aws-table.aws-table-sources td.aws-active .aws-disabled {
295
  background-color: #26CC06;
296
  padding: 1px 7px;
297
  color: #fff;
300
  cursor: pointer;
301
  }
302
 
303
+ .aws-table.aws-table-sources td.aws-active .aws-disabled {
304
+ background-color: #808080;
305
+ cursor: default;
306
+ }
307
+
308
  .aws-table.aws-table-sources td.aws-active .aws-no {
309
  background-color: #CC0606;
310
  }
311
 
312
  .aws-table.aws-table-sources td.aws-active .aws-yes,
313
+ .aws-table.aws-table-sources td.aws-active .aws-disabled,
314
  .aws-table.aws-table-sources td.aws-active.active .aws-no {
315
  display: none;
316
  }
319
  display: inline;
320
  }
321
 
322
+ .aws-table.aws-table-sources td.aws-active.disabled .aws-disabled {
323
+ display: inline !important;
324
+ }
325
+
326
+ .aws-table.aws-table-sources td.aws-active.disabled .aws-yes,
327
+ .aws-table.aws-table-sources td.aws-active.disabled .aws-no {
328
+ display: none;
329
+ }
330
+
331
  .aws-table.aws-table-sources td.aws-active:after {
332
  content: "";
333
  display: none;
assets/js/common.js CHANGED
@@ -105,10 +105,12 @@ AwsHooks.filters = AwsHooks.filters || {};
105
  methods.showLoader();
106
  }
107
 
 
 
108
  clearTimeout( keyupTimeout );
109
  keyupTimeout = setTimeout( function() {
110
  methods.ajaxRequest();
111
- }, 300 );
112
 
113
  },
114
 
@@ -505,6 +507,7 @@ AwsHooks.filters = AwsHooks.filters || {};
505
  showClear: ( self.data('show-clear') !== undefined ) ? self.data('show-clear') : false,
506
  mobileScreen: ( self.data('mobile-screen') !== undefined ) ? self.data('mobile-screen') : false,
507
  useAnalytics: ( self.data('use-analytics') !== undefined ) ? self.data('use-analytics') : false,
 
508
  instance: instance,
509
  resultBlock: '#aws-search-result-' + instance,
510
  pageId: ( self.data('page-id') !== undefined ) ? self.data('page-id') : 0,
@@ -596,8 +599,11 @@ AwsHooks.filters = AwsHooks.filters || {};
596
 
597
  $( d.resultBlock ).on( 'click', 'span[href], [data-link]', function(e) {
598
  e.preventDefault();
599
- e.stopPropagation();
600
  var link = $(this).data('link') ? $(this).data('link') : $(this).attr('href');
 
 
 
 
601
  if ( link ) {
602
  window.location = link;
603
  }
105
  methods.showLoader();
106
  }
107
 
108
+ var searchTimeout = d.searchTimeout > 100 ? d.searchTimeout : 300;
109
+
110
  clearTimeout( keyupTimeout );
111
  keyupTimeout = setTimeout( function() {
112
  methods.ajaxRequest();
113
+ }, searchTimeout );
114
 
115
  },
116
 
507
  showClear: ( self.data('show-clear') !== undefined ) ? self.data('show-clear') : false,
508
  mobileScreen: ( self.data('mobile-screen') !== undefined ) ? self.data('mobile-screen') : false,
509
  useAnalytics: ( self.data('use-analytics') !== undefined ) ? self.data('use-analytics') : false,
510
+ searchTimeout: ( self.data('timeout') !== undefined ) ? parseInt( self.data('timeout') ) : 300,
511
  instance: instance,
512
  resultBlock: '#aws-search-result-' + instance,
513
  pageId: ( self.data('page-id') !== undefined ) ? self.data('page-id') : 0,
599
 
600
  $( d.resultBlock ).on( 'click', 'span[href], [data-link]', function(e) {
601
  e.preventDefault();
 
602
  var link = $(this).data('link') ? $(this).data('link') : $(this).attr('href');
603
+ if ( link === '' || link === '#' ) {
604
+ return;
605
+ }
606
+ e.stopPropagation();
607
  if ( link ) {
608
  window.location = link;
609
  }
includes/admin/class-aws-admin-ajax.php CHANGED
@@ -41,6 +41,8 @@ if ( ! class_exists( 'AWS_Admin_Ajax' ) ) :
41
 
42
  do_action( 'aws_cache_clear' );
43
 
 
 
44
  wp_send_json_success( '1' );
45
 
46
  }
41
 
42
  do_action( 'aws_cache_clear' );
43
 
44
+ do_action( 'aws_admin_change_state', $setting, $option, $state );
45
+
46
  wp_send_json_success( '1' );
47
 
48
  }
includes/admin/class-aws-admin-fields.php CHANGED
@@ -74,10 +74,18 @@ if ( ! class_exists( 'AWS_Admin_Fields' ) ) :
74
  <?php break;
75
 
76
  case 'number': ?>
 
 
 
 
 
 
 
 
77
  <tr valign="top">
78
  <th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
79
  <td>
80
- <input type="number" name="<?php echo esc_attr( $value['id'] ); ?>" class="regular-text" value="<?php echo esc_attr( stripslashes( $plugin_options[ $value['id'] ] ) ); ?>">
81
  <br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
82
  </td>
83
  </tr>
@@ -296,14 +304,18 @@ if ( ! class_exists( 'AWS_Admin_Fields' ) ) :
296
  <?php
297
  $active_class = isset( $table_options[$val] ) && $table_options[$val] ? 'active' : '';
298
  $label = is_array( $fchoices ) ? $fchoices['label'] : $fchoices;
 
 
 
299
  ?>
300
 
301
  <tr>
302
- <td class="aws-name"><?php echo esc_html( $label ); ?></td>
303
  <td class="aws-actions"></td>
304
  <td class="aws-active <?php echo $active_class; ?>">
305
  <span data-change-state="1" data-setting="<?php echo esc_attr( $value['id'] ); ?>" data-name="<?php echo esc_attr( $val ); ?>" class="aws-yes" title="<?php echo esc_attr__( 'Disable this source', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'Yes', 'advanced-woo-search' ); ?></span>
306
  <span data-change-state="0" data-setting="<?php echo esc_attr( $value['id'] ); ?>" data-name="<?php echo esc_attr( $val ); ?>" class="aws-no" title="<?php echo esc_attr__( 'Enable this source', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'No', 'advanced-woo-search' ); ?></span>
 
307
  </td>
308
  </tr>
309
  <?php } ?>
@@ -320,9 +332,20 @@ if ( ! class_exists( 'AWS_Admin_Fields' ) ) :
320
 
321
  <?php break;
322
 
323
- case 'heading': ?>
 
 
 
 
 
324
  <tr valign="top">
325
- <th scope="row"><h3 class="aws-heading"><?php echo esc_html( $value['name'] ); ?></h3></th>
 
 
 
 
 
 
326
  </tr>
327
  <?php break;
328
 
74
  <?php break;
75
 
76
  case 'number': ?>
77
+
78
+ <?php
79
+ $params = '';
80
+ $params .= isset( $value['step'] ) ? ' step="' . $value['step'] . '"' : '';
81
+ $params .= isset( $value['min'] ) ? ' min="' . $value['min'] . '"' : '';
82
+ $params .= isset( $value['max'] ) ? ' max="' . $value['max'] . '"' : '';
83
+ ?>
84
+
85
  <tr valign="top">
86
  <th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
87
  <td>
88
+ <input type="number" <?php echo $params; ?> name="<?php echo esc_attr( $value['id'] ); ?>" class="regular-text" value="<?php echo esc_attr( stripslashes( $plugin_options[ $value['id'] ] ) ); ?>">
89
  <br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
90
  </td>
91
  </tr>
304
  <?php
305
  $active_class = isset( $table_options[$val] ) && $table_options[$val] ? 'active' : '';
306
  $label = is_array( $fchoices ) ? $fchoices['label'] : $fchoices;
307
+ if ( strpos( $label, 'index disabled' ) !== false ) {
308
+ $active_class = 'disabled';
309
+ }
310
  ?>
311
 
312
  <tr>
313
+ <td class="aws-name"><?php echo $label; ?></td>
314
  <td class="aws-actions"></td>
315
  <td class="aws-active <?php echo $active_class; ?>">
316
  <span data-change-state="1" data-setting="<?php echo esc_attr( $value['id'] ); ?>" data-name="<?php echo esc_attr( $val ); ?>" class="aws-yes" title="<?php echo esc_attr__( 'Disable this source', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'Yes', 'advanced-woo-search' ); ?></span>
317
  <span data-change-state="0" data-setting="<?php echo esc_attr( $value['id'] ); ?>" data-name="<?php echo esc_attr( $val ); ?>" class="aws-no" title="<?php echo esc_attr__( 'Enable this source', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'No', 'advanced-woo-search' ); ?></span>
318
+ <span style="display: none;" class="aws-disabled" title="<?php echo esc_attr__( 'Source index disabled', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'No', 'advanced-woo-search' ); ?></span>
319
  </td>
320
  </tr>
321
  <?php } ?>
332
 
333
  <?php break;
334
 
335
+ case 'heading':
336
+
337
+ $heading_tag = isset( $value['heading_type'] ) && $value['heading_type'] === 'text' ? 'span' : 'h3';
338
+ $heading_description = isset( $value['desc'] ) ? $value['desc'] : '';
339
+ ?>
340
+
341
  <tr valign="top">
342
+ <th scope="row"><<?php echo $heading_tag; ?> class="aws-heading"><?php echo esc_html( $value['name'] ); ?></<?php echo $heading_tag; ?>></th>
343
+
344
+ <?php if ( $heading_description ): ?>
345
+ <td>
346
+ <span class="description"><?php echo $heading_description; ?></span>
347
+ </td>
348
+ <?php endif; ?>
349
  </tr>
350
  <?php break;
351
 
includes/admin/class-aws-admin-meta-boxes.php CHANGED
@@ -46,7 +46,8 @@ if ( ! class_exists( 'AWS_Admin_Meta_Boxes' ) ) :
46
  $html .= '<div id="aws-reindex"><input class="button" type="button" value="' . esc_attr__( 'Reindex table', 'advanced-woo-search' ) . '"><span class="loader"></span><span class="reindex-progress">0%</span></div><br><br>';
47
  $html .= '<span class="description">' .
48
  sprintf( esc_html__( 'This action only need for %s one time %s - after you activate this plugin. After this all products changes will be re-indexed automatically.', 'advanced-woo-search' ), '<strong>', '</strong>' ) . '<br>' .
49
- __( 'Update all data in plugins index table. Index table - table with products data where plugin is searching all typed terms.<br>Use this button if you think that plugin not shows last actual data in its search results.<br><strong>CAUTION:</strong> this can take large amount of time.', 'advanced-woo-search' ) . '<br><br>' .
 
50
  esc_html__( 'Products in index:', 'advanced-woo-search' ) . '<span id="aws-reindex-count"> <strong>' . AWS_Helpers::get_indexed_products_count() . '</strong></span>';
51
  $html .= '</span>';
52
  $html .= '</td>';
@@ -123,6 +124,24 @@ if ( ! class_exists( 'AWS_Admin_Meta_Boxes' ) ) :
123
 
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }
127
 
128
  endif;
46
  $html .= '<div id="aws-reindex"><input class="button" type="button" value="' . esc_attr__( 'Reindex table', 'advanced-woo-search' ) . '"><span class="loader"></span><span class="reindex-progress">0%</span></div><br><br>';
47
  $html .= '<span class="description">' .
48
  sprintf( esc_html__( 'This action only need for %s one time %s - after you activate this plugin. After this all products changes will be re-indexed automatically.', 'advanced-woo-search' ), '<strong>', '</strong>' ) . '<br>' .
49
+ __( 'Update all data in plugins index table. Index table - table with products data where plugin is searching all typed terms.<br>Use this button if you think that plugin not shows last actual data in its search results.<br>' .
50
+ '<strong>CAUTION:</strong> this can take large amount of time.', 'advanced-woo-search' ) . sprintf( __( 'Index table options can be found inside %s section.', 'advanced-woo-search' ), '<a href="'.esc_url( admin_url('admin.php?page=aws-options&tab=performance') ).'">' . __( 'Performance', 'advanced-woo-search' ) . '</a>' ) . '<br><br>' .
51
  esc_html__( 'Products in index:', 'advanced-woo-search' ) . '<span id="aws-reindex-count"> <strong>' . AWS_Helpers::get_indexed_products_count() . '</strong></span>';
52
  $html .= '</span>';
53
  $html .= '</td>';
124
 
125
  }
126
 
127
+ /*
128
+ * Get content for the reindex notice
129
+ * @return string
130
+ */
131
+ static public function get_reindex_notice() {
132
+
133
+ $html = '';
134
+
135
+ $html .= '<div class="updated notice is-dismissible">';
136
+ $html .= '<p>';
137
+ $html .= sprintf( esc_html__( 'Advanced Woo Search: In order to apply the changes in the index table you need to reindex. %s', 'advanced-woo-search' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Go to Settings Page', 'advanced-woo-search' ).'</a>' );
138
+ $html .= '</p>';
139
+ $html .= '</div>';
140
+
141
+ return $html;
142
+
143
+ }
144
+
145
  }
146
 
147
  endif;
includes/admin/class-aws-admin-options.php CHANGED
@@ -162,6 +162,14 @@ if ( ! class_exists( 'AWS_Admin_Options' ) ) :
162
 
163
  }
164
 
 
 
 
 
 
 
 
 
165
  return $options_arr;
166
 
167
  }
@@ -292,6 +300,85 @@ if ( ! class_exists( 'AWS_Admin_Options' ) ) :
292
  )
293
  );
294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  // Search Form Settings
296
  $options['form'][] = array(
297
  "name" => __( "Text for search field", "advanced-woo-search" ),
@@ -577,6 +664,51 @@ if ( ! class_exists( 'AWS_Admin_Options' ) ) :
577
 
578
  }
579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580
  }
581
 
582
  endif;
162
 
163
  }
164
 
165
+ /**
166
+ * Filter admin page options for current page
167
+ * @since 2.23
168
+ * @param array $options_arr Array of options
169
+ * @param bool|string $tab Current settings page tab
170
+ */
171
+ $options_arr = apply_filters( 'aws_admin_page_options_current', $options_arr, $tab );
172
+
173
  return $options_arr;
174
 
175
  }
300
  )
301
  );
302
 
303
+ $options['performance'][] = array(
304
+ "name" => __( "Search options", "advanced-woo-search" ),
305
+ "type" => "heading"
306
+ );
307
+
308
+ $options['performance'][] = array(
309
+ "name" => __( "Search rule", "advanced-woo-search" ),
310
+ "desc" => __( "Search rule that will be used for terms search.", "advanced-woo-search" ),
311
+ "id" => "search_rule",
312
+ "value" => 'contains',
313
+ "type" => "radio",
314
+ 'choices' => array(
315
+ 'contains' => '%s% ' . __( "( contains ). Search query can be inside any part of the product words ( beginning, end, middle ). Slow.", "advanced-woo-search" ),
316
+ 'begins' => 's% ' . __( "( begins ). Search query can be only at the beginning of the product words. Fast.", "advanced-woo-search" ),
317
+ )
318
+ );
319
+
320
+ $options['performance'][] = array(
321
+ "name" => __( "AJAX timeout", "advanced-woo-search" ),
322
+ "desc" => __( "Time after user input that script is waiting before sending a search event to the server, ms.", "advanced-woo-search" ),
323
+ "id" => "search_timeout",
324
+ "value" => 300,
325
+ 'min' => 100,
326
+ "type" => "number"
327
+ );
328
+
329
+ $options['performance'][] = array(
330
+ "name" => __( "Index table options", "advanced-woo-search" ),
331
+ "type" => "heading"
332
+ );
333
+
334
+ $options['performance'][] = array(
335
+ "name" => __( "Overview", "advanced-woo-search" ),
336
+ 'heading_type' => 'text',
337
+ 'desc' => __( 'To perform the search plugin use a special index table. This table contains normalized words of all your products from all available sources.', "advanced-woo-search" ) . '<br>' .
338
+ __( 'Sometimes when there are too many products in your store index table can be very large and that can reflect on search speed.', "advanced-woo-search" ) . '<br>' .
339
+ __( 'In this section you can use several options to change the table size by disabling some unused product data.', "advanced-woo-search" ) . '<br>' .
340
+ '<b>' . __( "Note:", "advanced-woo-search" ) . '</b> ' . __( "Reindex is required after options changes.", "advanced-woo-search" ),
341
+ "type" => "heading"
342
+ );
343
+
344
+ $options['performance'][] = array(
345
+ "name" => __( "Data to index", "advanced-woo-search" ),
346
+ "desc" => __( "Choose what products data to add inside the plugin index table.", "advanced-woo-search" ),
347
+ "table_head" => __( 'What to index', 'advanced-woo-search' ),
348
+ "id" => "index_sources",
349
+ "value" => array(
350
+ 'title' => 1,
351
+ 'content' => 1,
352
+ 'sku' => 1,
353
+ 'excerpt' => 1,
354
+ 'category' => 1,
355
+ 'tag' => 1,
356
+ 'id' => 1,
357
+ ),
358
+ "choices" => array(
359
+ "title" => __( "Title", "advanced-woo-search" ),
360
+ "content" => __( "Content", "advanced-woo-search" ),
361
+ "sku" => __( "SKU", "advanced-woo-search" ),
362
+ "excerpt" => __( "Short description", "advanced-woo-search" ),
363
+ "category" => __( "Category", "advanced-woo-search" ),
364
+ "tag" => __( "Tag", "advanced-woo-search" ),
365
+ "id" => __( "ID", "advanced-woo-search" ),
366
+ ),
367
+ "type" => "table"
368
+ );
369
+
370
+ $options['performance'][] = array(
371
+ "name" => __( "Index variations", "advanced-woo-search" ),
372
+ "desc" => __( "Index or not content of product variations.", "advanced-woo-search" ),
373
+ "id" => "index_variations",
374
+ "value" => 'true',
375
+ "type" => "radio",
376
+ 'choices' => array(
377
+ 'true' => __( 'On', 'advanced-woo-search' ),
378
+ 'false' => __( 'Off', 'advanced-woo-search' ),
379
+ )
380
+ );
381
+
382
  // Search Form Settings
383
  $options['form'][] = array(
384
  "name" => __( "Text for search field", "advanced-woo-search" ),
664
 
665
  }
666
 
667
+ /**
668
+ * Get array of index table options
669
+ * @return array $options
670
+ */
671
+ static public function get_index_options() {
672
+
673
+ /**
674
+ * Apply or not WP filters to indexed content
675
+ * @since 1.82
676
+ * @param bool false
677
+ */
678
+ $apply_filters = apply_filters( 'aws_index_apply_filters', false );
679
+
680
+ $index_variations_option = AWS()->get_settings( 'index_variations' );
681
+ $index_sources_option = AWS()->get_settings( 'index_sources' );
682
+
683
+ $index_variations = $index_variations_option && $index_variations_option === 'false' ? false : true;
684
+ $index_title = is_array( $index_sources_option ) && isset( $index_sources_option['title'] ) && ! $index_sources_option['title'] ? false : true;
685
+ $index_content = is_array( $index_sources_option ) && isset( $index_sources_option['content'] ) && ! $index_sources_option['content'] ? false : true;
686
+ $index_sku = is_array( $index_sources_option ) && isset( $index_sources_option['sku'] ) && ! $index_sources_option['sku'] ? false : true;
687
+ $index_excerpt = is_array( $index_sources_option ) && isset( $index_sources_option['excerpt'] ) && ! $index_sources_option['excerpt'] ? false : true;
688
+ $index_category = is_array( $index_sources_option ) && isset( $index_sources_option['category'] ) && ! $index_sources_option['category'] ? false : true;
689
+ $index_tag = is_array( $index_sources_option ) && isset( $index_sources_option['tag'] ) && ! $index_sources_option['tag'] ? false : true;
690
+ $index_id = is_array( $index_sources_option ) && isset( $index_sources_option['id'] ) && ! $index_sources_option['id'] ? false : true;
691
+
692
+ $index_vars = array(
693
+ 'variations' => $index_variations,
694
+ 'title' => $index_title,
695
+ 'content' => $index_content,
696
+ 'sku' => $index_sku,
697
+ 'excerpt' => $index_excerpt,
698
+ 'category' => $index_category,
699
+ 'tag' => $index_tag,
700
+ 'id' => $index_id,
701
+ );
702
+
703
+ $options = array(
704
+ 'apply_filters' => $apply_filters,
705
+ 'index' => $index_vars,
706
+ );
707
+
708
+ return $options;
709
+
710
+ }
711
+
712
  }
713
 
714
  endif;
includes/admin/class-aws-admin.php CHANGED
@@ -55,8 +55,15 @@ class AWS_Admin {
55
 
56
  add_action( 'admin_notices', array( $this, 'display_welcome_header' ), 1 );
57
 
 
 
58
  add_filter( 'submenu_file', array( $this, 'submenu_file' ), 10, 2 );
59
 
 
 
 
 
 
60
  }
61
 
62
  /**
@@ -76,10 +83,11 @@ class AWS_Admin {
76
  $nonce = wp_create_nonce( 'plugin-settings' );
77
 
78
  $tabs = array(
79
- 'general' => esc_html__( 'General', 'advanced-woo-search' ),
80
- 'form' => esc_html__( 'Search Form', 'advanced-woo-search' ),
81
- 'results' => esc_html__( 'Search Results', 'advanced-woo-search' ),
82
- 'premium' => esc_html__( 'Get Premium', 'advanced-woo-search' )
 
83
  );
84
 
85
  $current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_text_field( $_GET['tab'] );
@@ -108,6 +116,9 @@ class AWS_Admin {
108
  echo '<form action="" name="aws_form" id="aws_form" method="post">';
109
 
110
  switch ($current_tab) {
 
 
 
111
  case('form'):
112
  new AWS_Admin_Fields( 'form' );
113
  break;
@@ -173,6 +184,49 @@ class AWS_Admin {
173
  return $submenu_file;
174
  }
175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  /*
177
  * Add welcome notice
178
  */
@@ -192,6 +246,25 @@ class AWS_Admin {
192
 
193
  }
194
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  }
196
 
197
  endif;
55
 
56
  add_action( 'admin_notices', array( $this, 'display_welcome_header' ), 1 );
57
 
58
+ add_action( 'admin_notices', array( $this, 'display_reindex_message' ), 1 );
59
+
60
  add_filter( 'submenu_file', array( $this, 'submenu_file' ), 10, 2 );
61
 
62
+ add_filter( 'aws_admin_page_options_current', array( $this, 'check_sources_in_index' ), 1 );
63
+
64
+ add_action( 'aws_admin_change_state', array( $this, 'disable_not_indexed_sources' ), 1, 3 );
65
+
66
+
67
  }
68
 
69
  /**
83
  $nonce = wp_create_nonce( 'plugin-settings' );
84
 
85
  $tabs = array(
86
+ 'general' => esc_html__( 'General', 'advanced-woo-search' ),
87
+ 'performance' => esc_html__( 'Performance', 'advanced-woo-search' ),
88
+ 'form' => esc_html__( 'Search Form', 'advanced-woo-search' ),
89
+ 'results' => esc_html__( 'Search Results', 'advanced-woo-search' ),
90
+ 'premium' => esc_html__( 'Get Premium', 'advanced-woo-search' )
91
  );
92
 
93
  $current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_text_field( $_GET['tab'] );
116
  echo '<form action="" name="aws_form" id="aws_form" method="post">';
117
 
118
  switch ($current_tab) {
119
+ case('performance'):
120
+ new AWS_Admin_Fields( 'performance' );
121
+ break;
122
  case('form'):
123
  new AWS_Admin_Fields( 'form' );
124
  break;
184
  return $submenu_file;
185
  }
186
 
187
+ /*
188
+ * Check if some sources for disabled from index
189
+ */
190
+ public function check_sources_in_index( $options ) {
191
+
192
+ if ( $options ) {
193
+
194
+ $index_options = AWS_Admin_Options::get_index_options();
195
+
196
+ foreach( $options as $options_key => $options_tab ) {
197
+ foreach( $options_tab as $key => $option ) {
198
+ if ( isset( $option['id'] ) && $option['id'] === 'search_in' && isset( $option['choices'] ) ) {
199
+ foreach( $option['choices'] as $choice_key => $choice_label ) {
200
+ if ( isset( $index_options['index'][$choice_key] ) && ! $index_options['index'][$choice_key] ) {
201
+ $text = '<span style="color:#dc3232;">' . __( '(index disabled)', 'advanced-woo-search' ) . '</span>' . ' <a href="'.esc_url( admin_url('admin.php?page=aws-options&tab=performance') ).'">' . __( '(enable)', 'advanced-woo-search' ) . '</a>';
202
+ $options[$options_key][$key]['choices'][$choice_key] = $choice_label . ' ' . $text;
203
+ }
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ }
210
+
211
+ return $options;
212
+
213
+ }
214
+
215
+ /*
216
+ * Disable sources that was excluded from index
217
+ */
218
+ public function disable_not_indexed_sources( $setting, $option, $state ) {
219
+
220
+ if ( $setting === 'index_sources' && $state ) {
221
+ $settings = AWS_Admin_Options::get_settings();
222
+ if ( isset( $settings['search_in'][$option] ) ) {
223
+ $settings['search_in'][$option] = 0;
224
+ update_option( 'aws_settings', $settings );
225
+ }
226
+ }
227
+
228
+ }
229
+
230
  /*
231
  * Add welcome notice
232
  */
246
 
247
  }
248
 
249
+ /*
250
+ * Add reindex notice after index options change
251
+ */
252
+ public function display_reindex_message() {
253
+
254
+ if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'aws-options' ) {
255
+ return;
256
+ }
257
+
258
+ if ( ! isset( $_POST["Submit"] ) || ! current_user_can( 'manage_options' ) ) {
259
+ return;
260
+ }
261
+
262
+ if ( isset( $_POST["index_variations"] ) || isset( $_POST["search_rule"] ) ) {
263
+ echo AWS_Admin_Meta_Boxes::get_reindex_notice();
264
+ }
265
+
266
+ }
267
+
268
  }
269
 
270
  endif;
includes/class-aws-integrations.php CHANGED
@@ -157,6 +157,25 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
157
  add_filter( 'wp_nav_menu', array( $this, 'aurum_mobile_menu' ), 10, 2 );
158
  }
159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
 
162
  add_action( 'wp_head', array( $this, 'head_js_integration' ) );
@@ -243,6 +262,11 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
243
  add_action( 'wp_enqueue_scripts', array( $this, 'divi_popups_enqueue_scripts' ), 999 );
244
  }
245
 
 
 
 
 
 
246
  }
247
 
248
  /**
@@ -1036,6 +1060,157 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
1036
  return $nav_menu;
1037
  }
1038
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1039
  /*
1040
  * Exclude product categories
1041
  */
@@ -1207,6 +1382,18 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
1207
  $selectors[] = '.ts-header .search-wrapper form';
1208
  }
1209
 
 
 
 
 
 
 
 
 
 
 
 
 
1210
  // WCFM - WooCommerce Multivendor Marketplace
1211
  if ( class_exists( 'WCFMmp' ) ) {
1212
  $selectors[] = '#wcfmmp-store .woocommerce-product-search';
@@ -1461,9 +1648,24 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
1461
  $taxonomy = $matches[1];
1462
  $operator = strpos( $matches[2], '-' ) !== false ? 'OR' : 'AND';
1463
  $explode_char = strpos( $matches[2], '-' ) !== false ? '-' : '+';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1464
  $filters['tax'][$taxonomy] = array(
1465
- 'terms' => explode( $explode_char, $matches[2] ),
1466
- 'operator' => $operator
 
1467
  );
1468
  }
1469
 
@@ -1730,6 +1932,22 @@ if ( ! class_exists( 'AWS_Integrations' ) ) :
1730
 
1731
  }
1732
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1733
  }
1734
 
1735
  endif;
157
  add_filter( 'wp_nav_menu', array( $this, 'aurum_mobile_menu' ), 10, 2 );
158
  }
159
 
160
+ if ( 'Fury' === $this->current_theme ) {
161
+ add_filter( 'aws_searchbox_markup', array( $this, 'fury_searchbox_markup' ) );
162
+ add_action( 'wp_head', array( $this, 'fury_wp_head' ) );
163
+ }
164
+
165
+ if ( 'Bazar' === $this->current_theme ) {
166
+ add_action( 'yit_header-cart-search_after', array( $this, 'bazar_add_header_form' ) );
167
+ add_action( 'wp_head', array( $this, 'bazar_wp_head' ) );
168
+ }
169
+
170
+ if ( 'Claue' === $this->current_theme ) {
171
+ add_filter( 'jas_claue_header', array( $this, 'claue_header' ) );
172
+ add_action( 'wp_head', array( $this, 'claue_wp_head' ) );
173
+ }
174
+
175
+ if ( 'Salient' === $this->current_theme ) {
176
+ add_action( 'wp_head', array( $this, 'salient_wp_head' ) );
177
+ }
178
+
179
  }
180
 
181
  add_action( 'wp_head', array( $this, 'head_js_integration' ) );
262
  add_action( 'wp_enqueue_scripts', array( $this, 'divi_popups_enqueue_scripts' ), 999 );
263
  }
264
 
265
+ // WooCommerce Catalog Visibility Options plugin
266
+ if ( class_exists( 'WC_Catalog_Restrictions_Query' ) ) {
267
+ add_filter( 'aws_exclude_products', array( $this, 'wcvo_exclude_products' ), 1 );
268
+ }
269
+
270
  }
271
 
272
  /**
1060
  return $nav_menu;
1061
  }
1062
 
1063
+ /*
1064
+ * Fury theme markup change
1065
+ */
1066
+ public function fury_searchbox_markup( $markup ) {
1067
+ global $wp_current_filter;
1068
+ if ( in_array( 'wp_head', $wp_current_filter ) ) {
1069
+ $search_tools = '<div class="search-tools">
1070
+ <button type="button" class="clear-search">' . esc_html( "Clear", "fury" ) . '</button>
1071
+ <button type="button" class="close-search" aria-label="' . esc_attr( "Close search", "fury" ) . '"><i class="icon-cross"></i></button>
1072
+ </div>';
1073
+ $markup = str_replace( 'aws-container', 'aws-container aws-fury-navbar', $markup );
1074
+ $markup = str_replace( 'aws-search-form', 'aws-search-form site-search', $markup );
1075
+ $markup = str_replace( '<div class="aws-search-clear">', $search_tools . '<div class="aws-search-clear">', $markup );
1076
+ }
1077
+ return $markup;
1078
+ }
1079
+
1080
+ /*
1081
+ * Fury theme styles and scripts
1082
+ */
1083
+ public function fury_wp_head() { ?>
1084
+ <style>
1085
+ .aws-fury-navbar.aws-container,
1086
+ .aws-fury-navbar.aws-container form {
1087
+ height: 100%;
1088
+ position: absolute;
1089
+ width: 100%;
1090
+ }
1091
+ .aws-fury-navbar.aws-container .aws-search-form.aws-show-clear.aws-form-active .aws-search-clear {
1092
+ display: none !important;
1093
+ }
1094
+ </style>
1095
+ <script>
1096
+ window.addEventListener('load', function() {
1097
+ if ( typeof jQuery !== 'undefined' ) {
1098
+
1099
+ jQuery(document).on( 'click', '.aws-fury-navbar .clear-search', function () {
1100
+ jQuery('.aws-fury-navbar input').val('');
1101
+ jQuery('.aws-search-result').hide();
1102
+ jQuery('.aws-fury-navbar .aws-search-form').removeClass('aws-form-active');
1103
+ } );
1104
+
1105
+ jQuery(document).on( 'click', '.aws-fury-navbar .close-search', function () {
1106
+ jQuery('.aws-fury-navbar .aws-search-form').removeClass('search-visible');
1107
+ jQuery('.aws-fury-navbar input').val('');
1108
+ jQuery('.aws-search-result').hide();
1109
+ jQuery('.aws-fury-navbar .aws-search-form').removeClass('aws-form-active');
1110
+ } );
1111
+
1112
+ }
1113
+ }, false);
1114
+ </script>
1115
+ <?php }
1116
+
1117
+ /*
1118
+ * Bazar theme: add search form
1119
+ */
1120
+ public function bazar_add_header_form() {
1121
+ $output = aws_get_search_form( false );
1122
+ $output = str_replace( 'aws-container', 'aws-container widget widget_search_mini', $output );
1123
+ echo $output;
1124
+ }
1125
+
1126
+ /*
1127
+ * Bazar theme: add styles
1128
+ */
1129
+ public function bazar_wp_head() { ?>
1130
+ <style>
1131
+ #header-cart-search .widget_search_mini:not(.aws-container){
1132
+ display: none !important;
1133
+ }
1134
+ #header-cart-search .aws-container,
1135
+ #header-cart-search .aws-container .aws-search-form {
1136
+ height: 50px;
1137
+ }
1138
+ #header-cart-search .aws-container .aws-search-field {
1139
+ font-size: 18px;
1140
+ font-family: 'Oswald', sans-serif;
1141
+ color: #747373;
1142
+ font-style: normal;
1143
+ font-weight: 400;
1144
+ text-transform: uppercase;
1145
+ padding-left: 14px;
1146
+ }
1147
+ </style>
1148
+ <?php }
1149
+
1150
+ /*
1151
+ * Claue theme header markup
1152
+ */
1153
+ public function claue_header( $markup ) {
1154
+ $pattern = '/(<form[\S\s]*?<\/form>)/i';
1155
+ if ( strpos( $markup, 'aws-container' ) === false ) {
1156
+ $form = '<div class="header__search w__100 dn pf">' . aws_get_search_form( false ) . '<a id="sf-close" class="pa" href="#"><i class="pe-7s-close"></i></a></div>';
1157
+ $markup = preg_replace( $pattern, $form, $markup );
1158
+ }
1159
+ return $markup;
1160
+ }
1161
+
1162
+ /*
1163
+ * Claue theme styles
1164
+ */
1165
+ public function claue_wp_head() { ?>
1166
+ <style>
1167
+ #jas-header .aws-container {
1168
+ position: absolute;
1169
+ }
1170
+ #jas-header .aws-container .aws-search-field {
1171
+ height: 100% !important;
1172
+ font-size: 20px;
1173
+ }
1174
+ #jas-header .aws-container .aws-search-field,
1175
+ #jas-header .aws-container .aws-search-form .aws-form-btn {
1176
+ background: transparent;
1177
+ border-color: rgba(255, 255, 255, .2);
1178
+ }
1179
+ </style>
1180
+ <?php }
1181
+
1182
+ /*
1183
+ * Salient theme styles
1184
+ */
1185
+ public function salient_wp_head() { ?>
1186
+ <style>
1187
+ #search-outer #search #close {
1188
+ top: -5px;
1189
+ }
1190
+ #search-box .aws-container {
1191
+ margin-right: 70px;
1192
+ }
1193
+ #search-box .aws-container .aws-search-form .aws-search-btn_icon {
1194
+ margin: 0 !important;
1195
+ color: rgba(0,0,0,0.7) !important;
1196
+ }
1197
+ #search-box .aws-container .aws-search-field {
1198
+ font-size: 26px;
1199
+ font-weight: bold;
1200
+ padding: 6px 15px 8px 0;
1201
+ background: transparent;
1202
+ }
1203
+ #search-box .aws-container .aws-search-field:focus {
1204
+ box-shadow: none;
1205
+ }
1206
+ #search-box .aws-container .aws-search-field,
1207
+ #search-box .aws-container .aws-search-form .aws-form-btn {
1208
+ border: none;
1209
+ border-bottom: 3px solid #3452ff !important;
1210
+ }
1211
+ </style>
1212
+ <?php }
1213
+
1214
  /*
1215
  * Exclude product categories
1216
  */
1382
  $selectors[] = '.ts-header .search-wrapper form';
1383
  }
1384
 
1385
+ if ( 'Fury' === $this->current_theme ) {
1386
+ $selectors[] = 'header .site-search';
1387
+ }
1388
+
1389
+ if ( 'Urna' === $this->current_theme ) {
1390
+ $selectors[] = '#tbay-header .searchform';
1391
+ }
1392
+
1393
+ if ( 'Salient' === $this->current_theme ) {
1394
+ $selectors[] = '#search-box form';
1395
+ }
1396
+
1397
  // WCFM - WooCommerce Multivendor Marketplace
1398
  if ( class_exists( 'WCFMmp' ) ) {
1399
  $selectors[] = '#wcfmmp-store .woocommerce-product-search';
1648
  $taxonomy = $matches[1];
1649
  $operator = strpos( $matches[2], '-' ) !== false ? 'OR' : 'AND';
1650
  $explode_char = strpos( $matches[2], '-' ) !== false ? '-' : '+';
1651
+ $terms_arr = explode( $explode_char, $matches[2] );
1652
+ // if used slugs instead of IDs for terms
1653
+ if ( preg_match( '/[a-z]/', $matches[2] ) ) {
1654
+ $new_terms_arr = array();
1655
+ foreach ( $terms_arr as $term_slug ) {
1656
+ $term = get_term_by('slug', $term_slug, $taxonomy );
1657
+ if ( $term ) {
1658
+ $new_terms_arr[] = $term->term_id;
1659
+ }
1660
+ }
1661
+ if ( $new_terms_arr ) {
1662
+ $terms_arr = $new_terms_arr;
1663
+ }
1664
+ }
1665
  $filters['tax'][$taxonomy] = array(
1666
+ 'terms' => $terms_arr,
1667
+ 'operator' => $operator,
1668
+ 'include_parent' => true,
1669
  );
1670
  }
1671
 
1932
 
1933
  }
1934
 
1935
+ /*
1936
+ * WooCommerce Catalog Visibility Options plugin: exclude restricted products
1937
+ */
1938
+ public function wcvo_exclude_products( $exclude_products ) {
1939
+ $catalog_query = WC_Catalog_Restrictions_Query::instance();
1940
+ if ( is_object( $catalog_query ) && method_exists( $catalog_query, 'get_disallowed_products' ) ) {
1941
+ $disallowed_products = $catalog_query->get_disallowed_products();
1942
+ if ( is_array( $disallowed_products ) && ! empty( $disallowed_products ) ) {
1943
+ foreach( $disallowed_products as $disallowed_product ) {
1944
+ $exclude_products[] = $disallowed_product;
1945
+ }
1946
+ }
1947
+ }
1948
+ return $exclude_products;
1949
+ }
1950
+
1951
  }
1952
 
1953
  endif;
includes/class-aws-markup.php CHANGED
@@ -28,15 +28,16 @@ if ( ! class_exists( 'AWS_Markup' ) ) :
28
  }
29
 
30
 
31
- $placeholder = AWS_Helpers::translate( 'search_field_text', AWS()->get_settings( 'search_field_text' ) );
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' );
39
- $buttons_order = AWS()->get_settings( 'buttons_order' );
 
40
 
41
  $current_lang = AWS_Helpers::get_lang();
42
 
@@ -64,6 +65,7 @@ if ( ! class_exists( 'AWS_Markup' ) ) :
64
  'data-use-analytics' => $use_analytics,
65
  'data-min-chars' => $min_chars,
66
  'data-buttons-order' => $buttons_order,
 
67
  'data-is-mobile' => wp_is_mobile() ? 'true' : 'false',
68
  'data-page-id' => get_queried_object_id(),
69
  'data-tax' => get_query_var('taxonomy')
28
  }
29
 
30
 
31
+ $placeholder = AWS_Helpers::translate( 'search_field_text', AWS()->get_settings( 'search_field_text' ) );
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' );
39
+ $buttons_order = AWS()->get_settings( 'buttons_order' );
40
+ $search_timeout = AWS()->get_settings( 'search_timeout' );
41
 
42
  $current_lang = AWS_Helpers::get_lang();
43
 
65
  'data-use-analytics' => $use_analytics,
66
  'data-min-chars' => $min_chars,
67
  'data-buttons-order' => $buttons_order,
68
+ 'data-timeout' => $search_timeout,
69
  'data-is-mobile' => wp_is_mobile() ? 'true' : 'false',
70
  'data-page-id' => get_queried_object_id(),
71
  'data-tax' => get_query_var('taxonomy')
includes/class-aws-order.php CHANGED
@@ -154,17 +154,34 @@ if ( ! class_exists( 'AWS_Order' ) ) :
154
 
155
  $terms = get_the_terms( $post_array['id'], $taxonomy );
156
  $operator = isset( $taxonomy_terms['operator'] ) ? $taxonomy_terms['operator'] : 'OR';
 
157
  $term_arr = array();
158
 
159
  if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
160
  foreach ( $terms as $term ) {
161
  $term_arr[] = $term->term_id;
 
 
 
 
 
 
 
 
162
  }
163
  } elseif( strpos( $taxonomy, 'pa_' ) !== 0 ) {
164
  $terms = get_the_terms( $post_array['id'], 'pa_' . $taxonomy );
165
  if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
166
  foreach ( $terms as $term ) {
167
  $term_arr[] = $term->term_id;
 
 
 
 
 
 
 
 
168
  }
169
  }
170
  }
154
 
155
  $terms = get_the_terms( $post_array['id'], $taxonomy );
156
  $operator = isset( $taxonomy_terms['operator'] ) ? $taxonomy_terms['operator'] : 'OR';
157
+ $include_parent = isset( $taxonomy_terms['include_parent'] ) ? $taxonomy_terms['include_parent'] : false;
158
  $term_arr = array();
159
 
160
  if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
161
  foreach ( $terms as $term ) {
162
  $term_arr[] = $term->term_id;
163
+ if ( $include_parent && $term->parent ) {
164
+ $term_arr[] = $term->parent;
165
+ $term_parent = get_term( $term->parent, $taxonomy );
166
+ while ( ! is_wp_error( $term_parent ) && ! empty( $term_parent->parent ) && ! in_array( $term_parent->parent, $term_arr, true ) ) {
167
+ $term_arr[] = (int) $term_parent->parent;
168
+ $term_parent = get_term( $term_parent->parent, $taxonomy );
169
+ }
170
+ }
171
  }
172
  } elseif( strpos( $taxonomy, 'pa_' ) !== 0 ) {
173
  $terms = get_the_terms( $post_array['id'], 'pa_' . $taxonomy );
174
  if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
175
  foreach ( $terms as $term ) {
176
  $term_arr[] = $term->term_id;
177
+ if ( $include_parent && $term->parent ) {
178
+ $term_arr[] = $term->parent;
179
+ $term_parent = get_term( $term->parent, $taxonomy );
180
+ while ( ! is_wp_error( $term_parent ) && ! empty( $term_parent->parent ) && ! in_array( $term_parent->parent, $term_arr, true ) ) {
181
+ $term_arr[] = (int) $term_parent->parent;
182
+ $term_parent = get_term( $term_parent->parent, $taxonomy );
183
+ }
184
+ }
185
  }
186
  }
187
  }
includes/class-aws-search.php CHANGED
@@ -127,22 +127,20 @@ if ( ! class_exists( 'AWS_Search' ) ) :
127
  $results_num = $keyword ? apply_filters( 'aws_page_results', 100 ) : AWS()->get_settings( 'results_num' );
128
  $search_in = AWS()->get_settings( 'search_in' );
129
  $outofstock = AWS()->get_settings( 'outofstock' );
 
130
 
131
- if ( is_array( $search_in ) ) {
 
 
132
  foreach( $search_in as $search_in_source => $search_in_active ) {
133
  if ( $search_in_active ) {
134
  $search_in_arr[] = $search_in_source;
135
  }
136
  }
137
- } else {
138
  $search_in_arr = explode( ',', $search_in );
139
  }
140
 
141
- // Search in title if all options is disabled
142
- if ( ! $search_in ) {
143
- $search_in_arr = array( 'title' );
144
- }
145
-
146
  $products_array = array();
147
  $tax_to_display = array();
148
  $custom_tax_array = array();
@@ -152,6 +150,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
152
  $this->data['search_terms'] = array();
153
  $this->data['search_in'] = $search_in_arr;
154
  $this->data['outofstock'] = $outofstock;
 
155
 
156
  $search_array = array_unique( explode( ' ', $s ) );
157
 
@@ -172,30 +171,34 @@ if ( ! class_exists( 'AWS_Search' ) ) :
172
 
173
  if ( ! empty( $this->data['search_terms'] ) ) {
174
 
175
- $posts_ids = $this->query_index_table();
176
 
177
- /**
178
- * Filters array of products ids
179
- *
180
- * @since 1.53
181
- *
182
- * @param array $posts_ids Array of products ids
183
- * @param string $s Search query
184
- */
185
- $posts_ids = apply_filters( 'aws_search_results_products_ids', $posts_ids, $s );
186
 
 
 
 
 
 
 
 
 
 
187
 
188
- $products_array = $this->get_products( $posts_ids );
189
 
190
- /**
191
- * Filters array of products before they displayed in search results
192
- *
193
- * @since 1.42
194
- *
195
- * @param array $products_array Array of products results
196
- * @param string $s Search query
197
- */
198
- $products_array = apply_filters( 'aws_search_results_products', $products_array, $s );
 
 
 
 
199
 
200
  if ( $show_cats === 'true' ) {
201
  $tax_to_display[] = 'product_cat';
@@ -261,7 +264,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
261
  $search_in_arr = $this->data['search_in'];
262
  $results_num = $this->data['results_num'];
263
  $outofstock = $this->data['outofstock'];
264
-
265
 
266
  $reindex_version = get_option( 'aws_reindex_version' );
267
 
@@ -305,8 +308,11 @@ if ( ! class_exists( 'AWS_Search' ) ) :
305
  $search_term = $search_term_norm;
306
  }
307
 
308
- $like = '%' . $wpdb->esc_like( $search_term ) . '%';
309
-
 
 
 
310
 
311
  if ( $search_term_len > 1 ) {
312
  $search_array[] = $wpdb->prepare( '( term LIKE %s )', $like );
127
  $results_num = $keyword ? apply_filters( 'aws_page_results', 100 ) : AWS()->get_settings( 'results_num' );
128
  $search_in = AWS()->get_settings( 'search_in' );
129
  $outofstock = AWS()->get_settings( 'outofstock' );
130
+ $search_rule = AWS()->get_settings( 'search_rule' );
131
 
132
+ $search_in_arr = array();
133
+
134
+ if ( is_array( $search_in ) && ! empty( $search_in ) ) {
135
  foreach( $search_in as $search_in_source => $search_in_active ) {
136
  if ( $search_in_active ) {
137
  $search_in_arr[] = $search_in_source;
138
  }
139
  }
140
+ } elseif ( is_string( $search_in ) && $search_in ) {
141
  $search_in_arr = explode( ',', $search_in );
142
  }
143
 
 
 
 
 
 
144
  $products_array = array();
145
  $tax_to_display = array();
146
  $custom_tax_array = array();
150
  $this->data['search_terms'] = array();
151
  $this->data['search_in'] = $search_in_arr;
152
  $this->data['outofstock'] = $outofstock;
153
+ $this->data['search_rule'] = $search_rule;
154
 
155
  $search_array = array_unique( explode( ' ', $s ) );
156
 
171
 
172
  if ( ! empty( $this->data['search_terms'] ) ) {
173
 
174
+ if ( ! empty( $this->data['search_in'] ) ) {
175
 
176
+ $posts_ids = $this->query_index_table();
 
 
 
 
 
 
 
 
177
 
178
+ /**
179
+ * Filters array of products ids
180
+ *
181
+ * @since 1.53
182
+ *
183
+ * @param array $posts_ids Array of products ids
184
+ * @param string $s Search query
185
+ */
186
+ $posts_ids = apply_filters( 'aws_search_results_products_ids', $posts_ids, $s );
187
 
 
188
 
189
+ $products_array = $this->get_products( $posts_ids );
190
+
191
+ /**
192
+ * Filters array of products before they displayed in search results
193
+ *
194
+ * @since 1.42
195
+ *
196
+ * @param array $products_array Array of products results
197
+ * @param string $s Search query
198
+ */
199
+ $products_array = apply_filters( 'aws_search_results_products', $products_array, $s );
200
+
201
+ }
202
 
203
  if ( $show_cats === 'true' ) {
204
  $tax_to_display[] = 'product_cat';
264
  $search_in_arr = $this->data['search_in'];
265
  $results_num = $this->data['results_num'];
266
  $outofstock = $this->data['outofstock'];
267
+ $search_rule = $this->data['search_rule'];
268
 
269
  $reindex_version = get_option( 'aws_reindex_version' );
270
 
308
  $search_term = $search_term_norm;
309
  }
310
 
311
+ if ( $search_rule === 'begins' ) {
312
+ $like = $wpdb->esc_like( $search_term ) . '%';
313
+ } else {
314
+ $like = '%' . $wpdb->esc_like( $search_term ) . '%';
315
+ }
316
 
317
  if ( $search_term_len > 1 ) {
318
  $search_array[] = $wpdb->prepare( '( term LIKE %s )', $like );
includes/class-aws-table-data.php ADDED
@@ -0,0 +1,477 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ if ( ! class_exists( 'AWS_Table_Data' ) ) :
8
+
9
+ /**
10
+ * Class for admin condition rules
11
+ */
12
+ class AWS_Table_Data {
13
+
14
+ /**
15
+ * @var object AWS_Table_Data Product object
16
+ */
17
+ private $product;
18
+
19
+ /**
20
+ * @var int AWS_Table_Data Product id
21
+ */
22
+ private $id;
23
+
24
+ /**
25
+ * @var array AWS_Table_Data Index options
26
+ */
27
+ private $options;
28
+
29
+ /**
30
+ * @var string AWS_Table_Data Current language
31
+ */
32
+ private $lang = '';
33
+
34
+ /**
35
+ * @var array AWS_Table_Data Product data
36
+ */
37
+ private $scraped_data = array();
38
+
39
+ /*
40
+ * Constructor
41
+ */
42
+ public function __construct( $product, $id, $options ) {
43
+
44
+ $this->product = $product;
45
+
46
+ $this->id = $id;
47
+
48
+ $this->options = $options;
49
+
50
+ $this->lang = $this->get_lang();
51
+
52
+ }
53
+
54
+ /*
55
+ * Scrap data from product
56
+ *
57
+ * @return array
58
+ */
59
+ public function scrap_data() {
60
+
61
+ $product = $this->product;
62
+
63
+ $data = array();
64
+
65
+ $data['id'] = $this->id;
66
+
67
+ $data['terms'] = array();
68
+
69
+ $data['in_stock'] = $this->get_stock_status();
70
+ $data['on_sale'] = $product->is_on_sale();
71
+ $data['visibility'] = $this->get_visibility();
72
+ $data['lang'] = $this->lang ? $this->lang : '';
73
+
74
+ $ids = $data['id'];
75
+
76
+ $sku = $product->get_sku();
77
+ $title = get_the_title( $data['id'] );
78
+ $content = get_post_field( 'post_content', $data['id'] );
79
+ $excerpt = get_post_field( 'post_excerpt', $data['id'] );
80
+
81
+ $cat_array = $this->options['index']['category'] ? AWS_Helpers::get_terms_array( $data['id'], 'product_cat' ) : false;
82
+ $tag_array = $this->options['index']['tag'] ? AWS_Helpers::get_terms_array( $data['id'], 'product_tag' ) : false;
83
+
84
+ if ( $this->options['apply_filters'] ) {
85
+ $content = apply_filters( 'the_content', $content, $data['id'] );
86
+ } else {
87
+ $content = do_shortcode( $content );
88
+ }
89
+
90
+ // Get all child products if exists
91
+ if ( $product->is_type( 'variable' ) && class_exists( 'WC_Product_Variation' ) && $this->options['index']['variations'] ) {
92
+
93
+ if ( sizeof( $product->get_children() ) > 0 ) {
94
+
95
+ foreach ( $product->get_children() as $child_id ) {
96
+
97
+ $variation_product = new WC_Product_Variation( $child_id );
98
+
99
+ if ( method_exists( $variation_product, 'get_status' ) && $variation_product->get_status() === 'private' ) {
100
+ continue;
101
+ }
102
+
103
+ $variation_sku = $variation_product->get_sku();
104
+
105
+ $variation_desc = '';
106
+ if ( method_exists( $variation_product, 'get_description' ) ) {
107
+ $variation_desc = $variation_product->get_description();
108
+ }
109
+
110
+ if ( $variation_sku ) {
111
+ $sku = $sku . ' ' . $variation_sku;
112
+ }
113
+
114
+ $ids = $ids . ' ' . $child_id;
115
+
116
+ if ( $variation_desc ) {
117
+ $content = $content . ' ' . $variation_desc;
118
+ }
119
+
120
+ }
121
+
122
+ }
123
+
124
+ }
125
+
126
+ // Get content from Custom Product Tabs
127
+ if ( $custom_tabs = get_post_meta( $data['id'], 'yikes_woo_products_tabs' ) ) {
128
+ if ( $custom_tabs && ! empty( $custom_tabs ) ) {
129
+ foreach( $custom_tabs as $custom_tab_array ) {
130
+ if ( $custom_tab_array && ! empty( $custom_tab_array ) ) {
131
+ foreach( $custom_tab_array as $custom_tab ) {
132
+ if ( isset( $custom_tab['content'] ) && $custom_tab['content'] ) {
133
+ $content = $content . ' ' . $custom_tab['content'];
134
+ }
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
140
+
141
+ // WP 4.2 emoji strip
142
+ if ( function_exists( 'wp_encode_emoji' ) ) {
143
+ $content = wp_encode_emoji( $content );
144
+ }
145
+
146
+ $content = AWS_Helpers::strip_shortcodes( $content );
147
+ $excerpt = AWS_Helpers::strip_shortcodes( $excerpt );
148
+
149
+ /**
150
+ * Filters product title before it will be indexed.
151
+ *
152
+ * @since 1.37
153
+ *
154
+ * @param string $title Product title.
155
+ * @param int $data['id'] Product id.
156
+ * @param object $product Current product object.
157
+ */
158
+ $title = apply_filters( 'aws_indexed_title', $title, $data['id'], $product );
159
+
160
+ /**
161
+ * Filters product content before it will be indexed.
162
+ *
163
+ * @since 1.37
164
+ *
165
+ * @param string $content Product content.
166
+ * @param int $data['id'] Product id.
167
+ * @param object $product Current product object.
168
+ */
169
+ $content = apply_filters( 'aws_indexed_content', $content, $data['id'], $product );
170
+
171
+ /**
172
+ * Filters product excerpt before it will be indexed.
173
+ *
174
+ * @since 1.37
175
+ *
176
+ * @param string $excerpt Product excerpt.
177
+ * @param int $data['id'] Product id.
178
+ * @param object $product Current product object.
179
+ */
180
+ $excerpt = apply_filters( 'aws_indexed_excerpt', $excerpt, $data['id'], $product );
181
+
182
+ $data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $title, 'title' ) : '';
183
+ $data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $content, 'content' ) : '';
184
+ $data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $excerpt, 'excerpt' ) : '';
185
+ $data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
186
+ $data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $ids, 'id' ) : '';
187
+
188
+
189
+ if ( $cat_array && ! empty( $cat_array ) ) {
190
+ foreach( $cat_array as $cat_source => $cat_terms ) {
191
+ $data['terms'][$cat_source] = $this->extract_terms( $cat_terms, 'cat' );
192
+ }
193
+ }
194
+
195
+ if ( $tag_array && ! empty( $tag_array ) ) {
196
+ foreach( $tag_array as $tag_source => $tag_terms ) {
197
+ $data['terms'][$tag_source] = $this->extract_terms( $tag_terms, 'tag' );
198
+ }
199
+ }
200
+
201
+ // Get translations if exists ( WPML )
202
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter('wpml_element_has_translations') && has_filter('wpml_get_element_translations') ) {
203
+
204
+ $is_translated = apply_filters( 'wpml_element_has_translations', NULL, $data['id'], 'post_product' );
205
+
206
+ if ( $is_translated ) {
207
+
208
+ $translations = apply_filters( 'wpml_get_element_translations', NULL, $data['id'], 'post_product');
209
+
210
+ foreach( $translations as $language => $lang_obj ) {
211
+ if ( ! $lang_obj->original && $lang_obj->post_status === 'publish' ) {
212
+ $translated_post = get_post( $lang_obj->element_id );
213
+ if ( $translated_post && !empty( $translated_post ) ) {
214
+
215
+ $translated_post_data = array();
216
+ $translated_post_data['id'] = $translated_post->ID;
217
+ $translated_post_data['in_stock'] = $data['in_stock'];
218
+ $translated_post_data['on_sale'] = $data['on_sale'];
219
+ $translated_post_data['visibility'] = $data['visibility'];
220
+ $translated_post_data['lang'] = $lang_obj->language_code;
221
+ $translated_post_data['terms'] = array();
222
+
223
+ $translated_title = get_the_title( $translated_post->ID );
224
+ $translated_content = get_post_field( 'post_content', $translated_post->ID );
225
+ $translated_excerpt = get_post_field( 'post_excerpt', $translated_post->ID );
226
+
227
+ if ( $this->options['apply_filters'] ) {
228
+ $translated_content = apply_filters( 'the_content', $translated_content, $translated_post->ID );
229
+ }
230
+
231
+ $translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
232
+ $translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
233
+
234
+ $translated_post_data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $translated_title, 'title' ) : '';
235
+ $translated_post_data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $translated_content, 'content' ) : '';
236
+ $translated_post_data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $translated_excerpt, 'excerpt' ) : '';
237
+ $translated_post_data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
238
+ $translated_post_data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $translated_post->ID, 'id' ) : '';
239
+
240
+ $this->scraped_data[] = $translated_post_data;
241
+
242
+ }
243
+ }
244
+ }
245
+
246
+ }
247
+
248
+ }
249
+ elseif ( function_exists( 'qtranxf_use' ) ) {
250
+
251
+ $enabled_languages = get_option( 'qtranslate_enabled_languages' );
252
+
253
+ if ( $enabled_languages ) {
254
+
255
+ foreach( $enabled_languages as $current_lang ) {
256
+
257
+ if ( $current_lang == $this->lang ) {
258
+ $default_lang_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
259
+ $data['terms']['title'] = $this->extract_terms( $default_lang_title, 'title' );
260
+ continue;
261
+ }
262
+
263
+ if ( function_exists( 'qtranxf_getAvailableLanguages' ) ) {
264
+
265
+ global $wpdb;
266
+
267
+ $qtrans_content = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $data['id'] ) );
268
+
269
+ if ( $qtrans_content ) {
270
+
271
+ $languages_title = qtranxf_getAvailableLanguages( $qtrans_content->post_title );
272
+ $languages_content = qtranxf_getAvailableLanguages( $qtrans_content->post_content );
273
+
274
+ if ( ( $languages_title && in_array( $current_lang, $languages_title ) ) || ( $languages_content && in_array( $current_lang, $languages_content ) ) ) {
275
+
276
+ if ( method_exists( $product, 'get_description' ) && method_exists( $product, 'get_name' ) && method_exists( $product, 'get_short_description' ) ) {
277
+
278
+ $translated_post_data = array();
279
+ $translated_post_data['id'] = $data['id'];
280
+ $translated_post_data['in_stock'] = $data['in_stock'];
281
+ $translated_post_data['on_sale'] = $data['on_sale'];
282
+ $translated_post_data['visibility'] = $data['visibility'];
283
+ $translated_post_data['lang'] = $current_lang;
284
+ $translated_post_data['terms'] = array();
285
+
286
+ $translated_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
287
+ $translated_content = qtranxf_use( $current_lang, $product->get_description(), true, true );
288
+ $translated_excerpt = qtranxf_use( $current_lang, $product->get_short_description(), true, true );
289
+
290
+ $translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
291
+ $translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
292
+
293
+ $translated_post_data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $translated_title, 'title' ) : '';
294
+ $translated_post_data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $translated_content, 'content' ) : '';
295
+ $translated_post_data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $translated_excerpt, 'excerpt' ) : '';
296
+ $translated_post_data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
297
+ $translated_post_data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $ids, 'id' ) : '';
298
+
299
+ $this->scraped_data[] = $translated_post_data;
300
+
301
+ }
302
+
303
+ }
304
+
305
+ }
306
+
307
+ }
308
+
309
+ }
310
+
311
+ }
312
+
313
+ }
314
+
315
+ $this->scraped_data[] = $data;
316
+
317
+ return $this->scraped_data;
318
+
319
+ }
320
+
321
+ /*
322
+ * Get current language
323
+ *
324
+ * @return string
325
+ */
326
+ private function get_lang() {
327
+
328
+ $lang = '';
329
+
330
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter( 'wpml_post_language_details' ) ) {
331
+ $lang = apply_filters( 'wpml_post_language_details', NULL, $this->id );
332
+ $lang = $lang['language_code'];
333
+ } elseif ( function_exists( 'pll_default_language' ) && function_exists( 'pll_get_post_language' ) ) {
334
+ $lang = pll_get_post_language( $this->id ) ? pll_get_post_language( $this->id ) : pll_default_language();
335
+ } elseif ( function_exists( 'qtranxf_getLanguageDefault' ) ) {
336
+ $lang = qtranxf_getLanguageDefault();
337
+ }
338
+
339
+ return $lang;
340
+
341
+ }
342
+
343
+ /*
344
+ * Extract terms from content
345
+ */
346
+ private function extract_terms( $str, $source = '' ) {
347
+
348
+ // Avoid single A-Z.
349
+ //$str = preg_replace( '/\b\w{1}\b/i', " ", $str );
350
+ //if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z]$/i', $term ) ) )
351
+
352
+ $str = AWS_Helpers::normalize_string( $str );
353
+
354
+ $str = str_replace( array(
355
+ "ˇ",
356
+ "°",
357
+ "Ë›",
358
+ "Ă‹ĹĄ",
359
+ "¸",
360
+ "§",
361
+ "=",
362
+ "¨",
363
+ "’",
364
+ "‘",
365
+ "”",
366
+ "“",
367
+ "„",
368
+ "´",
369
+ "—",
370
+ "–",
371
+ "Ă—",
372
+ '&#8217;',
373
+ "&nbsp;",
374
+ chr( 194 ) . chr( 160 )
375
+ ), " ", $str );
376
+
377
+ $str = str_replace( 'Ăź', 'ss', $str );
378
+
379
+ $str = preg_replace( '/^[a-z]$/i', "", $str );
380
+
381
+ $str = preg_replace( '/\s+/', ' ', $str );
382
+
383
+ /**
384
+ * Filters extracted string
385
+ *
386
+ * @since 1.44
387
+ *
388
+ * @param string $str String of product content
389
+ * @param @since 1.97 string $source Terms source
390
+ */
391
+ $str = apply_filters( 'aws_extracted_string', $str, $source );
392
+
393
+ $str_array = explode( ' ', $str );
394
+ $str_array = AWS_Helpers::filter_stopwords( $str_array );
395
+ $str_array = array_count_values( $str_array );
396
+
397
+ /**
398
+ * Filters extracted terms before adding to index table
399
+ *
400
+ * @since 1.44
401
+ *
402
+ * @param string $str_array Array of terms
403
+ * @param @since 1.97 string $source Terms source
404
+ */
405
+ $str_array = apply_filters( 'aws_extracted_terms', $str_array, $source );
406
+
407
+ $str_new_array = array();
408
+
409
+ // Remove e, es, ies from the end of the string
410
+ if ( ! empty( $str_array ) && $str_array ) {
411
+ foreach( $str_array as $str_item_term => $str_item_num ) {
412
+ if ( $str_item_term ) {
413
+ $new_array_key = AWS_Plurals::singularize( $str_item_term );
414
+
415
+ if ( $new_array_key && strlen( $str_item_term ) > 3 && strlen( $new_array_key ) > 2 ) {
416
+ if ( ! isset( $str_new_array[$new_array_key] ) ) {
417
+ $str_new_array[$new_array_key] = $str_item_num;
418
+ }
419
+ } else {
420
+ if ( ! isset( $str_new_array[$str_item_term] ) ) {
421
+ $str_new_array[$str_item_term] = $str_item_num;
422
+ }
423
+ }
424
+
425
+ }
426
+ }
427
+ }
428
+
429
+ $str_new_array = AWS_Helpers::get_synonyms( $str_new_array );
430
+
431
+ return $str_new_array;
432
+
433
+ }
434
+
435
+ /*
436
+ * Get product stock status
437
+ *
438
+ * @return string
439
+ */
440
+ private function get_stock_status() {
441
+
442
+ $stock_status = 1;
443
+
444
+ if ( method_exists( $this->product, 'get_stock_status' ) ) {
445
+ $stock_status = $this->product->get_stock_status() === 'outofstock' ? 0 : 1;
446
+ } elseif ( method_exists( $this->product, 'is_in_stock' ) ) {
447
+ $stock_status = $this->product->is_in_stock();
448
+ }
449
+
450
+ return $stock_status;
451
+
452
+ }
453
+
454
+ /*
455
+ * Get product visibility
456
+ *
457
+ * @return string
458
+ */
459
+ private function get_visibility() {
460
+
461
+ $visibility = 'visible';
462
+
463
+ if ( method_exists( $this->product, 'get_catalog_visibility' ) ) {
464
+ $visibility = $this->product->get_catalog_visibility();
465
+ } elseif ( method_exists( $this->product, 'get_visibility' ) ) {
466
+ $visibility = $this->product->get_visibility();
467
+ } else {
468
+ $visibility = $this->product->visibility;
469
+ }
470
+
471
+ return $visibility;
472
+
473
+ }
474
+
475
+ }
476
+
477
+ endif;
includes/class-aws-table.php CHANGED
@@ -294,6 +294,12 @@ if ( ! class_exists( 'AWS_Table' ) ) :
294
  global $wpdb;
295
 
296
  $charset_collate = $wpdb->get_charset_collate();
 
 
 
 
 
 
297
 
298
  $sql = "CREATE TABLE {$this->table_name} (
299
  id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
@@ -307,6 +313,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
307
  visibility VARCHAR(20) NOT NULL DEFAULT 0,
308
  lang VARCHAR(20) NOT NULL DEFAULT 0,
309
  KEY id (id),
 
310
  KEY term_id (term_id)
311
  ) $charset_collate;";
312
 
@@ -329,17 +336,10 @@ if ( ! class_exists( 'AWS_Table' ) ) :
329
  */
330
  $posts = apply_filters( 'aws_index_product_ids', $posts );
331
 
332
- /**
333
- * Apply or not WP filters to indexed contetn
334
- * @since 1.82
335
- * @param bool false
336
- */
337
- $apply_filters = apply_filters( 'aws_index_apply_filters', false );
338
 
339
  foreach ( $posts as $post_item ) {
340
 
341
- $data = array();
342
-
343
  if ( ! is_object( $post_item ) ) {
344
  $product = wc_get_product( $post_item );
345
  } else {
@@ -350,281 +350,21 @@ if ( ! class_exists( 'AWS_Table' ) ) :
350
  continue;
351
  }
352
 
353
- $data['terms'] = array();
354
- $data['id'] = method_exists( $product, 'get_id' ) ? $product->get_id() : $post_item;
355
-
356
-
357
- $lang = '';
358
-
359
- if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter( 'wpml_post_language_details' ) ) {
360
- $lang = apply_filters( 'wpml_post_language_details', NULL, $data['id'] );
361
- $lang = $lang['language_code'];
362
- } elseif ( function_exists( 'pll_default_language' ) && function_exists( 'pll_get_post_language' ) ) {
363
- $lang = pll_get_post_language( $data['id'] ) ? pll_get_post_language( $data['id'] ) : pll_default_language();
364
- } elseif ( function_exists( 'qtranxf_getLanguageDefault' ) ) {
365
- $lang = qtranxf_getLanguageDefault();
366
- }
367
-
368
-
369
- $data['in_stock'] = $this->get_stock_status( $product );
370
- $data['on_sale'] = $product->is_on_sale();
371
- $data['visibility'] = $this->get_visibility( $product );
372
- $data['lang'] = $lang ? $lang : '';
373
-
374
- $sku = $product->get_sku();
375
-
376
- $ids = $data['id'];
377
-
378
- $title = get_the_title( $data['id'] );
379
-
380
- $content = get_post_field( 'post_content', $data['id'] );
381
-
382
- $excerpt = get_post_field( 'post_excerpt', $data['id'] );
383
- $cat_array = AWS_Helpers::get_terms_array( $data['id'], 'product_cat' );
384
- $tag_array = AWS_Helpers::get_terms_array( $data['id'], 'product_tag' );
385
-
386
- if ( $apply_filters ) {
387
- $content = apply_filters( 'the_content', $content, $data['id'] );
388
- } else {
389
- $content = do_shortcode( $content );
390
- }
391
-
392
- // Get all child products if exists
393
- if ( $product->is_type( 'variable' ) && class_exists( 'WC_Product_Variation' ) ) {
394
-
395
- if ( sizeof( $product->get_children() ) > 0 ) {
396
-
397
- foreach ( $product->get_children() as $child_id ) {
398
-
399
- $variation_product = new WC_Product_Variation( $child_id );
400
-
401
- if ( method_exists( $variation_product, 'get_status' ) && $variation_product->get_status() === 'private' ) {
402
- continue;
403
- }
404
-
405
- $variation_sku = $variation_product->get_sku();
406
-
407
- $variation_desc = '';
408
- if ( method_exists( $variation_product, 'get_description' ) ) {
409
- $variation_desc = $variation_product->get_description();
410
- }
411
-
412
- if ( $variation_sku ) {
413
- $sku = $sku . ' ' . $variation_sku;
414
- }
415
-
416
- $ids = $ids . ' ' . $child_id;
417
-
418
- if ( $variation_desc ) {
419
- $content = $content . ' ' . $variation_desc;
420
- }
421
-
422
- }
423
-
424
- }
425
-
426
- }
427
-
428
-
429
- // Get content from Custom Product Tabs
430
- if ( $custom_tabs = get_post_meta( $data['id'], 'yikes_woo_products_tabs' ) ) {
431
- if ( $custom_tabs && ! empty( $custom_tabs ) ) {
432
- foreach( $custom_tabs as $custom_tab_array ) {
433
- if ( $custom_tab_array && ! empty( $custom_tab_array ) ) {
434
- foreach( $custom_tab_array as $custom_tab ) {
435
- if ( isset( $custom_tab['content'] ) && $custom_tab['content'] ) {
436
- $content = $content . ' ' . $custom_tab['content'];
437
- }
438
- }
439
- }
440
- }
441
- }
442
- }
443
-
444
-
445
- // WP 4.2 emoji strip
446
- if ( function_exists( 'wp_encode_emoji' ) ) {
447
- $content = wp_encode_emoji( $content );
448
- }
449
-
450
- $content = AWS_Helpers::strip_shortcodes( $content );
451
- $excerpt = AWS_Helpers::strip_shortcodes( $excerpt );
452
-
453
- /**
454
- * Filters product title before it will be indexed.
455
- *
456
- * @since 1.37
457
- *
458
- * @param string $title Product title.
459
- * @param int $data['id'] Product id.
460
- * @param object $product Current product object.
461
- */
462
- $title = apply_filters( 'aws_indexed_title', $title, $data['id'], $product );
463
-
464
- /**
465
- * Filters product content before it will be indexed.
466
- *
467
- * @since 1.37
468
- *
469
- * @param string $content Product content.
470
- * @param int $data['id'] Product id.
471
- * @param object $product Current product object.
472
- */
473
- $content = apply_filters( 'aws_indexed_content', $content, $data['id'], $product );
474
-
475
- /**
476
- * Filters product excerpt before it will be indexed.
477
- *
478
- * @since 1.37
479
- *
480
- * @param string $excerpt Product excerpt.
481
- * @param int $data['id'] Product id.
482
- * @param object $product Current product object.
483
- */
484
- $excerpt = apply_filters( 'aws_indexed_excerpt', $excerpt, $data['id'], $product );
485
-
486
-
487
- $data['terms']['title'] = $this->extract_terms( $title, 'title' );
488
- $data['terms']['content'] = $this->extract_terms( $content, 'content' );
489
- $data['terms']['excerpt'] = $this->extract_terms( $excerpt, 'excerpt' );
490
- $data['terms']['sku'] = $this->extract_terms( $sku, 'sku' );
491
- $data['terms']['id'] = $this->extract_terms( $ids, 'id' );
492
-
493
-
494
- if ( $cat_array && ! empty( $cat_array ) ) {
495
- foreach( $cat_array as $cat_source => $cat_terms ) {
496
- $data['terms'][$cat_source] = $this->extract_terms( $cat_terms, 'cat' );
497
- }
498
- }
499
-
500
- if ( $tag_array && ! empty( $tag_array ) ) {
501
- foreach( $tag_array as $tag_source => $tag_terms ) {
502
- $data['terms'][$tag_source] = $this->extract_terms( $tag_terms, 'tag' );
503
- }
504
- }
505
-
506
-
507
- // Get translations if exists ( WPML )
508
- if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter('wpml_element_has_translations') && has_filter('wpml_get_element_translations') ) {
509
-
510
- $is_translated = apply_filters( 'wpml_element_has_translations', NULL, $data['id'], 'post_product' );
511
-
512
- if ( $is_translated ) {
513
-
514
- $translations = apply_filters( 'wpml_get_element_translations', NULL, $data['id'], 'post_product');
515
-
516
- foreach( $translations as $language => $lang_obj ) {
517
- if ( ! $lang_obj->original && $lang_obj->post_status === 'publish' ) {
518
- $translated_post = get_post( $lang_obj->element_id );
519
- if ( $translated_post && !empty( $translated_post ) ) {
520
-
521
- $translated_post_data = array();
522
- $translated_post_data['id'] = $translated_post->ID;
523
- $translated_post_data['in_stock'] = $data['in_stock'];
524
- $translated_post_data['on_sale'] = $data['on_sale'];
525
- $translated_post_data['visibility'] = $data['visibility'];
526
- $translated_post_data['lang'] = $lang_obj->language_code;
527
- $translated_post_data['terms'] = array();
528
-
529
- $translated_title = get_the_title( $translated_post->ID );
530
- $translated_content = get_post_field( 'post_content', $translated_post->ID );
531
- $translated_excerpt = get_post_field( 'post_excerpt', $translated_post->ID );
532
-
533
- if ( $apply_filters ) {
534
- $translated_content = apply_filters( 'the_content', $translated_content, $translated_post->ID );
535
- }
536
-
537
- $translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
538
- $translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
539
-
540
- $translated_post_data['terms']['title'] = $this->extract_terms( $translated_title, 'title' );
541
- $translated_post_data['terms']['content'] = $this->extract_terms( $translated_content, 'content' );
542
- $translated_post_data['terms']['excerpt'] = $this->extract_terms( $translated_excerpt, 'excerpt' );
543
- $translated_post_data['terms']['sku'] = $this->extract_terms( $sku, 'sku' );
544
- $translated_post_data['terms']['id'] = $this->extract_terms( $translated_post->ID, 'id' );
545
-
546
-
547
- //Insert translated product data into table
548
- $this->insert_into_table( $translated_post_data );
549
-
550
- }
551
- }
552
- }
553
-
554
- }
555
-
556
- }
557
- elseif ( function_exists( 'qtranxf_use' ) ) {
558
-
559
- $enabled_languages = get_option( 'qtranslate_enabled_languages' );
560
-
561
- if ( $enabled_languages ) {
562
-
563
- foreach( $enabled_languages as $current_lang ) {
564
-
565
- if ( $current_lang == $lang ) {
566
- $default_lang_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
567
- $data['terms']['title'] = $this->extract_terms( $default_lang_title, 'title' );
568
- continue;
569
- }
570
-
571
- if ( function_exists( 'qtranxf_getAvailableLanguages' ) ) {
572
-
573
- global $wpdb;
574
-
575
- $qtrans_content = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $data['id'] ) );
576
-
577
- if ( $qtrans_content ) {
578
 
579
- $languages_title = qtranxf_getAvailableLanguages( $qtrans_content->post_title );
580
- $languages_content = qtranxf_getAvailableLanguages( $qtrans_content->post_content );
581
 
582
- if ( ( $languages_title && in_array( $current_lang, $languages_title ) ) || ( $languages_content && in_array( $current_lang, $languages_content ) ) ) {
583
 
584
- if ( method_exists( $product, 'get_description' ) && method_exists( $product, 'get_name' ) && method_exists( $product, 'get_short_description' ) ) {
 
585
 
586
- $translated_post_data = array();
587
- $translated_post_data['id'] = $data['id'];
588
- $translated_post_data['in_stock'] = $data['in_stock'];
589
- $translated_post_data['on_sale'] = $data['on_sale'];
590
- $translated_post_data['visibility'] = $data['visibility'];
591
- $translated_post_data['lang'] = $current_lang;
592
- $translated_post_data['terms'] = array();
593
-
594
- $translated_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
595
- $translated_content = qtranxf_use( $current_lang, $product->get_description(), true, true );
596
- $translated_excerpt = qtranxf_use( $current_lang, $product->get_short_description(), true, true );
597
-
598
- $translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
599
- $translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
600
-
601
- $translated_post_data['terms']['title'] = $this->extract_terms( $translated_title, 'title' );
602
- $translated_post_data['terms']['content'] = $this->extract_terms( $translated_content, 'content' );
603
- $translated_post_data['terms']['excerpt'] = $this->extract_terms( $translated_excerpt, 'excerpt' );
604
- $translated_post_data['terms']['sku'] = $this->extract_terms( $sku, 'sku' );
605
- $translated_post_data['terms']['id'] = $this->extract_terms( $ids, 'id' );
606
-
607
-
608
- //Insert translated product data into table
609
- $this->insert_into_table( $translated_post_data );
610
-
611
- }
612
-
613
- }
614
-
615
- }
616
-
617
- }
618
-
619
- }
620
 
621
  }
622
-
623
  }
624
 
625
- //Insert data into table
626
- $this->insert_into_table( $data );
627
-
628
  }
629
 
630
  }
@@ -662,19 +402,21 @@ if ( ! class_exists( 'AWS_Table' ) ) :
662
  }
663
  }
664
 
665
- foreach ( $all_terms as $term => $count ) {
 
666
 
667
- if ( ! $term ) {
668
- continue;
669
- }
670
 
671
- $value = $wpdb->prepare(
672
- "(%d, %s, %s, %s, %d, %d, %d, %d, %s, %s)",
673
- $data['id'], $term, $source, 'product', $count, $data['in_stock'], $data['on_sale'], $term_id, $data['visibility'], $data['lang']
674
- );
675
 
676
- $values[] = $value;
677
 
 
678
  }
679
 
680
  }
@@ -846,138 +588,6 @@ if ( ! class_exists( 'AWS_Table' ) ) :
846
 
847
  }
848
 
849
- /*
850
- * Extract terms from content
851
- */
852
- private function extract_terms( $str, $source = '' ) {
853
-
854
- // Avoid single A-Z.
855
- //$str = preg_replace( '/\b\w{1}\b/i', " ", $str );
856
- //if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z]$/i', $term ) ) )
857
-
858
- $str = AWS_Helpers::normalize_string( $str );
859
-
860
- $str = str_replace( array(
861
- "ˇ",
862
- "°",
863
- "Ë›",
864
- "Ă‹ĹĄ",
865
- "¸",
866
- "§",
867
- "=",
868
- "¨",
869
- "’",
870
- "‘",
871
- "”",
872
- "“",
873
- "„",
874
- "´",
875
- "—",
876
- "–",
877
- "Ă—",
878
- '&#8217;',
879
- "&nbsp;",
880
- chr( 194 ) . chr( 160 )
881
- ), " ", $str );
882
-
883
- $str = str_replace( 'Ăź', 'ss', $str );
884
-
885
- $str = preg_replace( '/^[a-z]$/i', "", $str );
886
-
887
- $str = preg_replace( '/\s+/', ' ', $str );
888
-
889
- /**
890
- * Filters extracted string
891
- *
892
- * @since 1.44
893
- *
894
- * @param string $str String of product content
895
- * @param @since 1.97 string $source Terms source
896
- */
897
- $str = apply_filters( 'aws_extracted_string', $str, $source );
898
-
899
- $str_array = explode( ' ', $str );
900
- $str_array = AWS_Helpers::filter_stopwords( $str_array );
901
- $str_array = array_count_values( $str_array );
902
-
903
- /**
904
- * Filters extracted terms before adding to index table
905
- *
906
- * @since 1.44
907
- *
908
- * @param string $str_array Array of terms
909
- * @param @since 1.97 string $source Terms source
910
- */
911
- $str_array = apply_filters( 'aws_extracted_terms', $str_array, $source );
912
-
913
- $str_new_array = array();
914
-
915
- // Remove e, es, ies from the end of the string
916
- if ( ! empty( $str_array ) && $str_array ) {
917
- foreach( $str_array as $str_item_term => $str_item_num ) {
918
- if ( $str_item_term ) {
919
- $new_array_key = AWS_Plurals::singularize( $str_item_term );
920
-
921
- if ( $new_array_key && strlen( $str_item_term ) > 3 && strlen( $new_array_key ) > 2 ) {
922
- if ( ! isset( $str_new_array[$new_array_key] ) ) {
923
- $str_new_array[$new_array_key] = $str_item_num;
924
- }
925
- } else {
926
- if ( ! isset( $str_new_array[$str_item_term] ) ) {
927
- $str_new_array[$str_item_term] = $str_item_num;
928
- }
929
- }
930
-
931
- }
932
- }
933
- }
934
-
935
- $str_new_array = AWS_Helpers::get_synonyms( $str_new_array );
936
-
937
- return $str_new_array;
938
-
939
- }
940
-
941
- /*
942
- * Get product stock status
943
- *
944
- * @return bool
945
- */
946
- private function get_stock_status( $product ) {
947
-
948
- $stock_status = 1;
949
-
950
- if ( method_exists( $product, 'get_stock_status' ) ) {
951
- $stock_status = $product->get_stock_status() === 'outofstock' ? 0 : 1;
952
- } elseif ( method_exists( $product, 'is_in_stock' ) ) {
953
- $stock_status = $product->is_in_stock();
954
- }
955
-
956
- return $stock_status;
957
-
958
- }
959
-
960
- /*
961
- * Get product visibility
962
- *
963
- * @return bool
964
- */
965
- private function get_visibility( $product ) {
966
-
967
- $visibility = 'visible';
968
-
969
- if ( method_exists( $product, 'get_catalog_visibility' ) ) {
970
- $visibility = $product->get_catalog_visibility();
971
- } elseif ( method_exists( $product, 'get_visibility' ) ) {
972
- $visibility = $product->get_visibility();
973
- } else {
974
- $visibility = $product->visibility;
975
- }
976
-
977
- return $visibility;
978
-
979
- }
980
-
981
  }
982
 
983
  endif;
294
  global $wpdb;
295
 
296
  $charset_collate = $wpdb->get_charset_collate();
297
+ $terms_key = '';
298
+
299
+ $search_rule = AWS()->get_settings( 'search_rule' );
300
+ if ( $search_rule === 'begins' ) {
301
+ $terms_key = 'KEY term (term),';
302
+ }
303
 
304
  $sql = "CREATE TABLE {$this->table_name} (
305
  id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
313
  visibility VARCHAR(20) NOT NULL DEFAULT 0,
314
  lang VARCHAR(20) NOT NULL DEFAULT 0,
315
  KEY id (id),
316
+ {$terms_key}
317
  KEY term_id (term_id)
318
  ) $charset_collate;";
319
 
336
  */
337
  $posts = apply_filters( 'aws_index_product_ids', $posts );
338
 
339
+ $options = AWS_Admin_Options::get_index_options();
 
 
 
 
 
340
 
341
  foreach ( $posts as $post_item ) {
342
 
 
 
343
  if ( ! is_object( $post_item ) ) {
344
  $product = wc_get_product( $post_item );
345
  } else {
350
  continue;
351
  }
352
 
353
+ $id = method_exists( $product, 'get_id' ) ? $product->get_id() : $post_item;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
354
 
355
+ $table_data = new AWS_Table_Data( $product, $id, $options );
 
356
 
357
+ $scraped_data = $table_data->scrap_data();
358
 
359
+ if ( ! empty( $scraped_data ) ) {
360
+ foreach ( $scraped_data as $product_data ) {
361
 
362
+ //Insert data into table
363
+ $this->insert_into_table( $product_data );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
364
 
365
  }
 
366
  }
367
 
 
 
 
368
  }
369
 
370
  }
402
  }
403
  }
404
 
405
+ if ( is_array( $all_terms ) && ! empty( $all_terms ) ) {
406
+ foreach ( $all_terms as $term => $count ) {
407
 
408
+ if ( ! $term ) {
409
+ continue;
410
+ }
411
 
412
+ $value = $wpdb->prepare(
413
+ "(%d, %s, %s, %s, %d, %d, %d, %d, %s, %s)",
414
+ $data['id'], $term, $source, 'product', $count, $data['in_stock'], $data['on_sale'], $term_id, $data['visibility'], $data['lang']
415
+ );
416
 
417
+ $values[] = $value;
418
 
419
+ }
420
  }
421
 
422
  }
588
 
589
  }
590
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591
  }
592
 
593
  endif;
includes/class-aws-versions.php CHANGED
@@ -344,6 +344,46 @@ if ( ! class_exists( 'AWS_Versions' ) ) :
344
 
345
  }
346
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
  }
348
 
349
  update_option( 'aws_plugin_ver', AWS_VERSION );
344
 
345
  }
346
 
347
+ if ( version_compare( $current_version, '2.23', '<' ) ) {
348
+
349
+ $settings = get_option( 'aws_settings' );
350
+
351
+ if ( $settings ) {
352
+
353
+ if ( ! isset( $settings['search_rule'] ) ) {
354
+ $settings['search_rule'] = 'contains';
355
+ update_option( 'aws_settings', $settings );
356
+ }
357
+
358
+ if ( ! isset( $settings['search_timeout'] ) ) {
359
+ $settings['search_timeout'] = '300';
360
+ update_option( 'aws_settings', $settings );
361
+ }
362
+
363
+ if ( ! isset( $settings['index_sources'] ) ) {
364
+ $index_sources = array();
365
+ $options_array = AWS_Admin_Options::include_options();
366
+ foreach( $options_array['performance'] as $def_option ) {
367
+ if ( isset( $def_option['id'] ) && $def_option['id'] === 'index_sources' && isset( $def_option['choices'] ) ) {
368
+ foreach( $def_option['choices'] as $choice_key => $choice_label ) {
369
+ $index_sources[$choice_key] = 1;
370
+ }
371
+ $settings['index_sources'] = $index_sources;
372
+ break;
373
+ }
374
+ }
375
+ update_option( 'aws_settings', $settings );
376
+ }
377
+
378
+ if ( ! isset( $settings['index_variations'] ) ) {
379
+ $settings['index_variations'] = 'true';
380
+ update_option( 'aws_settings', $settings );
381
+ }
382
+
383
+ }
384
+
385
+ }
386
+
387
  }
388
 
389
  update_option( 'aws_plugin_ver', AWS_VERSION );
includes/modules/gutenberg/class-aws-gutenberg-init.php CHANGED
@@ -94,8 +94,6 @@ if (!class_exists('AWS_Gutenberg_Init')) :
94
 
95
  }
96
 
97
- $search_form = '<div style="margin: 20px 0;">' . $search_form . '</div>';
98
-
99
  return $search_form;
100
 
101
  }
94
 
95
  }
96
 
 
 
97
  return $search_form;
98
 
99
  }
languages/advanced-woo-search.pot CHANGED
@@ -38,7 +38,10 @@ msgid ""
38
  "Update all data in plugins index table. Index table - table with products "
39
  "data where plugin is searching all typed terms.<br>Use this button if you "
40
  "think that plugin not shows last actual data in its search results.<br>"
41
- "<strong>CAUTION:</strong> this can take large amount of time.</span>"
 
 
 
42
  msgstr ""
43
 
44
  #: includes/class-aws-admin.php:362
@@ -690,4 +693,76 @@ msgid "To configure your Advanced Woo Search form please visit %s."
690
  msgstr ""
691
 
692
  msgid "plugin settings page"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
693
  msgstr ""
38
  "Update all data in plugins index table. Index table - table with products "
39
  "data where plugin is searching all typed terms.<br>Use this button if you "
40
  "think that plugin not shows last actual data in its search results.<br>"
41
+ "<strong>CAUTION:</strong> this can take large amount of time."
42
+ msgstr ""
43
+
44
+ msgid "Index table options can be found inside %s section."
45
  msgstr ""
46
 
47
  #: includes/class-aws-admin.php:362
693
  msgstr ""
694
 
695
  msgid "plugin settings page"
696
+ msgstr ""
697
+
698
+ msgid "Performance"
699
+ msgstr ""
700
+
701
+ msgid "(index disabled)"
702
+ msgstr ""
703
+
704
+ msgid "(enable)"
705
+ msgstr ""
706
+
707
+ msgid "Source index disabled"
708
+ msgstr ""
709
+
710
+ msgid "Advanced Woo Search: In order to apply the changes in the index table you need to reindex. %s"
711
+ msgstr ""
712
+
713
+ msgid "Search options"
714
+ msgstr ""
715
+
716
+ msgid "Search rule"
717
+ msgstr ""
718
+
719
+ msgid "Search rule that will be used for terms search."
720
+ msgstr ""
721
+
722
+ msgid "( contains ). Search query can be inside any part of the product words ( beginning, end, middle ). Slow."
723
+ msgstr ""
724
+
725
+ msgid "( begins ). Search query can be only at the beginning of the product words. Fast."
726
+ msgstr ""
727
+
728
+ msgid "AJAX timeout"
729
+ msgstr ""
730
+
731
+ msgid "Time after user input that script is waiting before sending a search event to the server, ms."
732
+ msgstr ""
733
+
734
+ msgid "Index table options"
735
+ msgstr ""
736
+
737
+ msgid "Overview"
738
+ msgstr ""
739
+
740
+ msgid "To perform the search plugin use a special index table. This table contains normalized words of all your products from all available sources."
741
+ msgstr ""
742
+
743
+ msgid "Sometimes when there are too many products in your store index table can be very large and that can reflect on search speed."
744
+ msgstr ""
745
+
746
+ msgid "In this section you can use several options to change the table size by disabling some unused product data."
747
+ msgstr ""
748
+
749
+ msgid "Note:"
750
+ msgstr ""
751
+
752
+ msgid "Reindex is required after options changes."
753
+ msgstr ""
754
+
755
+ msgid "Data to index"
756
+ msgstr ""
757
+
758
+ msgid "Choose what products data to add inside the plugin index table."
759
+ msgstr ""
760
+
761
+ msgid "What to index"
762
+ msgstr ""
763
+
764
+ msgid "Index variations"
765
+ msgstr ""
766
+
767
+ msgid "Index or not content of product variations."
768
  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.7
7
- Stable tag: 2.22
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -166,6 +166,21 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
166
 
167
  == Changelog ==
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  = 2.22 ( 2021-02-19 ) =
170
  * Add - Support for WOOF - WooCommerce Products Filter plugin
171
  * Fix - Search form widget layout
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.7
7
+ Stable tag: 2.23
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
166
 
167
  == Changelog ==
168
 
169
+ = 2.23 ( 2021-03-22 ) =
170
+ * Add - Performance options
171
+ * Add - Support for TI WooCommerce Wishlist plugin
172
+ * Add - Support for Fury theme
173
+ * Add - Support for Salient theme
174
+ * Add - Support for Bazar theme
175
+ * Add - Support for Claue theme
176
+ * Add - Integration for Urna theme
177
+ * Update - BeRocket AJAX filters plugin support. Fix issue when used slugs for terms instead of IDs inside URL
178
+ * Update - BeRocket AJAX filter support. Include parent terms filters
179
+ * Update - Gutenberg block markup
180
+ * Update - Admin page styles
181
+ * Fix - If no search sources is set - do not show the products search results
182
+ * Dev - Add aws_admin_page_options_current filter
183
+
184
  = 2.22 ( 2021-02-19 ) =
185
  * Add - Support for WOOF - WooCommerce Products Filter plugin
186
  * Fix - Search form widget layout