Version Description
- Add caching table to store cached search result instead of store them in wp_options table
- Fix deprecated action 'woocommerce_variable_product_sync'
Download this release
Release Info
Developer | Mihail Barinov |
Plugin | Advanced Woo Search |
Version | 1.28 |
Comparing to | |
See all releases |
Code changes from version 1.27 to 1.28
- advanced-woo-search.php +23 -7
- assets/css/common.css +1 -2
- includes/class-aws-admin.php +2 -0
- includes/class-aws-cache.php +187 -0
- includes/class-aws-search-page.php +4 -3
- includes/class-aws-search.php +11 -26
- includes/class-aws-table.php +22 -30
- readme.txt +5 -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
|
@@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
-
define( 'AWS_VERSION', '1.
|
18 |
|
19 |
|
20 |
define( 'AWS_DIR', dirname( __FILE__ ) );
|
@@ -22,6 +22,7 @@ define( 'AWS_URL', plugins_url( '', __FILE__ ) );
|
|
22 |
|
23 |
|
24 |
define( 'AWS_INDEX_TABLE_NAME', 'aws_index' );
|
|
|
25 |
|
26 |
|
27 |
if ( ! class_exists( 'AWS_Main' ) ) :
|
@@ -38,10 +39,15 @@ final class AWS_Main {
|
|
38 |
*/
|
39 |
protected static $_instance = null;
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
/**
|
47 |
* Main AWS_Main Instance
|
@@ -75,7 +81,9 @@ final class AWS_Main {
|
|
75 |
|
76 |
load_plugin_textdomain( 'aws', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
|
77 |
|
78 |
-
|
|
|
|
|
79 |
|
80 |
}
|
81 |
|
@@ -86,6 +94,7 @@ final class AWS_Main {
|
|
86 |
include_once( 'includes/class-aws-versions.php' );
|
87 |
include_once( 'includes/class-aws-helpers.php' );
|
88 |
include_once( 'includes/class-aws-admin.php' );
|
|
|
89 |
include_once( 'includes/class-aws-table.php' );
|
90 |
include_once( 'includes/class-aws-markup.php' );
|
91 |
include_once( 'includes/class-aws-search.php' );
|
@@ -103,6 +112,13 @@ final class AWS_Main {
|
|
103 |
return $markup->markup();
|
104 |
|
105 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
/*
|
108 |
* Load assets for search form
|
3 |
/*
|
4 |
Plugin Name: Advanced Woo Search
|
5 |
Description: Advance ajax WooCommerce product search.
|
6 |
+
Version: 1.28
|
7 |
Author: ILLID
|
8 |
Author URI: https://advanced-woo-search.com/
|
9 |
Text Domain: aws
|
14 |
exit;
|
15 |
}
|
16 |
|
17 |
+
define( 'AWS_VERSION', '1.28' );
|
18 |
|
19 |
|
20 |
define( 'AWS_DIR', dirname( __FILE__ ) );
|
22 |
|
23 |
|
24 |
define( 'AWS_INDEX_TABLE_NAME', 'aws_index' );
|
25 |
+
define( 'AWS_CACHE_TABLE_NAME', 'aws_cache' );
|
26 |
|
27 |
|
28 |
if ( ! class_exists( 'AWS_Main' ) ) :
|
39 |
*/
|
40 |
protected static $_instance = null;
|
41 |
|
42 |
+
/**
|
43 |
+
* @var AWS_Main Array of all plugin data $data
|
44 |
+
*/
|
45 |
+
private $data = array();
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @var AWS_Main Cache instance
|
49 |
+
*/
|
50 |
+
public $cache = null;
|
51 |
|
52 |
/**
|
53 |
* Main AWS_Main Instance
|
81 |
|
82 |
load_plugin_textdomain( 'aws', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
|
83 |
|
84 |
+
$this->includes();
|
85 |
+
|
86 |
+
add_action( 'init', array( $this, 'init' ), 0 );
|
87 |
|
88 |
}
|
89 |
|
94 |
include_once( 'includes/class-aws-versions.php' );
|
95 |
include_once( 'includes/class-aws-helpers.php' );
|
96 |
include_once( 'includes/class-aws-admin.php' );
|
97 |
+
include_once( 'includes/class-aws-cache.php' );
|
98 |
include_once( 'includes/class-aws-table.php' );
|
99 |
include_once( 'includes/class-aws-markup.php' );
|
100 |
include_once( 'includes/class-aws-search.php' );
|
112 |
return $markup->markup();
|
113 |
|
114 |
}
|
115 |
+
|
116 |
+
/*
|
117 |
+
* Init plugin classes
|
118 |
+
*/
|
119 |
+
public function init() {
|
120 |
+
$this->cache = AWS_Cache::factory();
|
121 |
+
}
|
122 |
|
123 |
/*
|
124 |
* Load assets for search form
|
assets/css/common.css
CHANGED
@@ -54,8 +54,7 @@
|
|
54 |
|
55 |
.aws-search-result {
|
56 |
position: absolute;
|
57 |
-
z-index:
|
58 |
-
z-index: 9999;
|
59 |
background: #fff;
|
60 |
width: 100%;
|
61 |
margin-top: -1px;
|
54 |
|
55 |
.aws-search-result {
|
56 |
position: absolute;
|
57 |
+
z-index: 9999999999999;
|
|
|
58 |
background: #fff;
|
59 |
width: 100%;
|
60 |
margin-top: -1px;
|
includes/class-aws-admin.php
CHANGED
@@ -120,6 +120,8 @@ class AWS_Admin {
|
|
120 |
update_option( 'aws_settings', $update_settings );
|
121 |
|
122 |
do_action( 'aws_settings_saved' );
|
|
|
|
|
123 |
|
124 |
}
|
125 |
|
120 |
update_option( 'aws_settings', $update_settings );
|
121 |
|
122 |
do_action( 'aws_settings_saved' );
|
123 |
+
|
124 |
+
do_action( 'aws_cache_clear' );
|
125 |
|
126 |
}
|
127 |
|
includes/class-aws-cache.php
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Cache' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plugin search
|
11 |
+
*/
|
12 |
+
class AWS_Cache {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var AWS_Cache Cache table name
|
16 |
+
*/
|
17 |
+
private $cache_table_name;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Return a singleton instance of the current class
|
21 |
+
*
|
22 |
+
* @return object
|
23 |
+
*/
|
24 |
+
public static function factory() {
|
25 |
+
static $instance = false;
|
26 |
+
|
27 |
+
if ( ! $instance ) {
|
28 |
+
$instance = new self();
|
29 |
+
$instance->setup();
|
30 |
+
}
|
31 |
+
|
32 |
+
return $instance;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Constructor
|
37 |
+
*/
|
38 |
+
public function __construct() {}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Setup actions and filters for all things settings
|
42 |
+
*/
|
43 |
+
public function setup() {
|
44 |
+
|
45 |
+
global $wpdb;
|
46 |
+
|
47 |
+
$this->cache_table_name = $wpdb->prefix . AWS_CACHE_TABLE_NAME;
|
48 |
+
|
49 |
+
add_action( 'aws_cache_clear', array( $this, 'clear_cache' ) );
|
50 |
+
add_action( 'wp_ajax_aws-clear-cache', array( $this, 'clear_cache' ) );
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Get caching option name
|
56 |
+
*/
|
57 |
+
public function get_cache_name( $s ) {
|
58 |
+
|
59 |
+
$cache_option_name = 'aws_search_term_' . $s;
|
60 |
+
|
61 |
+
if ( has_filter('wpml_current_language') ) {
|
62 |
+
$current_lang = apply_filters('wpml_current_language', NULL);
|
63 |
+
if ( $current_lang ) {
|
64 |
+
$cache_option_name = $cache_option_name . '_' . $current_lang;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
return $cache_option_name;
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
/*
|
73 |
+
* Check if cache table exist
|
74 |
+
*/
|
75 |
+
private function is_cache_table_not_exist() {
|
76 |
+
|
77 |
+
global $wpdb;
|
78 |
+
|
79 |
+
return ( $wpdb->get_var( "SHOW TABLES LIKE '{$this->cache_table_name}'" ) != $this->cache_table_name );
|
80 |
+
|
81 |
+
}
|
82 |
+
|
83 |
+
/*
|
84 |
+
* Create cache table
|
85 |
+
*/
|
86 |
+
private function create_cache_table() {
|
87 |
+
|
88 |
+
global $wpdb;
|
89 |
+
|
90 |
+
$charset_collate = $wpdb->get_charset_collate();
|
91 |
+
|
92 |
+
$sql = "CREATE TABLE {$this->cache_table_name} (
|
93 |
+
name VARCHAR(50) NOT NULL,
|
94 |
+
value LONGTEXT NOT NULL
|
95 |
+
) $charset_collate;";
|
96 |
+
|
97 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
98 |
+
dbDelta( $sql );
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
/*
|
103 |
+
* Insert data into cache table
|
104 |
+
*/
|
105 |
+
public function insert_into_cache_table( $cache_option_name, $result_array ) {
|
106 |
+
|
107 |
+
global $wpdb;
|
108 |
+
|
109 |
+
$values = $wpdb->prepare(
|
110 |
+
"(%s, %s)",
|
111 |
+
$cache_option_name, json_encode( $result_array )
|
112 |
+
);
|
113 |
+
|
114 |
+
$query = "INSERT IGNORE INTO {$this->cache_table_name}
|
115 |
+
(`name`, `value`)
|
116 |
+
VALUES $values
|
117 |
+
";
|
118 |
+
|
119 |
+
$wpdb->query( $query );
|
120 |
+
|
121 |
+
if ( $wpdb->last_error ) {
|
122 |
+
if ( $this->is_cache_table_not_exist() ) {
|
123 |
+
$this->create_cache_table();
|
124 |
+
}
|
125 |
+
}
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
/*
|
130 |
+
* Get data from cache table
|
131 |
+
*/
|
132 |
+
public function get_from_cache_table( $cache_option_name ) {
|
133 |
+
|
134 |
+
global $wpdb;
|
135 |
+
|
136 |
+
$result = '';
|
137 |
+
$where = $wpdb->prepare( " name LIKE %s", $cache_option_name );
|
138 |
+
|
139 |
+
$sql = "SELECT *
|
140 |
+
FROM
|
141 |
+
{$this->cache_table_name}
|
142 |
+
WHERE
|
143 |
+
{$where}
|
144 |
+
";
|
145 |
+
|
146 |
+
$cache_content = $wpdb->get_results( $sql, ARRAY_A );
|
147 |
+
|
148 |
+
if ( ! $wpdb->last_error ) {
|
149 |
+
if (!empty($cache_content) && !is_wp_error($cache_content) && is_array($cache_content)) {
|
150 |
+
$result = $cache_content[0]['value'];
|
151 |
+
}
|
152 |
+
} else {
|
153 |
+
if ( $this->is_cache_table_not_exist() ) {
|
154 |
+
$this->create_cache_table();
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
return $result;
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
/*
|
163 |
+
* Clear cached terms
|
164 |
+
*/
|
165 |
+
public function clear_cache() {
|
166 |
+
|
167 |
+
global $wpdb;
|
168 |
+
|
169 |
+
if ( ! $this->is_cache_table_not_exist() ) {
|
170 |
+
|
171 |
+
$terms = "aws_search_term_%";
|
172 |
+
$where = $wpdb->prepare( " name LIKE %s", $terms );
|
173 |
+
|
174 |
+
$sql = "DELETE FROM {$this->cache_table_name}
|
175 |
+
WHERE {$where}
|
176 |
+
";
|
177 |
+
|
178 |
+
$wpdb->query( $sql );
|
179 |
+
|
180 |
+
}
|
181 |
+
|
182 |
+
}
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
|
187 |
+
endif;
|
includes/class-aws-search-page.php
CHANGED
@@ -99,15 +99,16 @@ if ( ! class_exists( 'AWS_Search_Page' ) ) :
|
|
99 |
$search_query = $query->query_vars['s'];
|
100 |
|
101 |
$posts_array = aws_search( $search_query );
|
|
|
102 |
|
103 |
$query->found_posts = count( $posts_array['products'] );
|
104 |
-
$query->max_num_pages = ceil( count( $posts_array['products'] ) / $
|
105 |
|
106 |
$paged = $query->query_vars['paged'] ? $query->query_vars['paged'] : 1;
|
107 |
-
$offset = ( $paged > 1 ) ? $paged * $
|
108 |
|
109 |
|
110 |
-
$products = array_slice( $posts_array['products'], $offset, $
|
111 |
|
112 |
|
113 |
foreach ( $products as $post_array ) {
|
99 |
$search_query = $query->query_vars['s'];
|
100 |
|
101 |
$posts_array = aws_search( $search_query );
|
102 |
+
$posts_per_page = apply_filters( 'aws_posts_per_page', $query->get( 'posts_per_page' ) );
|
103 |
|
104 |
$query->found_posts = count( $posts_array['products'] );
|
105 |
+
$query->max_num_pages = ceil( count( $posts_array['products'] ) / $posts_per_page );
|
106 |
|
107 |
$paged = $query->query_vars['paged'] ? $query->query_vars['paged'] : 1;
|
108 |
+
$offset = ( $paged > 1 ) ? $paged * $posts_per_page - $posts_per_page : 0;
|
109 |
|
110 |
|
111 |
+
$products = array_slice( $posts_array['products'], $offset, $posts_per_page );
|
112 |
|
113 |
|
114 |
foreach ( $products as $post_array ) {
|
includes/class-aws-search.php
CHANGED
@@ -60,24 +60,9 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
60 |
|
61 |
}
|
62 |
|
63 |
-
|
64 |
-
*
|
65 |
*/
|
66 |
-
private function get_cache_name( $s ) {
|
67 |
-
|
68 |
-
$cache_option_name = 'aws_search_term_' . $s;
|
69 |
-
|
70 |
-
if ( has_filter('wpml_current_language') ) {
|
71 |
-
$current_lang = apply_filters('wpml_current_language', NULL);
|
72 |
-
if ( $current_lang ) {
|
73 |
-
$cache_option_name = $cache_option_name . '_' . $current_lang;
|
74 |
-
}
|
75 |
-
}
|
76 |
-
|
77 |
-
return $cache_option_name;
|
78 |
-
|
79 |
-
}
|
80 |
-
|
81 |
public function search( $keyword = '' ) {
|
82 |
|
83 |
global $wpdb;
|
@@ -90,16 +75,16 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
90 |
$s = str_replace( array( "\r", "\n" ), '', $s );
|
91 |
$s = str_replace( $special_chars, '', $s );
|
92 |
|
93 |
-
$cache_option_name =
|
94 |
-
|
95 |
if ( $cache === 'true' ) {
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
$cached_value
|
100 |
-
|
|
|
101 |
}
|
102 |
-
|
103 |
}
|
104 |
|
105 |
$show_cats = AWS()->get_settings( 'show_cats' );
|
@@ -147,7 +132,7 @@ if ( ! class_exists( 'AWS_Search' ) ) :
|
|
147 |
|
148 |
|
149 |
if ( $cache === 'true' ) {
|
150 |
-
|
151 |
}
|
152 |
|
153 |
|
60 |
|
61 |
}
|
62 |
|
63 |
+
/*
|
64 |
+
* Search
|
65 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
public function search( $keyword = '' ) {
|
67 |
|
68 |
global $wpdb;
|
75 |
$s = str_replace( array( "\r", "\n" ), '', $s );
|
76 |
$s = str_replace( $special_chars, '', $s );
|
77 |
|
78 |
+
$cache_option_name = AWS()->cache->get_cache_name( $s );
|
79 |
+
|
80 |
if ( $cache === 'true' ) {
|
81 |
+
$res = AWS()->cache->get_from_cache_table( $cache_option_name );
|
82 |
+
if ( $res ) {
|
83 |
+
$cached_value = json_decode( $res );
|
84 |
+
if ( $cached_value && ! empty( $cached_value ) ) {
|
85 |
+
return $cached_value;
|
86 |
+
}
|
87 |
}
|
|
|
88 |
}
|
89 |
|
90 |
$show_cats = AWS()->get_settings( 'show_cats' );
|
132 |
|
133 |
|
134 |
if ( $cache === 'true' ) {
|
135 |
+
AWS()->cache->insert_into_cache_table( $cache_option_name, $result_array );
|
136 |
}
|
137 |
|
138 |
|
includes/class-aws-table.php
CHANGED
@@ -12,7 +12,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
12 |
class AWS_Table {
|
13 |
|
14 |
/**
|
15 |
-
* @var
|
16 |
*/
|
17 |
private $table_name;
|
18 |
|
@@ -27,23 +27,24 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
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' ) );
|
32 |
-
|
33 |
add_action( 'create_term', array( &$this, 'term_changed' ), 10, 3 );
|
34 |
add_action( 'delete_term', array( &$this, 'term_changed' ), 10, 3 );
|
35 |
add_action( 'edit_term', array( &$this, 'term_changed' ), 10, 3 );
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
39 |
add_action( 'wp_ajax_aws-reindex', array( $this, 'reindex_table' ) );
|
40 |
|
41 |
add_action( 'aws_reindex_table', array( $this, 'reindex_table_job' ) );
|
42 |
|
43 |
add_action( 'wp_ajax_aws-cancel-index', array( $this, 'cancel_reindex' ) );
|
44 |
|
45 |
-
add_action( 'wp_ajax_aws-clear-cache', array( &$this, 'clear_cache' ) );
|
46 |
-
|
47 |
}
|
48 |
|
49 |
/*
|
@@ -127,7 +128,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
127 |
|
128 |
delete_option( 'aws_index_meta' );
|
129 |
|
130 |
-
|
131 |
|
132 |
update_option( 'aws_reindex_version', AWS_VERSION );
|
133 |
|
@@ -441,7 +442,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
441 |
|
442 |
$this->fill_table( $posts );
|
443 |
|
444 |
-
|
445 |
|
446 |
}
|
447 |
|
@@ -459,13 +460,21 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
459 |
/*
|
460 |
* Fires when products variations are changed
|
461 |
*/
|
462 |
-
public function variable_product_changed( $
|
463 |
|
464 |
global $wpdb;
|
465 |
|
|
|
|
|
466 |
if ( $this->is_table_not_exist() ) {
|
467 |
$this->create_table();
|
468 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
|
470 |
$wpdb->delete( $this->table_name, array( 'id' => $product_id ) );
|
471 |
|
@@ -481,7 +490,7 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
481 |
|
482 |
$this->fill_table( $posts );
|
483 |
|
484 |
-
|
485 |
|
486 |
}
|
487 |
|
@@ -495,23 +504,6 @@ if ( ! class_exists( 'AWS_Table' ) ) :
|
|
495 |
wp_send_json_success( 'Deleted!' );
|
496 |
}
|
497 |
|
498 |
-
/*
|
499 |
-
* Clear search cache
|
500 |
-
*/
|
501 |
-
public function clear_cache() {
|
502 |
-
|
503 |
-
global $wpdb;
|
504 |
-
|
505 |
-
$table_name = "aws_search_term_%";
|
506 |
-
|
507 |
-
$sql = "DELETE FROM $wpdb->options
|
508 |
-
WHERE option_name LIKE '{$table_name}'
|
509 |
-
";
|
510 |
-
|
511 |
-
$wpdb->query( $sql );
|
512 |
-
|
513 |
-
}
|
514 |
-
|
515 |
/*
|
516 |
* Extract terms from content
|
517 |
*/
|
12 |
class AWS_Table {
|
13 |
|
14 |
/**
|
15 |
+
* @var AWS_Table Index table name
|
16 |
*/
|
17 |
private $table_name;
|
18 |
|
27 |
|
28 |
add_action( 'wp_insert_post', array( $this, 'update_table' ), 10, 3 );
|
29 |
|
|
|
|
|
|
|
30 |
add_action( 'create_term', array( &$this, 'term_changed' ), 10, 3 );
|
31 |
add_action( 'delete_term', array( &$this, 'term_changed' ), 10, 3 );
|
32 |
add_action( 'edit_term', array( &$this, 'term_changed' ), 10, 3 );
|
33 |
+
|
34 |
+
if ( defined('WOOCOMMERCE_VERSION') ) {
|
35 |
+
if ( version_compare( WOOCOMMERCE_VERSION, '3.0', ">=" ) ) {
|
36 |
+
add_action( 'woocommerce_variable_product_sync_data', array( $this, 'variable_product_changed' ) );
|
37 |
+
} else {
|
38 |
+
add_action( 'woocommerce_variable_product_sync', array( $this, 'variable_product_changed' ), 10, 2 );
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
add_action( 'wp_ajax_aws-reindex', array( $this, 'reindex_table' ) );
|
43 |
|
44 |
add_action( 'aws_reindex_table', array( $this, 'reindex_table_job' ) );
|
45 |
|
46 |
add_action( 'wp_ajax_aws-cancel-index', array( $this, 'cancel_reindex' ) );
|
47 |
|
|
|
|
|
48 |
}
|
49 |
|
50 |
/*
|
128 |
|
129 |
delete_option( 'aws_index_meta' );
|
130 |
|
131 |
+
do_action('aws_cache_clear');
|
132 |
|
133 |
update_option( 'aws_reindex_version', AWS_VERSION );
|
134 |
|
442 |
|
443 |
$this->fill_table( $posts );
|
444 |
|
445 |
+
do_action('aws_cache_clear');
|
446 |
|
447 |
}
|
448 |
|
460 |
/*
|
461 |
* Fires when products variations are changed
|
462 |
*/
|
463 |
+
public function variable_product_changed( $product, $children = null ) {
|
464 |
|
465 |
global $wpdb;
|
466 |
|
467 |
+
$product_id = '';
|
468 |
+
|
469 |
if ( $this->is_table_not_exist() ) {
|
470 |
$this->create_table();
|
471 |
}
|
472 |
+
|
473 |
+
if ( is_object( $product ) ) {
|
474 |
+
$product_id = $product->get_id();
|
475 |
+
} else {
|
476 |
+
$product_id = $product;
|
477 |
+
}
|
478 |
|
479 |
$wpdb->delete( $this->table_name, array( 'id' => $product_id ) );
|
480 |
|
490 |
|
491 |
$this->fill_table( $posts );
|
492 |
|
493 |
+
do_action('aws_cache_clear');
|
494 |
|
495 |
}
|
496 |
|
504 |
wp_send_json_success( 'Deleted!' );
|
505 |
}
|
506 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
507 |
/*
|
508 |
* Extract terms from content
|
509 |
*/
|
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.9
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -75,6 +75,10 @@ Yep. This plugin is always compatible with the latest version of Woocommerce?
|
|
75 |
|
76 |
== Changelog ==
|
77 |
|
|
|
|
|
|
|
|
|
78 |
= 1.27 =
|
79 |
* Add option to show stock status in search results
|
80 |
* Add 'aws_special_chars' filter
|
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.9
|
7 |
+
Stable tag: 1.28
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
75 |
|
76 |
== Changelog ==
|
77 |
|
78 |
+
= 1.28 =
|
79 |
+
* Add caching table to store cached search result instead of store them in wp_options table
|
80 |
+
* Fix deprecated action 'woocommerce_variable_product_sync'
|
81 |
+
|
82 |
= 1.27 =
|
83 |
* Add option to show stock status in search results
|
84 |
* Add 'aws_special_chars' filter
|