Advanced Woo Search - Version 1.13

Version Description

  • Add support for variable products
  • Fix bugs
Download this release

Release Info

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

Code changes from version 1.12 to 1.13

advanced-woo-search.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
- Version: 1.12
7
  Author: ILLID
8
  Text Domain: aws
9
  */
@@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
- define( 'AWS_VERSION', '1.12' );
17
 
18
 
19
  define( 'AWS_DIR', dirname( __FILE__ ) );
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
+ Version: 1.13
7
  Author: ILLID
8
  Text Domain: aws
9
  */
13
  exit;
14
  }
15
 
16
+ define( 'AWS_VERSION', '1.13' );
17
 
18
 
19
  define( 'AWS_DIR', dirname( __FILE__ ) );
assets/css/admin.css CHANGED
@@ -6,9 +6,11 @@
6
  }
7
 
8
  .sortable-title {
9
- padding: 10px 0;
10
  margin-right: 10px;
11
- font-size: 13px;
 
 
12
  }
13
 
14
  .sti-sortable {
@@ -38,6 +40,7 @@
38
  border: 1px solid #C7C4C4;
39
  text-align: center;
40
  padding: 8px 0;
 
41
  }
42
 
43
  .sti-sortable li.highlight {
6
  }
7
 
8
  .sortable-title {
9
+ padding: 8px 0;
10
  margin-right: 10px;
11
+ font-size: 12px;
12
+ font-weight: 700;
13
+ line-height: 17px;
14
  }
15
 
16
  .sti-sortable {
40
  border: 1px solid #C7C4C4;
41
  text-align: center;
42
  padding: 8px 0;
43
+ text-transform: capitalize;
44
  }
45
 
