Version Description
Download this release
Release Info
Developer | damian-gora |
Plugin | Ajax Search for WooCommerce |
Version | 1.1.6 |
Comparing to | |
See all releases |
Code changes from version 1.1.5 to 1.1.6
- ajax-search-for-woocommerce.php +2 -3
- includes/class-search.php +77 -28
- readme.txt +6 -2
ajax-search-for-woocommerce.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: AJAX Search for WooCommerce
|
5 |
* Plugin URI: https://wordpress.org/plugins/ajax-search-for-woocommerce/
|
6 |
* Description: Allows your customers to search products easily and quickly. It will display the results instantly while typing in an inputbox.
|
7 |
-
* Version: 1.1.
|
8 |
* Author: Damian Góra
|
9 |
* Author URI: http://damiangora.com
|
10 |
* Text Domain: ajax-search-for-woocommerce
|
@@ -121,7 +121,7 @@ if ( !class_exists( 'DGWT_WC_Ajax_Search' ) ) {
|
|
121 |
*/
|
122 |
private function constants() {
|
123 |
|
124 |
-
$this->define( 'DGWT_WCAS_VERSION', '1.1.
|
125 |
$this->define( 'DGWT_WCAS_NAME', 'Ajax Search for WooCommerce' );
|
126 |
$this->define( 'DGWT_WCAS_FILE', __FILE__ );
|
127 |
$this->define( 'DGWT_WCAS_DIR', plugin_dir_path( __FILE__ ) );
|
@@ -141,7 +141,6 @@ if ( !class_exists( 'DGWT_WC_Ajax_Search' ) ) {
|
|
141 |
|
142 |
$this->define( 'DGWT_WCAS_DEBUG', false );
|
143 |
|
144 |
-
//$this->define( 'DGWT_WCAS_PRO_VERSION', true );
|
145 |
}
|
146 |
|
147 |
/**
|
4 |
* Plugin Name: AJAX Search for WooCommerce
|
5 |
* Plugin URI: https://wordpress.org/plugins/ajax-search-for-woocommerce/
|
6 |
* Description: Allows your customers to search products easily and quickly. It will display the results instantly while typing in an inputbox.
|
7 |
+
* Version: 1.1.6
|
8 |
* Author: Damian Góra
|
9 |
* Author URI: http://damiangora.com
|
10 |
* Text Domain: ajax-search-for-woocommerce
|
121 |
*/
|
122 |
private function constants() {
|
123 |
|
124 |
+
$this->define( 'DGWT_WCAS_VERSION', '1.1.6' );
|
125 |
$this->define( 'DGWT_WCAS_NAME', 'Ajax Search for WooCommerce' );
|
126 |
$this->define( 'DGWT_WCAS_FILE', __FILE__ );
|
127 |
$this->define( 'DGWT_WCAS_DIR', plugin_dir_path( __FILE__ ) );
|
141 |
|
142 |
$this->define( 'DGWT_WCAS_DEBUG', false );
|
143 |
|
|
|
144 |
}
|
145 |
|
146 |
/**
|
includes/class-search.php
CHANGED
@@ -99,10 +99,17 @@ class DGWT_WCAS_Search {
|
|
99 |
'ignore_sticky_posts' => 1,
|
100 |
'orderby' => $ordering_args[ 'orderby' ],
|
101 |
'order' => $ordering_args[ 'order' ],
|
102 |
-
'suppress_filters' => false
|
103 |
-
'meta_query' => $this->get_meta_query()
|
104 |
);
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
$args = apply_filters('dgwt_wcas_products_args', $args);
|
107 |
|
108 |
$products = get_posts( $args );
|
@@ -177,7 +184,8 @@ class DGWT_WCAS_Search {
|
|
177 |
}
|
178 |
|
179 |
/*
|
180 |
-
* Get meta query
|
|
|
181 |
*
|
182 |
* return array
|
183 |
*/
|
@@ -186,39 +194,72 @@ class DGWT_WCAS_Search {
|
|
186 |
|
187 |
$meta_query = array();
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
'
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
'
|
200 |
-
array(
|
201 |
-
|
202 |
-
'value' => array( 'search', 'visible' ),
|
203 |
-
'compare' => 'IN'
|
204 |
-
)
|
205 |
)
|
206 |
-
)
|
207 |
-
|
208 |
|
209 |
|
210 |
// Exclude out of stock products from suggestions
|
211 |
if ( DGWT_WCAS()->settings->get_opt( 'exclude_out_of_stock' ) === 'on' ) {
|
212 |
$meta_query[] = array(
|
213 |
-
'key'
|
214 |
-
'value'
|
215 |
-
'compare'
|
216 |
);
|
217 |
};
|
218 |
|
219 |
return $meta_query;
|
220 |
}
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
/*
|
223 |
* Search for matching category
|
224 |
*
|
@@ -262,10 +303,12 @@ class DGWT_WCAS_Search {
|
|
262 |
|
263 |
$results[ $i ][ 'parents' ] = sprintf( ' <em>%s <b>%s</b></em>', __( 'in', 'ajax-search-for-woocommerce' ), mb_substr( $parents, 0, -3 ) );
|
264 |
}
|
|
|
|
|
265 |
}
|
266 |
}
|
267 |
|
268 |
-
|
269 |
}
|
270 |
|
271 |
return $results;
|
@@ -313,10 +356,10 @@ class DGWT_WCAS_Search {
|
|
313 |
|
314 |
$results[ $i ][ 'parents' ] = sprintf( ' <em>%s <b>%s</b></em>', __( 'in', 'ajax-search-for-woocommerce' ), mb_substr( $parents, 0, -3 ) );
|
315 |
}
|
|
|
|
|
316 |
}
|
317 |
}
|
318 |
-
|
319 |
-
$i++;
|
320 |
}
|
321 |
|
322 |
return $results;
|
@@ -519,7 +562,13 @@ class DGWT_WCAS_Search {
|
|
519 |
$query->query_vars[ 'post_type' ] = DGWT_WCAS_WOO_PRODUCT_POST_TYPE;
|
520 |
$query->query_vars[ 'ignore_sticky_posts' ] = 1;
|
521 |
$query->query_vars[ 'suppress_filters' ] = false;
|
522 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
523 |
|
524 |
|
525 |
$ordering_args = $woocommerce->query->get_catalog_ordering_args( 'title', 'asc' );
|
99 |
'ignore_sticky_posts' => 1,
|
100 |
'orderby' => $ordering_args[ 'orderby' ],
|
101 |
'order' => $ordering_args[ 'order' ],
|
102 |
+
'suppress_filters' => false
|
|
|
103 |
);
|
104 |
|
105 |
+
// Backward compatibility WC < 3.0
|
106 |
+
if ( dgwt_wcas_compare_wc_version( '3.0', '<' ) ) {
|
107 |
+
$args['meta_query'] = $this->get_meta_query();
|
108 |
+
}else{
|
109 |
+
$args['tax_query'] = $this->get_tax_query();
|
110 |
+
}
|
111 |
+
|
112 |
+
|
113 |
$args = apply_filters('dgwt_wcas_products_args', $args);
|
114 |
|
115 |
$products = get_posts( $args );
|
184 |
}
|
185 |
|
186 |
/*
|
187 |
+
* Get meta query
|
188 |
+
* For WooCommerce < 3.0
|
189 |
*
|
190 |
* return array
|
191 |
*/
|
194 |
|
195 |
$meta_query = array();
|
196 |
|
197 |
+
$meta_query = array(
|
198 |
+
'relation' => 'AND',
|
199 |
+
1 => array(
|
200 |
+
'key' => '_visibility',
|
201 |
+
'value' => array( 'search', 'visible' ),
|
202 |
+
'compare' => 'IN'
|
203 |
+
),
|
204 |
+
2 => array(
|
205 |
+
'relation' => 'OR',
|
206 |
+
array(
|
207 |
+
'key' => '_visibility',
|
208 |
+
'value' => array( 'search', 'visible' ),
|
209 |
+
'compare' => 'IN'
|
|
|
|
|
|
|
210 |
)
|
211 |
+
)
|
212 |
+
);
|
213 |
|
214 |
|
215 |
// Exclude out of stock products from suggestions
|
216 |
if ( DGWT_WCAS()->settings->get_opt( 'exclude_out_of_stock' ) === 'on' ) {
|
217 |
$meta_query[] = array(
|
218 |
+
'key' => '_stock_status',
|
219 |
+
'value' => 'outofstock',
|
220 |
+
'compare' => 'NOT IN'
|
221 |
);
|
222 |
};
|
223 |
|
224 |
return $meta_query;
|
225 |
}
|
226 |
|
227 |
+
/*
|
228 |
+
* Get tax query
|
229 |
+
* For WooCommerce >= 3.0
|
230 |
+
*
|
231 |
+
* return array
|
232 |
+
*/
|
233 |
+
|
234 |
+
private function get_tax_query() {
|
235 |
+
|
236 |
+
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
|
237 |
+
|
238 |
+
$tax_query = array(
|
239 |
+
'relation' => 'AND'
|
240 |
+
);
|
241 |
+
|
242 |
+
$tax_query[] = array(
|
243 |
+
'taxonomy' => 'product_visibility',
|
244 |
+
'field' => 'term_taxonomy_id',
|
245 |
+
'terms' => $product_visibility_term_ids['exclude-from-search'],
|
246 |
+
'operator' => 'NOT IN',
|
247 |
+
);
|
248 |
+
|
249 |
+
|
250 |
+
// Exclude out of stock products from suggestions
|
251 |
+
if ( DGWT_WCAS()->settings->get_opt( 'exclude_out_of_stock' ) === 'on' ) {
|
252 |
+
$tax_query[] = array(
|
253 |
+
'taxonomy' => 'product_visibility',
|
254 |
+
'field' => 'term_taxonomy_id',
|
255 |
+
'terms' => $product_visibility_term_ids['outofstock'],
|
256 |
+
'operator' => 'NOT IN',
|
257 |
+
);
|
258 |
+
};
|
259 |
+
|
260 |
+
return $tax_query;
|
261 |
+
}
|
262 |
+
|
263 |
/*
|
264 |
* Search for matching category
|
265 |
*
|
303 |
|
304 |
$results[ $i ][ 'parents' ] = sprintf( ' <em>%s <b>%s</b></em>', __( 'in', 'ajax-search-for-woocommerce' ), mb_substr( $parents, 0, -3 ) );
|
305 |
}
|
306 |
+
|
307 |
+
$i++;
|
308 |
}
|
309 |
}
|
310 |
|
311 |
+
|
312 |
}
|
313 |
|
314 |
return $results;
|
356 |
|
357 |
$results[ $i ][ 'parents' ] = sprintf( ' <em>%s <b>%s</b></em>', __( 'in', 'ajax-search-for-woocommerce' ), mb_substr( $parents, 0, -3 ) );
|
358 |
}
|
359 |
+
|
360 |
+
$i++;
|
361 |
}
|
362 |
}
|
|
|
|
|
363 |
}
|
364 |
|
365 |
return $results;
|
562 |
$query->query_vars[ 'post_type' ] = DGWT_WCAS_WOO_PRODUCT_POST_TYPE;
|
563 |
$query->query_vars[ 'ignore_sticky_posts' ] = 1;
|
564 |
$query->query_vars[ 'suppress_filters' ] = false;
|
565 |
+
|
566 |
+
// Backward compatibility WC < 3.0
|
567 |
+
if ( dgwt_wcas_compare_wc_version( '3.0', '<' ) ) {
|
568 |
+
$query->query_vars[ 'meta_query' ] = $this->get_meta_query();
|
569 |
+
}else{
|
570 |
+
$query->query_vars[ 'tax_query' ] = $this->get_tax_query();
|
571 |
+
}
|
572 |
|
573 |
|
574 |
$ordering_args = $woocommerce->query->get_catalog_ordering_args( 'title', 'asc' );
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ Contributors: damian-gora
|
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LD2ALVRLXPZPC
|
4 |
Tags: AJAX, ajax search, autocomplete, category search, custom search, ecommerce, instant search, sive search, product search, products, search, search by sku, search highlight, search plugin, shop, woocommerce, woocommerce live search, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress search, wp ajax search, wp search, wp search plugin, wp tao
|
5 |
Requires at least: 3.8
|
6 |
-
Tested up to: 4.8.
|
7 |
Requires PHP: 5.3
|
8 |
-
Stable tag: 1.1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -69,6 +69,10 @@ Any suggestions or comments are welcome. Feel free to contact me using this [con
|
|
69 |
|
70 |
== Changelog ==
|
71 |
|
|
|
|
|
|
|
|
|
72 |
= 1.1.5, September 05, 2017 =
|
73 |
* ADD: Requires PHP tag in readme.txt
|
74 |
* FIX: PHP Fatal error for PHP < 5.3
|
3 |
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LD2ALVRLXPZPC
|
4 |
Tags: AJAX, ajax search, autocomplete, category search, custom search, ecommerce, instant search, sive search, product search, products, search, search by sku, search highlight, search plugin, shop, woocommerce, woocommerce live search, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress search, wp ajax search, wp search, wp search plugin, wp tao
|
5 |
Requires at least: 3.8
|
6 |
+
Tested up to: 4.8.2
|
7 |
Requires PHP: 5.3
|
8 |
+
Stable tag: 1.1.6
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
69 |
|
70 |
== Changelog ==
|
71 |
|
72 |
+
= 1.1.6, October 01, 2017 =
|
73 |
+
* FIX: Disappearing some categories and tags in suggestions
|
74 |
+
* FIX: Hidden products were shown in search
|
75 |
+
|
76 |
= 1.1.5, September 05, 2017 =
|
77 |
* ADD: Requires PHP tag in readme.txt
|
78 |
* FIX: PHP Fatal error for PHP < 5.3
|