Advanced Woo Search - Version 1.16

Version Description

  • Option for 'Out of stock' products
  • Fix bugs
Download this release

Release Info

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

Code changes from version 1.15 to 1.16

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.15
7
  Author: ILLID
8
  Text Domain: aws
9
  */
@@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
- define( 'AWS_VERSION', '1.15' );
17
 
18
 
19
  define( 'AWS_DIR', dirname( __FILE__ ) );
@@ -74,8 +74,6 @@ final class AWS_Main {
74
 
75
  load_plugin_textdomain( 'aws', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
76
 
77
- update_option( 'aws_plugin_ver', AWS_VERSION );
78
-
79
  $this->includes();
80
 
81
  }
@@ -84,6 +82,7 @@ final class AWS_Main {
84
  * Include required core files used in admin and on the frontend.
85
  */
86
  public function includes() {
 
87
  include_once( 'includes/class-aws-helpers.php' );
88
  include_once( 'includes/class-aws-admin.php' );
89
  include_once( 'includes/class-aws-table.php' );
@@ -160,13 +159,14 @@ function AWS() {
160
  /*
161
  * Check if WooCommerce is active
162
  */
163
- if ( aws_is_plugin_active('woocommerce/woocommerce.php') ) {
164
- add_action( 'woocommerce_loaded', 'aws_init' );
165
- } else {
166
- add_action( 'admin_notices', 'aws_install_woocommerce_admin_notice' );
 
 
167
  }
168
 
169
-
170
  /*
171
  * Check whether the plugin is active by checking the active_plugins list.
172
  */
@@ -182,7 +182,7 @@ function aws_is_plugin_active_for_network( $plugin ) {
182
  if ( !is_multisite() )
183
  return false;
184
 
185
- $plugins = get_site_option( 'active_sitewide_plugins');
186
  if ( isset($plugins[$plugin]) )
187
  return true;
188
 
3
  /*
4
  Plugin Name: Advanced Woo Search
5
  Description: Advance ajax WooCommerce product search.
6
+ Version: 1.16
7
  Author: ILLID
8
  Text Domain: aws
9
  */
13
  exit;
14
  }
15
 
16
+ define( 'AWS_VERSION', '1.16' );
17
 
18
 
19
  define( 'AWS_DIR', dirname( __FILE__ ) );
74
 
75
  load_plugin_textdomain( 'aws', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
76
 
 
 
77
  $this->includes();
78
 
79
  }
82
  * Include required core files used in admin and on the frontend.
83
  */
84
  public function includes() {
85
+ include_once( 'includes/class-aws-versions.php' );
86
  include_once( 'includes/class-aws-helpers.php' );
87
  include_once( 'includes/class-aws-admin.php' );
88
  include_once( 'includes/class-aws-table.php' );
159
  /*
160
  * Check if WooCommerce is active
161
  */
162
+ if ( ! aws_is_plugin_active( 'advanced-woo-search-pro/advanced-woo-search-pro.php' ) ) {
163
+ if ( aws_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
164
+ add_action( 'woocommerce_loaded', 'aws_init' );
165
+ } else {
166
+ add_action( 'admin_notices', 'aws_install_woocommerce_admin_notice' );
167
+ }
168
  }
169
 
 
170
  /*
171
  * Check whether the plugin is active by checking the active_plugins list.
172
  */
182
  if ( !is_multisite() )
183
  return false;
184
 
185
+ $plugins = get_site_option( 'active_sitewide_plugins' );
186
  if ( isset($plugins[$plugin]) )
187
  return true;
188
 
assets/css/common.css CHANGED
@@ -47,6 +47,11 @@
47
  background-color: #fff;
48
  }
49
 
 
 
 
 
 
50
  .aws-search-result {
51
  position: absolute;
52
  z-index: 999;
47
  background-color: #fff;
48
  }
49
 
50
+ .aws-container .aws-search-field:focus::-webkit-input-placeholder { color:transparent; }
51
+ .aws-container .aws-search-field:focus:-moz-placeholder { color:transparent; }
52
+ .aws-container .aws-search-field:focus::-moz-placeholder { color:transparent; }
53
+ .aws-container .aws-search-field:focus:-ms-input-placeholder { color:transparent; }
54
+
55
  .aws-search-result {
56
  position: absolute;
57
  z-index: 999;
includes/class-aws-search-page.php CHANGED
@@ -1,9 +1,6 @@
1
  <?php
2
  /**
3
  * Integrate with WP_Query
4
- *
5
- * @since 1.0
6
- * @package elasticpress
7
  */
8
 
9
  if ( ! defined( 'ABSPATH' ) ) {
1
  <?php
2
  /**
3
  * Integrate with WP_Query
 
 
 
4
  */
5
 
6
  if ( ! defined( 'ABSPATH' ) ) {
includes/class-aws-search.php CHANGED
@@ -77,6 +77,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
77
  $show_tags = AWS()->get_settings( 'show_tags' );
78
  $results_num = $keyword ? 100 : AWS()->get_settings( 'results_num' );
79
  $search_in = AWS()->get_settings( 'search_in' );
 
80
 
81
  $search_in_arr = explode( ',', AWS()->get_settings( 'search_in' ) );
82
 
@@ -90,10 +91,11 @@ if ( ! class_exists( 'AWS_Search' ) ) :
90
 
91
 
92
  $this->data['s'] = $s;
93
- $this->data['results_num'] = $results_num ? $results_num : 10;
94
  $this->data['search_terms'] = array();
95
  $this->data['search_terms'] = array_unique( explode( ' ', $s ) );
96
- $this->data['search_in'] = $search_in_arr;
 
97
 
98
 
99
  $posts_ids = $this->query_index_table();
@@ -146,12 +148,18 @@ if ( ! class_exists( 'AWS_Search' ) ) :
146
 
147
  $search_in_arr = $this->data['search_in'];
148
  $results_num = $this->data['results_num'];
 
 
 
 
149
 
150
  $query = array();
151
 
152
  $query['search'] = '';
153
  $query['source'] = '';
154
  $query['relevance'] = '';
 
 
155
 
156
  $search_array = array();
157
  $source_array = array();
@@ -228,6 +236,17 @@ if ( ! class_exists( 'AWS_Search' ) ) :
228
  $query['source'] .= sprintf( ' AND ( %s )', implode( ' OR ', $source_array ) );
229
 
230
 
 
 
 
 
 
 
 
 
 
 
 
231
  $sql = "SELECT
232
  distinct ID,
233
  {$query['relevance']} as relevance
@@ -237,11 +256,13 @@ if ( ! class_exists( 'AWS_Search' ) ) :
237
  type = 'product'
238
  {$query['source']}
239
  {$query['search']}
 
 
240
  GROUP BY ID
241
  ORDER BY
242
  relevance DESC
243
  LIMIT 0, {$results_num}
244
- ";
245
 
246
  $posts_ids = $this->get_posts_ids( $sql );
247
 
77
  $show_tags = AWS()->get_settings( 'show_tags' );
78
  $results_num = $keyword ? 100 : AWS()->get_settings( 'results_num' );
79
  $search_in = AWS()->get_settings( 'search_in' );
80
+ $outofstock = AWS()->get_settings( 'outofstock' );
81
 
82
  $search_in_arr = explode( ',', AWS()->get_settings( 'search_in' ) );
83
 
91
 
92
 
93
  $this->data['s'] = $s;
94
+ $this->data['results_num'] = $results_num ? $results_num : 10;
95
  $this->data['search_terms'] = array();
96
  $this->data['search_terms'] = array_unique( explode( ' ', $s ) );
97
+ $this->data['search_in'] = $search_in_arr;
98
+ $this->data['outofstock'] = $outofstock;
99
 
100
 
101
  $posts_ids = $this->query_index_table();
148
 
149
  $search_in_arr = $this->data['search_in'];
150
  $results_num = $this->data['results_num'];
151
+ $outofstock = $this->data['outofstock'];
152
+
153
+
154
+ $reindex_version = get_option( 'aws_reindex_version' );
155
 
156
  $query = array();
157
 
158
  $query['search'] = '';
159
  $query['source'] = '';
160
  $query['relevance'] = '';
161
+ $query['stock'] = '';
162
+ $query['visibility'] = '';
163
 
164
  $search_array = array();
165
  $source_array = array();
236
  $query['source'] .= sprintf( ' AND ( %s )', implode( ' OR ', $source_array ) );
237
 
238
 
239
+ if ( $reindex_version && version_compare( $reindex_version, '1.16', '>=' ) ) {
240
+
241
+ if ( $outofstock !== 'true' ) {
242
+ $query['stock'] .= " AND in_stock = 1";
243
+ }
244
+
245
+ $query['visibility'] .= " AND NOT visibility LIKE '%hidden%'";
246
+
247
+ }
248
+
249
+
250
  $sql = "SELECT
251
  distinct ID,
252
  {$query['relevance']} as relevance
256
  type = 'product'
257
  {$query['source']}
258
  {$query['search']}
259
+ {$query['stock']}
260
+ {$query['visibility']}
261
  GROUP BY ID
262
  ORDER BY
263
  relevance DESC
264
  LIMIT 0, {$results_num}
265
+ ";
266
 
267
  $posts_ids = $this->get_posts_ids( $sql );
268
 
includes/class-aws-table.php CHANGED
@@ -25,7 +25,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
25
 
26
  $this->table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
27
 
28
- add_action( 'save_post', array( $this, 'update_table' ), 10, 3 );
29
 
30
  add_action( 'aws_settings_saved', array( $this, 'clear_cache' ) );
31
  add_action( 'aws_cache_clear', array( $this, 'clear_cache' ) );
@@ -126,6 +126,9 @@ if ( ! class_exists( 'AWS_Table' ) ) :
126
  delete_option( 'aws_index_meta' );
127
 
128
  $this->clear_cache();
 
 
 
129
  }
130
 
131
  } else {
@@ -163,7 +166,9 @@ if ( ! class_exists( 'AWS_Table' ) ) :
163
  term VARCHAR(50) NOT NULL DEFAULT 0,
164
  term_source VARCHAR(20) NOT NULL DEFAULT 0,
165
  type VARCHAR(50) NOT NULL DEFAULT 0,
166
- count BIGINT(20) UNSIGNED NOT NULL DEFAULT 0
 
 
167
  ) $charset_collate;";
168
 
169
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
@@ -185,21 +190,10 @@ if ( ! class_exists( 'AWS_Table' ) ) :
185
  $terms = array();
186
  $id = $found_post_id;
187
 
188
- $custom = get_post_custom( $id );
189
-
190
- if ( isset( $custom['_visibility'] ) && $custom['_visibility'][0] == 'hidden' ) {
191
- continue;
192
- }
193
-
194
- // if ( isset( $custom['_stock_status'] ) && $custom['_stock_status'][0] == 'outofstock' ) {
195
- // continue;
196
- // }
197
-
198
  $product = wc_get_product( $id );
199
 
200
- if ( $product->stock_status === 'outofstock' ) {
201
- continue;
202
- }
203
 
204
  $sku = $product->get_sku();
205
 
@@ -262,8 +256,8 @@ if ( ! class_exists( 'AWS_Table' ) ) :
262
  }
263
 
264
  $value = $wpdb->prepare(
265
- "(%d, %s, %s, %s, %d)",
266
- $id, $term, $source, 'product', $count
267
  );
268
 
269
  $values[] = $value;
@@ -278,7 +272,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
278
  $values = implode( ', ', $values );
279
 
280
  $query = "INSERT IGNORE INTO {$this->table_name}
281
- (`id`, `term`, `term_source`, `type`, `count`)
282
  VALUES $values
283
  ";
284
 
25
 
26
  $this->table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
27
 
28
+ add_action( 'wp_insert_post', array( $this, 'update_table' ), 10, 3 );
29
 
30
  add_action( 'aws_settings_saved', array( $this, 'clear_cache' ) );
31
  add_action( 'aws_cache_clear', array( $this, 'clear_cache' ) );
126
  delete_option( 'aws_index_meta' );
127
 
128
  $this->clear_cache();
129
+
130
+ update_option( 'aws_reindex_version', AWS_VERSION );
131
+
132
  }
133
 
134
  } else {
166
  term VARCHAR(50) NOT NULL DEFAULT 0,
167
  term_source VARCHAR(20) NOT NULL DEFAULT 0,
168
  type VARCHAR(50) NOT NULL DEFAULT 0,
169
+ count BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
170
+ in_stock INT(11) NOT NULL DEFAULT 0,
171
+ visibility VARCHAR(20) NOT NULL DEFAULT 0
172
  ) $charset_collate;";
173
 
174
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
190
  $terms = array();
191
  $id = $found_post_id;
192
 
 
 
 
 
 
 
 
 
 
 
193
  $product = wc_get_product( $id );
194
 
195
+ $in_stock = ( $product->stock_status === 'outofstock' ) ? 0 : 1;
196
+ $visibility = $product->catalog_visibility;
 
197
 
198
  $sku = $product->get_sku();
199
 
256
  }
257
 
258
  $value = $wpdb->prepare(
259
+ "(%d, %s, %s, %s, %d, %d, %s)",
260
+ $id, $term, $source, 'product', $count, $in_stock, $visibility
261
  );
262
 
263
  $values[] = $value;
272
  $values = implode( ', ', $values );
273
 
274
  $query = "INSERT IGNORE INTO {$this->table_name}
275
+ (`id`, `term`, `term_source`, `type`, `count`, `in_stock`, `visibility`)
276
  VALUES $values
277
  ";
278
 
includes/class-aws-versions.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Versions capability
4
+ */
5
+
6
+ if ( ! defined( 'ABSPATH' ) ) {
7
+ exit; // Exit if accessed directly.
8
+ }
9
+
10
+ if ( ! class_exists( 'AWS_Versions' ) ) :
11
+
12
+ /**
13
+ * Class for plugin search
14
+ */
15
+ class AWS_Versions {
16
+
17
+ /**
18
+ * Return a singleton instance of the current class
19
+ *
20
+ * @return object
21
+ */
22
+ public static function factory() {
23
+ static $instance = false;
24
+
25
+ if ( ! $instance ) {
26
+ $instance = new self();
27
+ $instance->setup();
28
+ }
29
+
30
+ return $instance;
31
+ }
32
+
33
+ /**
34
+ * Placeholder
35
+ */
36
+ public function __construct() {}
37
+
38
+ /**
39
+ * Setup actions and filters for all things settings
40
+ */
41
+ public function setup() {
42
+
43
+ $current_version = get_option( 'aws_plugin_ver' );
44
+ $reindex_version = get_option( 'aws_reindex_version' );
45
+
46
+ if ( ! ( $reindex_version ) ) {
47
+ add_action( 'admin_notices', array( $this, 'admin_notice_no_index' ) );
48
+ }
49
+
50
+ if ( $reindex_version && version_compare( $reindex_version, '1.16', '<' ) ) {
51
+ add_action( 'admin_notices', array( $this, 'admin_notice_reindex' ) );
52
+ }
53
+
54
+ if ( $current_version ) {
55
+
56
+ if ( version_compare( $current_version, '1.16', '<' ) ) {
57
+
58
+ $settings = get_option( 'aws_settings' );
59
+
60
+ if ( $settings ) {
61
+ if ( ! $settings['outofstock'] ) {
62
+
63
+ $settings['outofstock'] = 'false';
64
+
65
+ update_option( 'aws_settings', $settings );
66
+
67
+ }
68
+ }
69
+
70
+ }
71
+
72
+ }
73
+
74
+ update_option( 'aws_plugin_ver', AWS_VERSION );
75
+
76
+ }
77
+
78
+ /**
79
+ * Admin notice for table first reindex
80
+ */
81
+ public function admin_notice_no_index() { ?>
82
+ <div class="updated notice is-dismissible">
83
+ <p><?php printf( esc_html__( 'Advanced Woo Search: Please go to plugin setting page and start the indexing of your products. %s', 'aws' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Reindex Table', 'aws' ).'</a>' ); ?></p>
84
+ </div>
85
+ <?php }
86
+
87
+ /**
88
+ * Admin notice for table reindex
89
+ */
90
+ public function admin_notice_reindex() { ?>
91
+ <div class="updated notice is-dismissible">
92
+ <p><?php printf( esc_html__( 'Advanced Woo Search: Please reindex table for proper work of new plugin features. %s', 'aws' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Reindex Table', 'aws' ).'</a>' ); ?></p>
93
+ </div>
94
+ <?php }
95
+
96
+ }
97
+
98
+
99
+ endif;
100
+
101
+ add_action( 'admin_init', 'AWS_Versions::factory' );
includes/options.php CHANGED
@@ -26,6 +26,17 @@ $options['general'][] = array(
26
  "type" => "sortable"
27
  );
28
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  // Search Form Settings
31
  $options['form'][] = array(
26
  "type" => "sortable"
27
  );
28
 
29
+ $options['general'][] = array(
30
+ "name" => __( "Show out-of-stock", "aws" ),
31
+ "desc" => __( "Show out-of-stock products in search", "aws" ),
32
+ "id" => "outofstock",
33
+ "value" => 'true',
34
+ "type" => "radio",
35
+ 'choices' => array(
36
+ 'true' => __( 'Show', 'aws' ),
37
+ 'false' => __( 'Hide', 'aws' ),
38
+ )
39
+ );
40
 
41
  // Search Form Settings
42
  $options['form'][] = array(
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: Mihail Barinov
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GSE37FC4Y7CEY
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.3
7
  Stable tag: 1.15
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -35,9 +35,9 @@ Advanced Woo Search - powerful live search plugin for WooCommerce. Just start ty
35
  * **Filters**. Switch between tabs to show different search results
36
  * **Unlimited** amount of search form instances
37
  * **Anvanced settings page** with lot of options
38
- * **Smooth scroll** for search results
39
  * **Exclude** spicific products by its categories or tags from search results
40
  * Ability to specify **source of image** for search results: featured image, gallery, product content, product short description or set default image if there is no other images
 
41
  * Support for **WooCommerce Brands plugin**
42
 
43
  == Installation ==
@@ -71,6 +71,10 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
71
 
72
  == Changelog ==
73
 
 
 
 
 
74
  = 1.15 =
75
  * Exclude 'Out of stock' products from search
76
  * Fix bugs
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GSE37FC4Y7CEY
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.4
7
  Stable tag: 1.15
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
35
  * **Filters**. Switch between tabs to show different search results
36
  * **Unlimited** amount of search form instances
37
  * **Anvanced settings page** with lot of options
 
38
  * **Exclude** spicific products by its categories or tags from search results
39
  * Ability to specify **source of image** for search results: featured image, gallery, product content, product short description or set default image if there is no other images
40
+ * **Visibility option** - choose what catalog visibility must be for product to displayed in search results
41
  * Support for **WooCommerce Brands plugin**
42
 
43
  == Installation ==
71
 
72
  == Changelog ==
73
 
74
+ = 1.16 =
75
+ * Option for 'Out of stock' products
76
+ * Fix bugs
77
+
78
  = 1.15 =
79
  * Exclude 'Out of stock' products from search
80
  * Fix bugs