Version Description
- Add option for preventing submit of empty search form
- Add support for Protected Categories plugin
- Add aws_exclude_products filter
- Add aws_terms_exclude_product_cat filter
- Add aws_terms_exclude_product_tag filter
Download this release
Release Info
Developer | Mihail Barinov |
Plugin | Advanced Woo Search |
Version | 1.58 |
Comparing to | |
See all releases |
Code changes from version 1.57 to 1.58
- advanced-woo-search.php +3 -2
- assets/js/common.js +2 -2
- includes/class-aws-integrations.php +123 -0
- includes/class-aws-search.php +31 -2
- includes/class-aws-table.php +1 -1
- readme.txt +8 -1
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.
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: aws
|
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
16 |
exit;
|
17 |
}
|
18 |
|
19 |
-
define( 'AWS_VERSION', '1.
|
20 |
|
21 |
|
22 |
define( 'AWS_DIR', dirname( __FILE__ ) );
|
@@ -109,6 +109,7 @@ final class AWS_Main {
|
|
109 |
include_once( 'includes/class-aws-search.php' );
|
110 |
include_once( 'includes/class-aws-search-page.php' );
|
111 |
include_once( 'includes/class-aws-order.php' );
|
|
|
112 |
include_once( 'includes/widget.php' );
|
113 |
}
|
114 |
|
3 |
/*
|
4 |
Plugin Name: Advanced Woo Search
|
5 |
Description: Advance ajax WooCommerce product search.
|
6 |
+
Version: 1.58
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: aws
|
16 |
exit;
|
17 |
}
|
18 |
|
19 |
+
define( 'AWS_VERSION', '1.58' );
|
20 |
|
21 |
|
22 |
define( 'AWS_DIR', dirname( __FILE__ ) );
|
109 |
include_once( 'includes/class-aws-search.php' );
|
110 |
include_once( 'includes/class-aws-search-page.php' );
|
111 |
include_once( 'includes/class-aws-order.php' );
|
112 |
+
include_once( 'includes/class-aws-integrations.php' );
|
113 |
include_once( 'includes/widget.php' );
|
114 |
}
|
115 |
|
assets/js/common.js
CHANGED
@@ -380,14 +380,14 @@
|
|
380 |
|
381 |
|
382 |
$searchForm.on( 'keypress', function(e) {
|
383 |
-
if ( e.keyCode == 13 && ! d.showPage ) {
|
384 |
e.preventDefault();
|
385 |
}
|
386 |
});
|
387 |
|
388 |
|
389 |
$searchButton.on( 'click', function (e) {
|
390 |
-
if ( d.showPage ) {
|
391 |
$searchForm.submit();
|
392 |
}
|
393 |
});
|
380 |
|
381 |
|
382 |
$searchForm.on( 'keypress', function(e) {
|
383 |
+
if ( e.keyCode == 13 && ( ! d.showPage || $searchField.val() === '' ) ) {
|
384 |
e.preventDefault();
|
385 |
}
|
386 |
});
|
387 |
|
388 |
|
389 |
$searchButton.on( 'click', function (e) {
|
390 |
+
if ( d.showPage && $searchField.val() !== '' ) {
|
391 |
$searchForm.submit();
|
392 |
}
|
393 |
});
|
includes/class-aws-integrations.php
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* AWS plugin integrations
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly.
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! class_exists( 'AWS_Integrations' ) ) :
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class for main plugin functions
|
14 |
+
*/
|
15 |
+
class AWS_Integrations {
|
16 |
+
|
17 |
+
private $data = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var AWS_Integrations The single instance of the class
|
21 |
+
*/
|
22 |
+
protected static $_instance = null;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Main AWS_Integrations Instance
|
26 |
+
*
|
27 |
+
* Ensures only one instance of AWS_Integrations is loaded or can be loaded.
|
28 |
+
*
|
29 |
+
* @static
|
30 |
+
* @return AWS_Integrations - Main instance
|
31 |
+
*/
|
32 |
+
public static function instance() {
|
33 |
+
if ( is_null( self::$_instance ) ) {
|
34 |
+
self::$_instance = new self();
|
35 |
+
}
|
36 |
+
return self::$_instance;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Constructor
|
41 |
+
*/
|
42 |
+
public function __construct() {
|
43 |
+
|
44 |
+
// Protected categories plugin
|
45 |
+
if ( class_exists('WC_PPC_Util' ) ) {
|
46 |
+
|
47 |
+
$hidden_categories = array();
|
48 |
+
$show_protected = WC_PPC_Util::showing_protected_categories();
|
49 |
+
|
50 |
+
// Get all the product categories, and check which are hidden.
|
51 |
+
foreach ( WC_PPC_Util::to_category_visibilities( WC_PPC_Util::get_product_categories() ) as $category ) {
|
52 |
+
if ( $category->is_private() || ( ! $show_protected && $category->is_protected() ) ) {
|
53 |
+
$hidden_categories[] = $category->term_id;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
if ( $hidden_categories && ! empty( $hidden_categories ) ) {
|
58 |
+
|
59 |
+
$this->data['exclude_categories'] = $hidden_categories;
|
60 |
+
|
61 |
+
$args = array(
|
62 |
+
'posts_per_page' => -1,
|
63 |
+
'fields' => 'ids',
|
64 |
+
'post_type' => 'product',
|
65 |
+
'post_status' => 'publish',
|
66 |
+
'ignore_sticky_posts' => true,
|
67 |
+
'suppress_filters' => true,
|
68 |
+
'tax_query' => array(
|
69 |
+
array(
|
70 |
+
'taxonomy' => 'product_cat',
|
71 |
+
'field' => 'id',
|
72 |
+
'terms' => $hidden_categories
|
73 |
+
)
|
74 |
+
)
|
75 |
+
);
|
76 |
+
|
77 |
+
$exclude_products = get_posts( $args );
|
78 |
+
|
79 |
+
if ( $exclude_products && count( $exclude_products ) > 0 ) {
|
80 |
+
|
81 |
+
$this->data['exclude_products'] = $exclude_products;
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
|
89 |
+
if ( isset( $this->data['exclude_categories'] ) ) {
|
90 |
+
add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) );
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( isset( $this->data['exclude_products'] ) ) {
|
94 |
+
add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) );
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
/*
|
100 |
+
* Exclude product categories
|
101 |
+
*/
|
102 |
+
public function filter_protected_cats_term_exclude( $exclude ) {
|
103 |
+
foreach( $this->data['exclude_categories'] as $to_exclude ) {
|
104 |
+
$exclude[] = $to_exclude;
|
105 |
+
}
|
106 |
+
return $exclude;
|
107 |
+
}
|
108 |
+
|
109 |
+
/*
|
110 |
+
* Exclude products
|
111 |
+
*/
|
112 |
+
public function filter_products_exclude( $exclude ) {
|
113 |
+
foreach( $this->data['exclude_products'] as $to_exclude ) {
|
114 |
+
$exclude[] = $to_exclude;
|
115 |
+
}
|
116 |
+
return $exclude;
|
117 |
+
}
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
endif;
|
122 |
+
|
123 |
+
add_action( 'init', 'AWS_Integrations::instance' );
|
includes/class-aws-search.php
CHANGED
@@ -249,6 +249,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
249 |
$query['relevance'] = '';
|
250 |
$query['stock'] = '';
|
251 |
$query['visibility'] = '';
|
|
|
252 |
$query['lang'] = '';
|
253 |
|
254 |
$search_array = array();
|
@@ -279,7 +280,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
279 |
|
280 |
$search_term_norm = preg_replace( '/(s|es|ies)$/i', '', $search_term );
|
281 |
|
282 |
-
if ( $search_term_norm ) {
|
283 |
$search_term = $search_term_norm;
|
284 |
}
|
285 |
|
@@ -359,6 +360,20 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
359 |
}
|
360 |
|
361 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
if ( $this->lang ) {
|
363 |
$current_lang = $this->lang;
|
364 |
} else {
|
@@ -381,6 +396,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
381 |
{$query['search']}
|
382 |
{$query['stock']}
|
383 |
{$query['visibility']}
|
|
|
384 |
{$query['lang']}
|
385 |
GROUP BY ID
|
386 |
ORDER BY
|
@@ -681,6 +697,18 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
681 |
|
682 |
$search_query .= sprintf( ' AND ( %s )', implode( ' OR ', $search_array ) );
|
683 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
684 |
|
685 |
$sql = "
|
686 |
SELECT
|
@@ -695,9 +723,10 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
695 |
{$search_query}
|
696 |
AND $wpdb->term_taxonomy.taxonomy = '{$taxonomy}'
|
697 |
AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id
|
698 |
-
|
699 |
LIMIT 0, 10";
|
700 |
|
|
|
701 |
$search_results = $wpdb->get_results( $sql );
|
702 |
|
703 |
if ( ! empty( $search_results ) && !is_wp_error( $search_results ) ) {
|
249 |
$query['relevance'] = '';
|
250 |
$query['stock'] = '';
|
251 |
$query['visibility'] = '';
|
252 |
+
$query['exclude_products'] = '';
|
253 |
$query['lang'] = '';
|
254 |
|
255 |
$search_array = array();
|
280 |
|
281 |
$search_term_norm = preg_replace( '/(s|es|ies)$/i', '', $search_term );
|
282 |
|
283 |
+
if ( $search_term_norm && $search_term_len > 3 ) {
|
284 |
$search_term = $search_term_norm;
|
285 |
}
|
286 |
|
360 |
}
|
361 |
|
362 |
|
363 |
+
/**
|
364 |
+
* Exclude certain products from search
|
365 |
+
*
|
366 |
+
* @since 1.58
|
367 |
+
*
|
368 |
+
* @param array
|
369 |
+
*/
|
370 |
+
$exclude_products_filter = apply_filters( 'aws_exclude_products', array() );
|
371 |
+
|
372 |
+
if ( $exclude_products_filter && is_array( $exclude_products_filter ) && ! empty( $exclude_products_filter ) ) {
|
373 |
+
$query['exclude_products'] = sprintf( ' AND ( id NOT IN ( %s ) )', implode( ',', $exclude_products_filter ) );
|
374 |
+
}
|
375 |
+
|
376 |
+
|
377 |
if ( $this->lang ) {
|
378 |
$current_lang = $this->lang;
|
379 |
} else {
|
396 |
{$query['search']}
|
397 |
{$query['stock']}
|
398 |
{$query['visibility']}
|
399 |
+
{$query['exclude_products']}
|
400 |
{$query['lang']}
|
401 |
GROUP BY ID
|
402 |
ORDER BY
|
697 |
|
698 |
$search_query .= sprintf( ' AND ( %s )', implode( ' OR ', $search_array ) );
|
699 |
|
700 |
+
/**
|
701 |
+
* Exclude certain terms from search
|
702 |
+
*
|
703 |
+
* @since 1.58
|
704 |
+
*
|
705 |
+
* @param array
|
706 |
+
*/
|
707 |
+
$exclude_terms = apply_filters( 'aws_terms_exclude_' . $taxonomy, array() );
|
708 |
+
|
709 |
+
if ( $exclude_terms && is_array( $exclude_terms ) && ! empty( $exclude_terms ) ) {
|
710 |
+
$excludes = $wpdb->prepare( " AND ( " . $wpdb->terms . ".term_id NOT IN ( %s ) )", implode( ',', $exclude_terms ) );
|
711 |
+
}
|
712 |
|
713 |
$sql = "
|
714 |
SELECT
|
723 |
{$search_query}
|
724 |
AND $wpdb->term_taxonomy.taxonomy = '{$taxonomy}'
|
725 |
AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id
|
726 |
+
{$excludes}
|
727 |
LIMIT 0, 10";
|
728 |
|
729 |
+
|
730 |
$search_results = $wpdb->get_results( $sql );
|
731 |
|
732 |
if ( ! empty( $search_results ) && !is_wp_error( $search_results ) ) {
|
includes/class-aws-table.php
CHANGED
@@ -734,7 +734,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
734 |
if ( $str_item_term ) {
|
735 |
$new_array_key = preg_replace( '/(s|es|ies)$/i', '', $str_item_term );
|
736 |
|
737 |
-
if ( $new_array_key ) {
|
738 |
if ( ! isset( $str_new_array[$new_array_key] ) ) {
|
739 |
$str_new_array[$new_array_key] = $str_item_num;
|
740 |
}
|
734 |
if ( $str_item_term ) {
|
735 |
$new_array_key = preg_replace( '/(s|es|ies)$/i', '', $str_item_term );
|
736 |
|
737 |
+
if ( $new_array_key && strlen( $str_item_term ) > 3 ) {
|
738 |
if ( ! isset( $str_new_array[$new_array_key] ) ) {
|
739 |
$str_new_array[$new_array_key] = $str_item_num;
|
740 |
}
|
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.0
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -101,6 +101,13 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
|
|
101 |
|
102 |
== Changelog ==
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
= 1.57 =
|
105 |
* Update search query string
|
106 |
* Fix style for search icon
|
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.0
|
7 |
+
Stable tag: 1.58
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
101 |
|
102 |
== Changelog ==
|
103 |
|
104 |
+
= 1.58 =
|
105 |
+
* Add option for preventing submit of empty search form
|
106 |
+
* Add support for Protected Categories plugin
|
107 |
+
* Add aws_exclude_products filter
|
108 |
+
* Add aws_terms_exclude_product_cat filter
|
109 |
+
* Add aws_terms_exclude_product_tag filter
|
110 |
+
|
111 |
= 1.57 =
|
112 |
* Update search query string
|
113 |
* Fix style for search icon
|