46
  .sti-sortable li.highlight {
assets/js/common.js CHANGED
@@ -87,7 +87,7 @@
87
  var html = '<ul>';
88
 
89
 
90
- if ( response.cats.length > 0 ) {
91
 
92
  $.each(response.cats, function (i, result) {
93
 
@@ -105,7 +105,7 @@
105
 
106
  }
107
 
108
- if ( response.tags.length > 0 ) {
109
 
110
  $.each(response.tags, function (i, result) {
111
 
@@ -123,7 +123,7 @@
123
 
124
  }
125
 
126
- if ( response.products.length > 0 ) {
127
 
128
  $.each(response.products, function (i, result) {
129
 
@@ -169,7 +169,7 @@
169
 
170
  }
171
 
172
- if ( response.cats.length <= 0 && response.tags.length <= 0 && response.products.length <= 0 ) {
173
  html += '<li class="aws_result_item aws_no_result">' + translate.noresults + '</li>';
174
  }
175
 
87
  var html = '<ul>';
88
 
89
 
90
+ if ( ( typeof response.cats !== 'undefined' ) && response.cats.length > 0 ) {
91
 
92
  $.each(response.cats, function (i, result) {
93
 
105
 
106
  }
107
 
108
+ if ( ( typeof response.tags !== 'undefined' ) && response.tags.length > 0 ) {
109
 
110
  $.each(response.tags, function (i, result) {
111
 
123
 
124
  }
125
 
126
+ if ( ( typeof response.products !== 'undefined' ) && response.products.length > 0 ) {
127
 
128
  $.each(response.products, function (i, result) {
129
 
169
 
170
  }
171
 
172
+ if ( ( typeof response.cats !== 'undefined' ) && response.cats.length <= 0 && ( typeof response.tags !== 'undefined' ) && response.tags.length <= 0 && ( typeof response.products !== 'undefined' ) && response.products.length <= 0 ) {
173
  html += '<li class="aws_result_item aws_no_result">' + translate.noresults + '</li>';
174
  }
175
 
includes/class-aws-admin.php CHANGED
@@ -292,12 +292,16 @@ class AWS_Admin {
292
 
293
  <div class="sortable-container">
294
 
295
- <div class="sortable-title"><?php _e( 'Available fields', 'aws' ) ?></div>
 
 
 
296
 
297
- <ul id="sti-sortable1" class="sti-sortable disabled connectedSortable">
298
  <?php
299
- if ( count( $inactive_buttons ) > 0 ) {
300
- foreach ($inactive_buttons as $button) {
 
301
  echo '<li id="' . $button . '" class="sti-btn sti-' . $button . '-btn">' . $button . '</li>';
302
  }
303
  }
@@ -308,13 +312,15 @@ class AWS_Admin {
308
 
309
  <div class="sortable-container">
310
 
311
- <div class="sortable-title"><?php _e( 'Drag&drop to enable', 'aws' ) ?></div>
 
 
 
312
 
313
- <ul id="sti-sortable2" class="sti-sortable enabled connectedSortable">
314
  <?php
315
- if ( count( $active_buttons ) > 0 ) {
316
- foreach ($active_buttons as $button) {
317
- if ( ! $button ) continue;
318
  echo '<li id="' . $button . '" class="sti-btn sti-' . $button . '-btn">' . $button . '</li>';
319
  }
320
  }
292
 
293
  <div class="sortable-container">
294
 
295
+ <div class="sortable-title">
296
+ <?php _e( 'Active sources', 'aws' ) ?><br>
297
+ <?php _e( 'Change order by drag&drop', 'aws' ) ?>
298
+ </div>
299
 
300
+ <ul id="sti-sortable2" class="sti-sortable enabled connectedSortable">
301
  <?php
302
+ if ( count( $active_buttons ) > 0 ) {
303
+ foreach ($active_buttons as $button) {
304
+ if ( ! $button ) continue;
305
  echo '<li id="' . $button . '" class="sti-btn sti-' . $button . '-btn">' . $button . '</li>';
306
  }
307
  }
312
 
313
  <div class="sortable-container">
314
 
315
+ <div class="sortable-title">
316
+ <?php _e( 'Deactivated sources', 'aws' ) ?><br>
317
+ <?php _e( 'Excluded from search results', 'aws' ) ?>
318
+ </div>
319
 
320
+ <ul id="sti-sortable1" class="sti-sortable disabled connectedSortable">
321
  <?php
322
+ if ( count( $inactive_buttons ) > 0 ) {
323
+ foreach ($inactive_buttons as $button) {
 
324
  echo '<li id="' . $button . '" class="sti-btn sti-' . $button . '-btn">' . $button . '</li>';
325
  }
326
  }
includes/class-aws-search-page.php CHANGED
@@ -99,7 +99,8 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
99
 
100
  $new_posts = array();
101
 
102
- $posts_array = aws_search( $query->query_vars['s'] );
 
103
 
104
  $query->found_posts = count( $posts_array['products'] );
105
  $query->max_num_pages = ceil( count( $posts_array['products'] ) / $query->get( 'posts_per_page' ) );
99
 
100
  $new_posts = array();
101
 
102
+ $search_query = str_replace( array( '.', '`', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '|', '+', '\\', '?', ';', ':', '"', ',', '<', '>', '{', '}', '/' ), '', $query->query_vars['s'] );
103
+ $posts_array = aws_search( $search_query );
104
 
105
  $query->found_posts = count( $posts_array['products'] );
106
  $query->max_num_pages = ceil( count( $posts_array['products'] ) / $query->get( 'posts_per_page' ) );
includes/class-aws-table.php CHANGED
@@ -34,6 +34,8 @@ if ( ! class_exists( 'AWS_Table' ) ) :
34
  add_action( 'delete_term', array( &$this, 'term_changed' ), 10, 3 );
35
  add_action( 'edit_term', array( &$this, 'term_changed' ), 10, 3 );
36
 
 
 
37
  add_action( 'wp_ajax_aws-reindex', array( $this, 'reindex_table' ) );
38
 
39
  add_action( 'wp_ajax_aws-cancel-index', array( $this, 'cancel_reindex' ) );
@@ -156,11 +158,11 @@ if ( ! class_exists( 'AWS_Table' ) ) :
156
  $charset_collate = $wpdb->get_charset_collate();
157
 
158
  $sql = "CREATE TABLE {$this->table_name} (
159
- id MEDIUMINT(20) NOT NULL DEFAULT 0,
160
  term VARCHAR(50) NOT NULL DEFAULT 0,
161
  term_source VARCHAR(20) NOT NULL DEFAULT 0,
162
  type VARCHAR(50) NOT NULL DEFAULT 0,
163
- count MEDIUMINT(20) NOT NULL DEFAULT 0
164
  ) $charset_collate;";
165
 
166
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@@ -192,7 +194,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
192
  // continue;
193
  // }
194
 
195
- $product = new WC_product( $id );
196
 
197
  $sku = $product->get_sku();
198
 
@@ -203,6 +205,33 @@ if ( ! class_exists( 'AWS_Table' ) ) :
203
  $tag_names = $this->get_terms_names_list( $id, 'product_tag' );
204
 
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  // WP 4.2 emoji strip
207
  if ( function_exists( 'wp_encode_emoji' ) ) {
208
  $content = wp_encode_emoji( $content );
@@ -301,6 +330,33 @@ if ( ! class_exists( 'AWS_Table' ) ) :
301
 
302
  }
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  /*
305
  * Cancel index
306
  */
34
  add_action( 'delete_term', array( &$this, 'term_changed' ), 10, 3 );
35
  add_action( 'edit_term', array( &$this, 'term_changed' ), 10, 3 );
36
 
37
+ add_action( 'woocommerce_variable_product_sync', array( &$this, 'variable_product_changed' ), 10, 2 );
38
+
39
  add_action( 'wp_ajax_aws-reindex', array( $this, 'reindex_table' ) );
40
 
41
  add_action( 'wp_ajax_aws-cancel-index', array( $this, 'cancel_reindex' ) );
158
  $charset_collate = $wpdb->get_charset_collate();
159
 
160
  $sql = "CREATE TABLE {$this->table_name} (
161
+ id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
162
  term VARCHAR(50) NOT NULL DEFAULT 0,
163
  term_source VARCHAR(20) NOT NULL DEFAULT 0,
164
  type VARCHAR(50) NOT NULL DEFAULT 0,
165
+ count BIGINT(20) UNSIGNED NOT NULL DEFAULT 0
166
  ) $charset_collate;";
167
 
168
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
194
  // continue;
195
  // }
196
 
197
+ $product = wc_get_product( $id );
198
 
199
  $sku = $product->get_sku();
200
 
205
  $tag_names = $this->get_terms_names_list( $id, 'product_tag' );
206
 
207
 
208
+ // Get all child products if exists
209
+ if ( $product->is_type( 'variable' ) ) {
210
+
211
+ if ( sizeof( $product->get_children() ) > 0 ) {
212
+
213
+ foreach ( $product->get_children() as $child_id ) {
214
+
215
+ $variation_product = new WC_Product_Variation( $child_id );
216
+
217
+ $variation_sku = $variation_product->get_sku();
218
+ $variation_desc = $variation_product->get_variation_description();
219
+
220
+ if ( $variation_sku ) {
221
+ $sku = $sku . ' ' . $variation_sku;
222
+ }
223
+
224
+ if ( $variation_desc ) {
225
+ $content = $content . ' ' . $variation_desc;
226
+ }
227
+
228
+ }
229
+
230
+ }
231
+
232
+ }
233
+
234
+
235
  // WP 4.2 emoji strip
236
  if ( function_exists( 'wp_encode_emoji' ) ) {
237
  $content = wp_encode_emoji( $content );
330
 
331
  }
332
 
333
+ /*
334
+ * Fires when products variations are changed
335
+ */
336
+ public function variable_product_changed( $product_id, $children ) {
337
+
338
+ global $wpdb;
339
+
340
+ if ( $this->is_table_not_exist() ) {
341
+ $this->create_table();
342
+ }
343
+
344
+ $wpdb->delete( $this->table_name, array( 'id' => $product_id ) );
345
+
346
+ $posts = get_posts( array(
347
+ 'posts_per_page' => -1,
348
+ 'fields' => 'ids',
349
+ 'post_type' => 'product',
350
+ 'no_found_rows' => 1,
351
+ 'include' => $product_id
352
+ ) );
353
+
354
+ $this->fill_table( $posts );
355
+
356
+ $this->clear_cache();
357
+
358
+ }
359
+
360
  /*
361
  * Cancel index
362
  */
includes/options.php CHANGED
@@ -19,7 +19,7 @@ $options['general'][] = array(
19
 
20
  $options['general'][] = array(
21
  "name" => __( "Search in", "aws" ),
22
- "desc" => __( "Source of searching. Set the source of searching by drag&drop needed fields to the right area.", "aws" ),
23
  "id" => "search_in",
24
  "value" => "title,content,sku,excerpt",
25
  "choices" => array( "title", "content", "sku", "excerpt", "category", "tag" ),
19
 
20
  $options['general'][] = array(
21
  "name" => __( "Search in", "aws" ),
22
+ "desc" => __( "Search source: Drag&drop sources order to change priority, or exclude by moving to deactivated sources.", "aws" ),
23
  "id" => "search_in",
24
  "value" => "title,content,sku,excerpt",
25
  "choices" => array( "title", "content", "sku", "excerpt", "category", "tag" ),
languages/aws.pot CHANGED
@@ -100,12 +100,20 @@ msgstr ""
100
  msgid "General"
101
  msgstr ""
102
 
103
- #: includes/class-aws-admin.php:295
104
- msgid "Available fields"
105
  msgstr ""
106
 
107
- #: includes/class-aws-admin.php:311
108
- msgid "Drag&drop to enable"
 
 
 
 
 
 
 
 
109
  msgstr ""
110
 
111
  #: includes/options.php:9
@@ -258,9 +266,7 @@ msgid "Search in"
258
  msgstr ""
259
 
260
  #: includes/options.php:176
261
- msgid ""
262
- "Source of searching. Set the source of searching by drag&drop needed fields "
263
- "to the right area."
264
  msgstr ""
265
 
266
  #. Name of the plugin
100
  msgid "General"
101
  msgstr ""
102
 
103
+ #: includes/class-aws-admin.php:296
104
+ msgid "Active sources"
105
  msgstr ""
106
 
107
+ #: includes/class-aws-admin.php:297
108
+ msgid "Change order by drag&drop"
109
+ msgstr ""
110
+
111
+ #: includes/class-aws-admin.php:316
112
+ msgid "Deactivated sources"
113
+ msgstr ""
114
+
115
+ #: includes/class-aws-admin.php:317
116
+ msgid "Excluded from search results"
117
  msgstr ""
118
 
119
  #: includes/options.php:9
266
  msgstr ""
267
 
268
  #: includes/options.php:176
269
+ msgid "Search source: Drag&drop sources order to change priority, or exclude by moving to deactivated sources."
 
 
270
  msgstr ""
271
 
272
  #. Name of the plugin
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: 4.7.2
7
- Stable tag: 1.12
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -25,6 +25,7 @@ Advanced Woo Search - powerful live search plugin for WooCommerce. Just start ty
25
  * **Terms search** - Search for product categories and tags
26
  * **Smart ordering** - Search results ordered by the priority of source where they were found
27
  * **Fast** - Nothing extra. Just what you need for proper work
 
28
 
29
  = Premium Features =
30
 
@@ -65,6 +66,10 @@ Or insert this function inside php file ( often it used to insert form inside pa
65
 
66
  == Changelog ==
67
 
 
 
 
 
68
  = 1.12 =
69
  * Fix small bugs in search results output
70
 
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: 4.7.2
7
+ Stable tag: 1.13
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
25
  * **Terms search** - Search for product categories and tags
26
  * **Smart ordering** - Search results ordered by the priority of source where they were found
27
  * **Fast** - Nothing extra. Just what you need for proper work
28
+ * Supports variable products
29
 
30
  = Premium Features =
31
 
66
 
67
  == Changelog ==
68
 
69
+ = 1.13 =
70
+ * Add support for variable products
71
+ * Fix bugs
72
+
73
  = 1.12 =
74
  * Fix small bugs in search results output
75