Version Description
( 2021-06-07 ) = * Add - Woostify theme support * Dev - Fix search page filters
Download this release
Release Info
Developer | Mihail Barinov |
Plugin | Advanced Woo Search |
Version | 2.29 |
Comparing to | |
See all releases |
Code changes from version 2.28 to 2.29
- advanced-woo-search.php +340 -340
- assets/css/admin.css +684 -684
- assets/css/common-rtl.css +52 -52
- assets/css/common.css +532 -532
- assets/js/admin.js +193 -193
- assets/js/common.js +702 -702
- includes/admin/class-aws-admin-ajax.php +75 -75
- includes/admin/class-aws-admin-fields.php +368 -368
- includes/admin/class-aws-admin-meta-boxes.php +146 -146
- includes/admin/class-aws-admin-options.php +669 -669
- includes/admin/class-aws-admin-page-premium.php +310 -310
- includes/admin/class-aws-admin.php +272 -272
- includes/class-aws-cache.php +204 -204
- includes/class-aws-helpers.php +959 -959
- includes/class-aws-integrations.php +1949 -1937
- includes/class-aws-markup.php +136 -136
- includes/class-aws-order.php +583 -583
- includes/class-aws-plurals.php +188 -188
- includes/class-aws-search-page.php +589 -589
- includes/class-aws-search.php +812 -812
- includes/class-aws-table-data.php +476 -476
- includes/class-aws-table.php +619 -619
- includes/class-aws-tax-search.php +414 -414
- includes/class-aws-versions.php +415 -415
- includes/modules/bb-aws-search/class-aws-bb-module.php +44 -44
- includes/modules/bb-aws-search/includes/frontend.php +6 -6
- includes/modules/class-aws-um.php +269 -269
- includes/modules/class-aws-wcfm.php +197 -197
- includes/modules/class-aws-wholesale.php +225 -225
- includes/modules/class-aws-woof-filter.php +164 -164
- includes/modules/divi/class-divi-aws-module.php +51 -51
- includes/modules/divi/divi.css +3 -3
- includes/modules/elementor-widget/class-elementor-aws-init.php +202 -202
- includes/modules/elementor-widget/class-elementor-aws-widget.php +109 -109
- includes/modules/elementor-widget/elementor.css +11 -11
- includes/modules/gutenberg/aws-gutenberg-search-block.js +83 -83
- includes/modules/gutenberg/class-aws-gutenberg-init.php +121 -121
- includes/widget.php +79 -79
- languages/advanced-woo-search-de_DE.po +546 -546
- languages/advanced-woo-search-hu_HU.po +284 -284
- languages/advanced-woo-search-ru_RU.po +460 -502
advanced-woo-search.php
CHANGED
@@ -1,341 +1,341 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/*
|
4 |
-
Plugin Name: Advanced Woo Search
|
5 |
-
Description: Advance ajax WooCommerce product search.
|
6 |
-
Version: 2.
|
7 |
-
Author: ILLID
|
8 |
-
Author URI: https://advanced-woo-search.com/
|
9 |
-
Text Domain: advanced-woo-search
|
10 |
-
WC requires at least: 3.0.0
|
11 |
-
WC tested up to: 5.3.0
|
12 |
-
*/
|
13 |
-
|
14 |
-
|
15 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
16 |
-
exit;
|
17 |
-
}
|
18 |
-
|
19 |
-
if ( ! defined( 'AWS_FILE' ) ) {
|
20 |
-
define( 'AWS_FILE', __FILE__ );
|
21 |
-
}
|
22 |
-
|
23 |
-
if ( ! class_exists( 'AWS_Main' ) ) :
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Main plugin class
|
27 |
-
*
|
28 |
-
* @class AWS_Main
|
29 |
-
*/
|
30 |
-
final class AWS_Main {
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @var AWS_Main The single instance of the class
|
34 |
-
*/
|
35 |
-
protected static $_instance = null;
|
36 |
-
|
37 |
-
/**
|
38 |
-
* @var AWS_Main Array of all plugin data $data
|
39 |
-
*/
|
40 |
-
private $data = array();
|
41 |
-
|
42 |
-
/**
|
43 |
-
* @var AWS_Main Cache instance
|
44 |
-
*/
|
45 |
-
public $cache = null;
|
46 |
-
|
47 |
-
/**
|
48 |
-
* Main AWS_Main Instance
|
49 |
-
*
|
50 |
-
* Ensures only one instance of AWS_Main is loaded or can be loaded.
|
51 |
-
*
|
52 |
-
* @static
|
53 |
-
* @return AWS_Main - Main instance
|
54 |
-
*/
|
55 |
-
public static function instance() {
|
56 |
-
if ( is_null( self::$_instance ) ) {
|
57 |
-
self::$_instance = new self();
|
58 |
-
}
|
59 |
-
return self::$_instance;
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Constructor
|
64 |
-
*/
|
65 |
-
public function __construct() {
|
66 |
-
|
67 |
-
$this->define_constants();
|
68 |
-
|
69 |
-
$this->data['settings'] = get_option( 'aws_settings' );
|
70 |
-
|
71 |
-
add_filter( 'widget_text', 'do_shortcode' );
|
72 |
-
|
73 |
-
add_shortcode( 'aws_search_form', array( $this, 'markup' ) );
|
74 |
-
|
75 |
-
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
|
76 |
-
|
77 |
-
add_filter( 'plugin_action_links', array( $this, 'add_action_link' ), 10, 2 );
|
78 |
-
|
79 |
-
load_plugin_textdomain( 'advanced-woo-search', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
|
80 |
-
|
81 |
-
$this->includes();
|
82 |
-
|
83 |
-
add_action( 'init', array( $this, 'init' ), 1 );
|
84 |
-
|
85 |
-
add_filter( 'wcml_multi_currency_ajax_actions', array( $this, 'add_wpml_ajax_actions' ) );
|
86 |
-
|
87 |
-
if ( $this->get_settings('seamless') === 'true' ) {
|
88 |
-
add_filter( 'get_search_form', array( $this, 'markup' ), 999999 );
|
89 |
-
add_filter( 'get_product_search_form', array( $this, 'markup' ), 999999 );
|
90 |
-
}
|
91 |
-
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Define constants
|
96 |
-
*/
|
97 |
-
private function define_constants() {
|
98 |
-
|
99 |
-
$this->define( 'AWS_VERSION', '2.
|
100 |
-
|
101 |
-
$this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
|
102 |
-
$this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
|
103 |
-
|
104 |
-
$this->define( 'AWS_INDEX_TABLE_NAME', 'aws_index' );
|
105 |
-
$this->define( 'AWS_CACHE_TABLE_NAME', 'aws_cache' );
|
106 |
-
|
107 |
-
}
|
108 |
-
|
109 |
-
/**
|
110 |
-
* Include required core files used in admin and on the frontend.
|
111 |
-
*/
|
112 |
-
public function includes() {
|
113 |
-
|
114 |
-
include_once( 'includes/class-aws-helpers.php' );
|
115 |
-
include_once( 'includes/class-aws-versions.php' );
|
116 |
-
include_once( 'includes/class-aws-cache.php' );
|
117 |
-
include_once( 'includes/class-aws-plurals.php' );
|
118 |
-
include_once( 'includes/class-aws-table.php' );
|
119 |
-
include_once( 'includes/class-aws-table-data.php' );
|
120 |
-
include_once( 'includes/class-aws-markup.php' );
|
121 |
-
include_once( 'includes/class-aws-search.php' );
|
122 |
-
include_once( 'includes/class-aws-tax-search.php' );
|
123 |
-
include_once( 'includes/class-aws-search-page.php' );
|
124 |
-
include_once( 'includes/class-aws-order.php' );
|
125 |
-
include_once( 'includes/class-aws-integrations.php' );
|
126 |
-
include_once( 'includes/widget.php' );
|
127 |
-
|
128 |
-
// Admin
|
129 |
-
include_once( 'includes/admin/class-aws-admin.php' );
|
130 |
-
include_once( 'includes/admin/class-aws-admin-ajax.php' );
|
131 |
-
include_once( 'includes/admin/class-aws-admin-fields.php' );
|
132 |
-
include_once( 'includes/admin/class-aws-admin-options.php' );
|
133 |
-
include_once( 'includes/admin/class-aws-admin-meta-boxes.php' );
|
134 |
-
include_once( 'includes/admin/class-aws-admin-page-premium.php' );
|
135 |
-
|
136 |
-
}
|
137 |
-
|
138 |
-
/*
|
139 |
-
* Generate search box markup
|
140 |
-
*/
|
141 |
-
public function markup( $args = array() ) {
|
142 |
-
|
143 |
-
$markup = new AWS_Markup();
|
144 |
-
|
145 |
-
return $markup->markup();
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
/*
|
150 |
-
* Sort products
|
151 |
-
*/
|
152 |
-
public function order( $products, $order_by ) {
|
153 |
-
|
154 |
-
$order = new AWS_Order( $products, $order_by );
|
155 |
-
|
156 |
-
return $order->result();
|
157 |
-
|
158 |
-
}
|
159 |
-
|
160 |
-
/*
|
161 |
-
* Init plugin classes
|
162 |
-
*/
|
163 |
-
public function init() {
|
164 |
-
$this->cache = AWS_Cache::factory();
|
165 |
-
AWS_Integrations::instance();
|
166 |
-
}
|
167 |
-
|
168 |
-
/*
|
169 |
-
* Load assets for search form
|
170 |
-
*/
|
171 |
-
public function load_scripts() {
|
172 |
-
wp_enqueue_style( 'aws-style', AWS_URL . '/assets/css/common.css', array(), AWS_VERSION );
|
173 |
-
if ( is_rtl() ) {
|
174 |
-
wp_enqueue_style( 'aws-style-rtl', AWS_URL . '/assets/css/common-rtl.css', array(), AWS_VERSION );
|
175 |
-
}
|
176 |
-
wp_enqueue_script('aws-script', AWS_URL . '/assets/js/common.js', array('jquery'), AWS_VERSION, true);
|
177 |
-
wp_localize_script('aws-script', 'aws_vars', array(
|
178 |
-
'sale' => __('Sale!', 'advanced-woo-search'),
|
179 |
-
'sku' => __('SKU', 'advanced-woo-search') . ': ',
|
180 |
-
'showmore' => $this->get_settings('show_more_text') ? AWS_Helpers::translate( 'show_more_text', stripslashes( $this->get_settings('show_more_text') ) ) : __('View all results', 'advanced-woo-search'),
|
181 |
-
'noresults' => $this->get_settings('not_found_text') ? AWS_Helpers::translate( 'not_found_text', stripslashes( $this->get_settings('not_found_text') ) ) : __('Nothing found', 'advanced-woo-search'),
|
182 |
-
));
|
183 |
-
}
|
184 |
-
|
185 |
-
/*
|
186 |
-
* Add settings link to plugins
|
187 |
-
*/
|
188 |
-
public function add_action_link( $links, $file ) {
|
189 |
-
$plugin_base = plugin_basename( __FILE__ );
|
190 |
-
|
191 |
-
if ( $file == $plugin_base ) {
|
192 |
-
$setting_link = '<a href="' . admin_url('admin.php?page=aws-options') . '">'.esc_html__( 'Settings', 'advanced-woo-search' ).'</a>';
|
193 |
-
array_unshift( $links, $setting_link );
|
194 |
-
|
195 |
-
$premium_link = '<a href="' . admin_url( 'admin.php?page=aws-options&tab=premium' ) . '">'.esc_html__( 'Premium Version', 'advanced-woo-search' ).'</a>';
|
196 |
-
array_unshift( $links, $premium_link );
|
197 |
-
}
|
198 |
-
|
199 |
-
return $links;
|
200 |
-
}
|
201 |
-
|
202 |
-
/*
|
203 |
-
* Get plugin settings
|
204 |
-
*/
|
205 |
-
public function get_settings( $name ) {
|
206 |
-
$plugin_options = $this->data['settings'];
|
207 |
-
$return_value = isset( $plugin_options[ $name ] ) ? $plugin_options[ $name ] : '';
|
208 |
-
return $return_value;
|
209 |
-
}
|
210 |
-
|
211 |
-
/*
|
212 |
-
* Define constant if not already set
|
213 |
-
*/
|
214 |
-
private function define( $name, $value ) {
|
215 |
-
if ( ! defined( $name ) ) {
|
216 |
-
define( $name, $value );
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
/*
|
221 |
-
* Add ajax action to WPML plugin
|
222 |
-
*/
|
223 |
-
function add_wpml_ajax_actions( $actions ){
|
224 |
-
$actions[] = 'aws_action';
|
225 |
-
return $actions;
|
226 |
-
}
|
227 |
-
|
228 |
-
}
|
229 |
-
|
230 |
-
endif;
|
231 |
-
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Returns the main instance of AWS_Main
|
235 |
-
*
|
236 |
-
* @return AWS_Main
|
237 |
-
*/
|
238 |
-
function AWS() {
|
239 |
-
return AWS_Main::instance();
|
240 |
-
}
|
241 |
-
|
242 |
-
|
243 |
-
/*
|
244 |
-
* Check if WooCommerce is active
|
245 |
-
*/
|
246 |
-
if ( ! aws_is_plugin_active( 'advanced-woo-search-pro/advanced-woo-search-pro.php' ) ) {
|
247 |
-
if ( aws_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
248 |
-
add_action( 'woocommerce_loaded', 'aws_init' );
|
249 |
-
} else {
|
250 |
-
add_action( 'admin_notices', 'aws_install_woocommerce_admin_notice' );
|
251 |
-
}
|
252 |
-
}
|
253 |
-
|
254 |
-
/*
|
255 |
-
* Check whether the plugin is active by checking the active_plugins list.
|
256 |
-
*/
|
257 |
-
function aws_is_plugin_active( $plugin ) {
|
258 |
-
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || aws_is_plugin_active_for_network( $plugin );
|
259 |
-
}
|
260 |
-
|
261 |
-
|
262 |
-
/*
|
263 |
-
* Check whether the plugin is active for the entire network
|
264 |
-
*/
|
265 |
-
function aws_is_plugin_active_for_network( $plugin ) {
|
266 |
-
if ( !is_multisite() )
|
267 |
-
return false;
|
268 |
-
|
269 |
-
$plugins = get_site_option( 'active_sitewide_plugins' );
|
270 |
-
if ( isset($plugins[$plugin]) )
|
271 |
-
return true;
|
272 |
-
|
273 |
-
return false;
|
274 |
-
}
|
275 |
-
|
276 |
-
|
277 |
-
/*
|
278 |
-
* Error notice if WooCommerce plugin is not active
|
279 |
-
*/
|
280 |
-
function aws_install_woocommerce_admin_notice() {
|
281 |
-
?>
|
282 |
-
<div class="error">
|
283 |
-
<p><?php esc_html_e( 'Advanced Woo Search plugin is enabled but not effective. It requires WooCommerce in order to work.', 'advanced-woo-search' ); ?></p>
|
284 |
-
</div>
|
285 |
-
<?php
|
286 |
-
}
|
287 |
-
|
288 |
-
|
289 |
-
/*
|
290 |
-
* Activation hook
|
291 |
-
*/
|
292 |
-
register_activation_hook( __FILE__, 'aws_on_activation' );
|
293 |
-
function aws_on_activation() {
|
294 |
-
$hide_notice = get_option( 'aws_hide_welcome_notice' );
|
295 |
-
if ( ! $hide_notice ) {
|
296 |
-
$free_plugin_version = get_option( 'aws_plugin_ver' );
|
297 |
-
$pro_plugin_version = get_option( 'aws_pro_plugin_ver' );
|
298 |
-
$hide = 'false';
|
299 |
-
if ( $free_plugin_version || $pro_plugin_version ) {
|
300 |
-
$hide = 'true';
|
301 |
-
}
|
302 |
-
update_option( 'aws_hide_welcome_notice', $hide, false );
|
303 |
-
}
|
304 |
-
}
|
305 |
-
|
306 |
-
|
307 |
-
/*
|
308 |
-
* Init AWS plugin
|
309 |
-
*/
|
310 |
-
function aws_init() {
|
311 |
-
AWS();
|
312 |
-
}
|
313 |
-
|
314 |
-
|
315 |
-
if ( ! function_exists( 'aws_get_search_form' ) ) {
|
316 |
-
|
317 |
-
/**
|
318 |
-
* Returns search form html
|
319 |
-
*
|
320 |
-
* @since 1.47
|
321 |
-
* @return string
|
322 |
-
*/
|
323 |
-
function aws_get_search_form( $echo = true, $args = array() ) {
|
324 |
-
|
325 |
-
$form = '';
|
326 |
-
|
327 |
-
if ( ! aws_is_plugin_active( 'advanced-woo-search-pro/advanced-woo-search-pro.php' ) ) {
|
328 |
-
if ( aws_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
329 |
-
$form = AWS()->markup( $args );
|
330 |
-
}
|
331 |
-
}
|
332 |
-
|
333 |
-
if ( $echo ) {
|
334 |
-
echo $form;
|
335 |
-
} else {
|
336 |
-
return $form;
|
337 |
-
}
|
338 |
-
|
339 |
-
}
|
340 |
-
|
341 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
Plugin Name: Advanced Woo Search
|
5 |
+
Description: Advance ajax WooCommerce product search.
|
6 |
+
Version: 2.29
|
7 |
+
Author: ILLID
|
8 |
+
Author URI: https://advanced-woo-search.com/
|
9 |
+
Text Domain: advanced-woo-search
|
10 |
+
WC requires at least: 3.0.0
|
11 |
+
WC tested up to: 5.3.0
|
12 |
+
*/
|
13 |
+
|
14 |
+
|
15 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
16 |
+
exit;
|
17 |
+
}
|
18 |
+
|
19 |
+
if ( ! defined( 'AWS_FILE' ) ) {
|
20 |
+
define( 'AWS_FILE', __FILE__ );
|
21 |
+
}
|
22 |
+
|
23 |
+
if ( ! class_exists( 'AWS_Main' ) ) :
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Main plugin class
|
27 |
+
*
|
28 |
+
* @class AWS_Main
|
29 |
+
*/
|
30 |
+
final class AWS_Main {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* @var AWS_Main The single instance of the class
|
34 |
+
*/
|
35 |
+
protected static $_instance = null;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @var AWS_Main Array of all plugin data $data
|
39 |
+
*/
|
40 |
+
private $data = array();
|
41 |
+
|
42 |
+
/**
|
43 |
+
* @var AWS_Main Cache instance
|
44 |
+
*/
|
45 |
+
public $cache = null;
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Main AWS_Main Instance
|
49 |
+
*
|
50 |
+
* Ensures only one instance of AWS_Main is loaded or can be loaded.
|
51 |
+
*
|
52 |
+
* @static
|
53 |
+
* @return AWS_Main - Main instance
|
54 |
+
*/
|
55 |
+
public static function instance() {
|
56 |
+
if ( is_null( self::$_instance ) ) {
|
57 |
+
self::$_instance = new self();
|
58 |
+
}
|
59 |
+
return self::$_instance;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Constructor
|
64 |
+
*/
|
65 |
+
public function __construct() {
|
66 |
+
|
67 |
+
$this->define_constants();
|
68 |
+
|
69 |
+
$this->data['settings'] = get_option( 'aws_settings' );
|
70 |
+
|
71 |
+
add_filter( 'widget_text', 'do_shortcode' );
|
72 |
+
|
73 |
+
add_shortcode( 'aws_search_form', array( $this, 'markup' ) );
|
74 |
+
|
75 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
|
76 |
+
|
77 |
+
add_filter( 'plugin_action_links', array( $this, 'add_action_link' ), 10, 2 );
|
78 |
+
|
79 |
+
load_plugin_textdomain( 'advanced-woo-search', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
|
80 |
+
|
81 |
+
$this->includes();
|
82 |
+
|
83 |
+
add_action( 'init', array( $this, 'init' ), 1 );
|
84 |
+
|
85 |
+
add_filter( 'wcml_multi_currency_ajax_actions', array( $this, 'add_wpml_ajax_actions' ) );
|
86 |
+
|
87 |
+
if ( $this->get_settings('seamless') === 'true' ) {
|
88 |
+
add_filter( 'get_search_form', array( $this, 'markup' ), 999999 );
|
89 |
+
add_filter( 'get_product_search_form', array( $this, 'markup' ), 999999 );
|
90 |
+
}
|
91 |
+
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Define constants
|
96 |
+
*/
|
97 |
+
private function define_constants() {
|
98 |
+
|
99 |
+
$this->define( 'AWS_VERSION', '2.29' );
|
100 |
+
|
101 |
+
$this->define( 'AWS_DIR', plugin_dir_path( AWS_FILE ) );
|
102 |
+
$this->define( 'AWS_URL', plugin_dir_url( AWS_FILE ) );
|
103 |
+
|
104 |
+
$this->define( 'AWS_INDEX_TABLE_NAME', 'aws_index' );
|
105 |
+
$this->define( 'AWS_CACHE_TABLE_NAME', 'aws_cache' );
|
106 |
+
|
107 |
+
}
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Include required core files used in admin and on the frontend.
|
111 |
+
*/
|
112 |
+
public function includes() {
|
113 |
+
|
114 |
+
include_once( 'includes/class-aws-helpers.php' );
|
115 |
+
include_once( 'includes/class-aws-versions.php' );
|
116 |
+
include_once( 'includes/class-aws-cache.php' );
|
117 |
+
include_once( 'includes/class-aws-plurals.php' );
|
118 |
+
include_once( 'includes/class-aws-table.php' );
|
119 |
+
include_once( 'includes/class-aws-table-data.php' );
|
120 |
+
include_once( 'includes/class-aws-markup.php' );
|
121 |
+
include_once( 'includes/class-aws-search.php' );
|
122 |
+
include_once( 'includes/class-aws-tax-search.php' );
|
123 |
+
include_once( 'includes/class-aws-search-page.php' );
|
124 |
+
include_once( 'includes/class-aws-order.php' );
|
125 |
+
include_once( 'includes/class-aws-integrations.php' );
|
126 |
+
include_once( 'includes/widget.php' );
|
127 |
+
|
128 |
+
// Admin
|
129 |
+
include_once( 'includes/admin/class-aws-admin.php' );
|
130 |
+
include_once( 'includes/admin/class-aws-admin-ajax.php' );
|
131 |
+
include_once( 'includes/admin/class-aws-admin-fields.php' );
|
132 |
+
include_once( 'includes/admin/class-aws-admin-options.php' );
|
133 |
+
include_once( 'includes/admin/class-aws-admin-meta-boxes.php' );
|
134 |
+
include_once( 'includes/admin/class-aws-admin-page-premium.php' );
|
135 |
+
|
136 |
+
}
|
137 |
+
|
138 |
+
/*
|
139 |
+
* Generate search box markup
|
140 |
+
*/
|
141 |
+
public function markup( $args = array() ) {
|
142 |
+
|
143 |
+
$markup = new AWS_Markup();
|
144 |
+
|
145 |
+
return $markup->markup();
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
/*
|
150 |
+
* Sort products
|
151 |
+
*/
|
152 |
+
public function order( $products, $order_by ) {
|
153 |
+
|
154 |
+
$order = new AWS_Order( $products, $order_by );
|
155 |
+
|
156 |
+
return $order->result();
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
/*
|
161 |
+
* Init plugin classes
|
162 |
+
*/
|
163 |
+
public function init() {
|
164 |
+
$this->cache = AWS_Cache::factory();
|
165 |
+
AWS_Integrations::instance();
|
166 |
+
}
|
167 |
+
|
168 |
+
/*
|
169 |
+
* Load assets for search form
|
170 |
+
*/
|
171 |
+
public function load_scripts() {
|
172 |
+
wp_enqueue_style( 'aws-style', AWS_URL . '/assets/css/common.css', array(), AWS_VERSION );
|
173 |
+
if ( is_rtl() ) {
|
174 |
+
wp_enqueue_style( 'aws-style-rtl', AWS_URL . '/assets/css/common-rtl.css', array(), AWS_VERSION );
|
175 |
+
}
|
176 |
+
wp_enqueue_script('aws-script', AWS_URL . '/assets/js/common.js', array('jquery'), AWS_VERSION, true);
|
177 |
+
wp_localize_script('aws-script', 'aws_vars', array(
|
178 |
+
'sale' => __('Sale!', 'advanced-woo-search'),
|
179 |
+
'sku' => __('SKU', 'advanced-woo-search') . ': ',
|
180 |
+
'showmore' => $this->get_settings('show_more_text') ? AWS_Helpers::translate( 'show_more_text', stripslashes( $this->get_settings('show_more_text') ) ) : __('View all results', 'advanced-woo-search'),
|
181 |
+
'noresults' => $this->get_settings('not_found_text') ? AWS_Helpers::translate( 'not_found_text', stripslashes( $this->get_settings('not_found_text') ) ) : __('Nothing found', 'advanced-woo-search'),
|
182 |
+
));
|
183 |
+
}
|
184 |
+
|
185 |
+
/*
|
186 |
+
* Add settings link to plugins
|
187 |
+
*/
|
188 |
+
public function add_action_link( $links, $file ) {
|
189 |
+
$plugin_base = plugin_basename( __FILE__ );
|
190 |
+
|
191 |
+
if ( $file == $plugin_base ) {
|
192 |
+
$setting_link = '<a href="' . admin_url('admin.php?page=aws-options') . '">'.esc_html__( 'Settings', 'advanced-woo-search' ).'</a>';
|
193 |
+
array_unshift( $links, $setting_link );
|
194 |
+
|
195 |
+
$premium_link = '<a href="' . admin_url( 'admin.php?page=aws-options&tab=premium' ) . '">'.esc_html__( 'Premium Version', 'advanced-woo-search' ).'</a>';
|
196 |
+
array_unshift( $links, $premium_link );
|
197 |
+
}
|
198 |
+
|
199 |
+
return $links;
|
200 |
+
}
|
201 |
+
|
202 |
+
/*
|
203 |
+
* Get plugin settings
|
204 |
+
*/
|
205 |
+
public function get_settings( $name ) {
|
206 |
+
$plugin_options = $this->data['settings'];
|
207 |
+
$return_value = isset( $plugin_options[ $name ] ) ? $plugin_options[ $name ] : '';
|
208 |
+
return $return_value;
|
209 |
+
}
|
210 |
+
|
211 |
+
/*
|
212 |
+
* Define constant if not already set
|
213 |
+
*/
|
214 |
+
private function define( $name, $value ) {
|
215 |
+
if ( ! defined( $name ) ) {
|
216 |
+
define( $name, $value );
|
217 |
+
}
|
218 |
+
}
|
219 |
+
|
220 |
+
/*
|
221 |
+
* Add ajax action to WPML plugin
|
222 |
+
*/
|
223 |
+
function add_wpml_ajax_actions( $actions ){
|
224 |
+
$actions[] = 'aws_action';
|
225 |
+
return $actions;
|
226 |
+
}
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
endif;
|
231 |
+
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Returns the main instance of AWS_Main
|
235 |
+
*
|
236 |
+
* @return AWS_Main
|
237 |
+
*/
|
238 |
+
function AWS() {
|
239 |
+
return AWS_Main::instance();
|
240 |
+
}
|
241 |
+
|
242 |
+
|
243 |
+
/*
|
244 |
+
* Check if WooCommerce is active
|
245 |
+
*/
|
246 |
+
if ( ! aws_is_plugin_active( 'advanced-woo-search-pro/advanced-woo-search-pro.php' ) ) {
|
247 |
+
if ( aws_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
248 |
+
add_action( 'woocommerce_loaded', 'aws_init' );
|
249 |
+
} else {
|
250 |
+
add_action( 'admin_notices', 'aws_install_woocommerce_admin_notice' );
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
/*
|
255 |
+
* Check whether the plugin is active by checking the active_plugins list.
|
256 |
+
*/
|
257 |
+
function aws_is_plugin_active( $plugin ) {
|
258 |
+
return in_array( $plugin, (array) get_option( 'active_plugins', array() ) ) || aws_is_plugin_active_for_network( $plugin );
|
259 |
+
}
|
260 |
+
|
261 |
+
|
262 |
+
/*
|
263 |
+
* Check whether the plugin is active for the entire network
|
264 |
+
*/
|
265 |
+
function aws_is_plugin_active_for_network( $plugin ) {
|
266 |
+
if ( !is_multisite() )
|
267 |
+
return false;
|
268 |
+
|
269 |
+
$plugins = get_site_option( 'active_sitewide_plugins' );
|
270 |
+
if ( isset($plugins[$plugin]) )
|
271 |
+
return true;
|
272 |
+
|
273 |
+
return false;
|
274 |
+
}
|
275 |
+
|
276 |
+
|
277 |
+
/*
|
278 |
+
* Error notice if WooCommerce plugin is not active
|
279 |
+
*/
|
280 |
+
function aws_install_woocommerce_admin_notice() {
|
281 |
+
?>
|
282 |
+
<div class="error">
|
283 |
+
<p><?php esc_html_e( 'Advanced Woo Search plugin is enabled but not effective. It requires WooCommerce in order to work.', 'advanced-woo-search' ); ?></p>
|
284 |
+
</div>
|
285 |
+
<?php
|
286 |
+
}
|
287 |
+
|
288 |
+
|
289 |
+
/*
|
290 |
+
* Activation hook
|
291 |
+
*/
|
292 |
+
register_activation_hook( __FILE__, 'aws_on_activation' );
|
293 |
+
function aws_on_activation() {
|
294 |
+
$hide_notice = get_option( 'aws_hide_welcome_notice' );
|
295 |
+
if ( ! $hide_notice ) {
|
296 |
+
$free_plugin_version = get_option( 'aws_plugin_ver' );
|
297 |
+
$pro_plugin_version = get_option( 'aws_pro_plugin_ver' );
|
298 |
+
$hide = 'false';
|
299 |
+
if ( $free_plugin_version || $pro_plugin_version ) {
|
300 |
+
$hide = 'true';
|
301 |
+
}
|
302 |
+
update_option( 'aws_hide_welcome_notice', $hide, false );
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
|
307 |
+
/*
|
308 |
+
* Init AWS plugin
|
309 |
+
*/
|
310 |
+
function aws_init() {
|
311 |
+
AWS();
|
312 |
+
}
|
313 |
+
|
314 |
+
|
315 |
+
if ( ! function_exists( 'aws_get_search_form' ) ) {
|
316 |
+
|
317 |
+
/**
|
318 |
+
* Returns search form html
|
319 |
+
*
|
320 |
+
* @since 1.47
|
321 |
+
* @return string
|
322 |
+
*/
|
323 |
+
function aws_get_search_form( $echo = true, $args = array() ) {
|
324 |
+
|
325 |
+
$form = '';
|
326 |
+
|
327 |
+
if ( ! aws_is_plugin_active( 'advanced-woo-search-pro/advanced-woo-search-pro.php' ) ) {
|
328 |
+
if ( aws_is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
|
329 |
+
$form = AWS()->markup( $args );
|
330 |
+
}
|
331 |
+
}
|
332 |
+
|
333 |
+
if ( $echo ) {
|
334 |
+
echo $form;
|
335 |
+
} else {
|
336 |
+
return $form;
|
337 |
+
}
|
338 |
+
|
339 |
+
}
|
340 |
+
|
341 |
}
|
assets/css/admin.css
CHANGED
@@ -1,685 +1,685 @@
|
|
1 |
-
.sortable-container {
|
2 |
-
width: 200px;
|
3 |
-
padding: 0;
|
4 |
-
float: left;
|
5 |
-
margin-right: 10px;
|
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 {
|
17 |
-
border: 1px solid #C7C4C4;
|
18 |
-
background: #fff7f7;
|
19 |
-
list-style-type: none;
|
20 |
-
margin: 0;
|
21 |
-
padding: 5px;
|
22 |
-
margin-right: 10px;
|
23 |
-
min-height: 180px;
|
24 |
-
}
|
25 |
-
|
26 |
-
.sti-sortable.enabled {
|
27 |
-
background: #ddf0dc;
|
28 |
-
}
|
29 |
-
|
30 |
-
.sti-sortable li.sti-btn,
|
31 |
-
.sti-sortable li.highlight,
|
32 |
-
.sti-sortable li#excerpt {
|
33 |
-
display: inline-block;
|
34 |
-
/*float: left;*/
|
35 |
-
width: 100%;
|
36 |
-
height: auto;
|
37 |
-
margin: 0 3px 3px 0;
|
38 |
-
cursor: pointer;
|
39 |
-
background: #F1F1F1;
|
40 |
-
border: 1px solid #C7C4C4;
|
41 |
-
text-align: center;
|
42 |
-
padding: 8px 0;
|
43 |
-
text-transform: capitalize;
|
44 |
-
}
|
45 |
-
|
46 |
-
.sti-sortable li.highlight {
|
47 |
-
background: #fff;
|
48 |
-
width: 100%;
|
49 |
-
height: 36px;
|
50 |
-
padding: 0;
|
51 |
-
border: 1px dotted #ccc;
|
52 |
-
}
|
53 |
-
|
54 |
-
.nav-tab.premium-tab,
|
55 |
-
.nav-tab[href*="page=aws-options&tab=premium"]{
|
56 |
-
background: #FFF7C7;
|
57 |
-
}
|
58 |
-
|
59 |
-
.nav-tab.premium-tab:hover,
|
60 |
-
.nav-tab[href*="page=aws-options&tab=premium"]:hover {
|
61 |
-
background: #fff;
|
62 |
-
}
|
63 |
-
|
64 |
-
.wp-submenu .current a[href*="page=aws-options&tab=premium"] span,
|
65 |
-
.wp-submenu a[href*="page=aws-options&tab=premium"]:hover span {
|
66 |
-
color: rgb(255, 255, 91) !important;
|
67 |
-
}
|
68 |
-
|
69 |
-
/* Reindex button */
|
70 |
-
#aws-reindex {
|
71 |
-
display: inline-block;
|
72 |
-
}
|
73 |
-
|
74 |
-
#aws-reindex .loader {
|
75 |
-
display: none;
|
76 |
-
width: 20px;
|
77 |
-
height: 20px;
|
78 |
-
background: url('../img/loader-1.GIF') no-repeat 50% 50%;
|
79 |
-
margin-left: 15px;
|
80 |
-
margin-top: 4px;
|
81 |
-
}
|
82 |
-
|
83 |
-
#aws-reindex .reindex-progress,
|
84 |
-
#aws-reindex .reindex-notice {
|
85 |
-
display: none;
|
86 |
-
margin-left: 15px;
|
87 |
-
position: relative;
|
88 |
-
top: -5px;
|
89 |
-
font-size: 13px;
|
90 |
-
font-weight: bold;
|
91 |
-
}
|
92 |
-
|
93 |
-
#aws-reindex .reindex-notice {
|
94 |
-
font-weight: normal;
|
95 |
-
}
|
96 |
-
|
97 |
-
#aws-reindex.loading .loader,
|
98 |
-
#aws-reindex.loading .reindex-progress,
|
99 |
-
#aws-reindex.loading .reindex-notice {
|
100 |
-
display: inline-block;
|
101 |
-
}
|
102 |
-
|
103 |
-
#aws_form .aws-heading {
|
104 |
-
margin-right: -40px;
|
105 |
-
}
|
106 |
-
|
107 |
-
#aws_form select {
|
108 |
-
min-width: 170px;
|
109 |
-
display: block;
|
110 |
-
}
|
111 |
-
|
112 |
-
/* Image select option */
|
113 |
-
#aws_form .img-select {
|
114 |
-
position: relative;
|
115 |
-
font-size: 0;
|
116 |
-
list-style: none;
|
117 |
-
max-width: 400px;
|
118 |
-
}
|
119 |
-
|
120 |
-
#aws_form .img-select .option {
|
121 |
-
display: block;
|
122 |
-
position: relative;
|
123 |
-
vertical-align: top;
|
124 |
-
height: 36px;
|
125 |
-
width: 400px;
|
126 |
-
margin: 0 0 16px;
|
127 |
-
}
|
128 |
-
|
129 |
-
#aws_form .img-select .option input {
|
130 |
-
width: 100%;
|
131 |
-
height: 100%;
|
132 |
-
position: absolute;
|
133 |
-
left: 0;
|
134 |
-
top: 0;
|
135 |
-
z-index: 2;
|
136 |
-
cursor: pointer;
|
137 |
-
opacity: 0;
|
138 |
-
}
|
139 |
-
#aws_form .img-select .option input:before,
|
140 |
-
#aws_form .img-select .option input:checked:before{
|
141 |
-
display: none;
|
142 |
-
}
|
143 |
-
|
144 |
-
#aws_form .img-select .option .ico {
|
145 |
-
display: block;
|
146 |
-
width: 100%;
|
147 |
-
height: 100%;
|
148 |
-
margin: 0 auto;
|
149 |
-
background-size: contain !important;
|
150 |
-
border:2px solid transparent;
|
151 |
-
border-radius: 5px;
|
152 |
-
}
|
153 |
-
|
154 |
-
#aws_form .img-select .option input:checked + .ico {
|
155 |
-
border-color: rgba(0,0,0,0.6);
|
156 |
-
}
|
157 |
-
|
158 |
-
|
159 |
-
/* Premium tab */
|
160 |
-
#aws_form .b-compare .column {
|
161 |
-
width: 50%;
|
162 |
-
float: left;
|
163 |
-
}
|
164 |
-
|
165 |
-
#aws_form .b-compare .column p {
|
166 |
-
font-size: 14px;
|
167 |
-
border-bottom: 1px solid #ccc;
|
168 |
-
padding-bottom: 4px;
|
169 |
-
}
|
170 |
-
|
171 |
-
#aws_form .description.activation {
|
172 |
-
font-size: 14px;
|
173 |
-
line-height: 1.5;
|
174 |
-
font-style: normal;
|
175 |
-
}
|
176 |
-
|
177 |
-
#aws_form .description.activation .list {
|
178 |
-
padding-top: 2px;
|
179 |
-
}
|
180 |
-
|
181 |
-
|
182 |
-
h1.aws-instance-name {
|
183 |
-
position: relative;
|
184 |
-
padding-bottom: 20px;
|
185 |
-
padding-right: 20px;
|
186 |
-
display: inline-block;
|
187 |
-
cursor: pointer;
|
188 |
-
}
|
189 |
-
|
190 |
-
.aws-instance-shortcode {
|
191 |
-
display: inline-block;
|
192 |
-
background: #fff;
|
193 |
-
padding: 4px;
|
194 |
-
margin-left: 20px;
|
195 |
-
font-size: 14px;
|
196 |
-
font-weight: 600;
|
197 |
-
position: relative;
|
198 |
-
top: -4px;
|
199 |
-
}
|
200 |
-
|
201 |
-
|
202 |
-
/* Table */
|
203 |
-
.aws-table {
|
204 |
-
margin: 20px 0 10px;
|
205 |
-
}
|
206 |
-
|
207 |
-
.aws-table tr:nth-child(odd) td {
|
208 |
-
background: #f9f9f9;
|
209 |
-
}
|
210 |
-
|
211 |
-
.aws-table .aws-name {
|
212 |
-
font-weight: 700;
|
213 |
-
}
|
214 |
-
|
215 |
-
.aws-table .aws-current-filter {
|
216 |
-
color: #b00000;
|
217 |
-
margin-left: 8px;
|
218 |
-
font-size: 12px;
|
219 |
-
}
|
220 |
-
|
221 |
-
.aws-table th {
|
222 |
-
padding: 9px 7px!important;
|
223 |
-
vertical-align: middle;
|
224 |
-
}
|
225 |
-
|
226 |
-
.aws-table td {
|
227 |
-
vertical-align: middle;
|
228 |
-
padding: 7px;
|
229 |
-
line-height: 2em;
|
230 |
-
}
|
231 |
-
|
232 |
-
.aws-table .aws-actions a {
|
233 |
-
display: block;
|
234 |
-
text-indent: -9999px;
|
235 |
-
position: relative;
|
236 |
-
padding: 0!important;
|
237 |
-
height: 2em!important;
|
238 |
-
min-height: 2em!important;
|
239 |
-
width: 2em;
|
240 |
-
margin-left: 10px;
|
241 |
-
}
|
242 |
-
|
243 |
-
.aws-table .aws-actions a:after {
|
244 |
-
speak: none;
|
245 |
-
font-weight: 400;
|
246 |
-
font-variant: normal;
|
247 |
-
text-transform: none;
|
248 |
-
-webkit-font-smoothing: antialiased;
|
249 |
-
margin: 0;
|
250 |
-
text-indent: 0;
|
251 |
-
position: absolute;
|
252 |
-
top: 0;
|
253 |
-
left: 0;
|
254 |
-
width: 100%;
|
255 |
-
height: 100%;
|
256 |
-
text-align: center;
|
257 |
-
font-family: Dashicons;
|
258 |
-
line-height: 1.85;
|
259 |
-
}
|
260 |
-
|
261 |
-
.aws-table .aws-actions a.edit:after {
|
262 |
-
content: "";
|
263 |
-
}
|
264 |
-
|
265 |
-
.aws-table .aws-actions a.delete:after {
|
266 |
-
content: "";
|
267 |
-
}
|
268 |
-
|
269 |
-
.aws-table .aws-actions a.delete:hover:after {
|
270 |
-
background: rgba(255, 0, 0, 0.2);
|
271 |
-
}
|
272 |
-
|
273 |
-
.aws-table .aws-actions a.copy:after {
|
274 |
-
content: "";
|
275 |
-
}
|
276 |
-
|
277 |
-
.aws-insert-instance {
|
278 |
-
margin: 20px 0;
|
279 |
-
|
280 |
-
}
|
281 |
-
|
282 |
-
.aws-table.aws-table-sources {
|
283 |
-
margin: 10px 0 10px;
|
284 |
-
width: 500px;
|
285 |
-
}
|
286 |
-
|
287 |
-
.aws-table.aws-table-sources th.aws-actions {
|
288 |
-
width: 60px;
|
289 |
-
}
|
290 |
-
.aws-table.aws-table-sources th.aws-active {
|
291 |
-
width: 30px;
|
292 |
-
}
|
293 |
-
|
294 |
-
.aws-table.aws-table-sources td.aws-active {
|
295 |
-
text-align: center;
|
296 |
-
}
|
297 |
-
|
298 |
-
.aws-table.aws-table-sources td.aws-active .aws-yes,
|
299 |
-
.aws-table.aws-table-sources td.aws-active .aws-no,
|
300 |
-
.aws-table.aws-table-sources td.aws-active .aws-disabled {
|
301 |
-
background-color: #26CC06;
|
302 |
-
padding: 1px 7px;
|
303 |
-
color: #fff;
|
304 |
-
border-radius: 4px;
|
305 |
-
position: relative;
|
306 |
-
cursor: pointer;
|
307 |
-
}
|
308 |
-
|
309 |
-
.aws-table.aws-table-sources td.aws-active .aws-disabled {
|
310 |
-
background-color: #808080;
|
311 |
-
cursor: default;
|
312 |
-
}
|
313 |
-
|
314 |
-
.aws-table.aws-table-sources td.aws-active .aws-no {
|
315 |
-
background-color: #CC0606;
|
316 |
-
}
|
317 |
-
|
318 |
-
.aws-table.aws-table-sources td.aws-active .aws-yes,
|
319 |
-
.aws-table.aws-table-sources td.aws-active .aws-disabled,
|
320 |
-
.aws-table.aws-table-sources td.aws-active.active .aws-no {
|
321 |
-
display: none;
|
322 |
-
}
|
323 |
-
|
324 |
-
.aws-table.aws-table-sources td.aws-active.active .aws-yes {
|
325 |
-
display: inline;
|
326 |
-
}
|
327 |
-
|
328 |
-
.aws-table.aws-table-sources td.aws-active.disabled .aws-disabled {
|
329 |
-
display: inline !important;
|
330 |
-
}
|
331 |
-
|
332 |
-
.aws-table.aws-table-sources td.aws-active.disabled .aws-yes,
|
333 |
-
.aws-table.aws-table-sources td.aws-active.disabled .aws-no {
|
334 |
-
display: none;
|
335 |
-
}
|
336 |
-
|
337 |
-
.aws-table.aws-table-sources td.aws-active:after {
|
338 |
-
content: "";
|
339 |
-
display: none;
|
340 |
-
margin: 0 auto;
|
341 |
-
width: 20px;
|
342 |
-
height: 20px;
|
343 |
-
background: url('../img/loader-2.gif') no-repeat 50% 50%;
|
344 |
-
}
|
345 |
-
|
346 |
-
.aws-table.aws-table-sources td.aws-active.loading .aws-yes,
|
347 |
-
.aws-table.aws-table-sources td.aws-active.loading .aws-no {
|
348 |
-
display: none;
|
349 |
-
}
|
350 |
-
|
351 |
-
.aws-table.aws-table-sources td.aws-active.loading:after {
|
352 |
-
display: block;
|
353 |
-
}
|
354 |
-
|
355 |
-
.aws-table.aws-table-sources td.aws-name {
|
356 |
-
font-weight: 400;
|
357 |
-
}
|
358 |
-
|
359 |
-
/* Premium tab */
|
360 |
-
#aws_form.form-tab-premium .submit {
|
361 |
-
display: none;
|
362 |
-
}
|
363 |
-
|
364 |
-
#aws_form .free-pro-table *,
|
365 |
-
#aws_form .free-pro-table *:before,
|
366 |
-
#aws_form .free-pro-table *:after {
|
367 |
-
-webkit-box-sizing: border-box;
|
368 |
-
-moz-box-sizing: border-box;
|
369 |
-
box-sizing: border-box;
|
370 |
-
}
|
371 |
-
|
372 |
-
#aws_form .free-pro-table {
|
373 |
-
background: #fff;
|
374 |
-
max-width: 900px;
|
375 |
-
margin: 50px auto 20px;
|
376 |
-
}
|
377 |
-
|
378 |
-
#aws_form .free-pro-table b {
|
379 |
-
font-weight: bold;
|
380 |
-
}
|
381 |
-
|
382 |
-
#aws_form .free-pro-table td,
|
383 |
-
#aws_form .free-pro-table th {
|
384 |
-
margin-bottom: 0;
|
385 |
-
padding: 15px 10px;
|
386 |
-
line-height: 1.3;
|
387 |
-
vertical-align: middle;
|
388 |
-
}
|
389 |
-
|
390 |
-
#aws_form .free-pro-table td.center,
|
391 |
-
#aws_form .free-pro-table th.center {
|
392 |
-
text-align: center;
|
393 |
-
}
|
394 |
-
|
395 |
-
#aws_form .free-pro-table td h3 {
|
396 |
-
margin: 0 0 6px;
|
397 |
-
}
|
398 |
-
|
399 |
-
#aws_form .free-pro-table .yes,
|
400 |
-
#aws_form .free-pro-table .no {
|
401 |
-
text-align: center;
|
402 |
-
width: 10%;
|
403 |
-
padding: 0;
|
404 |
-
}
|
405 |
-
|
406 |
-
#aws_form .free-pro-table.bordered,
|
407 |
-
#aws_form .free-pro-table.bordered td,
|
408 |
-
#aws_form .free-pro-table.bordered th {
|
409 |
-
border: 1px solid #e0e0e0;
|
410 |
-
border-collapse: collapse;
|
411 |
-
}
|
412 |
-
|
413 |
-
#aws_form .free-pro-table .icon-before {
|
414 |
-
margin: 0 auto;
|
415 |
-
display: inline-block;
|
416 |
-
}
|
417 |
-
|
418 |
-
#aws_form .free-pro-table .yes .icon-before:before,
|
419 |
-
#aws_form .free-pro-table .no .icon-before:before {
|
420 |
-
height: 35px;
|
421 |
-
width: 35px;
|
422 |
-
content: '';
|
423 |
-
display: block;
|
424 |
-
position: relative;
|
425 |
-
top: 0;
|
426 |
-
background-size: contain !important;
|
427 |
-
}
|
428 |
-
|
429 |
-
#aws_form .free-pro-table .yes .icon-before:before {
|
430 |
-
height: 40px;
|
431 |
-
width: 40px;
|
432 |
-
}
|
433 |
-
|
434 |
-
#aws_form .free-pro-table .yes .icon-before:before {
|
435 |
-
background: url(../img/yes.svg) no-repeat 50% 50%;
|
436 |
-
}
|
437 |
-
|
438 |
-
#aws_form .free-pro-table .no .icon-before:before {
|
439 |
-
background: url(../img/no.svg) no-repeat 50% 50%;
|
440 |
-
}
|
441 |
-
|
442 |
-
#aws_form .links {
|
443 |
-
margin: 5px 0;
|
444 |
-
}
|
445 |
-
|
446 |
-
#aws_form .links .links-title {
|
447 |
-
display: inline-block;
|
448 |
-
}
|
449 |
-
|
450 |
-
#aws_form .links ul {
|
451 |
-
display: inline-block;
|
452 |
-
margin: 0 0 0 10px;
|
453 |
-
}
|
454 |
-
|
455 |
-
#aws_form .links ul li {
|
456 |
-
display: inline-block;
|
457 |
-
margin: 0 5px;
|
458 |
-
}
|
459 |
-
|
460 |
-
#aws_form .links ul li a {
|
461 |
-
color: #7f54b3;
|
462 |
-
}
|
463 |
-
|
464 |
-
#aws_form .buy-premium {
|
465 |
-
width: 500px;
|
466 |
-
margin: 20px auto 40px;
|
467 |
-
}
|
468 |
-
|
469 |
-
#aws_form .buy-premium a {
|
470 |
-
position: relative;
|
471 |
-
display: block;
|
472 |
-
background-color: #7f54b3;
|
473 |
-
color: #fff;
|
474 |
-
border-radius: 6px;
|
475 |
-
padding: 16px 15px;
|
476 |
-
text-decoration: none;
|
477 |
-
}
|
478 |
-
|
479 |
-
#aws_form .buy-premium a:hover {
|
480 |
-
background-color: #6f3eb0;
|
481 |
-
}
|
482 |
-
|
483 |
-
#aws_form .buy-premium a:after {
|
484 |
-
background: url(../img/cart.svg) no-repeat 50% 50%;
|
485 |
-
height: 40px;
|
486 |
-
width: 40px;
|
487 |
-
content: '';
|
488 |
-
display: block;
|
489 |
-
position: absolute;
|
490 |
-
top: 17px;
|
491 |
-
right: 15px;
|
492 |
-
background-size: contain;
|
493 |
-
}
|
494 |
-
|
495 |
-
#aws_form .buy-premium a .desc {
|
496 |
-
font-size: 15px;
|
497 |
-
line-height: 1.5;
|
498 |
-
}
|
499 |
-
|
500 |
-
#aws_form .buy-premium a .desc b {
|
501 |
-
text-transform: uppercase;
|
502 |
-
font-weight: bold;
|
503 |
-
}
|
504 |
-
|
505 |
-
#aws_form .buy-premium a ul {
|
506 |
-
margin: 12px 0 0 15px;
|
507 |
-
list-style: disc;
|
508 |
-
}
|
509 |
-
|
510 |
-
#aws_form .buy-premium a ul li {
|
511 |
-
margin: 0;
|
512 |
-
font-size: 12px;
|
513 |
-
line-height: 15px;
|
514 |
-
}
|
515 |
-
|
516 |
-
#aws_form .faq {
|
517 |
-
text-align: center;
|
518 |
-
max-width: 900px;
|
519 |
-
margin: 80px auto 70px;
|
520 |
-
}
|
521 |
-
|
522 |
-
#aws_form .faq h3 {
|
523 |
-
margin: 50px 0 46px;
|
524 |
-
font-size: 36px;
|
525 |
-
color: #444;
|
526 |
-
}
|
527 |
-
|
528 |
-
#aws_form .faq .faq-item {
|
529 |
-
margin: 0 0 25px;
|
530 |
-
}
|
531 |
-
|
532 |
-
#aws_form .faq .faq-item .question {
|
533 |
-
margin: 0 0 6px;
|
534 |
-
font-size: 18px;
|
535 |
-
color: #000;
|
536 |
-
}
|
537 |
-
|
538 |
-
#aws_form .faq .faq-item .answer {
|
539 |
-
font-size: 14px;
|
540 |
-
}
|
541 |
-
|
542 |
-
#aws_form .features {
|
543 |
-
max-width: 1050px;
|
544 |
-
margin: 70px auto 90px;
|
545 |
-
}
|
546 |
-
|
547 |
-
#aws_form .features h3 {
|
548 |
-
margin: 0 0 70px;
|
549 |
-
font-size: 36px;
|
550 |
-
color: #444;
|
551 |
-
text-align: center;
|
552 |
-
}
|
553 |
-
|
554 |
-
#aws_form .features .features-item {
|
555 |
-
display: flex;
|
556 |
-
flex-wrap: wrap;
|
557 |
-
justify-content: space-between;
|
558 |
-
align-items: center;
|
559 |
-
margin-bottom: 60px;
|
560 |
-
padding-bottom: 60px;
|
561 |
-
border-bottom: 1px solid #e0e0e0;
|
562 |
-
}
|
563 |
-
|
564 |
-
/*#aws_form .features .features-item:last-child {*/
|
565 |
-
/* border: none;*/
|
566 |
-
/* padding-bottom: 0;*/
|
567 |
-
/*}*/
|
568 |
-
|
569 |
-
#aws_form .features .features-item .column {
|
570 |
-
padding: 0;
|
571 |
-
width: 48%;
|
572 |
-
}
|
573 |
-
|
574 |
-
#aws_form .features .features-item .column .title {
|
575 |
-
font-size: 24px;
|
576 |
-
margin: 0 0 16px;
|
577 |
-
font-weight: 700;
|
578 |
-
}
|
579 |
-
|
580 |
-
#aws_form .features .features-item .column .desc {
|
581 |
-
font-size: 16px;
|
582 |
-
line-height: 1.6;
|
583 |
-
color: #444;
|
584 |
-
}
|
585 |
-
|
586 |
-
#aws_form .features .features-item .column .desc a {
|
587 |
-
color: #6f3eb0;
|
588 |
-
}
|
589 |
-
|
590 |
-
#aws_form .features .features-item .column .img {
|
591 |
-
margin-bottom: 0;
|
592 |
-
padding: 0;
|
593 |
-
}
|
594 |
-
|
595 |
-
#aws_form .features .features-item .column .img img {
|
596 |
-
height: auto;
|
597 |
-
vertical-align: middle;
|
598 |
-
max-width: 100%;
|
599 |
-
box-shadow: 0 1px 4px rgba(0,0,0,.2);
|
600 |
-
}
|
601 |
-
|
602 |
-
#aws_form .features .features-item:nth-child(2n) .column:first-child {
|
603 |
-
order: 2;
|
604 |
-
}
|
605 |
-
|
606 |
-
#aws_form .features .features-item .column .title,
|
607 |
-
#aws_form .features .features-item .column .desc {
|
608 |
-
padding-right: 10px;
|
609 |
-
}
|
610 |
-
|
611 |
-
#aws_form .features .features-item:nth-child(2n) .column .title,
|
612 |
-
#aws_form .features .features-item:nth-child(2n) .column .desc {
|
613 |
-
padding-right: 0;
|
614 |
-
padding-left: 10px;
|
615 |
-
}
|
616 |
-
|
617 |
-
#aws_form .screenshots h3 {
|
618 |
-
margin: 46px 0 50px;
|
619 |
-
font-size: 36px;
|
620 |
-
color: #444;
|
621 |
-
text-align: center;
|
622 |
-
}
|
623 |
-
|
624 |
-
#aws_form .screenshots,
|
625 |
-
#aws_form .screenshots * {
|
626 |
-
box-sizing: border-box;
|
627 |
-
}
|
628 |
-
|
629 |
-
#aws_form .screenshots {
|
630 |
-
max-width: 1050px;
|
631 |
-
margin: 70px auto 90px;
|
632 |
-
}
|
633 |
-
|
634 |
-
#aws_form .screenshots .screenshots-section {
|
635 |
-
text-align: left;
|
636 |
-
}
|
637 |
-
|
638 |
-
#aws_form .screenshots .section-title {
|
639 |
-
margin: 0 0 10px;
|
640 |
-
font-size: 18px;
|
641 |
-
}
|
642 |
-
|
643 |
-
#aws_form .screenshots .screenshots-list {
|
644 |
-
display: flex;
|
645 |
-
flex-wrap: wrap;
|
646 |
-
margin: 0 -10px 30px;
|
647 |
-
align-items: stretch;
|
648 |
-
}
|
649 |
-
|
650 |
-
#aws_form .screenshots .screenshots-list .screen {
|
651 |
-
width: 25%;
|
652 |
-
padding: 10px;
|
653 |
-
}
|
654 |
-
|
655 |
-
#aws_form .screenshots .screenshots-list .screen a {
|
656 |
-
display: block;
|
657 |
-
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
658 |
-
padding: 10px;
|
659 |
-
height: 100%;
|
660 |
-
min-height: 180px;
|
661 |
-
}
|
662 |
-
|
663 |
-
#aws_form .screenshots .screenshots-list .screen a:hover {
|
664 |
-
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
|
665 |
-
}
|
666 |
-
|
667 |
-
#aws_form .screenshots .screenshots-list .screen img {
|
668 |
-
display: block;
|
669 |
-
max-width: 100%;
|
670 |
-
}
|
671 |
-
|
672 |
-
#TB_window .awl-screen {
|
673 |
-
display: block;
|
674 |
-
max-width: 100%;
|
675 |
-
}
|
676 |
-
|
677 |
-
|
678 |
-
/* Welcome message */
|
679 |
-
|
680 |
-
.welcome-panel .welcome-panel-column:first-child {
|
681 |
-
width: 60%;
|
682 |
-
}
|
683 |
-
.welcome-panel .welcome-panel-column {
|
684 |
-
width: 20%;
|
685 |
}
|
1 |
+
.sortable-container {
|
2 |
+
width: 200px;
|
3 |
+
padding: 0;
|
4 |
+
float: left;
|
5 |
+
margin-right: 10px;
|
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 {
|
17 |
+
border: 1px solid #C7C4C4;
|
18 |
+
background: #fff7f7;
|
19 |
+
list-style-type: none;
|
20 |
+
margin: 0;
|
21 |
+
padding: 5px;
|
22 |
+
margin-right: 10px;
|
23 |
+
min-height: 180px;
|
24 |
+
}
|
25 |
+
|
26 |
+
.sti-sortable.enabled {
|
27 |
+
background: #ddf0dc;
|
28 |
+
}
|
29 |
+
|
30 |
+
.sti-sortable li.sti-btn,
|
31 |
+
.sti-sortable li.highlight,
|
32 |
+
.sti-sortable li#excerpt {
|
33 |
+
display: inline-block;
|
34 |
+
/*float: left;*/
|
35 |
+
width: 100%;
|
36 |
+
height: auto;
|
37 |
+
margin: 0 3px 3px 0;
|
38 |
+
cursor: pointer;
|
39 |
+
background: #F1F1F1;
|
40 |
+
border: 1px solid #C7C4C4;
|
41 |
+
text-align: center;
|
42 |
+
padding: 8px 0;
|
43 |
+
text-transform: capitalize;
|
44 |
+
}
|
45 |
+
|
46 |
+
.sti-sortable li.highlight {
|
47 |
+
background: #fff;
|
48 |
+
width: 100%;
|
49 |
+
height: 36px;
|
50 |
+
padding: 0;
|
51 |
+
border: 1px dotted #ccc;
|
52 |
+
}
|
53 |
+
|
54 |
+
.nav-tab.premium-tab,
|
55 |
+
.nav-tab[href*="page=aws-options&tab=premium"]{
|
56 |
+
background: #FFF7C7;
|
57 |
+
}
|
58 |
+
|
59 |
+
.nav-tab.premium-tab:hover,
|
60 |
+
.nav-tab[href*="page=aws-options&tab=premium"]:hover {
|
61 |
+
background: #fff;
|
62 |
+
}
|
63 |
+
|
64 |
+
.wp-submenu .current a[href*="page=aws-options&tab=premium"] span,
|
65 |
+
.wp-submenu a[href*="page=aws-options&tab=premium"]:hover span {
|
66 |
+
color: rgb(255, 255, 91) !important;
|
67 |
+
}
|
68 |
+
|
69 |
+
/* Reindex button */
|
70 |
+
#aws-reindex {
|
71 |
+
display: inline-block;
|
72 |
+
}
|
73 |
+
|
74 |
+
#aws-reindex .loader {
|
75 |
+
display: none;
|
76 |
+
width: 20px;
|
77 |
+
height: 20px;
|
78 |
+
background: url('../img/loader-1.GIF') no-repeat 50% 50%;
|
79 |
+
margin-left: 15px;
|
80 |
+
margin-top: 4px;
|
81 |
+
}
|
82 |
+
|
83 |
+
#aws-reindex .reindex-progress,
|
84 |
+
#aws-reindex .reindex-notice {
|
85 |
+
display: none;
|
86 |
+
margin-left: 15px;
|
87 |
+
position: relative;
|
88 |
+
top: -5px;
|
89 |
+
font-size: 13px;
|
90 |
+
font-weight: bold;
|
91 |
+
}
|
92 |
+
|
93 |
+
#aws-reindex .reindex-notice {
|
94 |
+
font-weight: normal;
|
95 |
+
}
|
96 |
+
|
97 |
+
#aws-reindex.loading .loader,
|
98 |
+
#aws-reindex.loading .reindex-progress,
|
99 |
+
#aws-reindex.loading .reindex-notice {
|
100 |
+
display: inline-block;
|
101 |
+
}
|
102 |
+
|
103 |
+
#aws_form .aws-heading {
|
104 |
+
margin-right: -40px;
|
105 |
+
}
|
106 |
+
|
107 |
+
#aws_form select {
|
108 |
+
min-width: 170px;
|
109 |
+
display: block;
|
110 |
+
}
|
111 |
+
|
112 |
+
/* Image select option */
|
113 |
+
#aws_form .img-select {
|
114 |
+
position: relative;
|
115 |
+
font-size: 0;
|
116 |
+
list-style: none;
|
117 |
+
max-width: 400px;
|
118 |
+
}
|
119 |
+
|
120 |
+
#aws_form .img-select .option {
|
121 |
+
display: block;
|
122 |
+
position: relative;
|
123 |
+
vertical-align: top;
|
124 |
+
height: 36px;
|
125 |
+
width: 400px;
|
126 |
+
margin: 0 0 16px;
|
127 |
+
}
|
128 |
+
|
129 |
+
#aws_form .img-select .option input {
|
130 |
+
width: 100%;
|
131 |
+
height: 100%;
|
132 |
+
position: absolute;
|
133 |
+
left: 0;
|
134 |
+
top: 0;
|
135 |
+
z-index: 2;
|
136 |
+
cursor: pointer;
|
137 |
+
opacity: 0;
|
138 |
+
}
|
139 |
+
#aws_form .img-select .option input:before,
|
140 |
+
#aws_form .img-select .option input:checked:before{
|
141 |
+
display: none;
|
142 |
+
}
|
143 |
+
|
144 |
+
#aws_form .img-select .option .ico {
|
145 |
+
display: block;
|
146 |
+
width: 100%;
|
147 |
+
height: 100%;
|
148 |
+
margin: 0 auto;
|
149 |
+
background-size: contain !important;
|
150 |
+
border:2px solid transparent;
|
151 |
+
border-radius: 5px;
|
152 |
+
}
|
153 |
+
|
154 |
+
#aws_form .img-select .option input:checked + .ico {
|
155 |
+
border-color: rgba(0,0,0,0.6);
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/* Premium tab */
|
160 |
+
#aws_form .b-compare .column {
|
161 |
+
width: 50%;
|
162 |
+
float: left;
|
163 |
+
}
|
164 |
+
|
165 |
+
#aws_form .b-compare .column p {
|
166 |
+
font-size: 14px;
|
167 |
+
border-bottom: 1px solid #ccc;
|
168 |
+
padding-bottom: 4px;
|
169 |
+
}
|
170 |
+
|
171 |
+
#aws_form .description.activation {
|
172 |
+
font-size: 14px;
|
173 |
+
line-height: 1.5;
|
174 |
+
font-style: normal;
|
175 |
+
}
|
176 |
+
|
177 |
+
#aws_form .description.activation .list {
|
178 |
+
padding-top: 2px;
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
h1.aws-instance-name {
|
183 |
+
position: relative;
|
184 |
+
padding-bottom: 20px;
|
185 |
+
padding-right: 20px;
|
186 |
+
display: inline-block;
|
187 |
+
cursor: pointer;
|
188 |
+
}
|
189 |
+
|
190 |
+
.aws-instance-shortcode {
|
191 |
+
display: inline-block;
|
192 |
+
background: #fff;
|
193 |
+
padding: 4px;
|
194 |
+
margin-left: 20px;
|
195 |
+
font-size: 14px;
|
196 |
+
font-weight: 600;
|
197 |
+
position: relative;
|
198 |
+
top: -4px;
|
199 |
+
}
|
200 |
+
|
201 |
+
|
202 |
+
/* Table */
|
203 |
+
.aws-table {
|
204 |
+
margin: 20px 0 10px;
|
205 |
+
}
|
206 |
+
|
207 |
+
.aws-table tr:nth-child(odd) td {
|
208 |
+
background: #f9f9f9;
|
209 |
+
}
|
210 |
+
|
211 |
+
.aws-table .aws-name {
|
212 |
+
font-weight: 700;
|
213 |
+
}
|
214 |
+
|
215 |
+
.aws-table .aws-current-filter {
|
216 |
+
color: #b00000;
|
217 |
+
margin-left: 8px;
|
218 |
+
font-size: 12px;
|
219 |
+
}
|
220 |
+
|
221 |
+
.aws-table th {
|
222 |
+
padding: 9px 7px!important;
|
223 |
+
vertical-align: middle;
|
224 |
+
}
|
225 |
+
|
226 |
+
.aws-table td {
|
227 |
+
vertical-align: middle;
|
228 |
+
padding: 7px;
|
229 |
+
line-height: 2em;
|
230 |
+
}
|
231 |
+
|
232 |
+
.aws-table .aws-actions a {
|
233 |
+
display: block;
|
234 |
+
text-indent: -9999px;
|
235 |
+
position: relative;
|
236 |
+
padding: 0!important;
|
237 |
+
height: 2em!important;
|
238 |
+
min-height: 2em!important;
|
239 |
+
width: 2em;
|
240 |
+
margin-left: 10px;
|
241 |
+
}
|
242 |
+
|
243 |
+
.aws-table .aws-actions a:after {
|
244 |
+
speak: none;
|
245 |
+
font-weight: 400;
|
246 |
+
font-variant: normal;
|
247 |
+
text-transform: none;
|
248 |
+
-webkit-font-smoothing: antialiased;
|
249 |
+
margin: 0;
|
250 |
+
text-indent: 0;
|
251 |
+
position: absolute;
|
252 |
+
top: 0;
|
253 |
+
left: 0;
|
254 |
+
width: 100%;
|
255 |
+
height: 100%;
|
256 |
+
text-align: center;
|
257 |
+
font-family: Dashicons;
|
258 |
+
line-height: 1.85;
|
259 |
+
}
|
260 |
+
|
261 |
+
.aws-table .aws-actions a.edit:after {
|
262 |
+
content: "";
|
263 |
+
}
|
264 |
+
|
265 |
+
.aws-table .aws-actions a.delete:after {
|
266 |
+
content: "";
|
267 |
+
}
|
268 |
+
|
269 |
+
.aws-table .aws-actions a.delete:hover:after {
|
270 |
+
background: rgba(255, 0, 0, 0.2);
|
271 |
+
}
|
272 |
+
|
273 |
+
.aws-table .aws-actions a.copy:after {
|
274 |
+
content: "";
|
275 |
+
}
|
276 |
+
|
277 |
+
.aws-insert-instance {
|
278 |
+
margin: 20px 0;
|
279 |
+
|
280 |
+
}
|
281 |
+
|
282 |
+
.aws-table.aws-table-sources {
|
283 |
+
margin: 10px 0 10px;
|
284 |
+
width: 500px;
|
285 |
+
}
|
286 |
+
|
287 |
+
.aws-table.aws-table-sources th.aws-actions {
|
288 |
+
width: 60px;
|
289 |
+
}
|
290 |
+
.aws-table.aws-table-sources th.aws-active {
|
291 |
+
width: 30px;
|
292 |
+
}
|
293 |
+
|
294 |
+
.aws-table.aws-table-sources td.aws-active {
|
295 |
+
text-align: center;
|
296 |
+
}
|
297 |
+
|
298 |
+
.aws-table.aws-table-sources td.aws-active .aws-yes,
|
299 |
+
.aws-table.aws-table-sources td.aws-active .aws-no,
|
300 |
+
.aws-table.aws-table-sources td.aws-active .aws-disabled {
|
301 |
+
background-color: #26CC06;
|
302 |
+
padding: 1px 7px;
|
303 |
+
color: #fff;
|
304 |
+
border-radius: 4px;
|
305 |
+
position: relative;
|
306 |
+
cursor: pointer;
|
307 |
+
}
|
308 |
+
|
309 |
+
.aws-table.aws-table-sources td.aws-active .aws-disabled {
|
310 |
+
background-color: #808080;
|
311 |
+
cursor: default;
|
312 |
+
}
|
313 |
+
|
314 |
+
.aws-table.aws-table-sources td.aws-active .aws-no {
|
315 |
+
background-color: #CC0606;
|
316 |
+
}
|
317 |
+
|
318 |
+
.aws-table.aws-table-sources td.aws-active .aws-yes,
|
319 |
+
.aws-table.aws-table-sources td.aws-active .aws-disabled,
|
320 |
+
.aws-table.aws-table-sources td.aws-active.active .aws-no {
|
321 |
+
display: none;
|
322 |
+
}
|
323 |
+
|
324 |
+
.aws-table.aws-table-sources td.aws-active.active .aws-yes {
|
325 |
+
display: inline;
|
326 |
+
}
|
327 |
+
|
328 |
+
.aws-table.aws-table-sources td.aws-active.disabled .aws-disabled {
|
329 |
+
display: inline !important;
|
330 |
+
}
|
331 |
+
|
332 |
+
.aws-table.aws-table-sources td.aws-active.disabled .aws-yes,
|
333 |
+
.aws-table.aws-table-sources td.aws-active.disabled .aws-no {
|
334 |
+
display: none;
|
335 |
+
}
|
336 |
+
|
337 |
+
.aws-table.aws-table-sources td.aws-active:after {
|
338 |
+
content: "";
|
339 |
+
display: none;
|
340 |
+
margin: 0 auto;
|
341 |
+
width: 20px;
|
342 |
+
height: 20px;
|
343 |
+
background: url('../img/loader-2.gif') no-repeat 50% 50%;
|
344 |
+
}
|
345 |
+
|
346 |
+
.aws-table.aws-table-sources td.aws-active.loading .aws-yes,
|
347 |
+
.aws-table.aws-table-sources td.aws-active.loading .aws-no {
|
348 |
+
display: none;
|
349 |
+
}
|
350 |
+
|
351 |
+
.aws-table.aws-table-sources td.aws-active.loading:after {
|
352 |
+
display: block;
|
353 |
+
}
|
354 |
+
|
355 |
+
.aws-table.aws-table-sources td.aws-name {
|
356 |
+
font-weight: 400;
|
357 |
+
}
|
358 |
+
|
359 |
+
/* Premium tab */
|
360 |
+
#aws_form.form-tab-premium .submit {
|
361 |
+
display: none;
|
362 |
+
}
|
363 |
+
|
364 |
+
#aws_form .free-pro-table *,
|
365 |
+
#aws_form .free-pro-table *:before,
|
366 |
+
#aws_form .free-pro-table *:after {
|
367 |
+
-webkit-box-sizing: border-box;
|
368 |
+
-moz-box-sizing: border-box;
|
369 |
+
box-sizing: border-box;
|
370 |
+
}
|
371 |
+
|
372 |
+
#aws_form .free-pro-table {
|
373 |
+
background: #fff;
|
374 |
+
max-width: 900px;
|
375 |
+
margin: 50px auto 20px;
|
376 |
+
}
|
377 |
+
|
378 |
+
#aws_form .free-pro-table b {
|
379 |
+
font-weight: bold;
|
380 |
+
}
|
381 |
+
|
382 |
+
#aws_form .free-pro-table td,
|
383 |
+
#aws_form .free-pro-table th {
|
384 |
+
margin-bottom: 0;
|
385 |
+
padding: 15px 10px;
|
386 |
+
line-height: 1.3;
|
387 |
+
vertical-align: middle;
|
388 |
+
}
|
389 |
+
|
390 |
+
#aws_form .free-pro-table td.center,
|
391 |
+
#aws_form .free-pro-table th.center {
|
392 |
+
text-align: center;
|
393 |
+
}
|
394 |
+
|
395 |
+
#aws_form .free-pro-table td h3 {
|
396 |
+
margin: 0 0 6px;
|
397 |
+
}
|
398 |
+
|
399 |
+
#aws_form .free-pro-table .yes,
|
400 |
+
#aws_form .free-pro-table .no {
|
401 |
+
text-align: center;
|
402 |
+
width: 10%;
|
403 |
+
padding: 0;
|
404 |
+
}
|
405 |
+
|
406 |
+
#aws_form .free-pro-table.bordered,
|
407 |
+
#aws_form .free-pro-table.bordered td,
|
408 |
+
#aws_form .free-pro-table.bordered th {
|
409 |
+
border: 1px solid #e0e0e0;
|
410 |
+
border-collapse: collapse;
|
411 |
+
}
|
412 |
+
|
413 |
+
#aws_form .free-pro-table .icon-before {
|
414 |
+
margin: 0 auto;
|
415 |
+
display: inline-block;
|
416 |
+
}
|
417 |
+
|
418 |
+
#aws_form .free-pro-table .yes .icon-before:before,
|
419 |
+
#aws_form .free-pro-table .no .icon-before:before {
|
420 |
+
height: 35px;
|
421 |
+
width: 35px;
|
422 |
+
content: '';
|
423 |
+
display: block;
|
424 |
+
position: relative;
|
425 |
+
top: 0;
|
426 |
+
background-size: contain !important;
|
427 |
+
}
|
428 |
+
|
429 |
+
#aws_form .free-pro-table .yes .icon-before:before {
|
430 |
+
height: 40px;
|
431 |
+
width: 40px;
|
432 |
+
}
|
433 |
+
|
434 |
+
#aws_form .free-pro-table .yes .icon-before:before {
|
435 |
+
background: url(../img/yes.svg) no-repeat 50% 50%;
|
436 |
+
}
|
437 |
+
|
438 |
+
#aws_form .free-pro-table .no .icon-before:before {
|
439 |
+
background: url(../img/no.svg) no-repeat 50% 50%;
|
440 |
+
}
|
441 |
+
|
442 |
+
#aws_form .links {
|
443 |
+
margin: 5px 0;
|
444 |
+
}
|
445 |
+
|
446 |
+
#aws_form .links .links-title {
|
447 |
+
display: inline-block;
|
448 |
+
}
|
449 |
+
|
450 |
+
#aws_form .links ul {
|
451 |
+
display: inline-block;
|
452 |
+
margin: 0 0 0 10px;
|
453 |
+
}
|
454 |
+
|
455 |
+
#aws_form .links ul li {
|
456 |
+
display: inline-block;
|
457 |
+
margin: 0 5px;
|
458 |
+
}
|
459 |
+
|
460 |
+
#aws_form .links ul li a {
|
461 |
+
color: #7f54b3;
|
462 |
+
}
|
463 |
+
|
464 |
+
#aws_form .buy-premium {
|
465 |
+
width: 500px;
|
466 |
+
margin: 20px auto 40px;
|
467 |
+
}
|
468 |
+
|
469 |
+
#aws_form .buy-premium a {
|
470 |
+
position: relative;
|
471 |
+
display: block;
|
472 |
+
background-color: #7f54b3;
|
473 |
+
color: #fff;
|
474 |
+
border-radius: 6px;
|
475 |
+
padding: 16px 15px;
|
476 |
+
text-decoration: none;
|
477 |
+
}
|
478 |
+
|
479 |
+
#aws_form .buy-premium a:hover {
|
480 |
+
background-color: #6f3eb0;
|
481 |
+
}
|
482 |
+
|
483 |
+
#aws_form .buy-premium a:after {
|
484 |
+
background: url(../img/cart.svg) no-repeat 50% 50%;
|
485 |
+
height: 40px;
|
486 |
+
width: 40px;
|
487 |
+
content: '';
|
488 |
+
display: block;
|
489 |
+
position: absolute;
|
490 |
+
top: 17px;
|
491 |
+
right: 15px;
|
492 |
+
background-size: contain;
|
493 |
+
}
|
494 |
+
|
495 |
+
#aws_form .buy-premium a .desc {
|
496 |
+
font-size: 15px;
|
497 |
+
line-height: 1.5;
|
498 |
+
}
|
499 |
+
|
500 |
+
#aws_form .buy-premium a .desc b {
|
501 |
+
text-transform: uppercase;
|
502 |
+
font-weight: bold;
|
503 |
+
}
|
504 |
+
|
505 |
+
#aws_form .buy-premium a ul {
|
506 |
+
margin: 12px 0 0 15px;
|
507 |
+
list-style: disc;
|
508 |
+
}
|
509 |
+
|
510 |
+
#aws_form .buy-premium a ul li {
|
511 |
+
margin: 0;
|
512 |
+
font-size: 12px;
|
513 |
+
line-height: 15px;
|
514 |
+
}
|
515 |
+
|
516 |
+
#aws_form .faq {
|
517 |
+
text-align: center;
|
518 |
+
max-width: 900px;
|
519 |
+
margin: 80px auto 70px;
|
520 |
+
}
|
521 |
+
|
522 |
+
#aws_form .faq h3 {
|
523 |
+
margin: 50px 0 46px;
|
524 |
+
font-size: 36px;
|
525 |
+
color: #444;
|
526 |
+
}
|
527 |
+
|
528 |
+
#aws_form .faq .faq-item {
|
529 |
+
margin: 0 0 25px;
|
530 |
+
}
|
531 |
+
|
532 |
+
#aws_form .faq .faq-item .question {
|
533 |
+
margin: 0 0 6px;
|
534 |
+
font-size: 18px;
|
535 |
+
color: #000;
|
536 |
+
}
|
537 |
+
|
538 |
+
#aws_form .faq .faq-item .answer {
|
539 |
+
font-size: 14px;
|
540 |
+
}
|
541 |
+
|
542 |
+
#aws_form .features {
|
543 |
+
max-width: 1050px;
|
544 |
+
margin: 70px auto 90px;
|
545 |
+
}
|
546 |
+
|
547 |
+
#aws_form .features h3 {
|
548 |
+
margin: 0 0 70px;
|
549 |
+
font-size: 36px;
|
550 |
+
color: #444;
|
551 |
+
text-align: center;
|
552 |
+
}
|
553 |
+
|
554 |
+
#aws_form .features .features-item {
|
555 |
+
display: flex;
|
556 |
+
flex-wrap: wrap;
|
557 |
+
justify-content: space-between;
|
558 |
+
align-items: center;
|
559 |
+
margin-bottom: 60px;
|
560 |
+
padding-bottom: 60px;
|
561 |
+
border-bottom: 1px solid #e0e0e0;
|
562 |
+
}
|
563 |
+
|
564 |
+
/*#aws_form .features .features-item:last-child {*/
|
565 |
+
/* border: none;*/
|
566 |
+
/* padding-bottom: 0;*/
|
567 |
+
/*}*/
|
568 |
+
|
569 |
+
#aws_form .features .features-item .column {
|
570 |
+
padding: 0;
|
571 |
+
width: 48%;
|
572 |
+
}
|
573 |
+
|
574 |
+
#aws_form .features .features-item .column .title {
|
575 |
+
font-size: 24px;
|
576 |
+
margin: 0 0 16px;
|
577 |
+
font-weight: 700;
|
578 |
+
}
|
579 |
+
|
580 |
+
#aws_form .features .features-item .column .desc {
|
581 |
+
font-size: 16px;
|
582 |
+
line-height: 1.6;
|
583 |
+
color: #444;
|
584 |
+
}
|
585 |
+
|
586 |
+
#aws_form .features .features-item .column .desc a {
|
587 |
+
color: #6f3eb0;
|
588 |
+
}
|
589 |
+
|
590 |
+
#aws_form .features .features-item .column .img {
|
591 |
+
margin-bottom: 0;
|
592 |
+
padding: 0;
|
593 |
+
}
|
594 |
+
|
595 |
+
#aws_form .features .features-item .column .img img {
|
596 |
+
height: auto;
|
597 |
+
vertical-align: middle;
|
598 |
+
max-width: 100%;
|
599 |
+
box-shadow: 0 1px 4px rgba(0,0,0,.2);
|
600 |
+
}
|
601 |
+
|
602 |
+
#aws_form .features .features-item:nth-child(2n) .column:first-child {
|
603 |
+
order: 2;
|
604 |
+
}
|
605 |
+
|
606 |
+
#aws_form .features .features-item .column .title,
|
607 |
+
#aws_form .features .features-item .column .desc {
|
608 |
+
padding-right: 10px;
|
609 |
+
}
|
610 |
+
|
611 |
+
#aws_form .features .features-item:nth-child(2n) .column .title,
|
612 |
+
#aws_form .features .features-item:nth-child(2n) .column .desc {
|
613 |
+
padding-right: 0;
|
614 |
+
padding-left: 10px;
|
615 |
+
}
|
616 |
+
|
617 |
+
#aws_form .screenshots h3 {
|
618 |
+
margin: 46px 0 50px;
|
619 |
+
font-size: 36px;
|
620 |
+
color: #444;
|
621 |
+
text-align: center;
|
622 |
+
}
|
623 |
+
|
624 |
+
#aws_form .screenshots,
|
625 |
+
#aws_form .screenshots * {
|
626 |
+
box-sizing: border-box;
|
627 |
+
}
|
628 |
+
|
629 |
+
#aws_form .screenshots {
|
630 |
+
max-width: 1050px;
|
631 |
+
margin: 70px auto 90px;
|
632 |
+
}
|
633 |
+
|
634 |
+
#aws_form .screenshots .screenshots-section {
|
635 |
+
text-align: left;
|
636 |
+
}
|
637 |
+
|
638 |
+
#aws_form .screenshots .section-title {
|
639 |
+
margin: 0 0 10px;
|
640 |
+
font-size: 18px;
|
641 |
+
}
|
642 |
+
|
643 |
+
#aws_form .screenshots .screenshots-list {
|
644 |
+
display: flex;
|
645 |
+
flex-wrap: wrap;
|
646 |
+
margin: 0 -10px 30px;
|
647 |
+
align-items: stretch;
|
648 |
+
}
|
649 |
+
|
650 |
+
#aws_form .screenshots .screenshots-list .screen {
|
651 |
+
width: 25%;
|
652 |
+
padding: 10px;
|
653 |
+
}
|
654 |
+
|
655 |
+
#aws_form .screenshots .screenshots-list .screen a {
|
656 |
+
display: block;
|
657 |
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
|
658 |
+
padding: 10px;
|
659 |
+
height: 100%;
|
660 |
+
min-height: 180px;
|
661 |
+
}
|
662 |
+
|
663 |
+
#aws_form .screenshots .screenshots-list .screen a:hover {
|
664 |
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
|
665 |
+
}
|
666 |
+
|
667 |
+
#aws_form .screenshots .screenshots-list .screen img {
|
668 |
+
display: block;
|
669 |
+
max-width: 100%;
|
670 |
+
}
|
671 |
+
|
672 |
+
#TB_window .awl-screen {
|
673 |
+
display: block;
|
674 |
+
max-width: 100%;
|
675 |
+
}
|
676 |
+
|
677 |
+
|
678 |
+
/* Welcome message */
|
679 |
+
|
680 |
+
.welcome-panel .welcome-panel-column:first-child {
|
681 |
+
width: 60%;
|
682 |
+
}
|
683 |
+
.welcome-panel .welcome-panel-column {
|
684 |
+
width: 20%;
|
685 |
}
|
assets/css/common-rtl.css
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
/* Rtl support */
|
2 |
-
.rtl .aws-container .aws-search-form .aws-loader {
|
3 |
-
right: auto;
|
4 |
-
left: 10px;
|
5 |
-
}
|
6 |
-
.rtl .aws-container .aws-show-clear .aws-search-field {
|
7 |
-
padding: 6px 6px 6px 40px;
|
8 |
-
}
|
9 |
-
.rtl .aws-container .aws-search-form .aws-search-clear {
|
10 |
-
right: auto;
|
11 |
-
left: 0;
|
12 |
-
padding: 0 10px 0 0;
|
13 |
-
text-align: right;
|
14 |
-
}
|
15 |
-
.rtl .aws-container .aws-search-form .aws-form-btn {
|
16 |
-
margin: 0 -1px 0 0;
|
17 |
-
}
|
18 |
-
.rtl .aws-container[data-buttons-order="3"] .aws-search-form .aws-search-btn{
|
19 |
-
margin: 0 0 0 -1px;
|
20 |
-
}
|
21 |
-
.rtl .aws-search-result {
|
22 |
-
text-align: right;
|
23 |
-
}
|
24 |
-
.rtl .aws-search-result .aws_result_featured {
|
25 |
-
margin: 0 0 0 6px;
|
26 |
-
}
|
27 |
-
.rtl .aws-search-result .aws_result_price del,
|
28 |
-
.rtl .aws-search-result .aws_result_price ins {
|
29 |
-
padding: 0 0 0 12px;
|
30 |
-
}
|
31 |
-
.rtl .aws-search-result .aws_result_cats {
|
32 |
-
float: right;
|
33 |
-
margin: 0 0 0 20px;
|
34 |
-
}
|
35 |
-
.rtl .aws-search-result .aws_result_image {
|
36 |
-
float: right;
|
37 |
-
padding: 0 0 0 10px;
|
38 |
-
}
|
39 |
-
.rtl .aws-search-result .aws_result_sale {
|
40 |
-
right: auto;
|
41 |
-
left: 0;
|
42 |
-
}
|
43 |
-
.rtl .aws-search-result .aws_onsale {
|
44 |
-
float: left;
|
45 |
-
padding-top: 2px;
|
46 |
-
position: relative;
|
47 |
-
right: auto;
|
48 |
-
left: -25px;
|
49 |
-
transform: rotate(-45deg);
|
50 |
-
}
|
51 |
-
.rtl .et_vertical_nav .et_search_outer .aws-container {
|
52 |
-
margin: 0 0 0 20px;
|
53 |
}
|
1 |
+
/* Rtl support */
|
2 |
+
.rtl .aws-container .aws-search-form .aws-loader {
|
3 |
+
right: auto;
|
4 |
+
left: 10px;
|
5 |
+
}
|
6 |
+
.rtl .aws-container .aws-show-clear .aws-search-field {
|
7 |
+
padding: 6px 6px 6px 40px;
|
8 |
+
}
|
9 |
+
.rtl .aws-container .aws-search-form .aws-search-clear {
|
10 |
+
right: auto;
|
11 |
+
left: 0;
|
12 |
+
padding: 0 10px 0 0;
|
13 |
+
text-align: right;
|
14 |
+
}
|
15 |
+
.rtl .aws-container .aws-search-form .aws-form-btn {
|
16 |
+
margin: 0 -1px 0 0;
|
17 |
+
}
|
18 |
+
.rtl .aws-container[data-buttons-order="3"] .aws-search-form .aws-search-btn{
|
19 |
+
margin: 0 0 0 -1px;
|
20 |
+
}
|
21 |
+
.rtl .aws-search-result {
|
22 |
+
text-align: right;
|
23 |
+
}
|
24 |
+
.rtl .aws-search-result .aws_result_featured {
|
25 |
+
margin: 0 0 0 6px;
|
26 |
+
}
|
27 |
+
.rtl .aws-search-result .aws_result_price del,
|
28 |
+
.rtl .aws-search-result .aws_result_price ins {
|
29 |
+
padding: 0 0 0 12px;
|
30 |
+
}
|
31 |
+
.rtl .aws-search-result .aws_result_cats {
|
32 |
+
float: right;
|
33 |
+
margin: 0 0 0 20px;
|
34 |
+
}
|
35 |
+
.rtl .aws-search-result .aws_result_image {
|
36 |
+
float: right;
|
37 |
+
padding: 0 0 0 10px;
|
38 |
+
}
|
39 |
+
.rtl .aws-search-result .aws_result_sale {
|
40 |
+
right: auto;
|
41 |
+
left: 0;
|
42 |
+
}
|
43 |
+
.rtl .aws-search-result .aws_onsale {
|
44 |
+
float: left;
|
45 |
+
padding-top: 2px;
|
46 |
+
position: relative;
|
47 |
+
right: auto;
|
48 |
+
left: -25px;
|
49 |
+
transform: rotate(-45deg);
|
50 |
+
}
|
51 |
+
.rtl .et_vertical_nav .et_search_outer .aws-container {
|
52 |
+
margin: 0 0 0 20px;
|
53 |
}
|
assets/css/common.css
CHANGED
@@ -1,533 +1,533 @@
|
|
1 |
-
.aws-container .aws-search-form {
|
2 |
-
position: relative;
|
3 |
-
width: 100%;
|
4 |
-
float: none !important;
|
5 |
-
display: -webkit-box !important;
|
6 |
-
display: -moz-box !important;
|
7 |
-
display: -ms-flexbox !important;
|
8 |
-
display: -webkit-flex !important;
|
9 |
-
display: flex !important;
|
10 |
-
align-items: stretch;
|
11 |
-
height: 44px;
|
12 |
-
}
|
13 |
-
|
14 |
-
.aws-container .aws-search-form *,
|
15 |
-
.aws-search-result {
|
16 |
-
-moz-box-sizing: border-box;
|
17 |
-
-webkit-box-sizing: border-box;
|
18 |
-
box-sizing: border-box;
|
19 |
-
-moz-hyphens: manual;
|
20 |
-
-webkit-hyphens: manual;
|
21 |
-
hyphens: manual;
|
22 |
-
border-radius: 0 !important;
|
23 |
-
}
|
24 |
-
|
25 |
-
|
26 |
-
.aws-container .aws-search-form .aws-loader,
|
27 |
-
.aws-container .aws-search-form .aws-loader:after {
|
28 |
-
border-radius: 50% !important;
|
29 |
-
width: 20px;
|
30 |
-
height: 20px;
|
31 |
-
}
|
32 |
-
|
33 |
-
.aws-container .aws-search-form .aws-wrapper {
|
34 |
-
flex-grow: 1;
|
35 |
-
position: relative;
|
36 |
-
vertical-align: top;
|
37 |
-
padding: 0;
|
38 |
-
width: 100%;
|
39 |
-
}
|
40 |
-
|
41 |
-
.aws-container .aws-search-form .aws-loader {
|
42 |
-
position: absolute;
|
43 |
-
display: none;
|
44 |
-
right: 10px;
|
45 |
-
top: 50%;
|
46 |
-
z-index: 999;
|
47 |
-
margin: 0;
|
48 |
-
margin-top: -10px;
|
49 |
-
font-size: 10px;
|
50 |
-
text-indent: -9999em;
|
51 |
-
border-top: 3px solid #ededed;
|
52 |
-
border-right: 3px solid #ededed;
|
53 |
-
border-bottom: 3px solid #ededed;
|
54 |
-
border-left: 3px solid #555;
|
55 |
-
|
56 |
-
}
|
57 |
-
|
58 |
-
.aws-container .aws-search-form.aws-processing .aws-loader {
|
59 |
-
display: block;
|
60 |
-
-webkit-transform: translateZ(0);
|
61 |
-
-ms-transform: translateZ(0);
|
62 |
-
transform: translateZ(0);
|
63 |
-
-webkit-animation: load8 0.7s infinite linear;
|
64 |
-
animation: load8 0.7s infinite linear;
|
65 |
-
}
|
66 |
-
|
67 |
-
@-webkit-keyframes load8 {
|
68 |
-
0% {
|
69 |
-
-webkit-transform: rotate(0deg);
|
70 |
-
transform: rotate(0deg);
|
71 |
-
}
|
72 |
-
100% {
|
73 |
-
-webkit-transform: rotate(360deg);
|
74 |
-
transform: rotate(360deg);
|
75 |
-
}
|
76 |
-
}
|
77 |
-
@keyframes load8 {
|
78 |
-
0% {
|
79 |
-
-webkit-transform: rotate(0deg);
|
80 |
-
transform: rotate(0deg);
|
81 |
-
}
|
82 |
-
100% {
|
83 |
-
-webkit-transform: rotate(360deg);
|
84 |
-
transform: rotate(360deg);
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
.aws-container .aws-search-label {
|
89 |
-
position: absolute !important;
|
90 |
-
left: -10000px;
|
91 |
-
top: auto;
|
92 |
-
width: 1px;
|
93 |
-
height: 1px;
|
94 |
-
overflow: hidden;
|
95 |
-
clip: rect(1px, 1px, 1px, 1px);
|
96 |
-
}
|
97 |
-
|
98 |
-
.aws-container .aws-search-field {
|
99 |
-
width: 100%;
|
100 |
-
max-width: 100%;
|
101 |
-
color: #313131;
|
102 |
-
padding: 6px;
|
103 |
-
line-height: 30px;
|
104 |
-
display: block;
|
105 |
-
font-size: 12px;
|
106 |
-
position: relative;
|
107 |
-
z-index: 2;
|
108 |
-
-webkit-appearance: none;
|
109 |
-
height: 100%;
|
110 |
-
margin: 0 !important;
|
111 |
-
border: 1px solid #d8d8d8;
|
112 |
-
outline: 0;
|
113 |
-
}
|
114 |
-
|
115 |
-
/* Mobile zoom disable */
|
116 |
-
@media screen and (-webkit-min-device-pixel-ratio:0) and (max-device-width:1024px) {
|
117 |
-
.aws-container .aws-search-field {
|
118 |
-
font-size: 16px;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
.aws-container .aws-search-field::-ms-clear { display: none; width : 0; height: 0; }
|
123 |
-
.aws-container .aws-search-field::-ms-reveal { display: none; width : 0; height: 0; }
|
124 |
-
|
125 |
-
.aws-container .aws-search-field::-webkit-search-decoration,
|
126 |
-
.aws-container .aws-search-field::-webkit-search-cancel-button,
|
127 |
-
.aws-container .aws-search-field::-webkit-search-results-button,
|
128 |
-
.aws-container .aws-search-field::-webkit-search-results-decoration {
|
129 |
-
display: none;
|
130 |
-
}
|
131 |
-
|
132 |
-
.aws-container .aws-search-field:focus {
|
133 |
-
background-color: #fff;
|
134 |
-
}
|
135 |
-
|
136 |
-
.aws-container .aws-show-clear .aws-search-field {
|
137 |
-
padding-right: 40px;
|
138 |
-
}
|
139 |
-
|
140 |
-
.aws-container .aws-search-field:focus::-webkit-input-placeholder { color:transparent; }
|
141 |
-
.aws-container .aws-search-field:focus:-moz-placeholder { color:transparent; }
|
142 |
-
.aws-container .aws-search-field:focus::-moz-placeholder { color:transparent; }
|
143 |
-
.aws-container .aws-search-field:focus:-ms-input-placeholder { color:transparent; }
|
144 |
-
|
145 |
-
|
146 |
-
/* Clear button */
|
147 |
-
.aws-container .aws-search-form .aws-search-clear {
|
148 |
-
display: none !important;
|
149 |
-
position: absolute;
|
150 |
-
top: 0;
|
151 |
-
right: 0;
|
152 |
-
z-index: 2;
|
153 |
-
cursor: pointer;
|
154 |
-
color: #757575;
|
155 |
-
height: 100%;
|
156 |
-
width: 38px;
|
157 |
-
padding: 0 0 0 10px;
|
158 |
-
text-align: left;
|
159 |
-
}
|
160 |
-
.aws-container .aws-search-form .aws-search-clear span {
|
161 |
-
position: relative;
|
162 |
-
display: block;
|
163 |
-
font-size: 24px;
|
164 |
-
line-height: 24px;
|
165 |
-
top: 50%;
|
166 |
-
margin-top: -12px;
|
167 |
-
}
|
168 |
-
|
169 |
-
.aws-container .aws-search-form.aws-show-clear.aws-form-active .aws-search-clear {
|
170 |
-
display: block !important;
|
171 |
-
}
|
172 |
-
|
173 |
-
.aws-container .aws-search-form.aws-form-active.aws-processing .aws-search-clear {
|
174 |
-
display: none !important;
|
175 |
-
}
|
176 |
-
|
177 |
-
|
178 |
-
/* Search button */
|
179 |
-
.aws-container .aws-search-form .aws-search-btn {
|
180 |
-
padding: 0;
|
181 |
-
line-height: 10px;
|
182 |
-
width: 42px;
|
183 |
-
}
|
184 |
-
|
185 |
-
.aws-container .aws-search-form .aws-search-btn_icon {
|
186 |
-
display: inline-block;
|
187 |
-
fill: currentColor;
|
188 |
-
height: 24px;
|
189 |
-
line-height: 24px;
|
190 |
-
position: relative;
|
191 |
-
width: 42px;
|
192 |
-
color: #555;
|
193 |
-
}
|
194 |
-
|
195 |
-
.aws-container .aws-search-form .aws-search-btn svg {
|
196 |
-
display: block;
|
197 |
-
height: 100%;
|
198 |
-
width: 100%;
|
199 |
-
}
|
200 |
-
|
201 |
-
.aws-container[data-show-page="false"] .aws-search-form .aws-search-btn:hover {
|
202 |
-
background: #ededed;
|
203 |
-
cursor: default;
|
204 |
-
}
|
205 |
-
|
206 |
-
|
207 |
-
/* Form buttons */
|
208 |
-
.aws-container .aws-search-form .aws-form-btn {
|
209 |
-
display: -webkit-box;
|
210 |
-
display: -moz-box;
|
211 |
-
display: -ms-flexbox;
|
212 |
-
display: -webkit-flex;
|
213 |
-
display: flex;
|
214 |
-
justify-content: center;
|
215 |
-
flex-direction: column;
|
216 |
-
text-align: center;
|
217 |
-
|
218 |
-
background: #ededed;
|
219 |
-
border: 1px solid #d8d8d8;
|
220 |
-
/*border-left: none;*/
|
221 |
-
margin: 0 0 0 -1px;
|
222 |
-
cursor: pointer;
|
223 |
-
position: relative;
|
224 |
-
white-space: nowrap;
|
225 |
-
|
226 |
-
-moz-user-select: none;
|
227 |
-
-ms-user-select: none;
|
228 |
-
user-select: none;
|
229 |
-
|
230 |
-
-webkit-transition: background-color 100ms ease-in-out;
|
231 |
-
-moz-transition: background-color 100ms ease-in-out;
|
232 |
-
-o-transition: background-color 100ms ease-in-out;
|
233 |
-
transition: background-color 100ms ease-in-out;
|
234 |
-
}
|
235 |
-
.aws-container .aws-search-form .aws-form-btn:hover {
|
236 |
-
background: #dcdcdc;
|
237 |
-
}
|
238 |
-
.aws-container .aws-search-form .aws-form-btn:active {
|
239 |
-
background: #d8d8d8;
|
240 |
-
}
|
241 |
-
|
242 |
-
|
243 |
-
/* Form buttons layouts */
|
244 |
-
.aws-container[data-buttons-order="3"] .aws-search-form .aws-wrapper{
|
245 |
-
-webkit-order: 2;
|
246 |
-
order: 2;
|
247 |
-
}
|
248 |
-
|
249 |
-
.aws-container[data-buttons-order="3"] .aws-search-form .aws-search-btn{
|
250 |
-
margin: 0 -1px 0 0;
|
251 |
-
}
|
252 |
-
|
253 |
-
.aws-search-result {
|
254 |
-
position: absolute;
|
255 |
-
text-align: left;
|
256 |
-
z-index: 9999999999999;
|
257 |
-
background: #fff;
|
258 |
-
width: 100%;
|
259 |
-
margin-top: -1px;
|
260 |
-
border: 1px solid #ccc;
|
261 |
-
font-size: 12px;
|
262 |
-
line-height: 16px;
|
263 |
-
}
|
264 |
-
|
265 |
-
.aws-search-result ul {
|
266 |
-
list-style: none;
|
267 |
-
padding: 0 !important;
|
268 |
-
margin: 0 !important;
|
269 |
-
max-height: 400px;
|
270 |
-
overflow-y: auto;
|
271 |
-
}
|
272 |
-
|
273 |
-
.aws-search-result ul::-webkit-scrollbar-track {
|
274 |
-
-webkit-box-shadow: none;
|
275 |
-
background-color: #ededed;
|
276 |
-
}
|
277 |
-
.aws-search-result ul::-webkit-scrollbar {
|
278 |
-
width: 7px;
|
279 |
-
background-color: #ededed;
|
280 |
-
}
|
281 |
-
|
282 |
-
.aws-search-result ul::-webkit-scrollbar-thumb {
|
283 |
-
background-color: #d8d8d8;
|
284 |
-
}
|
285 |
-
|
286 |
-
.aws-search-result ul li {
|
287 |
-
list-style: none;
|
288 |
-
border-bottom: 1px solid #ccc;
|
289 |
-
overflow: hidden;
|
290 |
-
margin: 0 !important;
|
291 |
-
position: relative;
|
292 |
-
}
|
293 |
-
|
294 |
-
.aws-search-result ul li:last-child {
|
295 |
-
border-bottom: 0;
|
296 |
-
}
|
297 |
-
|
298 |
-
|
299 |
-
.aws-search-result .aws_result_link {
|
300 |
-
display: block;
|
301 |
-
cursor: pointer;
|
302 |
-
padding: 10px 8px;
|
303 |
-
height: 100%;
|
304 |
-
overflow: hidden;
|
305 |
-
text-decoration: none;
|
306 |
-
border: 0;
|
307 |
-
}
|
308 |
-
|
309 |
-
|
310 |
-
.aws-search-result .aws_result_item:hover,
|
311 |
-
.aws-search-result .aws_result_item.hovered {
|
312 |
-
background: #f5f5f5;
|
313 |
-
}
|
314 |
-
|
315 |
-
|
316 |
-
.aws-search-result .aws_result_content {
|
317 |
-
overflow: hidden;
|
318 |
-
display: block;
|
319 |
-
}
|
320 |
-
|
321 |
-
.aws-search-result .aws_result_title {
|
322 |
-
display: block;
|
323 |
-
font-weight: normal;
|
324 |
-
margin-bottom: 3px;
|
325 |
-
color: #21759b;
|
326 |
-
}
|
327 |
-
|
328 |
-
.aws-search-result .aws_result_featured {
|
329 |
-
margin: 0 6px 0 0;
|
330 |
-
position: relative;
|
331 |
-
top: -2px;
|
332 |
-
}
|
333 |
-
|
334 |
-
.aws-search-result .aws_result_featured svg {
|
335 |
-
width: 13px;
|
336 |
-
height: 13px;
|
337 |
-
fill: #fa0;
|
338 |
-
vertical-align: bottom;
|
339 |
-
}
|
340 |
-
|
341 |
-
.aws-search-result .aws_result_stock {
|
342 |
-
display: block;
|
343 |
-
font-weight: normal;
|
344 |
-
margin-top: 4px;
|
345 |
-
margin-bottom: 5px;
|
346 |
-
color: #7ad03a;
|
347 |
-
}
|
348 |
-
.aws-search-result .aws_result_stock.out {
|
349 |
-
color: #a44;
|
350 |
-
}
|
351 |
-
|
352 |
-
.aws-search-result .aws_result_sku {
|
353 |
-
display: block;
|
354 |
-
font-weight: normal;
|
355 |
-
margin-top: 3px;
|
356 |
-
margin-bottom: 5px;
|
357 |
-
color: #222;
|
358 |
-
}
|
359 |
-
|
360 |
-
.aws-search-result .aws_result_cat .aws_result_title,
|
361 |
-
.aws-search-result .aws_result_tag .aws_result_title {
|
362 |
-
margin-bottom: 2px;
|
363 |
-
}
|
364 |
-
|
365 |
-
.aws-search-result .aws_result_excerpt {
|
366 |
-
display: block;
|
367 |
-
color: #222;
|
368 |
-
}
|
369 |
-
|
370 |
-
.aws-search-result .aws_result_price {
|
371 |
-
display: block;
|
372 |
-
padding: 2px 0;
|
373 |
-
color: #222;
|
374 |
-
}
|
375 |
-
|
376 |
-
.aws-search-result .aws_result_price del,
|
377 |
-
.aws-search-result .aws_result_price ins {
|
378 |
-
background: none;
|
379 |
-
padding: 0 12px 0 0;
|
380 |
-
opacity: 1;
|
381 |
-
}
|
382 |
-
|
383 |
-
.aws-search-result .aws_result_price del {
|
384 |
-
opacity: 0.8;
|
385 |
-
text-decoration: line-through !important;
|
386 |
-
}
|
387 |
-
|
388 |
-
.aws-search-result .aws_result_cats {
|
389 |
-
display: block;
|
390 |
-
float: left;
|
391 |
-
margin: 0 20px 0 0;
|
392 |
-
}
|
393 |
-
|
394 |
-
.aws-search-result .aws_result_image {
|
395 |
-
display: block;
|
396 |
-
height: 100%;
|
397 |
-
float: left;
|
398 |
-
padding: 0 10px 0 0;
|
399 |
-
}
|
400 |
-
.aws-search-result .aws_result_image img {
|
401 |
-
width: 50px;
|
402 |
-
height: auto;
|
403 |
-
box-shadow: none;
|
404 |
-
}
|
405 |
-
|
406 |
-
.aws-search-result .aws_result_sale {
|
407 |
-
display: block;
|
408 |
-
height: 42px;
|
409 |
-
overflow: hidden;
|
410 |
-
position: absolute;
|
411 |
-
right: 0;
|
412 |
-
top: 0;
|
413 |
-
width: 47px;
|
414 |
-
}
|
415 |
-
|
416 |
-
.aws-search-result .aws_onsale {
|
417 |
-
background: #77a464 none repeat scroll 0 0;
|
418 |
-
color: #fff;
|
419 |
-
display: block;
|
420 |
-
float: right;
|
421 |
-
height: 20px;
|
422 |
-
padding-top: 2px;
|
423 |
-
position: relative;
|
424 |
-
right: -25px;
|
425 |
-
text-align: center;
|
426 |
-
top: 3px;
|
427 |
-
transform: rotate(45deg);
|
428 |
-
width: 77px;
|
429 |
-
}
|
430 |
-
|
431 |
-
.aws-search-result .aws_no_result {
|
432 |
-
line-height: 1.5;
|
433 |
-
padding: 10px 6px;
|
434 |
-
cursor: auto;
|
435 |
-
}
|
436 |
-
|
437 |
-
.aws-search-result .aws_search_more {
|
438 |
-
|
439 |
-
}
|
440 |
-
.aws-search-result .aws_search_more a {
|
441 |
-
line-height: 40px;
|
442 |
-
display: block;
|
443 |
-
text-decoration: none;
|
444 |
-
border: 0;
|
445 |
-
text-align: center;
|
446 |
-
color: #21759b;
|
447 |
-
}
|
448 |
-
.aws-search-result .aws_search_more a:hover {
|
449 |
-
background: #f5f5f5;
|
450 |
-
}
|
451 |
-
|
452 |
-
/* Mobile form overlay */
|
453 |
-
|
454 |
-
body.aws-overlay {
|
455 |
-
overflow: hidden !important;
|
456 |
-
position: fixed;
|
457 |
-
width: 100%;
|
458 |
-
}
|
459 |
-
|
460 |
-
.aws-container.aws-mobile-fixed {
|
461 |
-
position: fixed !important;
|
462 |
-
z-index: 9999999 !important;
|
463 |
-
top: 10px !important;
|
464 |
-
left: 20px !important;
|
465 |
-
width: 100%;
|
466 |
-
width: calc(100% - 40px) !important;
|
467 |
-
}
|
468 |
-
|
469 |
-
.aws-mobile-fixed-close {
|
470 |
-
padding: 15px;
|
471 |
-
margin-right: -10px;
|
472 |
-
display: inline-block;
|
473 |
-
float: right;
|
474 |
-
cursor: pointer;
|
475 |
-
}
|
476 |
-
|
477 |
-
.aws-overlay-mask {
|
478 |
-
display: block;
|
479 |
-
position: fixed;
|
480 |
-
top: 0;
|
481 |
-
left: 0;
|
482 |
-
right: 0;
|
483 |
-
bottom: 0;
|
484 |
-
opacity: 0;
|
485 |
-
background: #fff;
|
486 |
-
z-index: 9999998 !important;
|
487 |
-
}
|
488 |
-
.aws-overlay .aws-overlay-mask {
|
489 |
-
opacity: 1;
|
490 |
-
}
|
491 |
-
|
492 |
-
/* Integrations */
|
493 |
-
|
494 |
-
.et_search_outer .aws-container {
|
495 |
-
width: 60%;
|
496 |
-
}
|
497 |
-
.et_search_outer .aws-container .aws-search-form {
|
498 |
-
max-width: 100% !important;
|
499 |
-
}
|
500 |
-
.et_vertical_nav .et_search_outer .aws-container {
|
501 |
-
width: auto;
|
502 |
-
margin: 0 20px 0 0;
|
503 |
-
}
|
504 |
-
.et_fixed_nav .et-fixed-header .et_search_outer .aws-container {
|
505 |
-
top: 7px;
|
506 |
-
}
|
507 |
-
.et_pb_menu__search .aws-container {
|
508 |
-
width: 100%;
|
509 |
-
}
|
510 |
-
|
511 |
-
#et-boc .aws-container .aws-search-field {
|
512 |
-
border: 1px solid #d8d8d8;
|
513 |
-
padding: 6px 15px;
|
514 |
-
}
|
515 |
-
#et-boc .aws-container .aws-search-form .aws-form-btn {
|
516 |
-
background: #ededed;
|
517 |
-
border: 1px solid #d8d8d8;
|
518 |
-
margin: 0 0 0 -1px;
|
519 |
-
}
|
520 |
-
#et-boc .aws-container .aws-search-form .aws-wrapper .aws-loader {
|
521 |
-
border-top: 3px solid #ededed;
|
522 |
-
border-right: 3px solid #ededed;
|
523 |
-
border-bottom: 3px solid #ededed;
|
524 |
-
border-left: 3px solid #555;
|
525 |
-
margin: 0;
|
526 |
-
margin-top: -10px;
|
527 |
-
}
|
528 |
-
#et-boc .aws-container .aws-search-form .aws-search-clear span {
|
529 |
-
margin-top: -12px;
|
530 |
-
}
|
531 |
-
#et-boc .aws-container .aws-search-form .aws-search-clear {
|
532 |
-
padding: 0 0 0 10px;
|
533 |
}
|
1 |
+
.aws-container .aws-search-form {
|
2 |
+
position: relative;
|
3 |
+
width: 100%;
|
4 |
+
float: none !important;
|
5 |
+
display: -webkit-box !important;
|
6 |
+
display: -moz-box !important;
|
7 |
+
display: -ms-flexbox !important;
|
8 |
+
display: -webkit-flex !important;
|
9 |
+
display: flex !important;
|
10 |
+
align-items: stretch;
|
11 |
+
height: 44px;
|
12 |
+
}
|
13 |
+
|
14 |
+
.aws-container .aws-search-form *,
|
15 |
+
.aws-search-result {
|
16 |
+
-moz-box-sizing: border-box;
|
17 |
+
-webkit-box-sizing: border-box;
|
18 |
+
box-sizing: border-box;
|
19 |
+
-moz-hyphens: manual;
|
20 |
+
-webkit-hyphens: manual;
|
21 |
+
hyphens: manual;
|
22 |
+
border-radius: 0 !important;
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
.aws-container .aws-search-form .aws-loader,
|
27 |
+
.aws-container .aws-search-form .aws-loader:after {
|
28 |
+
border-radius: 50% !important;
|
29 |
+
width: 20px;
|
30 |
+
height: 20px;
|
31 |
+
}
|
32 |
+
|
33 |
+
.aws-container .aws-search-form .aws-wrapper {
|
34 |
+
flex-grow: 1;
|
35 |
+
position: relative;
|
36 |
+
vertical-align: top;
|
37 |
+
padding: 0;
|
38 |
+
width: 100%;
|
39 |
+
}
|
40 |
+
|
41 |
+
.aws-container .aws-search-form .aws-loader {
|
42 |
+
position: absolute;
|
43 |
+
display: none;
|
44 |
+
right: 10px;
|
45 |
+
top: 50%;
|
46 |
+
z-index: 999;
|
47 |
+
margin: 0;
|
48 |
+
margin-top: -10px;
|
49 |
+
font-size: 10px;
|
50 |
+
text-indent: -9999em;
|
51 |
+
border-top: 3px solid #ededed;
|
52 |
+
border-right: 3px solid #ededed;
|
53 |
+
border-bottom: 3px solid #ededed;
|
54 |
+
border-left: 3px solid #555;
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
.aws-container .aws-search-form.aws-processing .aws-loader {
|
59 |
+
display: block;
|
60 |
+
-webkit-transform: translateZ(0);
|
61 |
+
-ms-transform: translateZ(0);
|
62 |
+
transform: translateZ(0);
|
63 |
+
-webkit-animation: load8 0.7s infinite linear;
|
64 |
+
animation: load8 0.7s infinite linear;
|
65 |
+
}
|
66 |
+
|
67 |
+
@-webkit-keyframes load8 {
|
68 |
+
0% {
|
69 |
+
-webkit-transform: rotate(0deg);
|
70 |
+
transform: rotate(0deg);
|
71 |
+
}
|
72 |
+
100% {
|
73 |
+
-webkit-transform: rotate(360deg);
|
74 |
+
transform: rotate(360deg);
|
75 |
+
}
|
76 |
+
}
|
77 |
+
@keyframes load8 {
|
78 |
+
0% {
|
79 |
+
-webkit-transform: rotate(0deg);
|
80 |
+
transform: rotate(0deg);
|
81 |
+
}
|
82 |
+
100% {
|
83 |
+
-webkit-transform: rotate(360deg);
|
84 |
+
transform: rotate(360deg);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
.aws-container .aws-search-label {
|
89 |
+
position: absolute !important;
|
90 |
+
left: -10000px;
|
91 |
+
top: auto;
|
92 |
+
width: 1px;
|
93 |
+
height: 1px;
|
94 |
+
overflow: hidden;
|
95 |
+
clip: rect(1px, 1px, 1px, 1px);
|
96 |
+
}
|
97 |
+
|
98 |
+
.aws-container .aws-search-field {
|
99 |
+
width: 100%;
|
100 |
+
max-width: 100%;
|
101 |
+
color: #313131;
|
102 |
+
padding: 6px;
|
103 |
+
line-height: 30px;
|
104 |
+
display: block;
|
105 |
+
font-size: 12px;
|
106 |
+
position: relative;
|
107 |
+
z-index: 2;
|
108 |
+
-webkit-appearance: none;
|
109 |
+
height: 100%;
|
110 |
+
margin: 0 !important;
|
111 |
+
border: 1px solid #d8d8d8;
|
112 |
+
outline: 0;
|
113 |
+
}
|
114 |
+
|
115 |
+
/* Mobile zoom disable */
|
116 |
+
@media screen and (-webkit-min-device-pixel-ratio:0) and (max-device-width:1024px) {
|
117 |
+
.aws-container .aws-search-field {
|
118 |
+
font-size: 16px;
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
.aws-container .aws-search-field::-ms-clear { display: none; width : 0; height: 0; }
|
123 |
+
.aws-container .aws-search-field::-ms-reveal { display: none; width : 0; height: 0; }
|
124 |
+
|
125 |
+
.aws-container .aws-search-field::-webkit-search-decoration,
|
126 |
+
.aws-container .aws-search-field::-webkit-search-cancel-button,
|
127 |
+
.aws-container .aws-search-field::-webkit-search-results-button,
|
128 |
+
.aws-container .aws-search-field::-webkit-search-results-decoration {
|
129 |
+
display: none;
|
130 |
+
}
|
131 |
+
|
132 |
+
.aws-container .aws-search-field:focus {
|
133 |
+
background-color: #fff;
|
134 |
+
}
|
135 |
+
|
136 |
+
.aws-container .aws-show-clear .aws-search-field {
|
137 |
+
padding-right: 40px;
|
138 |
+
}
|
139 |
+
|
140 |
+
.aws-container .aws-search-field:focus::-webkit-input-placeholder { color:transparent; }
|
141 |
+
.aws-container .aws-search-field:focus:-moz-placeholder { color:transparent; }
|
142 |
+
.aws-container .aws-search-field:focus::-moz-placeholder { color:transparent; }
|
143 |
+
.aws-container .aws-search-field:focus:-ms-input-placeholder { color:transparent; }
|
144 |
+
|
145 |
+
|
146 |
+
/* Clear button */
|
147 |
+
.aws-container .aws-search-form .aws-search-clear {
|
148 |
+
display: none !important;
|
149 |
+
position: absolute;
|
150 |
+
top: 0;
|
151 |
+
right: 0;
|
152 |
+
z-index: 2;
|
153 |
+
cursor: pointer;
|
154 |
+
color: #757575;
|
155 |
+
height: 100%;
|
156 |
+
width: 38px;
|
157 |
+
padding: 0 0 0 10px;
|
158 |
+
text-align: left;
|
159 |
+
}
|
160 |
+
.aws-container .aws-search-form .aws-search-clear span {
|
161 |
+
position: relative;
|
162 |
+
display: block;
|
163 |
+
font-size: 24px;
|
164 |
+
line-height: 24px;
|
165 |
+
top: 50%;
|
166 |
+
margin-top: -12px;
|
167 |
+
}
|
168 |
+
|
169 |
+
.aws-container .aws-search-form.aws-show-clear.aws-form-active .aws-search-clear {
|
170 |
+
display: block !important;
|
171 |
+
}
|
172 |
+
|
173 |
+
.aws-container .aws-search-form.aws-form-active.aws-processing .aws-search-clear {
|
174 |
+
display: none !important;
|
175 |
+
}
|
176 |
+
|
177 |
+
|
178 |
+
/* Search button */
|
179 |
+
.aws-container .aws-search-form .aws-search-btn {
|
180 |
+
padding: 0;
|
181 |
+
line-height: 10px;
|
182 |
+
width: 42px;
|
183 |
+
}
|
184 |
+
|
185 |
+
.aws-container .aws-search-form .aws-search-btn_icon {
|
186 |
+
display: inline-block;
|
187 |
+
fill: currentColor;
|
188 |
+
height: 24px;
|
189 |
+
line-height: 24px;
|
190 |
+
position: relative;
|
191 |
+
width: 42px;
|
192 |
+
color: #555;
|
193 |
+
}
|
194 |
+
|
195 |
+
.aws-container .aws-search-form .aws-search-btn svg {
|
196 |
+
display: block;
|
197 |
+
height: 100%;
|
198 |
+
width: 100%;
|
199 |
+
}
|
200 |
+
|
201 |
+
.aws-container[data-show-page="false"] .aws-search-form .aws-search-btn:hover {
|
202 |
+
background: #ededed;
|
203 |
+
cursor: default;
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
/* Form buttons */
|
208 |
+
.aws-container .aws-search-form .aws-form-btn {
|
209 |
+
display: -webkit-box;
|
210 |
+
display: -moz-box;
|
211 |
+
display: -ms-flexbox;
|
212 |
+
display: -webkit-flex;
|
213 |
+
display: flex;
|
214 |
+
justify-content: center;
|
215 |
+
flex-direction: column;
|
216 |
+
text-align: center;
|
217 |
+
|
218 |
+
background: #ededed;
|
219 |
+
border: 1px solid #d8d8d8;
|
220 |
+
/*border-left: none;*/
|
221 |
+
margin: 0 0 0 -1px;
|
222 |
+
cursor: pointer;
|
223 |
+
position: relative;
|
224 |
+
white-space: nowrap;
|
225 |
+
|
226 |
+
-moz-user-select: none;
|
227 |
+
-ms-user-select: none;
|
228 |
+
user-select: none;
|
229 |
+
|
230 |
+
-webkit-transition: background-color 100ms ease-in-out;
|
231 |
+
-moz-transition: background-color 100ms ease-in-out;
|
232 |
+
-o-transition: background-color 100ms ease-in-out;
|
233 |
+
transition: background-color 100ms ease-in-out;
|
234 |
+
}
|
235 |
+
.aws-container .aws-search-form .aws-form-btn:hover {
|
236 |
+
background: #dcdcdc;
|
237 |
+
}
|
238 |
+
.aws-container .aws-search-form .aws-form-btn:active {
|
239 |
+
background: #d8d8d8;
|
240 |
+
}
|
241 |
+
|
242 |
+
|
243 |
+
/* Form buttons layouts */
|
244 |
+
.aws-container[data-buttons-order="3"] .aws-search-form .aws-wrapper{
|
245 |
+
-webkit-order: 2;
|
246 |
+
order: 2;
|
247 |
+
}
|
248 |
+
|
249 |
+
.aws-container[data-buttons-order="3"] .aws-search-form .aws-search-btn{
|
250 |
+
margin: 0 -1px 0 0;
|
251 |
+
}
|
252 |
+
|
253 |
+
.aws-search-result {
|
254 |
+
position: absolute;
|
255 |
+
text-align: left;
|
256 |
+
z-index: 9999999999999;
|
257 |
+
background: #fff;
|
258 |
+
width: 100%;
|
259 |
+
margin-top: -1px;
|
260 |
+
border: 1px solid #ccc;
|
261 |
+
font-size: 12px;
|
262 |
+
line-height: 16px;
|
263 |
+
}
|
264 |
+
|
265 |
+
.aws-search-result ul {
|
266 |
+
list-style: none;
|
267 |
+
padding: 0 !important;
|
268 |
+
margin: 0 !important;
|
269 |
+
max-height: 400px;
|
270 |
+
overflow-y: auto;
|
271 |
+
}
|
272 |
+
|
273 |
+
.aws-search-result ul::-webkit-scrollbar-track {
|
274 |
+
-webkit-box-shadow: none;
|
275 |
+
background-color: #ededed;
|
276 |
+
}
|
277 |
+
.aws-search-result ul::-webkit-scrollbar {
|
278 |
+
width: 7px;
|
279 |
+
background-color: #ededed;
|
280 |
+
}
|
281 |
+
|
282 |
+
.aws-search-result ul::-webkit-scrollbar-thumb {
|
283 |
+
background-color: #d8d8d8;
|
284 |
+
}
|
285 |
+
|
286 |
+
.aws-search-result ul li {
|
287 |
+
list-style: none;
|
288 |
+
border-bottom: 1px solid #ccc;
|
289 |
+
overflow: hidden;
|
290 |
+
margin: 0 !important;
|
291 |
+
position: relative;
|
292 |
+
}
|
293 |
+
|
294 |
+
.aws-search-result ul li:last-child {
|
295 |
+
border-bottom: 0;
|
296 |
+
}
|
297 |
+
|
298 |
+
|
299 |
+
.aws-search-result .aws_result_link {
|
300 |
+
display: block;
|
301 |
+
cursor: pointer;
|
302 |
+
padding: 10px 8px;
|
303 |
+
height: 100%;
|
304 |
+
overflow: hidden;
|
305 |
+
text-decoration: none;
|
306 |
+
border: 0;
|
307 |
+
}
|
308 |
+
|
309 |
+
|
310 |
+
.aws-search-result .aws_result_item:hover,
|
311 |
+
.aws-search-result .aws_result_item.hovered {
|
312 |
+
background: #f5f5f5;
|
313 |
+
}
|
314 |
+
|
315 |
+
|
316 |
+
.aws-search-result .aws_result_content {
|
317 |
+
overflow: hidden;
|
318 |
+
display: block;
|
319 |
+
}
|
320 |
+
|
321 |
+
.aws-search-result .aws_result_title {
|
322 |
+
display: block;
|
323 |
+
font-weight: normal;
|
324 |
+
margin-bottom: 3px;
|
325 |
+
color: #21759b;
|
326 |
+
}
|
327 |
+
|
328 |
+
.aws-search-result .aws_result_featured {
|
329 |
+
margin: 0 6px 0 0;
|
330 |
+
position: relative;
|
331 |
+
top: -2px;
|
332 |
+
}
|
333 |
+
|
334 |
+
.aws-search-result .aws_result_featured svg {
|
335 |
+
width: 13px;
|
336 |
+
height: 13px;
|
337 |
+
fill: #fa0;
|
338 |
+
vertical-align: bottom;
|
339 |
+
}
|
340 |
+
|
341 |
+
.aws-search-result .aws_result_stock {
|
342 |
+
display: block;
|
343 |
+
font-weight: normal;
|
344 |
+
margin-top: 4px;
|
345 |
+
margin-bottom: 5px;
|
346 |
+
color: #7ad03a;
|
347 |
+
}
|
348 |
+
.aws-search-result .aws_result_stock.out {
|
349 |
+
color: #a44;
|
350 |
+
}
|
351 |
+
|
352 |
+
.aws-search-result .aws_result_sku {
|
353 |
+
display: block;
|
354 |
+
font-weight: normal;
|
355 |
+
margin-top: 3px;
|
356 |
+
margin-bottom: 5px;
|
357 |
+
color: #222;
|
358 |
+
}
|
359 |
+
|
360 |
+
.aws-search-result .aws_result_cat .aws_result_title,
|
361 |
+
.aws-search-result .aws_result_tag .aws_result_title {
|
362 |
+
margin-bottom: 2px;
|
363 |
+
}
|
364 |
+
|
365 |
+
.aws-search-result .aws_result_excerpt {
|
366 |
+
display: block;
|
367 |
+
color: #222;
|
368 |
+
}
|
369 |
+
|
370 |
+
.aws-search-result .aws_result_price {
|
371 |
+
display: block;
|
372 |
+
padding: 2px 0;
|
373 |
+
color: #222;
|
374 |
+
}
|
375 |
+
|
376 |
+
.aws-search-result .aws_result_price del,
|
377 |
+
.aws-search-result .aws_result_price ins {
|
378 |
+
background: none;
|
379 |
+
padding: 0 12px 0 0;
|
380 |
+
opacity: 1;
|
381 |
+
}
|
382 |
+
|
383 |
+
.aws-search-result .aws_result_price del {
|
384 |
+
opacity: 0.8;
|
385 |
+
text-decoration: line-through !important;
|
386 |
+
}
|
387 |
+
|
388 |
+
.aws-search-result .aws_result_cats {
|
389 |
+
display: block;
|
390 |
+
float: left;
|
391 |
+
margin: 0 20px 0 0;
|
392 |
+
}
|
393 |
+
|
394 |
+
.aws-search-result .aws_result_image {
|
395 |
+
display: block;
|
396 |
+
height: 100%;
|
397 |
+
float: left;
|
398 |
+
padding: 0 10px 0 0;
|
399 |
+
}
|
400 |
+
.aws-search-result .aws_result_image img {
|
401 |
+
width: 50px;
|
402 |
+
height: auto;
|
403 |
+
box-shadow: none;
|
404 |
+
}
|
405 |
+
|
406 |
+
.aws-search-result .aws_result_sale {
|
407 |
+
display: block;
|
408 |
+
height: 42px;
|
409 |
+
overflow: hidden;
|
410 |
+
position: absolute;
|
411 |
+
right: 0;
|
412 |
+
top: 0;
|
413 |
+
width: 47px;
|
414 |
+
}
|
415 |
+
|
416 |
+
.aws-search-result .aws_onsale {
|
417 |
+
background: #77a464 none repeat scroll 0 0;
|
418 |
+
color: #fff;
|
419 |
+
display: block;
|
420 |
+
float: right;
|
421 |
+
height: 20px;
|
422 |
+
padding-top: 2px;
|
423 |
+
position: relative;
|
424 |
+
right: -25px;
|
425 |
+
text-align: center;
|
426 |
+
top: 3px;
|
427 |
+
transform: rotate(45deg);
|
428 |
+
width: 77px;
|
429 |
+
}
|
430 |
+
|
431 |
+
.aws-search-result .aws_no_result {
|
432 |
+
line-height: 1.5;
|
433 |
+
padding: 10px 6px;
|
434 |
+
cursor: auto;
|
435 |
+
}
|
436 |
+
|
437 |
+
.aws-search-result .aws_search_more {
|
438 |
+
|
439 |
+
}
|
440 |
+
.aws-search-result .aws_search_more a {
|
441 |
+
line-height: 40px;
|
442 |
+
display: block;
|
443 |
+
text-decoration: none;
|
444 |
+
border: 0;
|
445 |
+
text-align: center;
|
446 |
+
color: #21759b;
|
447 |
+
}
|
448 |
+
.aws-search-result .aws_search_more a:hover {
|
449 |
+
background: #f5f5f5;
|
450 |
+
}
|
451 |
+
|
452 |
+
/* Mobile form overlay */
|
453 |
+
|
454 |
+
body.aws-overlay {
|
455 |
+
overflow: hidden !important;
|
456 |
+
position: fixed;
|
457 |
+
width: 100%;
|
458 |
+
}
|
459 |
+
|
460 |
+
.aws-container.aws-mobile-fixed {
|
461 |
+
position: fixed !important;
|
462 |
+
z-index: 9999999 !important;
|
463 |
+
top: 10px !important;
|
464 |
+
left: 20px !important;
|
465 |
+
width: 100%;
|
466 |
+
width: calc(100% - 40px) !important;
|
467 |
+
}
|
468 |
+
|
469 |
+
.aws-mobile-fixed-close {
|
470 |
+
padding: 15px;
|
471 |
+
margin-right: -10px;
|
472 |
+
display: inline-block;
|
473 |
+
float: right;
|
474 |
+
cursor: pointer;
|
475 |
+
}
|
476 |
+
|
477 |
+
.aws-overlay-mask {
|
478 |
+
display: block;
|
479 |
+
position: fixed;
|
480 |
+
top: 0;
|
481 |
+
left: 0;
|
482 |
+
right: 0;
|
483 |
+
bottom: 0;
|
484 |
+
opacity: 0;
|
485 |
+
background: #fff;
|
486 |
+
z-index: 9999998 !important;
|
487 |
+
}
|
488 |
+
.aws-overlay .aws-overlay-mask {
|
489 |
+
opacity: 1;
|
490 |
+
}
|
491 |
+
|
492 |
+
/* Integrations */
|
493 |
+
|
494 |
+
.et_search_outer .aws-container {
|
495 |
+
width: 60%;
|
496 |
+
}
|
497 |
+
.et_search_outer .aws-container .aws-search-form {
|
498 |
+
max-width: 100% !important;
|
499 |
+
}
|
500 |
+
.et_vertical_nav .et_search_outer .aws-container {
|
501 |
+
width: auto;
|
502 |
+
margin: 0 20px 0 0;
|
503 |
+
}
|
504 |
+
.et_fixed_nav .et-fixed-header .et_search_outer .aws-container {
|
505 |
+
top: 7px;
|
506 |
+
}
|
507 |
+
.et_pb_menu__search .aws-container {
|
508 |
+
width: 100%;
|
509 |
+
}
|
510 |
+
|
511 |
+
#et-boc .aws-container .aws-search-field {
|
512 |
+
border: 1px solid #d8d8d8;
|
513 |
+
padding: 6px 15px;
|
514 |
+
}
|
515 |
+
#et-boc .aws-container .aws-search-form .aws-form-btn {
|
516 |
+
background: #ededed;
|
517 |
+
border: 1px solid #d8d8d8;
|
518 |
+
margin: 0 0 0 -1px;
|
519 |
+
}
|
520 |
+
#et-boc .aws-container .aws-search-form .aws-wrapper .aws-loader {
|
521 |
+
border-top: 3px solid #ededed;
|
522 |
+
border-right: 3px solid #ededed;
|
523 |
+
border-bottom: 3px solid #ededed;
|
524 |
+
border-left: 3px solid #555;
|
525 |
+
margin: 0;
|
526 |
+
margin-top: -10px;
|
527 |
+
}
|
528 |
+
#et-boc .aws-container .aws-search-form .aws-search-clear span {
|
529 |
+
margin-top: -12px;
|
530 |
+
}
|
531 |
+
#et-boc .aws-container .aws-search-form .aws-search-clear {
|
532 |
+
padding: 0 0 0 10px;
|
533 |
}
|
assets/js/admin.js
CHANGED
@@ -1,194 +1,194 @@
|
|
1 |
-
jQuery(document).ready(function ($) {
|
2 |
-
'use strict';
|
3 |
-
|
4 |
-
var $reindexBlock = $('#aws-reindex');
|
5 |
-
var $reindexBtn = $('#aws-reindex .button');
|
6 |
-
var $reindexProgress = $('#aws-reindex .reindex-progress');
|
7 |
-
var $reindexCount = $('#aws-reindex-count strong');
|
8 |
-
var syncStatus;
|
9 |
-
var processed;
|
10 |
-
var toProcess;
|
11 |
-
var syncData = false;
|
12 |
-
|
13 |
-
var $clearCacheBtn = $('#aws-clear-cache .button');
|
14 |
-
|
15 |
-
|
16 |
-
// Reindex table
|
17 |
-
$reindexBtn.on( 'click', function(e) {
|
18 |
-
|
19 |
-
e.preventDefault();
|
20 |
-
|
21 |
-
syncStatus = 'sync';
|
22 |
-
toProcess = 0;
|
23 |
-
processed = 0;
|
24 |
-
|
25 |
-
$reindexBlock.addClass('loading');
|
26 |
-
$reindexProgress.html ( processed + '%' );
|
27 |
-
|
28 |
-
sync('start');
|
29 |
-
|
30 |
-
});
|
31 |
-
|
32 |
-
|
33 |
-
function sync( data ) {
|
34 |
-
|
35 |
-
$.ajax({
|
36 |
-
type: 'POST',
|
37 |
-
url: aws_vars.ajaxurl,
|
38 |
-
data: {
|
39 |
-
action: 'aws-reindex',
|
40 |
-
data: data,
|
41 |
-
_ajax_nonce: aws_vars.ajax_nonce
|
42 |
-
},
|
43 |
-
dataType: "json",
|
44 |
-
timeout:0,
|
45 |
-
success: function (response) {
|
46 |
-
if ( 'sync' !== syncStatus ) {
|
47 |
-
return;
|
48 |
-
}
|
49 |
-
|
50 |
-
toProcess = response.data.found_posts;
|
51 |
-
processed = response.data.offset;
|
52 |
-
|
53 |
-
processed = Math.floor( processed / toProcess * 100 );
|
54 |
-
|
55 |
-
syncData = response.data;
|
56 |
-
|
57 |
-
if ( 0 === response.data.offset && ! response.data.start ) {
|
58 |
-
|
59 |
-
// Sync finished
|
60 |
-
syncStatus = 'finished';
|
61 |
-
|
62 |
-
console.log( response.data );
|
63 |
-
console.log( "Reindex finished!" );
|
64 |
-
|
65 |
-
$reindexBlock.removeClass('loading');
|
66 |
-
|
67 |
-
$reindexCount.text( response.data.found_posts );
|
68 |
-
|
69 |
-
} else {
|
70 |
-
|
71 |
-
console.log( response.data );
|
72 |
-
|
73 |
-
$reindexProgress.html( processed + '%' );
|
74 |
-
|
75 |
-
// We are starting a sync
|
76 |
-
syncStatus = 'sync';
|
77 |
-
|
78 |
-
sync( response.data );
|
79 |
-
}
|
80 |
-
|
81 |
-
},
|
82 |
-
error : function( jqXHR, textStatus, errorThrown ) {
|
83 |
-
console.log( "Request failed: " + textStatus );
|
84 |
-
|
85 |
-
if ( textStatus == 'timeout' || jqXHR.status == 504 ) {
|
86 |
-
console.log( 'timeout' );
|
87 |
-
if ( syncData ) {
|
88 |
-
setTimeout(function() { sync( syncData ); }, 1000);
|
89 |
-
}
|
90 |
-
} else if ( textStatus == 'error') {
|
91 |
-
if ( syncData ) {
|
92 |
-
|
93 |
-
if ( 0 !== syncData.offset && ! syncData.start ) {
|
94 |
-
setTimeout(function() { sync( syncData ); }, 3000);
|
95 |
-
}
|
96 |
-
|
97 |
-
}
|
98 |
-
}
|
99 |
-
|
100 |
-
},
|
101 |
-
complete: function ( jqXHR, textStatus ) {
|
102 |
-
}
|
103 |
-
});
|
104 |
-
|
105 |
-
}
|
106 |
-
|
107 |
-
// Clear cache
|
108 |
-
$clearCacheBtn.on( 'click', function(e) {
|
109 |
-
|
110 |
-
e.preventDefault();
|
111 |
-
|
112 |
-
var $clearCacheBlock = $(this).closest('#aws-clear-cache');
|
113 |
-
|
114 |
-
$clearCacheBlock.addClass('loading');
|
115 |
-
|
116 |
-
$.ajax({
|
117 |
-
type: 'POST',
|
118 |
-
url: aws_vars.ajaxurl,
|
119 |
-
data: {
|
120 |
-
action: 'aws-clear-cache',
|
121 |
-
_ajax_nonce: aws_vars.ajax_nonce
|
122 |
-
},
|
123 |
-
dataType: "json",
|
124 |
-
success: function (data) {
|
125 |
-
alert('Cache cleared!');
|
126 |
-
$clearCacheBlock.removeClass('loading');
|
127 |
-
}
|
128 |
-
});
|
129 |
-
|
130 |
-
});
|
131 |
-
|
132 |
-
|
133 |
-
// Change option state
|
134 |
-
|
135 |
-
var changingState = false;
|
136 |
-
|
137 |
-
$('[data-change-state]').on( 'click', function(e) {
|
138 |
-
|
139 |
-
e.preventDefault();
|
140 |
-
|
141 |
-
if ( changingState ) {
|
142 |
-
return;
|
143 |
-
} else {
|
144 |
-
changingState = true;
|
145 |
-
}
|
146 |
-
|
147 |
-
var self = $(this);
|
148 |
-
var $parent = self.closest('td');
|
149 |
-
var setting = self.data('setting');
|
150 |
-
var option = self.data('name');
|
151 |
-
var state = self.data('change-state');
|
152 |
-
|
153 |
-
$parent.addClass('loading');
|
154 |
-
|
155 |
-
$.ajax({
|
156 |
-
type: 'POST',
|
157 |
-
url: aws_vars.ajaxurl,
|
158 |
-
data: {
|
159 |
-
action: 'aws-changeState',
|
160 |
-
setting: setting,
|
161 |
-
option: option,
|
162 |
-
state: state,
|
163 |
-
_ajax_nonce: aws_vars.ajax_nonce
|
164 |
-
},
|
165 |
-
dataType: "json",
|
166 |
-
success: function (data) {
|
167 |
-
$parent.removeClass('loading');
|
168 |
-
$parent.toggleClass('active');
|
169 |
-
changingState = false;
|
170 |
-
}
|
171 |
-
});
|
172 |
-
|
173 |
-
});
|
174 |
-
|
175 |
-
|
176 |
-
// Dismiss welcome notice
|
177 |
-
|
178 |
-
$( '.aws-welcome-notice.is-dismissible' ).on('click', '.notice-dismiss', function ( event ) {
|
179 |
-
|
180 |
-
$.ajax({
|
181 |
-
type: 'POST',
|
182 |
-
url: aws_vars.ajaxurl,
|
183 |
-
data: {
|
184 |
-
action: 'aws-hideWelcomeNotice',
|
185 |
-
_ajax_nonce: aws_vars.ajax_nonce
|
186 |
-
},
|
187 |
-
dataType: "json",
|
188 |
-
success: function (data) {
|
189 |
-
}
|
190 |
-
});
|
191 |
-
|
192 |
-
});
|
193 |
-
|
194 |
});
|
1 |
+
jQuery(document).ready(function ($) {
|
2 |
+
'use strict';
|
3 |
+
|
4 |
+
var $reindexBlock = $('#aws-reindex');
|
5 |
+
var $reindexBtn = $('#aws-reindex .button');
|
6 |
+
var $reindexProgress = $('#aws-reindex .reindex-progress');
|
7 |
+
var $reindexCount = $('#aws-reindex-count strong');
|
8 |
+
var syncStatus;
|
9 |
+
var processed;
|
10 |
+
var toProcess;
|
11 |
+
var syncData = false;
|
12 |
+
|
13 |
+
var $clearCacheBtn = $('#aws-clear-cache .button');
|
14 |
+
|
15 |
+
|
16 |
+
// Reindex table
|
17 |
+
$reindexBtn.on( 'click', function(e) {
|
18 |
+
|
19 |
+
e.preventDefault();
|
20 |
+
|
21 |
+
syncStatus = 'sync';
|
22 |
+
toProcess = 0;
|
23 |
+
processed = 0;
|
24 |
+
|
25 |
+
$reindexBlock.addClass('loading');
|
26 |
+
$reindexProgress.html ( processed + '%' );
|
27 |
+
|
28 |
+
sync('start');
|
29 |
+
|
30 |
+
});
|
31 |
+
|
32 |
+
|
33 |
+
function sync( data ) {
|
34 |
+
|
35 |
+
$.ajax({
|
36 |
+
type: 'POST',
|
37 |
+
url: aws_vars.ajaxurl,
|
38 |
+
data: {
|
39 |
+
action: 'aws-reindex',
|
40 |
+
data: data,
|
41 |
+
_ajax_nonce: aws_vars.ajax_nonce
|
42 |
+
},
|
43 |
+
dataType: "json",
|
44 |
+
timeout:0,
|
45 |
+
success: function (response) {
|
46 |
+
if ( 'sync' !== syncStatus ) {
|
47 |
+
return;
|
48 |
+
}
|
49 |
+
|
50 |
+
toProcess = response.data.found_posts;
|
51 |
+
processed = response.data.offset;
|
52 |
+
|
53 |
+
processed = Math.floor( processed / toProcess * 100 );
|
54 |
+
|
55 |
+
syncData = response.data;
|
56 |
+
|
57 |
+
if ( 0 === response.data.offset && ! response.data.start ) {
|
58 |
+
|
59 |
+
// Sync finished
|
60 |
+
syncStatus = 'finished';
|
61 |
+
|
62 |
+
console.log( response.data );
|
63 |
+
console.log( "Reindex finished!" );
|
64 |
+
|
65 |
+
$reindexBlock.removeClass('loading');
|
66 |
+
|
67 |
+
$reindexCount.text( response.data.found_posts );
|
68 |
+
|
69 |
+
} else {
|
70 |
+
|
71 |
+
console.log( response.data );
|
72 |
+
|
73 |
+
$reindexProgress.html( processed + '%' );
|
74 |
+
|
75 |
+
// We are starting a sync
|
76 |
+
syncStatus = 'sync';
|
77 |
+
|
78 |
+
sync( response.data );
|
79 |
+
}
|
80 |
+
|
81 |
+
},
|
82 |
+
error : function( jqXHR, textStatus, errorThrown ) {
|
83 |
+
console.log( "Request failed: " + textStatus );
|
84 |
+
|
85 |
+
if ( textStatus == 'timeout' || jqXHR.status == 504 ) {
|
86 |
+
console.log( 'timeout' );
|
87 |
+
if ( syncData ) {
|
88 |
+
setTimeout(function() { sync( syncData ); }, 1000);
|
89 |
+
}
|
90 |
+
} else if ( textStatus == 'error') {
|
91 |
+
if ( syncData ) {
|
92 |
+
|
93 |
+
if ( 0 !== syncData.offset && ! syncData.start ) {
|
94 |
+
setTimeout(function() { sync( syncData ); }, 3000);
|
95 |
+
}
|
96 |
+
|
97 |
+
}
|
98 |
+
}
|
99 |
+
|
100 |
+
},
|
101 |
+
complete: function ( jqXHR, textStatus ) {
|
102 |
+
}
|
103 |
+
});
|
104 |
+
|
105 |
+
}
|
106 |
+
|
107 |
+
// Clear cache
|
108 |
+
$clearCacheBtn.on( 'click', function(e) {
|
109 |
+
|
110 |
+
e.preventDefault();
|
111 |
+
|
112 |
+
var $clearCacheBlock = $(this).closest('#aws-clear-cache');
|
113 |
+
|
114 |
+
$clearCacheBlock.addClass('loading');
|
115 |
+
|
116 |
+
$.ajax({
|
117 |
+
type: 'POST',
|
118 |
+
url: aws_vars.ajaxurl,
|
119 |
+
data: {
|
120 |
+
action: 'aws-clear-cache',
|
121 |
+
_ajax_nonce: aws_vars.ajax_nonce
|
122 |
+
},
|
123 |
+
dataType: "json",
|
124 |
+
success: function (data) {
|
125 |
+
alert('Cache cleared!');
|
126 |
+
$clearCacheBlock.removeClass('loading');
|
127 |
+
}
|
128 |
+
});
|
129 |
+
|
130 |
+
});
|
131 |
+
|
132 |
+
|
133 |
+
// Change option state
|
134 |
+
|
135 |
+
var changingState = false;
|
136 |
+
|
137 |
+
$('[data-change-state]').on( 'click', function(e) {
|
138 |
+
|
139 |
+
e.preventDefault();
|
140 |
+
|
141 |
+
if ( changingState ) {
|
142 |
+
return;
|
143 |
+
} else {
|
144 |
+
changingState = true;
|
145 |
+
}
|
146 |
+
|
147 |
+
var self = $(this);
|
148 |
+
var $parent = self.closest('td');
|
149 |
+
var setting = self.data('setting');
|
150 |
+
var option = self.data('name');
|
151 |
+
var state = self.data('change-state');
|
152 |
+
|
153 |
+
$parent.addClass('loading');
|
154 |
+
|
155 |
+
$.ajax({
|
156 |
+
type: 'POST',
|
157 |
+
url: aws_vars.ajaxurl,
|
158 |
+
data: {
|
159 |
+
action: 'aws-changeState',
|
160 |
+
setting: setting,
|
161 |
+
option: option,
|
162 |
+
state: state,
|
163 |
+
_ajax_nonce: aws_vars.ajax_nonce
|
164 |
+
},
|
165 |
+
dataType: "json",
|
166 |
+
success: function (data) {
|
167 |
+
$parent.removeClass('loading');
|
168 |
+
$parent.toggleClass('active');
|
169 |
+
changingState = false;
|
170 |
+
}
|
171 |
+
});
|
172 |
+
|
173 |
+
});
|
174 |
+
|
175 |
+
|
176 |
+
// Dismiss welcome notice
|
177 |
+
|
178 |
+
$( '.aws-welcome-notice.is-dismissible' ).on('click', '.notice-dismiss', function ( event ) {
|
179 |
+
|
180 |
+
$.ajax({
|
181 |
+
type: 'POST',
|
182 |
+
url: aws_vars.ajaxurl,
|
183 |
+
data: {
|
184 |
+
action: 'aws-hideWelcomeNotice',
|
185 |
+
_ajax_nonce: aws_vars.ajax_nonce
|
186 |
+
},
|
187 |
+
dataType: "json",
|
188 |
+
success: function (data) {
|
189 |
+
}
|
190 |
+
});
|
191 |
+
|
192 |
+
});
|
193 |
+
|
194 |
});
|
assets/js/common.js
CHANGED
@@ -1,703 +1,703 @@
|
|
1 |
-
// Hooks
|
2 |
-
var AwsHooks = AwsHooks || {};
|
3 |
-
AwsHooks.filters = AwsHooks.filters || {};
|
4 |
-
|
5 |
-
(function($){
|
6 |
-
"use strict";
|
7 |
-
|
8 |
-
var selector = '.aws-container';
|
9 |
-
var instance = 0;
|
10 |
-
var pluginPfx = 'aws_opts';
|
11 |
-
var translate = {
|
12 |
-
sale : aws_vars.sale,
|
13 |
-
sku : aws_vars.sku,
|
14 |
-
showmore : aws_vars.showmore,
|
15 |
-
noresults : aws_vars.noresults
|
16 |
-
};
|
17 |
-
|
18 |
-
AwsHooks.add_filter = function( tag, callback, priority ) {
|
19 |
-
|
20 |
-
if( typeof priority === "undefined" ) {
|
21 |
-
priority = 10;
|
22 |
-
}
|
23 |
-
|
24 |
-
AwsHooks.filters[ tag ] = AwsHooks.filters[ tag ] || [];
|
25 |
-
AwsHooks.filters[ tag ].push( { priority: priority, callback: callback } );
|
26 |
-
|
27 |
-
};
|
28 |
-
|
29 |
-
AwsHooks.apply_filters = function( tag, value, options ) {
|
30 |
-
|
31 |
-
var filters = [];
|
32 |
-
|
33 |
-
if( typeof AwsHooks.filters[ tag ] !== "undefined" && AwsHooks.filters[ tag ].length > 0 ) {
|
34 |
-
|
35 |
-
AwsHooks.filters[ tag ].forEach( function( hook ) {
|
36 |
-
|
37 |
-
filters[ hook.priority ] = filters[ hook.priority ] || [];
|
38 |
-
filters[ hook.priority ].push( hook.callback );
|
39 |
-
} );
|
40 |
-
|
41 |
-
filters.forEach( function( AwsHooks ) {
|
42 |
-
|
43 |
-
AwsHooks.forEach( function( callback ) {
|
44 |
-
value = callback( value, options );
|
45 |
-
} );
|
46 |
-
|
47 |
-
} );
|
48 |
-
}
|
49 |
-
|
50 |
-
return value;
|
51 |
-
|
52 |
-
};
|
53 |
-
|
54 |
-
$.fn.aws_search = function( options ) {
|
55 |
-
|
56 |
-
var methods = {
|
57 |
-
|
58 |
-
init: function() {
|
59 |
-
|
60 |
-
// @since 2.16
|
61 |
-
var appendResultsTo = AwsHooks.apply_filters( 'aws_results_append_to', 'body', { instance: instance, form: self, data: d } );
|
62 |
-
|
63 |
-
$(appendResultsTo).append('<div id="aws-search-result-' + instance + '" class="aws-search-result" style="display: none;"></div>');
|
64 |
-
|
65 |
-
methods.addClasses();
|
66 |
-
|
67 |
-
setTimeout(function() { methods.resultLayout(); }, 500);
|
68 |
-
|
69 |
-
},
|
70 |
-
|
71 |
-
onKeyup: function(e) {
|
72 |
-
|
73 |
-
searchFor = $searchField.val();
|
74 |
-
searchFor = searchFor.trim();
|
75 |
-
searchFor = searchFor.replace( /<>\{\}\[\]\\\/]/gi, '' );
|
76 |
-
searchFor = searchFor.replace( /\s\s+/g, ' ' );
|
77 |
-
|
78 |
-
for ( var i = 0; i < requests.length; i++ ) {
|
79 |
-
requests[i].abort();
|
80 |
-
}
|
81 |
-
|
82 |
-
if ( d.showPage == 'ajax_off' ) {
|
83 |
-
return;
|
84 |
-
}
|
85 |
-
|
86 |
-
if ( searchFor === '' ) {
|
87 |
-
$(d.resultBlock).html('').hide();
|
88 |
-
methods.hideLoader();
|
89 |
-
methods.resultsHide();
|
90 |
-
return;
|
91 |
-
}
|
92 |
-
|
93 |
-
if ( cachedResponse.hasOwnProperty( searchFor ) ) {
|
94 |
-
methods.showResults( cachedResponse[searchFor] );
|
95 |
-
return;
|
96 |
-
}
|
97 |
-
|
98 |
-
if ( searchFor.length < d.minChars ) {
|
99 |
-
$(d.resultBlock).html('');
|
100 |
-
methods.hideLoader();
|
101 |
-
return;
|
102 |
-
}
|
103 |
-
|
104 |
-
if ( d.showLoader ) {
|
105 |
-
methods.showLoader();
|
106 |
-
}
|
107 |
-
|
108 |
-
var searchTimeout = d.searchTimeout > 100 ? d.searchTimeout : 300;
|
109 |
-
|
110 |
-
clearTimeout( keyupTimeout );
|
111 |
-
keyupTimeout = setTimeout( function() {
|
112 |
-
methods.ajaxRequest();
|
113 |
-
}, searchTimeout );
|
114 |
-
|
115 |
-
},
|
116 |
-
|
117 |
-
ajaxRequest: function() {
|
118 |
-
|
119 |
-
var data = {
|
120 |
-
action: 'aws_action',
|
121 |
-
keyword : searchFor,
|
122 |
-
aws_page: d.pageId,
|
123 |
-
aws_tax: d.tax,
|
124 |
-
lang: d.lang,
|
125 |
-
pageurl: window.location.href,
|
126 |
-
typedata: 'json'
|
127 |
-
};
|
128 |
-
|
129 |
-
requests.push(
|
130 |
-
|
131 |
-
$.ajax({
|
132 |
-
type: 'POST',
|
133 |
-
url: ajaxUrl,
|
134 |
-
data: data,
|
135 |
-
dataType: 'json',
|
136 |
-
success: function( response ) {
|
137 |
-
|
138 |
-
cachedResponse[searchFor] = response;
|
139 |
-
|
140 |
-
methods.showResults( response );
|
141 |
-
|
142 |
-
methods.showResultsBlock();
|
143 |
-
|
144 |
-
methods.analytics( searchFor );
|
145 |
-
|
146 |
-
},
|
147 |
-
error: function (jqXHR, textStatus, errorThrown) {
|
148 |
-
console.log( "Request failed: " + textStatus );
|
149 |
-
methods.hideLoader();
|
150 |
-
}
|
151 |
-
})
|
152 |
-
|
153 |
-
);
|
154 |
-
|
155 |
-
},
|
156 |
-
|
157 |
-
showResults: function( response ) {
|
158 |
-
|
159 |
-
var resultNum = 0;
|
160 |
-
var html = '<ul>';
|
161 |
-
|
162 |
-
if ( typeof response.tax !== 'undefined' ) {
|
163 |
-
|
164 |
-
$.each(response.tax, function (i, taxes) {
|
165 |
-
|
166 |
-
if ( ( typeof taxes !== 'undefined' ) && taxes.length > 0 ) {
|
167 |
-
$.each(taxes, function (i, taxitem) {
|
168 |
-
|
169 |
-
resultNum++;
|
170 |
-
|
171 |
-
html += '<li class="aws_result_item aws_result_tag">';
|
172 |
-
html += '<a class="aws_result_link" href="' + taxitem.link + '" >';
|
173 |
-
html += '<span class="aws_result_content">';
|
174 |
-
html += '<span class="aws_result_title">';
|
175 |
-
html += taxitem.name;
|
176 |
-
if ( taxitem.count ) {
|
177 |
-
html += '<span class="aws_result_count"> (' + taxitem.count + ')</span>';
|
178 |
-
}
|
179 |
-
html += '</span>';
|
180 |
-
if ( ( typeof taxitem.excerpt !== 'undefined' ) && taxitem.excerpt ) {
|
181 |
-
html += '<span class="aws_result_excerpt">' + taxitem.excerpt + '</span>';
|
182 |
-
}
|
183 |
-
html += '</span>';
|
184 |
-
html += '</a>';
|
185 |
-
html += '</li>';
|
186 |
-
|
187 |
-
});
|
188 |
-
}
|
189 |
-
|
190 |
-
});
|
191 |
-
|
192 |
-
}
|
193 |
-
|
194 |
-
if ( ( typeof response.products !== 'undefined' ) && response.products.length > 0 ) {
|
195 |
-
|
196 |
-
$.each(response.products, function (i, result) {
|
197 |
-
|
198 |
-
resultNum++;
|
199 |
-
|
200 |
-
html += '<li class="aws_result_item">';
|
201 |
-
html += '<a class="aws_result_link" href="' + result.link + '" >';
|
202 |
-
|
203 |
-
if ( result.image ) {
|
204 |
-
html += '<span class="aws_result_image">';
|
205 |
-
html += '<img src="' + result.image + '">';
|
206 |
-
html += '</span>';
|
207 |
-
}
|
208 |
-
|
209 |
-
html += '<span class="aws_result_content">';
|
210 |
-
|
211 |
-
html += '<span class="aws_result_title">';
|
212 |
-
if ( result.featured ) {
|
213 |
-
html += '<span class="aws_result_featured" title="Featured"><svg version="1.1" viewBox="0 0 20 21" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><g fill-rule="evenodd" stroke="none" stroke-width="1"><g transform="translate(-296.000000, -422.000000)"><g transform="translate(296.000000, 422.500000)"><path d="M10,15.273 L16.18,19 L14.545,11.971 L20,7.244 L12.809,6.627 L10,0 L7.191,6.627 L0,7.244 L5.455,11.971 L3.82,19 L10,15.273 Z"/></g></g></g></svg></span>';
|
214 |
-
}
|
215 |
-
html += result.title;
|
216 |
-
html += '</span>';
|
217 |
-
|
218 |
-
if ( result.stock_status ) {
|
219 |
-
var statusClass = result.stock_status.status ? 'in' : 'out';
|
220 |
-
html += '<span class="aws_result_stock ' + statusClass + '">';
|
221 |
-
html += result.stock_status.text;
|
222 |
-
html += '</span>';
|
223 |
-
}
|
224 |
-
|
225 |
-
if ( result.sku ) {
|
226 |
-
html += '<span class="aws_result_sku">' + translate.sku + result.sku + '</span>';
|
227 |
-
}
|
228 |
-
|
229 |
-
if ( result.excerpt ) {
|
230 |
-
html += '<span class="aws_result_excerpt">' + result.excerpt + '</span>';
|
231 |
-
}
|
232 |
-
|
233 |
-
if ( result.price ) {
|
234 |
-
html += '<span class="aws_result_price">' + result.price + '</span>';
|
235 |
-
}
|
236 |
-
|
237 |
-
html += '</span>';
|
238 |
-
|
239 |
-
if ( result.on_sale ) {
|
240 |
-
html += '<span class="aws_result_sale">';
|
241 |
-
html += '<span class="aws_onsale">' + translate.sale + '</span>';
|
242 |
-
html += '</span>';
|
243 |
-
}
|
244 |
-
|
245 |
-
html += '</a>';
|
246 |
-
html += '</li>';
|
247 |
-
|
248 |
-
});
|
249 |
-
|
250 |
-
if ( d.showMore && d.showPage ) {
|
251 |
-
html += '<li class="aws_result_item aws_search_more"><a href="#">' + translate.showmore + '</a></li>';
|
252 |
-
}
|
253 |
-
|
254 |
-
//html += '<li class="aws_result_item"><a href="#">Next Page</a></li>';
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
if ( ! resultNum ) {
|
259 |
-
html += '<li class="aws_result_item aws_no_result">' + translate.noresults + '</li>';
|
260 |
-
}
|
261 |
-
|
262 |
-
|
263 |
-
html += '</ul>';
|
264 |
-
|
265 |
-
// @since 2.05
|
266 |
-
html = AwsHooks.apply_filters( 'aws_results_html', html, { response: response, data: d } );
|
267 |
-
|
268 |
-
|
269 |
-
methods.hideLoader();
|
270 |
-
|
271 |
-
$(d.resultBlock).html( html );
|
272 |
-
|
273 |
-
methods.showResultsBlock();
|
274 |
-
|
275 |
-
if ( eShowResults ) {
|
276 |
-
self[0].dispatchEvent( eShowResults );
|
277 |
-
}
|
278 |
-
|
279 |
-
},
|
280 |
-
|
281 |
-
showResultsBlock: function() {
|
282 |
-
methods.resultLayout();
|
283 |
-
methods.resultsShow();
|
284 |
-
},
|
285 |
-
|
286 |
-
showLoader: function() {
|
287 |
-
$searchForm.addClass('aws-processing');
|
288 |
-
},
|
289 |
-
|
290 |
-
hideLoader: function() {
|
291 |
-
$searchForm.removeClass('aws-processing');
|
292 |
-
},
|
293 |
-
|
294 |
-
resultsShow: function() {
|
295 |
-
$(d.resultBlock).show();
|
296 |
-
$searchForm.addClass('aws-form-active');
|
297 |
-
},
|
298 |
-
|
299 |
-
resultsHide: function() {
|
300 |
-
$(d.resultBlock).hide();
|
301 |
-
$searchForm.removeClass('aws-form-active');
|
302 |
-
},
|
303 |
-
|
304 |
-
onFocus: function( event ) {
|
305 |
-
|
306 |
-
var show = AwsHooks.apply_filters( 'aws_show_modal_layout', false, { instance: instance, form: self, data: d } );
|
307 |
-
|
308 |
-
if ( ! $('body').hasClass('aws-overlay') && ( ( methods.isMobile() && d.mobileScreen && ! methods.isFixed() ) || show ) ) {
|
309 |
-
methods.showMobileLayout();
|
310 |
-
}
|
311 |
-
|
312 |
-
if ( searchFor !== '' ) {
|
313 |
-
methods.showResultsBlock();
|
314 |
-
}
|
315 |
-
|
316 |
-
},
|
317 |
-
|
318 |
-
hideResults: function( event ) {
|
319 |
-
if ( ! $(event.target).closest( ".aws-container" ).length ) {
|
320 |
-
methods.resultsHide();
|
321 |
-
}
|
322 |
-
},
|
323 |
-
|
324 |
-
isResultsVisible:function() {
|
325 |
-
return $(d.resultBlock).is(":visible");
|
326 |
-
},
|
327 |
-
|
328 |
-
removeHovered: function() {
|
329 |
-
$( d.resultBlock ).find('.aws_result_item').removeClass('hovered');
|
330 |
-
},
|
331 |
-
|
332 |
-
resultLayout: function () {
|
333 |
-
|
334 |
-
var $resultsBlock = $( d.resultBlock );
|
335 |
-
var offset = self.offset();
|
336 |
-
var bodyOffset = $('body').offset();
|
337 |
-
var bodyPosition = $('body').css('position');
|
338 |
-
var bodyHeight = $(document).height();
|
339 |
-
var resultsHeight = $resultsBlock.height();
|
340 |
-
|
341 |
-
if ( offset && bodyOffset ) {
|
342 |
-
|
343 |
-
var styles = {
|
344 |
-
width: self.outerWidth(),
|
345 |
-
top : 0,
|
346 |
-
left: 0
|
347 |
-
};
|
348 |
-
|
349 |
-
if ( bodyPosition === 'relative' || bodyPosition === 'absolute' || bodyPosition === 'fixed' ) {
|
350 |
-
styles.top = offset.top + $(self).innerHeight() - bodyOffset.top;
|
351 |
-
styles.left = offset.left - bodyOffset.left;
|
352 |
-
} else {
|
353 |
-
styles.top = offset.top + $(self).innerHeight();
|
354 |
-
styles.left = offset.left;
|
355 |
-
}
|
356 |
-
|
357 |
-
if ( bodyHeight - offset.top < 500 ) {
|
358 |
-
resultsHeight = methods.getResultsBlockHeight();
|
359 |
-
if ( ( bodyHeight - offset.top < resultsHeight ) && ( offset.top >= resultsHeight ) ) {
|
360 |
-
styles.top = styles.top - resultsHeight - $(self).innerHeight();
|
361 |
-
}
|
362 |
-
}
|
363 |
-
|
364 |
-
// @since 2.10
|
365 |
-
styles = AwsHooks.apply_filters( 'aws_results_layout', styles, { resultsBlock: $resultsBlock, form: self } );
|
366 |
-
|
367 |
-
$resultsBlock.css( styles );
|
368 |
-
|
369 |
-
}
|
370 |
-
|
371 |
-
},
|
372 |
-
|
373 |
-
getResultsBlockHeight: function() {
|
374 |
-
|
375 |
-
var $resultsBlock = $( d.resultBlock );
|
376 |
-
var resultsHeight = $resultsBlock.height();
|
377 |
-
|
378 |
-
if ( resultsHeight === 0 ) {
|
379 |
-
var copied_elem = $resultsBlock.clone()
|
380 |
-
.attr("id", false)
|
381 |
-
.css({visibility:"hidden", display:"block",
|
382 |
-
position:"absolute"});
|
383 |
-
$("body").append(copied_elem);
|
384 |
-
//copied_elem.find('.mCSB_outside').attr('style', '');
|
385 |
-
resultsHeight = copied_elem.height();
|
386 |
-
copied_elem.remove();
|
387 |
-
}
|
388 |
-
|
389 |
-
return resultsHeight;
|
390 |
-
|
391 |
-
},
|
392 |
-
|
393 |
-
showMobileLayout: function() {
|
394 |
-
self.after('<div class="aws-placement-container"></div>');
|
395 |
-
self.addClass('aws-mobile-fixed').prepend('<div class="aws-mobile-fixed-close"><svg width="17" height="17" viewBox="1.5 1.5 21 21"><path d="M22.182 3.856c.522-.554.306-1.394-.234-1.938-.54-.543-1.433-.523-1.826-.135C19.73 2.17 11.955 10 11.955 10S4.225 2.154 3.79 1.783c-.438-.371-1.277-.4-1.81.135-.533.537-.628 1.513-.25 1.938.377.424 8.166 8.218 8.166 8.218s-7.85 7.864-8.166 8.219c-.317.354-.34 1.335.25 1.805.59.47 1.24.455 1.81 0 .568-.456 8.166-7.951 8.166-7.951l8.167 7.86c.747.72 1.504.563 1.96.09.456-.471.609-1.268.1-1.804-.508-.537-8.167-8.219-8.167-8.219s7.645-7.665 8.167-8.218z"></path></svg></div>');
|
396 |
-
$('body').addClass('aws-overlay').append('<div class="aws-overlay-mask"></div>').append( self );
|
397 |
-
$searchField.focus();
|
398 |
-
},
|
399 |
-
|
400 |
-
hideMobileLayout: function() {
|
401 |
-
$('.aws-placement-container').after( self ).remove();
|
402 |
-
self.removeClass('aws-mobile-fixed');
|
403 |
-
$('body').removeClass('aws-overlay');
|
404 |
-
$('.aws-mobile-fixed-close').remove();
|
405 |
-
$('.aws-overlay-mask').remove();
|
406 |
-
},
|
407 |
-
|
408 |
-
isFixed: function() {
|
409 |
-
var $checkElements = self.add(self.parents());
|
410 |
-
var isFixed = false;
|
411 |
-
$checkElements.each(function(){
|
412 |
-
if ($(this).css("position") === "fixed") {
|
413 |
-
isFixed = true;
|
414 |
-
return false;
|
415 |
-
}
|
416 |
-
});
|
417 |
-
return isFixed;
|
418 |
-
},
|
419 |
-
|
420 |
-
analytics: function( label ) {
|
421 |
-
if ( d.useAnalytics ) {
|
422 |
-
try {
|
423 |
-
var sPage = '/?s=' + encodeURIComponent( 'ajax-search:' + label );
|
424 |
-
if ( typeof gtag !== 'undefined' && gtag !== null ) {
|
425 |
-
gtag('event', 'AWS search', {
|
426 |
-
'event_label': label,
|
427 |
-
'event_category': 'AWS Search Term',
|
428 |
-
'transport_type' : 'beacon'
|
429 |
-
});
|
430 |
-
gtag('event', 'page_view', {
|
431 |
-
'page_path': sPage,
|
432 |
-
'page_title' : 'AWS search'
|
433 |
-
});
|
434 |
-
}
|
435 |
-
if ( typeof ga !== 'undefined' && ga !== null ) {
|
436 |
-
ga('send', 'event', 'AWS search', 'AWS Search Term', label);
|
437 |
-
ga( 'send', 'pageview', sPage );
|
438 |
-
}
|
439 |
-
if ( typeof pageTracker !== "undefined" && pageTracker !== null ) {
|
440 |
-
pageTracker._trackPageview( sPage );
|
441 |
-
pageTracker._trackEvent( 'AWS search', 'AWS search', 'AWS Search Term', label )
|
442 |
-
}
|
443 |
-
if ( typeof _gaq !== 'undefined' && _gaq !== null ) {
|
444 |
-
_gaq.push(['_trackEvent', 'AWS search', 'AWS Search Term', label ]);
|
445 |
-
_gaq.push(['_trackPageview', sPage]);
|
446 |
-
}
|
447 |
-
// This uses Monster Insights method of tracking Google Analytics.
|
448 |
-
if ( typeof __gaTracker !== 'undefined' && __gaTracker !== null ) {
|
449 |
-
__gaTracker( 'send', 'event', 'AWS search', 'AWS Search Term', label );
|
450 |
-
__gaTracker( 'send', 'pageview', sPage );
|
451 |
-
}
|
452 |
-
}
|
453 |
-
catch (error) {
|
454 |
-
}
|
455 |
-
}
|
456 |
-
},
|
457 |
-
|
458 |
-
addClasses: function() {
|
459 |
-
if ( methods.isMobile() || d.showClear ) {
|
460 |
-
$searchForm.addClass('aws-show-clear');
|
461 |
-
}
|
462 |
-
},
|
463 |
-
|
464 |
-
isMobile: function() {
|
465 |
-
var check = false;
|
466 |
-
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
|
467 |
-
return check;
|
468 |
-
},
|
469 |
-
|
470 |
-
};
|
471 |
-
|
472 |
-
|
473 |
-
var self = $(this),
|
474 |
-
$searchForm = self.find('.aws-search-form'),
|
475 |
-
$searchField = self.find('.aws-search-field'),
|
476 |
-
$searchButton = self.find('.aws-search-btn'),
|
477 |
-
haveResults = false,
|
478 |
-
eShowResults = false,
|
479 |
-
requests = Array(),
|
480 |
-
searchFor = '',
|
481 |
-
keyupTimeout,
|
482 |
-
cachedResponse = new Array();
|
483 |
-
|
484 |
-
var ajaxUrl = ( self.data('url') !== undefined ) ? self.data('url') : false;
|
485 |
-
|
486 |
-
if ( document.createEvent ){
|
487 |
-
eShowResults = document.createEvent("Event");
|
488 |
-
eShowResults.initEvent('awsShowingResults', true, true);
|
489 |
-
eShowResults.eventName = 'awsShowingResults';
|
490 |
-
}
|
491 |
-
|
492 |
-
if ( options === 'relayout' ) {
|
493 |
-
var d = self.data(pluginPfx);
|
494 |
-
methods.resultLayout();
|
495 |
-
return;
|
496 |
-
}
|
497 |
-
|
498 |
-
|
499 |
-
instance++;
|
500 |
-
|
501 |
-
self.data( pluginPfx, {
|
502 |
-
minChars : ( self.data('min-chars') !== undefined ) ? self.data('min-chars') : 1,
|
503 |
-
lang : ( self.data('lang') !== undefined ) ? self.data('lang') : false,
|
504 |
-
showLoader: ( self.data('show-loader') !== undefined ) ? self.data('show-loader') : true,
|
505 |
-
showMore: ( self.data('show-more') !== undefined ) ? self.data('show-more') : true,
|
506 |
-
showPage: ( self.data('show-page') !== undefined ) ? self.data('show-page') : true,
|
507 |
-
showClear: ( self.data('show-clear') !== undefined ) ? self.data('show-clear') : false,
|
508 |
-
mobileScreen: ( self.data('mobile-screen') !== undefined ) ? self.data('mobile-screen') : false,
|
509 |
-
useAnalytics: ( self.data('use-analytics') !== undefined ) ? self.data('use-analytics') : false,
|
510 |
-
searchTimeout: ( self.data('timeout') !== undefined ) ? parseInt( self.data('timeout') ) : 300,
|
511 |
-
instance: instance,
|
512 |
-
resultBlock: '#aws-search-result-' + instance,
|
513 |
-
pageId: ( self.data('page-id') !== undefined ) ? self.data('page-id') : 0,
|
514 |
-
tax: ( self.data('tax') !== undefined ) ? self.data('tax') : 0
|
515 |
-
});
|
516 |
-
|
517 |
-
|
518 |
-
var d = self.data(pluginPfx);
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
if ( $searchForm.length > 0 ) {
|
523 |
-
methods.init.call(this);
|
524 |
-
}
|
525 |
-
|
526 |
-
|
527 |
-
$searchField.on( 'keyup input', function(e) {
|
528 |
-
if ( e.keyCode != 40 && e.keyCode != 38 ) {
|
529 |
-
methods.onKeyup(e);
|
530 |
-
}
|
531 |
-
});
|
532 |
-
|
533 |
-
|
534 |
-
$searchField.on( 'focus', function (e) {
|
535 |
-
$searchForm.addClass('aws-focus');
|
536 |
-
methods.onFocus(e);
|
537 |
-
});
|
538 |
-
|
539 |
-
$searchField.on( 'focusout', function (e) {
|
540 |
-
$searchForm.removeClass('aws-focus');
|
541 |
-
});
|
542 |
-
|
543 |
-
$searchForm.on( 'keypress', function(e) {
|
544 |
-
if ( e.keyCode == 13 && ( ! d.showPage || $searchField.val() === '' ) ) {
|
545 |
-
e.preventDefault();
|
546 |
-
}
|
547 |
-
});
|
548 |
-
|
549 |
-
|
550 |
-
$searchButton.on( 'click', function (e) {
|
551 |
-
if ( d.showPage && $searchField.val() !== '' ) {
|
552 |
-
$searchForm.submit();
|
553 |
-
}
|
554 |
-
});
|
555 |
-
|
556 |
-
|
557 |
-
$searchForm.find('.aws-search-clear').on( 'click', function (e) {
|
558 |
-
$searchField.val('');
|
559 |
-
$searchField.focus();
|
560 |
-
methods.resultsHide();
|
561 |
-
$(d.resultBlock).html('');
|
562 |
-
searchFor = '';
|
563 |
-
});
|
564 |
-
|
565 |
-
|
566 |
-
$(document).on( 'click', function (e) {
|
567 |
-
methods.hideResults(e);
|
568 |
-
});
|
569 |
-
|
570 |
-
|
571 |
-
$(window).on( 'resize', function(e) {
|
572 |
-
methods.resultLayout();
|
573 |
-
});
|
574 |
-
|
575 |
-
|
576 |
-
$(window).on( 'scroll', function(e) {
|
577 |
-
if ( $( d.resultBlock ).css('display') == 'block' ) {
|
578 |
-
methods.resultLayout();
|
579 |
-
}
|
580 |
-
});
|
581 |
-
|
582 |
-
|
583 |
-
$( d.resultBlock ).on( 'mouseenter', '.aws_result_item', function() {
|
584 |
-
methods.removeHovered();
|
585 |
-
$(this).addClass('hovered');
|
586 |
-
$searchField.trigger('mouseenter');
|
587 |
-
});
|
588 |
-
|
589 |
-
|
590 |
-
$( d.resultBlock ).on( 'mouseleave', '.aws_result_item', function() {
|
591 |
-
methods.removeHovered();
|
592 |
-
});
|
593 |
-
|
594 |
-
|
595 |
-
$( d.resultBlock ).on( 'click', '.aws_search_more', function(e) {
|
596 |
-
e.preventDefault();
|
597 |
-
$searchForm.submit();
|
598 |
-
});
|
599 |
-
|
600 |
-
$( d.resultBlock ).on( 'click', 'span[href], [data-link]', function(e) {
|
601 |
-
e.preventDefault();
|
602 |
-
var link = $(this).data('link') ? $(this).data('link') : $(this).attr('href');
|
603 |
-
if ( link === '' || link === '#' ) {
|
604 |
-
return;
|
605 |
-
}
|
606 |
-
e.stopPropagation();
|
607 |
-
if ( link ) {
|
608 |
-
window.location = link;
|
609 |
-
}
|
610 |
-
});
|
611 |
-
|
612 |
-
$( self ).on( 'click', '.aws-mobile-fixed-close', function(e) {
|
613 |
-
methods.hideMobileLayout();
|
614 |
-
});
|
615 |
-
|
616 |
-
|
617 |
-
$(window).on( 'keydown', function(e) {
|
618 |
-
|
619 |
-
if ( e.keyCode == 40 || e.keyCode == 38 ) {
|
620 |
-
if ( methods.isResultsVisible() ) {
|
621 |
-
|
622 |
-
e.stopPropagation();
|
623 |
-
e.preventDefault();
|
624 |
-
|
625 |
-
var $item = $( d.resultBlock ).find('.aws_result_item');
|
626 |
-
var $hoveredItem = $( d.resultBlock ).find('.aws_result_item.hovered');
|
627 |
-
var $itemsList = $( d.resultBlock ).find('ul');
|
628 |
-
|
629 |
-
if ( e.keyCode == 40 ) {
|
630 |
-
|
631 |
-
if ( $hoveredItem.length > 0 ) {
|
632 |
-
methods.removeHovered();
|
633 |
-
$hoveredItem.next().addClass('hovered');
|
634 |
-
} else {
|
635 |
-
$item.first().addClass('hovered');
|
636 |
-
}
|
637 |
-
|
638 |
-
}
|
639 |
-
|
640 |
-
if ( e.keyCode == 38 ) {
|
641 |
-
|
642 |
-
if ( $hoveredItem.length > 0 ) {
|
643 |
-
methods.removeHovered();
|
644 |
-
$hoveredItem.prev().addClass('hovered');
|
645 |
-
} else {
|
646 |
-
$item.last().addClass('hovered');
|
647 |
-
}
|
648 |
-
|
649 |
-
}
|
650 |
-
|
651 |
-
var activeItemOffset = $(".aws_result_item.hovered").position();
|
652 |
-
if ( activeItemOffset ) {
|
653 |
-
$itemsList.animate({
|
654 |
-
scrollTop: activeItemOffset.top + $itemsList.scrollTop()
|
655 |
-
}, 400);
|
656 |
-
}
|
657 |
-
|
658 |
-
}
|
659 |
-
}
|
660 |
-
|
661 |
-
});
|
662 |
-
|
663 |
-
|
664 |
-
};
|
665 |
-
|
666 |
-
|
667 |
-
// Call plugin method
|
668 |
-
$(document).ready( function() {
|
669 |
-
|
670 |
-
$(selector).each( function() {
|
671 |
-
$(this).aws_search();
|
672 |
-
});
|
673 |
-
|
674 |
-
// Enfold header
|
675 |
-
$('[data-avia-search-tooltip]').on( 'click', function() {
|
676 |
-
window.setTimeout(function(){
|
677 |
-
$(selector).aws_search();
|
678 |
-
}, 1000);
|
679 |
-
} );
|
680 |
-
|
681 |
-
// Search results filters fix
|
682 |
-
var $filters_widget = $('.woocommerce.widget_layered_nav_filters');
|
683 |
-
var searchQuery = window.location.search;
|
684 |
-
|
685 |
-
if ( $filters_widget.length > 0 && searchQuery ) {
|
686 |
-
if ( searchQuery.indexOf('type_aws=true') !== -1 ) {
|
687 |
-
var $filterLinks = $filters_widget.find('ul li.chosen a');
|
688 |
-
if ( $filterLinks.length > 0 ) {
|
689 |
-
var addQuery = '&type_aws=true';
|
690 |
-
$filterLinks.each( function() {
|
691 |
-
var filterLink = $(this).attr("href");
|
692 |
-
if ( filterLink && filterLink.indexOf('post_type=product') !== -1 ) {
|
693 |
-
$(this).attr( "href", filterLink + addQuery );
|
694 |
-
}
|
695 |
-
});
|
696 |
-
}
|
697 |
-
}
|
698 |
-
}
|
699 |
-
|
700 |
-
});
|
701 |
-
|
702 |
-
|
703 |
})( jQuery );
|
1 |
+
// Hooks
|
2 |
+
var AwsHooks = AwsHooks || {};
|
3 |
+
AwsHooks.filters = AwsHooks.filters || {};
|
4 |
+
|
5 |
+
(function($){
|
6 |
+
"use strict";
|
7 |
+
|
8 |
+
var selector = '.aws-container';
|
9 |
+
var instance = 0;
|
10 |
+
var pluginPfx = 'aws_opts';
|
11 |
+
var translate = {
|
12 |
+
sale : aws_vars.sale,
|
13 |
+
sku : aws_vars.sku,
|
14 |
+
showmore : aws_vars.showmore,
|
15 |
+
noresults : aws_vars.noresults
|
16 |
+
};
|
17 |
+
|
18 |
+
AwsHooks.add_filter = function( tag, callback, priority ) {
|
19 |
+
|
20 |
+
if( typeof priority === "undefined" ) {
|
21 |
+
priority = 10;
|
22 |
+
}
|
23 |
+
|
24 |
+
AwsHooks.filters[ tag ] = AwsHooks.filters[ tag ] || [];
|
25 |
+
AwsHooks.filters[ tag ].push( { priority: priority, callback: callback } );
|
26 |
+
|
27 |
+
};
|
28 |
+
|
29 |
+
AwsHooks.apply_filters = function( tag, value, options ) {
|
30 |
+
|
31 |
+
var filters = [];
|
32 |
+
|
33 |
+
if( typeof AwsHooks.filters[ tag ] !== "undefined" && AwsHooks.filters[ tag ].length > 0 ) {
|
34 |
+
|
35 |
+
AwsHooks.filters[ tag ].forEach( function( hook ) {
|
36 |
+
|
37 |
+
filters[ hook.priority ] = filters[ hook.priority ] || [];
|
38 |
+
filters[ hook.priority ].push( hook.callback );
|
39 |
+
} );
|
40 |
+
|
41 |
+
filters.forEach( function( AwsHooks ) {
|
42 |
+
|
43 |
+
AwsHooks.forEach( function( callback ) {
|
44 |
+
value = callback( value, options );
|
45 |
+
} );
|
46 |
+
|
47 |
+
} );
|
48 |
+
}
|
49 |
+
|
50 |
+
return value;
|
51 |
+
|
52 |
+
};
|
53 |
+
|
54 |
+
$.fn.aws_search = function( options ) {
|
55 |
+
|
56 |
+
var methods = {
|
57 |
+
|
58 |
+
init: function() {
|
59 |
+
|
60 |
+
// @since 2.16
|
61 |
+
var appendResultsTo = AwsHooks.apply_filters( 'aws_results_append_to', 'body', { instance: instance, form: self, data: d } );
|
62 |
+
|
63 |
+
$(appendResultsTo).append('<div id="aws-search-result-' + instance + '" class="aws-search-result" style="display: none;"></div>');
|
64 |
+
|
65 |
+
methods.addClasses();
|
66 |
+
|
67 |
+
setTimeout(function() { methods.resultLayout(); }, 500);
|
68 |
+
|
69 |
+
},
|
70 |
+
|
71 |
+
onKeyup: function(e) {
|
72 |
+
|
73 |
+
searchFor = $searchField.val();
|
74 |
+
searchFor = searchFor.trim();
|
75 |
+
searchFor = searchFor.replace( /<>\{\}\[\]\\\/]/gi, '' );
|
76 |
+
searchFor = searchFor.replace( /\s\s+/g, ' ' );
|
77 |
+
|
78 |
+
for ( var i = 0; i < requests.length; i++ ) {
|
79 |
+
requests[i].abort();
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( d.showPage == 'ajax_off' ) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( searchFor === '' ) {
|
87 |
+
$(d.resultBlock).html('').hide();
|
88 |
+
methods.hideLoader();
|
89 |
+
methods.resultsHide();
|
90 |
+
return;
|
91 |
+
}
|
92 |
+
|
93 |
+
if ( cachedResponse.hasOwnProperty( searchFor ) ) {
|
94 |
+
methods.showResults( cachedResponse[searchFor] );
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
if ( searchFor.length < d.minChars ) {
|
99 |
+
$(d.resultBlock).html('');
|
100 |
+
methods.hideLoader();
|
101 |
+
return;
|
102 |
+
}
|
103 |
+
|
104 |
+
if ( d.showLoader ) {
|
105 |
+
methods.showLoader();
|
106 |
+
}
|
107 |
+
|
108 |
+
var searchTimeout = d.searchTimeout > 100 ? d.searchTimeout : 300;
|
109 |
+
|
110 |
+
clearTimeout( keyupTimeout );
|
111 |
+
keyupTimeout = setTimeout( function() {
|
112 |
+
methods.ajaxRequest();
|
113 |
+
}, searchTimeout );
|
114 |
+
|
115 |
+
},
|
116 |
+
|
117 |
+
ajaxRequest: function() {
|
118 |
+
|
119 |
+
var data = {
|
120 |
+
action: 'aws_action',
|
121 |
+
keyword : searchFor,
|
122 |
+
aws_page: d.pageId,
|
123 |
+
aws_tax: d.tax,
|
124 |
+
lang: d.lang,
|
125 |
+
pageurl: window.location.href,
|
126 |
+
typedata: 'json'
|
127 |
+
};
|
128 |
+
|
129 |
+
requests.push(
|
130 |
+
|
131 |
+
$.ajax({
|
132 |
+
type: 'POST',
|
133 |
+
url: ajaxUrl,
|
134 |
+
data: data,
|
135 |
+
dataType: 'json',
|
136 |
+
success: function( response ) {
|
137 |
+
|
138 |
+
cachedResponse[searchFor] = response;
|
139 |
+
|
140 |
+
methods.showResults( response );
|
141 |
+
|
142 |
+
methods.showResultsBlock();
|
143 |
+
|
144 |
+
methods.analytics( searchFor );
|
145 |
+
|
146 |
+
},
|
147 |
+
error: function (jqXHR, textStatus, errorThrown) {
|
148 |
+
console.log( "Request failed: " + textStatus );
|
149 |
+
methods.hideLoader();
|
150 |
+
}
|
151 |
+
})
|
152 |
+
|
153 |
+
);
|
154 |
+
|
155 |
+
},
|
156 |
+
|
157 |
+
showResults: function( response ) {
|
158 |
+
|
159 |
+
var resultNum = 0;
|
160 |
+
var html = '<ul>';
|
161 |
+
|
162 |
+
if ( typeof response.tax !== 'undefined' ) {
|
163 |
+
|
164 |
+
$.each(response.tax, function (i, taxes) {
|
165 |
+
|
166 |
+
if ( ( typeof taxes !== 'undefined' ) && taxes.length > 0 ) {
|
167 |
+
$.each(taxes, function (i, taxitem) {
|
168 |
+
|
169 |
+
resultNum++;
|
170 |
+
|
171 |
+
html += '<li class="aws_result_item aws_result_tag">';
|
172 |
+
html += '<a class="aws_result_link" href="' + taxitem.link + '" >';
|
173 |
+
html += '<span class="aws_result_content">';
|
174 |
+
html += '<span class="aws_result_title">';
|
175 |
+
html += taxitem.name;
|
176 |
+
if ( taxitem.count ) {
|
177 |
+
html += '<span class="aws_result_count"> (' + taxitem.count + ')</span>';
|
178 |
+
}
|
179 |
+
html += '</span>';
|
180 |
+
if ( ( typeof taxitem.excerpt !== 'undefined' ) && taxitem.excerpt ) {
|
181 |
+
html += '<span class="aws_result_excerpt">' + taxitem.excerpt + '</span>';
|
182 |
+
}
|
183 |
+
html += '</span>';
|
184 |
+
html += '</a>';
|
185 |
+
html += '</li>';
|
186 |
+
|
187 |
+
});
|
188 |
+
}
|
189 |
+
|
190 |
+
});
|
191 |
+
|
192 |
+
}
|
193 |
+
|
194 |
+
if ( ( typeof response.products !== 'undefined' ) && response.products.length > 0 ) {
|
195 |
+
|
196 |
+
$.each(response.products, function (i, result) {
|
197 |
+
|
198 |
+
resultNum++;
|
199 |
+
|
200 |
+
html += '<li class="aws_result_item">';
|
201 |
+
html += '<a class="aws_result_link" href="' + result.link + '" >';
|
202 |
+
|
203 |
+
if ( result.image ) {
|
204 |
+
html += '<span class="aws_result_image">';
|
205 |
+
html += '<img src="' + result.image + '">';
|
206 |
+
html += '</span>';
|
207 |
+
}
|
208 |
+
|
209 |
+
html += '<span class="aws_result_content">';
|
210 |
+
|
211 |
+
html += '<span class="aws_result_title">';
|
212 |
+
if ( result.featured ) {
|
213 |
+
html += '<span class="aws_result_featured" title="Featured"><svg version="1.1" viewBox="0 0 20 21" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><g fill-rule="evenodd" stroke="none" stroke-width="1"><g transform="translate(-296.000000, -422.000000)"><g transform="translate(296.000000, 422.500000)"><path d="M10,15.273 L16.18,19 L14.545,11.971 L20,7.244 L12.809,6.627 L10,0 L7.191,6.627 L0,7.244 L5.455,11.971 L3.82,19 L10,15.273 Z"/></g></g></g></svg></span>';
|
214 |
+
}
|
215 |
+
html += result.title;
|
216 |
+
html += '</span>';
|
217 |
+
|
218 |
+
if ( result.stock_status ) {
|
219 |
+
var statusClass = result.stock_status.status ? 'in' : 'out';
|
220 |
+
html += '<span class="aws_result_stock ' + statusClass + '">';
|
221 |
+
html += result.stock_status.text;
|
222 |
+
html += '</span>';
|
223 |
+
}
|
224 |
+
|
225 |
+
if ( result.sku ) {
|
226 |
+
html += '<span class="aws_result_sku">' + translate.sku + result.sku + '</span>';
|
227 |
+
}
|
228 |
+
|
229 |
+
if ( result.excerpt ) {
|
230 |
+
html += '<span class="aws_result_excerpt">' + result.excerpt + '</span>';
|
231 |
+
}
|
232 |
+
|
233 |
+
if ( result.price ) {
|
234 |
+
html += '<span class="aws_result_price">' + result.price + '</span>';
|
235 |
+
}
|
236 |
+
|
237 |
+
html += '</span>';
|
238 |
+
|
239 |
+
if ( result.on_sale ) {
|
240 |
+
html += '<span class="aws_result_sale">';
|
241 |
+
html += '<span class="aws_onsale">' + translate.sale + '</span>';
|
242 |
+
html += '</span>';
|
243 |
+
}
|
244 |
+
|
245 |
+
html += '</a>';
|
246 |
+
html += '</li>';
|
247 |
+
|
248 |
+
});
|
249 |
+
|
250 |
+
if ( d.showMore && d.showPage ) {
|
251 |
+
html += '<li class="aws_result_item aws_search_more"><a href="#">' + translate.showmore + '</a></li>';
|
252 |
+
}
|
253 |
+
|
254 |
+
//html += '<li class="aws_result_item"><a href="#">Next Page</a></li>';
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
if ( ! resultNum ) {
|
259 |
+
html += '<li class="aws_result_item aws_no_result">' + translate.noresults + '</li>';
|
260 |
+
}
|
261 |
+
|
262 |
+
|
263 |
+
html += '</ul>';
|
264 |
+
|
265 |
+
// @since 2.05
|
266 |
+
html = AwsHooks.apply_filters( 'aws_results_html', html, { response: response, data: d } );
|
267 |
+
|
268 |
+
|
269 |
+
methods.hideLoader();
|
270 |
+
|
271 |
+
$(d.resultBlock).html( html );
|
272 |
+
|
273 |
+
methods.showResultsBlock();
|
274 |
+
|
275 |
+
if ( eShowResults ) {
|
276 |
+
self[0].dispatchEvent( eShowResults );
|
277 |
+
}
|
278 |
+
|
279 |
+
},
|
280 |
+
|
281 |
+
showResultsBlock: function() {
|
282 |
+
methods.resultLayout();
|
283 |
+
methods.resultsShow();
|
284 |
+
},
|
285 |
+
|
286 |
+
showLoader: function() {
|
287 |
+
$searchForm.addClass('aws-processing');
|
288 |
+
},
|
289 |
+
|
290 |
+
hideLoader: function() {
|
291 |
+
$searchForm.removeClass('aws-processing');
|
292 |
+
},
|
293 |
+
|
294 |
+
resultsShow: function() {
|
295 |
+
$(d.resultBlock).show();
|
296 |
+
$searchForm.addClass('aws-form-active');
|
297 |
+
},
|
298 |
+
|
299 |
+
resultsHide: function() {
|
300 |
+
$(d.resultBlock).hide();
|
301 |
+
$searchForm.removeClass('aws-form-active');
|
302 |
+
},
|
303 |
+
|
304 |
+
onFocus: function( event ) {
|
305 |
+
|
306 |
+
var show = AwsHooks.apply_filters( 'aws_show_modal_layout', false, { instance: instance, form: self, data: d } );
|
307 |
+
|
308 |
+
if ( ! $('body').hasClass('aws-overlay') && ( ( methods.isMobile() && d.mobileScreen && ! methods.isFixed() ) || show ) ) {
|
309 |
+
methods.showMobileLayout();
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( searchFor !== '' ) {
|
313 |
+
methods.showResultsBlock();
|
314 |
+
}
|
315 |
+
|
316 |
+
},
|
317 |
+
|
318 |
+
hideResults: function( event ) {
|
319 |
+
if ( ! $(event.target).closest( ".aws-container" ).length ) {
|
320 |
+
methods.resultsHide();
|
321 |
+
}
|
322 |
+
},
|
323 |
+
|
324 |
+
isResultsVisible:function() {
|
325 |
+
return $(d.resultBlock).is(":visible");
|
326 |
+
},
|
327 |
+
|
328 |
+
removeHovered: function() {
|
329 |
+
$( d.resultBlock ).find('.aws_result_item').removeClass('hovered');
|
330 |
+
},
|
331 |
+
|
332 |
+
resultLayout: function () {
|
333 |
+
|
334 |
+
var $resultsBlock = $( d.resultBlock );
|
335 |
+
var offset = self.offset();
|
336 |
+
var bodyOffset = $('body').offset();
|
337 |
+
var bodyPosition = $('body').css('position');
|
338 |
+
var bodyHeight = $(document).height();
|
339 |
+
var resultsHeight = $resultsBlock.height();
|
340 |
+
|
341 |
+
if ( offset && bodyOffset ) {
|
342 |
+
|
343 |
+
var styles = {
|
344 |
+
width: self.outerWidth(),
|
345 |
+
top : 0,
|
346 |
+
left: 0
|
347 |
+
};
|
348 |
+
|
349 |
+
if ( bodyPosition === 'relative' || bodyPosition === 'absolute' || bodyPosition === 'fixed' ) {
|
350 |
+
styles.top = offset.top + $(self).innerHeight() - bodyOffset.top;
|
351 |
+
styles.left = offset.left - bodyOffset.left;
|
352 |
+
} else {
|
353 |
+
styles.top = offset.top + $(self).innerHeight();
|
354 |
+
styles.left = offset.left;
|
355 |
+
}
|
356 |
+
|
357 |
+
if ( bodyHeight - offset.top < 500 ) {
|
358 |
+
resultsHeight = methods.getResultsBlockHeight();
|
359 |
+
if ( ( bodyHeight - offset.top < resultsHeight ) && ( offset.top >= resultsHeight ) ) {
|
360 |
+
styles.top = styles.top - resultsHeight - $(self).innerHeight();
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
// @since 2.10
|
365 |
+
styles = AwsHooks.apply_filters( 'aws_results_layout', styles, { resultsBlock: $resultsBlock, form: self } );
|
366 |
+
|
367 |
+
$resultsBlock.css( styles );
|
368 |
+
|
369 |
+
}
|
370 |
+
|
371 |
+
},
|
372 |
+
|
373 |
+
getResultsBlockHeight: function() {
|
374 |
+
|
375 |
+
var $resultsBlock = $( d.resultBlock );
|
376 |
+
var resultsHeight = $resultsBlock.height();
|
377 |
+
|
378 |
+
if ( resultsHeight === 0 ) {
|
379 |
+
var copied_elem = $resultsBlock.clone()
|
380 |
+
.attr("id", false)
|
381 |
+
.css({visibility:"hidden", display:"block",
|
382 |
+
position:"absolute"});
|
383 |
+
$("body").append(copied_elem);
|
384 |
+
//copied_elem.find('.mCSB_outside').attr('style', '');
|
385 |
+
resultsHeight = copied_elem.height();
|
386 |
+
copied_elem.remove();
|
387 |
+
}
|
388 |
+
|
389 |
+
return resultsHeight;
|
390 |
+
|
391 |
+
},
|
392 |
+
|
393 |
+
showMobileLayout: function() {
|
394 |
+
self.after('<div class="aws-placement-container"></div>');
|
395 |
+
self.addClass('aws-mobile-fixed').prepend('<div class="aws-mobile-fixed-close"><svg width="17" height="17" viewBox="1.5 1.5 21 21"><path d="M22.182 3.856c.522-.554.306-1.394-.234-1.938-.54-.543-1.433-.523-1.826-.135C19.73 2.17 11.955 10 11.955 10S4.225 2.154 3.79 1.783c-.438-.371-1.277-.4-1.81.135-.533.537-.628 1.513-.25 1.938.377.424 8.166 8.218 8.166 8.218s-7.85 7.864-8.166 8.219c-.317.354-.34 1.335.25 1.805.59.47 1.24.455 1.81 0 .568-.456 8.166-7.951 8.166-7.951l8.167 7.86c.747.72 1.504.563 1.96.09.456-.471.609-1.268.1-1.804-.508-.537-8.167-8.219-8.167-8.219s7.645-7.665 8.167-8.218z"></path></svg></div>');
|
396 |
+
$('body').addClass('aws-overlay').append('<div class="aws-overlay-mask"></div>').append( self );
|
397 |
+
$searchField.focus();
|
398 |
+
},
|
399 |
+
|
400 |
+
hideMobileLayout: function() {
|
401 |
+
$('.aws-placement-container').after( self ).remove();
|
402 |
+
self.removeClass('aws-mobile-fixed');
|
403 |
+
$('body').removeClass('aws-overlay');
|
404 |
+
$('.aws-mobile-fixed-close').remove();
|
405 |
+
$('.aws-overlay-mask').remove();
|
406 |
+
},
|
407 |
+
|
408 |
+
isFixed: function() {
|
409 |
+
var $checkElements = self.add(self.parents());
|
410 |
+
var isFixed = false;
|
411 |
+
$checkElements.each(function(){
|
412 |
+
if ($(this).css("position") === "fixed") {
|
413 |
+
isFixed = true;
|
414 |
+
return false;
|
415 |
+
}
|
416 |
+
});
|
417 |
+
return isFixed;
|
418 |
+
},
|
419 |
+
|
420 |
+
analytics: function( label ) {
|
421 |
+
if ( d.useAnalytics ) {
|
422 |
+
try {
|
423 |
+
var sPage = '/?s=' + encodeURIComponent( 'ajax-search:' + label );
|
424 |
+
if ( typeof gtag !== 'undefined' && gtag !== null ) {
|
425 |
+
gtag('event', 'AWS search', {
|
426 |
+
'event_label': label,
|
427 |
+
'event_category': 'AWS Search Term',
|
428 |
+
'transport_type' : 'beacon'
|
429 |
+
});
|
430 |
+
gtag('event', 'page_view', {
|
431 |
+
'page_path': sPage,
|
432 |
+
'page_title' : 'AWS search'
|
433 |
+
});
|
434 |
+
}
|
435 |
+
if ( typeof ga !== 'undefined' && ga !== null ) {
|
436 |
+
ga('send', 'event', 'AWS search', 'AWS Search Term', label);
|
437 |
+
ga( 'send', 'pageview', sPage );
|
438 |
+
}
|
439 |
+
if ( typeof pageTracker !== "undefined" && pageTracker !== null ) {
|
440 |
+
pageTracker._trackPageview( sPage );
|
441 |
+
pageTracker._trackEvent( 'AWS search', 'AWS search', 'AWS Search Term', label )
|
442 |
+
}
|
443 |
+
if ( typeof _gaq !== 'undefined' && _gaq !== null ) {
|
444 |
+
_gaq.push(['_trackEvent', 'AWS search', 'AWS Search Term', label ]);
|
445 |
+
_gaq.push(['_trackPageview', sPage]);
|
446 |
+
}
|
447 |
+
// This uses Monster Insights method of tracking Google Analytics.
|
448 |
+
if ( typeof __gaTracker !== 'undefined' && __gaTracker !== null ) {
|
449 |
+
__gaTracker( 'send', 'event', 'AWS search', 'AWS Search Term', label );
|
450 |
+
__gaTracker( 'send', 'pageview', sPage );
|
451 |
+
}
|
452 |
+
}
|
453 |
+
catch (error) {
|
454 |
+
}
|
455 |
+
}
|
456 |
+
},
|
457 |
+
|
458 |
+
addClasses: function() {
|
459 |
+
if ( methods.isMobile() || d.showClear ) {
|
460 |
+
$searchForm.addClass('aws-show-clear');
|
461 |
+
}
|
462 |
+
},
|
463 |
+
|
464 |
+
isMobile: function() {
|
465 |
+
var check = false;
|
466 |
+
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4))) check = true;})(navigator.userAgent||navigator.vendor||window.opera);
|
467 |
+
return check;
|
468 |
+
},
|
469 |
+
|
470 |
+
};
|
471 |
+
|
472 |
+
|
473 |
+
var self = $(this),
|
474 |
+
$searchForm = self.find('.aws-search-form'),
|
475 |
+
$searchField = self.find('.aws-search-field'),
|
476 |
+
$searchButton = self.find('.aws-search-btn'),
|
477 |
+
haveResults = false,
|
478 |
+
eShowResults = false,
|
479 |
+
requests = Array(),
|
480 |
+
searchFor = '',
|
481 |
+
keyupTimeout,
|
482 |
+
cachedResponse = new Array();
|
483 |
+
|
484 |
+
var ajaxUrl = ( self.data('url') !== undefined ) ? self.data('url') : false;
|
485 |
+
|
486 |
+
if ( document.createEvent ){
|
487 |
+
eShowResults = document.createEvent("Event");
|
488 |
+
eShowResults.initEvent('awsShowingResults', true, true);
|
489 |
+
eShowResults.eventName = 'awsShowingResults';
|
490 |
+
}
|
491 |
+
|
492 |
+
if ( options === 'relayout' ) {
|
493 |
+
var d = self.data(pluginPfx);
|
494 |
+
methods.resultLayout();
|
495 |
+
return;
|
496 |
+
}
|
497 |
+
|
498 |
+
|
499 |
+
instance++;
|
500 |
+
|
501 |
+
self.data( pluginPfx, {
|
502 |
+
minChars : ( self.data('min-chars') !== undefined ) ? self.data('min-chars') : 1,
|
503 |
+
lang : ( self.data('lang') !== undefined ) ? self.data('lang') : false,
|
504 |
+
showLoader: ( self.data('show-loader') !== undefined ) ? self.data('show-loader') : true,
|
505 |
+
showMore: ( self.data('show-more') !== undefined ) ? self.data('show-more') : true,
|
506 |
+
showPage: ( self.data('show-page') !== undefined ) ? self.data('show-page') : true,
|
507 |
+
showClear: ( self.data('show-clear') !== undefined ) ? self.data('show-clear') : false,
|
508 |
+
mobileScreen: ( self.data('mobile-screen') !== undefined ) ? self.data('mobile-screen') : false,
|
509 |
+
useAnalytics: ( self.data('use-analytics') !== undefined ) ? self.data('use-analytics') : false,
|
510 |
+
searchTimeout: ( self.data('timeout') !== undefined ) ? parseInt( self.data('timeout') ) : 300,
|
511 |
+
instance: instance,
|
512 |
+
resultBlock: '#aws-search-result-' + instance,
|
513 |
+
pageId: ( self.data('page-id') !== undefined ) ? self.data('page-id') : 0,
|
514 |
+
tax: ( self.data('tax') !== undefined ) ? self.data('tax') : 0
|
515 |
+
});
|
516 |
+
|
517 |
+
|
518 |
+
var d = self.data(pluginPfx);
|
519 |
+
|
520 |
+
|
521 |
+
|
522 |
+
if ( $searchForm.length > 0 ) {
|
523 |
+
methods.init.call(this);
|
524 |
+
}
|
525 |
+
|
526 |
+
|
527 |
+
$searchField.on( 'keyup input', function(e) {
|
528 |
+
if ( e.keyCode != 40 && e.keyCode != 38 ) {
|
529 |
+
methods.onKeyup(e);
|
530 |
+
}
|
531 |
+
});
|
532 |
+
|
533 |
+
|
534 |
+
$searchField.on( 'focus', function (e) {
|
535 |
+
$searchForm.addClass('aws-focus');
|
536 |
+
methods.onFocus(e);
|
537 |
+
});
|
538 |
+
|
539 |
+
$searchField.on( 'focusout', function (e) {
|
540 |
+
$searchForm.removeClass('aws-focus');
|
541 |
+
});
|
542 |
+
|
543 |
+
$searchForm.on( 'keypress', function(e) {
|
544 |
+
if ( e.keyCode == 13 && ( ! d.showPage || $searchField.val() === '' ) ) {
|
545 |
+
e.preventDefault();
|
546 |
+
}
|
547 |
+
});
|
548 |
+
|
549 |
+
|
550 |
+
$searchButton.on( 'click', function (e) {
|
551 |
+
if ( d.showPage && $searchField.val() !== '' ) {
|
552 |
+
$searchForm.submit();
|
553 |
+
}
|
554 |
+
});
|
555 |
+
|
556 |
+
|
557 |
+
$searchForm.find('.aws-search-clear').on( 'click', function (e) {
|
558 |
+
$searchField.val('');
|
559 |
+
$searchField.focus();
|
560 |
+
methods.resultsHide();
|
561 |
+
$(d.resultBlock).html('');
|
562 |
+
searchFor = '';
|
563 |
+
});
|
564 |
+
|
565 |
+
|
566 |
+
$(document).on( 'click', function (e) {
|
567 |
+
methods.hideResults(e);
|
568 |
+
});
|
569 |
+
|
570 |
+
|
571 |
+
$(window).on( 'resize', function(e) {
|
572 |
+
methods.resultLayout();
|
573 |
+
});
|
574 |
+
|
575 |
+
|
576 |
+
$(window).on( 'scroll', function(e) {
|
577 |
+
if ( $( d.resultBlock ).css('display') == 'block' ) {
|
578 |
+
methods.resultLayout();
|
579 |
+
}
|
580 |
+
});
|
581 |
+
|
582 |
+
|
583 |
+
$( d.resultBlock ).on( 'mouseenter', '.aws_result_item', function() {
|
584 |
+
methods.removeHovered();
|
585 |
+
$(this).addClass('hovered');
|
586 |
+
$searchField.trigger('mouseenter');
|
587 |
+
});
|
588 |
+
|
589 |
+
|
590 |
+
$( d.resultBlock ).on( 'mouseleave', '.aws_result_item', function() {
|
591 |
+
methods.removeHovered();
|
592 |
+
});
|
593 |
+
|
594 |
+
|
595 |
+
$( d.resultBlock ).on( 'click', '.aws_search_more', function(e) {
|
596 |
+
e.preventDefault();
|
597 |
+
$searchForm.submit();
|
598 |
+
});
|
599 |
+
|
600 |
+
$( d.resultBlock ).on( 'click', 'span[href], [data-link]', function(e) {
|
601 |
+
e.preventDefault();
|
602 |
+
var link = $(this).data('link') ? $(this).data('link') : $(this).attr('href');
|
603 |
+
if ( link === '' || link === '#' ) {
|
604 |
+
return;
|
605 |
+
}
|
606 |
+
e.stopPropagation();
|
607 |
+
if ( link ) {
|
608 |
+
window.location = link;
|
609 |
+
}
|
610 |
+
});
|
611 |
+
|
612 |
+
$( self ).on( 'click', '.aws-mobile-fixed-close', function(e) {
|
613 |
+
methods.hideMobileLayout();
|
614 |
+
});
|
615 |
+
|
616 |
+
|
617 |
+
$(window).on( 'keydown', function(e) {
|
618 |
+
|
619 |
+
if ( e.keyCode == 40 || e.keyCode == 38 ) {
|
620 |
+
if ( methods.isResultsVisible() ) {
|
621 |
+
|
622 |
+
e.stopPropagation();
|
623 |
+
e.preventDefault();
|
624 |
+
|
625 |
+
var $item = $( d.resultBlock ).find('.aws_result_item');
|
626 |
+
var $hoveredItem = $( d.resultBlock ).find('.aws_result_item.hovered');
|
627 |
+
var $itemsList = $( d.resultBlock ).find('ul');
|
628 |
+
|
629 |
+
if ( e.keyCode == 40 ) {
|
630 |
+
|
631 |
+
if ( $hoveredItem.length > 0 ) {
|
632 |
+
methods.removeHovered();
|
633 |
+
$hoveredItem.next().addClass('hovered');
|
634 |
+
} else {
|
635 |
+
$item.first().addClass('hovered');
|
636 |
+
}
|
637 |
+
|
638 |
+
}
|
639 |
+
|
640 |
+
if ( e.keyCode == 38 ) {
|
641 |
+
|
642 |
+
if ( $hoveredItem.length > 0 ) {
|
643 |
+
methods.removeHovered();
|
644 |
+
$hoveredItem.prev().addClass('hovered');
|
645 |
+
} else {
|
646 |
+
$item.last().addClass('hovered');
|
647 |
+
}
|
648 |
+
|
649 |
+
}
|
650 |
+
|
651 |
+
var activeItemOffset = $(".aws_result_item.hovered").position();
|
652 |
+
if ( activeItemOffset ) {
|
653 |
+
$itemsList.animate({
|
654 |
+
scrollTop: activeItemOffset.top + $itemsList.scrollTop()
|
655 |
+
}, 400);
|
656 |
+
}
|
657 |
+
|
658 |
+
}
|
659 |
+
}
|
660 |
+
|
661 |
+
});
|
662 |
+
|
663 |
+
|
664 |
+
};
|
665 |
+
|
666 |
+
|
667 |
+
// Call plugin method
|
668 |
+
$(document).ready( function() {
|
669 |
+
|
670 |
+
$(selector).each( function() {
|
671 |
+
$(this).aws_search();
|
672 |
+
});
|
673 |
+
|
674 |
+
// Enfold header
|
675 |
+
$('[data-avia-search-tooltip]').on( 'click', function() {
|
676 |
+
window.setTimeout(function(){
|
677 |
+
$(selector).aws_search();
|
678 |
+
}, 1000);
|
679 |
+
} );
|
680 |
+
|
681 |
+
// Search results filters fix
|
682 |
+
var $filters_widget = $('.woocommerce.widget_layered_nav_filters');
|
683 |
+
var searchQuery = window.location.search;
|
684 |
+
|
685 |
+
if ( $filters_widget.length > 0 && searchQuery ) {
|
686 |
+
if ( searchQuery.indexOf('type_aws=true') !== -1 ) {
|
687 |
+
var $filterLinks = $filters_widget.find('ul li.chosen a');
|
688 |
+
if ( $filterLinks.length > 0 ) {
|
689 |
+
var addQuery = '&type_aws=true';
|
690 |
+
$filterLinks.each( function() {
|
691 |
+
var filterLink = $(this).attr("href");
|
692 |
+
if ( filterLink && filterLink.indexOf('post_type=product') !== -1 ) {
|
693 |
+
$(this).attr( "href", filterLink + addQuery );
|
694 |
+
}
|
695 |
+
});
|
696 |
+
}
|
697 |
+
}
|
698 |
+
}
|
699 |
+
|
700 |
+
});
|
701 |
+
|
702 |
+
|
703 |
})( jQuery );
|
includes/admin/class-aws-admin-ajax.php
CHANGED
@@ -1,76 +1,76 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Admin_Ajax' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for plugin admin ajax hooks
|
11 |
-
*/
|
12 |
-
class AWS_Admin_Ajax {
|
13 |
-
|
14 |
-
/*
|
15 |
-
* Constructor
|
16 |
-
*/
|
17 |
-
public function __construct() {
|
18 |
-
|
19 |
-
add_action( 'wp_ajax_aws-changeState', array( &$this, 'change_state' ) );
|
20 |
-
|
21 |
-
add_action( 'wp_ajax_aws-hideWelcomeNotice', array( $this, 'hide_welcome_notice' ) );
|
22 |
-
|
23 |
-
}
|
24 |
-
|
25 |
-
/*
|
26 |
-
* Change option state
|
27 |
-
*/
|
28 |
-
public function change_state() {
|
29 |
-
|
30 |
-
check_ajax_referer( 'aws_admin_ajax_nonce' );
|
31 |
-
|
32 |
-
$setting = sanitize_text_field( $_POST['setting'] );
|
33 |
-
$option = sanitize_text_field( $_POST['option'] );
|
34 |
-
$state = sanitize_text_field( $_POST['state'] );
|
35 |
-
|
36 |
-
$settings = $this->get_settings();
|
37 |
-
|
38 |
-
$settings[$setting][$option] = $state ? 0 : 1;
|
39 |
-
|
40 |
-
update_option( 'aws_settings', $settings );
|
41 |
-
|
42 |
-
do_action( 'aws_cache_clear' );
|
43 |
-
|
44 |
-
do_action( 'aws_admin_change_state', $setting, $option, $state );
|
45 |
-
|
46 |
-
wp_send_json_success( '1' );
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
/*
|
51 |
-
* Hide plugin welcome notice
|
52 |
-
*/
|
53 |
-
public function hide_welcome_notice() {
|
54 |
-
|
55 |
-
check_ajax_referer( 'aws_admin_ajax_nonce' );
|
56 |
-
|
57 |
-
update_option( 'aws_hide_welcome_notice', 'true', false );
|
58 |
-
|
59 |
-
wp_send_json_success( '1' );
|
60 |
-
|
61 |
-
}
|
62 |
-
|
63 |
-
/*
|
64 |
-
* Get plugin settings
|
65 |
-
*/
|
66 |
-
private function get_settings() {
|
67 |
-
$plugin_options = get_option( 'aws_settings' );
|
68 |
-
return $plugin_options;
|
69 |
-
}
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
endif;
|
74 |
-
|
75 |
-
|
76 |
new AWS_Admin_Ajax();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Admin_Ajax' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plugin admin ajax hooks
|
11 |
+
*/
|
12 |
+
class AWS_Admin_Ajax {
|
13 |
+
|
14 |
+
/*
|
15 |
+
* Constructor
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
|
19 |
+
add_action( 'wp_ajax_aws-changeState', array( &$this, 'change_state' ) );
|
20 |
+
|
21 |
+
add_action( 'wp_ajax_aws-hideWelcomeNotice', array( $this, 'hide_welcome_notice' ) );
|
22 |
+
|
23 |
+
}
|
24 |
+
|
25 |
+
/*
|
26 |
+
* Change option state
|
27 |
+
*/
|
28 |
+
public function change_state() {
|
29 |
+
|
30 |
+
check_ajax_referer( 'aws_admin_ajax_nonce' );
|
31 |
+
|
32 |
+
$setting = sanitize_text_field( $_POST['setting'] );
|
33 |
+
$option = sanitize_text_field( $_POST['option'] );
|
34 |
+
$state = sanitize_text_field( $_POST['state'] );
|
35 |
+
|
36 |
+
$settings = $this->get_settings();
|
37 |
+
|
38 |
+
$settings[$setting][$option] = $state ? 0 : 1;
|
39 |
+
|
40 |
+
update_option( 'aws_settings', $settings );
|
41 |
+
|
42 |
+
do_action( 'aws_cache_clear' );
|
43 |
+
|
44 |
+
do_action( 'aws_admin_change_state', $setting, $option, $state );
|
45 |
+
|
46 |
+
wp_send_json_success( '1' );
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
/*
|
51 |
+
* Hide plugin welcome notice
|
52 |
+
*/
|
53 |
+
public function hide_welcome_notice() {
|
54 |
+
|
55 |
+
check_ajax_referer( 'aws_admin_ajax_nonce' );
|
56 |
+
|
57 |
+
update_option( 'aws_hide_welcome_notice', 'true', false );
|
58 |
+
|
59 |
+
wp_send_json_success( '1' );
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
/*
|
64 |
+
* Get plugin settings
|
65 |
+
*/
|
66 |
+
private function get_settings() {
|
67 |
+
$plugin_options = get_option( 'aws_settings' );
|
68 |
+
return $plugin_options;
|
69 |
+
}
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
endif;
|
74 |
+
|
75 |
+
|
76 |
new AWS_Admin_Ajax();
|
includes/admin/class-aws-admin-fields.php
CHANGED
@@ -1,368 +1,368 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Admin_Fields' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for plugin admin ajax hooks
|
11 |
-
*/
|
12 |
-
class AWS_Admin_Fields {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @var AWS_Admin_Fields The array of options that is need to be generated
|
16 |
-
*/
|
17 |
-
private $options_array;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var AWS_Admin_Fields Current plugin instance options
|
21 |
-
*/
|
22 |
-
private $plugin_options;
|
23 |
-
|
24 |
-
/*
|
25 |
-
* Constructor
|
26 |
-
*/
|
27 |
-
public function __construct( $tab_name ) {
|
28 |
-
|
29 |
-
$options = AWS_Admin_Options::options_array( $tab_name );
|
30 |
-
$this->options_array = $options[$tab_name];
|
31 |
-
$this->plugin_options = AWS_Admin_Options::get_settings();
|
32 |
-
|
33 |
-
$this->generate_fields();
|
34 |
-
|
35 |
-
}
|
36 |
-
|
37 |
-
/*
|
38 |
-
* Generate options fields
|
39 |
-
*/
|
40 |
-
private function generate_fields() {
|
41 |
-
|
42 |
-
if ( empty( $this->options_array ) ) {
|
43 |
-
return;
|
44 |
-
}
|
45 |
-
|
46 |
-
$plugin_options = $this->plugin_options;
|
47 |
-
|
48 |
-
echo '<table class="form-table">';
|
49 |
-
echo '<tbody>';
|
50 |
-
|
51 |
-
foreach ( $this->options_array as $k => $value ) {
|
52 |
-
|
53 |
-
switch ( $value['type'] ) {
|
54 |
-
|
55 |
-
case 'text': ?>
|
56 |
-
<tr valign="top">
|
57 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
58 |
-
<td>
|
59 |
-
<input type="text" name="<?php echo esc_attr( $value['id'] ); ?>" class="regular-text" value="<?php echo isset( $plugin_options[ $value['id'] ] ) ? esc_attr( stripslashes( $plugin_options[ $value['id'] ] ) ) : ''; ?>">
|
60 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
61 |
-
</td>
|
62 |
-
</tr>
|
63 |
-
<?php break;
|
64 |
-
|
65 |
-
case 'image': ?>
|
66 |
-
<tr valign="top">
|
67 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
68 |
-
<td>
|
69 |
-
<input type="text" name="<?php echo esc_attr( $value['id'] ); ?>" class="regular-text" value="<?php echo esc_attr( stripslashes( $plugin_options[ $value['id'] ] ) ); ?>">
|
70 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
71 |
-
<img style="display: block;max-width: 100px;margin-top: 20px;" src="<?php echo esc_url( $plugin_options[ $value['id'] ] ); ?>">
|
72 |
-
</td>
|
73 |
-
</tr>
|
74 |
-
<?php break;
|
75 |
-
|
76 |
-
case 'number': ?>
|
77 |
-
|
78 |
-
<?php
|
79 |
-
$params = '';
|
80 |
-
$params .= isset( $value['step'] ) ? ' step="' . $value['step'] . '"' : '';
|
81 |
-
$params .= isset( $value['min'] ) ? ' min="' . $value['min'] . '"' : '';
|
82 |
-
$params .= isset( $value['max'] ) ? ' max="' . $value['max'] . '"' : '';
|
83 |
-
?>
|
84 |
-
|
85 |
-
<tr valign="top">
|
86 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
87 |
-
<td>
|
88 |
-
<input type="number" <?php echo $params; ?> name="<?php echo esc_attr( $value['id'] ); ?>" class="regular-text" value="<?php echo esc_attr( stripslashes( $plugin_options[ $value['id'] ] ) ); ?>">
|
89 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
90 |
-
</td>
|
91 |
-
</tr>
|
92 |
-
<?php break;
|
93 |
-
|
94 |
-
case 'textarea': ?>
|
95 |
-
<tr valign="top">
|
96 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
97 |
-
<td>
|
98 |
-
<?php $textarea_cols = isset( $value['cols'] ) ? $value['cols'] : "55"; ?>
|
99 |
-
<?php $textarea_rows = isset( $value['rows'] ) ? $value['rows'] : "4"; ?>
|
100 |
-
<?php $textarea_output = isset( $value['allow_tags'] ) ? wp_kses( $plugin_options[ $value['id'] ], AWS_Helpers::get_kses( $value['allow_tags'] ) ) : stripslashes( $plugin_options[ $value['id'] ] ); ?>
|
101 |
-
<textarea id="<?php echo esc_attr( $value['id'] ); ?>" name="<?php echo esc_attr( $value['id'] ); ?>" cols="<?php echo $textarea_cols; ?>" rows="<?php echo $textarea_rows; ?>"><?php print $textarea_output; ?></textarea>
|
102 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
103 |
-
</td>
|
104 |
-
</tr>
|
105 |
-
<?php break;
|
106 |
-
|
107 |
-
case 'checkbox': ?>
|
108 |
-
<tr valign="top">
|
109 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
110 |
-
<td>
|
111 |
-
<?php $checkbox_options = $plugin_options[ $value['id'] ]; ?>
|
112 |
-
<?php foreach ( $value['choices'] as $val => $label ) { ?>
|
113 |
-
<input type="checkbox" name="<?php echo esc_attr( $value['id'] . '[' . $val . ']' ); ?>" id="<?php echo esc_attr( $value['id'] . '_' . $val ); ?>" value="1" <?php checked( $checkbox_options[$val], '1' ); ?>> <label for="<?php echo esc_attr( $value['id'] . '_' . $val ); ?>"><?php echo esc_html( $label ); ?></label><br>
|
114 |
-
<?php } ?>
|
115 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
116 |
-
</td>
|
117 |
-
</tr>
|
118 |
-
<?php break;
|
119 |
-
|
120 |
-
case 'radio': ?>
|
121 |
-
<tr valign="top">
|
122 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
123 |
-
<td>
|
124 |
-
<?php foreach ( $value['choices'] as $val => $label ) { ?>
|
125 |
-
<?php $option_val = isset( $plugin_options[ $value['id'] ] ) ? $plugin_options[ $value['id'] ] : ''; ?>
|
126 |
-
<input class="radio" type="radio" name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'].$val ); ?>" value="<?php echo esc_attr( $val ); ?>" <?php checked( $option_val, $val ); ?>> <label for="<?php echo esc_attr( $value['id'].$val ); ?>"><?php echo esc_html( $label ); ?></label><br>
|
127 |
-
<?php } ?>
|
128 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
129 |
-
</td>
|
130 |
-
</tr>
|
131 |
-
<?php break;
|
132 |
-
|
133 |
-
case 'select': ?>
|
134 |
-
<tr valign="top">
|
135 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
136 |
-
<td>
|
137 |
-
<select name="<?php echo esc_attr( $value['id'] ); ?>">
|
138 |
-
<?php foreach ( $value['choices'] as $val => $label ) { ?>
|
139 |
-
<?php $option_val = isset( $plugin_options[ $value['id'] ] ) ? $plugin_options[ $value['id'] ] : ''; ?>
|
140 |
-
<option value="<?php echo esc_attr( $val ); ?>" <?php selected( $option_val, $val ); ?>><?php echo esc_html( $label ); ?></option>
|
141 |
-
<?php } ?>
|
142 |
-
</select>
|
143 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
144 |
-
</td>
|
145 |
-
</tr>
|
146 |
-
<?php break;
|
147 |
-
|
148 |
-
case 'select_advanced': ?>
|
149 |
-
<tr valign="top">
|
150 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
151 |
-
<td>
|
152 |
-
<select name="<?php echo esc_attr( $value['id'].'[]' ); ?>" multiple class="chosen-select">
|
153 |
-
<?php $values = $plugin_options[ $value['id'] ]; ?>
|
154 |
-
<?php foreach ( $value['choices'] as $val => $label ) { ?>
|
155 |
-
<?php $selected = ( is_array( $values ) && in_array( $val, $values ) ) ? ' selected="selected" ' : ''; ?>
|
156 |
-
<option value="<?php echo esc_attr( $val ); ?>"<?php echo $selected; ?>><?php echo esc_html( $label ); ?></option>
|
157 |
-
<?php } ?>
|
158 |
-
</select>
|
159 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
160 |
-
|
161 |
-
<?php if ( $value['sub_option'] ): ?>
|
162 |
-
<?php $sub_options = $value['sub_option']; ?>
|
163 |
-
<br><br>
|
164 |
-
<p>
|
165 |
-
<label for="<?php echo esc_attr( $sub_options['id'] ); ?>">
|
166 |
-
<input type="checkbox" value="1" id="<?php echo esc_attr( $sub_options['id'] ); ?>" name="<?php echo esc_attr( $sub_options['id'] ); ?>" <?php checked( $plugin_options[ $sub_options['id'] ], '1' ); ?>>
|
167 |
-
<?php echo esc_html( $sub_options['desc'] ); ?>
|
168 |
-
</label>
|
169 |
-
</p>
|
170 |
-
<?php endif; ?>
|
171 |
-
|
172 |
-
</td>
|
173 |
-
</tr>
|
174 |
-
<?php break;
|
175 |
-
|
176 |
-
case 'radio-image': ?>
|
177 |
-
<tr valign="top">
|
178 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
179 |
-
<td>
|
180 |
-
<ul class="img-select">
|
181 |
-
<?php foreach ( $value['choices'] as $val => $img ) { ?>
|
182 |
-
<li class="option">
|
183 |
-
<input class="radio" type="radio" name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'].$val ); ?>" value="<?php echo esc_attr( $val ); ?>" <?php checked( $plugin_options[ $value['id'] ], $val ); ?>>
|
184 |
-
<span class="ico" style="background: url('<?php echo esc_url( AWS_URL . '/assets/img/' . $img ); ?>') no-repeat 50% 50%;"></span>
|
185 |
-
</li>
|
186 |
-
<?php } ?>
|
187 |
-
</ul>
|
188 |
-
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
189 |
-
</td>
|
190 |
-
</tr>
|
191 |
-
<?php break;
|
192 |
-
|
193 |
-
case 'sortable': ?>
|
194 |
-
<tr valign="top">
|
195 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
196 |
-
<td>
|
197 |
-
|
198 |
-
<script>
|
199 |
-
jQuery(document).ready(function() {
|
200 |
-
|
201 |
-
jQuery( "#sti-sortable1, #sti-sortable2" ).sortable({
|
202 |
-
connectWith: ".connectedSortable",
|
203 |
-
placeholder: "highlight",
|
204 |
-
update: function(event, ui){
|
205 |
-
var serviceList = '';
|
206 |
-
jQuery("#sti-sortable2 li").each(function(){
|
207 |
-
|
208 |
-
serviceList = serviceList + ',' + jQuery(this).attr('id');
|
209 |
-
|
210 |
-
});
|
211 |
-
var serviceListOut = serviceList.substring(1);
|
212 |
-
jQuery('#<?php echo esc_attr( $value['id'] ); ?>').attr('value', serviceListOut);
|
213 |
-
}
|
214 |
-
}).disableSelection();
|
215 |
-
|
216 |
-
});
|
217 |
-
</script>
|
218 |
-
|
219 |
-
<span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span><br><br>
|
220 |
-
|
221 |
-
<?php
|
222 |
-
$all_buttons = $value['choices'];
|
223 |
-
$active_buttons = explode( ',', $plugin_options[ $value['id'] ] );
|
224 |
-
$inactive_buttons = array_diff($all_buttons, $active_buttons);
|
225 |
-
?>
|
226 |
-
|
227 |
-
<div class="sortable-container">
|
228 |
-
|
229 |
-
<div class="sortable-title">
|
230 |
-
<?php esc_html_e( 'Active sources', 'advanced-woo-search' ) ?><br>
|
231 |
-
<?php esc_html_e( 'Change order by drag&drop', 'advanced-woo-search' ) ?>
|
232 |
-
</div>
|
233 |
-
|
234 |
-
<ul id="sti-sortable2" class="sti-sortable enabled connectedSortable">
|
235 |
-
<?php
|
236 |
-
if ( count( $active_buttons ) > 0 ) {
|
237 |
-
foreach ($active_buttons as $button) {
|
238 |
-
if ( ! $button ) continue;
|
239 |
-
echo '<li id="' . esc_attr( $button ) . '" class="sti-btn sti-' . esc_attr( $button ) . '-btn">' . $button . '</li>';
|
240 |
-
}
|
241 |
-
}
|
242 |
-
?>
|
243 |
-
</ul>
|
244 |
-
|
245 |
-
</div>
|
246 |
-
|
247 |
-
<div class="sortable-container">
|
248 |
-
|
249 |
-
<div class="sortable-title">
|
250 |
-
<?php esc_html_e( 'Deactivated sources', 'advanced-woo-search' ) ?><br>
|
251 |
-
<?php esc_html_e( 'Excluded from search results', 'advanced-woo-search' ) ?>
|
252 |
-
</div>
|
253 |
-
|
254 |
-
<ul id="sti-sortable1" class="sti-sortable disabled connectedSortable">
|
255 |
-
<?php
|
256 |
-
if ( count( $inactive_buttons ) > 0 ) {
|
257 |
-
foreach ($inactive_buttons as $button) {
|
258 |
-
echo '<li id="' . esc_attr( $button ) . '" class="sti-btn sti-' . esc_attr( $button ) . '-btn">' . $button . '</li>';
|
259 |
-
}
|
260 |
-
}
|
261 |
-
?>
|
262 |
-
</ul>
|
263 |
-
|
264 |
-
</div>
|
265 |
-
|
266 |
-
<input type="hidden" id="<?php echo esc_attr( $value['id'] ); ?>" name="<?php echo esc_attr( $value['id'] ); ?>" value="<?php echo esc_attr( $plugin_options[ $value['id'] ] ); ?>" />
|
267 |
-
|
268 |
-
</td>
|
269 |
-
</tr>
|
270 |
-
<?php break;
|
271 |
-
|
272 |
-
case 'table': ?>
|
273 |
-
|
274 |
-
<?php
|
275 |
-
$table_head = isset( $value['table_head'] ) && $value['table_head'] ? $value['table_head'] : '';
|
276 |
-
?>
|
277 |
-
|
278 |
-
<tr valign="top">
|
279 |
-
|
280 |
-
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
281 |
-
|
282 |
-
<td>
|
283 |
-
|
284 |
-
<span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span><br><br>
|
285 |
-
|
286 |
-
<table class="aws-table aws-table-sources widefat" cellspacing="0">
|
287 |
-
|
288 |
-
<thead>
|
289 |
-
<tr>
|
290 |
-
<th class="aws-name"><?php echo esc_html( $table_head ); ?></th>
|
291 |
-
<th class="aws-actions"></th>
|
292 |
-
<th class="aws-active"></th>
|
293 |
-
</tr>
|
294 |
-
</thead>
|
295 |
-
|
296 |
-
<tbody>
|
297 |
-
|
298 |
-
<?php $table_options = isset( $plugin_options[ $value['id'] ] ) ? $plugin_options[ $value['id'] ] : array(); ?>
|
299 |
-
|
300 |
-
<?php if ( is_array( $table_options ) ) { ?>
|
301 |
-
|
302 |
-
<?php foreach ( $value['choices'] as $val => $fchoices ) { ?>
|
303 |
-
|
304 |
-
<?php
|
305 |
-
$active_class = isset( $table_options[$val] ) && $table_options[$val] ? 'active' : '';
|
306 |
-
$label = is_array( $fchoices ) ? $fchoices['label'] : $fchoices;
|
307 |
-
if ( strpos( $label, 'index disabled' ) !== false ) {
|
308 |
-
$active_class = 'disabled';
|
309 |
-
}
|
310 |
-
?>
|
311 |
-
|
312 |
-
<tr>
|
313 |
-
<td class="aws-name"><?php echo $label; ?></td>
|
314 |
-
<td class="aws-actions"></td>
|
315 |
-
<td class="aws-active <?php echo $active_class; ?>">
|
316 |
-
<span data-change-state="1" data-setting="<?php echo esc_attr( $value['id'] ); ?>" data-name="<?php echo esc_attr( $val ); ?>" class="aws-yes" title="<?php echo esc_attr__( 'Disable this source', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'Yes', 'advanced-woo-search' ); ?></span>
|
317 |
-
<span data-change-state="0" data-setting="<?php echo esc_attr( $value['id'] ); ?>" data-name="<?php echo esc_attr( $val ); ?>" class="aws-no" title="<?php echo esc_attr__( 'Enable this source', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'No', 'advanced-woo-search' ); ?></span>
|
318 |
-
<span style="display: none;" class="aws-disabled" title="<?php echo esc_attr__( 'Source index disabled', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'No', 'advanced-woo-search' ); ?></span>
|
319 |
-
</td>
|
320 |
-
</tr>
|
321 |
-
<?php } ?>
|
322 |
-
|
323 |
-
<?php } ?>
|
324 |
-
|
325 |
-
</tbody>
|
326 |
-
|
327 |
-
</table>
|
328 |
-
|
329 |
-
</td>
|
330 |
-
|
331 |
-
</tr>
|
332 |
-
|
333 |
-
<?php break;
|
334 |
-
|
335 |
-
case 'heading':
|
336 |
-
|
337 |
-
$heading_tag = isset( $value['heading_type'] ) && $value['heading_type'] === 'text' ? 'span' : 'h3';
|
338 |
-
$heading_description = isset( $value['desc'] ) ? $value['desc'] : '';
|
339 |
-
$id = isset($value['id']) && $value['id'] ? 'id="' . $value['id'] . '"' : '';
|
340 |
-
?>
|
341 |
-
|
342 |
-
<tr valign="top">
|
343 |
-
<th scope="row"><<?php echo $heading_tag; ?> <?php echo $id; ?> class="aws-heading"><?php echo esc_html( $value['name'] ); ?></<?php echo $heading_tag; ?>></th>
|
344 |
-
|
345 |
-
<?php if ( $heading_description ): ?>
|
346 |
-
<td>
|
347 |
-
<span class="description"><?php echo $heading_description; ?></span>
|
348 |
-
</td>
|
349 |
-
<?php endif; ?>
|
350 |
-
</tr>
|
351 |
-
<?php break;
|
352 |
-
|
353 |
-
}
|
354 |
-
|
355 |
-
}
|
356 |
-
|
357 |
-
echo '</tbody>';
|
358 |
-
echo '</table>';
|
359 |
-
|
360 |
-
echo '<p class="submit"><input name="Submit" type="submit" class="button-primary" value="' . esc_attr__( 'Save Changes', 'advanced-woo-search' ) . '" /></p>';
|
361 |
-
|
362 |
-
}
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
}
|
367 |
-
|
368 |
-
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Admin_Fields' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plugin admin ajax hooks
|
11 |
+
*/
|
12 |
+
class AWS_Admin_Fields {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var AWS_Admin_Fields The array of options that is need to be generated
|
16 |
+
*/
|
17 |
+
private $options_array;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var AWS_Admin_Fields Current plugin instance options
|
21 |
+
*/
|
22 |
+
private $plugin_options;
|
23 |
+
|
24 |
+
/*
|
25 |
+
* Constructor
|
26 |
+
*/
|
27 |
+
public function __construct( $tab_name ) {
|
28 |
+
|
29 |
+
$options = AWS_Admin_Options::options_array( $tab_name );
|
30 |
+
$this->options_array = $options[$tab_name];
|
31 |
+
$this->plugin_options = AWS_Admin_Options::get_settings();
|
32 |
+
|
33 |
+
$this->generate_fields();
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
/*
|
38 |
+
* Generate options fields
|
39 |
+
*/
|
40 |
+
private function generate_fields() {
|
41 |
+
|
42 |
+
if ( empty( $this->options_array ) ) {
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
$plugin_options = $this->plugin_options;
|
47 |
+
|
48 |
+
echo '<table class="form-table">';
|
49 |
+
echo '<tbody>';
|
50 |
+
|
51 |
+
foreach ( $this->options_array as $k => $value ) {
|
52 |
+
|
53 |
+
switch ( $value['type'] ) {
|
54 |
+
|
55 |
+
case 'text': ?>
|
56 |
+
<tr valign="top">
|
57 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
58 |
+
<td>
|
59 |
+
<input type="text" name="<?php echo esc_attr( $value['id'] ); ?>" class="regular-text" value="<?php echo isset( $plugin_options[ $value['id'] ] ) ? esc_attr( stripslashes( $plugin_options[ $value['id'] ] ) ) : ''; ?>">
|
60 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
61 |
+
</td>
|
62 |
+
</tr>
|
63 |
+
<?php break;
|
64 |
+
|
65 |
+
case 'image': ?>
|
66 |
+
<tr valign="top">
|
67 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
68 |
+
<td>
|
69 |
+
<input type="text" name="<?php echo esc_attr( $value['id'] ); ?>" class="regular-text" value="<?php echo esc_attr( stripslashes( $plugin_options[ $value['id'] ] ) ); ?>">
|
70 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
71 |
+
<img style="display: block;max-width: 100px;margin-top: 20px;" src="<?php echo esc_url( $plugin_options[ $value['id'] ] ); ?>">
|
72 |
+
</td>
|
73 |
+
</tr>
|
74 |
+
<?php break;
|
75 |
+
|
76 |
+
case 'number': ?>
|
77 |
+
|
78 |
+
<?php
|
79 |
+
$params = '';
|
80 |
+
$params .= isset( $value['step'] ) ? ' step="' . $value['step'] . '"' : '';
|
81 |
+
$params .= isset( $value['min'] ) ? ' min="' . $value['min'] . '"' : '';
|
82 |
+
$params .= isset( $value['max'] ) ? ' max="' . $value['max'] . '"' : '';
|
83 |
+
?>
|
84 |
+
|
85 |
+
<tr valign="top">
|
86 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
87 |
+
<td>
|
88 |
+
<input type="number" <?php echo $params; ?> name="<?php echo esc_attr( $value['id'] ); ?>" class="regular-text" value="<?php echo esc_attr( stripslashes( $plugin_options[ $value['id'] ] ) ); ?>">
|
89 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
90 |
+
</td>
|
91 |
+
</tr>
|
92 |
+
<?php break;
|
93 |
+
|
94 |
+
case 'textarea': ?>
|
95 |
+
<tr valign="top">
|
96 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
97 |
+
<td>
|
98 |
+
<?php $textarea_cols = isset( $value['cols'] ) ? $value['cols'] : "55"; ?>
|
99 |
+
<?php $textarea_rows = isset( $value['rows'] ) ? $value['rows'] : "4"; ?>
|
100 |
+
<?php $textarea_output = isset( $value['allow_tags'] ) ? wp_kses( $plugin_options[ $value['id'] ], AWS_Helpers::get_kses( $value['allow_tags'] ) ) : stripslashes( $plugin_options[ $value['id'] ] ); ?>
|
101 |
+
<textarea id="<?php echo esc_attr( $value['id'] ); ?>" name="<?php echo esc_attr( $value['id'] ); ?>" cols="<?php echo $textarea_cols; ?>" rows="<?php echo $textarea_rows; ?>"><?php print $textarea_output; ?></textarea>
|
102 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
103 |
+
</td>
|
104 |
+
</tr>
|
105 |
+
<?php break;
|
106 |
+
|
107 |
+
case 'checkbox': ?>
|
108 |
+
<tr valign="top">
|
109 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
110 |
+
<td>
|
111 |
+
<?php $checkbox_options = $plugin_options[ $value['id'] ]; ?>
|
112 |
+
<?php foreach ( $value['choices'] as $val => $label ) { ?>
|
113 |
+
<input type="checkbox" name="<?php echo esc_attr( $value['id'] . '[' . $val . ']' ); ?>" id="<?php echo esc_attr( $value['id'] . '_' . $val ); ?>" value="1" <?php checked( $checkbox_options[$val], '1' ); ?>> <label for="<?php echo esc_attr( $value['id'] . '_' . $val ); ?>"><?php echo esc_html( $label ); ?></label><br>
|
114 |
+
<?php } ?>
|
115 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
116 |
+
</td>
|
117 |
+
</tr>
|
118 |
+
<?php break;
|
119 |
+
|
120 |
+
case 'radio': ?>
|
121 |
+
<tr valign="top">
|
122 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
123 |
+
<td>
|
124 |
+
<?php foreach ( $value['choices'] as $val => $label ) { ?>
|
125 |
+
<?php $option_val = isset( $plugin_options[ $value['id'] ] ) ? $plugin_options[ $value['id'] ] : ''; ?>
|
126 |
+
<input class="radio" type="radio" name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'].$val ); ?>" value="<?php echo esc_attr( $val ); ?>" <?php checked( $option_val, $val ); ?>> <label for="<?php echo esc_attr( $value['id'].$val ); ?>"><?php echo esc_html( $label ); ?></label><br>
|
127 |
+
<?php } ?>
|
128 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
129 |
+
</td>
|
130 |
+
</tr>
|
131 |
+
<?php break;
|
132 |
+
|
133 |
+
case 'select': ?>
|
134 |
+
<tr valign="top">
|
135 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
136 |
+
<td>
|
137 |
+
<select name="<?php echo esc_attr( $value['id'] ); ?>">
|
138 |
+
<?php foreach ( $value['choices'] as $val => $label ) { ?>
|
139 |
+
<?php $option_val = isset( $plugin_options[ $value['id'] ] ) ? $plugin_options[ $value['id'] ] : ''; ?>
|
140 |
+
<option value="<?php echo esc_attr( $val ); ?>" <?php selected( $option_val, $val ); ?>><?php echo esc_html( $label ); ?></option>
|
141 |
+
<?php } ?>
|
142 |
+
</select>
|
143 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
144 |
+
</td>
|
145 |
+
</tr>
|
146 |
+
<?php break;
|
147 |
+
|
148 |
+
case 'select_advanced': ?>
|
149 |
+
<tr valign="top">
|
150 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
151 |
+
<td>
|
152 |
+
<select name="<?php echo esc_attr( $value['id'].'[]' ); ?>" multiple class="chosen-select">
|
153 |
+
<?php $values = $plugin_options[ $value['id'] ]; ?>
|
154 |
+
<?php foreach ( $value['choices'] as $val => $label ) { ?>
|
155 |
+
<?php $selected = ( is_array( $values ) && in_array( $val, $values ) ) ? ' selected="selected" ' : ''; ?>
|
156 |
+
<option value="<?php echo esc_attr( $val ); ?>"<?php echo $selected; ?>><?php echo esc_html( $label ); ?></option>
|
157 |
+
<?php } ?>
|
158 |
+
</select>
|
159 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
160 |
+
|
161 |
+
<?php if ( $value['sub_option'] ): ?>
|
162 |
+
<?php $sub_options = $value['sub_option']; ?>
|
163 |
+
<br><br>
|
164 |
+
<p>
|
165 |
+
<label for="<?php echo esc_attr( $sub_options['id'] ); ?>">
|
166 |
+
<input type="checkbox" value="1" id="<?php echo esc_attr( $sub_options['id'] ); ?>" name="<?php echo esc_attr( $sub_options['id'] ); ?>" <?php checked( $plugin_options[ $sub_options['id'] ], '1' ); ?>>
|
167 |
+
<?php echo esc_html( $sub_options['desc'] ); ?>
|
168 |
+
</label>
|
169 |
+
</p>
|
170 |
+
<?php endif; ?>
|
171 |
+
|
172 |
+
</td>
|
173 |
+
</tr>
|
174 |
+
<?php break;
|
175 |
+
|
176 |
+
case 'radio-image': ?>
|
177 |
+
<tr valign="top">
|
178 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
179 |
+
<td>
|
180 |
+
<ul class="img-select">
|
181 |
+
<?php foreach ( $value['choices'] as $val => $img ) { ?>
|
182 |
+
<li class="option">
|
183 |
+
<input class="radio" type="radio" name="<?php echo esc_attr( $value['id'] ); ?>" id="<?php echo esc_attr( $value['id'].$val ); ?>" value="<?php echo esc_attr( $val ); ?>" <?php checked( $plugin_options[ $value['id'] ], $val ); ?>>
|
184 |
+
<span class="ico" style="background: url('<?php echo esc_url( AWS_URL . '/assets/img/' . $img ); ?>') no-repeat 50% 50%;"></span>
|
185 |
+
</li>
|
186 |
+
<?php } ?>
|
187 |
+
</ul>
|
188 |
+
<br><span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span>
|
189 |
+
</td>
|
190 |
+
</tr>
|
191 |
+
<?php break;
|
192 |
+
|
193 |
+
case 'sortable': ?>
|
194 |
+
<tr valign="top">
|
195 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
196 |
+
<td>
|
197 |
+
|
198 |
+
<script>
|
199 |
+
jQuery(document).ready(function() {
|
200 |
+
|
201 |
+
jQuery( "#sti-sortable1, #sti-sortable2" ).sortable({
|
202 |
+
connectWith: ".connectedSortable",
|
203 |
+
placeholder: "highlight",
|
204 |
+
update: function(event, ui){
|
205 |
+
var serviceList = '';
|
206 |
+
jQuery("#sti-sortable2 li").each(function(){
|
207 |
+
|
208 |
+
serviceList = serviceList + ',' + jQuery(this).attr('id');
|
209 |
+
|
210 |
+
});
|
211 |
+
var serviceListOut = serviceList.substring(1);
|
212 |
+
jQuery('#<?php echo esc_attr( $value['id'] ); ?>').attr('value', serviceListOut);
|
213 |
+
}
|
214 |
+
}).disableSelection();
|
215 |
+
|
216 |
+
});
|
217 |
+
</script>
|
218 |
+
|
219 |
+
<span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span><br><br>
|
220 |
+
|
221 |
+
<?php
|
222 |
+
$all_buttons = $value['choices'];
|
223 |
+
$active_buttons = explode( ',', $plugin_options[ $value['id'] ] );
|
224 |
+
$inactive_buttons = array_diff($all_buttons, $active_buttons);
|
225 |
+
?>
|
226 |
+
|
227 |
+
<div class="sortable-container">
|
228 |
+
|
229 |
+
<div class="sortable-title">
|
230 |
+
<?php esc_html_e( 'Active sources', 'advanced-woo-search' ) ?><br>
|
231 |
+
<?php esc_html_e( 'Change order by drag&drop', 'advanced-woo-search' ) ?>
|
232 |
+
</div>
|
233 |
+
|
234 |
+
<ul id="sti-sortable2" class="sti-sortable enabled connectedSortable">
|
235 |
+
<?php
|
236 |
+
if ( count( $active_buttons ) > 0 ) {
|
237 |
+
foreach ($active_buttons as $button) {
|
238 |
+
if ( ! $button ) continue;
|
239 |
+
echo '<li id="' . esc_attr( $button ) . '" class="sti-btn sti-' . esc_attr( $button ) . '-btn">' . $button . '</li>';
|
240 |
+
}
|
241 |
+
}
|
242 |
+
?>
|
243 |
+
</ul>
|
244 |
+
|
245 |
+
</div>
|
246 |
+
|
247 |
+
<div class="sortable-container">
|
248 |
+
|
249 |
+
<div class="sortable-title">
|
250 |
+
<?php esc_html_e( 'Deactivated sources', 'advanced-woo-search' ) ?><br>
|
251 |
+
<?php esc_html_e( 'Excluded from search results', 'advanced-woo-search' ) ?>
|
252 |
+
</div>
|
253 |
+
|
254 |
+
<ul id="sti-sortable1" class="sti-sortable disabled connectedSortable">
|
255 |
+
<?php
|
256 |
+
if ( count( $inactive_buttons ) > 0 ) {
|
257 |
+
foreach ($inactive_buttons as $button) {
|
258 |
+
echo '<li id="' . esc_attr( $button ) . '" class="sti-btn sti-' . esc_attr( $button ) . '-btn">' . $button . '</li>';
|
259 |
+
}
|
260 |
+
}
|
261 |
+
?>
|
262 |
+
</ul>
|
263 |
+
|
264 |
+
</div>
|
265 |
+
|
266 |
+
<input type="hidden" id="<?php echo esc_attr( $value['id'] ); ?>" name="<?php echo esc_attr( $value['id'] ); ?>" value="<?php echo esc_attr( $plugin_options[ $value['id'] ] ); ?>" />
|
267 |
+
|
268 |
+
</td>
|
269 |
+
</tr>
|
270 |
+
<?php break;
|
271 |
+
|
272 |
+
case 'table': ?>
|
273 |
+
|
274 |
+
<?php
|
275 |
+
$table_head = isset( $value['table_head'] ) && $value['table_head'] ? $value['table_head'] : '';
|
276 |
+
?>
|
277 |
+
|
278 |
+
<tr valign="top">
|
279 |
+
|
280 |
+
<th scope="row"><?php echo esc_html( $value['name'] ); ?></th>
|
281 |
+
|
282 |
+
<td>
|
283 |
+
|
284 |
+
<span class="description"><?php echo wp_kses_post( $value['desc'] ); ?></span><br><br>
|
285 |
+
|
286 |
+
<table class="aws-table aws-table-sources widefat" cellspacing="0">
|
287 |
+
|
288 |
+
<thead>
|
289 |
+
<tr>
|
290 |
+
<th class="aws-name"><?php echo esc_html( $table_head ); ?></th>
|
291 |
+
<th class="aws-actions"></th>
|
292 |
+
<th class="aws-active"></th>
|
293 |
+
</tr>
|
294 |
+
</thead>
|
295 |
+
|
296 |
+
<tbody>
|
297 |
+
|
298 |
+
<?php $table_options = isset( $plugin_options[ $value['id'] ] ) ? $plugin_options[ $value['id'] ] : array(); ?>
|
299 |
+
|
300 |
+
<?php if ( is_array( $table_options ) ) { ?>
|
301 |
+
|
302 |
+
<?php foreach ( $value['choices'] as $val => $fchoices ) { ?>
|
303 |
+
|
304 |
+
<?php
|
305 |
+
$active_class = isset( $table_options[$val] ) && $table_options[$val] ? 'active' : '';
|
306 |
+
$label = is_array( $fchoices ) ? $fchoices['label'] : $fchoices;
|
307 |
+
if ( strpos( $label, 'index disabled' ) !== false ) {
|
308 |
+
$active_class = 'disabled';
|
309 |
+
}
|
310 |
+
?>
|
311 |
+
|
312 |
+
<tr>
|
313 |
+
<td class="aws-name"><?php echo $label; ?></td>
|
314 |
+
<td class="aws-actions"></td>
|
315 |
+
<td class="aws-active <?php echo $active_class; ?>">
|
316 |
+
<span data-change-state="1" data-setting="<?php echo esc_attr( $value['id'] ); ?>" data-name="<?php echo esc_attr( $val ); ?>" class="aws-yes" title="<?php echo esc_attr__( 'Disable this source', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'Yes', 'advanced-woo-search' ); ?></span>
|
317 |
+
<span data-change-state="0" data-setting="<?php echo esc_attr( $value['id'] ); ?>" data-name="<?php echo esc_attr( $val ); ?>" class="aws-no" title="<?php echo esc_attr__( 'Enable this source', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'No', 'advanced-woo-search' ); ?></span>
|
318 |
+
<span style="display: none;" class="aws-disabled" title="<?php echo esc_attr__( 'Source index disabled', 'advanced-woo-search' ); ?>"><?php echo esc_html__( 'No', 'advanced-woo-search' ); ?></span>
|
319 |
+
</td>
|
320 |
+
</tr>
|
321 |
+
<?php } ?>
|
322 |
+
|
323 |
+
<?php } ?>
|
324 |
+
|
325 |
+
</tbody>
|
326 |
+
|
327 |
+
</table>
|
328 |
+
|
329 |
+
</td>
|
330 |
+
|
331 |
+
</tr>
|
332 |
+
|
333 |
+
<?php break;
|
334 |
+
|
335 |
+
case 'heading':
|
336 |
+
|
337 |
+
$heading_tag = isset( $value['heading_type'] ) && $value['heading_type'] === 'text' ? 'span' : 'h3';
|
338 |
+
$heading_description = isset( $value['desc'] ) ? $value['desc'] : '';
|
339 |
+
$id = isset($value['id']) && $value['id'] ? 'id="' . $value['id'] . '"' : '';
|
340 |
+
?>
|
341 |
+
|
342 |
+
<tr valign="top">
|
343 |
+
<th scope="row"><<?php echo $heading_tag; ?> <?php echo $id; ?> class="aws-heading"><?php echo esc_html( $value['name'] ); ?></<?php echo $heading_tag; ?>></th>
|
344 |
+
|
345 |
+
<?php if ( $heading_description ): ?>
|
346 |
+
<td>
|
347 |
+
<span class="description"><?php echo $heading_description; ?></span>
|
348 |
+
</td>
|
349 |
+
<?php endif; ?>
|
350 |
+
</tr>
|
351 |
+
<?php break;
|
352 |
+
|
353 |
+
}
|
354 |
+
|
355 |
+
}
|
356 |
+
|
357 |
+
echo '</tbody>';
|
358 |
+
echo '</table>';
|
359 |
+
|
360 |
+
echo '<p class="submit"><input name="Submit" type="submit" class="button-primary" value="' . esc_attr__( 'Save Changes', 'advanced-woo-search' ) . '" /></p>';
|
361 |
+
|
362 |
+
}
|
363 |
+
|
364 |
+
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
endif;
|
includes/admin/class-aws-admin-meta-boxes.php
CHANGED
@@ -1,147 +1,147 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Admin_Meta_Boxes' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for plugin admin panel
|
11 |
-
*/
|
12 |
-
class AWS_Admin_Meta_Boxes {
|
13 |
-
|
14 |
-
/*
|
15 |
-
* Get content for the General tab
|
16 |
-
* @return string
|
17 |
-
*/
|
18 |
-
static public function get_general_tab_content() {
|
19 |
-
|
20 |
-
$html = '';
|
21 |
-
|
22 |
-
$html .= '<table class="form-table">';
|
23 |
-
$html .= '<tbody>';
|
24 |
-
|
25 |
-
$html .= '<tr id="activation">';
|
26 |
-
|
27 |
-
$html .= '<th>' . esc_html__( 'Activation', 'advanced-woo-search' ) . '</th>';
|
28 |
-
$html .= '<td>';
|
29 |
-
$html .= '<div class="description activation">';
|
30 |
-
$html .= esc_html__( 'In case you need to add plugin search form on your website, you can do it in several ways:', 'advanced-woo-search' ) . '<br>';
|
31 |
-
$html .= '<div class="list">';
|
32 |
-
$html .= '1. ' . esc_html__( 'Enable a "Seamless integration" option ( may not work with some themes )', 'advanced-woo-search' ) . '<br>';
|
33 |
-
$html .= '2. ' . sprintf( esc_html__( 'Add search form using shortcode %s', 'advanced-woo-search' ), "<code>[aws_search_form]</code>" ) . '<br>';
|
34 |
-
$html .= '3. ' . esc_html__( 'Add search form as widget for one of your theme widget areas. Go to Appearance -> Widgets and drag&drop AWS Widget to one of your widget areas', 'advanced-woo-search' ) . '<br>';
|
35 |
-
$html .= '4. ' . sprintf( esc_html__( 'Add PHP code to the necessary files of your theme: %s', 'advanced-woo-search' ), "<code><?php if ( function_exists( 'aws_get_search_form' ) ) { aws_get_search_form(); } ?></code>" ) . '<br>';
|
36 |
-
$html .= '</div>';
|
37 |
-
$html .= '</div>';
|
38 |
-
$html .= '</td>';
|
39 |
-
|
40 |
-
$html .= '</tr>';
|
41 |
-
|
42 |
-
$html .= '<tr>';
|
43 |
-
|
44 |
-
$html .= '<th>' . esc_html__( 'Reindex table', 'advanced-woo-search' ) . '</th>';
|
45 |
-
$html .= '<td>';
|
46 |
-
$html .= '<div id="aws-reindex"><input class="button" type="button" value="' . esc_attr__( 'Reindex table', 'advanced-woo-search' ) . '"><span class="loader"></span><span class="reindex-progress">0%</span><span class="reindex-notice">' . __( 'Please do not close the page.', 'advanced-woo-search' ) . '</span></div><br><br>';
|
47 |
-
$html .= '<span class="description">' .
|
48 |
-
sprintf( esc_html__( 'This action only need for %s one time %s - after you activate this plugin. After this all products changes will be re-indexed automatically.', 'advanced-woo-search' ), '<strong>', '</strong>' ) . '<br>' .
|
49 |
-
__( 'Update all data in plugins index table. Index table - table with products data where plugin is searching all typed terms.<br>Use this button if you think that plugin not shows last actual data in its search results.<br>' .
|
50 |
-
'<strong>CAUTION:</strong> this can take large amount of time.', 'advanced-woo-search' ) . sprintf( __( 'Index table options can be found inside %s section.', 'advanced-woo-search' ), '<a href="'.esc_url( admin_url('admin.php?page=aws-options&tab=performance') ).'">' . __( 'Performance', 'advanced-woo-search' ) . '</a>' ) . '<br><br>' .
|
51 |
-
esc_html__( 'Products in index:', 'advanced-woo-search' ) . '<span id="aws-reindex-count"> <strong>' . AWS_Helpers::get_indexed_products_count() . '</strong></span>';
|
52 |
-
$html .= '</span>';
|
53 |
-
$html .= '</td>';
|
54 |
-
|
55 |
-
$html .= '</tr>';
|
56 |
-
|
57 |
-
|
58 |
-
$html .= '<tr>';
|
59 |
-
|
60 |
-
$html .= '<th>' . esc_html__( 'Clear cache', 'advanced-woo-search' ) . '</th>';
|
61 |
-
$html .= '<td>';
|
62 |
-
$html .= '<div id="aws-clear-cache"><input class="button" type="button" value="' . esc_attr__( 'Clear cache', 'advanced-woo-search' ) . '"><span class="loader"></span></div><br>';
|
63 |
-
$html .= '<span class="description">' . esc_html__( 'Clear cache for all search results.', 'advanced-woo-search' ) . '</span>';
|
64 |
-
$html .= '</td>';
|
65 |
-
|
66 |
-
$html .= '</tr>';
|
67 |
-
|
68 |
-
$html .= '</tbody>';
|
69 |
-
$html .= '</table>';
|
70 |
-
|
71 |
-
return $html;
|
72 |
-
|
73 |
-
}
|
74 |
-
|
75 |
-
/*
|
76 |
-
* Get content for the welcome notice
|
77 |
-
* @return string
|
78 |
-
*/
|
79 |
-
static public function get_welcome_notice() {
|
80 |
-
|
81 |
-
$html = '';
|
82 |
-
|
83 |
-
$html .= '<div id="aws-welcome-panel">';
|
84 |
-
$html .= '<div class="aws-welcome-notice updated notice is-dismissible" style="background:#f2fbff;">';
|
85 |
-
|
86 |
-
$html .= '<div class="welcome-panel" style="border:none;box-shadow:none;padding:0;margin:16px 0 0;background:transparent;">';
|
87 |
-
$html .= '<div class="welcome-panel-content">';
|
88 |
-
$html .= '<h2>' . sprintf( __( 'Welcome to %s', 'advanced-woo-search' ), 'Advanced Woo Search' ) . '</h2>';
|
89 |
-
$html .= '<p class="about-description">' . __( 'Powerful search plugin for WooCommerce.', 'advanced-woo-search' ) . '</p>';
|
90 |
-
$html .= '<div class="welcome-panel-column-container">';
|
91 |
-
$html .= '<div class="welcome-panel-column">';
|
92 |
-
$html .= '<h4>' . __( 'Get Started', 'advanced-woo-search' ) . '</h4>';
|
93 |
-
$html .= '<p style="margin-bottom:10px;">' . __( 'In order to start using the plugin search form you need to take following steps:', 'advanced-woo-search' ) . '</p>';
|
94 |
-
$html .= '<ul>';
|
95 |
-
$html .= '<li><strong>1.</strong> <strong>' . __( 'Index plugin table.', 'advanced-woo-search' ) . '</strong> ' . __( 'Click on the \'Reindex table\' button and wait till the index process is finished.', 'advanced-woo-search' ) . '</li>';
|
96 |
-
$html .= '<li><strong>2.</strong> <strong>' . __( 'Set plugin settings.', 'advanced-woo-search' ) . '</strong> ' . __( 'Leave it to default values or customize some of them.', 'advanced-woo-search' ) . '</li>';
|
97 |
-
$html .= '<li><strong>3.</strong> <strong>' . __( 'Add search form.', 'advanced-woo-search' ) . '</strong> ' . sprintf( __( 'There are several ways you can add a search form to your site. Use the \'Seamless integration\' option, shortcode, widget or custom php function. Read more inside %s section or read %s.', 'advanced-woo-search' ), '<a href="#activation">' . __( 'Activation', 'advanced-woo-search' ) . '</a>', '<a target="_blank" href="https://advanced-woo-search.com/guide/search-form/">' . __( 'guide article', 'advanced-woo-search' ) . '</a>' ) . '</li>';
|
98 |
-
$html .= '<li><strong>4.</strong> <strong>' . __( 'Finish!', 'advanced-woo-search' ) . '</strong> ' . __( 'Now all is set and you can check your search form on the pages where you add it.', 'advanced-woo-search' ) . '</li>';
|
99 |
-
$html .= '</ul>';
|
100 |
-
$html .= '</div>';
|
101 |
-
$html .= '<div class="welcome-panel-column">';
|
102 |
-
$html .= '<h4>' . __( 'Documentation', 'advanced-woo-search' ) . '</h4>';
|
103 |
-
$html .= '<ul>';
|
104 |
-
$html .= '<li><a href="https://advanced-woo-search.com/guide/search-form/" class="welcome-icon welcome-edit-page" target="_blank">' . __( 'How to Add Search Form', 'advanced-woo-search' ) . '</a></li>';
|
105 |
-
$html .= '<li><a href="https://advanced-woo-search.com/guide/search-source/" class="welcome-icon welcome-edit-page" target="_blank">' . __( 'Search Sources', 'advanced-woo-search' ) . '</a></li>';
|
106 |
-
$html .= '<li><a href="https://advanced-woo-search.com/guide/terms-search/" class="welcome-icon welcome-edit-page" target="_blank">' . __( 'Terms Pages Search', 'advanced-woo-search' ) . '</a></li>';
|
107 |
-
$html .= '</ul>';
|
108 |
-
$html .= '</div>';
|
109 |
-
$html .= '<div class="welcome-panel-column welcome-panel-last">';
|
110 |
-
$html .= '<h4>' . __( 'Help', 'advanced-woo-search' ) . '</h4>';
|
111 |
-
$html .= '<ul>';
|
112 |
-
$html .= '<li><div class="welcome-icon welcome-widgets-menus"><a href="https://wordpress.org/support/plugin/advanced-woo-search/" target="_blank">' . __( 'Support Forums', 'advanced-woo-search' ) . '</a></div></li>';
|
113 |
-
$html .= '<li><div class="welcome-icon welcome-widgets-menus"><a href="https://advanced-woo-search.com/contact/" target="_blank">' . __( 'Contact Form', 'advanced-woo-search' ) . '</a></div></li>';
|
114 |
-
$html .= '</ul>';
|
115 |
-
$html .= '</div>';
|
116 |
-
$html .= '</div>';
|
117 |
-
$html .= '</div>';
|
118 |
-
$html .= '</div>';
|
119 |
-
|
120 |
-
$html .= '</div>';
|
121 |
-
$html .= '</div>';
|
122 |
-
|
123 |
-
return $html;
|
124 |
-
|
125 |
-
}
|
126 |
-
|
127 |
-
/*
|
128 |
-
* Get content for the reindex notice
|
129 |
-
* @return string
|
130 |
-
*/
|
131 |
-
static public function get_reindex_notice() {
|
132 |
-
|
133 |
-
$html = '';
|
134 |
-
|
135 |
-
$html .= '<div class="updated notice is-dismissible">';
|
136 |
-
$html .= '<p>';
|
137 |
-
$html .= sprintf( esc_html__( 'Advanced Woo Search: In order to apply the changes in the index table you need to reindex. %s', 'advanced-woo-search' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Go to Settings Page', 'advanced-woo-search' ).'</a>' );
|
138 |
-
$html .= '</p>';
|
139 |
-
$html .= '</div>';
|
140 |
-
|
141 |
-
return $html;
|
142 |
-
|
143 |
-
}
|
144 |
-
|
145 |
-
}
|
146 |
-
|
147 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Admin_Meta_Boxes' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plugin admin panel
|
11 |
+
*/
|
12 |
+
class AWS_Admin_Meta_Boxes {
|
13 |
+
|
14 |
+
/*
|
15 |
+
* Get content for the General tab
|
16 |
+
* @return string
|
17 |
+
*/
|
18 |
+
static public function get_general_tab_content() {
|
19 |
+
|
20 |
+
$html = '';
|
21 |
+
|
22 |
+
$html .= '<table class="form-table">';
|
23 |
+
$html .= '<tbody>';
|
24 |
+
|
25 |
+
$html .= '<tr id="activation">';
|
26 |
+
|
27 |
+
$html .= '<th>' . esc_html__( 'Activation', 'advanced-woo-search' ) . '</th>';
|
28 |
+
$html .= '<td>';
|
29 |
+
$html .= '<div class="description activation">';
|
30 |
+
$html .= esc_html__( 'In case you need to add plugin search form on your website, you can do it in several ways:', 'advanced-woo-search' ) . '<br>';
|
31 |
+
$html .= '<div class="list">';
|
32 |
+
$html .= '1. ' . esc_html__( 'Enable a "Seamless integration" option ( may not work with some themes )', 'advanced-woo-search' ) . '<br>';
|
33 |
+
$html .= '2. ' . sprintf( esc_html__( 'Add search form using shortcode %s', 'advanced-woo-search' ), "<code>[aws_search_form]</code>" ) . '<br>';
|
34 |
+
$html .= '3. ' . esc_html__( 'Add search form as widget for one of your theme widget areas. Go to Appearance -> Widgets and drag&drop AWS Widget to one of your widget areas', 'advanced-woo-search' ) . '<br>';
|
35 |
+
$html .= '4. ' . sprintf( esc_html__( 'Add PHP code to the necessary files of your theme: %s', 'advanced-woo-search' ), "<code><?php if ( function_exists( 'aws_get_search_form' ) ) { aws_get_search_form(); } ?></code>" ) . '<br>';
|
36 |
+
$html .= '</div>';
|
37 |
+
$html .= '</div>';
|
38 |
+
$html .= '</td>';
|
39 |
+
|
40 |
+
$html .= '</tr>';
|
41 |
+
|
42 |
+
$html .= '<tr>';
|
43 |
+
|
44 |
+
$html .= '<th>' . esc_html__( 'Reindex table', 'advanced-woo-search' ) . '</th>';
|
45 |
+
$html .= '<td>';
|
46 |
+
$html .= '<div id="aws-reindex"><input class="button" type="button" value="' . esc_attr__( 'Reindex table', 'advanced-woo-search' ) . '"><span class="loader"></span><span class="reindex-progress">0%</span><span class="reindex-notice">' . __( 'Please do not close the page.', 'advanced-woo-search' ) . '</span></div><br><br>';
|
47 |
+
$html .= '<span class="description">' .
|
48 |
+
sprintf( esc_html__( 'This action only need for %s one time %s - after you activate this plugin. After this all products changes will be re-indexed automatically.', 'advanced-woo-search' ), '<strong>', '</strong>' ) . '<br>' .
|
49 |
+
__( 'Update all data in plugins index table. Index table - table with products data where plugin is searching all typed terms.<br>Use this button if you think that plugin not shows last actual data in its search results.<br>' .
|
50 |
+
'<strong>CAUTION:</strong> this can take large amount of time.', 'advanced-woo-search' ) . sprintf( __( 'Index table options can be found inside %s section.', 'advanced-woo-search' ), '<a href="'.esc_url( admin_url('admin.php?page=aws-options&tab=performance') ).'">' . __( 'Performance', 'advanced-woo-search' ) . '</a>' ) . '<br><br>' .
|
51 |
+
esc_html__( 'Products in index:', 'advanced-woo-search' ) . '<span id="aws-reindex-count"> <strong>' . AWS_Helpers::get_indexed_products_count() . '</strong></span>';
|
52 |
+
$html .= '</span>';
|
53 |
+
$html .= '</td>';
|
54 |
+
|
55 |
+
$html .= '</tr>';
|
56 |
+
|
57 |
+
|
58 |
+
$html .= '<tr>';
|
59 |
+
|
60 |
+
$html .= '<th>' . esc_html__( 'Clear cache', 'advanced-woo-search' ) . '</th>';
|
61 |
+
$html .= '<td>';
|
62 |
+
$html .= '<div id="aws-clear-cache"><input class="button" type="button" value="' . esc_attr__( 'Clear cache', 'advanced-woo-search' ) . '"><span class="loader"></span></div><br>';
|
63 |
+
$html .= '<span class="description">' . esc_html__( 'Clear cache for all search results.', 'advanced-woo-search' ) . '</span>';
|
64 |
+
$html .= '</td>';
|
65 |
+
|
66 |
+
$html .= '</tr>';
|
67 |
+
|
68 |
+
$html .= '</tbody>';
|
69 |
+
$html .= '</table>';
|
70 |
+
|
71 |
+
return $html;
|
72 |
+
|
73 |
+
}
|
74 |
+
|
75 |
+
/*
|
76 |
+
* Get content for the welcome notice
|
77 |
+
* @return string
|
78 |
+
*/
|
79 |
+
static public function get_welcome_notice() {
|
80 |
+
|
81 |
+
$html = '';
|
82 |
+
|
83 |
+
$html .= '<div id="aws-welcome-panel">';
|
84 |
+
$html .= '<div class="aws-welcome-notice updated notice is-dismissible" style="background:#f2fbff;">';
|
85 |
+
|
86 |
+
$html .= '<div class="welcome-panel" style="border:none;box-shadow:none;padding:0;margin:16px 0 0;background:transparent;">';
|
87 |
+
$html .= '<div class="welcome-panel-content">';
|
88 |
+
$html .= '<h2>' . sprintf( __( 'Welcome to %s', 'advanced-woo-search' ), 'Advanced Woo Search' ) . '</h2>';
|
89 |
+
$html .= '<p class="about-description">' . __( 'Powerful search plugin for WooCommerce.', 'advanced-woo-search' ) . '</p>';
|
90 |
+
$html .= '<div class="welcome-panel-column-container">';
|
91 |
+
$html .= '<div class="welcome-panel-column">';
|
92 |
+
$html .= '<h4>' . __( 'Get Started', 'advanced-woo-search' ) . '</h4>';
|
93 |
+
$html .= '<p style="margin-bottom:10px;">' . __( 'In order to start using the plugin search form you need to take following steps:', 'advanced-woo-search' ) . '</p>';
|
94 |
+
$html .= '<ul>';
|
95 |
+
$html .= '<li><strong>1.</strong> <strong>' . __( 'Index plugin table.', 'advanced-woo-search' ) . '</strong> ' . __( 'Click on the \'Reindex table\' button and wait till the index process is finished.', 'advanced-woo-search' ) . '</li>';
|
96 |
+
$html .= '<li><strong>2.</strong> <strong>' . __( 'Set plugin settings.', 'advanced-woo-search' ) . '</strong> ' . __( 'Leave it to default values or customize some of them.', 'advanced-woo-search' ) . '</li>';
|
97 |
+
$html .= '<li><strong>3.</strong> <strong>' . __( 'Add search form.', 'advanced-woo-search' ) . '</strong> ' . sprintf( __( 'There are several ways you can add a search form to your site. Use the \'Seamless integration\' option, shortcode, widget or custom php function. Read more inside %s section or read %s.', 'advanced-woo-search' ), '<a href="#activation">' . __( 'Activation', 'advanced-woo-search' ) . '</a>', '<a target="_blank" href="https://advanced-woo-search.com/guide/search-form/">' . __( 'guide article', 'advanced-woo-search' ) . '</a>' ) . '</li>';
|
98 |
+
$html .= '<li><strong>4.</strong> <strong>' . __( 'Finish!', 'advanced-woo-search' ) . '</strong> ' . __( 'Now all is set and you can check your search form on the pages where you add it.', 'advanced-woo-search' ) . '</li>';
|
99 |
+
$html .= '</ul>';
|
100 |
+
$html .= '</div>';
|
101 |
+
$html .= '<div class="welcome-panel-column">';
|
102 |
+
$html .= '<h4>' . __( 'Documentation', 'advanced-woo-search' ) . '</h4>';
|
103 |
+
$html .= '<ul>';
|
104 |
+
$html .= '<li><a href="https://advanced-woo-search.com/guide/search-form/" class="welcome-icon welcome-edit-page" target="_blank">' . __( 'How to Add Search Form', 'advanced-woo-search' ) . '</a></li>';
|
105 |
+
$html .= '<li><a href="https://advanced-woo-search.com/guide/search-source/" class="welcome-icon welcome-edit-page" target="_blank">' . __( 'Search Sources', 'advanced-woo-search' ) . '</a></li>';
|
106 |
+
$html .= '<li><a href="https://advanced-woo-search.com/guide/terms-search/" class="welcome-icon welcome-edit-page" target="_blank">' . __( 'Terms Pages Search', 'advanced-woo-search' ) . '</a></li>';
|
107 |
+
$html .= '</ul>';
|
108 |
+
$html .= '</div>';
|
109 |
+
$html .= '<div class="welcome-panel-column welcome-panel-last">';
|
110 |
+
$html .= '<h4>' . __( 'Help', 'advanced-woo-search' ) . '</h4>';
|
111 |
+
$html .= '<ul>';
|
112 |
+
$html .= '<li><div class="welcome-icon welcome-widgets-menus"><a href="https://wordpress.org/support/plugin/advanced-woo-search/" target="_blank">' . __( 'Support Forums', 'advanced-woo-search' ) . '</a></div></li>';
|
113 |
+
$html .= '<li><div class="welcome-icon welcome-widgets-menus"><a href="https://advanced-woo-search.com/contact/" target="_blank">' . __( 'Contact Form', 'advanced-woo-search' ) . '</a></div></li>';
|
114 |
+
$html .= '</ul>';
|
115 |
+
$html .= '</div>';
|
116 |
+
$html .= '</div>';
|
117 |
+
$html .= '</div>';
|
118 |
+
$html .= '</div>';
|
119 |
+
|
120 |
+
$html .= '</div>';
|
121 |
+
$html .= '</div>';
|
122 |
+
|
123 |
+
return $html;
|
124 |
+
|
125 |
+
}
|
126 |
+
|
127 |
+
/*
|
128 |
+
* Get content for the reindex notice
|
129 |
+
* @return string
|
130 |
+
*/
|
131 |
+
static public function get_reindex_notice() {
|
132 |
+
|
133 |
+
$html = '';
|
134 |
+
|
135 |
+
$html .= '<div class="updated notice is-dismissible">';
|
136 |
+
$html .= '<p>';
|
137 |
+
$html .= sprintf( esc_html__( 'Advanced Woo Search: In order to apply the changes in the index table you need to reindex. %s', 'advanced-woo-search' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Go to Settings Page', 'advanced-woo-search' ).'</a>' );
|
138 |
+
$html .= '</p>';
|
139 |
+
$html .= '</div>';
|
140 |
+
|
141 |
+
return $html;
|
142 |
+
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
endif;
|
includes/admin/class-aws-admin-options.php
CHANGED
@@ -1,670 +1,670 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'AWS_Admin_Options' ) ) :
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class for plugin admin options methods
|
12 |
-
*/
|
13 |
-
class AWS_Admin_Options {
|
14 |
-
|
15 |
-
/*
|
16 |
-
* Get default settings values
|
17 |
-
* @param string $tab Tab name
|
18 |
-
* @return array
|
19 |
-
*/
|
20 |
-
static public function get_default_settings( $tab = false ) {
|
21 |
-
|
22 |
-
$options = self::options_array( $tab );
|
23 |
-
$default_settings = array();
|
24 |
-
|
25 |
-
foreach ( $options as $section_name => $section ) {
|
26 |
-
|
27 |
-
foreach ( $section as $values ) {
|
28 |
-
|
29 |
-
if ( isset( $values['type'] ) && $values['type'] === 'heading' ) {
|
30 |
-
continue;
|
31 |
-
}
|
32 |
-
|
33 |
-
if ( isset( $values['type'] ) && $values['type'] === 'table' && empty( $values['value'] ) ) {
|
34 |
-
continue;
|
35 |
-
}
|
36 |
-
|
37 |
-
if ( isset( $values['type'] ) && ( $values['type'] === 'checkbox' || $values['type'] === 'table' ) ) {
|
38 |
-
foreach ( $values['choices'] as $key => $val ) {
|
39 |
-
$default_settings[ $values['id'] ][$key] = sanitize_text_field( $values['value'][$key] );
|
40 |
-
}
|
41 |
-
continue;
|
42 |
-
}
|
43 |
-
|
44 |
-
if ( $values['type'] === 'textarea' && isset( $values['allow_tags'] ) ) {
|
45 |
-
$default_settings[$values['id']] = (string) addslashes( wp_kses( stripslashes( $values['value'] ), AWS_Helpers::get_kses( $values['allow_tags'] ) ) );
|
46 |
-
continue;
|
47 |
-
}
|
48 |
-
|
49 |
-
if ( $values['type'] === 'textarea' ) {
|
50 |
-
if ( function_exists('sanitize_textarea_field') ) {
|
51 |
-
$default_settings[ $values['id'] ] = (string) sanitize_textarea_field( $values['value'] );
|
52 |
-
} else {
|
53 |
-
$default_settings[ $values['id'] ] = (string) str_replace( "<\n", "<\n", wp_strip_all_tags( $values['value'] ) );
|
54 |
-
}
|
55 |
-
continue;
|
56 |
-
}
|
57 |
-
|
58 |
-
$default_settings[$values['id']] = (string) sanitize_text_field( $values['value'] );
|
59 |
-
|
60 |
-
if ( isset( $values['sub_option'] ) ) {
|
61 |
-
$default_settings[$values['sub_option']['id']] = (string) sanitize_text_field( $values['sub_option']['value'] );
|
62 |
-
}
|
63 |
-
|
64 |
-
}
|
65 |
-
|
66 |
-
}
|
67 |
-
|
68 |
-
return $default_settings;
|
69 |
-
|
70 |
-
}
|
71 |
-
|
72 |
-
/*
|
73 |
-
* Update plugin settings
|
74 |
-
*/
|
75 |
-
static public function update_settings() {
|
76 |
-
|
77 |
-
$options = self::options_array();
|
78 |
-
$update_settings = self::get_settings();
|
79 |
-
$current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_text_field( $_GET['tab'] );
|
80 |
-
|
81 |
-
foreach ( $options[$current_tab] as $values ) {
|
82 |
-
|
83 |
-
if ( $values['type'] === 'heading' || $values['type'] === 'table' ) {
|
84 |
-
continue;
|
85 |
-
}
|
86 |
-
|
87 |
-
if ( $values['type'] === 'checkbox' ) {
|
88 |
-
|
89 |
-
$checkbox_array = array();
|
90 |
-
|
91 |
-
foreach ( $values['choices'] as $key => $value ) {
|
92 |
-
$new_value = isset( $_POST[ $values['id'] ][$key] ) ? '1' : '0';
|
93 |
-
$checkbox_array[$key] = (string) sanitize_text_field( $new_value );
|
94 |
-
}
|
95 |
-
|
96 |
-
$update_settings[ $values['id'] ] = $checkbox_array;
|
97 |
-
|
98 |
-
continue;
|
99 |
-
}
|
100 |
-
|
101 |
-
$new_value = isset( $_POST[ $values['id'] ] ) ? $_POST[ $values['id'] ] : '';
|
102 |
-
|
103 |
-
if ( $values['type'] === 'textarea' && isset( $values['allow_tags'] ) ) {
|
104 |
-
$update_settings[ $values['id'] ] = (string) addslashes( wp_kses( stripslashes( $new_value ), AWS_Helpers::get_kses( $values['allow_tags'] ) ) );
|
105 |
-
continue;
|
106 |
-
}
|
107 |
-
|
108 |
-
if ( $values['type'] === 'textarea' ) {
|
109 |
-
if ( function_exists('sanitize_textarea_field') ) {
|
110 |
-
$update_settings[ $values['id'] ] = (string) sanitize_textarea_field( $new_value );
|
111 |
-
} else {
|
112 |
-
$update_settings[ $values['id'] ] = (string) str_replace( "<\n", "<\n", wp_strip_all_tags( $new_value ) );
|
113 |
-
}
|
114 |
-
continue;
|
115 |
-
}
|
116 |
-
|
117 |
-
$update_settings[ $values['id'] ] = (string) sanitize_text_field( $new_value );
|
118 |
-
|
119 |
-
if ( isset( $values['sub_option'] ) ) {
|
120 |
-
$new_value = isset( $_POST[ $values['sub_option']['id'] ] ) ? $_POST[ $values['sub_option']['id'] ] : '';
|
121 |
-
$update_settings[ $values['sub_option']['id'] ] = (string) sanitize_text_field( $new_value );
|
122 |
-
}
|
123 |
-
}
|
124 |
-
|
125 |
-
update_option( 'aws_settings', $update_settings );
|
126 |
-
|
127 |
-
AWS_Helpers::register_wpml_translations( $update_settings );
|
128 |
-
|
129 |
-
do_action( 'aws_settings_saved' );
|
130 |
-
|
131 |
-
do_action( 'aws_cache_clear' );
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
/*
|
136 |
-
* Get plugin settings
|
137 |
-
* @return array
|
138 |
-
*/
|
139 |
-
static public function get_settings() {
|
140 |
-
$plugin_options = get_option( 'aws_settings' );
|
141 |
-
return $plugin_options;
|
142 |
-
}
|
143 |
-
|
144 |
-
/*
|
145 |
-
* Options array that generate settings page
|
146 |
-
*
|
147 |
-
* @param string $tab Tab name
|
148 |
-
* @return array
|
149 |
-
*/
|
150 |
-
static public function options_array( $tab = false ) {
|
151 |
-
|
152 |
-
$options = self::include_options();
|
153 |
-
$options_arr = array();
|
154 |
-
|
155 |
-
foreach ( $options as $tab_name => $tab_options ) {
|
156 |
-
|
157 |
-
if ( $tab && $tab !== $tab_name ) {
|
158 |
-
continue;
|
159 |
-
}
|
160 |
-
|
161 |
-
$options_arr[$tab_name] = $tab_options;
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* Filter admin page options for current page
|
167 |
-
* @since 2.23
|
168 |
-
* @param array $options_arr Array of options
|
169 |
-
* @param bool|string $tab Current settings page tab
|
170 |
-
*/
|
171 |
-
$options_arr = apply_filters( 'aws_admin_page_options_current', $options_arr, $tab );
|
172 |
-
|
173 |
-
return $options_arr;
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
/*
|
178 |
-
* Include options array
|
179 |
-
* @return array
|
180 |
-
*/
|
181 |
-
static public function include_options() {
|
182 |
-
|
183 |
-
$options = array();
|
184 |
-
|
185 |
-
$options['general'][] = array(
|
186 |
-
"name" => __( "Main Settings", "advanced-woo-search" ),
|
187 |
-
"type" => "heading"
|
188 |
-
);
|
189 |
-
|
190 |
-
$options['general'][] = array(
|
191 |
-
"name" => __( "Seamless integration", "advanced-woo-search" ),
|
192 |
-
"desc" => __( "Replace all the standard search forms on your website ( may not work with some themes ).", "advanced-woo-search" ),
|
193 |
-
"id" => "seamless",
|
194 |
-
"value" => 'false',
|
195 |
-
"type" => "radio",
|
196 |
-
'choices' => array(
|
197 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
198 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
199 |
-
)
|
200 |
-
);
|
201 |
-
|
202 |
-
$options['general'][] = array(
|
203 |
-
"name" => __( "Cache results", "advanced-woo-search" ),
|
204 |
-
"desc" => __( "Turn off if you have old data in the search results after content of products was changed.<br><strong>CAUTION:</strong> can dramatically increase search speed", "advanced-woo-search" ),
|
205 |
-
"id" => "cache",
|
206 |
-
"value" => 'true',
|
207 |
-
"type" => "radio",
|
208 |
-
'choices' => array(
|
209 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
210 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
211 |
-
)
|
212 |
-
);
|
213 |
-
|
214 |
-
$options['general'][] = array(
|
215 |
-
"name" => __( "Sync index table", "advanced-woo-search" ),
|
216 |
-
"desc" => __( "Automatically update plugin index table when product content was changed. This means that in search there will be always latest product data.", "advanced-woo-search" ) . '<br>' .
|
217 |
-
__( "Turn this off if you have any problems with performance.", "advanced-woo-search" ),
|
218 |
-
"id" => "autoupdates",
|
219 |
-
"value" => 'true',
|
220 |
-
"type" => "radio",
|
221 |
-
'choices' => array(
|
222 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
223 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
224 |
-
)
|
225 |
-
);
|
226 |
-
|
227 |
-
$options['general'][] = array(
|
228 |
-
"name" => __( "Search in", "advanced-woo-search" ),
|
229 |
-
"desc" => __( "Click on status icon to enable or disable search source.", "advanced-woo-search" ),
|
230 |
-
"table_head" => __( 'Search Source', 'advanced-woo-search' ),
|
231 |
-
"id" => "search_in",
|
232 |
-
"value" => array(
|
233 |
-
'title' => 1,
|
234 |
-
'content' => 1,
|
235 |
-
'sku' => 1,
|
236 |
-
'excerpt' => 1,
|
237 |
-
'category' => 0,
|
238 |
-
'tag' => 0,
|
239 |
-
'id' => 0,
|
240 |
-
),
|
241 |
-
"choices" => array(
|
242 |
-
"title" => __( "Title", "advanced-woo-search" ),
|
243 |
-
"content" => __( "Content", "advanced-woo-search" ),
|
244 |
-
"sku" => __( "SKU", "advanced-woo-search" ),
|
245 |
-
"excerpt" => __( "Short description", "advanced-woo-search" ),
|
246 |
-
"category" => __( "Category", "advanced-woo-search" ),
|
247 |
-
"tag" => __( "Tag", "advanced-woo-search" ),
|
248 |
-
"id" => __( "ID", "advanced-woo-search" ),
|
249 |
-
),
|
250 |
-
"type" => "table"
|
251 |
-
);
|
252 |
-
|
253 |
-
$options['general'][] = array(
|
254 |
-
"name" => __( "Archive pages", "advanced-woo-search" ),
|
255 |
-
"desc" => __( "Search for taxonomies and displayed their archive pages in search results.", "advanced-woo-search" ),
|
256 |
-
'table_head' => __( 'Archive Pages', 'advanced-woo-search' ),
|
257 |
-
"id" => "search_archives",
|
258 |
-
"value" => array(
|
259 |
-
'archive_category' => 0,
|
260 |
-
'archive_tag' => 0,
|
261 |
-
),
|
262 |
-
"choices" => array(
|
263 |
-
"archive_category" => __( "Category", "advanced-woo-search" ),
|
264 |
-
"archive_tag" => __( "Tag", "advanced-woo-search" ),
|
265 |
-
),
|
266 |
-
"type" => "table"
|
267 |
-
);
|
268 |
-
|
269 |
-
$options['general'][] = array(
|
270 |
-
"name" => __( "Stop words list", "advanced-woo-search" ),
|
271 |
-
"desc" => __( "Comma separated list of words that will be excluded from search.", "advanced-woo-search" ) . '<br>' . __( "Re-index required on change.", "advanced-woo-search" ),
|
272 |
-
"id" => "stopwords",
|
273 |
-
"value" => "a, also, am, an, and, are, as, at, be, but, by, call, can, co, con, de, do, due, eg, eight, etc, even, ever, every, for, from, full, go, had, has, hasnt, have, he, hence, her, here, his, how, ie, if, in, inc, into, is, it, its, ltd, me, my, no, none, nor, not, now, of, off, on, once, one, only, onto, or, our, ours, out, over, own, part, per, put, re, see, so, some, ten, than, that, the, their, there, these, they, this, three, thru, thus, to, too, top, un, up, us, very, via, was, we, well, were, what, when, where, who, why, will",
|
274 |
-
"cols" => "85",
|
275 |
-
"rows" => "3",
|
276 |
-
"type" => "textarea"
|
277 |
-
);
|
278 |
-
|
279 |
-
$options['general'][] = array(
|
280 |
-
"name" => __( "Synonyms", "advanced-woo-search" ),
|
281 |
-
"desc" => __( "Comma separated list of synonym words. Each group of synonyms must be on separated text line.", "advanced-woo-search" ) . '<br>' . __( "Re-index required on change.", "advanced-woo-search" ),
|
282 |
-
"id" => "synonyms",
|
283 |
-
"value" => "buy, pay, purchase, acquire box, housing, unit, package",
|
284 |
-
"cols" => "85",
|
285 |
-
"rows" => "3",
|
286 |
-
"type" => "textarea"
|
287 |
-
);
|
288 |
-
|
289 |
-
$options['general'][] = array(
|
290 |
-
"name" => __( "Use Google Analytics", "advanced-woo-search" ),
|
291 |
-
"desc" => __( "Use google analytics to track searches. You need google analytics to be installed on your site.", "advanced-woo-search" ) .
|
292 |
-
'<br>' . sprintf( __( "Data will be visible inside Google Analytics 'Site Search' report. Need to activate 'Site Search' feature inside GA. %s", "advanced-woo-search" ), '<a href="https://advanced-woo-search.com/guide/google-analytics/" target="_blank">' . __( 'More info', 'advanced-woo-search' ) . '</a>' ) .
|
293 |
-
'<br>' . __( "Also will send event with category - 'AWS search', action - 'AWS Search Term' and label of value of search term.", "advanced-woo-search" ),
|
294 |
-
"id" => "use_analytics",
|
295 |
-
"value" => 'false',
|
296 |
-
"type" => "radio",
|
297 |
-
'choices' => array(
|
298 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
299 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
300 |
-
)
|
301 |
-
);
|
302 |
-
|
303 |
-
$options['performance'][] = array(
|
304 |
-
"name" => __( "Search options", "advanced-woo-search" ),
|
305 |
-
"type" => "heading"
|
306 |
-
);
|
307 |
-
|
308 |
-
$options['performance'][] = array(
|
309 |
-
"name" => __( "Search rule", "advanced-woo-search" ),
|
310 |
-
"desc" => __( "Search rule that will be used for terms search.", "advanced-woo-search" ),
|
311 |
-
"id" => "search_rule",
|
312 |
-
"value" => 'contains',
|
313 |
-
"type" => "radio",
|
314 |
-
'choices' => array(
|
315 |
-
'contains' => '%s% ' . __( "( contains ). Search query can be inside any part of the product words ( beginning, end, middle ). Slow.", "advanced-woo-search" ),
|
316 |
-
'begins' => 's% ' . __( "( begins ). Search query can be only at the beginning of the product words. Fast.", "advanced-woo-search" ),
|
317 |
-
)
|
318 |
-
);
|
319 |
-
|
320 |
-
$options['performance'][] = array(
|
321 |
-
"name" => __( "AJAX timeout", "advanced-woo-search" ),
|
322 |
-
"desc" => __( "Time after user input that script is waiting before sending a search event to the server, ms.", "advanced-woo-search" ),
|
323 |
-
"id" => "search_timeout",
|
324 |
-
"value" => 300,
|
325 |
-
'min' => 100,
|
326 |
-
"type" => "number"
|
327 |
-
);
|
328 |
-
|
329 |
-
$options['performance'][] = array(
|
330 |
-
"name" => __( "Index table options", "advanced-woo-search" ),
|
331 |
-
"id" => "index_sources",
|
332 |
-
"type" => "heading"
|
333 |
-
);
|
334 |
-
|
335 |
-
$options['performance'][] = array(
|
336 |
-
"name" => __( "Overview", "advanced-woo-search" ),
|
337 |
-
'heading_type' => 'text',
|
338 |
-
'desc' => __( 'To perform the search plugin use a special index table. This table contains normalized words of all your products from all available sources.', "advanced-woo-search" ) . '<br>' .
|
339 |
-
__( 'Sometimes when there are too many products in your store index table can be very large and that can reflect on search speed.', "advanced-woo-search" ) . '<br>' .
|
340 |
-
__( 'In this section you can use several options to change the table size by disabling some unused product data.', "advanced-woo-search" ) . '<br>' .
|
341 |
-
'<b>' . __( "Note:", "advanced-woo-search" ) . '</b> ' . __( "Reindex is required after options changes.", "advanced-woo-search" ),
|
342 |
-
"type" => "heading"
|
343 |
-
);
|
344 |
-
|
345 |
-
$options['performance'][] = array(
|
346 |
-
"name" => __( "Data to index", "advanced-woo-search" ),
|
347 |
-
"desc" => __( "Choose what products data to add inside the plugin index table.", "advanced-woo-search" ),
|
348 |
-
"table_head" => __( 'What to index', 'advanced-woo-search' ),
|
349 |
-
"id" => "index_sources",
|
350 |
-
"value" => array(
|
351 |
-
'title' => 1,
|
352 |
-
'content' => 1,
|
353 |
-
'sku' => 1,
|
354 |
-
'excerpt' => 1,
|
355 |
-
'category' => 1,
|
356 |
-
'tag' => 1,
|
357 |
-
'id' => 1,
|
358 |
-
),
|
359 |
-
"choices" => array(
|
360 |
-
"title" => __( "Title", "advanced-woo-search" ),
|
361 |
-
"content" => __( "Content", "advanced-woo-search" ),
|
362 |
-
"sku" => __( "SKU", "advanced-woo-search" ),
|
363 |
-
"excerpt" => __( "Short description", "advanced-woo-search" ),
|
364 |
-
"category" => __( "Category", "advanced-woo-search" ),
|
365 |
-
"tag" => __( "Tag", "advanced-woo-search" ),
|
366 |
-
"id" => __( "ID", "advanced-woo-search" ),
|
367 |
-
),
|
368 |
-
"type" => "table"
|
369 |
-
);
|
370 |
-
|
371 |
-
$options['performance'][] = array(
|
372 |
-
"name" => __( "Index variations", "advanced-woo-search" ),
|
373 |
-
"desc" => __( "Index or not content of product variations.", "advanced-woo-search" ),
|
374 |
-
"id" => "index_variations",
|
375 |
-
"value" => 'true',
|
376 |
-
"type" => "radio",
|
377 |
-
'choices' => array(
|
378 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
379 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
380 |
-
)
|
381 |
-
);
|
382 |
-
|
383 |
-
// Search Form Settings
|
384 |
-
$options['form'][] = array(
|
385 |
-
"name" => __( "Text for search field", "advanced-woo-search" ),
|
386 |
-
"desc" => __( "Text for search field placeholder.", "advanced-woo-search" ),
|
387 |
-
"id" => "search_field_text",
|
388 |
-
"value" => __( "Search", "advanced-woo-search" ),
|
389 |
-
"type" => "text"
|
390 |
-
);
|
391 |
-
|
392 |
-
$options['form'][] = array(
|
393 |
-
"name" => __( "Text for show more button", "advanced-woo-search" ),
|
394 |
-
"desc" => __( "Text for link to search results page at the bottom of search results block.", "advanced-woo-search" ),
|
395 |
-
"id" => "show_more_text",
|
396 |
-
"value" => __( "View all results", "advanced-woo-search" ),
|
397 |
-
"type" => "text"
|
398 |
-
);
|
399 |
-
|
400 |
-
$options['form'][] = array(
|
401 |
-
"name" => __( "Nothing found field", "advanced-woo-search" ),
|
402 |
-
"desc" => __( "Text when there is no search results.", "advanced-woo-search" ),
|
403 |
-
"id" => "not_found_text",
|
404 |
-
"value" => __( "Nothing found", "advanced-woo-search" ),
|
405 |
-
"type" => "textarea",
|
406 |
-
'allow_tags' => array( 'a', 'br', 'em', 'strong', 'b', 'code', 'blockquote', 'p', 'i' )
|
407 |
-
);
|
408 |
-
|
409 |
-
$options['form'][] = array(
|
410 |
-
"name" => __( "Minimum number of characters", "advanced-woo-search" ),
|
411 |
-
"desc" => __( "Minimum number of characters required to run ajax search.", "advanced-woo-search" ),
|
412 |
-
"id" => "min_chars",
|
413 |
-
"value" => 1,
|
414 |
-
"type" => "number"
|
415 |
-
);
|
416 |
-
|
417 |
-
$options['form'][] = array(
|
418 |
-
"name" => __( "Show loader", "advanced-woo-search" ),
|
419 |
-
"desc" => __( "Show loader animation while searching.", "advanced-woo-search" ),
|
420 |
-
"id" => "show_loader",
|
421 |
-
"value" => 'true',
|
422 |
-
"type" => "radio",
|
423 |
-
'choices' => array(
|
424 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
425 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
426 |
-
)
|
427 |
-
);
|
428 |
-
|
429 |
-
$options['form'][] = array(
|
430 |
-
"name" => __( "Show clear button", "advanced-woo-search" ),
|
431 |
-
"desc" => __( "Show 'Clear search string' button for desktop devices ( for mobile it is always visible ).", "advanced-woo-search" ),
|
432 |
-
"id" => "show_clear",
|
433 |
-
"value" => 'true',
|
434 |
-
"type" => "radio",
|
435 |
-
'choices' => array(
|
436 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
437 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
438 |
-
)
|
439 |
-
);
|
440 |
-
|
441 |
-
$options['form'][] = array(
|
442 |
-
"name" => __( "Show 'View All Results'", "advanced-woo-search" ),
|
443 |
-
"desc" => __( "Show link to search results page at the bottom of search results block.", "advanced-woo-search" ),
|
444 |
-
"id" => "show_more",
|
445 |
-
"value" => 'true',
|
446 |
-
"type" => "radio",
|
447 |
-
'choices' => array(
|
448 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
449 |
-
'false' => __( 'Off', 'advanced-woo-search' )
|
450 |
-
)
|
451 |
-
);
|
452 |
-
|
453 |
-
$options['form'][] = array(
|
454 |
-
"name" => __( "Mobile full screen", "advanced-woo-search" ),
|
455 |
-
"desc" => __( "Full screen search on focus. Will not work if the search form is inside the block with position: fixed.", "advanced-woo-search" ),
|
456 |
-
"id" => "mobile_overlay",
|
457 |
-
"value" => 'false',
|
458 |
-
"type" => "radio",
|
459 |
-
'choices' => array(
|
460 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
461 |
-
'false' => __( 'Off', 'advanced-woo-search' )
|
462 |
-
)
|
463 |
-
);
|
464 |
-
|
465 |
-
$options['form'][] = array(
|
466 |
-
"name" => __( "Search Results", "advanced-woo-search" ),
|
467 |
-
"desc" => __( "Choose how to view search results.", "advanced-woo-search" ),
|
468 |
-
"id" => "show_page",
|
469 |
-
"value" => 'true',
|
470 |
-
"type" => "radio",
|
471 |
-
'choices' => array(
|
472 |
-
'true' => __( 'Both ajax search results and search results page', 'advanced-woo-search' ),
|
473 |
-
'false' => __( 'Only ajax search results ( no search results page )', 'advanced-woo-search' ),
|
474 |
-
'ajax_off' => __( 'Only search results page ( no ajax search results )', 'advanced-woo-search' )
|
475 |
-
)
|
476 |
-
);
|
477 |
-
|
478 |
-
$options['form'][] = array(
|
479 |
-
"name" => __( "Form Styling", "advanced-woo-search" ),
|
480 |
-
"desc" => __( "Choose search form layout", "advanced-woo-search" ) . '<br>' . __( "Filter button will be visible only if you have more than one active filter for current search form instance.", "advanced-woo-search" ),
|
481 |
-
"id" => "buttons_order",
|
482 |
-
"value" => '1',
|
483 |
-
"type" => "radio-image",
|
484 |
-
'choices' => array(
|
485 |
-
'1' => 'btn-layout1.png',
|
486 |
-
'2' => 'btn-layout2.png',
|
487 |
-
'3' => 'btn-layout3.png',
|
488 |
-
)
|
489 |
-
);
|
490 |
-
|
491 |
-
// Search Results Settings
|
492 |
-
$options['results'][] = array(
|
493 |
-
"name" => __( "Description source", "advanced-woo-search" ),
|
494 |
-
"desc" => __( "From where to take product description.<br>If first source is empty data will be taken from other sources.", "advanced-woo-search" ),
|
495 |
-
"id" => "desc_source",
|
496 |
-
"value" => 'content',
|
497 |
-
"type" => "radio",
|
498 |
-
'choices' => array(
|
499 |
-
'content' => __( 'Content', 'advanced-woo-search' ),
|
500 |
-
'excerpt' => __( 'Short description', 'advanced-woo-search' ),
|
501 |
-
)
|
502 |
-
);
|
503 |
-
|
504 |
-
$options['results'][] = array(
|
505 |
-
"name" => __( "Description content", "advanced-woo-search" ),
|
506 |
-
"desc" => __( "What to show in product description?", "advanced-woo-search" ),
|
507 |
-
"id" => "mark_words",
|
508 |
-
"value" => 'true',
|
509 |
-
"type" => "radio",
|
510 |
-
'choices' => array(
|
511 |
-
'true' => __( "Smart scrapping sentences with searching terms from product description.", "advanced-woo-search" ),
|
512 |
-
'false' => __( "First N words of product description ( number of words that you choose below. )", "advanced-woo-search" ),
|
513 |
-
)
|
514 |
-
);
|
515 |
-
|
516 |
-
$options['results'][] = array(
|
517 |
-
"name" => __( "Description length", "advanced-woo-search" ),
|
518 |
-
"desc" => __( "Maximal allowed number of words for product description.", "advanced-woo-search" ),
|
519 |
-
"id" => "excerpt_length",
|
520 |
-
"value" => 20,
|
521 |
-
"type" => "number"
|
522 |
-
);
|
523 |
-
|
524 |
-
$options['results'][] = array(
|
525 |
-
"name" => __( "Max number of results", "advanced-woo-search" ),
|
526 |
-
"desc" => __( "Maximum number of displayed search results.", "advanced-woo-search" ),
|
527 |
-
"id" => "results_num",
|
528 |
-
"value" => 10,
|
529 |
-
"type" => "number"
|
530 |
-
);
|
531 |
-
|
532 |
-
$options['results'][] = array(
|
533 |
-
"name" => __( "Show out-of-stock", "advanced-woo-search" ),
|
534 |
-
"desc" => __( "Show out-of-stock products in search", "advanced-woo-search" ),
|
535 |
-
"id" => "outofstock",
|
536 |
-
"value" => 'true',
|
537 |
-
"type" => "radio",
|
538 |
-
'choices' => array(
|
539 |
-
'true' => __( 'Show', 'advanced-woo-search' ),
|
540 |
-
'false' => __( 'Hide', 'advanced-woo-search' ),
|
541 |
-
)
|
542 |
-
);
|
543 |
-
|
544 |
-
$options['results'][] = array(
|
545 |
-
"name" => __( "View", "advanced-woo-search" ),
|
546 |
-
"type" => "heading"
|
547 |
-
);
|
548 |
-
|
549 |
-
$options['results'][] = array(
|
550 |
-
"name" => __( "Highlight words", "advanced-woo-search" ),
|
551 |
-
"desc" => __( "Highlight search words inside products content.", "advanced-woo-search" ),
|
552 |
-
"id" => "highlight",
|
553 |
-
"value" => 'true',
|
554 |
-
"type" => "radio",
|
555 |
-
'choices' => array(
|
556 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
557 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
558 |
-
)
|
559 |
-
);
|
560 |
-
|
561 |
-
$options['results'][] = array(
|
562 |
-
"name" => __( "Show image", "advanced-woo-search" ),
|
563 |
-
"desc" => __( "Show product image for each search result.", "advanced-woo-search" ),
|
564 |
-
"id" => "show_image",
|
565 |
-
"value" => 'true',
|
566 |
-
"type" => "radio",
|
567 |
-
'choices' => array(
|
568 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
569 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
570 |
-
)
|
571 |
-
);
|
572 |
-
|
573 |
-
$options['results'][] = array(
|
574 |
-
"name" => __( "Show description", "advanced-woo-search" ),
|
575 |
-
"desc" => __( "Show product description for each search result.", "advanced-woo-search" ),
|
576 |
-
"id" => "show_excerpt",
|
577 |
-
"value" => 'true',
|
578 |
-
"type" => "radio",
|
579 |
-
'choices' => array(
|
580 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
581 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
582 |
-
)
|
583 |
-
);
|
584 |
-
|
585 |
-
$options['results'][] = array(
|
586 |
-
"name" => __( "Show price", "advanced-woo-search" ),
|
587 |
-
"desc" => __( "Show product price for each search result.", "advanced-woo-search" ),
|
588 |
-
"id" => "show_price",
|
589 |
-
"value" => 'true',
|
590 |
-
"type" => "radio",
|
591 |
-
'choices' => array(
|
592 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
593 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
594 |
-
)
|
595 |
-
);
|
596 |
-
|
597 |
-
$options['results'][] = array(
|
598 |
-
"name" => __( "Show price for out of stock", "advanced-woo-search" ),
|
599 |
-
"desc" => __( "Show product price for out of stock products.", "advanced-woo-search" ),
|
600 |
-
"id" => "show_outofstock_price",
|
601 |
-
"value" => 'true',
|
602 |
-
"type" => "radio",
|
603 |
-
'choices' => array(
|
604 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
605 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
606 |
-
)
|
607 |
-
);
|
608 |
-
|
609 |
-
$options['results'][] = array(
|
610 |
-
"name" => __( "Show sale badge", "advanced-woo-search" ),
|
611 |
-
"desc" => __( "Show sale badge for products in search results.", "advanced-woo-search" ),
|
612 |
-
"id" => "show_sale",
|
613 |
-
"value" => 'true',
|
614 |
-
"type" => "radio",
|
615 |
-
'choices' => array(
|
616 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
617 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
618 |
-
)
|
619 |
-
);
|
620 |
-
|
621 |
-
$options['results'][] = array(
|
622 |
-
"name" => __( "Show product SKU", "advanced-woo-search" ),
|
623 |
-
"desc" => __( "Show product SKU in search results.", "advanced-woo-search" ),
|
624 |
-
"id" => "show_sku",
|
625 |
-
"value" => 'false',
|
626 |
-
"type" => "radio",
|
627 |
-
'choices' => array(
|
628 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
629 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
630 |
-
)
|
631 |
-
);
|
632 |
-
|
633 |
-
$options['results'][] = array(
|
634 |
-
"name" => __( "Show stock status", "advanced-woo-search" ),
|
635 |
-
"desc" => __( "Show stock status for every product in search results.", "advanced-woo-search" ),
|
636 |
-
"id" => "show_stock",
|
637 |
-
"value" => 'false',
|
638 |
-
"type" => "radio",
|
639 |
-
'choices' => array(
|
640 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
641 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
642 |
-
)
|
643 |
-
);
|
644 |
-
|
645 |
-
$options['results'][] = array(
|
646 |
-
"name" => __( "Show featured icon", "advanced-woo-search" ),
|
647 |
-
"desc" => __( "Show or not star icon for featured products.", "advanced-woo-search" ),
|
648 |
-
"id" => "show_featured",
|
649 |
-
"value" => 'false',
|
650 |
-
"type" => "radio",
|
651 |
-
'choices' => array(
|
652 |
-
'true' => __( 'On', 'advanced-woo-search' ),
|
653 |
-
'false' => __( 'Off', 'advanced-woo-search' ),
|
654 |
-
)
|
655 |
-
);
|
656 |
-
|
657 |
-
/**
|
658 |
-
* Filter admin page options
|
659 |
-
* @since 2.15
|
660 |
-
* @param array $options Array of options
|
661 |
-
*/
|
662 |
-
$options = apply_filters( 'aws_admin_page_options', $options );
|
663 |
-
|
664 |
-
return $options;
|
665 |
-
|
666 |
-
}
|
667 |
-
|
668 |
-
}
|
669 |
-
|
670 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'AWS_Admin_Options' ) ) :
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class for plugin admin options methods
|
12 |
+
*/
|
13 |
+
class AWS_Admin_Options {
|
14 |
+
|
15 |
+
/*
|
16 |
+
* Get default settings values
|
17 |
+
* @param string $tab Tab name
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
static public function get_default_settings( $tab = false ) {
|
21 |
+
|
22 |
+
$options = self::options_array( $tab );
|
23 |
+
$default_settings = array();
|
24 |
+
|
25 |
+
foreach ( $options as $section_name => $section ) {
|
26 |
+
|
27 |
+
foreach ( $section as $values ) {
|
28 |
+
|
29 |
+
if ( isset( $values['type'] ) && $values['type'] === 'heading' ) {
|
30 |
+
continue;
|
31 |
+
}
|
32 |
+
|
33 |
+
if ( isset( $values['type'] ) && $values['type'] === 'table' && empty( $values['value'] ) ) {
|
34 |
+
continue;
|
35 |
+
}
|
36 |
+
|
37 |
+
if ( isset( $values['type'] ) && ( $values['type'] === 'checkbox' || $values['type'] === 'table' ) ) {
|
38 |
+
foreach ( $values['choices'] as $key => $val ) {
|
39 |
+
$default_settings[ $values['id'] ][$key] = sanitize_text_field( $values['value'][$key] );
|
40 |
+
}
|
41 |
+
continue;
|
42 |
+
}
|
43 |
+
|
44 |
+
if ( $values['type'] === 'textarea' && isset( $values['allow_tags'] ) ) {
|
45 |
+
$default_settings[$values['id']] = (string) addslashes( wp_kses( stripslashes( $values['value'] ), AWS_Helpers::get_kses( $values['allow_tags'] ) ) );
|
46 |
+
continue;
|
47 |
+
}
|
48 |
+
|
49 |
+
if ( $values['type'] === 'textarea' ) {
|
50 |
+
if ( function_exists('sanitize_textarea_field') ) {
|
51 |
+
$default_settings[ $values['id'] ] = (string) sanitize_textarea_field( $values['value'] );
|
52 |
+
} else {
|
53 |
+
$default_settings[ $values['id'] ] = (string) str_replace( "<\n", "<\n", wp_strip_all_tags( $values['value'] ) );
|
54 |
+
}
|
55 |
+
continue;
|
56 |
+
}
|
57 |
+
|
58 |
+
$default_settings[$values['id']] = (string) sanitize_text_field( $values['value'] );
|
59 |
+
|
60 |
+
if ( isset( $values['sub_option'] ) ) {
|
61 |
+
$default_settings[$values['sub_option']['id']] = (string) sanitize_text_field( $values['sub_option']['value'] );
|
62 |
+
}
|
63 |
+
|
64 |
+
}
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
return $default_settings;
|
69 |
+
|
70 |
+
}
|
71 |
+
|
72 |
+
/*
|
73 |
+
* Update plugin settings
|
74 |
+
*/
|
75 |
+
static public function update_settings() {
|
76 |
+
|
77 |
+
$options = self::options_array();
|
78 |
+
$update_settings = self::get_settings();
|
79 |
+
$current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_text_field( $_GET['tab'] );
|
80 |
+
|
81 |
+
foreach ( $options[$current_tab] as $values ) {
|
82 |
+
|
83 |
+
if ( $values['type'] === 'heading' || $values['type'] === 'table' ) {
|
84 |
+
continue;
|
85 |
+
}
|
86 |
+
|
87 |
+
if ( $values['type'] === 'checkbox' ) {
|
88 |
+
|
89 |
+
$checkbox_array = array();
|
90 |
+
|
91 |
+
foreach ( $values['choices'] as $key => $value ) {
|
92 |
+
$new_value = isset( $_POST[ $values['id'] ][$key] ) ? '1' : '0';
|
93 |
+
$checkbox_array[$key] = (string) sanitize_text_field( $new_value );
|
94 |
+
}
|
95 |
+
|
96 |
+
$update_settings[ $values['id'] ] = $checkbox_array;
|
97 |
+
|
98 |
+
continue;
|
99 |
+
}
|
100 |
+
|
101 |
+
$new_value = isset( $_POST[ $values['id'] ] ) ? $_POST[ $values['id'] ] : '';
|
102 |
+
|
103 |
+
if ( $values['type'] === 'textarea' && isset( $values['allow_tags'] ) ) {
|
104 |
+
$update_settings[ $values['id'] ] = (string) addslashes( wp_kses( stripslashes( $new_value ), AWS_Helpers::get_kses( $values['allow_tags'] ) ) );
|
105 |
+
continue;
|
106 |
+
}
|
107 |
+
|
108 |
+
if ( $values['type'] === 'textarea' ) {
|
109 |
+
if ( function_exists('sanitize_textarea_field') ) {
|
110 |
+
$update_settings[ $values['id'] ] = (string) sanitize_textarea_field( $new_value );
|
111 |
+
} else {
|
112 |
+
$update_settings[ $values['id'] ] = (string) str_replace( "<\n", "<\n", wp_strip_all_tags( $new_value ) );
|
113 |
+
}
|
114 |
+
continue;
|
115 |
+
}
|
116 |
+
|
117 |
+
$update_settings[ $values['id'] ] = (string) sanitize_text_field( $new_value );
|
118 |
+
|
119 |
+
if ( isset( $values['sub_option'] ) ) {
|
120 |
+
$new_value = isset( $_POST[ $values['sub_option']['id'] ] ) ? $_POST[ $values['sub_option']['id'] ] : '';
|
121 |
+
$update_settings[ $values['sub_option']['id'] ] = (string) sanitize_text_field( $new_value );
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
update_option( 'aws_settings', $update_settings );
|
126 |
+
|
127 |
+
AWS_Helpers::register_wpml_translations( $update_settings );
|
128 |
+
|
129 |
+
do_action( 'aws_settings_saved' );
|
130 |
+
|
131 |
+
do_action( 'aws_cache_clear' );
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
/*
|
136 |
+
* Get plugin settings
|
137 |
+
* @return array
|
138 |
+
*/
|
139 |
+
static public function get_settings() {
|
140 |
+
$plugin_options = get_option( 'aws_settings' );
|
141 |
+
return $plugin_options;
|
142 |
+
}
|
143 |
+
|
144 |
+
/*
|
145 |
+
* Options array that generate settings page
|
146 |
+
*
|
147 |
+
* @param string $tab Tab name
|
148 |
+
* @return array
|
149 |
+
*/
|
150 |
+
static public function options_array( $tab = false ) {
|
151 |
+
|
152 |
+
$options = self::include_options();
|
153 |
+
$options_arr = array();
|
154 |
+
|
155 |
+
foreach ( $options as $tab_name => $tab_options ) {
|
156 |
+
|
157 |
+
if ( $tab && $tab !== $tab_name ) {
|
158 |
+
continue;
|
159 |
+
}
|
160 |
+
|
161 |
+
$options_arr[$tab_name] = $tab_options;
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
/**
|
166 |
+
* Filter admin page options for current page
|
167 |
+
* @since 2.23
|
168 |
+
* @param array $options_arr Array of options
|
169 |
+
* @param bool|string $tab Current settings page tab
|
170 |
+
*/
|
171 |
+
$options_arr = apply_filters( 'aws_admin_page_options_current', $options_arr, $tab );
|
172 |
+
|
173 |
+
return $options_arr;
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
/*
|
178 |
+
* Include options array
|
179 |
+
* @return array
|
180 |
+
*/
|
181 |
+
static public function include_options() {
|
182 |
+
|
183 |
+
$options = array();
|
184 |
+
|
185 |
+
$options['general'][] = array(
|
186 |
+
"name" => __( "Main Settings", "advanced-woo-search" ),
|
187 |
+
"type" => "heading"
|
188 |
+
);
|
189 |
+
|
190 |
+
$options['general'][] = array(
|
191 |
+
"name" => __( "Seamless integration", "advanced-woo-search" ),
|
192 |
+
"desc" => __( "Replace all the standard search forms on your website ( may not work with some themes ).", "advanced-woo-search" ),
|
193 |
+
"id" => "seamless",
|
194 |
+
"value" => 'false',
|
195 |
+
"type" => "radio",
|
196 |
+
'choices' => array(
|
197 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
198 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
199 |
+
)
|
200 |
+
);
|
201 |
+
|
202 |
+
$options['general'][] = array(
|
203 |
+
"name" => __( "Cache results", "advanced-woo-search" ),
|
204 |
+
"desc" => __( "Turn off if you have old data in the search results after content of products was changed.<br><strong>CAUTION:</strong> can dramatically increase search speed", "advanced-woo-search" ),
|
205 |
+
"id" => "cache",
|
206 |
+
"value" => 'true',
|
207 |
+
"type" => "radio",
|
208 |
+
'choices' => array(
|
209 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
210 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
211 |
+
)
|
212 |
+
);
|
213 |
+
|
214 |
+
$options['general'][] = array(
|
215 |
+
"name" => __( "Sync index table", "advanced-woo-search" ),
|
216 |
+
"desc" => __( "Automatically update plugin index table when product content was changed. This means that in search there will be always latest product data.", "advanced-woo-search" ) . '<br>' .
|
217 |
+
__( "Turn this off if you have any problems with performance.", "advanced-woo-search" ),
|
218 |
+
"id" => "autoupdates",
|
219 |
+
"value" => 'true',
|
220 |
+
"type" => "radio",
|
221 |
+
'choices' => array(
|
222 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
223 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
224 |
+
)
|
225 |
+
);
|
226 |
+
|
227 |
+
$options['general'][] = array(
|
228 |
+
"name" => __( "Search in", "advanced-woo-search" ),
|
229 |
+
"desc" => __( "Click on status icon to enable or disable search source.", "advanced-woo-search" ),
|
230 |
+
"table_head" => __( 'Search Source', 'advanced-woo-search' ),
|
231 |
+
"id" => "search_in",
|
232 |
+
"value" => array(
|
233 |
+
'title' => 1,
|
234 |
+
'content' => 1,
|
235 |
+
'sku' => 1,
|
236 |
+
'excerpt' => 1,
|
237 |
+
'category' => 0,
|
238 |
+
'tag' => 0,
|
239 |
+
'id' => 0,
|
240 |
+
),
|
241 |
+
"choices" => array(
|
242 |
+
"title" => __( "Title", "advanced-woo-search" ),
|
243 |
+
"content" => __( "Content", "advanced-woo-search" ),
|
244 |
+
"sku" => __( "SKU", "advanced-woo-search" ),
|
245 |
+
"excerpt" => __( "Short description", "advanced-woo-search" ),
|
246 |
+
"category" => __( "Category", "advanced-woo-search" ),
|
247 |
+
"tag" => __( "Tag", "advanced-woo-search" ),
|
248 |
+
"id" => __( "ID", "advanced-woo-search" ),
|
249 |
+
),
|
250 |
+
"type" => "table"
|
251 |
+
);
|
252 |
+
|
253 |
+
$options['general'][] = array(
|
254 |
+
"name" => __( "Archive pages", "advanced-woo-search" ),
|
255 |
+
"desc" => __( "Search for taxonomies and displayed their archive pages in search results.", "advanced-woo-search" ),
|
256 |
+
'table_head' => __( 'Archive Pages', 'advanced-woo-search' ),
|
257 |
+
"id" => "search_archives",
|
258 |
+
"value" => array(
|
259 |
+
'archive_category' => 0,
|
260 |
+
'archive_tag' => 0,
|
261 |
+
),
|
262 |
+
"choices" => array(
|
263 |
+
"archive_category" => __( "Category", "advanced-woo-search" ),
|
264 |
+
"archive_tag" => __( "Tag", "advanced-woo-search" ),
|
265 |
+
),
|
266 |
+
"type" => "table"
|
267 |
+
);
|
268 |
+
|
269 |
+
$options['general'][] = array(
|
270 |
+
"name" => __( "Stop words list", "advanced-woo-search" ),
|
271 |
+
"desc" => __( "Comma separated list of words that will be excluded from search.", "advanced-woo-search" ) . '<br>' . __( "Re-index required on change.", "advanced-woo-search" ),
|
272 |
+
"id" => "stopwords",
|
273 |
+
"value" => "a, also, am, an, and, are, as, at, be, but, by, call, can, co, con, de, do, due, eg, eight, etc, even, ever, every, for, from, full, go, had, has, hasnt, have, he, hence, her, here, his, how, ie, if, in, inc, into, is, it, its, ltd, me, my, no, none, nor, not, now, of, off, on, once, one, only, onto, or, our, ours, out, over, own, part, per, put, re, see, so, some, ten, than, that, the, their, there, these, they, this, three, thru, thus, to, too, top, un, up, us, very, via, was, we, well, were, what, when, where, who, why, will",
|
274 |
+
"cols" => "85",
|
275 |
+
"rows" => "3",
|
276 |
+
"type" => "textarea"
|
277 |
+
);
|
278 |
+
|
279 |
+
$options['general'][] = array(
|
280 |
+
"name" => __( "Synonyms", "advanced-woo-search" ),
|
281 |
+
"desc" => __( "Comma separated list of synonym words. Each group of synonyms must be on separated text line.", "advanced-woo-search" ) . '<br>' . __( "Re-index required on change.", "advanced-woo-search" ),
|
282 |
+
"id" => "synonyms",
|
283 |
+
"value" => "buy, pay, purchase, acquire box, housing, unit, package",
|
284 |
+
"cols" => "85",
|
285 |
+
"rows" => "3",
|
286 |
+
"type" => "textarea"
|
287 |
+
);
|
288 |
+
|
289 |
+
$options['general'][] = array(
|
290 |
+
"name" => __( "Use Google Analytics", "advanced-woo-search" ),
|
291 |
+
"desc" => __( "Use google analytics to track searches. You need google analytics to be installed on your site.", "advanced-woo-search" ) .
|
292 |
+
'<br>' . sprintf( __( "Data will be visible inside Google Analytics 'Site Search' report. Need to activate 'Site Search' feature inside GA. %s", "advanced-woo-search" ), '<a href="https://advanced-woo-search.com/guide/google-analytics/" target="_blank">' . __( 'More info', 'advanced-woo-search' ) . '</a>' ) .
|
293 |
+
'<br>' . __( "Also will send event with category - 'AWS search', action - 'AWS Search Term' and label of value of search term.", "advanced-woo-search" ),
|
294 |
+
"id" => "use_analytics",
|
295 |
+
"value" => 'false',
|
296 |
+
"type" => "radio",
|
297 |
+
'choices' => array(
|
298 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
299 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
300 |
+
)
|
301 |
+
);
|
302 |
+
|
303 |
+
$options['performance'][] = array(
|
304 |
+
"name" => __( "Search options", "advanced-woo-search" ),
|
305 |
+
"type" => "heading"
|
306 |
+
);
|
307 |
+
|
308 |
+
$options['performance'][] = array(
|
309 |
+
"name" => __( "Search rule", "advanced-woo-search" ),
|
310 |
+
"desc" => __( "Search rule that will be used for terms search.", "advanced-woo-search" ),
|
311 |
+
"id" => "search_rule",
|
312 |
+
"value" => 'contains',
|
313 |
+
"type" => "radio",
|
314 |
+
'choices' => array(
|
315 |
+
'contains' => '%s% ' . __( "( contains ). Search query can be inside any part of the product words ( beginning, end, middle ). Slow.", "advanced-woo-search" ),
|
316 |
+
'begins' => 's% ' . __( "( begins ). Search query can be only at the beginning of the product words. Fast.", "advanced-woo-search" ),
|
317 |
+
)
|
318 |
+
);
|
319 |
+
|
320 |
+
$options['performance'][] = array(
|
321 |
+
"name" => __( "AJAX timeout", "advanced-woo-search" ),
|
322 |
+
"desc" => __( "Time after user input that script is waiting before sending a search event to the server, ms.", "advanced-woo-search" ),
|
323 |
+
"id" => "search_timeout",
|
324 |
+
"value" => 300,
|
325 |
+
'min' => 100,
|
326 |
+
"type" => "number"
|
327 |
+
);
|
328 |
+
|
329 |
+
$options['performance'][] = array(
|
330 |
+
"name" => __( "Index table options", "advanced-woo-search" ),
|
331 |
+
"id" => "index_sources",
|
332 |
+
"type" => "heading"
|
333 |
+
);
|
334 |
+
|
335 |
+
$options['performance'][] = array(
|
336 |
+
"name" => __( "Overview", "advanced-woo-search" ),
|
337 |
+
'heading_type' => 'text',
|
338 |
+
'desc' => __( 'To perform the search plugin use a special index table. This table contains normalized words of all your products from all available sources.', "advanced-woo-search" ) . '<br>' .
|
339 |
+
__( 'Sometimes when there are too many products in your store index table can be very large and that can reflect on search speed.', "advanced-woo-search" ) . '<br>' .
|
340 |
+
__( 'In this section you can use several options to change the table size by disabling some unused product data.', "advanced-woo-search" ) . '<br>' .
|
341 |
+
'<b>' . __( "Note:", "advanced-woo-search" ) . '</b> ' . __( "Reindex is required after options changes.", "advanced-woo-search" ),
|
342 |
+
"type" => "heading"
|
343 |
+
);
|
344 |
+
|
345 |
+
$options['performance'][] = array(
|
346 |
+
"name" => __( "Data to index", "advanced-woo-search" ),
|
347 |
+
"desc" => __( "Choose what products data to add inside the plugin index table.", "advanced-woo-search" ),
|
348 |
+
"table_head" => __( 'What to index', 'advanced-woo-search' ),
|
349 |
+
"id" => "index_sources",
|
350 |
+
"value" => array(
|
351 |
+
'title' => 1,
|
352 |
+
'content' => 1,
|
353 |
+
'sku' => 1,
|
354 |
+
'excerpt' => 1,
|
355 |
+
'category' => 1,
|
356 |
+
'tag' => 1,
|
357 |
+
'id' => 1,
|
358 |
+
),
|
359 |
+
"choices" => array(
|
360 |
+
"title" => __( "Title", "advanced-woo-search" ),
|
361 |
+
"content" => __( "Content", "advanced-woo-search" ),
|
362 |
+
"sku" => __( "SKU", "advanced-woo-search" ),
|
363 |
+
"excerpt" => __( "Short description", "advanced-woo-search" ),
|
364 |
+
"category" => __( "Category", "advanced-woo-search" ),
|
365 |
+
"tag" => __( "Tag", "advanced-woo-search" ),
|
366 |
+
"id" => __( "ID", "advanced-woo-search" ),
|
367 |
+
),
|
368 |
+
"type" => "table"
|
369 |
+
);
|
370 |
+
|
371 |
+
$options['performance'][] = array(
|
372 |
+
"name" => __( "Index variations", "advanced-woo-search" ),
|
373 |
+
"desc" => __( "Index or not content of product variations.", "advanced-woo-search" ),
|
374 |
+
"id" => "index_variations",
|
375 |
+
"value" => 'true',
|
376 |
+
"type" => "radio",
|
377 |
+
'choices' => array(
|
378 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
379 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
380 |
+
)
|
381 |
+
);
|
382 |
+
|
383 |
+
// Search Form Settings
|
384 |
+
$options['form'][] = array(
|
385 |
+
"name" => __( "Text for search field", "advanced-woo-search" ),
|
386 |
+
"desc" => __( "Text for search field placeholder.", "advanced-woo-search" ),
|
387 |
+
"id" => "search_field_text",
|
388 |
+
"value" => __( "Search", "advanced-woo-search" ),
|
389 |
+
"type" => "text"
|
390 |
+
);
|
391 |
+
|
392 |
+
$options['form'][] = array(
|
393 |
+
"name" => __( "Text for show more button", "advanced-woo-search" ),
|
394 |
+
"desc" => __( "Text for link to search results page at the bottom of search results block.", "advanced-woo-search" ),
|
395 |
+
"id" => "show_more_text",
|
396 |
+
"value" => __( "View all results", "advanced-woo-search" ),
|
397 |
+
"type" => "text"
|
398 |
+
);
|
399 |
+
|
400 |
+
$options['form'][] = array(
|
401 |
+
"name" => __( "Nothing found field", "advanced-woo-search" ),
|
402 |
+
"desc" => __( "Text when there is no search results.", "advanced-woo-search" ),
|
403 |
+
"id" => "not_found_text",
|
404 |
+
"value" => __( "Nothing found", "advanced-woo-search" ),
|
405 |
+
"type" => "textarea",
|
406 |
+
'allow_tags' => array( 'a', 'br', 'em', 'strong', 'b', 'code', 'blockquote', 'p', 'i' )
|
407 |
+
);
|
408 |
+
|
409 |
+
$options['form'][] = array(
|
410 |
+
"name" => __( "Minimum number of characters", "advanced-woo-search" ),
|
411 |
+
"desc" => __( "Minimum number of characters required to run ajax search.", "advanced-woo-search" ),
|
412 |
+
"id" => "min_chars",
|
413 |
+
"value" => 1,
|
414 |
+
"type" => "number"
|
415 |
+
);
|
416 |
+
|
417 |
+
$options['form'][] = array(
|
418 |
+
"name" => __( "Show loader", "advanced-woo-search" ),
|
419 |
+
"desc" => __( "Show loader animation while searching.", "advanced-woo-search" ),
|
420 |
+
"id" => "show_loader",
|
421 |
+
"value" => 'true',
|
422 |
+
"type" => "radio",
|
423 |
+
'choices' => array(
|
424 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
425 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
426 |
+
)
|
427 |
+
);
|
428 |
+
|
429 |
+
$options['form'][] = array(
|
430 |
+
"name" => __( "Show clear button", "advanced-woo-search" ),
|
431 |
+
"desc" => __( "Show 'Clear search string' button for desktop devices ( for mobile it is always visible ).", "advanced-woo-search" ),
|
432 |
+
"id" => "show_clear",
|
433 |
+
"value" => 'true',
|
434 |
+
"type" => "radio",
|
435 |
+
'choices' => array(
|
436 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
437 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
438 |
+
)
|
439 |
+
);
|
440 |
+
|
441 |
+
$options['form'][] = array(
|
442 |
+
"name" => __( "Show 'View All Results'", "advanced-woo-search" ),
|
443 |
+
"desc" => __( "Show link to search results page at the bottom of search results block.", "advanced-woo-search" ),
|
444 |
+
"id" => "show_more",
|
445 |
+
"value" => 'true',
|
446 |
+
"type" => "radio",
|
447 |
+
'choices' => array(
|
448 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
449 |
+
'false' => __( 'Off', 'advanced-woo-search' )
|
450 |
+
)
|
451 |
+
);
|
452 |
+
|
453 |
+
$options['form'][] = array(
|
454 |
+
"name" => __( "Mobile full screen", "advanced-woo-search" ),
|
455 |
+
"desc" => __( "Full screen search on focus. Will not work if the search form is inside the block with position: fixed.", "advanced-woo-search" ),
|
456 |
+
"id" => "mobile_overlay",
|
457 |
+
"value" => 'false',
|
458 |
+
"type" => "radio",
|
459 |
+
'choices' => array(
|
460 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
461 |
+
'false' => __( 'Off', 'advanced-woo-search' )
|
462 |
+
)
|
463 |
+
);
|
464 |
+
|
465 |
+
$options['form'][] = array(
|
466 |
+
"name" => __( "Search Results", "advanced-woo-search" ),
|
467 |
+
"desc" => __( "Choose how to view search results.", "advanced-woo-search" ),
|
468 |
+
"id" => "show_page",
|
469 |
+
"value" => 'true',
|
470 |
+
"type" => "radio",
|
471 |
+
'choices' => array(
|
472 |
+
'true' => __( 'Both ajax search results and search results page', 'advanced-woo-search' ),
|
473 |
+
'false' => __( 'Only ajax search results ( no search results page )', 'advanced-woo-search' ),
|
474 |
+
'ajax_off' => __( 'Only search results page ( no ajax search results )', 'advanced-woo-search' )
|
475 |
+
)
|
476 |
+
);
|
477 |
+
|
478 |
+
$options['form'][] = array(
|
479 |
+
"name" => __( "Form Styling", "advanced-woo-search" ),
|
480 |
+
"desc" => __( "Choose search form layout", "advanced-woo-search" ) . '<br>' . __( "Filter button will be visible only if you have more than one active filter for current search form instance.", "advanced-woo-search" ),
|
481 |
+
"id" => "buttons_order",
|
482 |
+
"value" => '1',
|
483 |
+
"type" => "radio-image",
|
484 |
+
'choices' => array(
|
485 |
+
'1' => 'btn-layout1.png',
|
486 |
+
'2' => 'btn-layout2.png',
|
487 |
+
'3' => 'btn-layout3.png',
|
488 |
+
)
|
489 |
+
);
|
490 |
+
|
491 |
+
// Search Results Settings
|
492 |
+
$options['results'][] = array(
|
493 |
+
"name" => __( "Description source", "advanced-woo-search" ),
|
494 |
+
"desc" => __( "From where to take product description.<br>If first source is empty data will be taken from other sources.", "advanced-woo-search" ),
|
495 |
+
"id" => "desc_source",
|
496 |
+
"value" => 'content',
|
497 |
+
"type" => "radio",
|
498 |
+
'choices' => array(
|
499 |
+
'content' => __( 'Content', 'advanced-woo-search' ),
|
500 |
+
'excerpt' => __( 'Short description', 'advanced-woo-search' ),
|
501 |
+
)
|
502 |
+
);
|
503 |
+
|
504 |
+
$options['results'][] = array(
|
505 |
+
"name" => __( "Description content", "advanced-woo-search" ),
|
506 |
+
"desc" => __( "What to show in product description?", "advanced-woo-search" ),
|
507 |
+
"id" => "mark_words",
|
508 |
+
"value" => 'true',
|
509 |
+
"type" => "radio",
|
510 |
+
'choices' => array(
|
511 |
+
'true' => __( "Smart scrapping sentences with searching terms from product description.", "advanced-woo-search" ),
|
512 |
+
'false' => __( "First N words of product description ( number of words that you choose below. )", "advanced-woo-search" ),
|
513 |
+
)
|
514 |
+
);
|
515 |
+
|
516 |
+
$options['results'][] = array(
|
517 |
+
"name" => __( "Description length", "advanced-woo-search" ),
|
518 |
+
"desc" => __( "Maximal allowed number of words for product description.", "advanced-woo-search" ),
|
519 |
+
"id" => "excerpt_length",
|
520 |
+
"value" => 20,
|
521 |
+
"type" => "number"
|
522 |
+
);
|
523 |
+
|
524 |
+
$options['results'][] = array(
|
525 |
+
"name" => __( "Max number of results", "advanced-woo-search" ),
|
526 |
+
"desc" => __( "Maximum number of displayed search results.", "advanced-woo-search" ),
|
527 |
+
"id" => "results_num",
|
528 |
+
"value" => 10,
|
529 |
+
"type" => "number"
|
530 |
+
);
|
531 |
+
|
532 |
+
$options['results'][] = array(
|
533 |
+
"name" => __( "Show out-of-stock", "advanced-woo-search" ),
|
534 |
+
"desc" => __( "Show out-of-stock products in search", "advanced-woo-search" ),
|
535 |
+
"id" => "outofstock",
|
536 |
+
"value" => 'true',
|
537 |
+
"type" => "radio",
|
538 |
+
'choices' => array(
|
539 |
+
'true' => __( 'Show', 'advanced-woo-search' ),
|
540 |
+
'false' => __( 'Hide', 'advanced-woo-search' ),
|
541 |
+
)
|
542 |
+
);
|
543 |
+
|
544 |
+
$options['results'][] = array(
|
545 |
+
"name" => __( "View", "advanced-woo-search" ),
|
546 |
+
"type" => "heading"
|
547 |
+
);
|
548 |
+
|
549 |
+
$options['results'][] = array(
|
550 |
+
"name" => __( "Highlight words", "advanced-woo-search" ),
|
551 |
+
"desc" => __( "Highlight search words inside products content.", "advanced-woo-search" ),
|
552 |
+
"id" => "highlight",
|
553 |
+
"value" => 'true',
|
554 |
+
"type" => "radio",
|
555 |
+
'choices' => array(
|
556 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
557 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
558 |
+
)
|
559 |
+
);
|
560 |
+
|
561 |
+
$options['results'][] = array(
|
562 |
+
"name" => __( "Show image", "advanced-woo-search" ),
|
563 |
+
"desc" => __( "Show product image for each search result.", "advanced-woo-search" ),
|
564 |
+
"id" => "show_image",
|
565 |
+
"value" => 'true',
|
566 |
+
"type" => "radio",
|
567 |
+
'choices' => array(
|
568 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
569 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
570 |
+
)
|
571 |
+
);
|
572 |
+
|
573 |
+
$options['results'][] = array(
|
574 |
+
"name" => __( "Show description", "advanced-woo-search" ),
|
575 |
+
"desc" => __( "Show product description for each search result.", "advanced-woo-search" ),
|
576 |
+
"id" => "show_excerpt",
|
577 |
+
"value" => 'true',
|
578 |
+
"type" => "radio",
|
579 |
+
'choices' => array(
|
580 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
581 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
582 |
+
)
|
583 |
+
);
|
584 |
+
|
585 |
+
$options['results'][] = array(
|
586 |
+
"name" => __( "Show price", "advanced-woo-search" ),
|
587 |
+
"desc" => __( "Show product price for each search result.", "advanced-woo-search" ),
|
588 |
+
"id" => "show_price",
|
589 |
+
"value" => 'true',
|
590 |
+
"type" => "radio",
|
591 |
+
'choices' => array(
|
592 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
593 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
594 |
+
)
|
595 |
+
);
|
596 |
+
|
597 |
+
$options['results'][] = array(
|
598 |
+
"name" => __( "Show price for out of stock", "advanced-woo-search" ),
|
599 |
+
"desc" => __( "Show product price for out of stock products.", "advanced-woo-search" ),
|
600 |
+
"id" => "show_outofstock_price",
|
601 |
+
"value" => 'true',
|
602 |
+
"type" => "radio",
|
603 |
+
'choices' => array(
|
604 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
605 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
606 |
+
)
|
607 |
+
);
|
608 |
+
|
609 |
+
$options['results'][] = array(
|
610 |
+
"name" => __( "Show sale badge", "advanced-woo-search" ),
|
611 |
+
"desc" => __( "Show sale badge for products in search results.", "advanced-woo-search" ),
|
612 |
+
"id" => "show_sale",
|
613 |
+
"value" => 'true',
|
614 |
+
"type" => "radio",
|
615 |
+
'choices' => array(
|
616 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
617 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
618 |
+
)
|
619 |
+
);
|
620 |
+
|
621 |
+
$options['results'][] = array(
|
622 |
+
"name" => __( "Show product SKU", "advanced-woo-search" ),
|
623 |
+
"desc" => __( "Show product SKU in search results.", "advanced-woo-search" ),
|
624 |
+
"id" => "show_sku",
|
625 |
+
"value" => 'false',
|
626 |
+
"type" => "radio",
|
627 |
+
'choices' => array(
|
628 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
629 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
630 |
+
)
|
631 |
+
);
|
632 |
+
|
633 |
+
$options['results'][] = array(
|
634 |
+
"name" => __( "Show stock status", "advanced-woo-search" ),
|
635 |
+
"desc" => __( "Show stock status for every product in search results.", "advanced-woo-search" ),
|
636 |
+
"id" => "show_stock",
|
637 |
+
"value" => 'false',
|
638 |
+
"type" => "radio",
|
639 |
+
'choices' => array(
|
640 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
641 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
642 |
+
)
|
643 |
+
);
|
644 |
+
|
645 |
+
$options['results'][] = array(
|
646 |
+
"name" => __( "Show featured icon", "advanced-woo-search" ),
|
647 |
+
"desc" => __( "Show or not star icon for featured products.", "advanced-woo-search" ),
|
648 |
+
"id" => "show_featured",
|
649 |
+
"value" => 'false',
|
650 |
+
"type" => "radio",
|
651 |
+
'choices' => array(
|
652 |
+
'true' => __( 'On', 'advanced-woo-search' ),
|
653 |
+
'false' => __( 'Off', 'advanced-woo-search' ),
|
654 |
+
)
|
655 |
+
);
|
656 |
+
|
657 |
+
/**
|
658 |
+
* Filter admin page options
|
659 |
+
* @since 2.15
|
660 |
+
* @param array $options Array of options
|
661 |
+
*/
|
662 |
+
$options = apply_filters( 'aws_admin_page_options', $options );
|
663 |
+
|
664 |
+
return $options;
|
665 |
+
|
666 |
+
}
|
667 |
+
|
668 |
+
}
|
669 |
+
|
670 |
endif;
|
includes/admin/class-aws-admin-page-premium.php
CHANGED
@@ -1,310 +1,310 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Admin_Page_Premium' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for plugin admin ajax hooks
|
11 |
-
*/
|
12 |
-
class AWS_Admin_Page_Premium {
|
13 |
-
|
14 |
-
/*
|
15 |
-
* Constructor
|
16 |
-
*/
|
17 |
-
public function __construct() {
|
18 |
-
|
19 |
-
$this->generate_content();
|
20 |
-
|
21 |
-
}
|
22 |
-
|
23 |
-
/*
|
24 |
-
* Generate options fields
|
25 |
-
*/
|
26 |
-
private function generate_content() {
|
27 |
-
|
28 |
-
echo '<div class="links">';
|
29 |
-
echo '<span class="links-title">' . __( 'Website Links:', 'advanced-woo-search' ) . '</span>';
|
30 |
-
echo '<ul>';
|
31 |
-
echo '<li><a target="_blank" href="https://advanced-woo-search.com/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin">' . __( 'Plugin home page', 'advanced-woo-search' ) . '</a></li>';
|
32 |
-
echo '<li><a target="_blank" href="https://advanced-woo-search.com/features/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin">' . __( 'Features', 'advanced-woo-search' ) . '</a></li>';
|
33 |
-
echo '<li><a target="_blank" href="https://advanced-woo-search.com/guide/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin">' . __( 'Documentation', 'advanced-woo-search' ) . '</a></li>';
|
34 |
-
echo '<li><a target="_blank" href="https://advanced-woo-search.com/pricing/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin">' . __( 'Pricing', 'advanced-woo-search' ) . '</a></li>';
|
35 |
-
echo '</ul>';
|
36 |
-
echo '</div>';
|
37 |
-
|
38 |
-
echo '<div class="buy-premium">';
|
39 |
-
echo '<a target="_blank" href="https://advanced-woo-search.com/pricing/?utm_source=plugin&utm_medium=settings-tab&utm_campaign=aws-pro-plugin">';
|
40 |
-
echo '<span class="desc">' . __( 'Upgrade to the', 'advanced-woo-search' ) . '<b> ' . __( 'Premium plugin version', 'advanced-woo-search' ) . '</b><br>' . __( 'to have all available features!', 'advanced-woo-search' ) . '</span>';
|
41 |
-
echo '<ul>';
|
42 |
-
echo '<li>' . __( '30-day money back guarantee', 'advanced-woo-search' ) . '</li>';
|
43 |
-
echo '<li>' . __( 'Priority support', 'advanced-woo-search' ) . '</li>';
|
44 |
-
echo '<li>' . __( '1 year of support and updates', 'advanced-woo-search' ) . '</li>';
|
45 |
-
echo '</ul>';
|
46 |
-
echo '</a>';
|
47 |
-
echo '</div>';
|
48 |
-
|
49 |
-
echo '<div class="features">';
|
50 |
-
|
51 |
-
echo '<h3>' . __( 'Premium Features', 'advanced-woo-search' ) . '</h3>';
|
52 |
-
|
53 |
-
echo '<div class="features-item">';
|
54 |
-
echo '<div class="column">';
|
55 |
-
echo '<h4 class="title">';
|
56 |
-
echo __( 'New Search Sources', 'advanced-woo-search' );
|
57 |
-
echo '</h4>';
|
58 |
-
echo '<p class="desc">';
|
59 |
-
echo sprintf( esc_html__( 'Search additionally inside %sproduct attributes%s, %staxonomies%s and %scustom fields%s. Inside the plugin settings page it is possible to choose some specific sources that must be available for search ( for example only several product attributes ) or just search for all of them.', 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>', '<b>', '</b>' );
|
60 |
-
echo '<br><a href="https://advanced-woo-search.com/features/search-sources/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
61 |
-
echo '</p>';
|
62 |
-
echo '</div>';
|
63 |
-
echo '<div class="column">';
|
64 |
-
echo '<div class="img">';
|
65 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature1.png' . '" />';
|
66 |
-
echo '</div>';
|
67 |
-
echo '</div>';
|
68 |
-
echo '</div>';
|
69 |
-
|
70 |
-
echo '<div class="features-item">';
|
71 |
-
echo '<div class="column">';
|
72 |
-
echo '<h4 class="title">';
|
73 |
-
echo __( 'Product Variations Support', 'advanced-woo-search' );
|
74 |
-
echo '</h4>';
|
75 |
-
echo '<p class="desc">';
|
76 |
-
echo sprintf( esc_html__( "Search and show inside search results %svariable product%s, %sproduct variations%s or %sboth%s. With the variable products will be displayed all attributes that belong to that specific variation.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>', '<b>', '</b>' );
|
77 |
-
echo '<br><a href="https://advanced-woo-search.com/features/variable-products-search/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
78 |
-
echo '</p>';
|
79 |
-
echo '</div>';
|
80 |
-
echo '<div class="column">';
|
81 |
-
echo '<div class="img">';
|
82 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature2.png' . '" />';
|
83 |
-
echo '</div>';
|
84 |
-
echo '</div>';
|
85 |
-
echo '</div>';
|
86 |
-
|
87 |
-
echo '<div class="features-item">';
|
88 |
-
echo '<div class="column">';
|
89 |
-
echo '<h4 class="title">';
|
90 |
-
echo __( 'Archive Pages Search', 'advanced-woo-search' );
|
91 |
-
echo '</h4>';
|
92 |
-
echo '<p class="desc">';
|
93 |
-
echo sprintf( esc_html__( "Search for WooCommerce product %scustom taxonomies%s and %sattributes archive pages%s. Display them right inside search results list along with the product search results.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>' );
|
94 |
-
echo '<br><a href="https://advanced-woo-search.com/features/terms-pages-search/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
95 |
-
echo '</p>';
|
96 |
-
echo '</div>';
|
97 |
-
echo '<div class="column">';
|
98 |
-
echo '<div class="img">';
|
99 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature3.png' . '" />';
|
100 |
-
echo '</div>';
|
101 |
-
echo '</div>';
|
102 |
-
echo '</div>';
|
103 |
-
|
104 |
-
echo '<div class="features-item">';
|
105 |
-
echo '<div class="column">';
|
106 |
-
echo '<h4 class="title">';
|
107 |
-
echo __( 'Users Search', 'advanced-woo-search' );
|
108 |
-
echo '</h4>';
|
109 |
-
echo '<p class="desc">';
|
110 |
-
echo esc_html__( "Search for website users and display them right inside the search results box. Choose what role the user must have to be available for search.", 'advanced-woo-search' );
|
111 |
-
echo '<br><a href="https://advanced-woo-search.com/features/users-search/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
112 |
-
echo '</p>';
|
113 |
-
echo '</div>';
|
114 |
-
echo '<div class="column">';
|
115 |
-
echo '<div class="img">';
|
116 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature4.png' . '" />';
|
117 |
-
echo '</div>';
|
118 |
-
echo '</div>';
|
119 |
-
echo '</div>';
|
120 |
-
|
121 |
-
echo '<div class="features-item">';
|
122 |
-
echo '<div class="column">';
|
123 |
-
echo '<h4 class="title">';
|
124 |
-
echo __( 'Search Form Filters', 'advanced-woo-search' );
|
125 |
-
echo '</h4>';
|
126 |
-
echo '<p class="desc">';
|
127 |
-
echo sprintf( esc_html__( "For each search form you can create a unique set of tabs. These tabs have their own %sset of settings%s and work as %sfilters%s for your search results.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>' );
|
128 |
-
echo '<br><a href="https://advanced-woo-search.com/features/filters-button/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
129 |
-
echo '</p>';
|
130 |
-
echo '</div>';
|
131 |
-
echo '<div class="column">';
|
132 |
-
echo '<div class="img">';
|
133 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature5.png' . '" />';
|
134 |
-
echo '</div>';
|
135 |
-
echo '</div>';
|
136 |
-
echo '</div>';
|
137 |
-
|
138 |
-
echo '<div class="features-item">';
|
139 |
-
echo '<div class="column">';
|
140 |
-
echo '<h4 class="title">';
|
141 |
-
echo __( 'Search Form Instances', 'advanced-woo-search' );
|
142 |
-
echo '</h4>';
|
143 |
-
echo '<p class="desc">';
|
144 |
-
echo sprintf( esc_html__( "Unlimited amount of search form instances with totally different settings and products look. You can create totally different search forms for any of your needs. Each instance is %sindependent%s and has its own %sset of settings%s.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>' );
|
145 |
-
echo '<br><a href="https://advanced-woo-search.com/features/search-form-instances/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
146 |
-
echo '</p>';
|
147 |
-
echo '</div>';
|
148 |
-
echo '<div class="column">';
|
149 |
-
echo '<div class="img">';
|
150 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature6.png' . '" />';
|
151 |
-
echo '</div>';
|
152 |
-
echo '</div>';
|
153 |
-
echo '</div>';
|
154 |
-
|
155 |
-
echo '<div class="features-item">';
|
156 |
-
echo '<div class="column">';
|
157 |
-
echo '<h4 class="title">';
|
158 |
-
echo __( 'Search Logic Change', 'advanced-woo-search' );
|
159 |
-
echo '</h4>';
|
160 |
-
echo '<p class="desc">';
|
161 |
-
echo sprintf( esc_html__( "Switch from %sOR%s to %sAND%s search logic. Choose from %spartial%s or %sexact match%s search.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>', '<b>', '</b>', '<b>', '</b>' );
|
162 |
-
echo '<br><a href="https://advanced-woo-search.com/features/search-operators-and-rules/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
163 |
-
echo '</p>';
|
164 |
-
echo '</div>';
|
165 |
-
echo '<div class="column">';
|
166 |
-
echo '<div class="img">';
|
167 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature7.png' . '" />';
|
168 |
-
echo '</div>';
|
169 |
-
echo '</div>';
|
170 |
-
echo '</div>';
|
171 |
-
|
172 |
-
echo '<div class="features-item">';
|
173 |
-
echo '<div class="column">';
|
174 |
-
echo '<h4 class="title">';
|
175 |
-
echo __( 'Add to Cart Button', 'advanced-woo-search' );
|
176 |
-
echo '</h4>';
|
177 |
-
echo '<p class="desc">';
|
178 |
-
echo sprintf( esc_html__( "Display %sAdd to Cart%s button right inside the search results. This makes it possible to add the product to the cart without visiting the product page. This button works perfect also and with product variations.", 'advanced-woo-search' ), '<b>', '</b>' );
|
179 |
-
echo '<br><a href="https://advanced-woo-search.com/features/add-to-cart-button/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
180 |
-
echo '</p>';
|
181 |
-
echo '</div>';
|
182 |
-
echo '<div class="column">';
|
183 |
-
echo '<div class="img">';
|
184 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature8.png' . '" />';
|
185 |
-
echo '</div>';
|
186 |
-
echo '</div>';
|
187 |
-
echo '</div>';
|
188 |
-
|
189 |
-
echo '<div class="features-item">';
|
190 |
-
echo '<div class="column">';
|
191 |
-
echo '<h4 class="title">';
|
192 |
-
echo __( 'Search Results Layouts', 'advanced-woo-search' );
|
193 |
-
echo '</h4>';
|
194 |
-
echo '<p class="desc">';
|
195 |
-
echo sprintf( esc_html__( "Choose between several %spredefined search results layouts%s. For example you can display all products in search results in a grid or in column one by one.", 'advanced-woo-search' ), '<b>', '</b>' );
|
196 |
-
echo '<br><a href="https://advanced-woo-search.com/features/search-results-layouts/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
197 |
-
echo '</p>';
|
198 |
-
echo '</div>';
|
199 |
-
echo '<div class="column">';
|
200 |
-
echo '<div class="img">';
|
201 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature9.png' . '" />';
|
202 |
-
echo '</div>';
|
203 |
-
echo '</div>';
|
204 |
-
echo '</div>';
|
205 |
-
|
206 |
-
echo '<div class="features-item">';
|
207 |
-
echo '<div class="column">';
|
208 |
-
echo '<h4 class="title">';
|
209 |
-
echo __( 'Exclude/Include Products Filters', 'advanced-woo-search' );
|
210 |
-
echo '</h4>';
|
211 |
-
echo '<p class="desc">';
|
212 |
-
echo sprintf( esc_html__( "Option to exclude or include products from search results by %sproduct ids%s, %staxonomies%s or %sattributes%s. Show only those products that you want. This option works great with the search form filters.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>', '<b>', '</b>' );
|
213 |
-
echo '<br><a href="https://advanced-woo-search.com/features/exclude-include-products/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
214 |
-
echo '</p>';
|
215 |
-
echo '</div>';
|
216 |
-
echo '<div class="column">';
|
217 |
-
echo '<div class="img">';
|
218 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature10.png' . '" />';
|
219 |
-
echo '</div>';
|
220 |
-
echo '</div>';
|
221 |
-
echo '</div>';
|
222 |
-
|
223 |
-
echo '<div class="features-item">';
|
224 |
-
echo '<div class="column">';
|
225 |
-
echo '<h4 class="title">';
|
226 |
-
echo __( 'ACF Plugin Support', 'advanced-woo-search' );
|
227 |
-
echo '</h4>';
|
228 |
-
echo '<p class="desc">';
|
229 |
-
echo sprintf( esc_html__( "All fields that were created with the help of %sAdvanced Custom Fields%s plugin are available for search. Also use a special build-in filters to display any ACF field value right inside the search results list.", 'advanced-woo-search' ), '<b>', '</b>' );
|
230 |
-
echo '<br><a href="https://advanced-woo-search.com/guide/acf-support/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
231 |
-
echo '</p>';
|
232 |
-
echo '</div>';
|
233 |
-
echo '<div class="column">';
|
234 |
-
echo '<div class="img">';
|
235 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature11.png' . '" />';
|
236 |
-
echo '</div>';
|
237 |
-
echo '</div>';
|
238 |
-
echo '</div>';
|
239 |
-
|
240 |
-
echo '<div class="features-item">';
|
241 |
-
echo '<div class="column">';
|
242 |
-
echo '<h4 class="title">';
|
243 |
-
echo __( 'Priority Support', 'advanced-woo-search' );
|
244 |
-
echo '</h4>';
|
245 |
-
echo '<p class="desc">';
|
246 |
-
echo esc_html__( "You will benefit from our full support for any issues you have with this plugin.", 'advanced-woo-search' );
|
247 |
-
echo '</p>';
|
248 |
-
echo '</div>';
|
249 |
-
echo '<div class="column">';
|
250 |
-
echo '<div class="img">';
|
251 |
-
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature12.png' . '" />';
|
252 |
-
echo '</div>';
|
253 |
-
echo '</div>';
|
254 |
-
echo '</div>';
|
255 |
-
|
256 |
-
echo '</div>';
|
257 |
-
|
258 |
-
echo '<div class="faq">';
|
259 |
-
|
260 |
-
echo '<h3>' . __( 'Frequently Asked Questions', 'advanced-woo-search' ) . '</h3>';
|
261 |
-
|
262 |
-
echo '<div class="faq-item">';
|
263 |
-
echo '<h4 class="question">';
|
264 |
-
echo __( 'Do you offer refunds?', 'advanced-woo-search' );
|
265 |
-
echo '</h4>';
|
266 |
-
echo '<div class="answer">';
|
267 |
-
echo __( 'If you\'re not completely happy with your purchase and we\'re unable to resolve the issue, let us know and we\'ll refund the full purchase price. Refunds can be processed within 30 days of the original purchase.', 'advanced-woo-search' );
|
268 |
-
echo '</div>';
|
269 |
-
echo '</div>';
|
270 |
-
|
271 |
-
echo '<div class="faq-item">';
|
272 |
-
echo '<h4 class="question">';
|
273 |
-
echo __( 'What payment methods do you accept?', 'advanced-woo-search' );
|
274 |
-
echo '</h4>';
|
275 |
-
echo '<div class="answer">';
|
276 |
-
echo __( 'Checkout is powered FastSpring company. They supports major credit and debit cards, PayPal, and a variety of other mainstream payment methods, so there’s plenty to pick from.', 'advanced-woo-search' );
|
277 |
-
echo '</div>';
|
278 |
-
echo '</div>';
|
279 |
-
|
280 |
-
echo '<div class="faq-item">';
|
281 |
-
echo '<h4 class="question">';
|
282 |
-
echo __( 'Do you offer support if I need help?', 'advanced-woo-search' );
|
283 |
-
echo '</h4>';
|
284 |
-
echo '<div class="answer">';
|
285 |
-
echo __( 'Yes! You will benefit of our full support for any issues you have with this plugin.', 'advanced-woo-search' );
|
286 |
-
echo '</div>';
|
287 |
-
echo '</div>';
|
288 |
-
|
289 |
-
echo '<div class="faq-item">';
|
290 |
-
echo '<h4 class="question">';
|
291 |
-
echo __( 'I have other pre-sale questions, can you help?', 'advanced-woo-search' );
|
292 |
-
echo '</h4>';
|
293 |
-
echo '<div class="answer">';
|
294 |
-
echo __( 'Yes! You can ask us any question through our', 'advanced-woo-search' ) . ' <a href="https://advanced-woo-search.com/contact/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=sti-pro-plugin" target="_blank">' . __( 'contact form.', 'advanced-woo-search' ) . '</a>';
|
295 |
-
echo '</div>';
|
296 |
-
echo '</div>';
|
297 |
-
|
298 |
-
echo '</div>';
|
299 |
-
|
300 |
-
echo '<div class="buy-premium">';
|
301 |
-
echo '<a target="_blank" href="https://advanced-woo-search.com/pricing/?utm_source=plugin&utm_medium=settings-tab&utm_campaign=aws-pro-plugin">';
|
302 |
-
echo '<span class="desc">' . __( 'Upgrade to the', 'advanced-woo-search' ) . '<b> ' . __( 'Premium plugin version', 'advanced-woo-search' ) . '</b><br>' . __( 'to have all available features!', 'advanced-woo-search' ) . '</span>';
|
303 |
-
echo '</a>';
|
304 |
-
echo '</div>';
|
305 |
-
|
306 |
-
}
|
307 |
-
|
308 |
-
}
|
309 |
-
|
310 |
-
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Admin_Page_Premium' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plugin admin ajax hooks
|
11 |
+
*/
|
12 |
+
class AWS_Admin_Page_Premium {
|
13 |
+
|
14 |
+
/*
|
15 |
+
* Constructor
|
16 |
+
*/
|
17 |
+
public function __construct() {
|
18 |
+
|
19 |
+
$this->generate_content();
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
/*
|
24 |
+
* Generate options fields
|
25 |
+
*/
|
26 |
+
private function generate_content() {
|
27 |
+
|
28 |
+
echo '<div class="links">';
|
29 |
+
echo '<span class="links-title">' . __( 'Website Links:', 'advanced-woo-search' ) . '</span>';
|
30 |
+
echo '<ul>';
|
31 |
+
echo '<li><a target="_blank" href="https://advanced-woo-search.com/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin">' . __( 'Plugin home page', 'advanced-woo-search' ) . '</a></li>';
|
32 |
+
echo '<li><a target="_blank" href="https://advanced-woo-search.com/features/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin">' . __( 'Features', 'advanced-woo-search' ) . '</a></li>';
|
33 |
+
echo '<li><a target="_blank" href="https://advanced-woo-search.com/guide/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin">' . __( 'Documentation', 'advanced-woo-search' ) . '</a></li>';
|
34 |
+
echo '<li><a target="_blank" href="https://advanced-woo-search.com/pricing/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin">' . __( 'Pricing', 'advanced-woo-search' ) . '</a></li>';
|
35 |
+
echo '</ul>';
|
36 |
+
echo '</div>';
|
37 |
+
|
38 |
+
echo '<div class="buy-premium">';
|
39 |
+
echo '<a target="_blank" href="https://advanced-woo-search.com/pricing/?utm_source=plugin&utm_medium=settings-tab&utm_campaign=aws-pro-plugin">';
|
40 |
+
echo '<span class="desc">' . __( 'Upgrade to the', 'advanced-woo-search' ) . '<b> ' . __( 'Premium plugin version', 'advanced-woo-search' ) . '</b><br>' . __( 'to have all available features!', 'advanced-woo-search' ) . '</span>';
|
41 |
+
echo '<ul>';
|
42 |
+
echo '<li>' . __( '30-day money back guarantee', 'advanced-woo-search' ) . '</li>';
|
43 |
+
echo '<li>' . __( 'Priority support', 'advanced-woo-search' ) . '</li>';
|
44 |
+
echo '<li>' . __( '1 year of support and updates', 'advanced-woo-search' ) . '</li>';
|
45 |
+
echo '</ul>';
|
46 |
+
echo '</a>';
|
47 |
+
echo '</div>';
|
48 |
+
|
49 |
+
echo '<div class="features">';
|
50 |
+
|
51 |
+
echo '<h3>' . __( 'Premium Features', 'advanced-woo-search' ) . '</h3>';
|
52 |
+
|
53 |
+
echo '<div class="features-item">';
|
54 |
+
echo '<div class="column">';
|
55 |
+
echo '<h4 class="title">';
|
56 |
+
echo __( 'New Search Sources', 'advanced-woo-search' );
|
57 |
+
echo '</h4>';
|
58 |
+
echo '<p class="desc">';
|
59 |
+
echo sprintf( esc_html__( 'Search additionally inside %sproduct attributes%s, %staxonomies%s and %scustom fields%s. Inside the plugin settings page it is possible to choose some specific sources that must be available for search ( for example only several product attributes ) or just search for all of them.', 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>', '<b>', '</b>' );
|
60 |
+
echo '<br><a href="https://advanced-woo-search.com/features/search-sources/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
61 |
+
echo '</p>';
|
62 |
+
echo '</div>';
|
63 |
+
echo '<div class="column">';
|
64 |
+
echo '<div class="img">';
|
65 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature1.png' . '" />';
|
66 |
+
echo '</div>';
|
67 |
+
echo '</div>';
|
68 |
+
echo '</div>';
|
69 |
+
|
70 |
+
echo '<div class="features-item">';
|
71 |
+
echo '<div class="column">';
|
72 |
+
echo '<h4 class="title">';
|
73 |
+
echo __( 'Product Variations Support', 'advanced-woo-search' );
|
74 |
+
echo '</h4>';
|
75 |
+
echo '<p class="desc">';
|
76 |
+
echo sprintf( esc_html__( "Search and show inside search results %svariable product%s, %sproduct variations%s or %sboth%s. With the variable products will be displayed all attributes that belong to that specific variation.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>', '<b>', '</b>' );
|
77 |
+
echo '<br><a href="https://advanced-woo-search.com/features/variable-products-search/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
78 |
+
echo '</p>';
|
79 |
+
echo '</div>';
|
80 |
+
echo '<div class="column">';
|
81 |
+
echo '<div class="img">';
|
82 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature2.png' . '" />';
|
83 |
+
echo '</div>';
|
84 |
+
echo '</div>';
|
85 |
+
echo '</div>';
|
86 |
+
|
87 |
+
echo '<div class="features-item">';
|
88 |
+
echo '<div class="column">';
|
89 |
+
echo '<h4 class="title">';
|
90 |
+
echo __( 'Archive Pages Search', 'advanced-woo-search' );
|
91 |
+
echo '</h4>';
|
92 |
+
echo '<p class="desc">';
|
93 |
+
echo sprintf( esc_html__( "Search for WooCommerce product %scustom taxonomies%s and %sattributes archive pages%s. Display them right inside search results list along with the product search results.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>' );
|
94 |
+
echo '<br><a href="https://advanced-woo-search.com/features/terms-pages-search/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
95 |
+
echo '</p>';
|
96 |
+
echo '</div>';
|
97 |
+
echo '<div class="column">';
|
98 |
+
echo '<div class="img">';
|
99 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature3.png' . '" />';
|
100 |
+
echo '</div>';
|
101 |
+
echo '</div>';
|
102 |
+
echo '</div>';
|
103 |
+
|
104 |
+
echo '<div class="features-item">';
|
105 |
+
echo '<div class="column">';
|
106 |
+
echo '<h4 class="title">';
|
107 |
+
echo __( 'Users Search', 'advanced-woo-search' );
|
108 |
+
echo '</h4>';
|
109 |
+
echo '<p class="desc">';
|
110 |
+
echo esc_html__( "Search for website users and display them right inside the search results box. Choose what role the user must have to be available for search.", 'advanced-woo-search' );
|
111 |
+
echo '<br><a href="https://advanced-woo-search.com/features/users-search/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
112 |
+
echo '</p>';
|
113 |
+
echo '</div>';
|
114 |
+
echo '<div class="column">';
|
115 |
+
echo '<div class="img">';
|
116 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature4.png' . '" />';
|
117 |
+
echo '</div>';
|
118 |
+
echo '</div>';
|
119 |
+
echo '</div>';
|
120 |
+
|
121 |
+
echo '<div class="features-item">';
|
122 |
+
echo '<div class="column">';
|
123 |
+
echo '<h4 class="title">';
|
124 |
+
echo __( 'Search Form Filters', 'advanced-woo-search' );
|
125 |
+
echo '</h4>';
|
126 |
+
echo '<p class="desc">';
|
127 |
+
echo sprintf( esc_html__( "For each search form you can create a unique set of tabs. These tabs have their own %sset of settings%s and work as %sfilters%s for your search results.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>' );
|
128 |
+
echo '<br><a href="https://advanced-woo-search.com/features/filters-button/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
129 |
+
echo '</p>';
|
130 |
+
echo '</div>';
|
131 |
+
echo '<div class="column">';
|
132 |
+
echo '<div class="img">';
|
133 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature5.png' . '" />';
|
134 |
+
echo '</div>';
|
135 |
+
echo '</div>';
|
136 |
+
echo '</div>';
|
137 |
+
|
138 |
+
echo '<div class="features-item">';
|
139 |
+
echo '<div class="column">';
|
140 |
+
echo '<h4 class="title">';
|
141 |
+
echo __( 'Search Form Instances', 'advanced-woo-search' );
|
142 |
+
echo '</h4>';
|
143 |
+
echo '<p class="desc">';
|
144 |
+
echo sprintf( esc_html__( "Unlimited amount of search form instances with totally different settings and products look. You can create totally different search forms for any of your needs. Each instance is %sindependent%s and has its own %sset of settings%s.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>' );
|
145 |
+
echo '<br><a href="https://advanced-woo-search.com/features/search-form-instances/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
146 |
+
echo '</p>';
|
147 |
+
echo '</div>';
|
148 |
+
echo '<div class="column">';
|
149 |
+
echo '<div class="img">';
|
150 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature6.png' . '" />';
|
151 |
+
echo '</div>';
|
152 |
+
echo '</div>';
|
153 |
+
echo '</div>';
|
154 |
+
|
155 |
+
echo '<div class="features-item">';
|
156 |
+
echo '<div class="column">';
|
157 |
+
echo '<h4 class="title">';
|
158 |
+
echo __( 'Search Logic Change', 'advanced-woo-search' );
|
159 |
+
echo '</h4>';
|
160 |
+
echo '<p class="desc">';
|
161 |
+
echo sprintf( esc_html__( "Switch from %sOR%s to %sAND%s search logic. Choose from %spartial%s or %sexact match%s search.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>', '<b>', '</b>', '<b>', '</b>' );
|
162 |
+
echo '<br><a href="https://advanced-woo-search.com/features/search-operators-and-rules/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
163 |
+
echo '</p>';
|
164 |
+
echo '</div>';
|
165 |
+
echo '<div class="column">';
|
166 |
+
echo '<div class="img">';
|
167 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature7.png' . '" />';
|
168 |
+
echo '</div>';
|
169 |
+
echo '</div>';
|
170 |
+
echo '</div>';
|
171 |
+
|
172 |
+
echo '<div class="features-item">';
|
173 |
+
echo '<div class="column">';
|
174 |
+
echo '<h4 class="title">';
|
175 |
+
echo __( 'Add to Cart Button', 'advanced-woo-search' );
|
176 |
+
echo '</h4>';
|
177 |
+
echo '<p class="desc">';
|
178 |
+
echo sprintf( esc_html__( "Display %sAdd to Cart%s button right inside the search results. This makes it possible to add the product to the cart without visiting the product page. This button works perfect also and with product variations.", 'advanced-woo-search' ), '<b>', '</b>' );
|
179 |
+
echo '<br><a href="https://advanced-woo-search.com/features/add-to-cart-button/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
180 |
+
echo '</p>';
|
181 |
+
echo '</div>';
|
182 |
+
echo '<div class="column">';
|
183 |
+
echo '<div class="img">';
|
184 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature8.png' . '" />';
|
185 |
+
echo '</div>';
|
186 |
+
echo '</div>';
|
187 |
+
echo '</div>';
|
188 |
+
|
189 |
+
echo '<div class="features-item">';
|
190 |
+
echo '<div class="column">';
|
191 |
+
echo '<h4 class="title">';
|
192 |
+
echo __( 'Search Results Layouts', 'advanced-woo-search' );
|
193 |
+
echo '</h4>';
|
194 |
+
echo '<p class="desc">';
|
195 |
+
echo sprintf( esc_html__( "Choose between several %spredefined search results layouts%s. For example you can display all products in search results in a grid or in column one by one.", 'advanced-woo-search' ), '<b>', '</b>' );
|
196 |
+
echo '<br><a href="https://advanced-woo-search.com/features/search-results-layouts/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
197 |
+
echo '</p>';
|
198 |
+
echo '</div>';
|
199 |
+
echo '<div class="column">';
|
200 |
+
echo '<div class="img">';
|
201 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature9.png' . '" />';
|
202 |
+
echo '</div>';
|
203 |
+
echo '</div>';
|
204 |
+
echo '</div>';
|
205 |
+
|
206 |
+
echo '<div class="features-item">';
|
207 |
+
echo '<div class="column">';
|
208 |
+
echo '<h4 class="title">';
|
209 |
+
echo __( 'Exclude/Include Products Filters', 'advanced-woo-search' );
|
210 |
+
echo '</h4>';
|
211 |
+
echo '<p class="desc">';
|
212 |
+
echo sprintf( esc_html__( "Option to exclude or include products from search results by %sproduct ids%s, %staxonomies%s or %sattributes%s. Show only those products that you want. This option works great with the search form filters.", 'advanced-woo-search' ), '<b>', '</b>', '<b>', '</b>', '<b>', '</b>' );
|
213 |
+
echo '<br><a href="https://advanced-woo-search.com/features/exclude-include-products/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
214 |
+
echo '</p>';
|
215 |
+
echo '</div>';
|
216 |
+
echo '<div class="column">';
|
217 |
+
echo '<div class="img">';
|
218 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature10.png' . '" />';
|
219 |
+
echo '</div>';
|
220 |
+
echo '</div>';
|
221 |
+
echo '</div>';
|
222 |
+
|
223 |
+
echo '<div class="features-item">';
|
224 |
+
echo '<div class="column">';
|
225 |
+
echo '<h4 class="title">';
|
226 |
+
echo __( 'ACF Plugin Support', 'advanced-woo-search' );
|
227 |
+
echo '</h4>';
|
228 |
+
echo '<p class="desc">';
|
229 |
+
echo sprintf( esc_html__( "All fields that were created with the help of %sAdvanced Custom Fields%s plugin are available for search. Also use a special build-in filters to display any ACF field value right inside the search results list.", 'advanced-woo-search' ), '<b>', '</b>' );
|
230 |
+
echo '<br><a href="https://advanced-woo-search.com/guide/acf-support/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=aws-pro-plugin" target="_blank">' . __( 'Learn more', 'advanced-woo-search' ) . '</a>';
|
231 |
+
echo '</p>';
|
232 |
+
echo '</div>';
|
233 |
+
echo '<div class="column">';
|
234 |
+
echo '<div class="img">';
|
235 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature11.png' . '" />';
|
236 |
+
echo '</div>';
|
237 |
+
echo '</div>';
|
238 |
+
echo '</div>';
|
239 |
+
|
240 |
+
echo '<div class="features-item">';
|
241 |
+
echo '<div class="column">';
|
242 |
+
echo '<h4 class="title">';
|
243 |
+
echo __( 'Priority Support', 'advanced-woo-search' );
|
244 |
+
echo '</h4>';
|
245 |
+
echo '<p class="desc">';
|
246 |
+
echo esc_html__( "You will benefit from our full support for any issues you have with this plugin.", 'advanced-woo-search' );
|
247 |
+
echo '</p>';
|
248 |
+
echo '</div>';
|
249 |
+
echo '<div class="column">';
|
250 |
+
echo '<div class="img">';
|
251 |
+
echo '<img alt="" src="' . AWS_URL . '/assets/img/pro/feature12.png' . '" />';
|
252 |
+
echo '</div>';
|
253 |
+
echo '</div>';
|
254 |
+
echo '</div>';
|
255 |
+
|
256 |
+
echo '</div>';
|
257 |
+
|
258 |
+
echo '<div class="faq">';
|
259 |
+
|
260 |
+
echo '<h3>' . __( 'Frequently Asked Questions', 'advanced-woo-search' ) . '</h3>';
|
261 |
+
|
262 |
+
echo '<div class="faq-item">';
|
263 |
+
echo '<h4 class="question">';
|
264 |
+
echo __( 'Do you offer refunds?', 'advanced-woo-search' );
|
265 |
+
echo '</h4>';
|
266 |
+
echo '<div class="answer">';
|
267 |
+
echo __( 'If you\'re not completely happy with your purchase and we\'re unable to resolve the issue, let us know and we\'ll refund the full purchase price. Refunds can be processed within 30 days of the original purchase.', 'advanced-woo-search' );
|
268 |
+
echo '</div>';
|
269 |
+
echo '</div>';
|
270 |
+
|
271 |
+
echo '<div class="faq-item">';
|
272 |
+
echo '<h4 class="question">';
|
273 |
+
echo __( 'What payment methods do you accept?', 'advanced-woo-search' );
|
274 |
+
echo '</h4>';
|
275 |
+
echo '<div class="answer">';
|
276 |
+
echo __( 'Checkout is powered FastSpring company. They supports major credit and debit cards, PayPal, and a variety of other mainstream payment methods, so there’s plenty to pick from.', 'advanced-woo-search' );
|
277 |
+
echo '</div>';
|
278 |
+
echo '</div>';
|
279 |
+
|
280 |
+
echo '<div class="faq-item">';
|
281 |
+
echo '<h4 class="question">';
|
282 |
+
echo __( 'Do you offer support if I need help?', 'advanced-woo-search' );
|
283 |
+
echo '</h4>';
|
284 |
+
echo '<div class="answer">';
|
285 |
+
echo __( 'Yes! You will benefit of our full support for any issues you have with this plugin.', 'advanced-woo-search' );
|
286 |
+
echo '</div>';
|
287 |
+
echo '</div>';
|
288 |
+
|
289 |
+
echo '<div class="faq-item">';
|
290 |
+
echo '<h4 class="question">';
|
291 |
+
echo __( 'I have other pre-sale questions, can you help?', 'advanced-woo-search' );
|
292 |
+
echo '</h4>';
|
293 |
+
echo '<div class="answer">';
|
294 |
+
echo __( 'Yes! You can ask us any question through our', 'advanced-woo-search' ) . ' <a href="https://advanced-woo-search.com/contact/?utm_source=plugin&utm_medium=premium-tab&utm_campaign=sti-pro-plugin" target="_blank">' . __( 'contact form.', 'advanced-woo-search' ) . '</a>';
|
295 |
+
echo '</div>';
|
296 |
+
echo '</div>';
|
297 |
+
|
298 |
+
echo '</div>';
|
299 |
+
|
300 |
+
echo '<div class="buy-premium">';
|
301 |
+
echo '<a target="_blank" href="https://advanced-woo-search.com/pricing/?utm_source=plugin&utm_medium=settings-tab&utm_campaign=aws-pro-plugin">';
|
302 |
+
echo '<span class="desc">' . __( 'Upgrade to the', 'advanced-woo-search' ) . '<b> ' . __( 'Premium plugin version', 'advanced-woo-search' ) . '</b><br>' . __( 'to have all available features!', 'advanced-woo-search' ) . '</span>';
|
303 |
+
echo '</a>';
|
304 |
+
echo '</div>';
|
305 |
+
|
306 |
+
}
|
307 |
+
|
308 |
+
}
|
309 |
+
|
310 |
+
endif;
|
includes/admin/class-aws-admin.php
CHANGED
@@ -1,273 +1,273 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'AWS_Admin' ) ) :
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class for plugin admin panel
|
12 |
-
*/
|
13 |
-
class AWS_Admin {
|
14 |
-
|
15 |
-
/*
|
16 |
-
* Name of the plugin settings page
|
17 |
-
*/
|
18 |
-
var $page_name = 'aws-options';
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @var AWS_Admin The single instance of the class
|
22 |
-
*/
|
23 |
-
protected static $_instance = null;
|
24 |
-
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Main AWS_Admin Instance
|
28 |
-
*
|
29 |
-
* Ensures only one instance of AWS_Admin is loaded or can be loaded.
|
30 |
-
*
|
31 |
-
* @static
|
32 |
-
* @return AWS_Admin - Main instance
|
33 |
-
*/
|
34 |
-
public static function instance() {
|
35 |
-
if ( is_null( self::$_instance ) ) {
|
36 |
-
self::$_instance = new self();
|
37 |
-
}
|
38 |
-
return self::$_instance;
|
39 |
-
}
|
40 |
-
|
41 |
-
/*
|
42 |
-
* Constructor
|
43 |
-
*/
|
44 |
-
public function __construct() {
|
45 |
-
|
46 |
-
add_action( 'admin_menu', array( &$this, 'add_admin_page' ) );
|
47 |
-
add_action( 'admin_init', array( &$this, 'register_settings' ) );
|
48 |
-
|
49 |
-
if ( ! AWS_Admin_Options::get_settings() ) {
|
50 |
-
$default_settings = AWS_Admin_Options::get_default_settings();
|
51 |
-
update_option( 'aws_settings', $default_settings );
|
52 |
-
}
|
53 |
-
|
54 |
-
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
55 |
-
|
56 |
-
add_action( 'admin_notices', array( $this, 'display_welcome_header' ), 1 );
|
57 |
-
|
58 |
-
add_action( 'admin_notices', array( $this, 'display_reindex_message' ), 1 );
|
59 |
-
|
60 |
-
add_filter( 'submenu_file', array( $this, 'submenu_file' ), 10, 2 );
|
61 |
-
|
62 |
-
add_filter( 'aws_admin_page_options_current', array( $this, 'check_sources_in_index' ), 1 );
|
63 |
-
|
64 |
-
add_action( 'aws_admin_change_state', array( $this, 'disable_not_indexed_sources' ), 1, 3 );
|
65 |
-
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Add options page
|
71 |
-
*/
|
72 |
-
public function add_admin_page() {
|
73 |
-
add_menu_page( esc_html__( 'Adv. Woo Search', 'advanced-woo-search' ), esc_html__( 'Adv. Woo Search', 'advanced-woo-search' ), 'manage_options', 'aws-options', array( &$this, 'display_admin_page' ), 'dashicons-search', 70 );
|
74 |
-
add_submenu_page( 'aws-options', __( 'Settings', 'advanced-woo-search' ), __( 'Settings', 'advanced-woo-search'), 'manage_options', 'aws-options', array( $this, 'display_admin_page' ) );
|
75 |
-
add_submenu_page( 'aws-options', __( 'Premium', 'advanced-woo-search' ), '<span style="color:rgba(255, 255, 91, 0.8);">' . __( 'Premium', 'advanced-woo-search' ) . '</span>', 'manage_options', admin_url( 'admin.php?page=aws-options&tab=premium' ) );
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* Generate and display options page
|
80 |
-
*/
|
81 |
-
public function display_admin_page() {
|
82 |
-
|
83 |
-
$nonce = wp_create_nonce( 'plugin-settings' );
|
84 |
-
|
85 |
-
$tabs = array(
|
86 |
-
'general' => esc_html__( 'General', 'advanced-woo-search' ),
|
87 |
-
'performance' => esc_html__( 'Performance', 'advanced-woo-search' ),
|
88 |
-
'form' => esc_html__( 'Search Form', 'advanced-woo-search' ),
|
89 |
-
'results' => esc_html__( 'Search Results', 'advanced-woo-search' ),
|
90 |
-
'premium' => esc_html__( 'Get Premium', 'advanced-woo-search' )
|
91 |
-
);
|
92 |
-
|
93 |
-
$current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_text_field( $_GET['tab'] );
|
94 |
-
|
95 |
-
$tabs_html = '';
|
96 |
-
|
97 |
-
foreach ( $tabs as $name => $label ) {
|
98 |
-
$tabs_html .= '<a href="' . admin_url( 'admin.php?page=aws-options&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
$tabs_html = '<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">'.$tabs_html.'</h2>';
|
103 |
-
|
104 |
-
if ( isset( $_POST["Submit"] ) && current_user_can( 'manage_options' ) && isset( $_POST["_wpnonce"] ) && wp_verify_nonce( $_POST["_wpnonce"], 'plugin-settings' ) ) {
|
105 |
-
AWS_Admin_Options::update_settings();
|
106 |
-
}
|
107 |
-
|
108 |
-
echo '<div class="wrap">';
|
109 |
-
|
110 |
-
echo '<h1></h1>';
|
111 |
-
|
112 |
-
echo '<h1 class="aws-instance-name">Advanced Woo Search</h1>';
|
113 |
-
|
114 |
-
echo $tabs_html;
|
115 |
-
|
116 |
-
echo '<form action="" name="aws_form" id="aws_form" method="post">';
|
117 |
-
|
118 |
-
switch ($current_tab) {
|
119 |
-
case('performance'):
|
120 |
-
new AWS_Admin_Fields( 'performance' );
|
121 |
-
break;
|
122 |
-
case('form'):
|
123 |
-
new AWS_Admin_Fields( 'form' );
|
124 |
-
break;
|
125 |
-
case('results'):
|
126 |
-
new AWS_Admin_Fields( 'results' );
|
127 |
-
break;
|
128 |
-
case('premium'):
|
129 |
-
new AWS_Admin_Page_Premium();
|
130 |
-
break;
|
131 |
-
default:
|
132 |
-
echo AWS_Admin_Meta_Boxes::get_general_tab_content();
|
133 |
-
new AWS_Admin_Fields( 'general' );
|
134 |
-
}
|
135 |
-
|
136 |
-
echo '<input type="hidden" name="_wpnonce" value="' . esc_attr( $nonce ) . '">';
|
137 |
-
|
138 |
-
echo '</form>';
|
139 |
-
|
140 |
-
echo '</div>';
|
141 |
-
|
142 |
-
}
|
143 |
-
|
144 |
-
/*
|
145 |
-
* Register plugin settings
|
146 |
-
*/
|
147 |
-
public function register_settings() {
|
148 |
-
register_setting( 'aws_settings', 'aws_settings' );
|
149 |
-
}
|
150 |
-
|
151 |
-
/*
|
152 |
-
* Get plugin settings
|
153 |
-
*/
|
154 |
-
public function get_settings() {
|
155 |
-
$plugin_options = get_option( 'aws_settings' );
|
156 |
-
return $plugin_options;
|
157 |
-
}
|
158 |
-
|
159 |
-
/*
|
160 |
-
* Enqueue admin scripts and styles
|
161 |
-
*/
|
162 |
-
public function admin_enqueue_scripts() {
|
163 |
-
|
164 |
-
if ( isset( $_GET['page'] ) && $_GET['page'] == 'aws-options' ) {
|
165 |
-
wp_enqueue_style( 'plugin-admin-style', AWS_URL . '/assets/css/admin.css', array(), AWS_VERSION );
|
166 |
-
wp_enqueue_script( 'jquery' );
|
167 |
-
wp_enqueue_script( 'jquery-ui-sortable' );
|
168 |
-
wp_enqueue_script( 'plugin-admin-scripts', AWS_URL . '/assets/js/admin.js', array('jquery'), AWS_VERSION );
|
169 |
-
wp_localize_script( 'plugin-admin-scripts', 'aws_vars', array(
|
170 |
-
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
|
171 |
-
'ajax_nonce' => wp_create_nonce( 'aws_admin_ajax_nonce' ),
|
172 |
-
) );
|
173 |
-
}
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
/*
|
178 |
-
* Change current class for premium tab
|
179 |
-
*/
|
180 |
-
public function submenu_file( $submenu_file, $parent_file ) {
|
181 |
-
if ( $parent_file === 'aws-options' && isset( $_GET['tab'] ) && $_GET['tab'] === 'premium' ) {
|
182 |
-
$submenu_file = admin_url( 'admin.php?page=aws-options&tab=premium' );
|
183 |
-
}
|
184 |
-
return $submenu_file;
|
185 |
-
}
|
186 |
-
|
187 |
-
/*
|
188 |
-
* Check if some sources for disabled from index
|
189 |
-
*/
|
190 |
-
public function check_sources_in_index( $options ) {
|
191 |
-
|
192 |
-
if ( $options ) {
|
193 |
-
|
194 |
-
$index_options = AWS_Helpers::get_index_options();
|
195 |
-
|
196 |
-
foreach( $options as $options_key => $options_tab ) {
|
197 |
-
foreach( $options_tab as $key => $option ) {
|
198 |
-
if ( isset( $option['id'] ) && $option['id'] === 'search_in' && isset( $option['choices'] ) ) {
|
199 |
-
foreach( $option['choices'] as $choice_key => $choice_label ) {
|
200 |
-
if ( isset( $index_options['index'][$choice_key] ) && ! $index_options['index'][$choice_key] ) {
|
201 |
-
$text = '<span style="color:#dc3232;">' . __( '(index disabled)', 'advanced-woo-search' ) . '</span>' . ' <a href="'.esc_url( admin_url('admin.php?page=aws-options&tab=performance#index_sources') ).'">' . __( '(enable)', 'advanced-woo-search' ) . '</a>';
|
202 |
-
$options[$options_key][$key]['choices'][$choice_key] = $choice_label . ' ' . $text;
|
203 |
-
}
|
204 |
-
}
|
205 |
-
}
|
206 |
-
}
|
207 |
-
}
|
208 |
-
|
209 |
-
}
|
210 |
-
|
211 |
-
return $options;
|
212 |
-
|
213 |
-
}
|
214 |
-
|
215 |
-
/*
|
216 |
-
* Disable sources that was excluded from index
|
217 |
-
*/
|
218 |
-
public function disable_not_indexed_sources( $setting, $option, $state ) {
|
219 |
-
|
220 |
-
if ( $setting === 'index_sources' && $state ) {
|
221 |
-
$settings = AWS_Admin_Options::get_settings();
|
222 |
-
if ( isset( $settings['search_in'][$option] ) ) {
|
223 |
-
$settings['search_in'][$option] = 0;
|
224 |
-
update_option( 'aws_settings', $settings );
|
225 |
-
}
|
226 |
-
}
|
227 |
-
|
228 |
-
}
|
229 |
-
|
230 |
-
/*
|
231 |
-
* Add welcome notice
|
232 |
-
*/
|
233 |
-
public function display_welcome_header() {
|
234 |
-
|
235 |
-
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'aws-options' ) {
|
236 |
-
return;
|
237 |
-
}
|
238 |
-
|
239 |
-
$hide_notice = get_option( 'aws_hide_welcome_notice' );
|
240 |
-
|
241 |
-
if ( ! $hide_notice || $hide_notice === 'true' ) {
|
242 |
-
return;
|
243 |
-
}
|
244 |
-
|
245 |
-
echo AWS_Admin_Meta_Boxes::get_welcome_notice();
|
246 |
-
|
247 |
-
}
|
248 |
-
|
249 |
-
/*
|
250 |
-
* Add reindex notice after index options change
|
251 |
-
*/
|
252 |
-
public function display_reindex_message() {
|
253 |
-
|
254 |
-
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'aws-options' ) {
|
255 |
-
return;
|
256 |
-
}
|
257 |
-
|
258 |
-
if ( ! isset( $_POST["Submit"] ) || ! current_user_can( 'manage_options' ) ) {
|
259 |
-
return;
|
260 |
-
}
|
261 |
-
|
262 |
-
if ( isset( $_POST["index_variations"] ) || isset( $_POST["search_rule"] ) ) {
|
263 |
-
echo AWS_Admin_Meta_Boxes::get_reindex_notice();
|
264 |
-
}
|
265 |
-
|
266 |
-
}
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
endif;
|
271 |
-
|
272 |
-
|
273 |
add_action( 'init', 'AWS_Admin::instance' );
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'AWS_Admin' ) ) :
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class for plugin admin panel
|
12 |
+
*/
|
13 |
+
class AWS_Admin {
|
14 |
+
|
15 |
+
/*
|
16 |
+
* Name of the plugin settings page
|
17 |
+
*/
|
18 |
+
var $page_name = 'aws-options';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var AWS_Admin The single instance of the class
|
22 |
+
*/
|
23 |
+
protected static $_instance = null;
|
24 |
+
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Main AWS_Admin Instance
|
28 |
+
*
|
29 |
+
* Ensures only one instance of AWS_Admin is loaded or can be loaded.
|
30 |
+
*
|
31 |
+
* @static
|
32 |
+
* @return AWS_Admin - Main instance
|
33 |
+
*/
|
34 |
+
public static function instance() {
|
35 |
+
if ( is_null( self::$_instance ) ) {
|
36 |
+
self::$_instance = new self();
|
37 |
+
}
|
38 |
+
return self::$_instance;
|
39 |
+
}
|
40 |
+
|
41 |
+
/*
|
42 |
+
* Constructor
|
43 |
+
*/
|
44 |
+
public function __construct() {
|
45 |
+
|
46 |
+
add_action( 'admin_menu', array( &$this, 'add_admin_page' ) );
|
47 |
+
add_action( 'admin_init', array( &$this, 'register_settings' ) );
|
48 |
+
|
49 |
+
if ( ! AWS_Admin_Options::get_settings() ) {
|
50 |
+
$default_settings = AWS_Admin_Options::get_default_settings();
|
51 |
+
update_option( 'aws_settings', $default_settings );
|
52 |
+
}
|
53 |
+
|
54 |
+
add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
|
55 |
+
|
56 |
+
add_action( 'admin_notices', array( $this, 'display_welcome_header' ), 1 );
|
57 |
+
|
58 |
+
add_action( 'admin_notices', array( $this, 'display_reindex_message' ), 1 );
|
59 |
+
|
60 |
+
add_filter( 'submenu_file', array( $this, 'submenu_file' ), 10, 2 );
|
61 |
+
|
62 |
+
add_filter( 'aws_admin_page_options_current', array( $this, 'check_sources_in_index' ), 1 );
|
63 |
+
|
64 |
+
add_action( 'aws_admin_change_state', array( $this, 'disable_not_indexed_sources' ), 1, 3 );
|
65 |
+
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Add options page
|
71 |
+
*/
|
72 |
+
public function add_admin_page() {
|
73 |
+
add_menu_page( esc_html__( 'Adv. Woo Search', 'advanced-woo-search' ), esc_html__( 'Adv. Woo Search', 'advanced-woo-search' ), 'manage_options', 'aws-options', array( &$this, 'display_admin_page' ), 'dashicons-search', 70 );
|
74 |
+
add_submenu_page( 'aws-options', __( 'Settings', 'advanced-woo-search' ), __( 'Settings', 'advanced-woo-search'), 'manage_options', 'aws-options', array( $this, 'display_admin_page' ) );
|
75 |
+
add_submenu_page( 'aws-options', __( 'Premium', 'advanced-woo-search' ), '<span style="color:rgba(255, 255, 91, 0.8);">' . __( 'Premium', 'advanced-woo-search' ) . '</span>', 'manage_options', admin_url( 'admin.php?page=aws-options&tab=premium' ) );
|
76 |
+
}
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Generate and display options page
|
80 |
+
*/
|
81 |
+
public function display_admin_page() {
|
82 |
+
|
83 |
+
$nonce = wp_create_nonce( 'plugin-settings' );
|
84 |
+
|
85 |
+
$tabs = array(
|
86 |
+
'general' => esc_html__( 'General', 'advanced-woo-search' ),
|
87 |
+
'performance' => esc_html__( 'Performance', 'advanced-woo-search' ),
|
88 |
+
'form' => esc_html__( 'Search Form', 'advanced-woo-search' ),
|
89 |
+
'results' => esc_html__( 'Search Results', 'advanced-woo-search' ),
|
90 |
+
'premium' => esc_html__( 'Get Premium', 'advanced-woo-search' )
|
91 |
+
);
|
92 |
+
|
93 |
+
$current_tab = empty( $_GET['tab'] ) ? 'general' : sanitize_text_field( $_GET['tab'] );
|
94 |
+
|
95 |
+
$tabs_html = '';
|
96 |
+
|
97 |
+
foreach ( $tabs as $name => $label ) {
|
98 |
+
$tabs_html .= '<a href="' . admin_url( 'admin.php?page=aws-options&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
$tabs_html = '<h2 class="nav-tab-wrapper woo-nav-tab-wrapper">'.$tabs_html.'</h2>';
|
103 |
+
|
104 |
+
if ( isset( $_POST["Submit"] ) && current_user_can( 'manage_options' ) && isset( $_POST["_wpnonce"] ) && wp_verify_nonce( $_POST["_wpnonce"], 'plugin-settings' ) ) {
|
105 |
+
AWS_Admin_Options::update_settings();
|
106 |
+
}
|
107 |
+
|
108 |
+
echo '<div class="wrap">';
|
109 |
+
|
110 |
+
echo '<h1></h1>';
|
111 |
+
|
112 |
+
echo '<h1 class="aws-instance-name">Advanced Woo Search</h1>';
|
113 |
+
|
114 |
+
echo $tabs_html;
|
115 |
+
|
116 |
+
echo '<form action="" name="aws_form" id="aws_form" method="post">';
|
117 |
+
|
118 |
+
switch ($current_tab) {
|
119 |
+
case('performance'):
|
120 |
+
new AWS_Admin_Fields( 'performance' );
|
121 |
+
break;
|
122 |
+
case('form'):
|
123 |
+
new AWS_Admin_Fields( 'form' );
|
124 |
+
break;
|
125 |
+
case('results'):
|
126 |
+
new AWS_Admin_Fields( 'results' );
|
127 |
+
break;
|
128 |
+
case('premium'):
|
129 |
+
new AWS_Admin_Page_Premium();
|
130 |
+
break;
|
131 |
+
default:
|
132 |
+
echo AWS_Admin_Meta_Boxes::get_general_tab_content();
|
133 |
+
new AWS_Admin_Fields( 'general' );
|
134 |
+
}
|
135 |
+
|
136 |
+
echo '<input type="hidden" name="_wpnonce" value="' . esc_attr( $nonce ) . '">';
|
137 |
+
|
138 |
+
echo '</form>';
|
139 |
+
|
140 |
+
echo '</div>';
|
141 |
+
|
142 |
+
}
|
143 |
+
|
144 |
+
/*
|
145 |
+
* Register plugin settings
|
146 |
+
*/
|
147 |
+
public function register_settings() {
|
148 |
+
register_setting( 'aws_settings', 'aws_settings' );
|
149 |
+
}
|
150 |
+
|
151 |
+
/*
|
152 |
+
* Get plugin settings
|
153 |
+
*/
|
154 |
+
public function get_settings() {
|
155 |
+
$plugin_options = get_option( 'aws_settings' );
|
156 |
+
return $plugin_options;
|
157 |
+
}
|
158 |
+
|
159 |
+
/*
|
160 |
+
* Enqueue admin scripts and styles
|
161 |
+
*/
|
162 |
+
public function admin_enqueue_scripts() {
|
163 |
+
|
164 |
+
if ( isset( $_GET['page'] ) && $_GET['page'] == 'aws-options' ) {
|
165 |
+
wp_enqueue_style( 'plugin-admin-style', AWS_URL . '/assets/css/admin.css', array(), AWS_VERSION );
|
166 |
+
wp_enqueue_script( 'jquery' );
|
167 |
+
wp_enqueue_script( 'jquery-ui-sortable' );
|
168 |
+
wp_enqueue_script( 'plugin-admin-scripts', AWS_URL . '/assets/js/admin.js', array('jquery'), AWS_VERSION );
|
169 |
+
wp_localize_script( 'plugin-admin-scripts', 'aws_vars', array(
|
170 |
+
'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
|
171 |
+
'ajax_nonce' => wp_create_nonce( 'aws_admin_ajax_nonce' ),
|
172 |
+
) );
|
173 |
+
}
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
/*
|
178 |
+
* Change current class for premium tab
|
179 |
+
*/
|
180 |
+
public function submenu_file( $submenu_file, $parent_file ) {
|
181 |
+
if ( $parent_file === 'aws-options' && isset( $_GET['tab'] ) && $_GET['tab'] === 'premium' ) {
|
182 |
+
$submenu_file = admin_url( 'admin.php?page=aws-options&tab=premium' );
|
183 |
+
}
|
184 |
+
return $submenu_file;
|
185 |
+
}
|
186 |
+
|
187 |
+
/*
|
188 |
+
* Check if some sources for disabled from index
|
189 |
+
*/
|
190 |
+
public function check_sources_in_index( $options ) {
|
191 |
+
|
192 |
+
if ( $options ) {
|
193 |
+
|
194 |
+
$index_options = AWS_Helpers::get_index_options();
|
195 |
+
|
196 |
+
foreach( $options as $options_key => $options_tab ) {
|
197 |
+
foreach( $options_tab as $key => $option ) {
|
198 |
+
if ( isset( $option['id'] ) && $option['id'] === 'search_in' && isset( $option['choices'] ) ) {
|
199 |
+
foreach( $option['choices'] as $choice_key => $choice_label ) {
|
200 |
+
if ( isset( $index_options['index'][$choice_key] ) && ! $index_options['index'][$choice_key] ) {
|
201 |
+
$text = '<span style="color:#dc3232;">' . __( '(index disabled)', 'advanced-woo-search' ) . '</span>' . ' <a href="'.esc_url( admin_url('admin.php?page=aws-options&tab=performance#index_sources') ).'">' . __( '(enable)', 'advanced-woo-search' ) . '</a>';
|
202 |
+
$options[$options_key][$key]['choices'][$choice_key] = $choice_label . ' ' . $text;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
}
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
}
|
210 |
+
|
211 |
+
return $options;
|
212 |
+
|
213 |
+
}
|
214 |
+
|
215 |
+
/*
|
216 |
+
* Disable sources that was excluded from index
|
217 |
+
*/
|
218 |
+
public function disable_not_indexed_sources( $setting, $option, $state ) {
|
219 |
+
|
220 |
+
if ( $setting === 'index_sources' && $state ) {
|
221 |
+
$settings = AWS_Admin_Options::get_settings();
|
222 |
+
if ( isset( $settings['search_in'][$option] ) ) {
|
223 |
+
$settings['search_in'][$option] = 0;
|
224 |
+
update_option( 'aws_settings', $settings );
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
/*
|
231 |
+
* Add welcome notice
|
232 |
+
*/
|
233 |
+
public function display_welcome_header() {
|
234 |
+
|
235 |
+
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'aws-options' ) {
|
236 |
+
return;
|
237 |
+
}
|
238 |
+
|
239 |
+
$hide_notice = get_option( 'aws_hide_welcome_notice' );
|
240 |
+
|
241 |
+
if ( ! $hide_notice || $hide_notice === 'true' ) {
|
242 |
+
return;
|
243 |
+
}
|
244 |
+
|
245 |
+
echo AWS_Admin_Meta_Boxes::get_welcome_notice();
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
/*
|
250 |
+
* Add reindex notice after index options change
|
251 |
+
*/
|
252 |
+
public function display_reindex_message() {
|
253 |
+
|
254 |
+
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'aws-options' ) {
|
255 |
+
return;
|
256 |
+
}
|
257 |
+
|
258 |
+
if ( ! isset( $_POST["Submit"] ) || ! current_user_can( 'manage_options' ) ) {
|
259 |
+
return;
|
260 |
+
}
|
261 |
+
|
262 |
+
if ( isset( $_POST["index_variations"] ) || isset( $_POST["search_rule"] ) ) {
|
263 |
+
echo AWS_Admin_Meta_Boxes::get_reindex_notice();
|
264 |
+
}
|
265 |
+
|
266 |
+
}
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
endif;
|
271 |
+
|
272 |
+
|
273 |
add_action( 'init', 'AWS_Admin::instance' );
|
includes/class-aws-cache.php
CHANGED
@@ -1,205 +1,205 @@
|
|
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_ajax' ) );
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
/*
|
55 |
-
* Clear cahce ajax hook
|
56 |
-
*/
|
57 |
-
public function clear_cache_ajax() {
|
58 |
-
check_ajax_referer( 'aws_admin_ajax_nonce' );
|
59 |
-
$this->clear_cache();
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Get caching option name
|
64 |
-
*/
|
65 |
-
public function get_cache_name( $s ) {
|
66 |
-
|
67 |
-
$s = sanitize_text_field( $s );
|
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 |
-
if ( is_user_logged_in() ) {
|
78 |
-
$user = wp_get_current_user();
|
79 |
-
$role = ( array ) $user->roles;
|
80 |
-
$user_role = $role[0];
|
81 |
-
if ( $user_role ) {
|
82 |
-
$cache_option_name = $cache_option_name . '_' . $user_role;
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
return $cache_option_name;
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
/*
|
91 |
-
* Check if cache table exist
|
92 |
-
*/
|
93 |
-
private function is_cache_table_not_exist() {
|
94 |
-
|
95 |
-
global $wpdb;
|
96 |
-
|
97 |
-
return ( $wpdb->get_var( "SHOW TABLES LIKE '{$this->cache_table_name}'" ) != $this->cache_table_name );
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
/*
|
102 |
-
* Create cache table
|
103 |
-
*/
|
104 |
-
private function create_cache_table() {
|
105 |
-
|
106 |
-
global $wpdb;
|
107 |
-
|
108 |
-
$charset_collate = $wpdb->get_charset_collate();
|
109 |
-
|
110 |
-
$sql = "CREATE TABLE {$this->cache_table_name} (
|
111 |
-
name VARCHAR(100) NOT NULL,
|
112 |
-
value LONGTEXT NOT NULL
|
113 |
-
) $charset_collate;";
|
114 |
-
|
115 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
116 |
-
dbDelta( $sql );
|
117 |
-
|
118 |
-
}
|
119 |
-
|
120 |
-
/*
|
121 |
-
* Insert data into cache table
|
122 |
-
*/
|
123 |
-
public function insert_into_cache_table( $cache_option_name, $result_array ) {
|
124 |
-
|
125 |
-
global $wpdb;
|
126 |
-
|
127 |
-
$values = $wpdb->prepare(
|
128 |
-
"(%s, %s)",
|
129 |
-
sanitize_text_field( $cache_option_name ), json_encode( $result_array )
|
130 |
-
);
|
131 |
-
|
132 |
-
$query = "INSERT IGNORE INTO {$this->cache_table_name}
|
133 |
-
(`name`, `value`)
|
134 |
-
VALUES $values
|
135 |
-
";
|
136 |
-
|
137 |
-
$wpdb->query( $query );
|
138 |
-
|
139 |
-
if ( $wpdb->last_error ) {
|
140 |
-
if ( $this->is_cache_table_not_exist() ) {
|
141 |
-
$this->create_cache_table();
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
-
}
|
146 |
-
|
147 |
-
/*
|
148 |
-
* Get data from cache table
|
149 |
-
*/
|
150 |
-
public function get_from_cache_table( $cache_option_name ) {
|
151 |
-
|
152 |
-
global $wpdb;
|
153 |
-
|
154 |
-
$result = '';
|
155 |
-
$where = $wpdb->prepare( " name = %s", sanitize_text_field( $cache_option_name ) );
|
156 |
-
|
157 |
-
$sql = "SELECT *
|
158 |
-
FROM
|
159 |
-
{$this->cache_table_name}
|
160 |
-
WHERE
|
161 |
-
{$where}
|
162 |
-
";
|
163 |
-
|
164 |
-
$cache_content = $wpdb->get_results( $sql, ARRAY_A );
|
165 |
-
|
166 |
-
if ( ! $wpdb->last_error ) {
|
167 |
-
if (!empty($cache_content) && !is_wp_error($cache_content) && is_array($cache_content)) {
|
168 |
-
$result = $cache_content[0]['value'];
|
169 |
-
}
|
170 |
-
} else {
|
171 |
-
if ( $this->is_cache_table_not_exist() ) {
|
172 |
-
$this->create_cache_table();
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
return $result;
|
177 |
-
|
178 |
-
}
|
179 |
-
|
180 |
-
/*
|
181 |
-
* Clear cached terms
|
182 |
-
*/
|
183 |
-
public function clear_cache() {
|
184 |
-
|
185 |
-
global $wpdb;
|
186 |
-
|
187 |
-
if ( ! $this->is_cache_table_not_exist() ) {
|
188 |
-
|
189 |
-
$terms = "aws_search_term_%";
|
190 |
-
$where = $wpdb->prepare( " name LIKE %s", $terms );
|
191 |
-
|
192 |
-
$sql = "DELETE FROM {$this->cache_table_name}
|
193 |
-
WHERE {$where}
|
194 |
-
";
|
195 |
-
|
196 |
-
$wpdb->query( $sql );
|
197 |
-
|
198 |
-
}
|
199 |
-
|
200 |
-
}
|
201 |
-
|
202 |
-
}
|
203 |
-
|
204 |
-
|
205 |
endif;
|
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_ajax' ) );
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/*
|
55 |
+
* Clear cahce ajax hook
|
56 |
+
*/
|
57 |
+
public function clear_cache_ajax() {
|
58 |
+
check_ajax_referer( 'aws_admin_ajax_nonce' );
|
59 |
+
$this->clear_cache();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Get caching option name
|
64 |
+
*/
|
65 |
+
public function get_cache_name( $s ) {
|
66 |
+
|
67 |
+
$s = sanitize_text_field( $s );
|
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 |
+
if ( is_user_logged_in() ) {
|
78 |
+
$user = wp_get_current_user();
|
79 |
+
$role = ( array ) $user->roles;
|
80 |
+
$user_role = $role[0];
|
81 |
+
if ( $user_role ) {
|
82 |
+
$cache_option_name = $cache_option_name . '_' . $user_role;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
return $cache_option_name;
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
/*
|
91 |
+
* Check if cache table exist
|
92 |
+
*/
|
93 |
+
private function is_cache_table_not_exist() {
|
94 |
+
|
95 |
+
global $wpdb;
|
96 |
+
|
97 |
+
return ( $wpdb->get_var( "SHOW TABLES LIKE '{$this->cache_table_name}'" ) != $this->cache_table_name );
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
/*
|
102 |
+
* Create cache table
|
103 |
+
*/
|
104 |
+
private function create_cache_table() {
|
105 |
+
|
106 |
+
global $wpdb;
|
107 |
+
|
108 |
+
$charset_collate = $wpdb->get_charset_collate();
|
109 |
+
|
110 |
+
$sql = "CREATE TABLE {$this->cache_table_name} (
|
111 |
+
name VARCHAR(100) NOT NULL,
|
112 |
+
value LONGTEXT NOT NULL
|
113 |
+
) $charset_collate;";
|
114 |
+
|
115 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
116 |
+
dbDelta( $sql );
|
117 |
+
|
118 |
+
}
|
119 |
+
|
120 |
+
/*
|
121 |
+
* Insert data into cache table
|
122 |
+
*/
|
123 |
+
public function insert_into_cache_table( $cache_option_name, $result_array ) {
|
124 |
+
|
125 |
+
global $wpdb;
|
126 |
+
|
127 |
+
$values = $wpdb->prepare(
|
128 |
+
"(%s, %s)",
|
129 |
+
sanitize_text_field( $cache_option_name ), json_encode( $result_array )
|
130 |
+
);
|
131 |
+
|
132 |
+
$query = "INSERT IGNORE INTO {$this->cache_table_name}
|
133 |
+
(`name`, `value`)
|
134 |
+
VALUES $values
|
135 |
+
";
|
136 |
+
|
137 |
+
$wpdb->query( $query );
|
138 |
+
|
139 |
+
if ( $wpdb->last_error ) {
|
140 |
+
if ( $this->is_cache_table_not_exist() ) {
|
141 |
+
$this->create_cache_table();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
146 |
+
|
147 |
+
/*
|
148 |
+
* Get data from cache table
|
149 |
+
*/
|
150 |
+
public function get_from_cache_table( $cache_option_name ) {
|
151 |
+
|
152 |
+
global $wpdb;
|
153 |
+
|
154 |
+
$result = '';
|
155 |
+
$where = $wpdb->prepare( " name = %s", sanitize_text_field( $cache_option_name ) );
|
156 |
+
|
157 |
+
$sql = "SELECT *
|
158 |
+
FROM
|
159 |
+
{$this->cache_table_name}
|
160 |
+
WHERE
|
161 |
+
{$where}
|
162 |
+
";
|
163 |
+
|
164 |
+
$cache_content = $wpdb->get_results( $sql, ARRAY_A );
|
165 |
+
|
166 |
+
if ( ! $wpdb->last_error ) {
|
167 |
+
if (!empty($cache_content) && !is_wp_error($cache_content) && is_array($cache_content)) {
|
168 |
+
$result = $cache_content[0]['value'];
|
169 |
+
}
|
170 |
+
} else {
|
171 |
+
if ( $this->is_cache_table_not_exist() ) {
|
172 |
+
$this->create_cache_table();
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
return $result;
|
177 |
+
|
178 |
+
}
|
179 |
+
|
180 |
+
/*
|
181 |
+
* Clear cached terms
|
182 |
+
*/
|
183 |
+
public function clear_cache() {
|
184 |
+
|
185 |
+
global $wpdb;
|
186 |
+
|
187 |
+
if ( ! $this->is_cache_table_not_exist() ) {
|
188 |
+
|
189 |
+
$terms = "aws_search_term_%";
|
190 |
+
$where = $wpdb->prepare( " name LIKE %s", $terms );
|
191 |
+
|
192 |
+
$sql = "DELETE FROM {$this->cache_table_name}
|
193 |
+
WHERE {$where}
|
194 |
+
";
|
195 |
+
|
196 |
+
$wpdb->query( $sql );
|
197 |
+
|
198 |
+
}
|
199 |
+
|
200 |
+
}
|
201 |
+
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
endif;
|
includes/class-aws-helpers.php
CHANGED
@@ -1,960 +1,960 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
|
8 |
-
if ( ! class_exists( 'AWS_Helpers' ) ) :
|
9 |
-
|
10 |
-
/**
|
11 |
-
* Class for plugin help methods
|
12 |
-
*/
|
13 |
-
class AWS_Helpers {
|
14 |
-
|
15 |
-
/*
|
16 |
-
* Removes scripts, styles, html tags
|
17 |
-
*/
|
18 |
-
static public function html2txt( $str ) {
|
19 |
-
$search = array(
|
20 |
-
'@<script[^>]*?>.*?</script>@si',
|
21 |
-
'@<[\/\!]*?[^<>]*?>@si',
|
22 |
-
'@<style[^>]*?>.*?</style>@siU',
|
23 |
-
'@<![\s\S]*?--[ \t\n\r]*>@'
|
24 |
-
);
|
25 |
-
$str = preg_replace( $search, '', $str );
|
26 |
-
|
27 |
-
$str = esc_attr( $str );
|
28 |
-
$str = stripslashes( $str );
|
29 |
-
$str = str_replace( array( "\r", "\n" ), ' ', $str );
|
30 |
-
|
31 |
-
$str = str_replace( array(
|
32 |
-
"·",
|
33 |
-
"…",
|
34 |
-
"€",
|
35 |
-
"­"
|
36 |
-
), "", $str );
|
37 |
-
|
38 |
-
return $str;
|
39 |
-
}
|
40 |
-
|
41 |
-
/*
|
42 |
-
* Check if index table exist
|
43 |
-
*/
|
44 |
-
static public function is_table_not_exist() {
|
45 |
-
|
46 |
-
global $wpdb;
|
47 |
-
|
48 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
49 |
-
|
50 |
-
return ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) != $table_name );
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
/*
|
55 |
-
* Get amount of indexed products
|
56 |
-
*/
|
57 |
-
static public function get_indexed_products_count() {
|
58 |
-
|
59 |
-
global $wpdb;
|
60 |
-
|
61 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
62 |
-
|
63 |
-
$indexed_products = 0;
|
64 |
-
|
65 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) {
|
66 |
-
|
67 |
-
$sql = "SELECT COUNT(*) FROM {$table_name} GROUP BY ID;";
|
68 |
-
|
69 |
-
$indexed_products = $wpdb->query( $sql );
|
70 |
-
|
71 |
-
}
|
72 |
-
|
73 |
-
return $indexed_products;
|
74 |
-
|
75 |
-
}
|
76 |
-
|
77 |
-
/*
|
78 |
-
* Check if index table has new terms columns
|
79 |
-
*/
|
80 |
-
static public function is_index_table_has_terms() {
|
81 |
-
|
82 |
-
global $wpdb;
|
83 |
-
|
84 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
85 |
-
|
86 |
-
$return = false;
|
87 |
-
|
88 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) {
|
89 |
-
|
90 |
-
$columns = $wpdb->get_row("
|
91 |
-
SELECT * FROM {$table_name} LIMIT 0, 1
|
92 |
-
", ARRAY_A );
|
93 |
-
|
94 |
-
if ( $columns && ! isset( $columns['term_id'] ) ) {
|
95 |
-
$return = 'no_terms';
|
96 |
-
} else {
|
97 |
-
$return = 'has_terms';
|
98 |
-
}
|
99 |
-
|
100 |
-
}
|
101 |
-
|
102 |
-
return $return;
|
103 |
-
|
104 |
-
}
|
105 |
-
|
106 |
-
/*
|
107 |
-
* Check if index table has new on_sale columns
|
108 |
-
*/
|
109 |
-
static public function is_index_table_has_on_sale() {
|
110 |
-
|
111 |
-
global $wpdb;
|
112 |
-
|
113 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
114 |
-
|
115 |
-
$return = false;
|
116 |
-
|
117 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) {
|
118 |
-
|
119 |
-
$columns = $wpdb->get_row("
|
120 |
-
SELECT * FROM {$table_name} LIMIT 0, 1
|
121 |
-
", ARRAY_A );
|
122 |
-
|
123 |
-
if ( $columns && ! isset( $columns['on_sale'] ) ) {
|
124 |
-
$return = 'no';
|
125 |
-
} else {
|
126 |
-
$return = 'has';
|
127 |
-
}
|
128 |
-
|
129 |
-
}
|
130 |
-
|
131 |
-
return $return;
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
/*
|
136 |
-
* Get special characters that must be striped
|
137 |
-
*/
|
138 |
-
static public function get_special_chars() {
|
139 |
-
|
140 |
-
$chars = array(
|
141 |
-
'!', //exclamation point
|
142 |
-
'"', //double quotes
|
143 |
-
'"', //double quotes
|
144 |
-
'#', //number sign
|
145 |
-
'$', //dollar sign
|
146 |
-
'%', //percent sign
|
147 |
-
'&', //ampersand
|
148 |
-
'&', //ampersand
|
149 |
-
'‘', //opening single quote
|
150 |
-
'’', //closing single quote & apostrophe
|
151 |
-
'“', //opening double quote
|
152 |
-
'”', //closing double quote
|
153 |
-
''', //single quote
|
154 |
-
''', //single quote
|
155 |
-
'(', //opening parenthesis
|
156 |
-
')', //closing parenthesis
|
157 |
-
'*', //asterisk
|
158 |
-
'+', //plus sign
|
159 |
-
',', //comma
|
160 |
-
'-', //minus sign - hyphen
|
161 |
-
'.', //period
|
162 |
-
'/', //slash
|
163 |
-
':', //colon
|
164 |
-
';', //semicolon
|
165 |
-
'<', //less than sign
|
166 |
-
'<', //less than sign
|
167 |
-
'=', //equal sign
|
168 |
-
'>', //greater than sign
|
169 |
-
'>', //greater than sign
|
170 |
-
'?', //question mark
|
171 |
-
'@', //at symbol
|
172 |
-
'[', //opening bracket
|
173 |
-
'\', //backslash
|
174 |
-
']', //closing bracket
|
175 |
-
'^', //caret - circumflex
|
176 |
-
'_', //underscore
|
177 |
-
'`', //grave accent
|
178 |
-
'{', //opening brace
|
179 |
-
'|', //vertical bar
|
180 |
-
'}', //closing brace
|
181 |
-
'~', //equivalency sign - tilde
|
182 |
-
'¡', //inverted exclamation mark
|
183 |
-
'¡', //inverted exclamation mark
|
184 |
-
'¢', //cent sign
|
185 |
-
'¢', //cent sign
|
186 |
-
'£', //pound sign
|
187 |
-
'£', //pound sign
|
188 |
-
'¤', //currency sign
|
189 |
-
'¤', //currency sign
|
190 |
-
'¥', //yen sign
|
191 |
-
'¥', //yen sign
|
192 |
-
'¦', //broken vertical bar
|
193 |
-
'¦', //broken vertical bar
|
194 |
-
'§', //section sign
|
195 |
-
'§', //section sign
|
196 |
-
'¨', //spacing diaeresis - umlaut
|
197 |
-
'¨', //spacing diaeresis - umlaut
|
198 |
-
'©', //copyright sign
|
199 |
-
'©', //copyright sign
|
200 |
-
'ª', //feminine ordinal indicator
|
201 |
-
'ª', //feminine ordinal indicator
|
202 |
-
'«', //left double angle quotes
|
203 |
-
'«', //left double angle quotes
|
204 |
-
'¬', //not sign
|
205 |
-
'¬', //not sign
|
206 |
-
'®', //registered trade mark sign
|
207 |
-
'®', //registered trade mark sign
|
208 |
-
'¯', //spacing macron - overline
|
209 |
-
'¯', //spacing macron - overline
|
210 |
-
'°', //degree sign
|
211 |
-
'°', //degree sign
|
212 |
-
'±', //plus-or-minus sign
|
213 |
-
'±', //plus-or-minus sign
|
214 |
-
'²', //superscript two - squared
|
215 |
-
'²', //superscript two - squared
|
216 |
-
'³', //superscript three - cubed
|
217 |
-
'³', //superscript three - cubed
|
218 |
-
'´', //acute accent - spacing acute
|
219 |
-
'´', //acute accent - spacing acute
|
220 |
-
'µ', //micro sign
|
221 |
-
'µ', //micro sign
|
222 |
-
'¶', //pilcrow sign - paragraph sign
|
223 |
-
'¶', //pilcrow sign - paragraph sign
|
224 |
-
'·', //middle dot - Georgian comma
|
225 |
-
'·', //middle dot - Georgian comma
|
226 |
-
'¸', //spacing cedilla
|
227 |
-
'¸', //spacing cedilla
|
228 |
-
'¹', //superscript one
|
229 |
-
'¹', //superscript one
|
230 |
-
'º', //masculine ordinal indicator
|
231 |
-
'º', //masculine ordinal indicator
|
232 |
-
'»', //right double angle quotes
|
233 |
-
'»', //right double angle quotes
|
234 |
-
'¼', //fraction one quarter
|
235 |
-
'¼', //fraction one quarter
|
236 |
-
'½', //fraction one half
|
237 |
-
'½', //fraction one half
|
238 |
-
'¾', //fraction three quarters
|
239 |
-
'¾', //fraction three quarters
|
240 |
-
'¿', //inverted question mark
|
241 |
-
'¿', //inverted question mark
|
242 |
-
'÷', //division sign
|
243 |
-
'÷', //division sign
|
244 |
-
'–', //en dash
|
245 |
-
'—', //em dash
|
246 |
-
'‘', //left single quotation mark
|
247 |
-
'’', //right single quotation mark
|
248 |
-
'‚', //single low-9 quotation mark
|
249 |
-
'“', //left double quotation mark
|
250 |
-
'”', //right double quotation mark
|
251 |
-
'„', //double low-9 quotation mark
|
252 |
-
'†', //dagger
|
253 |
-
'‡', //double dagger
|
254 |
-
'•', //bullet
|
255 |
-
'…', //horizontal ellipsis
|
256 |
-
'‰', //per thousand sign
|
257 |
-
'€', //euro sign
|
258 |
-
'€', //euro sign
|
259 |
-
'™', //trade mark sign
|
260 |
-
'!', //exclamation point
|
261 |
-
'"', //double quotes
|
262 |
-
'#', //number sign
|
263 |
-
'$', //dollar sign
|
264 |
-
'%', //percent sign
|
265 |
-
'&', //ampersand
|
266 |
-
"'", //single quote
|
267 |
-
'(', //opening parenthesis
|
268 |
-
')', //closing parenthesis
|
269 |
-
'*', //asterisk
|
270 |
-
'+', //plus sign
|
271 |
-
",", //comma
|
272 |
-
'-', //minus sign - hyphen
|
273 |
-
".", //period
|
274 |
-
"/", //slash
|
275 |
-
':', //colon
|
276 |
-
';', //semicolon
|
277 |
-
"<", //less than sign
|
278 |
-
"=", //equal sign
|
279 |
-
">", //greater than sign
|
280 |
-
'?', //question mark
|
281 |
-
'@', //at symbol
|
282 |
-
"[", //opening bracket
|
283 |
-
'\\', //backslash
|
284 |
-
"]", //closing bracket
|
285 |
-
'^', //caret - circumflex
|
286 |
-
'_', //underscore
|
287 |
-
'`', //grave accent
|
288 |
-
"{", //opening brace
|
289 |
-
'|', //vertical bar
|
290 |
-
"}", //closing brace
|
291 |
-
'~', //equivalency sign - tilde
|
292 |
-
'¡', //inverted exclamation mark
|
293 |
-
'¢', //cent sign
|
294 |
-
'£', //pound sign
|
295 |
-
'¤', //currency sign
|
296 |
-
'¥', //yen sign
|
297 |
-
'¦', //broken vertical bar
|
298 |
-
'§', //section sign
|
299 |
-
'¨', //spacing diaeresis - umlaut
|
300 |
-
'©', //copyright sign
|
301 |
-
'ª', //feminine ordinal indicator
|
302 |
-
'«', //left double angle quotes
|
303 |
-
'¬', //not sign
|
304 |
-
'®', //registered trade mark sign
|
305 |
-
'¯', //spacing macron - overline
|
306 |
-
'°', //degree sign
|
307 |
-
'±', //plus-or-minus sign
|
308 |
-
'²', //superscript two - squared
|
309 |
-
'³', //superscript three - cubed
|
310 |
-
'´', //acute accent - spacing acute
|
311 |
-
'µ', //micro sign
|
312 |
-
'¶', //pilcrow sign - paragraph sign
|
313 |
-
'·', //middle dot - Georgian comma
|
314 |
-
'¸', //spacing cedilla
|
315 |
-
'¹', //superscript one
|
316 |
-
'º', //masculine ordinal indicator
|
317 |
-
'»', //right double angle quotes
|
318 |
-
'¼', //fraction one quarter
|
319 |
-
'½', //fraction one half
|
320 |
-
'¾', //fraction three quarters
|
321 |
-
'¿', //inverted question mark
|
322 |
-
'÷', //division sign
|
323 |
-
'–', //en dash
|
324 |
-
'—', //em dash
|
325 |
-
'‘', //left single quotation mark
|
326 |
-
"’", //right single quotation mark
|
327 |
-
'‚', //single low-9 quotation mark
|
328 |
-
"“", //left double quotation mark
|
329 |
-
"”", //right double quotation mark
|
330 |
-
'„', //double low-9 quotation mark
|
331 |
-
'†', //dagger
|
332 |
-
'‡', //double dagger
|
333 |
-
'•', //bullet
|
334 |
-
'…', //horizontal ellipsis
|
335 |
-
'‰', //per thousand sign
|
336 |
-
'€', //euro sign
|
337 |
-
'™', //trade mark sign
|
338 |
-
);
|
339 |
-
|
340 |
-
return apply_filters( 'aws_special_chars', $chars );
|
341 |
-
|
342 |
-
}
|
343 |
-
|
344 |
-
/*
|
345 |
-
* Get diacritical marks
|
346 |
-
*/
|
347 |
-
static public function get_diacritic_chars() {
|
348 |
-
|
349 |
-
$chars = array(
|
350 |
-
'Š'=>'S',
|
351 |
-
'š'=>'s',
|
352 |
-
'Ž'=>'Z',
|
353 |
-
'ž'=>'z',
|
354 |
-
'À'=>'A',
|
355 |
-
'Á'=>'A',
|
356 |
-
'Â'=>'A',
|
357 |
-
'Ã'=>'A',
|
358 |
-
'Ä'=>'A',
|
359 |
-
'Å'=>'A',
|
360 |
-
'Æ'=>'A',
|
361 |
-
'Ç'=>'C',
|
362 |
-
'È'=>'E',
|
363 |
-
'É'=>'E',
|
364 |
-
'Ê'=>'E',
|
365 |
-
'Ë'=>'E',
|
366 |
-
'Ì'=>'I',
|
367 |
-
'Í'=>'I',
|
368 |
-
'Î'=>'I',
|
369 |
-
'Ï'=>'I',
|
370 |
-
'İ'=>'I',
|
371 |
-
'Ñ'=>'N',
|
372 |
-
'Ò'=>'O',
|
373 |
-
'Ó'=>'O',
|
374 |
-
'Ô'=>'O',
|
375 |
-
'Õ'=>'O',
|
376 |
-
'Ö'=>'O',
|
377 |
-
'Ø'=>'O',
|
378 |
-
'Ù'=>'U',
|
379 |
-
'Ú'=>'U',
|
380 |
-
'Û'=>'U',
|
381 |
-
'Ü'=>'U',
|
382 |
-
'Ý'=>'Y',
|
383 |
-
'à'=>'a',
|
384 |
-
'á'=>'a',
|
385 |
-
'â'=>'a',
|
386 |
-
'ã'=>'a',
|
387 |
-
'ä'=>'a',
|
388 |
-
'å'=>'a',
|
389 |
-
'ç'=>'c',
|
390 |
-
'è'=>'e',
|
391 |
-
'é'=>'e',
|
392 |
-
'ê'=>'e',
|
393 |
-
'ë'=>'e',
|
394 |
-
'ì'=>'i',
|
395 |
-
'í'=>'i',
|
396 |
-
'î'=>'i',
|
397 |
-
'ï'=>'i',
|
398 |
-
'ð'=>'o',
|
399 |
-
'ñ'=>'n',
|
400 |
-
'ò'=>'o',
|
401 |
-
'ó'=>'o',
|
402 |
-
'ô'=>'o',
|
403 |
-
'õ'=>'o',
|
404 |
-
'ö'=>'o',
|
405 |
-
'ø'=>'o',
|
406 |
-
'ù'=>'u',
|
407 |
-
'ú'=>'u',
|
408 |
-
'û'=>'u',
|
409 |
-
'ý'=>'y',
|
410 |
-
'þ'=>'b',
|
411 |
-
'ÿ'=>'y',
|
412 |
-
);
|
413 |
-
|
414 |
-
/**
|
415 |
-
* Filters array of diacritic chars
|
416 |
-
*
|
417 |
-
* @since 1.52
|
418 |
-
*/
|
419 |
-
return apply_filters( 'aws_diacritic_chars', $chars );
|
420 |
-
|
421 |
-
}
|
422 |
-
|
423 |
-
/*
|
424 |
-
* Normalize string
|
425 |
-
*/
|
426 |
-
static public function normalize_string( $string ) {
|
427 |
-
|
428 |
-
$special_chars = AWS_Helpers::get_special_chars();
|
429 |
-
|
430 |
-
$string = AWS_Helpers::html2txt( $string );
|
431 |
-
$string = str_replace( $special_chars, '', $string );
|
432 |
-
$string = str_replace( array( ' ', ' ' ), ' ', $string );
|
433 |
-
$string = trim( $string );
|
434 |
-
|
435 |
-
//$str = preg_replace( '/[[:punct:]]+/u', ' ', $str );
|
436 |
-
$string = preg_replace( '/[[:space:]]+/', ' ', $string );
|
437 |
-
|
438 |
-
// Most objects except unicode characters
|
439 |
-
$string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\x9F]/u', '', $string );
|
440 |
-
|
441 |
-
// Line feeds, carriage returns, tabs
|
442 |
-
$string = preg_replace( '/[\x00-\x1F\x80-\x9F]/u', '', $string );
|
443 |
-
|
444 |
-
// Diacritical marks
|
445 |
-
$string = strtr( $string, AWS_Helpers::get_diacritic_chars() );
|
446 |
-
|
447 |
-
if ( function_exists( 'mb_strtolower' ) ) {
|
448 |
-
$string = mb_strtolower( $string );
|
449 |
-
} else {
|
450 |
-
$string = strtolower( $string );
|
451 |
-
}
|
452 |
-
|
453 |
-
/**
|
454 |
-
* Filters normalized string
|
455 |
-
*
|
456 |
-
* @since 1.52
|
457 |
-
*/
|
458 |
-
return apply_filters( 'aws_normalize_string', $string );
|
459 |
-
|
460 |
-
}
|
461 |
-
|
462 |
-
/*
|
463 |
-
* Replace stopwords
|
464 |
-
*/
|
465 |
-
static public function filter_stopwords( $str_array ) {
|
466 |
-
|
467 |
-
$stopwords = AWS()->get_settings( 'stopwords' );
|
468 |
-
$stopwords_array = array();
|
469 |
-
$new_str_array = array();
|
470 |
-
|
471 |
-
if ( $stopwords ) {
|
472 |
-
$stopwords_array = explode( ',', $stopwords );
|
473 |
-
}
|
474 |
-
|
475 |
-
if ( $str_array && is_array( $str_array ) && ! empty( $str_array ) && $stopwords_array && ! empty( $stopwords_array ) ) {
|
476 |
-
|
477 |
-
$stopwords_array = array_map( 'trim', $stopwords_array );
|
478 |
-
|
479 |
-
foreach ( $str_array as $str_word ) {
|
480 |
-
if ( in_array( $str_word, $stopwords_array ) ) {
|
481 |
-
continue;
|
482 |
-
}
|
483 |
-
$new_str_array[] = $str_word;
|
484 |
-
}
|
485 |
-
|
486 |
-
} else {
|
487 |
-
$new_str_array = $str_array;
|
488 |
-
}
|
489 |
-
|
490 |
-
return $new_str_array;
|
491 |
-
|
492 |
-
}
|
493 |
-
|
494 |
-
/*
|
495 |
-
* Singularize terms
|
496 |
-
* @param string $search_term Search term
|
497 |
-
* @return string Singularized search term
|
498 |
-
*/
|
499 |
-
static public function singularize( $search_term ) {
|
500 |
-
|
501 |
-
$search_term_len = strlen( $search_term );
|
502 |
-
$search_term_norm = AWS_Plurals::singularize( $search_term );
|
503 |
-
|
504 |
-
if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
|
505 |
-
$search_term = $search_term_norm;
|
506 |
-
}
|
507 |
-
|
508 |
-
return $search_term;
|
509 |
-
|
510 |
-
}
|
511 |
-
|
512 |
-
/*
|
513 |
-
* Add synonyms
|
514 |
-
*/
|
515 |
-
static public function get_synonyms( $str_array, $singular = false ) {
|
516 |
-
|
517 |
-
$synonyms = AWS()->get_settings( 'synonyms' );
|
518 |
-
$synonyms_array = array();
|
519 |
-
$new_str_array = array();
|
520 |
-
|
521 |
-
if ( $synonyms ) {
|
522 |
-
$synonyms_array = preg_split( '/\r\n|\r|\n| /', $synonyms );
|
523 |
-
}
|
524 |
-
|
525 |
-
if ( $str_array && is_array( $str_array ) && ! empty( $str_array ) && $synonyms_array && ! empty( $synonyms_array ) ) {
|
526 |
-
|
527 |
-
$synonyms_array = array_map( 'trim', $synonyms_array );
|
528 |
-
|
529 |
-
/**
|
530 |
-
* Filters synonyms array before adding them to the index table where need
|
531 |
-
* @since 1.79
|
532 |
-
* @param array $synonyms_array Array of synonyms groups
|
533 |
-
*/
|
534 |
-
$synonyms_array = apply_filters( 'aws_synonyms_option_array', $synonyms_array );
|
535 |
-
|
536 |
-
foreach ( $synonyms_array as $synonyms_string ) {
|
537 |
-
|
538 |
-
if ( $synonyms_string ) {
|
539 |
-
|
540 |
-
$synonym_array = explode( ',', $synonyms_string );
|
541 |
-
|
542 |
-
if ( $synonym_array && ! empty( $synonym_array ) ) {
|
543 |
-
|
544 |
-
$synonym_array = array_map( array( 'AWS_Helpers', 'normalize_string' ), $synonym_array );
|
545 |
-
if ( $singular ) {
|
546 |
-
$synonym_array = array_map( array( 'AWS_Helpers', 'singularize' ), $synonym_array );
|
547 |
-
}
|
548 |
-
|
549 |
-
foreach ( $synonym_array as $synonym_item ) {
|
550 |
-
|
551 |
-
if ( $synonym_item && isset( $str_array[$synonym_item] ) ) {
|
552 |
-
$new_str_array = array_merge( $new_str_array, $synonym_array );
|
553 |
-
break;
|
554 |
-
}
|
555 |
-
|
556 |
-
if ( $synonym_item && preg_match( '/\s/',$synonym_item ) ) {
|
557 |
-
$synonym_words = explode( ' ', $synonym_item );
|
558 |
-
if ( $synonym_words && ! empty( $synonym_words ) ) {
|
559 |
-
|
560 |
-
$str_array_keys = array_keys( $str_array );
|
561 |
-
$synonym_prev_word_pos = 0;
|
562 |
-
$use_this = true;
|
563 |
-
|
564 |
-
foreach ( $synonym_words as $synonym_word ) {
|
565 |
-
if ( $synonym_word && isset( $str_array[$synonym_word] ) ) {
|
566 |
-
$synonym_current_word_pos = array_search( $synonym_word, $str_array_keys );
|
567 |
-
$synonym_prev_word_pos = $synonym_prev_word_pos ? $synonym_prev_word_pos : $synonym_current_word_pos;
|
568 |
-
|
569 |
-
if ( ( $synonym_prev_word_pos !== $synonym_current_word_pos ) && ++$synonym_prev_word_pos !== $synonym_current_word_pos ) {
|
570 |
-
$use_this = false;
|
571 |
-
break;
|
572 |
-
}
|
573 |
-
|
574 |
-
} else {
|
575 |
-
$use_this = false;
|
576 |
-
break;
|
577 |
-
}
|
578 |
-
}
|
579 |
-
|
580 |
-
if ( $use_this ) {
|
581 |
-
$new_str_array = array_merge( $new_str_array, $synonym_array );
|
582 |
-
break;
|
583 |
-
}
|
584 |
-
|
585 |
-
}
|
586 |
-
}
|
587 |
-
|
588 |
-
}
|
589 |
-
}
|
590 |
-
|
591 |
-
}
|
592 |
-
|
593 |
-
}
|
594 |
-
|
595 |
-
}
|
596 |
-
|
597 |
-
if ( $new_str_array ) {
|
598 |
-
$new_str_array = array_unique( $new_str_array );
|
599 |
-
foreach ( $new_str_array as $new_str_array_item ) {
|
600 |
-
if ( ! isset( $str_array[$new_str_array_item] ) ) {
|
601 |
-
$str_array[$new_str_array_item] = 1;
|
602 |
-
}
|
603 |
-
}
|
604 |
-
}
|
605 |
-
|
606 |
-
return $str_array;
|
607 |
-
|
608 |
-
}
|
609 |
-
|
610 |
-
/*
|
611 |
-
* Strip shortcodes
|
612 |
-
*/
|
613 |
-
static public function strip_shortcodes( $str ) {
|
614 |
-
|
615 |
-
/**
|
616 |
-
* Filter content string before striping shortcodes
|
617 |
-
* @since 2.01
|
618 |
-
* @param string $str
|
619 |
-
*/
|
620 |
-
$str = apply_filters( 'aws_before_strip_shortcodes', $str );
|
621 |
-
|
622 |
-
$str = preg_replace( '#\[[^\]]+\]#', '', $str );
|
623 |
-
return $str;
|
624 |
-
|
625 |
-
}
|
626 |
-
|
627 |
-
/*
|
628 |
-
* Get index table specific source name from taxonomy name
|
629 |
-
*
|
630 |
-
* @return string Source name
|
631 |
-
*/
|
632 |
-
static public function get_source_name( $taxonomy ) {
|
633 |
-
|
634 |
-
switch ( $taxonomy ) {
|
635 |
-
|
636 |
-
case 'product_cat':
|
637 |
-
$source_name = 'category';
|
638 |
-
break;
|
639 |
-
|
640 |
-
case 'product_tag':
|
641 |
-
$source_name = 'tag';
|
642 |
-
break;
|
643 |
-
|
644 |
-
default:
|
645 |
-
$source_name = '';
|
646 |
-
|
647 |
-
}
|
648 |
-
|
649 |
-
return $source_name;
|
650 |
-
|
651 |
-
}
|
652 |
-
|
653 |
-
/*
|
654 |
-
* Registers the WPML translations
|
655 |
-
*
|
656 |
-
*/
|
657 |
-
static public function register_wpml_translations( $params = false ) {
|
658 |
-
|
659 |
-
// No WPML
|
660 |
-
if ( ! function_exists( 'icl_register_string' ) ) {
|
661 |
-
return;
|
662 |
-
}
|
663 |
-
|
664 |
-
// These options are registered
|
665 |
-
$options_to_reg = array(
|
666 |
-
"search_field_text" => "Search",
|
667 |
-
"not_found_text" => "Nothing found",
|
668 |
-
"show_more_text" => "View all results",
|
669 |
-
);
|
670 |
-
|
671 |
-
if ( ! $params ) {
|
672 |
-
$params = $options_to_reg;
|
673 |
-
}
|
674 |
-
|
675 |
-
foreach ( $options_to_reg as $key => $option ) {
|
676 |
-
icl_register_string( 'aws', $key, $params[$key] );
|
677 |
-
}
|
678 |
-
|
679 |
-
}
|
680 |
-
|
681 |
-
/*
|
682 |
-
* Wrapper for WPML print
|
683 |
-
*
|
684 |
-
* @return string Source name
|
685 |
-
*/
|
686 |
-
static public function translate( $name, $value ) {
|
687 |
-
|
688 |
-
$translated_value = $value;
|
689 |
-
|
690 |
-
if ( function_exists( 'icl_t' ) ) {
|
691 |
-
$translated_value = icl_t( 'aws', $name, $value );
|
692 |
-
}
|
693 |
-
|
694 |
-
if ( $translated_value === $value ) {
|
695 |
-
$translated_value = __( $translated_value, 'advanced-woo-search' );
|
696 |
-
}
|
697 |
-
|
698 |
-
return $translated_value;
|
699 |
-
|
700 |
-
}
|
701 |
-
|
702 |
-
/*
|
703 |
-
* Get current active site language
|
704 |
-
*
|
705 |
-
* @return string Language code
|
706 |
-
*/
|
707 |
-
static public function get_lang() {
|
708 |
-
|
709 |
-
$current_lang = false;
|
710 |
-
|
711 |
-
if ( ( defined( 'ICL_SITEPRESS_VERSION' ) || function_exists( 'pll_current_language' ) ) ) {
|
712 |
-
|
713 |
-
if ( has_filter('wpml_current_language') ) {
|
714 |
-
$current_lang = apply_filters( 'wpml_current_language', NULL );
|
715 |
-
} elseif ( function_exists( 'pll_current_language' ) ) {
|
716 |
-
$current_lang = pll_current_language();
|
717 |
-
}
|
718 |
-
|
719 |
-
} elseif( function_exists( 'qtranxf_getLanguage' ) ) {
|
720 |
-
|
721 |
-
$current_lang = qtranxf_getLanguage();
|
722 |
-
|
723 |
-
}
|
724 |
-
|
725 |
-
return $current_lang;
|
726 |
-
|
727 |
-
}
|
728 |
-
|
729 |
-
/*
|
730 |
-
* Get search form action link
|
731 |
-
*
|
732 |
-
* @return string Search URL
|
733 |
-
*/
|
734 |
-
static public function get_search_url() {
|
735 |
-
|
736 |
-
$search_url = home_url( '/' );
|
737 |
-
|
738 |
-
if ( function_exists( 'pll_home_url' ) ) {
|
739 |
-
|
740 |
-
$search_url = pll_home_url();
|
741 |
-
|
742 |
-
if ( get_option( 'show_on_front' ) === 'page' ) {
|
743 |
-
|
744 |
-
$current_language = pll_current_language();
|
745 |
-
$default_language = pll_default_language();
|
746 |
-
|
747 |
-
if ( $current_language != $default_language ) {
|
748 |
-
if ( strpos( $search_url, '/' . $current_language ) !== false ) {
|
749 |
-
$language_subdir = $current_language.'/';
|
750 |
-
$search_url = home_url( '/' . $language_subdir );
|
751 |
-
}
|
752 |
-
}
|
753 |
-
|
754 |
-
}
|
755 |
-
|
756 |
-
}
|
757 |
-
|
758 |
-
return $search_url;
|
759 |
-
|
760 |
-
}
|
761 |
-
|
762 |
-
/*
|
763 |
-
* Get string with current product terms names
|
764 |
-
*
|
765 |
-
* @return string List of terms names
|
766 |
-
*/
|
767 |
-
static public function get_terms_array( $id, $taxonomy ) {
|
768 |
-
|
769 |
-
$terms = wp_get_object_terms( $id, $taxonomy );
|
770 |
-
|
771 |
-
if ( is_wp_error( $terms ) ) {
|
772 |
-
return '';
|
773 |
-
}
|
774 |
-
|
775 |
-
if ( empty( $terms ) ) {
|
776 |
-
return '';
|
777 |
-
}
|
778 |
-
|
779 |
-
$tax_array_temp = array();
|
780 |
-
$source_name = AWS_Helpers::get_source_name( $taxonomy );
|
781 |
-
|
782 |
-
foreach ( $terms as $term ) {
|
783 |
-
$source = $source_name . '%' . $term->term_id . '%';
|
784 |
-
$tax_array_temp[$source] = $term->name;
|
785 |
-
}
|
786 |
-
|
787 |
-
return $tax_array_temp;
|
788 |
-
|
789 |
-
}
|
790 |
-
|
791 |
-
/**
|
792 |
-
* Get product quantity
|
793 |
-
* @param object $product Product
|
794 |
-
* @return integer
|
795 |
-
*/
|
796 |
-
static public function get_quantity( $product ) {
|
797 |
-
|
798 |
-
$stock_levels = array();
|
799 |
-
|
800 |
-
if ( $product->is_type( 'variable' ) ) {
|
801 |
-
foreach ( $product->get_children() as $variation ) {
|
802 |
-
$var = wc_get_product( $variation );
|
803 |
-
$stock_levels[] = $var->get_stock_quantity();
|
804 |
-
}
|
805 |
-
} else {
|
806 |
-
$stock_levels[] = $product->get_stock_quantity();
|
807 |
-
}
|
808 |
-
|
809 |
-
return max( $stock_levels );
|
810 |
-
|
811 |
-
}
|
812 |
-
|
813 |
-
/**
|
814 |
-
* Get array of allowed tags for wp_kses function
|
815 |
-
* @param array $allowed_tags Tags that is allowed to display
|
816 |
-
* @return array $tags
|
817 |
-
*/
|
818 |
-
static public function get_kses( $allowed_tags = array() ) {
|
819 |
-
|
820 |
-
$tags = array(
|
821 |
-
'a' => array(
|
822 |
-
'href' => array(),
|
823 |
-
'title' => array()
|
824 |
-
),
|
825 |
-
'br' => array(),
|
826 |
-
'em' => array(),
|
827 |
-
'strong' => array(),
|
828 |
-
'b' => array(),
|
829 |
-
'code' => array(),
|
830 |
-
'blockquote' => array(
|
831 |
-
'cite' => array(),
|
832 |
-
),
|
833 |
-
'p' => array(),
|
834 |
-
'i' => array(),
|
835 |
-
'h1' => array(),
|
836 |
-
'h2' => array(),
|
837 |
-
'h3' => array(),
|
838 |
-
'h4' => array(),
|
839 |
-
'h5' => array(),
|
840 |
-
'h6' => array(),
|
841 |
-
'img' => array(
|
842 |
-
'alt' => array(),
|
843 |
-
'src' => array()
|
844 |
-
)
|
845 |
-
);
|
846 |
-
|
847 |
-
if ( is_array( $allowed_tags ) && ! empty( $allowed_tags ) ) {
|
848 |
-
foreach ( $tags as $tag => $tag_arr ) {
|
849 |
-
if ( array_search( $tag, $allowed_tags ) === false ) {
|
850 |
-
unset( $tags[$tag] );
|
851 |
-
}
|
852 |
-
}
|
853 |
-
|
854 |
-
}
|
855 |
-
|
856 |
-
return $tags;
|
857 |
-
|
858 |
-
}
|
859 |
-
|
860 |
-
/**
|
861 |
-
* Filter search page results by taxonomies
|
862 |
-
* @param array $product_terms Available product terms
|
863 |
-
* @param array $filter_terms Filter terms
|
864 |
-
* @param string $operator Operator
|
865 |
-
* @return bool $skip
|
866 |
-
*/
|
867 |
-
static public function page_filter_tax( $product_terms, $filter_terms, $operator = 'OR' ) {
|
868 |
-
|
869 |
-
$skip = true;
|
870 |
-
|
871 |
-
if ( $filter_terms && is_array( $filter_terms ) && ! empty( $filter_terms ) ) {
|
872 |
-
|
873 |
-
if ( $operator === 'AND' ) {
|
874 |
-
|
875 |
-
$has_all = true;
|
876 |
-
|
877 |
-
foreach( $filter_terms as $term ) {
|
878 |
-
if ( array_search( $term, $product_terms ) === false ) {
|
879 |
-
$has_all = false;
|
880 |
-
break;
|
881 |
-
}
|
882 |
-
}
|
883 |
-
|
884 |
-
if ( $has_all ) {
|
885 |
-
$skip = false;
|
886 |
-
}
|
887 |
-
|
888 |
-
}
|
889 |
-
|
890 |
-
if ( $operator === 'IN' || $operator === 'OR' ) {
|
891 |
-
|
892 |
-
$has_all = false;
|
893 |
-
|
894 |
-
foreach( $filter_terms as $term ) {
|
895 |
-
if ( array_search( $term, $product_terms ) !== false ) {
|
896 |
-
$has_all = true;
|
897 |
-
break;
|
898 |
-
}
|
899 |
-
}
|
900 |
-
|
901 |
-
if ( $has_all ) {
|
902 |
-
$skip = false;
|
903 |
-
}
|
904 |
-
|
905 |
-
}
|
906 |
-
|
907 |
-
}
|
908 |
-
|
909 |
-
return $skip;
|
910 |
-
|
911 |
-
}
|
912 |
-
|
913 |
-
/**
|
914 |
-
* Get array of index table options
|
915 |
-
* @return array $options
|
916 |
-
*/
|
917 |
-
static public function get_index_options() {
|
918 |
-
|
919 |
-
/**
|
920 |
-
* Apply or not WP filters to indexed content
|
921 |
-
* @since 1.82
|
922 |
-
* @param bool false
|
923 |
-
*/
|
924 |
-
$apply_filters = apply_filters( 'aws_index_apply_filters', false );
|
925 |
-
|
926 |
-
$index_variations_option = AWS()->get_settings( 'index_variations' );
|
927 |
-
$index_sources_option = AWS()->get_settings( 'index_sources' );
|
928 |
-
|
929 |
-
$index_variations = $index_variations_option && $index_variations_option === 'false' ? false : true;
|
930 |
-
$index_title = is_array( $index_sources_option ) && isset( $index_sources_option['title'] ) && ! $index_sources_option['title'] ? false : true;
|
931 |
-
$index_content = is_array( $index_sources_option ) && isset( $index_sources_option['content'] ) && ! $index_sources_option['content'] ? false : true;
|
932 |
-
$index_sku = is_array( $index_sources_option ) && isset( $index_sources_option['sku'] ) && ! $index_sources_option['sku'] ? false : true;
|
933 |
-
$index_excerpt = is_array( $index_sources_option ) && isset( $index_sources_option['excerpt'] ) && ! $index_sources_option['excerpt'] ? false : true;
|
934 |
-
$index_category = is_array( $index_sources_option ) && isset( $index_sources_option['category'] ) && ! $index_sources_option['category'] ? false : true;
|
935 |
-
$index_tag = is_array( $index_sources_option ) && isset( $index_sources_option['tag'] ) && ! $index_sources_option['tag'] ? false : true;
|
936 |
-
$index_id = is_array( $index_sources_option ) && isset( $index_sources_option['id'] ) && ! $index_sources_option['id'] ? false : true;
|
937 |
-
|
938 |
-
$index_vars = array(
|
939 |
-
'variations' => $index_variations,
|
940 |
-
'title' => $index_title,
|
941 |
-
'content' => $index_content,
|
942 |
-
'sku' => $index_sku,
|
943 |
-
'excerpt' => $index_excerpt,
|
944 |
-
'category' => $index_category,
|
945 |
-
'tag' => $index_tag,
|
946 |
-
'id' => $index_id,
|
947 |
-
);
|
948 |
-
|
949 |
-
$options = array(
|
950 |
-
'apply_filters' => $apply_filters,
|
951 |
-
'index' => $index_vars,
|
952 |
-
);
|
953 |
-
|
954 |
-
return $options;
|
955 |
-
|
956 |
-
}
|
957 |
-
|
958 |
-
}
|
959 |
-
|
960 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
|
8 |
+
if ( ! class_exists( 'AWS_Helpers' ) ) :
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class for plugin help methods
|
12 |
+
*/
|
13 |
+
class AWS_Helpers {
|
14 |
+
|
15 |
+
/*
|
16 |
+
* Removes scripts, styles, html tags
|
17 |
+
*/
|
18 |
+
static public function html2txt( $str ) {
|
19 |
+
$search = array(
|
20 |
+
'@<script[^>]*?>.*?</script>@si',
|
21 |
+
'@<[\/\!]*?[^<>]*?>@si',
|
22 |
+
'@<style[^>]*?>.*?</style>@siU',
|
23 |
+
'@<![\s\S]*?--[ \t\n\r]*>@'
|
24 |
+
);
|
25 |
+
$str = preg_replace( $search, '', $str );
|
26 |
+
|
27 |
+
$str = esc_attr( $str );
|
28 |
+
$str = stripslashes( $str );
|
29 |
+
$str = str_replace( array( "\r", "\n" ), ' ', $str );
|
30 |
+
|
31 |
+
$str = str_replace( array(
|
32 |
+
"·",
|
33 |
+
"…",
|
34 |
+
"€",
|
35 |
+
"­"
|
36 |
+
), "", $str );
|
37 |
+
|
38 |
+
return $str;
|
39 |
+
}
|
40 |
+
|
41 |
+
/*
|
42 |
+
* Check if index table exist
|
43 |
+
*/
|
44 |
+
static public function is_table_not_exist() {
|
45 |
+
|
46 |
+
global $wpdb;
|
47 |
+
|
48 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
49 |
+
|
50 |
+
return ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) != $table_name );
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/*
|
55 |
+
* Get amount of indexed products
|
56 |
+
*/
|
57 |
+
static public function get_indexed_products_count() {
|
58 |
+
|
59 |
+
global $wpdb;
|
60 |
+
|
61 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
62 |
+
|
63 |
+
$indexed_products = 0;
|
64 |
+
|
65 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) {
|
66 |
+
|
67 |
+
$sql = "SELECT COUNT(*) FROM {$table_name} GROUP BY ID;";
|
68 |
+
|
69 |
+
$indexed_products = $wpdb->query( $sql );
|
70 |
+
|
71 |
+
}
|
72 |
+
|
73 |
+
return $indexed_products;
|
74 |
+
|
75 |
+
}
|
76 |
+
|
77 |
+
/*
|
78 |
+
* Check if index table has new terms columns
|
79 |
+
*/
|
80 |
+
static public function is_index_table_has_terms() {
|
81 |
+
|
82 |
+
global $wpdb;
|
83 |
+
|
84 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
85 |
+
|
86 |
+
$return = false;
|
87 |
+
|
88 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) {
|
89 |
+
|
90 |
+
$columns = $wpdb->get_row("
|
91 |
+
SELECT * FROM {$table_name} LIMIT 0, 1
|
92 |
+
", ARRAY_A );
|
93 |
+
|
94 |
+
if ( $columns && ! isset( $columns['term_id'] ) ) {
|
95 |
+
$return = 'no_terms';
|
96 |
+
} else {
|
97 |
+
$return = 'has_terms';
|
98 |
+
}
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
return $return;
|
103 |
+
|
104 |
+
}
|
105 |
+
|
106 |
+
/*
|
107 |
+
* Check if index table has new on_sale columns
|
108 |
+
*/
|
109 |
+
static public function is_index_table_has_on_sale() {
|
110 |
+
|
111 |
+
global $wpdb;
|
112 |
+
|
113 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
114 |
+
|
115 |
+
$return = false;
|
116 |
+
|
117 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) === $table_name ) {
|
118 |
+
|
119 |
+
$columns = $wpdb->get_row("
|
120 |
+
SELECT * FROM {$table_name} LIMIT 0, 1
|
121 |
+
", ARRAY_A );
|
122 |
+
|
123 |
+
if ( $columns && ! isset( $columns['on_sale'] ) ) {
|
124 |
+
$return = 'no';
|
125 |
+
} else {
|
126 |
+
$return = 'has';
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
130 |
+
|
131 |
+
return $return;
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
/*
|
136 |
+
* Get special characters that must be striped
|
137 |
+
*/
|
138 |
+
static public function get_special_chars() {
|
139 |
+
|
140 |
+
$chars = array(
|
141 |
+
'!', //exclamation point
|
142 |
+
'"', //double quotes
|
143 |
+
'"', //double quotes
|
144 |
+
'#', //number sign
|
145 |
+
'$', //dollar sign
|
146 |
+
'%', //percent sign
|
147 |
+
'&', //ampersand
|
148 |
+
'&', //ampersand
|
149 |
+
'‘', //opening single quote
|
150 |
+
'’', //closing single quote & apostrophe
|
151 |
+
'“', //opening double quote
|
152 |
+
'”', //closing double quote
|
153 |
+
''', //single quote
|
154 |
+
''', //single quote
|
155 |
+
'(', //opening parenthesis
|
156 |
+
')', //closing parenthesis
|
157 |
+
'*', //asterisk
|
158 |
+
'+', //plus sign
|
159 |
+
',', //comma
|
160 |
+
'-', //minus sign - hyphen
|
161 |
+
'.', //period
|
162 |
+
'/', //slash
|
163 |
+
':', //colon
|
164 |
+
';', //semicolon
|
165 |
+
'<', //less than sign
|
166 |
+
'<', //less than sign
|
167 |
+
'=', //equal sign
|
168 |
+
'>', //greater than sign
|
169 |
+
'>', //greater than sign
|
170 |
+
'?', //question mark
|
171 |
+
'@', //at symbol
|
172 |
+
'[', //opening bracket
|
173 |
+
'\', //backslash
|
174 |
+
']', //closing bracket
|
175 |
+
'^', //caret - circumflex
|
176 |
+
'_', //underscore
|
177 |
+
'`', //grave accent
|
178 |
+
'{', //opening brace
|
179 |
+
'|', //vertical bar
|
180 |
+
'}', //closing brace
|
181 |
+
'~', //equivalency sign - tilde
|
182 |
+
'¡', //inverted exclamation mark
|
183 |
+
'¡', //inverted exclamation mark
|
184 |
+
'¢', //cent sign
|
185 |
+
'¢', //cent sign
|
186 |
+
'£', //pound sign
|
187 |
+
'£', //pound sign
|
188 |
+
'¤', //currency sign
|
189 |
+
'¤', //currency sign
|
190 |
+
'¥', //yen sign
|
191 |
+
'¥', //yen sign
|
192 |
+
'¦', //broken vertical bar
|
193 |
+
'¦', //broken vertical bar
|
194 |
+
'§', //section sign
|
195 |
+
'§', //section sign
|
196 |
+
'¨', //spacing diaeresis - umlaut
|
197 |
+
'¨', //spacing diaeresis - umlaut
|
198 |
+
'©', //copyright sign
|
199 |
+
'©', //copyright sign
|
200 |
+
'ª', //feminine ordinal indicator
|
201 |
+
'ª', //feminine ordinal indicator
|
202 |
+
'«', //left double angle quotes
|
203 |
+
'«', //left double angle quotes
|
204 |
+
'¬', //not sign
|
205 |
+
'¬', //not sign
|
206 |
+
'®', //registered trade mark sign
|
207 |
+
'®', //registered trade mark sign
|
208 |
+
'¯', //spacing macron - overline
|
209 |
+
'¯', //spacing macron - overline
|
210 |
+
'°', //degree sign
|
211 |
+
'°', //degree sign
|
212 |
+
'±', //plus-or-minus sign
|
213 |
+
'±', //plus-or-minus sign
|
214 |
+
'²', //superscript two - squared
|
215 |
+
'²', //superscript two - squared
|
216 |
+
'³', //superscript three - cubed
|
217 |
+
'³', //superscript three - cubed
|
218 |
+
'´', //acute accent - spacing acute
|
219 |
+
'´', //acute accent - spacing acute
|
220 |
+
'µ', //micro sign
|
221 |
+
'µ', //micro sign
|
222 |
+
'¶', //pilcrow sign - paragraph sign
|
223 |
+
'¶', //pilcrow sign - paragraph sign
|
224 |
+
'·', //middle dot - Georgian comma
|
225 |
+
'·', //middle dot - Georgian comma
|
226 |
+
'¸', //spacing cedilla
|
227 |
+
'¸', //spacing cedilla
|
228 |
+
'¹', //superscript one
|
229 |
+
'¹', //superscript one
|
230 |
+
'º', //masculine ordinal indicator
|
231 |
+
'º', //masculine ordinal indicator
|
232 |
+
'»', //right double angle quotes
|
233 |
+
'»', //right double angle quotes
|
234 |
+
'¼', //fraction one quarter
|
235 |
+
'¼', //fraction one quarter
|
236 |
+
'½', //fraction one half
|
237 |
+
'½', //fraction one half
|
238 |
+
'¾', //fraction three quarters
|
239 |
+
'¾', //fraction three quarters
|
240 |
+
'¿', //inverted question mark
|
241 |
+
'¿', //inverted question mark
|
242 |
+
'÷', //division sign
|
243 |
+
'÷', //division sign
|
244 |
+
'–', //en dash
|
245 |
+
'—', //em dash
|
246 |
+
'‘', //left single quotation mark
|
247 |
+
'’', //right single quotation mark
|
248 |
+
'‚', //single low-9 quotation mark
|
249 |
+
'“', //left double quotation mark
|
250 |
+
'”', //right double quotation mark
|
251 |
+
'„', //double low-9 quotation mark
|
252 |
+
'†', //dagger
|
253 |
+
'‡', //double dagger
|
254 |
+
'•', //bullet
|
255 |
+
'…', //horizontal ellipsis
|
256 |
+
'‰', //per thousand sign
|
257 |
+
'€', //euro sign
|
258 |
+
'€', //euro sign
|
259 |
+
'™', //trade mark sign
|
260 |
+
'!', //exclamation point
|
261 |
+
'"', //double quotes
|
262 |
+
'#', //number sign
|
263 |
+
'$', //dollar sign
|
264 |
+
'%', //percent sign
|
265 |
+
'&', //ampersand
|
266 |
+
"'", //single quote
|
267 |
+
'(', //opening parenthesis
|
268 |
+
')', //closing parenthesis
|
269 |
+
'*', //asterisk
|
270 |
+
'+', //plus sign
|
271 |
+
",", //comma
|
272 |
+
'-', //minus sign - hyphen
|
273 |
+
".", //period
|
274 |
+
"/", //slash
|
275 |
+
':', //colon
|
276 |
+
';', //semicolon
|
277 |
+
"<", //less than sign
|
278 |
+
"=", //equal sign
|
279 |
+
">", //greater than sign
|
280 |
+
'?', //question mark
|
281 |
+
'@', //at symbol
|
282 |
+
"[", //opening bracket
|
283 |
+
'\\', //backslash
|
284 |
+
"]", //closing bracket
|
285 |
+
'^', //caret - circumflex
|
286 |
+
'_', //underscore
|
287 |
+
'`', //grave accent
|
288 |
+
"{", //opening brace
|
289 |
+
'|', //vertical bar
|
290 |
+
"}", //closing brace
|
291 |
+
'~', //equivalency sign - tilde
|
292 |
+
'¡', //inverted exclamation mark
|
293 |
+
'¢', //cent sign
|
294 |
+
'£', //pound sign
|
295 |
+
'¤', //currency sign
|
296 |
+
'¥', //yen sign
|
297 |
+
'¦', //broken vertical bar
|
298 |
+
'§', //section sign
|
299 |
+
'¨', //spacing diaeresis - umlaut
|
300 |
+
'©', //copyright sign
|
301 |
+
'ª', //feminine ordinal indicator
|
302 |
+
'«', //left double angle quotes
|
303 |
+
'¬', //not sign
|
304 |
+
'®', //registered trade mark sign
|
305 |
+
'¯', //spacing macron - overline
|
306 |
+
'°', //degree sign
|
307 |
+
'±', //plus-or-minus sign
|
308 |
+
'²', //superscript two - squared
|
309 |
+
'³', //superscript three - cubed
|
310 |
+
'´', //acute accent - spacing acute
|
311 |
+
'µ', //micro sign
|
312 |
+
'¶', //pilcrow sign - paragraph sign
|
313 |
+
'·', //middle dot - Georgian comma
|
314 |
+
'¸', //spacing cedilla
|
315 |
+
'¹', //superscript one
|
316 |
+
'º', //masculine ordinal indicator
|
317 |
+
'»', //right double angle quotes
|
318 |
+
'¼', //fraction one quarter
|
319 |
+
'½', //fraction one half
|
320 |
+
'¾', //fraction three quarters
|
321 |
+
'¿', //inverted question mark
|
322 |
+
'÷', //division sign
|
323 |
+
'–', //en dash
|
324 |
+
'—', //em dash
|
325 |
+
'‘', //left single quotation mark
|
326 |
+
"’", //right single quotation mark
|
327 |
+
'‚', //single low-9 quotation mark
|
328 |
+
"“", //left double quotation mark
|
329 |
+
"”", //right double quotation mark
|
330 |
+
'„', //double low-9 quotation mark
|
331 |
+
'†', //dagger
|
332 |
+
'‡', //double dagger
|
333 |
+
'•', //bullet
|
334 |
+
'…', //horizontal ellipsis
|
335 |
+
'‰', //per thousand sign
|
336 |
+
'€', //euro sign
|
337 |
+
'™', //trade mark sign
|
338 |
+
);
|
339 |
+
|
340 |
+
return apply_filters( 'aws_special_chars', $chars );
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
/*
|
345 |
+
* Get diacritical marks
|
346 |
+
*/
|
347 |
+
static public function get_diacritic_chars() {
|
348 |
+
|
349 |
+
$chars = array(
|
350 |
+
'Š'=>'S',
|
351 |
+
'š'=>'s',
|
352 |
+
'Ž'=>'Z',
|
353 |
+
'ž'=>'z',
|
354 |
+
'À'=>'A',
|
355 |
+
'Á'=>'A',
|
356 |
+
'Â'=>'A',
|
357 |
+
'Ã'=>'A',
|
358 |
+
'Ä'=>'A',
|
359 |
+
'Å'=>'A',
|
360 |
+
'Æ'=>'A',
|
361 |
+
'Ç'=>'C',
|
362 |
+
'È'=>'E',
|
363 |
+
'É'=>'E',
|
364 |
+
'Ê'=>'E',
|
365 |
+
'Ë'=>'E',
|
366 |
+
'Ì'=>'I',
|
367 |
+
'Í'=>'I',
|
368 |
+
'Î'=>'I',
|
369 |
+
'Ï'=>'I',
|
370 |
+
'İ'=>'I',
|
371 |
+
'Ñ'=>'N',
|
372 |
+
'Ò'=>'O',
|
373 |
+
'Ó'=>'O',
|
374 |
+
'Ô'=>'O',
|
375 |
+
'Õ'=>'O',
|
376 |
+
'Ö'=>'O',
|
377 |
+
'Ø'=>'O',
|
378 |
+
'Ù'=>'U',
|
379 |
+
'Ú'=>'U',
|
380 |
+
'Û'=>'U',
|
381 |
+
'Ü'=>'U',
|
382 |
+
'Ý'=>'Y',
|
383 |
+
'à'=>'a',
|
384 |
+
'á'=>'a',
|
385 |
+
'â'=>'a',
|
386 |
+
'ã'=>'a',
|
387 |
+
'ä'=>'a',
|
388 |
+
'å'=>'a',
|
389 |
+
'ç'=>'c',
|
390 |
+
'è'=>'e',
|
391 |
+
'é'=>'e',
|
392 |
+
'ê'=>'e',
|
393 |
+
'ë'=>'e',
|
394 |
+
'ì'=>'i',
|
395 |
+
'í'=>'i',
|
396 |
+
'î'=>'i',
|
397 |
+
'ï'=>'i',
|
398 |
+
'ð'=>'o',
|
399 |
+
'ñ'=>'n',
|
400 |
+
'ò'=>'o',
|
401 |
+
'ó'=>'o',
|
402 |
+
'ô'=>'o',
|
403 |
+
'õ'=>'o',
|
404 |
+
'ö'=>'o',
|
405 |
+
'ø'=>'o',
|
406 |
+
'ù'=>'u',
|
407 |
+
'ú'=>'u',
|
408 |
+
'û'=>'u',
|
409 |
+
'ý'=>'y',
|
410 |
+
'þ'=>'b',
|
411 |
+
'ÿ'=>'y',
|
412 |
+
);
|
413 |
+
|
414 |
+
/**
|
415 |
+
* Filters array of diacritic chars
|
416 |
+
*
|
417 |
+
* @since 1.52
|
418 |
+
*/
|
419 |
+
return apply_filters( 'aws_diacritic_chars', $chars );
|
420 |
+
|
421 |
+
}
|
422 |
+
|
423 |
+
/*
|
424 |
+
* Normalize string
|
425 |
+
*/
|
426 |
+
static public function normalize_string( $string ) {
|
427 |
+
|
428 |
+
$special_chars = AWS_Helpers::get_special_chars();
|
429 |
+
|
430 |
+
$string = AWS_Helpers::html2txt( $string );
|
431 |
+
$string = str_replace( $special_chars, '', $string );
|
432 |
+
$string = str_replace( array( ' ', ' ' ), ' ', $string );
|
433 |
+
$string = trim( $string );
|
434 |
+
|
435 |
+
//$str = preg_replace( '/[[:punct:]]+/u', ' ', $str );
|
436 |
+
$string = preg_replace( '/[[:space:]]+/', ' ', $string );
|
437 |
+
|
438 |
+
// Most objects except unicode characters
|
439 |
+
$string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F\x80-\x9F]/u', '', $string );
|
440 |
+
|
441 |
+
// Line feeds, carriage returns, tabs
|
442 |
+
$string = preg_replace( '/[\x00-\x1F\x80-\x9F]/u', '', $string );
|
443 |
+
|
444 |
+
// Diacritical marks
|
445 |
+
$string = strtr( $string, AWS_Helpers::get_diacritic_chars() );
|
446 |
+
|
447 |
+
if ( function_exists( 'mb_strtolower' ) ) {
|
448 |
+
$string = mb_strtolower( $string );
|
449 |
+
} else {
|
450 |
+
$string = strtolower( $string );
|
451 |
+
}
|
452 |
+
|
453 |
+
/**
|
454 |
+
* Filters normalized string
|
455 |
+
*
|
456 |
+
* @since 1.52
|
457 |
+
*/
|
458 |
+
return apply_filters( 'aws_normalize_string', $string );
|
459 |
+
|
460 |
+
}
|
461 |
+
|
462 |
+
/*
|
463 |
+
* Replace stopwords
|
464 |
+
*/
|
465 |
+
static public function filter_stopwords( $str_array ) {
|
466 |
+
|
467 |
+
$stopwords = AWS()->get_settings( 'stopwords' );
|
468 |
+
$stopwords_array = array();
|
469 |
+
$new_str_array = array();
|
470 |
+
|
471 |
+
if ( $stopwords ) {
|
472 |
+
$stopwords_array = explode( ',', $stopwords );
|
473 |
+
}
|
474 |
+
|
475 |
+
if ( $str_array && is_array( $str_array ) && ! empty( $str_array ) && $stopwords_array && ! empty( $stopwords_array ) ) {
|
476 |
+
|
477 |
+
$stopwords_array = array_map( 'trim', $stopwords_array );
|
478 |
+
|
479 |
+
foreach ( $str_array as $str_word ) {
|
480 |
+
if ( in_array( $str_word, $stopwords_array ) ) {
|
481 |
+
continue;
|
482 |
+
}
|
483 |
+
$new_str_array[] = $str_word;
|
484 |
+
}
|
485 |
+
|
486 |
+
} else {
|
487 |
+
$new_str_array = $str_array;
|
488 |
+
}
|
489 |
+
|
490 |
+
return $new_str_array;
|
491 |
+
|
492 |
+
}
|
493 |
+
|
494 |
+
/*
|
495 |
+
* Singularize terms
|
496 |
+
* @param string $search_term Search term
|
497 |
+
* @return string Singularized search term
|
498 |
+
*/
|
499 |
+
static public function singularize( $search_term ) {
|
500 |
+
|
501 |
+
$search_term_len = strlen( $search_term );
|
502 |
+
$search_term_norm = AWS_Plurals::singularize( $search_term );
|
503 |
+
|
504 |
+
if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
|
505 |
+
$search_term = $search_term_norm;
|
506 |
+
}
|
507 |
+
|
508 |
+
return $search_term;
|
509 |
+
|
510 |
+
}
|
511 |
+
|
512 |
+
/*
|
513 |
+
* Add synonyms
|
514 |
+
*/
|
515 |
+
static public function get_synonyms( $str_array, $singular = false ) {
|
516 |
+
|
517 |
+
$synonyms = AWS()->get_settings( 'synonyms' );
|
518 |
+
$synonyms_array = array();
|
519 |
+
$new_str_array = array();
|
520 |
+
|
521 |
+
if ( $synonyms ) {
|
522 |
+
$synonyms_array = preg_split( '/\r\n|\r|\n| /', $synonyms );
|
523 |
+
}
|
524 |
+
|
525 |
+
if ( $str_array && is_array( $str_array ) && ! empty( $str_array ) && $synonyms_array && ! empty( $synonyms_array ) ) {
|
526 |
+
|
527 |
+
$synonyms_array = array_map( 'trim', $synonyms_array );
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Filters synonyms array before adding them to the index table where need
|
531 |
+
* @since 1.79
|
532 |
+
* @param array $synonyms_array Array of synonyms groups
|
533 |
+
*/
|
534 |
+
$synonyms_array = apply_filters( 'aws_synonyms_option_array', $synonyms_array );
|
535 |
+
|
536 |
+
foreach ( $synonyms_array as $synonyms_string ) {
|
537 |
+
|
538 |
+
if ( $synonyms_string ) {
|
539 |
+
|
540 |
+
$synonym_array = explode( ',', $synonyms_string );
|
541 |
+
|
542 |
+
if ( $synonym_array && ! empty( $synonym_array ) ) {
|
543 |
+
|
544 |
+
$synonym_array = array_map( array( 'AWS_Helpers', 'normalize_string' ), $synonym_array );
|
545 |
+
if ( $singular ) {
|
546 |
+
$synonym_array = array_map( array( 'AWS_Helpers', 'singularize' ), $synonym_array );
|
547 |
+
}
|
548 |
+
|
549 |
+
foreach ( $synonym_array as $synonym_item ) {
|
550 |
+
|
551 |
+
if ( $synonym_item && isset( $str_array[$synonym_item] ) ) {
|
552 |
+
$new_str_array = array_merge( $new_str_array, $synonym_array );
|
553 |
+
break;
|
554 |
+
}
|
555 |
+
|
556 |
+
if ( $synonym_item && preg_match( '/\s/',$synonym_item ) ) {
|
557 |
+
$synonym_words = explode( ' ', $synonym_item );
|
558 |
+
if ( $synonym_words && ! empty( $synonym_words ) ) {
|
559 |
+
|
560 |
+
$str_array_keys = array_keys( $str_array );
|
561 |
+
$synonym_prev_word_pos = 0;
|
562 |
+
$use_this = true;
|
563 |
+
|
564 |
+
foreach ( $synonym_words as $synonym_word ) {
|
565 |
+
if ( $synonym_word && isset( $str_array[$synonym_word] ) ) {
|
566 |
+
$synonym_current_word_pos = array_search( $synonym_word, $str_array_keys );
|
567 |
+
$synonym_prev_word_pos = $synonym_prev_word_pos ? $synonym_prev_word_pos : $synonym_current_word_pos;
|
568 |
+
|
569 |
+
if ( ( $synonym_prev_word_pos !== $synonym_current_word_pos ) && ++$synonym_prev_word_pos !== $synonym_current_word_pos ) {
|
570 |
+
$use_this = false;
|
571 |
+
break;
|
572 |
+
}
|
573 |
+
|
574 |
+
} else {
|
575 |
+
$use_this = false;
|
576 |
+
break;
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
if ( $use_this ) {
|
581 |
+
$new_str_array = array_merge( $new_str_array, $synonym_array );
|
582 |
+
break;
|
583 |
+
}
|
584 |
+
|
585 |
+
}
|
586 |
+
}
|
587 |
+
|
588 |
+
}
|
589 |
+
}
|
590 |
+
|
591 |
+
}
|
592 |
+
|
593 |
+
}
|
594 |
+
|
595 |
+
}
|
596 |
+
|
597 |
+
if ( $new_str_array ) {
|
598 |
+
$new_str_array = array_unique( $new_str_array );
|
599 |
+
foreach ( $new_str_array as $new_str_array_item ) {
|
600 |
+
if ( ! isset( $str_array[$new_str_array_item] ) ) {
|
601 |
+
$str_array[$new_str_array_item] = 1;
|
602 |
+
}
|
603 |
+
}
|
604 |
+
}
|
605 |
+
|
606 |
+
return $str_array;
|
607 |
+
|
608 |
+
}
|
609 |
+
|
610 |
+
/*
|
611 |
+
* Strip shortcodes
|
612 |
+
*/
|
613 |
+
static public function strip_shortcodes( $str ) {
|
614 |
+
|
615 |
+
/**
|
616 |
+
* Filter content string before striping shortcodes
|
617 |
+
* @since 2.01
|
618 |
+
* @param string $str
|
619 |
+
*/
|
620 |
+
$str = apply_filters( 'aws_before_strip_shortcodes', $str );
|
621 |
+
|
622 |
+
$str = preg_replace( '#\[[^\]]+\]#', '', $str );
|
623 |
+
return $str;
|
624 |
+
|
625 |
+
}
|
626 |
+
|
627 |
+
/*
|
628 |
+
* Get index table specific source name from taxonomy name
|
629 |
+
*
|
630 |
+
* @return string Source name
|
631 |
+
*/
|
632 |
+
static public function get_source_name( $taxonomy ) {
|
633 |
+
|
634 |
+
switch ( $taxonomy ) {
|
635 |
+
|
636 |
+
case 'product_cat':
|
637 |
+
$source_name = 'category';
|
638 |
+
break;
|
639 |
+
|
640 |
+
case 'product_tag':
|
641 |
+
$source_name = 'tag';
|
642 |
+
break;
|
643 |
+
|
644 |
+
default:
|
645 |
+
$source_name = '';
|
646 |
+
|
647 |
+
}
|
648 |
+
|
649 |
+
return $source_name;
|
650 |
+
|
651 |
+
}
|
652 |
+
|
653 |
+
/*
|
654 |
+
* Registers the WPML translations
|
655 |
+
*
|
656 |
+
*/
|
657 |
+
static public function register_wpml_translations( $params = false ) {
|
658 |
+
|
659 |
+
// No WPML
|
660 |
+
if ( ! function_exists( 'icl_register_string' ) ) {
|
661 |
+
return;
|
662 |
+
}
|
663 |
+
|
664 |
+
// These options are registered
|
665 |
+
$options_to_reg = array(
|
666 |
+
"search_field_text" => "Search",
|
667 |
+
"not_found_text" => "Nothing found",
|
668 |
+
"show_more_text" => "View all results",
|
669 |
+
);
|
670 |
+
|
671 |
+
if ( ! $params ) {
|
672 |
+
$params = $options_to_reg;
|
673 |
+
}
|
674 |
+
|
675 |
+
foreach ( $options_to_reg as $key => $option ) {
|
676 |
+
icl_register_string( 'aws', $key, $params[$key] );
|
677 |
+
}
|
678 |
+
|
679 |
+
}
|
680 |
+
|
681 |
+
/*
|
682 |
+
* Wrapper for WPML print
|
683 |
+
*
|
684 |
+
* @return string Source name
|
685 |
+
*/
|
686 |
+
static public function translate( $name, $value ) {
|
687 |
+
|
688 |
+
$translated_value = $value;
|
689 |
+
|
690 |
+
if ( function_exists( 'icl_t' ) ) {
|
691 |
+
$translated_value = icl_t( 'aws', $name, $value );
|
692 |
+
}
|
693 |
+
|
694 |
+
if ( $translated_value === $value ) {
|
695 |
+
$translated_value = __( $translated_value, 'advanced-woo-search' );
|
696 |
+
}
|
697 |
+
|
698 |
+
return $translated_value;
|
699 |
+
|
700 |
+
}
|
701 |
+
|
702 |
+
/*
|
703 |
+
* Get current active site language
|
704 |
+
*
|
705 |
+
* @return string Language code
|
706 |
+
*/
|
707 |
+
static public function get_lang() {
|
708 |
+
|
709 |
+
$current_lang = false;
|
710 |
+
|
711 |
+
if ( ( defined( 'ICL_SITEPRESS_VERSION' ) || function_exists( 'pll_current_language' ) ) ) {
|
712 |
+
|
713 |
+
if ( has_filter('wpml_current_language') ) {
|
714 |
+
$current_lang = apply_filters( 'wpml_current_language', NULL );
|
715 |
+
} elseif ( function_exists( 'pll_current_language' ) ) {
|
716 |
+
$current_lang = pll_current_language();
|
717 |
+
}
|
718 |
+
|
719 |
+
} elseif( function_exists( 'qtranxf_getLanguage' ) ) {
|
720 |
+
|
721 |
+
$current_lang = qtranxf_getLanguage();
|
722 |
+
|
723 |
+
}
|
724 |
+
|
725 |
+
return $current_lang;
|
726 |
+
|
727 |
+
}
|
728 |
+
|
729 |
+
/*
|
730 |
+
* Get search form action link
|
731 |
+
*
|
732 |
+
* @return string Search URL
|
733 |
+
*/
|
734 |
+
static public function get_search_url() {
|
735 |
+
|
736 |
+
$search_url = home_url( '/' );
|
737 |
+
|
738 |
+
if ( function_exists( 'pll_home_url' ) ) {
|
739 |
+
|
740 |
+
$search_url = pll_home_url();
|
741 |
+
|
742 |
+
if ( get_option( 'show_on_front' ) === 'page' ) {
|
743 |
+
|
744 |
+
$current_language = pll_current_language();
|
745 |
+
$default_language = pll_default_language();
|
746 |
+
|
747 |
+
if ( $current_language != $default_language ) {
|
748 |
+
if ( strpos( $search_url, '/' . $current_language ) !== false ) {
|
749 |
+
$language_subdir = $current_language.'/';
|
750 |
+
$search_url = home_url( '/' . $language_subdir );
|
751 |
+
}
|
752 |
+
}
|
753 |
+
|
754 |
+
}
|
755 |
+
|
756 |
+
}
|
757 |
+
|
758 |
+
return $search_url;
|
759 |
+
|
760 |
+
}
|
761 |
+
|
762 |
+
/*
|
763 |
+
* Get string with current product terms names
|
764 |
+
*
|
765 |
+
* @return string List of terms names
|
766 |
+
*/
|
767 |
+
static public function get_terms_array( $id, $taxonomy ) {
|
768 |
+
|
769 |
+
$terms = wp_get_object_terms( $id, $taxonomy );
|
770 |
+
|
771 |
+
if ( is_wp_error( $terms ) ) {
|
772 |
+
return '';
|
773 |
+
}
|
774 |
+
|
775 |
+
if ( empty( $terms ) ) {
|
776 |
+
return '';
|
777 |
+
}
|
778 |
+
|
779 |
+
$tax_array_temp = array();
|
780 |
+
$source_name = AWS_Helpers::get_source_name( $taxonomy );
|
781 |
+
|
782 |
+
foreach ( $terms as $term ) {
|
783 |
+
$source = $source_name . '%' . $term->term_id . '%';
|
784 |
+
$tax_array_temp[$source] = $term->name;
|
785 |
+
}
|
786 |
+
|
787 |
+
return $tax_array_temp;
|
788 |
+
|
789 |
+
}
|
790 |
+
|
791 |
+
/**
|
792 |
+
* Get product quantity
|
793 |
+
* @param object $product Product
|
794 |
+
* @return integer
|
795 |
+
*/
|
796 |
+
static public function get_quantity( $product ) {
|
797 |
+
|
798 |
+
$stock_levels = array();
|
799 |
+
|
800 |
+
if ( $product->is_type( 'variable' ) ) {
|
801 |
+
foreach ( $product->get_children() as $variation ) {
|
802 |
+
$var = wc_get_product( $variation );
|
803 |
+
$stock_levels[] = $var->get_stock_quantity();
|
804 |
+
}
|
805 |
+
} else {
|
806 |
+
$stock_levels[] = $product->get_stock_quantity();
|
807 |
+
}
|
808 |
+
|
809 |
+
return max( $stock_levels );
|
810 |
+
|
811 |
+
}
|
812 |
+
|
813 |
+
/**
|
814 |
+
* Get array of allowed tags for wp_kses function
|
815 |
+
* @param array $allowed_tags Tags that is allowed to display
|
816 |
+
* @return array $tags
|
817 |
+
*/
|
818 |
+
static public function get_kses( $allowed_tags = array() ) {
|
819 |
+
|
820 |
+
$tags = array(
|
821 |
+
'a' => array(
|
822 |
+
'href' => array(),
|
823 |
+
'title' => array()
|
824 |
+
),
|
825 |
+
'br' => array(),
|
826 |
+
'em' => array(),
|
827 |
+
'strong' => array(),
|
828 |
+
'b' => array(),
|
829 |
+
'code' => array(),
|
830 |
+
'blockquote' => array(
|
831 |
+
'cite' => array(),
|
832 |
+
),
|
833 |
+
'p' => array(),
|
834 |
+
'i' => array(),
|
835 |
+
'h1' => array(),
|
836 |
+
'h2' => array(),
|
837 |
+
'h3' => array(),
|
838 |
+
'h4' => array(),
|
839 |
+
'h5' => array(),
|
840 |
+
'h6' => array(),
|
841 |
+
'img' => array(
|
842 |
+
'alt' => array(),
|
843 |
+
'src' => array()
|
844 |
+
)
|
845 |
+
);
|
846 |
+
|
847 |
+
if ( is_array( $allowed_tags ) && ! empty( $allowed_tags ) ) {
|
848 |
+
foreach ( $tags as $tag => $tag_arr ) {
|
849 |
+
if ( array_search( $tag, $allowed_tags ) === false ) {
|
850 |
+
unset( $tags[$tag] );
|
851 |
+
}
|
852 |
+
}
|
853 |
+
|
854 |
+
}
|
855 |
+
|
856 |
+
return $tags;
|
857 |
+
|
858 |
+
}
|
859 |
+
|
860 |
+
/**
|
861 |
+
* Filter search page results by taxonomies
|
862 |
+
* @param array $product_terms Available product terms
|
863 |
+
* @param array $filter_terms Filter terms
|
864 |
+
* @param string $operator Operator
|
865 |
+
* @return bool $skip
|
866 |
+
*/
|
867 |
+
static public function page_filter_tax( $product_terms, $filter_terms, $operator = 'OR' ) {
|
868 |
+
|
869 |
+
$skip = true;
|
870 |
+
|
871 |
+
if ( $filter_terms && is_array( $filter_terms ) && ! empty( $filter_terms ) ) {
|
872 |
+
|
873 |
+
if ( $operator === 'AND' ) {
|
874 |
+
|
875 |
+
$has_all = true;
|
876 |
+
|
877 |
+
foreach( $filter_terms as $term ) {
|
878 |
+
if ( array_search( $term, $product_terms ) === false ) {
|
879 |
+
$has_all = false;
|
880 |
+
break;
|
881 |
+
}
|
882 |
+
}
|
883 |
+
|
884 |
+
if ( $has_all ) {
|
885 |
+
$skip = false;
|
886 |
+
}
|
887 |
+
|
888 |
+
}
|
889 |
+
|
890 |
+
if ( $operator === 'IN' || $operator === 'OR' ) {
|
891 |
+
|
892 |
+
$has_all = false;
|
893 |
+
|
894 |
+
foreach( $filter_terms as $term ) {
|
895 |
+
if ( array_search( $term, $product_terms ) !== false ) {
|
896 |
+
$has_all = true;
|
897 |
+
break;
|
898 |
+
}
|
899 |
+
}
|
900 |
+
|
901 |
+
if ( $has_all ) {
|
902 |
+
$skip = false;
|
903 |
+
}
|
904 |
+
|
905 |
+
}
|
906 |
+
|
907 |
+
}
|
908 |
+
|
909 |
+
return $skip;
|
910 |
+
|
911 |
+
}
|
912 |
+
|
913 |
+
/**
|
914 |
+
* Get array of index table options
|
915 |
+
* @return array $options
|
916 |
+
*/
|
917 |
+
static public function get_index_options() {
|
918 |
+
|
919 |
+
/**
|
920 |
+
* Apply or not WP filters to indexed content
|
921 |
+
* @since 1.82
|
922 |
+
* @param bool false
|
923 |
+
*/
|
924 |
+
$apply_filters = apply_filters( 'aws_index_apply_filters', false );
|
925 |
+
|
926 |
+
$index_variations_option = AWS()->get_settings( 'index_variations' );
|
927 |
+
$index_sources_option = AWS()->get_settings( 'index_sources' );
|
928 |
+
|
929 |
+
$index_variations = $index_variations_option && $index_variations_option === 'false' ? false : true;
|
930 |
+
$index_title = is_array( $index_sources_option ) && isset( $index_sources_option['title'] ) && ! $index_sources_option['title'] ? false : true;
|
931 |
+
$index_content = is_array( $index_sources_option ) && isset( $index_sources_option['content'] ) && ! $index_sources_option['content'] ? false : true;
|
932 |
+
$index_sku = is_array( $index_sources_option ) && isset( $index_sources_option['sku'] ) && ! $index_sources_option['sku'] ? false : true;
|
933 |
+
$index_excerpt = is_array( $index_sources_option ) && isset( $index_sources_option['excerpt'] ) && ! $index_sources_option['excerpt'] ? false : true;
|
934 |
+
$index_category = is_array( $index_sources_option ) && isset( $index_sources_option['category'] ) && ! $index_sources_option['category'] ? false : true;
|
935 |
+
$index_tag = is_array( $index_sources_option ) && isset( $index_sources_option['tag'] ) && ! $index_sources_option['tag'] ? false : true;
|
936 |
+
$index_id = is_array( $index_sources_option ) && isset( $index_sources_option['id'] ) && ! $index_sources_option['id'] ? false : true;
|
937 |
+
|
938 |
+
$index_vars = array(
|
939 |
+
'variations' => $index_variations,
|
940 |
+
'title' => $index_title,
|
941 |
+
'content' => $index_content,
|
942 |
+
'sku' => $index_sku,
|
943 |
+
'excerpt' => $index_excerpt,
|
944 |
+
'category' => $index_category,
|
945 |
+
'tag' => $index_tag,
|
946 |
+
'id' => $index_id,
|
947 |
+
);
|
948 |
+
|
949 |
+
$options = array(
|
950 |
+
'apply_filters' => $apply_filters,
|
951 |
+
'index' => $index_vars,
|
952 |
+
);
|
953 |
+
|
954 |
+
return $options;
|
955 |
+
|
956 |
+
}
|
957 |
+
|
958 |
+
}
|
959 |
+
|
960 |
endif;
|
includes/class-aws-integrations.php
CHANGED
@@ -1,1938 +1,1950 @@
|
|
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 Current theme name
|
21 |
-
*/
|
22 |
-
private $current_theme = '';
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var AWS_Integrations The single instance of the class
|
26 |
-
*/
|
27 |
-
protected static $_instance = null;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* Main AWS_Integrations Instance
|
31 |
-
*
|
32 |
-
* Ensures only one instance of AWS_Integrations is loaded or can be loaded.
|
33 |
-
*
|
34 |
-
* @static
|
35 |
-
* @return AWS_Integrations - Main instance
|
36 |
-
*/
|
37 |
-
public static function instance() {
|
38 |
-
if ( is_null( self::$_instance ) ) {
|
39 |
-
self::$_instance = new self();
|
40 |
-
}
|
41 |
-
return self::$_instance;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Constructor
|
46 |
-
*/
|
47 |
-
public function __construct() {
|
48 |
-
|
49 |
-
$theme = function_exists( 'wp_get_theme' ) ? wp_get_theme() : false;
|
50 |
-
|
51 |
-
if ( $theme ) {
|
52 |
-
$this->current_theme = $theme->get( 'Name' );
|
53 |
-
$this->child_theme = $theme->get( 'Name' );
|
54 |
-
if ( $theme->parent() ) {
|
55 |
-
$this->current_theme = $theme->parent()->get( 'Name' );
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
$this->includes();
|
60 |
-
|
61 |
-
//add_action('woocommerce_product_query', array( $this, 'woocommerce_product_query' ) );
|
62 |
-
|
63 |
-
if ( class_exists( 'BM' ) ) {
|
64 |
-
add_action( 'aws_search_start', array( $this, 'b2b_set_filter' ) );
|
65 |
-
}
|
66 |
-
|
67 |
-
// Protected categories
|
68 |
-
if ( class_exists( 'WC_PPC_Util' )
|
69 |
-
&& method_exists( 'WC_PPC_Util', 'showing_protected_categories' )
|
70 |
-
&& method_exists( 'WC_PPC_Util', 'to_category_visibilities' )
|
71 |
-
&& method_exists( 'WC_PPC_Util', 'get_product_categories' )
|
72 |
-
) {
|
73 |
-
add_action( 'aws_search_start', array( $this, 'wc_ppc_set_filter' ) );
|
74 |
-
}
|
75 |
-
|
76 |
-
if ( function_exists( 'dfrapi_currency_code_to_sign' ) ) {
|
77 |
-
add_filter( 'woocommerce_currency_symbol', array( $this, 'dfrapi_set_currency_symbol_filter' ), 10, 2 );
|
78 |
-
}
|
79 |
-
|
80 |
-
// WC Marketplace - https://wc-marketplace.com/
|
81 |
-
if ( defined( 'WCMp_PLUGIN_VERSION' ) ) {
|
82 |
-
add_filter( 'aws_search_data_params', array( $this, 'wc_marketplace_filter' ), 10, 3 );
|
83 |
-
add_filter( 'aws_search_pre_filter_products', array( $this, 'wc_marketplace_products_filter' ), 10, 2 );
|
84 |
-
}
|
85 |
-
|
86 |
-
// Maya shop theme
|
87 |
-
if ( defined( 'YIW_THEME_PATH' ) ) {
|
88 |
-
add_action( 'wp_head', array( $this, 'myashop_head_action' ) );
|
89 |
-
}
|
90 |
-
|
91 |
-
add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) );
|
92 |
-
add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) );
|
93 |
-
|
94 |
-
// Seamless integration
|
95 |
-
if ( AWS()->get_settings( 'seamless' ) === 'true' ) {
|
96 |
-
|
97 |
-
add_filter( 'aws_js_seamless_selectors', array( $this, 'js_seamless_selectors' ) );
|
98 |
-
|
99 |
-
add_filter( 'et_html_main_header', array( $this, 'et_html_main_header' ) );
|
100 |
-
add_filter( 'et_html_slide_header', array( $this, 'et_html_main_header' ) );
|
101 |
-
add_filter( 'generate_navigation_search_output', array( $this, 'generate_navigation_search_output' ) );
|
102 |
-
add_filter( 'et_pb_search_shortcode_output', array( $this, 'divi_builder_search_module' ) );
|
103 |
-
add_filter( 'et_pb_menu_shortcode_output', array( $this, 'divi_builder_search_module' ) );
|
104 |
-
add_filter( 'et_pb_fullwidth_menu_shortcode_output', array( $this, 'divi_builder_search_module' ) );
|
105 |
-
|
106 |
-
// Ocean wp theme
|
107 |
-
if ( class_exists( 'OCEANWP_Theme_Class' ) ) {
|
108 |
-
add_action( 'wp_head', array( $this, 'oceanwp_head_action' ) );
|
109 |
-
}
|
110 |
-
|
111 |
-
// Avada theme
|
112 |
-
if ( class_exists( 'Avada' ) ) {
|
113 |
-
add_action( 'wp_head', array( $this, 'avada_head_action' ) );
|
114 |
-
}
|
115 |
-
|
116 |
-
// Twenty Twenty theme
|
117 |
-
if ( function_exists( 'twentytwenty_theme_support' ) ) {
|
118 |
-
add_action( 'wp_head', array( $this, 'twenty_twenty_head_action' ) );
|
119 |
-
}
|
120 |
-
|
121 |
-
if ( 'Jupiter' === $this->current_theme ) {
|
122 |
-
add_action( 'wp_head', array( $this, 'jupiter_head_action' ) );
|
123 |
-
}
|
124 |
-
|
125 |
-
if ( 'Woodmart' === $this->current_theme ) {
|
126 |
-
add_action( 'wp_head', array( $this, 'woodmart_head_action' ) );
|
127 |
-
}
|
128 |
-
|
129 |
-
if ( 'Astra' === $this->current_theme ) {
|
130 |
-
add_filter( 'astra_get_search_form', array( $this, 'astra_markup' ), 999999 );
|
131 |
-
add_action( 'wp_head', array( $this, 'astra_head_action' ) );
|
132 |
-
}
|
133 |
-
|
134 |
-
if ( 'Storefront' === $this->current_theme ) {
|
135 |
-
add_action( 'wp_footer', array( $this, 'storefront_footer_action' ) );
|
136 |
-
}
|
137 |
-
|
138 |
-
if ( 'Elessi Theme' === $this->current_theme ) {
|
139 |
-
add_action( 'wp_head', array( $this, 'elessi_head_action' ) );
|
140 |
-
}
|
141 |
-
|
142 |
-
if ( 'Walker' === $this->current_theme ) {
|
143 |
-
add_action( 'wp_head', array( $this, 'walker_head_action' ) );
|
144 |
-
}
|
145 |
-
|
146 |
-
if ( 'Porto' === $this->current_theme ) {
|
147 |
-
add_filter( 'porto_search_form_content', array( $this, 'porto_search_form_content_filter' ) );
|
148 |
-
add_action( 'wp_head', array( $this, 'porto_head_action' ) );
|
149 |
-
}
|
150 |
-
|
151 |
-
if ( 'BoxShop' === $this->current_theme ) {
|
152 |
-
add_action( 'wp_head', array( $this, 'boxshop_head_action' ) );
|
153 |
-
}
|
154 |
-
|
155 |
-
if ( 'Aurum' === $this->current_theme ) {
|
156 |
-
add_filter( 'aurum_show_search_field_on_mobile', '__return_false' );
|
157 |
-
add_filter( 'wp_nav_menu', array( $this, 'aurum_mobile_menu' ), 10, 2 );
|
158 |
-
add_filter( 'aws_js_seamless_searchbox_markup', array( $this, 'aurum_seamless_searchbox_markup' ), 1 );
|
159 |
-
add_action( 'wp_head', array( $this, 'aurum_wp_head' ) );
|
160 |
-
}
|
161 |
-
|
162 |
-
if ( '
|
163 |
-
add_filter( 'aws_searchbox_markup', array( $this, '
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
add_action( '
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
add_action( 'wp_head', array( $this, '
|
179 |
-
}
|
180 |
-
|
181 |
-
if ( '
|
182 |
-
add_action( 'wp_head', array( $this, '
|
183 |
-
}
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
if ( '
|
224 |
-
add_filter(
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
add_filter( '
|
231 |
-
}
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
$
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
$
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
$
|
406 |
-
'
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
'
|
411 |
-
'
|
412 |
-
'
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
if (
|
446 |
-
return $currency_symbol;
|
447 |
-
}
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
$
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
$
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
.oceanwp-theme #searchform-
|
588 |
-
|
589 |
-
top:
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
#
|
606 |
-
|
607 |
-
}
|
608 |
-
#medium-searchform .aws-container
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
#
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
.mk-fullscreen-search-overlay .aws-container .aws-search-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
color:
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
}
|
770 |
-
|
771 |
-
.mk-header .
|
772 |
-
|
773 |
-
}
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
}
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
searchForm
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
text-
|
995 |
-
}
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
$
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
#header .aws-container
|
1025 |
-
border:
|
1026 |
-
|
1027 |
-
}
|
1028 |
-
#header .aws-container .aws-search-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
}
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
|
1039 |
-
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
$
|
1080 |
-
$markup =
|
1081 |
-
$markup =
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
}
|
1213 |
-
|
1214 |
-
/*
|
1215 |
-
* Claue theme
|
1216 |
-
*/
|
1217 |
-
public function
|
1218 |
-
<
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
#
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
|
1256 |
-
|
1257 |
-
|
1258 |
-
|
1259 |
-
|
1260 |
-
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
.
|
1272 |
-
|
1273 |
-
|
1274 |
-
|
1275 |
-
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
}
|
1301 |
-
|
1302 |
-
/*
|
1303 |
-
* Exclude
|
1304 |
-
*/
|
1305 |
-
public function
|
1306 |
-
if ( isset( $this->data['
|
1307 |
-
foreach( $this->data['
|
1308 |
-
$exclude[] = $to_exclude;
|
1309 |
-
}
|
1310 |
-
}
|
1311 |
-
return $exclude;
|
1312 |
-
}
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
'
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
$query_args_options
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
$html = '
|
1377 |
-
$html
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
$html =
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
$
|
1400 |
-
$
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
}
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
$selectors[] = '
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
$selectors[] = '.
|
1447 |
-
}
|
1448 |
-
|
1449 |
-
if ( '
|
1450 |
-
$selectors[] = '.
|
1451 |
-
}
|
1452 |
-
|
1453 |
-
if ( '
|
1454 |
-
$selectors[] = '#
|
1455 |
-
}
|
1456 |
-
|
1457 |
-
if ( '
|
1458 |
-
$selectors[] = '.
|
1459 |
-
}
|
1460 |
-
|
1461 |
-
if ( '
|
1462 |
-
$selectors[] = 'header .
|
1463 |
-
}
|
1464 |
-
|
1465 |
-
if ( '
|
1466 |
-
$selectors[] = '#
|
1467 |
-
}
|
1468 |
-
|
1469 |
-
if ( '
|
1470 |
-
$selectors[] = '
|
1471 |
-
}
|
1472 |
-
|
1473 |
-
if ( '
|
1474 |
-
$selectors[] = '
|
1475 |
-
}
|
1476 |
-
|
1477 |
-
if ( '
|
1478 |
-
$selectors[] = '
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
|
1528 |
-
|
1529 |
-
|
1530 |
-
|
1531 |
-
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
|
1569 |
-
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
}
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
|
1585 |
-
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
$
|
1629 |
-
|
1630 |
-
$
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
$
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
}
|
1672 |
-
|
1673 |
-
|
1674 |
-
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
case '
|
1705 |
-
$order_by_new = '
|
1706 |
-
break;
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
}
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
if (
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
if (
|
1777 |
-
$
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
|
1815 |
-
|
1816 |
-
|
1817 |
-
|
1818 |
-
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
}
|
1827 |
-
|
1828 |
-
/*
|
1829 |
-
* WooCommerce Product Filter by WooBeWoo:
|
1830 |
-
*/
|
1831 |
-
public function
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
|
1845 |
-
$
|
1846 |
-
|
1847 |
-
|
1848 |
-
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
if ( strpos($key, '
|
1860 |
-
|
1861 |
-
$idsAnd = explode(',', $param);
|
1862 |
-
$idsOr = explode('|', $param);
|
1863 |
-
$isAnd = count($idsAnd) > count($idsOr);
|
1864 |
-
$operator = $isAnd ? 'AND' : 'OR';
|
1865 |
-
$filters['tax']['
|
1866 |
-
'terms' => $isAnd ? $idsAnd : $idsOr,
|
1867 |
-
'operator' => $operator
|
1868 |
-
);
|
1869 |
-
}
|
1870 |
-
|
1871 |
-
if ( strpos($key, '
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
return $
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
$
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
|
1927 |
-
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
|
1934 |
-
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1938 |
endif;
|
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 Current theme name
|
21 |
+
*/
|
22 |
+
private $current_theme = '';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var AWS_Integrations The single instance of the class
|
26 |
+
*/
|
27 |
+
protected static $_instance = null;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Main AWS_Integrations Instance
|
31 |
+
*
|
32 |
+
* Ensures only one instance of AWS_Integrations is loaded or can be loaded.
|
33 |
+
*
|
34 |
+
* @static
|
35 |
+
* @return AWS_Integrations - Main instance
|
36 |
+
*/
|
37 |
+
public static function instance() {
|
38 |
+
if ( is_null( self::$_instance ) ) {
|
39 |
+
self::$_instance = new self();
|
40 |
+
}
|
41 |
+
return self::$_instance;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Constructor
|
46 |
+
*/
|
47 |
+
public function __construct() {
|
48 |
+
|
49 |
+
$theme = function_exists( 'wp_get_theme' ) ? wp_get_theme() : false;
|
50 |
+
|
51 |
+
if ( $theme ) {
|
52 |
+
$this->current_theme = $theme->get( 'Name' );
|
53 |
+
$this->child_theme = $theme->get( 'Name' );
|
54 |
+
if ( $theme->parent() ) {
|
55 |
+
$this->current_theme = $theme->parent()->get( 'Name' );
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
$this->includes();
|
60 |
+
|
61 |
+
//add_action('woocommerce_product_query', array( $this, 'woocommerce_product_query' ) );
|
62 |
+
|
63 |
+
if ( class_exists( 'BM' ) ) {
|
64 |
+
add_action( 'aws_search_start', array( $this, 'b2b_set_filter' ) );
|
65 |
+
}
|
66 |
+
|
67 |
+
// Protected categories
|
68 |
+
if ( class_exists( 'WC_PPC_Util' )
|
69 |
+
&& method_exists( 'WC_PPC_Util', 'showing_protected_categories' )
|
70 |
+
&& method_exists( 'WC_PPC_Util', 'to_category_visibilities' )
|
71 |
+
&& method_exists( 'WC_PPC_Util', 'get_product_categories' )
|
72 |
+
) {
|
73 |
+
add_action( 'aws_search_start', array( $this, 'wc_ppc_set_filter' ) );
|
74 |
+
}
|
75 |
+
|
76 |
+
if ( function_exists( 'dfrapi_currency_code_to_sign' ) ) {
|
77 |
+
add_filter( 'woocommerce_currency_symbol', array( $this, 'dfrapi_set_currency_symbol_filter' ), 10, 2 );
|
78 |
+
}
|
79 |
+
|
80 |
+
// WC Marketplace - https://wc-marketplace.com/
|
81 |
+
if ( defined( 'WCMp_PLUGIN_VERSION' ) ) {
|
82 |
+
add_filter( 'aws_search_data_params', array( $this, 'wc_marketplace_filter' ), 10, 3 );
|
83 |
+
add_filter( 'aws_search_pre_filter_products', array( $this, 'wc_marketplace_products_filter' ), 10, 2 );
|
84 |
+
}
|
85 |
+
|
86 |
+
// Maya shop theme
|
87 |
+
if ( defined( 'YIW_THEME_PATH' ) ) {
|
88 |
+
add_action( 'wp_head', array( $this, 'myashop_head_action' ) );
|
89 |
+
}
|
90 |
+
|
91 |
+
add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) );
|
92 |
+
add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) );
|
93 |
+
|
94 |
+
// Seamless integration
|
95 |
+
if ( AWS()->get_settings( 'seamless' ) === 'true' ) {
|
96 |
+
|
97 |
+
add_filter( 'aws_js_seamless_selectors', array( $this, 'js_seamless_selectors' ) );
|
98 |
+
|
99 |
+
add_filter( 'et_html_main_header', array( $this, 'et_html_main_header' ) );
|
100 |
+
add_filter( 'et_html_slide_header', array( $this, 'et_html_main_header' ) );
|
101 |
+
add_filter( 'generate_navigation_search_output', array( $this, 'generate_navigation_search_output' ) );
|
102 |
+
add_filter( 'et_pb_search_shortcode_output', array( $this, 'divi_builder_search_module' ) );
|
103 |
+
add_filter( 'et_pb_menu_shortcode_output', array( $this, 'divi_builder_search_module' ) );
|
104 |
+
add_filter( 'et_pb_fullwidth_menu_shortcode_output', array( $this, 'divi_builder_search_module' ) );
|
105 |
+
|
106 |
+
// Ocean wp theme
|
107 |
+
if ( class_exists( 'OCEANWP_Theme_Class' ) ) {
|
108 |
+
add_action( 'wp_head', array( $this, 'oceanwp_head_action' ) );
|
109 |
+
}
|
110 |
+
|
111 |
+
// Avada theme
|
112 |
+
if ( class_exists( 'Avada' ) ) {
|
113 |
+
add_action( 'wp_head', array( $this, 'avada_head_action' ) );
|
114 |
+
}
|
115 |
+
|
116 |
+
// Twenty Twenty theme
|
117 |
+
if ( function_exists( 'twentytwenty_theme_support' ) ) {
|
118 |
+
add_action( 'wp_head', array( $this, 'twenty_twenty_head_action' ) );
|
119 |
+
}
|
120 |
+
|
121 |
+
if ( 'Jupiter' === $this->current_theme ) {
|
122 |
+
add_action( 'wp_head', array( $this, 'jupiter_head_action' ) );
|
123 |
+
}
|
124 |
+
|
125 |
+
if ( 'Woodmart' === $this->current_theme ) {
|
126 |
+
add_action( 'wp_head', array( $this, 'woodmart_head_action' ) );
|
127 |
+
}
|
128 |
+
|
129 |
+
if ( 'Astra' === $this->current_theme ) {
|
130 |
+
add_filter( 'astra_get_search_form', array( $this, 'astra_markup' ), 999999 );
|
131 |
+
add_action( 'wp_head', array( $this, 'astra_head_action' ) );
|
132 |
+
}
|
133 |
+
|
134 |
+
if ( 'Storefront' === $this->current_theme ) {
|
135 |
+
add_action( 'wp_footer', array( $this, 'storefront_footer_action' ) );
|
136 |
+
}
|
137 |
+
|
138 |
+
if ( 'Elessi Theme' === $this->current_theme ) {
|
139 |
+
add_action( 'wp_head', array( $this, 'elessi_head_action' ) );
|
140 |
+
}
|
141 |
+
|
142 |
+
if ( 'Walker' === $this->current_theme ) {
|
143 |
+
add_action( 'wp_head', array( $this, 'walker_head_action' ) );
|
144 |
+
}
|
145 |
+
|
146 |
+
if ( 'Porto' === $this->current_theme ) {
|
147 |
+
add_filter( 'porto_search_form_content', array( $this, 'porto_search_form_content_filter' ) );
|
148 |
+
add_action( 'wp_head', array( $this, 'porto_head_action' ) );
|
149 |
+
}
|
150 |
+
|
151 |
+
if ( 'BoxShop' === $this->current_theme ) {
|
152 |
+
add_action( 'wp_head', array( $this, 'boxshop_head_action' ) );
|
153 |
+
}
|
154 |
+
|
155 |
+
if ( 'Aurum' === $this->current_theme ) {
|
156 |
+
add_filter( 'aurum_show_search_field_on_mobile', '__return_false' );
|
157 |
+
add_filter( 'wp_nav_menu', array( $this, 'aurum_mobile_menu' ), 10, 2 );
|
158 |
+
add_filter( 'aws_js_seamless_searchbox_markup', array( $this, 'aurum_seamless_searchbox_markup' ), 1 );
|
159 |
+
add_action( 'wp_head', array( $this, 'aurum_wp_head' ) );
|
160 |
+
}
|
161 |
+
|
162 |
+
if ( 'Woostify' === $this->current_theme ) {
|
163 |
+
add_filter( 'aws_searchbox_markup', array( $this, 'woostify_aws_searchbox_markup' ), 1 );
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( 'Fury' === $this->current_theme ) {
|
167 |
+
add_filter( 'aws_searchbox_markup', array( $this, 'fury_searchbox_markup' ) );
|
168 |
+
add_action( 'wp_head', array( $this, 'fury_wp_head' ) );
|
169 |
+
}
|
170 |
+
|
171 |
+
if ( 'Bazar' === $this->current_theme ) {
|
172 |
+
add_action( 'yit_header-cart-search_after', array( $this, 'bazar_add_header_form' ) );
|
173 |
+
add_action( 'wp_head', array( $this, 'bazar_wp_head' ) );
|
174 |
+
}
|
175 |
+
|
176 |
+
if ( 'Claue' === $this->current_theme ) {
|
177 |
+
add_filter( 'jas_claue_header', array( $this, 'claue_header' ) );
|
178 |
+
add_action( 'wp_head', array( $this, 'claue_wp_head' ) );
|
179 |
+
}
|
180 |
+
|
181 |
+
if ( 'Salient' === $this->current_theme ) {
|
182 |
+
add_action( 'wp_head', array( $this, 'salient_wp_head' ) );
|
183 |
+
}
|
184 |
+
|
185 |
+
if ( 'Royal' === $this->current_theme ) {
|
186 |
+
add_action( 'wp_head', array( $this, 'royal_wp_head' ) );
|
187 |
+
}
|
188 |
+
|
189 |
+
}
|
190 |
+
|
191 |
+
add_action( 'wp_head', array( $this, 'head_js_integration' ) );
|
192 |
+
|
193 |
+
// Search Exclude plugin
|
194 |
+
if ( class_exists( 'SearchExclude' ) ) {
|
195 |
+
add_filter( 'aws_index_product_ids', array( $this, 'search_exclude_filter' ) );
|
196 |
+
}
|
197 |
+
|
198 |
+
// WooCommerce Product Table plugin
|
199 |
+
if ( class_exists( 'WC_Product_Table_Plugin' ) ) {
|
200 |
+
add_filter( 'wc_product_table_data_config', array( $this, 'wc_product_table_data_config' ) );
|
201 |
+
add_filter( 'aws_posts_per_page', array( $this, 'wc_product_table_posts_per_page' ) );
|
202 |
+
}
|
203 |
+
|
204 |
+
// Flatsome theme remove search page blocl
|
205 |
+
if ( isset( $_GET['type_aws'] ) && function_exists( 'flatsome_pages_in_search_results' ) ) {
|
206 |
+
remove_action('woocommerce_after_main_content','flatsome_pages_in_search_results', 10);
|
207 |
+
}
|
208 |
+
|
209 |
+
// Divi builder dynamic text shortcodes
|
210 |
+
if ( defined( 'ET_BUILDER_PLUGIN_DIR' ) ) {
|
211 |
+
add_filter( 'aws_before_strip_shortcodes', array( $this, 'divi_builder_strip_shortcodes' ) );
|
212 |
+
}
|
213 |
+
|
214 |
+
// WP all import finish
|
215 |
+
//add_action( 'pmxi_after_xml_import', array( $this, 'pmxi_after_xml_import' ) );
|
216 |
+
|
217 |
+
// BeRocket WooCommerce AJAX Products Filter
|
218 |
+
if ( defined( 'BeRocket_AJAX_filters_version' ) ) {
|
219 |
+
add_filter( 'aws_search_page_filters', array( $this, 'berocket_search_page_filters' ) );
|
220 |
+
}
|
221 |
+
|
222 |
+
// Product Sort and Display for WooCommerce plugin
|
223 |
+
if ( defined( 'WC_PSAD_NAME' ) ) {
|
224 |
+
add_filter( "option_psad_shop_page_enable", array( $this, 'psad_filter' ) );
|
225 |
+
}
|
226 |
+
|
227 |
+
if ( 'Avada' === $this->current_theme ) {
|
228 |
+
add_filter( 'aws_posts_per_page', array( $this, 'avada_posts_per_page' ), 1 );
|
229 |
+
add_filter( 'aws_products_order_by', array( $this, 'avada_aws_products_order_by' ), 1 );
|
230 |
+
add_filter( 'post_class', array( $this, 'avada_post_class' ) );
|
231 |
+
}
|
232 |
+
|
233 |
+
if ( 'Electro' === $this->current_theme ) {
|
234 |
+
add_filter( 'aws_searchbox_markup', array( $this, 'electro_searchbox_markup' ), 1, 2 );
|
235 |
+
}
|
236 |
+
|
237 |
+
// FacetWP plugin
|
238 |
+
if ( class_exists( 'FacetWP' ) ) {
|
239 |
+
add_filter( 'facetwp_filtered_post_ids', array( $this, 'facetwp_filtered_post_ids' ), 1 );
|
240 |
+
add_filter( 'aws_searchpage_enabled', array( $this, 'facetwp_aws_searchpage_enabled' ), 1 );
|
241 |
+
}
|
242 |
+
|
243 |
+
// Product Visibility by User Role for WooCommerce plugin
|
244 |
+
if ( class_exists( 'Alg_WC_PVBUR' ) ) {
|
245 |
+
add_filter( 'aws_search_results_products', array( $this, 'pvbur_aws_search_results_products' ), 1 );
|
246 |
+
}
|
247 |
+
|
248 |
+
// WooCommerce Product Filter by WooBeWoo
|
249 |
+
if ( defined( 'WPF_PLUG_NAME' ) ) {
|
250 |
+
add_filter( 'wpf_addHtmlBeforeFilter', array( $this, 'wpf_add_html_before_filter' ) );
|
251 |
+
add_filter( 'aws_search_page_custom_data', array( $this, 'wpf_search_page_custom_data' ) );
|
252 |
+
add_filter( 'aws_search_page_filters', array( $this, 'wpf_search_page_filters' ) );
|
253 |
+
}
|
254 |
+
|
255 |
+
// ATUM Inventory Management for WooCommerce plugin ( Product level addon )
|
256 |
+
if ( class_exists( 'AtumProductLevelsAddon' ) ) {
|
257 |
+
add_filter( 'aws_indexed_data', array( $this, 'atum_index_data' ), 10, 2 );
|
258 |
+
}
|
259 |
+
|
260 |
+
// Popups for Divi plugin
|
261 |
+
if ( defined( 'DIVI_POPUP_PLUGIN' ) ) {
|
262 |
+
add_action( 'wp_enqueue_scripts', array( $this, 'divi_popups_enqueue_scripts' ), 999 );
|
263 |
+
}
|
264 |
+
|
265 |
+
// WooCommerce Catalog Visibility Options plugin
|
266 |
+
if ( class_exists( 'WC_Catalog_Restrictions_Query' ) ) {
|
267 |
+
add_filter( 'aws_exclude_products', array( $this, 'wcvo_exclude_products' ), 1 );
|
268 |
+
}
|
269 |
+
|
270 |
+
}
|
271 |
+
|
272 |
+
/**
|
273 |
+
* Include files
|
274 |
+
*/
|
275 |
+
public function includes() {
|
276 |
+
|
277 |
+
// Getenberg block
|
278 |
+
if ( function_exists( 'register_block_type' ) ) {
|
279 |
+
include_once( AWS_DIR . '/includes/modules/gutenberg/class-aws-gutenberg-init.php' );
|
280 |
+
}
|
281 |
+
|
282 |
+
// Elementor plugin widget
|
283 |
+
if ( defined( 'ELEMENTOR_VERSION' ) || defined( 'ELEMENTOR_PRO_VERSION' ) ) {
|
284 |
+
include_once( AWS_DIR . '/includes/modules/elementor-widget/class-elementor-aws-init.php' );
|
285 |
+
}
|
286 |
+
|
287 |
+
// Divi module
|
288 |
+
if ( defined( 'ET_BUILDER_PLUGIN_DIR' ) || function_exists( 'et_setup_theme' ) ) {
|
289 |
+
include_once( AWS_DIR . '/includes/modules/divi/class-divi-aws-module.php' );
|
290 |
+
}
|
291 |
+
|
292 |
+
// Beaver builder module
|
293 |
+
if ( class_exists( 'FLBuilder' ) ) {
|
294 |
+
include_once( AWS_DIR . '/includes/modules/bb-aws-search/class-aws-bb-module.php' );
|
295 |
+
}
|
296 |
+
|
297 |
+
// WCFM - WooCommerce Multivendor Marketplace
|
298 |
+
if ( class_exists( 'WCFMmp' ) ) {
|
299 |
+
include_once( AWS_DIR . '/includes/modules/class-aws-wcfm.php' );
|
300 |
+
AWS_WCFM::instance();
|
301 |
+
}
|
302 |
+
|
303 |
+
// WOOF - WooCommerce Products Filter
|
304 |
+
if ( defined( 'WOOF_PLUGIN_NAME' ) ) {
|
305 |
+
include_once( AWS_DIR . '/includes/modules/class-aws-woof-filter.php' );
|
306 |
+
}
|
307 |
+
|
308 |
+
// Ultimate Member plugin hide certain products
|
309 |
+
if ( class_exists( 'UM_Functions' ) ) {
|
310 |
+
include_once( AWS_DIR . '/includes/modules/class-aws-um.php' );
|
311 |
+
}
|
312 |
+
|
313 |
+
// Wholesale plugin
|
314 |
+
if ( class_exists( 'WooCommerceWholeSalePrices' ) ) {
|
315 |
+
include_once( AWS_DIR . '/includes/modules/class-aws-wholesale.php' );
|
316 |
+
}
|
317 |
+
|
318 |
+
}
|
319 |
+
|
320 |
+
/*
|
321 |
+
* B2B market plugin
|
322 |
+
*/
|
323 |
+
public function b2b_set_filter() {
|
324 |
+
|
325 |
+
$args = array(
|
326 |
+
'posts_per_page' => - 1,
|
327 |
+
'post_type' => 'customer_groups',
|
328 |
+
'post_status' => 'publish',
|
329 |
+
);
|
330 |
+
|
331 |
+
$posts = get_posts( $args );
|
332 |
+
$customer_groups = array();
|
333 |
+
$user_role = '';
|
334 |
+
|
335 |
+
foreach ( $posts as $customer_group ) {
|
336 |
+
$customer_groups[$customer_group->post_name] = $customer_group->ID;
|
337 |
+
}
|
338 |
+
|
339 |
+
if ( is_user_logged_in() ) {
|
340 |
+
$user = wp_get_current_user();
|
341 |
+
$role = ( array ) $user->roles;
|
342 |
+
$user_role = $role[0];
|
343 |
+
} else {
|
344 |
+
$guest_slugs = array( 'Gast', 'Gäste', 'Guest', 'Guests', 'gast', 'gäste', 'guest', 'guests' );
|
345 |
+
foreach( $customer_groups as $customer_group_key => $customer_group_id ) {
|
346 |
+
if ( in_array( $customer_group_key, $guest_slugs ) ) {
|
347 |
+
$user_role = $customer_group_key;
|
348 |
+
}
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
if ( $user_role ) {
|
353 |
+
|
354 |
+
if ( isset( $customer_groups[$user_role] ) ) {
|
355 |
+
$curret_customer_group_id = $customer_groups[$user_role];
|
356 |
+
|
357 |
+
$whitelist = get_post_meta( $curret_customer_group_id, 'bm_conditional_all_products', true );
|
358 |
+
|
359 |
+
if ( $whitelist && $whitelist === 'off' ) {
|
360 |
+
|
361 |
+
$products_to_exclude = get_post_meta( $curret_customer_group_id, 'bm_conditional_products', false );
|
362 |
+
$cats_to_exclude = get_post_meta( $curret_customer_group_id, 'bm_conditional_categories', false );
|
363 |
+
|
364 |
+
if ( $products_to_exclude && ! empty( $products_to_exclude ) ) {
|
365 |
+
|
366 |
+
foreach( $products_to_exclude as $product_to_exclude ) {
|
367 |
+
$this->data['exclude_products'][] = trim( $product_to_exclude, ',' );
|
368 |
+
}
|
369 |
+
|
370 |
+
}
|
371 |
+
|
372 |
+
if ( $cats_to_exclude && ! empty( $cats_to_exclude ) ) {
|
373 |
+
|
374 |
+
foreach( $cats_to_exclude as $cat_to_exclude ) {
|
375 |
+
$this->data['exclude_categories'][] = trim( $cat_to_exclude, ',' );
|
376 |
+
}
|
377 |
+
|
378 |
+
}
|
379 |
+
|
380 |
+
}
|
381 |
+
|
382 |
+
}
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
}
|
387 |
+
|
388 |
+
/*
|
389 |
+
* Protected categories plugin
|
390 |
+
*/
|
391 |
+
public function wc_ppc_set_filter() {
|
392 |
+
|
393 |
+
$hidden_categories = array();
|
394 |
+
$show_protected = WC_PPC_Util::showing_protected_categories();
|
395 |
+
|
396 |
+
// Get all the product categories, and check which are hidden.
|
397 |
+
foreach ( WC_PPC_Util::to_category_visibilities( WC_PPC_Util::get_product_categories() ) as $category ) {
|
398 |
+
if ( $category->is_private() || ( ! $show_protected && $category->is_protected() ) ) {
|
399 |
+
$hidden_categories[] = $category->term_id;
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
if ( $hidden_categories && ! empty( $hidden_categories ) ) {
|
404 |
+
|
405 |
+
foreach( $hidden_categories as $hidden_category ) {
|
406 |
+
$this->data['exclude_categories'][] = $hidden_category;
|
407 |
+
}
|
408 |
+
|
409 |
+
$args = array(
|
410 |
+
'posts_per_page' => -1,
|
411 |
+
'fields' => 'ids',
|
412 |
+
'post_type' => 'product',
|
413 |
+
'post_status' => 'publish',
|
414 |
+
'ignore_sticky_posts' => true,
|
415 |
+
'suppress_filters' => true,
|
416 |
+
'tax_query' => array(
|
417 |
+
array(
|
418 |
+
'taxonomy' => 'product_cat',
|
419 |
+
'field' => 'id',
|
420 |
+
'terms' => $hidden_categories
|
421 |
+
)
|
422 |
+
)
|
423 |
+
);
|
424 |
+
|
425 |
+
$exclude_products = get_posts( $args );
|
426 |
+
|
427 |
+
if ( $exclude_products && count( $exclude_products ) > 0 ) {
|
428 |
+
|
429 |
+
foreach( $exclude_products as $exclude_product ) {
|
430 |
+
$this->data['exclude_products'][] = $exclude_product;
|
431 |
+
}
|
432 |
+
|
433 |
+
}
|
434 |
+
|
435 |
+
}
|
436 |
+
|
437 |
+
}
|
438 |
+
|
439 |
+
/*
|
440 |
+
* Datafeedr WooCommerce Importer plugin
|
441 |
+
*/
|
442 |
+
public function dfrapi_set_currency_symbol_filter( $currency_symbol, $currency ) {
|
443 |
+
|
444 |
+
global $product;
|
445 |
+
if ( ! is_object( $product ) || ! isset( $product ) ) {
|
446 |
+
return $currency_symbol;
|
447 |
+
}
|
448 |
+
$fields = get_post_meta( $product->get_id(), '_dfrps_product', true );
|
449 |
+
if ( empty( $fields ) ) {
|
450 |
+
return $currency_symbol;
|
451 |
+
}
|
452 |
+
if ( ! isset( $fields['currency'] ) ) {
|
453 |
+
return $currency_symbol;
|
454 |
+
}
|
455 |
+
$currency_symbol = dfrapi_currency_code_to_sign( $fields['currency'] );
|
456 |
+
return $currency_symbol;
|
457 |
+
|
458 |
+
}
|
459 |
+
|
460 |
+
/*
|
461 |
+
* WC Marketplace plugin support
|
462 |
+
*/
|
463 |
+
public function wc_marketplace_filter( $data, $post_id, $product ) {
|
464 |
+
|
465 |
+
$wcmp_spmv_map_id = get_post_meta( $post_id, '_wcmp_spmv_map_id', true );
|
466 |
+
|
467 |
+
if ( $wcmp_spmv_map_id ) {
|
468 |
+
|
469 |
+
if ( isset( $data['wcmp_price'] ) && isset( $data['wcmp_price'][$wcmp_spmv_map_id] ) ) {
|
470 |
+
|
471 |
+
if ( $product->get_price() < $data['wcmp_price'][$wcmp_spmv_map_id] ) {
|
472 |
+
$data['wcmp_price'][$wcmp_spmv_map_id] = $product->get_price();
|
473 |
+
$data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] = $post_id;
|
474 |
+
}
|
475 |
+
|
476 |
+
} else {
|
477 |
+
$data['wcmp_price'][$wcmp_spmv_map_id] = $product->get_price();
|
478 |
+
}
|
479 |
+
|
480 |
+
$data['wcmp_spmv_product_id'][$wcmp_spmv_map_id][] = $post_id;
|
481 |
+
|
482 |
+
}
|
483 |
+
|
484 |
+
return $data;
|
485 |
+
|
486 |
+
}
|
487 |
+
|
488 |
+
/*
|
489 |
+
* WC Marketplace plugin products filter
|
490 |
+
*/
|
491 |
+
public function wc_marketplace_products_filter( $products_array, $data ) {
|
492 |
+
|
493 |
+
$wcmp_spmv_exclude_ids = array();
|
494 |
+
|
495 |
+
if ( isset( $data['wcmp_spmv_product_id'] ) ) {
|
496 |
+
|
497 |
+
foreach( $data['wcmp_spmv_product_id'] as $wcmp_spmv_map_id => $wcmp_spmv_product_id ) {
|
498 |
+
|
499 |
+
if ( count( $wcmp_spmv_product_id ) > 1 ) {
|
500 |
+
|
501 |
+
if ( isset( $data['wcmp_lowest_price_id'] ) && isset( $data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] ) ) {
|
502 |
+
|
503 |
+
foreach ( $wcmp_spmv_product_id as $wcmp_spmv_product_id_n ) {
|
504 |
+
|
505 |
+
if ( $wcmp_spmv_product_id_n === $data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] ) {
|
506 |
+
continue;
|
507 |
+
}
|
508 |
+
|
509 |
+
$wcmp_spmv_exclude_ids[] = $wcmp_spmv_product_id_n;
|
510 |
+
|
511 |
+
}
|
512 |
+
|
513 |
+
} else {
|
514 |
+
|
515 |
+
foreach ( $wcmp_spmv_product_id as $key => $wcmp_spmv_product_id_n ) {
|
516 |
+
|
517 |
+
if ( $key === 0 ) {
|
518 |
+
continue;
|
519 |
+
}
|
520 |
+
|
521 |
+
$wcmp_spmv_exclude_ids[] = $wcmp_spmv_product_id_n;
|
522 |
+
|
523 |
+
}
|
524 |
+
|
525 |
+
}
|
526 |
+
|
527 |
+
}
|
528 |
+
|
529 |
+
}
|
530 |
+
|
531 |
+
}
|
532 |
+
|
533 |
+
$new_product_array = array();
|
534 |
+
|
535 |
+
foreach( $products_array as $key => $pr_arr ) {
|
536 |
+
|
537 |
+
if ( ! in_array( $pr_arr['id'], $wcmp_spmv_exclude_ids ) ) {
|
538 |
+
$new_product_array[] = $pr_arr;
|
539 |
+
}
|
540 |
+
|
541 |
+
}
|
542 |
+
|
543 |
+
return $new_product_array;
|
544 |
+
|
545 |
+
}
|
546 |
+
|
547 |
+
/*
|
548 |
+
* Maya shop theme support
|
549 |
+
*/
|
550 |
+
public function myashop_head_action() { ?>
|
551 |
+
|
552 |
+
<style>
|
553 |
+
#header .aws-container {
|
554 |
+
margin: 0;
|
555 |
+
position: absolute;
|
556 |
+
right: 0;
|
557 |
+
bottom: 85px;
|
558 |
+
}
|
559 |
+
|
560 |
+
@media only screen and (max-width: 960px) {
|
561 |
+
#header .aws-container {
|
562 |
+
bottom: 118px !important;
|
563 |
+
right: 10px !important;
|
564 |
+
}
|
565 |
+
}
|
566 |
+
|
567 |
+
@media only screen and (max-width: 600px) {
|
568 |
+
#header .aws-container {
|
569 |
+
position: relative !important;
|
570 |
+
bottom: auto !important;
|
571 |
+
right: auto !important;
|
572 |
+
display: inline-block !important;
|
573 |
+
margin-top: 20px !important;
|
574 |
+
margin-bottom: 20px !important;
|
575 |
+
}
|
576 |
+
}
|
577 |
+
</style>
|
578 |
+
|
579 |
+
<?php }
|
580 |
+
|
581 |
+
/*
|
582 |
+
* Ocean wp theme
|
583 |
+
*/
|
584 |
+
public function oceanwp_head_action() { ?>
|
585 |
+
|
586 |
+
<style>
|
587 |
+
.oceanwp-theme #searchform-header-replace .aws-container {
|
588 |
+
padding-right: 45px;
|
589 |
+
padding-top: 15px;
|
590 |
+
}
|
591 |
+
.oceanwp-theme #searchform-overlay .aws-container {
|
592 |
+
position: absolute;
|
593 |
+
top: 50%;
|
594 |
+
left: 0;
|
595 |
+
margin-top: -33px;
|
596 |
+
width: 100%;
|
597 |
+
text-align: center;
|
598 |
+
}
|
599 |
+
.oceanwp-theme #searchform-overlay .aws-container form {
|
600 |
+
position: static;
|
601 |
+
}
|
602 |
+
.oceanwp-theme #searchform-overlay a.search-overlay-close {
|
603 |
+
top: -100px;
|
604 |
+
}
|
605 |
+
#sidr .aws-container {
|
606 |
+
margin: 30px 20px 0;
|
607 |
+
}
|
608 |
+
#medium-searchform .aws-container,
|
609 |
+
#vertical-searchform .aws-container {
|
610 |
+
background: #f5f5f5;
|
611 |
+
}
|
612 |
+
#medium-searchform .aws-container .aws-search-form .aws-search-field {
|
613 |
+
max-width: 100%;
|
614 |
+
}
|
615 |
+
#medium-searchform .aws-container .aws-search-form .aws-form-btn,
|
616 |
+
#vertical-searchform .aws-container .aws-search-form .aws-form-btn{
|
617 |
+
background: #f5f5f5;
|
618 |
+
border: none;
|
619 |
+
}
|
620 |
+
</style>
|
621 |
+
|
622 |
+
<script>
|
623 |
+
|
624 |
+
window.addEventListener('load', function() {
|
625 |
+
|
626 |
+
window.setTimeout(function(){
|
627 |
+
var formOverlay = document.querySelector("#searchform-overlay form");
|
628 |
+
if ( formOverlay ) {
|
629 |
+
formOverlay.innerHTML += '<a href="#" class="search-overlay-close"><span></span></a>';
|
630 |
+
}
|
631 |
+
}, 300);
|
632 |
+
|
633 |
+
jQuery(document).on( 'click', 'a.search-overlay-close', function (e) {
|
634 |
+
|
635 |
+
jQuery( '#searchform-overlay' ).removeClass( 'active' );
|
636 |
+
jQuery( '#searchform-overlay' ).fadeOut( 200 );
|
637 |
+
|
638 |
+
setTimeout( function() {
|
639 |
+
jQuery( 'html' ).css( 'overflow', 'visible' );
|
640 |
+
}, 400);
|
641 |
+
|
642 |
+
jQuery( '.aws-search-result' ).hide();
|
643 |
+
|
644 |
+
} );
|
645 |
+
|
646 |
+
}, false);
|
647 |
+
|
648 |
+
</script>
|
649 |
+
|
650 |
+
<?php }
|
651 |
+
|
652 |
+
/*
|
653 |
+
* Avada wp theme
|
654 |
+
*/
|
655 |
+
public function avada_head_action() { ?>
|
656 |
+
|
657 |
+
<style>
|
658 |
+
|
659 |
+
.fusion-flyout-search .aws-container {
|
660 |
+
margin: 0 auto;
|
661 |
+
padding: 0;
|
662 |
+
width: 100%;
|
663 |
+
width: calc(100% - 40px);
|
664 |
+
max-width: 600px;
|
665 |
+
position: absolute;
|
666 |
+
top: 40%;
|
667 |
+
left: 20px;
|
668 |
+
right: 20px;
|
669 |
+
}
|
670 |
+
|
671 |
+
</style>
|
672 |
+
|
673 |
+
<script>
|
674 |
+
|
675 |
+
window.addEventListener('load', function() {
|
676 |
+
var awsSearch = document.querySelectorAll(".fusion-menu .fusion-main-menu-search a, .fusion-flyout-menu-icons .fusion-icon-search");
|
677 |
+
if ( awsSearch ) {
|
678 |
+
for (var i = 0; i < awsSearch.length; i++) {
|
679 |
+
awsSearch[i].addEventListener('click', function() {
|
680 |
+
window.setTimeout(function(){
|
681 |
+
document.querySelector(".fusion-menu .fusion-main-menu-search .aws-search-field, .fusion-flyout-search .aws-search-field").focus();
|
682 |
+
}, 100);
|
683 |
+
}, false);
|
684 |
+
}
|
685 |
+
}
|
686 |
+
|
687 |
+
}, false);
|
688 |
+
|
689 |
+
</script>
|
690 |
+
|
691 |
+
<?php }
|
692 |
+
|
693 |
+
/*
|
694 |
+
* Twenty Twenty theme
|
695 |
+
*/
|
696 |
+
public function twenty_twenty_head_action() { ?>
|
697 |
+
|
698 |
+
<style>
|
699 |
+
|
700 |
+
.search-modal .aws-container {
|
701 |
+
width: 100%;
|
702 |
+
margin: 20px 0;
|
703 |
+
}
|
704 |
+
|
705 |
+
</style>
|
706 |
+
|
707 |
+
<script>
|
708 |
+
|
709 |
+
window.addEventListener('load', function() {
|
710 |
+
|
711 |
+
var awsSearch = document.querySelectorAll("#site-header .search-toggle");
|
712 |
+
if ( awsSearch ) {
|
713 |
+
for (var i = 0; i < awsSearch.length; i++) {
|
714 |
+
awsSearch[i].addEventListener('click', function() {
|
715 |
+
window.setTimeout(function(){
|
716 |
+
document.querySelector(".aws-container .aws-search-field").focus();
|
717 |
+
jQuery( '.aws-search-result' ).hide();
|
718 |
+
}, 100);
|
719 |
+
}, false);
|
720 |
+
}
|
721 |
+
}
|
722 |
+
|
723 |
+
var searchToggler = document.querySelectorAll('[data-modal-target-string=".search-modal"]');
|
724 |
+
if ( searchToggler ) {
|
725 |
+
for (var i = 0; i < searchToggler.length; i++) {
|
726 |
+
searchToggler[i].addEventListener('toggled', function() {
|
727 |
+
jQuery( '.aws-search-result' ).hide();
|
728 |
+
}, false);
|
729 |
+
}
|
730 |
+
}
|
731 |
+
|
732 |
+
}, false);
|
733 |
+
|
734 |
+
</script>
|
735 |
+
|
736 |
+
<?php }
|
737 |
+
|
738 |
+
/*
|
739 |
+
* Jupiter theme
|
740 |
+
*/
|
741 |
+
public function jupiter_head_action() { ?>
|
742 |
+
|
743 |
+
<style>
|
744 |
+
|
745 |
+
.mk-fullscreen-search-overlay .aws-container .aws-search-form {
|
746 |
+
height: 60px;
|
747 |
+
}
|
748 |
+
|
749 |
+
.mk-fullscreen-search-overlay .aws-container .aws-search-field {
|
750 |
+
width: 800px;
|
751 |
+
background-color: transparent;
|
752 |
+
box-shadow: 0 3px 0 0 rgba(255,255,255,.1);
|
753 |
+
border: none;
|
754 |
+
font-size: 35px;
|
755 |
+
color: #fff;
|
756 |
+
padding-bottom: 20px;
|
757 |
+
text-align: center;
|
758 |
+
}
|
759 |
+
|
760 |
+
.mk-fullscreen-search-overlay .aws-container .aws-search-form .aws-form-btn {
|
761 |
+
background-color: transparent;
|
762 |
+
border: none;
|
763 |
+
box-shadow: 0 3px 0 0 rgba(255,255,255,.1);
|
764 |
+
}
|
765 |
+
|
766 |
+
.mk-fullscreen-search-overlay .aws-container .aws-search-form .aws-search-btn_icon {
|
767 |
+
height: 30px;
|
768 |
+
line-height: 30px;
|
769 |
+
}
|
770 |
+
|
771 |
+
.mk-header .aws-container {
|
772 |
+
margin: 10px;
|
773 |
+
}
|
774 |
+
|
775 |
+
.mk-header .mk-responsive-wrap {
|
776 |
+
padding-bottom: 1px;
|
777 |
+
}
|
778 |
+
|
779 |
+
</style>
|
780 |
+
|
781 |
+
<script>
|
782 |
+
|
783 |
+
window.addEventListener('load', function() {
|
784 |
+
|
785 |
+
var iconSearch = document.querySelectorAll(".mk-fullscreen-trigger");
|
786 |
+
if ( iconSearch ) {
|
787 |
+
for (var i = 0; i < iconSearch.length; i++) {
|
788 |
+
iconSearch[i].addEventListener('click', function() {
|
789 |
+
window.setTimeout(function(){
|
790 |
+
document.querySelector(".mk-fullscreen-search-overlay .aws-container .aws-search-field").focus();
|
791 |
+
jQuery( '.aws-search-result' ).hide();
|
792 |
+
}, 100);
|
793 |
+
}, false);
|
794 |
+
}
|
795 |
+
}
|
796 |
+
|
797 |
+
|
798 |
+
}, false);
|
799 |
+
|
800 |
+
</script>
|
801 |
+
|
802 |
+
<?php }
|
803 |
+
|
804 |
+
/*
|
805 |
+
* Woodmart theme
|
806 |
+
*/
|
807 |
+
public function woodmart_head_action() { ?>
|
808 |
+
|
809 |
+
<style>
|
810 |
+
|
811 |
+
.woodmart-search-full-screen .aws-container .aws-search-form {
|
812 |
+
padding-top: 0;
|
813 |
+
padding-right: 0;
|
814 |
+
padding-bottom: 0;
|
815 |
+
padding-left: 0;
|
816 |
+
height: 110px;
|
817 |
+
border: none;
|
818 |
+
background-color: transparent;
|
819 |
+
box-shadow: none;
|
820 |
+
}
|
821 |
+
|
822 |
+
.woodmart-search-full-screen .aws-container .aws-search-field {
|
823 |
+
color: #333;
|
824 |
+
text-align: center;
|
825 |
+
font-weight: 600;
|
826 |
+
font-size: 48px;
|
827 |
+
}
|
828 |
+
|
829 |
+
.woodmart-search-full-screen .aws-container .aws-search-form .aws-form-btn,
|
830 |
+
.woodmart-search-full-screen .aws-container .aws-search-form.aws-show-clear.aws-form-active .aws-search-clear {
|
831 |
+
display: none !important;
|
832 |
+
}
|
833 |
+
|
834 |
+
</style>
|
835 |
+
|
836 |
+
<?php }
|
837 |
+
|
838 |
+
/*
|
839 |
+
* Astra theme form markup
|
840 |
+
*/
|
841 |
+
public function astra_markup( $output ) {
|
842 |
+
if ( function_exists( 'aws_get_search_form' ) && is_string( $output ) ) {
|
843 |
+
|
844 |
+
$pattern = '/(<form[\s\S]*?<\/form>)/i';
|
845 |
+
$form = aws_get_search_form(false);
|
846 |
+
|
847 |
+
if ( strpos( $output, 'aws-container' ) !== false ) {
|
848 |
+
$pattern = '/(<div class="aws-container"[\s\S]*?<form.*?<\/form><\/div>)/i';
|
849 |
+
}
|
850 |
+
|
851 |
+
$output = trim(preg_replace('/\s\s+/', ' ', $output));
|
852 |
+
$output = preg_replace( $pattern, $form, $output );
|
853 |
+
$output = str_replace( 'aws-container', 'aws-container search-form', $output );
|
854 |
+
$output = str_replace( 'aws-search-field', 'aws-search-field search-field', $output );
|
855 |
+
|
856 |
+
}
|
857 |
+
return $output;
|
858 |
+
}
|
859 |
+
|
860 |
+
/*
|
861 |
+
* Astra theme
|
862 |
+
*/
|
863 |
+
public function astra_head_action() { ?>
|
864 |
+
|
865 |
+
<style>
|
866 |
+
.ast-search-menu-icon.slide-search .search-form {
|
867 |
+
width: auto;
|
868 |
+
}
|
869 |
+
.ast-search-menu-icon .search-form {
|
870 |
+
padding: 0 !important;
|
871 |
+
}
|
872 |
+
.ast-search-menu-icon.ast-dropdown-active.slide-search .ast-search-icon {
|
873 |
+
opacity: 0;
|
874 |
+
}
|
875 |
+
.ast-search-menu-icon.slide-search .aws-container .aws-search-field {
|
876 |
+
width: 0;
|
877 |
+
background: #fff;
|
878 |
+
border: none;
|
879 |
+
}
|
880 |
+
.ast-search-menu-icon.ast-dropdown-active.slide-search .aws-search-field {
|
881 |
+
width: 235px;
|
882 |
+
}
|
883 |
+
.ast-search-menu-icon.slide-search .aws-container .aws-search-form .aws-form-btn {
|
884 |
+
background: #fff;
|
885 |
+
border: none;
|
886 |
+
}
|
887 |
+
</style>
|
888 |
+
|
889 |
+
<?php }
|
890 |
+
|
891 |
+
/*
|
892 |
+
* Elessi theme
|
893 |
+
*/
|
894 |
+
public function elessi_head_action() { ?>
|
895 |
+
|
896 |
+
<style>
|
897 |
+
.warpper-mobile-search .aws-container .aws-search-field {
|
898 |
+
border-radius: 30px !important;
|
899 |
+
border: 1px solid #ccc !important;;
|
900 |
+
padding-left: 20px !important;;
|
901 |
+
}
|
902 |
+
.warpper-mobile-search .aws-container .aws-search-form .aws-form-btn,
|
903 |
+
.nasa-header-search-wrap .aws-container .aws-search-form .aws-form-btn {
|
904 |
+
background: transparent !important;
|
905 |
+
border: none !important;
|
906 |
+
}
|
907 |
+
</style>
|
908 |
+
|
909 |
+
<?php }
|
910 |
+
|
911 |
+
/*
|
912 |
+
* Walker theme
|
913 |
+
*/
|
914 |
+
public function walker_head_action() { ?>
|
915 |
+
<style>
|
916 |
+
.edgtf-fullscreen-search-inner .aws-container {
|
917 |
+
position: relative;
|
918 |
+
width: 50%;
|
919 |
+
margin: auto;
|
920 |
+
}
|
921 |
+
</style>
|
922 |
+
<script>
|
923 |
+
window.addEventListener('load', function() {
|
924 |
+
if ( typeof jQuery !== 'undefined' ) {
|
925 |
+
jQuery(document).on( 'click focus', '.edgtf-fullscreen-search-inner input', function(e) {
|
926 |
+
e.preventDefault();
|
927 |
+
e.stopImmediatePropagation();
|
928 |
+
return false;
|
929 |
+
} );
|
930 |
+
}
|
931 |
+
}, false);
|
932 |
+
</script>
|
933 |
+
<?php }
|
934 |
+
|
935 |
+
/*
|
936 |
+
* Storefront theme search form layout
|
937 |
+
*/
|
938 |
+
public function storefront_footer_action() {
|
939 |
+
|
940 |
+
$mobile_screen = AWS()->get_settings( 'mobile_overlay' );
|
941 |
+
|
942 |
+
?>
|
943 |
+
|
944 |
+
<?php if ( $mobile_screen && $mobile_screen === 'true' ): ?>
|
945 |
+
|
946 |
+
<script>
|
947 |
+
window.addEventListener('load', function() {
|
948 |
+
if ( typeof jQuery !== 'undefined' ) {
|
949 |
+
var search = jQuery('.storefront-handheld-footer-bar .search a');
|
950 |
+
search.on( 'click', function() {
|
951 |
+
var searchForm = jQuery('.storefront-handheld-footer-bar .aws-container');
|
952 |
+
searchForm.after('<div class="aws-placement-container"></div>');
|
953 |
+
searchForm.addClass('aws-mobile-fixed').prepend('<div class="aws-mobile-fixed-close"><svg width="17" height="17" viewBox="1.5 1.5 21 21"><path d="M22.182 3.856c.522-.554.306-1.394-.234-1.938-.54-.543-1.433-.523-1.826-.135C19.73 2.17 11.955 10 11.955 10S4.225 2.154 3.79 1.783c-.438-.371-1.277-.4-1.81.135-.533.537-.628 1.513-.25 1.938.377.424 8.166 8.218 8.166 8.218s-7.85 7.864-8.166 8.219c-.317.354-.34 1.335.25 1.805.59.47 1.24.455 1.81 0 .568-.456 8.166-7.951 8.166-7.951l8.167 7.86c.747.72 1.504.563 1.96.09.456-.471.609-1.268.1-1.804-.508-.537-8.167-8.219-8.167-8.219s7.645-7.665 8.167-8.218z"></path></svg></div>');
|
954 |
+
jQuery('body').addClass('aws-overlay').append('<div class="aws-overlay-mask"></div>').append( searchForm );
|
955 |
+
searchForm.find('.aws-search-field').focus();
|
956 |
+
} );
|
957 |
+
}
|
958 |
+
}, false);
|
959 |
+
</script>
|
960 |
+
|
961 |
+
<style>
|
962 |
+
.storefront-handheld-footer-bar ul li.search.active .site-search {
|
963 |
+
display: none !important;
|
964 |
+
}
|
965 |
+
</style>
|
966 |
+
|
967 |
+
<?php else: ?>
|
968 |
+
|
969 |
+
<script>
|
970 |
+
window.addEventListener('load', function() {
|
971 |
+
function aws_results_layout( styles, options ) {
|
972 |
+
if ( typeof jQuery !== 'undefined' ) {
|
973 |
+
var $storefrontHandheld = options.form.closest('.storefront-handheld-footer-bar');
|
974 |
+
if ( $storefrontHandheld.length ) {
|
975 |
+
if ( ! $storefrontHandheld.find('.aws-search-result').length ) {
|
976 |
+
$storefrontHandheld.append( options.resultsBlock );
|
977 |
+
}
|
978 |
+
styles.top = 'auto';
|
979 |
+
styles.bottom = 130;
|
980 |
+
}
|
981 |
+
}
|
982 |
+
return styles;
|
983 |
+
}
|
984 |
+
if ( typeof AwsHooks === 'object' && typeof AwsHooks.add_filter === 'function' ) {
|
985 |
+
AwsHooks.add_filter( 'aws_results_layout', aws_results_layout );
|
986 |
+
}
|
987 |
+
}, false);
|
988 |
+
</script>
|
989 |
+
|
990 |
+
<style>
|
991 |
+
.storefront-handheld-footer-bar .aws-search-result ul li {
|
992 |
+
float: none !important;
|
993 |
+
display: block !important;
|
994 |
+
text-align: left !important;
|
995 |
+
}
|
996 |
+
.storefront-handheld-footer-bar .aws-search-result ul li a {
|
997 |
+
text-indent: 0 !important;
|
998 |
+
text-decoration: none;
|
999 |
+
}
|
1000 |
+
</style>
|
1001 |
+
|
1002 |
+
<?php endif; ?>
|
1003 |
+
|
1004 |
+
<?php }
|
1005 |
+
|
1006 |
+
/*
|
1007 |
+
* Porto theme seamless integration
|
1008 |
+
*/
|
1009 |
+
public function porto_search_form_content_filter( $markup ) {
|
1010 |
+
$pattern = '/(<form[\S\s]*?<\/form>)/i';
|
1011 |
+
if ( strpos( $markup, 'aws-container' ) === false ) {
|
1012 |
+
$markup = preg_replace( $pattern, aws_get_search_form( false ), $markup );
|
1013 |
+
}
|
1014 |
+
$markup = str_replace( 'aws-container', 'aws-container searchform', $markup );
|
1015 |
+
return $markup;
|
1016 |
+
}
|
1017 |
+
|
1018 |
+
/*
|
1019 |
+
* Porto theme styles
|
1020 |
+
*/
|
1021 |
+
public function porto_head_action() { ?>
|
1022 |
+
|
1023 |
+
<style>
|
1024 |
+
#header .aws-container.searchform {
|
1025 |
+
border: 0 !important;
|
1026 |
+
border-radius: 0 !important;
|
1027 |
+
}
|
1028 |
+
#header .aws-container .aws-search-field {
|
1029 |
+
border: 1px solid #eeeeee !important;
|
1030 |
+
height: 100%;
|
1031 |
+
}
|
1032 |
+
#header .aws-container .aws-search-form {
|
1033 |
+
height: 36px;
|
1034 |
+
}
|
1035 |
+
#header .aws-container .aws-search-form .aws-form-btn {
|
1036 |
+
background: #fff;
|
1037 |
+
border-color: #eeeeee;
|
1038 |
+
}
|
1039 |
+
</style>
|
1040 |
+
|
1041 |
+
<?php }
|
1042 |
+
|
1043 |
+
/*
|
1044 |
+
* BoxShop theme styles
|
1045 |
+
*/
|
1046 |
+
public function boxshop_head_action() { ?>
|
1047 |
+
|
1048 |
+
<style>
|
1049 |
+
.ts-header .aws-container .aws-search-form .aws-search-btn.aws-form-btn {
|
1050 |
+
background-color: #e72304;
|
1051 |
+
}
|
1052 |
+
.ts-header .aws-container .aws-search-form .aws-search-btn.aws-form-btn:hover {
|
1053 |
+
background-color: #000000;
|
1054 |
+
}
|
1055 |
+
.aws-container .aws-search-form .aws-search-btn_icon {
|
1056 |
+
color: #fff;
|
1057 |
+
}
|
1058 |
+
</style>
|
1059 |
+
|
1060 |
+
<?php }
|
1061 |
+
|
1062 |
+
/*
|
1063 |
+
* Add search form to Aurum theme mobile menu
|
1064 |
+
*/
|
1065 |
+
public function aurum_mobile_menu( $nav_menu, $args ) {
|
1066 |
+
if ( $args->theme_location === 'main-menu' && $args->menu_class && $args->menu_class === 'mobile-menu' ) {
|
1067 |
+
$form = aws_get_search_form( false );
|
1068 |
+
$nav_menu = $form . $nav_menu;
|
1069 |
+
}
|
1070 |
+
return $nav_menu;
|
1071 |
+
}
|
1072 |
+
|
1073 |
+
/*
|
1074 |
+
* Aurum theme markup for seamless js integration
|
1075 |
+
*/
|
1076 |
+
public function aurum_seamless_searchbox_markup( $markup ) {
|
1077 |
+
|
1078 |
+
if ( function_exists( 'lab_get_svg' ) ) {
|
1079 |
+
$button = '<a href="#" class="search-btn">' . lab_get_svg( "images/search.svg" ) . '<span class="sr-only">' . __( "Search", "aurum" ) .'</span></a>';
|
1080 |
+
$markup = preg_replace( '/(<form[\S\s]*?>)/i', '${1}<div class="search-input-env">', $markup );
|
1081 |
+
$markup = str_replace( '</form>', '</div></form>', $markup );
|
1082 |
+
$markup = str_replace( '</form>', $button . '</form>', $markup );
|
1083 |
+
$markup = str_replace( 'aws-search-form', 'aws-search-form search-form', $markup );
|
1084 |
+
$markup = str_replace( 'aws-search-field', 'aws-search-field search-input', $markup );
|
1085 |
+
$markup = preg_replace( '/(<div class="aws-search-btn aws-form-btn">[\S\s]*?<\/div>)/i', '', $markup );
|
1086 |
+
}
|
1087 |
+
|
1088 |
+
return $markup;
|
1089 |
+
|
1090 |
+
}
|
1091 |
+
|
1092 |
+
/*
|
1093 |
+
* Woostify theme markup for seamless integration
|
1094 |
+
*/
|
1095 |
+
public function woostify_aws_searchbox_markup( $markup ) {
|
1096 |
+
$markup = str_replace( 'aws-search-field', 'aws-search-field search-field', $markup );
|
1097 |
+
return $markup;
|
1098 |
+
}
|
1099 |
+
|
1100 |
+
/*
|
1101 |
+
* Aurum theme scripts
|
1102 |
+
*/
|
1103 |
+
public function aurum_wp_head() { ?>
|
1104 |
+
|
1105 |
+
<script>
|
1106 |
+
window.addEventListener("load", function() {
|
1107 |
+
window.setTimeout(function(){
|
1108 |
+
var forms = document.querySelectorAll(".search-btn");
|
1109 |
+
if ( forms ) {
|
1110 |
+
for (var i = 0; i < forms.length; i++) {
|
1111 |
+
forms[i].addEventListener("click", function() {
|
1112 |
+
var links = document.querySelectorAll(".header-links .search-form");
|
1113 |
+
if ( links ) {
|
1114 |
+
for (var i = 0; i < links.length; i++) {
|
1115 |
+
links[i].className += " input-visible";
|
1116 |
+
}
|
1117 |
+
}
|
1118 |
+
}, false);
|
1119 |
+
}
|
1120 |
+
}
|
1121 |
+
}, 1000);
|
1122 |
+
}, false);
|
1123 |
+
</script>
|
1124 |
+
|
1125 |
+
<?php }
|
1126 |
+
|
1127 |
+
/*
|
1128 |
+
* Fury theme markup change
|
1129 |
+
*/
|
1130 |
+
public function fury_searchbox_markup( $markup ) {
|
1131 |
+
global $wp_current_filter;
|
1132 |
+
if ( in_array( 'wp_head', $wp_current_filter ) ) {
|
1133 |
+
$search_tools = '<div class="search-tools">
|
1134 |
+
<button type="button" class="clear-search">' . esc_html( "Clear", "fury" ) . '</button>
|
1135 |
+
<button type="button" class="close-search" aria-label="' . esc_attr( "Close search", "fury" ) . '"><i class="icon-cross"></i></button>
|
1136 |
+
</div>';
|
1137 |
+
$markup = str_replace( 'aws-container', 'aws-container aws-fury-navbar', $markup );
|
1138 |
+
$markup = str_replace( 'aws-search-form', 'aws-search-form site-search', $markup );
|
1139 |
+
$markup = str_replace( '<div class="aws-search-clear">', $search_tools . '<div class="aws-search-clear">', $markup );
|
1140 |
+
}
|
1141 |
+
return $markup;
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
/*
|
1145 |
+
* Fury theme styles and scripts
|
1146 |
+
*/
|
1147 |
+
public function fury_wp_head() { ?>
|
1148 |
+
<style>
|
1149 |
+
.aws-fury-navbar.aws-container,
|
1150 |
+
.aws-fury-navbar.aws-container form {
|
1151 |
+
height: 100%;
|
1152 |
+
position: absolute;
|
1153 |
+
width: 100%;
|
1154 |
+
}
|
1155 |
+
.aws-fury-navbar.aws-container .aws-search-form.aws-show-clear.aws-form-active .aws-search-clear {
|
1156 |
+
display: none !important;
|
1157 |
+
}
|
1158 |
+
</style>
|
1159 |
+
<script>
|
1160 |
+
window.addEventListener('load', function() {
|
1161 |
+
if ( typeof jQuery !== 'undefined' ) {
|
1162 |
+
|
1163 |
+
jQuery(document).on( 'click', '.aws-fury-navbar .clear-search', function () {
|
1164 |
+
jQuery('.aws-fury-navbar input').val('');
|
1165 |
+
jQuery('.aws-search-result').hide();
|
1166 |
+
jQuery('.aws-fury-navbar .aws-search-form').removeClass('aws-form-active');
|
1167 |
+
} );
|
1168 |
+
|
1169 |
+
jQuery(document).on( 'click', '.aws-fury-navbar .close-search', function () {
|
1170 |
+
jQuery('.aws-fury-navbar .aws-search-form').removeClass('search-visible');
|
1171 |
+
jQuery('.aws-fury-navbar input').val('');
|
1172 |
+
jQuery('.aws-search-result').hide();
|
1173 |
+
jQuery('.aws-fury-navbar .aws-search-form').removeClass('aws-form-active');
|
1174 |
+
} );
|
1175 |
+
|
1176 |
+
}
|
1177 |
+
}, false);
|
1178 |
+
</script>
|
1179 |
+
<?php }
|
1180 |
+
|
1181 |
+
/*
|
1182 |
+
* Bazar theme: add search form
|
1183 |
+
*/
|
1184 |
+
public function bazar_add_header_form() {
|
1185 |
+
$output = aws_get_search_form( false );
|
1186 |
+
$output = str_replace( 'aws-container', 'aws-container widget widget_search_mini', $output );
|
1187 |
+
echo $output;
|
1188 |
+
}
|
1189 |
+
|
1190 |
+
/*
|
1191 |
+
* Bazar theme: add styles
|
1192 |
+
*/
|
1193 |
+
public function bazar_wp_head() { ?>
|
1194 |
+
<style>
|
1195 |
+
#header-cart-search .widget_search_mini:not(.aws-container){
|
1196 |
+
display: none !important;
|
1197 |
+
}
|
1198 |
+
#header-cart-search .aws-container,
|
1199 |
+
#header-cart-search .aws-container .aws-search-form {
|
1200 |
+
height: 50px;
|
1201 |
+
}
|
1202 |
+
#header-cart-search .aws-container .aws-search-field {
|
1203 |
+
font-size: 18px;
|
1204 |
+
font-family: 'Oswald', sans-serif;
|
1205 |
+
color: #747373;
|
1206 |
+
font-style: normal;
|
1207 |
+
font-weight: 400;
|
1208 |
+
text-transform: uppercase;
|
1209 |
+
padding-left: 14px;
|
1210 |
+
}
|
1211 |
+
</style>
|
1212 |
+
<?php }
|
1213 |
+
|
1214 |
+
/*
|
1215 |
+
* Claue theme header markup
|
1216 |
+
*/
|
1217 |
+
public function claue_header( $markup ) {
|
1218 |
+
$pattern = '/(<form[\S\s]*?<\/form>)/i';
|
1219 |
+
if ( strpos( $markup, 'aws-container' ) === false ) {
|
1220 |
+
$form = '<div class="header__search w__100 dn pf">' . aws_get_search_form( false ) . '<a id="sf-close" class="pa" href="#"><i class="pe-7s-close"></i></a></div>';
|
1221 |
+
$markup = preg_replace( $pattern, $form, $markup );
|
1222 |
+
}
|
1223 |
+
return $markup;
|
1224 |
+
}
|
1225 |
+
|
1226 |
+
/*
|
1227 |
+
* Claue theme styles
|
1228 |
+
*/
|
1229 |
+
public function claue_wp_head() { ?>
|
1230 |
+
<style>
|
1231 |
+
#jas-header .aws-container {
|
1232 |
+
position: absolute;
|
1233 |
+
}
|
1234 |
+
#jas-header .aws-container .aws-search-field {
|
1235 |
+
height: 100% !important;
|
1236 |
+
font-size: 20px;
|
1237 |
+
}
|
1238 |
+
#jas-header .aws-container .aws-search-field,
|
1239 |
+
#jas-header .aws-container .aws-search-form .aws-form-btn {
|
1240 |
+
background: transparent;
|
1241 |
+
border-color: rgba(255, 255, 255, .2);
|
1242 |
+
}
|
1243 |
+
</style>
|
1244 |
+
<?php }
|
1245 |
+
|
1246 |
+
/*
|
1247 |
+
* Salient theme styles
|
1248 |
+
*/
|
1249 |
+
public function salient_wp_head() { ?>
|
1250 |
+
<style>
|
1251 |
+
#search-outer #search #close {
|
1252 |
+
top: -5px;
|
1253 |
+
}
|
1254 |
+
#search-box .aws-container {
|
1255 |
+
margin-right: 70px;
|
1256 |
+
}
|
1257 |
+
#search-box .aws-container .aws-search-form .aws-search-btn_icon {
|
1258 |
+
margin: 0 !important;
|
1259 |
+
color: rgba(0,0,0,0.7) !important;
|
1260 |
+
}
|
1261 |
+
#search-box .aws-container .aws-search-field {
|
1262 |
+
font-size: 26px;
|
1263 |
+
font-weight: bold;
|
1264 |
+
padding: 6px 15px 8px 0;
|
1265 |
+
background: transparent;
|
1266 |
+
}
|
1267 |
+
#search-box .aws-container .aws-search-field:focus {
|
1268 |
+
box-shadow: none;
|
1269 |
+
}
|
1270 |
+
#search-box .aws-container .aws-search-field,
|
1271 |
+
#search-box .aws-container .aws-search-form .aws-form-btn {
|
1272 |
+
border: none;
|
1273 |
+
border-bottom: 3px solid #3452ff !important;
|
1274 |
+
}
|
1275 |
+
</style>
|
1276 |
+
<?php }
|
1277 |
+
|
1278 |
+
/*
|
1279 |
+
* Royal theme styles
|
1280 |
+
*/
|
1281 |
+
public function royal_wp_head() { ?>
|
1282 |
+
<style>
|
1283 |
+
.et-search-trigger.search-dropdown .aws-container {
|
1284 |
+
position: absolute;
|
1285 |
+
width: 325px;
|
1286 |
+
top: 55px;
|
1287 |
+
z-index: 1001;
|
1288 |
+
right: -12px;
|
1289 |
+
}
|
1290 |
+
.et-search-trigger.search-dropdown .aws-container .aws-search-form,
|
1291 |
+
.et-search-trigger.search-dropdown:hover .aws-container .aws-search-form{
|
1292 |
+
top: 0;
|
1293 |
+
right: 0;
|
1294 |
+
height: auto;
|
1295 |
+
}
|
1296 |
+
#searchModal .aws-container {
|
1297 |
+
margin: 30px 30px 20px;
|
1298 |
+
}
|
1299 |
+
</style>
|
1300 |
+
<?php }
|
1301 |
+
|
1302 |
+
/*
|
1303 |
+
* Exclude product categories
|
1304 |
+
*/
|
1305 |
+
public function filter_protected_cats_term_exclude( $exclude ) {
|
1306 |
+
if ( isset( $this->data['exclude_categories'] ) ) {
|
1307 |
+
foreach( $this->data['exclude_categories'] as $to_exclude ) {
|
1308 |
+
$exclude[] = $to_exclude;
|
1309 |
+
}
|
1310 |
+
}
|
1311 |
+
return $exclude;
|
1312 |
+
}
|
1313 |
+
|
1314 |
+
/*
|
1315 |
+
* Exclude products
|
1316 |
+
*/
|
1317 |
+
public function filter_products_exclude( $exclude ) {
|
1318 |
+
if ( isset( $this->data['exclude_products'] ) ) {
|
1319 |
+
foreach( $this->data['exclude_products'] as $to_exclude ) {
|
1320 |
+
$exclude[] = $to_exclude;
|
1321 |
+
}
|
1322 |
+
}
|
1323 |
+
return $exclude;
|
1324 |
+
}
|
1325 |
+
|
1326 |
+
public function woocommerce_product_query( $query ) {
|
1327 |
+
|
1328 |
+
$query_args = array(
|
1329 |
+
's' => 'a',
|
1330 |
+
'post_type' => 'product',
|
1331 |
+
'suppress_filters' => true,
|
1332 |
+
'fields' => 'ids',
|
1333 |
+
'posts_per_page' => 1
|
1334 |
+
);
|
1335 |
+
|
1336 |
+
$query = new WP_Query( $query_args );
|
1337 |
+
$query_vars = $query->query_vars;
|
1338 |
+
|
1339 |
+
$query_args_options = get_option( 'aws_search_query_args' );
|
1340 |
+
|
1341 |
+
if ( ! $query_args_options ) {
|
1342 |
+
$query_args_options = array();
|
1343 |
+
}
|
1344 |
+
|
1345 |
+
$user_role = 'non_login';
|
1346 |
+
|
1347 |
+
if ( is_user_logged_in() ) {
|
1348 |
+
$user = wp_get_current_user();
|
1349 |
+
$role = ( array ) $user->roles;
|
1350 |
+
$user_role = $role[0];
|
1351 |
+
}
|
1352 |
+
|
1353 |
+
$query_args_options[$user_role] = array(
|
1354 |
+
'post__not_in' => $query_vars['post__not_in'],
|
1355 |
+
'category__not_in' => $query_vars['category__not_in'],
|
1356 |
+
);
|
1357 |
+
|
1358 |
+
update_option( 'aws_search_query_args', $query_args_options );
|
1359 |
+
|
1360 |
+
}
|
1361 |
+
|
1362 |
+
/*
|
1363 |
+
* Divi theme seamless integration for header
|
1364 |
+
*/
|
1365 |
+
public function et_html_main_header( $html ) {
|
1366 |
+
if ( function_exists( 'aws_get_search_form' ) ) {
|
1367 |
+
|
1368 |
+
$pattern = '/(<form[\s\S]*?<\/form>)/i';
|
1369 |
+
$form = aws_get_search_form(false);
|
1370 |
+
|
1371 |
+
if ( strpos( $html, 'aws-container' ) !== false ) {
|
1372 |
+
$pattern = '/(<div class="aws-container"[\s\S]*?<form.*?<\/form><\/div>)/i';
|
1373 |
+
}
|
1374 |
+
|
1375 |
+
$html = '<style>.et_search_outer .aws-container { position: absolute;right: 40px;top: 20px; }</style>' . $html;
|
1376 |
+
$html = trim(preg_replace('/\s\s+/', ' ', $html));
|
1377 |
+
$html = preg_replace( $pattern, $form, $html );
|
1378 |
+
|
1379 |
+
}
|
1380 |
+
return $html;
|
1381 |
+
}
|
1382 |
+
|
1383 |
+
/*
|
1384 |
+
* Generatepress theme support
|
1385 |
+
*/
|
1386 |
+
public function generate_navigation_search_output( $html ) {
|
1387 |
+
if ( function_exists( 'aws_get_search_form' ) ) {
|
1388 |
+
$html = '<style>.navigation-search .aws-container .aws-search-form{height: 60px;} .navigation-search .aws-container{margin-right: 60px;} .navigation-search .aws-container .search-field{border:none;} </style>';
|
1389 |
+
$html .= '<script>
|
1390 |
+
window.addEventListener("awsShowingResults", function(e) {
|
1391 |
+
var links = document.querySelectorAll(".aws_result_link");
|
1392 |
+
if ( links ) {
|
1393 |
+
for (var i = 0; i < links.length; i++) {
|
1394 |
+
links[i].className += " search-item";
|
1395 |
+
}
|
1396 |
+
}
|
1397 |
+
}, false);
|
1398 |
+
</script>';
|
1399 |
+
$html .= '<div class="navigation-search">' . aws_get_search_form( false ) . '</div>';
|
1400 |
+
$html = str_replace( 'aws-search-field', 'aws-search-field search-field', $html );
|
1401 |
+
}
|
1402 |
+
return $html;
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
/*
|
1406 |
+
* Divi builder replace search module
|
1407 |
+
*/
|
1408 |
+
public function divi_builder_search_module( $output ) {
|
1409 |
+
if ( function_exists( 'aws_get_search_form' ) && is_string( $output ) ) {
|
1410 |
+
|
1411 |
+
$pattern = '/(<form[\s\S]*?<\/form>)/i';
|
1412 |
+
$form = aws_get_search_form(false);
|
1413 |
+
|
1414 |
+
if ( strpos( $output, 'aws-container' ) !== false ) {
|
1415 |
+
$pattern = '/(<div class="aws-container"[\s\S]*?<form.*?<\/form><\/div>)/i';
|
1416 |
+
}
|
1417 |
+
|
1418 |
+
$output = trim(preg_replace('/\s\s+/', ' ', $output));
|
1419 |
+
$output = preg_replace( $pattern, $form, $output );
|
1420 |
+
|
1421 |
+
}
|
1422 |
+
return $output;
|
1423 |
+
}
|
1424 |
+
|
1425 |
+
/*
|
1426 |
+
* Selector filter of js seamless
|
1427 |
+
*/
|
1428 |
+
public function js_seamless_selectors( $selectors ) {
|
1429 |
+
|
1430 |
+
// shopkeeper theme
|
1431 |
+
if ( function_exists( 'shopkeeper_theme_setup' ) ) {
|
1432 |
+
$selectors[] = '.site-search .woocommerce-product-search';
|
1433 |
+
}
|
1434 |
+
|
1435 |
+
// ocean wp theme
|
1436 |
+
if ( class_exists( 'OCEANWP_Theme_Class' ) ) {
|
1437 |
+
$selectors[] = '#searchform-header-replace form';
|
1438 |
+
$selectors[] = '#searchform-overlay form';
|
1439 |
+
$selectors[] = '#sidr .sidr-class-mobile-searchform';
|
1440 |
+
$selectors[] = '#mobile-menu-search form';
|
1441 |
+
$selectors[] = '#site-header form';
|
1442 |
+
}
|
1443 |
+
|
1444 |
+
if ( 'Jupiter' === $this->current_theme ) {
|
1445 |
+
$selectors[] = '#mk-fullscreen-searchform';
|
1446 |
+
$selectors[] = '.responsive-searchform';
|
1447 |
+
}
|
1448 |
+
|
1449 |
+
if ( 'Woodmart' === $this->current_theme ) {
|
1450 |
+
$selectors[] = '.woodmart-search-form form, form.woodmart-ajax-search';
|
1451 |
+
}
|
1452 |
+
|
1453 |
+
if ( 'Venedor' === $this->current_theme ) {
|
1454 |
+
$selectors[] = '#search-form form';
|
1455 |
+
}
|
1456 |
+
|
1457 |
+
if ( 'Elessi Theme' === $this->current_theme ) {
|
1458 |
+
$selectors[] = '.warpper-mobile-search form';
|
1459 |
+
}
|
1460 |
+
|
1461 |
+
if ( 'Walker' === $this->current_theme ) {
|
1462 |
+
$selectors[] = '.edgtf-page-header form, .edgtf-mobile-header form, .edgtf-fullscreen-search-form';
|
1463 |
+
}
|
1464 |
+
|
1465 |
+
if ( 'Martfury' === $this->current_theme ) {
|
1466 |
+
$selectors[] = '#site-header .products-search';
|
1467 |
+
}
|
1468 |
+
|
1469 |
+
if ( 'BoxShop' === $this->current_theme ) {
|
1470 |
+
$selectors[] = '.ts-header .search-wrapper form';
|
1471 |
+
}
|
1472 |
+
|
1473 |
+
if ( 'Fury' === $this->current_theme ) {
|
1474 |
+
$selectors[] = 'header .site-search';
|
1475 |
+
}
|
1476 |
+
|
1477 |
+
if ( 'Urna' === $this->current_theme ) {
|
1478 |
+
$selectors[] = '#tbay-header .searchform';
|
1479 |
+
}
|
1480 |
+
|
1481 |
+
if ( 'Salient' === $this->current_theme ) {
|
1482 |
+
$selectors[] = '#search-box form';
|
1483 |
+
}
|
1484 |
+
|
1485 |
+
if ( 'Aurum' === $this->current_theme ) {
|
1486 |
+
$selectors[] = '.header-links .search-form';
|
1487 |
+
}
|
1488 |
+
|
1489 |
+
if ( 'Royal' === $this->current_theme ) {
|
1490 |
+
$selectors[] = '.header-search form';
|
1491 |
+
$selectors[] = '#searchModal form';
|
1492 |
+
}
|
1493 |
+
|
1494 |
+
// WCFM - WooCommerce Multivendor Marketplace
|
1495 |
+
if ( class_exists( 'WCFMmp' ) ) {
|
1496 |
+
$selectors[] = '#wcfmmp-store .woocommerce-product-search';
|
1497 |
+
}
|
1498 |
+
|
1499 |
+
return $selectors;
|
1500 |
+
|
1501 |
+
}
|
1502 |
+
|
1503 |
+
/*
|
1504 |
+
* Js seamless integration method
|
1505 |
+
*/
|
1506 |
+
public function head_js_integration() {
|
1507 |
+
|
1508 |
+
/**
|
1509 |
+
* Filter seamless integrations js selectors for forms
|
1510 |
+
* @since 1.85
|
1511 |
+
* @param array $forms Array of css selectors
|
1512 |
+
*/
|
1513 |
+
$forms = apply_filters( 'aws_js_seamless_selectors', array() );
|
1514 |
+
|
1515 |
+
if ( ! is_array( $forms ) || empty( $forms ) ) {
|
1516 |
+
return;
|
1517 |
+
}
|
1518 |
+
|
1519 |
+
$forms_selector = implode( ',', $forms );
|
1520 |
+
|
1521 |
+
$form_html = str_replace( 'aws-container', 'aws-container aws-js-seamless', aws_get_search_form( false ) );
|
1522 |
+
|
1523 |
+
/**
|
1524 |
+
* Filter seamless integrations default form markup
|
1525 |
+
* @since 2.25
|
1526 |
+
* @param string $form_html Form html output
|
1527 |
+
* @param array $forms Array of css selectors
|
1528 |
+
*/
|
1529 |
+
$form_html = apply_filters( 'aws_js_seamless_searchbox_markup', $form_html, $forms );
|
1530 |
+
|
1531 |
+
?>
|
1532 |
+
|
1533 |
+
<script>
|
1534 |
+
|
1535 |
+
window.addEventListener('load', function() {
|
1536 |
+
var forms = document.querySelectorAll("<?php echo $forms_selector; ?>");
|
1537 |
+
|
1538 |
+
var awsFormHtml = <?php echo json_encode( $form_html ); ?>;
|
1539 |
+
|
1540 |
+
if ( forms ) {
|
1541 |
+
|
1542 |
+
for ( var i = 0; i < forms.length; i++ ) {
|
1543 |
+
if ( forms[i].parentNode.outerHTML.indexOf('aws-container') === -1 ) {
|
1544 |
+
forms[i].outerHTML = awsFormHtml;
|
1545 |
+
}
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
window.setTimeout(function(){
|
1549 |
+
jQuery('.aws-js-seamless').each( function() {
|
1550 |
+
jQuery(this).aws_search();
|
1551 |
+
});
|
1552 |
+
}, 1000);
|
1553 |
+
|
1554 |
+
}
|
1555 |
+
}, false);
|
1556 |
+
</script>
|
1557 |
+
|
1558 |
+
<?php }
|
1559 |
+
|
1560 |
+
/*
|
1561 |
+
* Remove products that was excluded with Search Exclude plugin ( https://wordpress.org/plugins/search-exclude/ )
|
1562 |
+
*/
|
1563 |
+
public function search_exclude_filter( $products ) {
|
1564 |
+
|
1565 |
+
$excluded = get_option('sep_exclude');
|
1566 |
+
|
1567 |
+
if ( $excluded && is_array( $excluded ) && ! empty( $excluded ) && $products && is_array( $products ) ) {
|
1568 |
+
foreach( $products as $key => $product_id ) {
|
1569 |
+
if ( false !== array_search( $product_id, $excluded ) ) {
|
1570 |
+
unset( $products[$key] );
|
1571 |
+
}
|
1572 |
+
}
|
1573 |
+
}
|
1574 |
+
|
1575 |
+
return $products;
|
1576 |
+
|
1577 |
+
}
|
1578 |
+
|
1579 |
+
/*
|
1580 |
+
* Fix WooCommerce Product Table for search page
|
1581 |
+
*/
|
1582 |
+
public function wc_product_table_data_config( $config ) {
|
1583 |
+
if ( isset( $_GET['type_aws'] ) && isset( $config['search'] ) ) {
|
1584 |
+
$config['search']['search'] = '';
|
1585 |
+
}
|
1586 |
+
return $config;
|
1587 |
+
}
|
1588 |
+
|
1589 |
+
/*
|
1590 |
+
* WooCommerce Product Table plugin change number of products on page
|
1591 |
+
*/
|
1592 |
+
public function wc_product_table_posts_per_page( $num ) {
|
1593 |
+
return 9999;
|
1594 |
+
}
|
1595 |
+
|
1596 |
+
/*
|
1597 |
+
* Divi builder remove dynamic text shortcodes
|
1598 |
+
*/
|
1599 |
+
public function divi_builder_strip_shortcodes( $str ) {
|
1600 |
+
$str = preg_replace( '#\[et_pb_text.[^\]]*?_dynamic_attributes.*?\]@ET-.*?\[\/et_pb_text\]#', '', $str );
|
1601 |
+
return $str;
|
1602 |
+
}
|
1603 |
+
|
1604 |
+
/*
|
1605 |
+
* WP all import cron job
|
1606 |
+
*/
|
1607 |
+
public function pmxi_after_xml_import() {
|
1608 |
+
$sunc = AWS()->get_settings( 'autoupdates' );
|
1609 |
+
if ( $sunc === 'true' ) {
|
1610 |
+
wp_schedule_single_event( time() + 1, 'aws_reindex_table' );
|
1611 |
+
}
|
1612 |
+
}
|
1613 |
+
|
1614 |
+
/*
|
1615 |
+
* BeRocket WooCommerce AJAX Products Filter
|
1616 |
+
*/
|
1617 |
+
public function berocket_search_page_filters( $filters ) {
|
1618 |
+
|
1619 |
+
if ( isset( $_GET['filters'] ) ) {
|
1620 |
+
|
1621 |
+
$get_filters = explode( '|', $_GET['filters'] );
|
1622 |
+
|
1623 |
+
foreach( $get_filters as $get_filter ) {
|
1624 |
+
|
1625 |
+
if ( $get_filter === '_stock_status[1]' ) {
|
1626 |
+
$filters['in_status'] = true;
|
1627 |
+
} elseif ( $get_filter === '_stock_status[2]' ) {
|
1628 |
+
$filters['in_status'] = false;
|
1629 |
+
} elseif ( $get_filter === '_sale[1]' ) {
|
1630 |
+
$filters['on_sale'] = true;
|
1631 |
+
} elseif ( $get_filter === '_sale[2]' ) {
|
1632 |
+
$filters['on_sale'] = false;
|
1633 |
+
} elseif ( strpos( $get_filter, 'price[' ) === 0 ) {
|
1634 |
+
if ( preg_match( '/([\w]+)\[(\d+)_(\d+)\]/', $get_filter, $matches ) ) {
|
1635 |
+
$filters['price_min'] = intval( $matches[2] );
|
1636 |
+
$filters['price_max'] = intval( $matches[3] );
|
1637 |
+
}
|
1638 |
+
} elseif ( preg_match( '/(.+)\[(.+?)\]/', $get_filter, $matches ) ) {
|
1639 |
+
$taxonomy = $matches[1];
|
1640 |
+
$operator = strpos( $matches[2], '-' ) !== false ? 'OR' : 'AND';
|
1641 |
+
$explode_char = strpos( $matches[2], '-' ) !== false ? '-' : '+';
|
1642 |
+
$terms_arr = explode( $explode_char, $matches[2] );
|
1643 |
+
// if used slugs instead of IDs for terms
|
1644 |
+
if ( preg_match( '/[a-z]/', $matches[2] ) ) {
|
1645 |
+
$new_terms_arr = array();
|
1646 |
+
foreach ( $terms_arr as $term_slug ) {
|
1647 |
+
$term = get_term_by('slug', $term_slug, $taxonomy );
|
1648 |
+
if ( $term ) {
|
1649 |
+
$new_terms_arr[] = $term->term_id;
|
1650 |
+
}
|
1651 |
+
if ( ! $term && strpos( $taxonomy, 'pa_' ) !== 0 ) {
|
1652 |
+
$term = get_term_by('slug', $term_slug, 'pa_' . $taxonomy );
|
1653 |
+
if ( $term ) {
|
1654 |
+
$new_terms_arr[] = $term->term_id;
|
1655 |
+
}
|
1656 |
+
}
|
1657 |
+
}
|
1658 |
+
if ( $new_terms_arr ) {
|
1659 |
+
$terms_arr = $new_terms_arr;
|
1660 |
+
}
|
1661 |
+
}
|
1662 |
+
$filters['tax'][$taxonomy] = array(
|
1663 |
+
'terms' => $terms_arr,
|
1664 |
+
'operator' => $operator,
|
1665 |
+
'include_parent' => true,
|
1666 |
+
);
|
1667 |
+
}
|
1668 |
+
|
1669 |
+
}
|
1670 |
+
|
1671 |
+
}
|
1672 |
+
|
1673 |
+
return $filters;
|
1674 |
+
|
1675 |
+
}
|
1676 |
+
|
1677 |
+
/*
|
1678 |
+
* Product Sort and Display for WooCommerce plugin disable on search page
|
1679 |
+
*/
|
1680 |
+
function psad_filter( $value ) {
|
1681 |
+
if ( isset( $_GET['type_aws'] ) ) {
|
1682 |
+
return 'no';
|
1683 |
+
}
|
1684 |
+
return $value;
|
1685 |
+
}
|
1686 |
+
|
1687 |
+
/*
|
1688 |
+
* Avada theme posts per page option
|
1689 |
+
*/
|
1690 |
+
public function avada_posts_per_page( $posts_per_page ) {
|
1691 |
+
$posts_per_page = isset( $_GET['product_count'] ) && intval( sanitize_text_field( $_GET['product_count'] ) ) ? intval( sanitize_text_field( $_GET['product_count'] ) ) : 12;
|
1692 |
+
return $posts_per_page;
|
1693 |
+
}
|
1694 |
+
|
1695 |
+
/*
|
1696 |
+
* Avada theme order by options
|
1697 |
+
*/
|
1698 |
+
public function avada_aws_products_order_by( $order_by ) {
|
1699 |
+
|
1700 |
+
$order_by_new = '';
|
1701 |
+
|
1702 |
+
if ( isset( $_GET['product_orderby'] ) ) {
|
1703 |
+
switch( sanitize_text_field( $_GET['product_orderby'] ) ) {
|
1704 |
+
case 'name':
|
1705 |
+
$order_by_new = 'title';
|
1706 |
+
break;
|
1707 |
+
case 'price':
|
1708 |
+
$order_by_new = 'price';
|
1709 |
+
break;
|
1710 |
+
case 'date':
|
1711 |
+
$order_by_new = 'date';
|
1712 |
+
break;
|
1713 |
+
case 'popularity':
|
1714 |
+
$order_by_new = 'popularity';
|
1715 |
+
break;
|
1716 |
+
case 'rating':
|
1717 |
+
$order_by_new = 'rating';
|
1718 |
+
break;
|
1719 |
+
}
|
1720 |
+
}
|
1721 |
+
|
1722 |
+
if ( isset( $_GET['product_order'] ) && $order_by_new ) {
|
1723 |
+
$product_order = sanitize_text_field( $_GET['product_order'] );
|
1724 |
+
if ( in_array( $product_order, array( 'asc', 'desc' ) ) ) {
|
1725 |
+
$order_by_new = $order_by_new . '-' . $product_order;
|
1726 |
+
}
|
1727 |
+
|
1728 |
+
}
|
1729 |
+
|
1730 |
+
if ( $order_by_new ) {
|
1731 |
+
$order_by = $order_by_new;
|
1732 |
+
}
|
1733 |
+
|
1734 |
+
return $order_by;
|
1735 |
+
|
1736 |
+
}
|
1737 |
+
|
1738 |
+
/*
|
1739 |
+
* Avada theme fix for product variations inside list products view
|
1740 |
+
*/
|
1741 |
+
public function avada_post_class( $classes ) {
|
1742 |
+
if ( 'product_variation' === get_post_type() ) {
|
1743 |
+
if ( isset( $_SERVER['QUERY_STRING'] ) ) {
|
1744 |
+
parse_str( sanitize_text_field( wp_unslash( $_SERVER['QUERY_STRING'] ) ), $params );
|
1745 |
+
if ( isset( $params['product_view'] ) && $params['product_view'] ) {
|
1746 |
+
$classes[] = 'product-' . $params['product_view'] . '-view';
|
1747 |
+
}
|
1748 |
+
}
|
1749 |
+
}
|
1750 |
+
return $classes;
|
1751 |
+
}
|
1752 |
+
|
1753 |
+
/*
|
1754 |
+
* Electro them update search form markup
|
1755 |
+
*/
|
1756 |
+
public function electro_searchbox_markup( $markup, $params ) {
|
1757 |
+
$pattern = '/<div class="aws-search-btn aws-form-btn">[\S\s]*?<\/div>/i';
|
1758 |
+
$markup = preg_replace( $pattern, '', $markup );
|
1759 |
+
return $markup;
|
1760 |
+
}
|
1761 |
+
|
1762 |
+
/*
|
1763 |
+
* FacetWP check for active filters
|
1764 |
+
*/
|
1765 |
+
public function facetwp_filtered_post_ids( $post_ids ) {
|
1766 |
+
if ( isset( $_GET['type_aws'] ) && isset( $_GET['s'] ) && ! empty( $post_ids ) ) {
|
1767 |
+
$this->data['facetwp'] = true;
|
1768 |
+
}
|
1769 |
+
return $post_ids;
|
1770 |
+
}
|
1771 |
+
|
1772 |
+
/*
|
1773 |
+
* Disable AWS search if FacetWP is active
|
1774 |
+
*/
|
1775 |
+
public function facetwp_aws_searchpage_enabled( $enabled ) {
|
1776 |
+
if ( isset( $this->data['facetwp'] ) && $this->data['facetwp'] ) {
|
1777 |
+
$enabled = false;
|
1778 |
+
}
|
1779 |
+
return $enabled;
|
1780 |
+
}
|
1781 |
+
|
1782 |
+
/*
|
1783 |
+
* Product Visibility by User Role for WooCommerce plugin hide products for certain users
|
1784 |
+
*/
|
1785 |
+
public function pvbur_aws_search_results_products( $products ) {
|
1786 |
+
|
1787 |
+
$user_role = 'guest';
|
1788 |
+
if ( is_user_logged_in() ) {
|
1789 |
+
$user = wp_get_current_user();
|
1790 |
+
$roles = ( array ) $user->roles;
|
1791 |
+
$user_role = $roles[0];
|
1792 |
+
}
|
1793 |
+
|
1794 |
+
foreach( $products as $key => $product ) {
|
1795 |
+
|
1796 |
+
$visible_roles = get_post_meta( $product['parent_id'], '_alg_wc_pvbur_visible', true );
|
1797 |
+
$invisible_roles = get_post_meta( $product['parent_id'], '_alg_wc_pvbur_invisible', true );
|
1798 |
+
|
1799 |
+
if ( is_array( $invisible_roles ) && ! empty( $invisible_roles ) ) {
|
1800 |
+
foreach( $invisible_roles as $invisible_role ) {
|
1801 |
+
if ( $user_role == $invisible_role ) {
|
1802 |
+
unset( $products[$key] );
|
1803 |
+
continue 2;
|
1804 |
+
}
|
1805 |
+
}
|
1806 |
+
}
|
1807 |
+
|
1808 |
+
if ( is_array( $visible_roles ) && ! empty( $visible_roles ) ) {
|
1809 |
+
$show = false;
|
1810 |
+
foreach( $visible_roles as $visible_role ) {
|
1811 |
+
if ( $user_role == $visible_role ) {
|
1812 |
+
$show = true;
|
1813 |
+
break;
|
1814 |
+
}
|
1815 |
+
}
|
1816 |
+
if ( ! $show ) {
|
1817 |
+
unset( $products[$key] );
|
1818 |
+
continue;
|
1819 |
+
}
|
1820 |
+
}
|
1821 |
+
|
1822 |
+
}
|
1823 |
+
|
1824 |
+
return $products;
|
1825 |
+
|
1826 |
+
}
|
1827 |
+
|
1828 |
+
/*
|
1829 |
+
* WooCommerce Product Filter by WooBeWoo: check for active widget
|
1830 |
+
*/
|
1831 |
+
public function wpf_add_html_before_filter( $html ) {
|
1832 |
+
$this->data['wpf_filter'] = true;
|
1833 |
+
if ( isset( $_GET['type_aws'] ) ) {
|
1834 |
+
$html = str_replace( '"enable_ajax":"1"', '"enable_ajax":"0"', $html );
|
1835 |
+
$html = str_replace( '"enable_ajax":"1"', '"enable_ajax":"0"', $html );
|
1836 |
+
}
|
1837 |
+
return $html;
|
1838 |
+
}
|
1839 |
+
|
1840 |
+
/*
|
1841 |
+
* WooCommerce Product Filter by WooBeWoo: fix filters display
|
1842 |
+
*/
|
1843 |
+
public function wpf_search_page_custom_data( $data ) {
|
1844 |
+
if ( isset( $this->data['wpf_filter'] ) ) {
|
1845 |
+
$data['force_ids'] = true;
|
1846 |
+
}
|
1847 |
+
return $data;
|
1848 |
+
}
|
1849 |
+
|
1850 |
+
/*
|
1851 |
+
* WooCommerce Product Filter by WooBeWoo: filter products
|
1852 |
+
*/
|
1853 |
+
public function wpf_search_page_filters( $filters ) {
|
1854 |
+
|
1855 |
+
foreach ( $_GET as $key => $param ) {
|
1856 |
+
|
1857 |
+
$isNot = ( substr($param, 0, 1) === '!' );
|
1858 |
+
|
1859 |
+
if ( strpos($key, 'filter_cat') !== false ) {
|
1860 |
+
|
1861 |
+
$idsAnd = explode(',', $param);
|
1862 |
+
$idsOr = explode('|', $param);
|
1863 |
+
$isAnd = count($idsAnd) > count($idsOr);
|
1864 |
+
$operator = $isAnd ? 'AND' : 'OR';
|
1865 |
+
$filters['tax']['product_cat'] = array(
|
1866 |
+
'terms' => $isAnd ? $idsAnd : $idsOr,
|
1867 |
+
'operator' => $operator
|
1868 |
+
);
|
1869 |
+
}
|
1870 |
+
|
1871 |
+
if ( strpos($key, 'product_tag') !== false ) {
|
1872 |
+
|
1873 |
+
$idsAnd = explode(',', $param);
|
1874 |
+
$idsOr = explode('|', $param);
|
1875 |
+
$isAnd = count($idsAnd) > count($idsOr);
|
1876 |
+
$operator = $isAnd ? 'AND' : 'OR';
|
1877 |
+
$filters['tax']['product_tag'] = array(
|
1878 |
+
'terms' => $isAnd ? $idsAnd : $idsOr,
|
1879 |
+
'operator' => $operator
|
1880 |
+
);
|
1881 |
+
}
|
1882 |
+
|
1883 |
+
if ( strpos($key, 'pr_onsale') !== false ) {
|
1884 |
+
$filters['on_sale'] = true;
|
1885 |
+
}
|
1886 |
+
|
1887 |
+
}
|
1888 |
+
|
1889 |
+
return $filters;
|
1890 |
+
|
1891 |
+
}
|
1892 |
+
|
1893 |
+
/*
|
1894 |
+
* ATUM Inventory Management for WooCommerce plugin ( Product level addon )
|
1895 |
+
*/
|
1896 |
+
public function atum_index_data( $data, $id ) {
|
1897 |
+
$is_purchasable = AtumLevels\Inc\Helpers::is_purchase_allowed( $id );
|
1898 |
+
if ( ! $is_purchasable ) {
|
1899 |
+
$data = array();
|
1900 |
+
}
|
1901 |
+
return $data;
|
1902 |
+
}
|
1903 |
+
|
1904 |
+
/*
|
1905 |
+
* Popups for Divi plugin fix scrolling for search results
|
1906 |
+
*/
|
1907 |
+
function divi_popups_enqueue_scripts() {
|
1908 |
+
|
1909 |
+
$script = "
|
1910 |
+
if ( typeof DiviArea === 'object' ) {
|
1911 |
+
DiviArea.addAction('disabled_scrolling', function() {
|
1912 |
+
var aws_form = jQuery('[data-da-area] .aws-search-form');
|
1913 |
+
if ( aws_form.length > 0 ) {
|
1914 |
+
DiviArea.Core.enableBodyScroll();
|
1915 |
+
jQuery('body').addClass('da-overlay-visible');
|
1916 |
+
}
|
1917 |
+
});
|
1918 |
+
DiviArea.addAction('close_area', function() {
|
1919 |
+
var aws_form = jQuery('[data-da-area] .aws-search-form');
|
1920 |
+
if ( aws_form.length > 0 ) {
|
1921 |
+
jQuery('body').removeClass('da-overlay-visible');
|
1922 |
+
jQuery('.aws-search-result').hide();
|
1923 |
+
}
|
1924 |
+
});
|
1925 |
+
}
|
1926 |
+
";
|
1927 |
+
|
1928 |
+
wp_add_inline_script( 'aws-script', $script );
|
1929 |
+
|
1930 |
+
}
|
1931 |
+
|
1932 |
+
/*
|
1933 |
+
* WooCommerce Catalog Visibility Options plugin: exclude restricted products
|
1934 |
+
*/
|
1935 |
+
public function wcvo_exclude_products( $exclude_products ) {
|
1936 |
+
$catalog_query = WC_Catalog_Restrictions_Query::instance();
|
1937 |
+
if ( is_object( $catalog_query ) && method_exists( $catalog_query, 'get_disallowed_products' ) ) {
|
1938 |
+
$disallowed_products = $catalog_query->get_disallowed_products();
|
1939 |
+
if ( is_array( $disallowed_products ) && ! empty( $disallowed_products ) ) {
|
1940 |
+
foreach( $disallowed_products as $disallowed_product ) {
|
1941 |
+
$exclude_products[] = $disallowed_product;
|
1942 |
+
}
|
1943 |
+
}
|
1944 |
+
}
|
1945 |
+
return $exclude_products;
|
1946 |
+
}
|
1947 |
+
|
1948 |
+
}
|
1949 |
+
|
1950 |
endif;
|
includes/class-aws-markup.php
CHANGED
@@ -1,137 +1,137 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Markup' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for plugin search action
|
11 |
-
*/
|
12 |
-
class AWS_Markup {
|
13 |
-
|
14 |
-
/*
|
15 |
-
* Generate search box markup
|
16 |
-
*/
|
17 |
-
public function markup() {
|
18 |
-
|
19 |
-
global $wpdb;
|
20 |
-
|
21 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
22 |
-
|
23 |
-
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) != $table_name ) {
|
24 |
-
if ( current_user_can( 'manage_options' ) ) {
|
25 |
-
echo 'Please go to <a href="' . admin_url( 'admin.php?page=aws-options' ) . '">plugins settings page</a> and click on "Reindex table" button.';
|
26 |
-
}
|
27 |
-
return;
|
28 |
-
}
|
29 |
-
|
30 |
-
|
31 |
-
$placeholder = AWS_Helpers::translate( 'search_field_text', AWS()->get_settings( 'search_field_text' ) );
|
32 |
-
$min_chars = AWS()->get_settings( 'min_chars' );
|
33 |
-
$show_loader = AWS()->get_settings( 'show_loader' );
|
34 |
-
$show_more = AWS()->get_settings( 'show_more' );
|
35 |
-
$show_page = AWS()->get_settings( 'show_page' );
|
36 |
-
$show_clear = AWS()->get_settings( 'show_clear' );
|
37 |
-
$mobile_screen = AWS()->get_settings( 'mobile_overlay' );
|
38 |
-
$use_analytics = AWS()->get_settings( 'use_analytics' );
|
39 |
-
$buttons_order = AWS()->get_settings( 'buttons_order' );
|
40 |
-
$search_timeout = AWS()->get_settings( 'search_timeout' );
|
41 |
-
|
42 |
-
$current_lang = AWS_Helpers::get_lang();
|
43 |
-
|
44 |
-
$url_array = parse_url( home_url() );
|
45 |
-
$url_query_parts = array();
|
46 |
-
|
47 |
-
if ( isset( $url_array['query'] ) && $url_array['query'] ) {
|
48 |
-
parse_str( $url_array['query'], $url_query_parts );
|
49 |
-
}
|
50 |
-
|
51 |
-
$form_action = AWS_Helpers::get_search_url();
|
52 |
-
$input_id = uniqid();
|
53 |
-
|
54 |
-
$params_string = '';
|
55 |
-
|
56 |
-
$params = array(
|
57 |
-
'data-url' => class_exists( 'WC_AJAX' ) ? WC_AJAX::get_endpoint( 'aws_action' ) : admin_url( 'admin-ajax.php' ),
|
58 |
-
'data-siteurl' => home_url(),
|
59 |
-
'data-lang' => $current_lang ? $current_lang : '',
|
60 |
-
'data-show-loader' => $show_loader,
|
61 |
-
'data-show-more' => $show_more,
|
62 |
-
'data-show-page' => $show_page,
|
63 |
-
'data-show-clear' => $show_clear,
|
64 |
-
'data-mobile-screen' => $mobile_screen,
|
65 |
-
'data-use-analytics' => $use_analytics,
|
66 |
-
'data-min-chars' => $min_chars,
|
67 |
-
'data-buttons-order' => $buttons_order,
|
68 |
-
'data-timeout' => $search_timeout,
|
69 |
-
'data-is-mobile' => wp_is_mobile() ? 'true' : 'false',
|
70 |
-
'data-page-id' => get_queried_object_id(),
|
71 |
-
'data-tax' => get_query_var('taxonomy')
|
72 |
-
);
|
73 |
-
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Filter form data parameters before output
|
77 |
-
* @since 1.69
|
78 |
-
* @param array $params Data parameters array
|
79 |
-
*/
|
80 |
-
$params = apply_filters( 'aws_front_data_parameters', $params );
|
81 |
-
|
82 |
-
|
83 |
-
foreach( $params as $key => $value ) {
|
84 |
-
$params_string .= $key . '="' . esc_attr( $value ) . '" ';
|
85 |
-
}
|
86 |
-
|
87 |
-
$markup = '';
|
88 |
-
$markup .= '<div class="aws-container" ' . $params_string . '>';
|
89 |
-
$markup .= '<form class="aws-search-form" action="' . $form_action . '" method="get" role="search" >';
|
90 |
-
|
91 |
-
$markup .= '<div class="aws-wrapper">';
|
92 |
-
|
93 |
-
$markup .= '<label class="aws-search-label" for="' . esc_attr( $input_id ) . '">' . esc_attr( $placeholder ) . '</label>';
|
94 |
-
$markup .= '<input type="search" name="s" id="' . esc_attr( $input_id ) . '" value="' . get_search_query() . '" class="aws-search-field" placeholder="' . esc_attr( $placeholder ) . '" autocomplete="off" />';
|
95 |
-
$markup .= '<input type="hidden" name="post_type" value="product">';
|
96 |
-
$markup .= '<input type="hidden" name="type_aws" value="true">';
|
97 |
-
|
98 |
-
if ( $current_lang ) {
|
99 |
-
$markup .= '<input type="hidden" name="lang" value="' . esc_attr( $current_lang ) . '">';
|
100 |
-
}
|
101 |
-
|
102 |
-
if ( $url_query_parts ) {
|
103 |
-
foreach( $url_query_parts as $url_query_key => $url_query_value ) {
|
104 |
-
$markup .= '<input type="hidden" name="' . esc_attr( $url_query_key ) . '" value="' . esc_attr( $url_query_value ) . '">';
|
105 |
-
}
|
106 |
-
}
|
107 |
-
|
108 |
-
$markup .= '<div class="aws-search-clear">';
|
109 |
-
$markup .= '<span>×</span>';
|
110 |
-
$markup .= '</div>';
|
111 |
-
|
112 |
-
$markup .= '<div class="aws-loader"></div>';
|
113 |
-
|
114 |
-
$markup .= '</div>';
|
115 |
-
|
116 |
-
if ( $buttons_order && $buttons_order !== '1' ) {
|
117 |
-
|
118 |
-
$markup .= '<div class="aws-search-btn aws-form-btn">';
|
119 |
-
$markup .= '<span class="aws-search-btn_icon">';
|
120 |
-
$markup .= '<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px">';
|
121 |
-
$markup .= '<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>';
|
122 |
-
$markup .= '</svg>';
|
123 |
-
$markup .= '</span>';
|
124 |
-
$markup .= '</div>';
|
125 |
-
|
126 |
-
}
|
127 |
-
|
128 |
-
$markup .= '</form>';
|
129 |
-
$markup .= '</div>';
|
130 |
-
|
131 |
-
return apply_filters( 'aws_searchbox_markup', $markup, $params );
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Markup' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plugin search action
|
11 |
+
*/
|
12 |
+
class AWS_Markup {
|
13 |
+
|
14 |
+
/*
|
15 |
+
* Generate search box markup
|
16 |
+
*/
|
17 |
+
public function markup() {
|
18 |
+
|
19 |
+
global $wpdb;
|
20 |
+
|
21 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
22 |
+
|
23 |
+
if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) != $table_name ) {
|
24 |
+
if ( current_user_can( 'manage_options' ) ) {
|
25 |
+
echo 'Please go to <a href="' . admin_url( 'admin.php?page=aws-options' ) . '">plugins settings page</a> and click on "Reindex table" button.';
|
26 |
+
}
|
27 |
+
return;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
$placeholder = AWS_Helpers::translate( 'search_field_text', AWS()->get_settings( 'search_field_text' ) );
|
32 |
+
$min_chars = AWS()->get_settings( 'min_chars' );
|
33 |
+
$show_loader = AWS()->get_settings( 'show_loader' );
|
34 |
+
$show_more = AWS()->get_settings( 'show_more' );
|
35 |
+
$show_page = AWS()->get_settings( 'show_page' );
|
36 |
+
$show_clear = AWS()->get_settings( 'show_clear' );
|
37 |
+
$mobile_screen = AWS()->get_settings( 'mobile_overlay' );
|
38 |
+
$use_analytics = AWS()->get_settings( 'use_analytics' );
|
39 |
+
$buttons_order = AWS()->get_settings( 'buttons_order' );
|
40 |
+
$search_timeout = AWS()->get_settings( 'search_timeout' );
|
41 |
+
|
42 |
+
$current_lang = AWS_Helpers::get_lang();
|
43 |
+
|
44 |
+
$url_array = parse_url( home_url() );
|
45 |
+
$url_query_parts = array();
|
46 |
+
|
47 |
+
if ( isset( $url_array['query'] ) && $url_array['query'] ) {
|
48 |
+
parse_str( $url_array['query'], $url_query_parts );
|
49 |
+
}
|
50 |
+
|
51 |
+
$form_action = AWS_Helpers::get_search_url();
|
52 |
+
$input_id = uniqid();
|
53 |
+
|
54 |
+
$params_string = '';
|
55 |
+
|
56 |
+
$params = array(
|
57 |
+
'data-url' => class_exists( 'WC_AJAX' ) ? WC_AJAX::get_endpoint( 'aws_action' ) : admin_url( 'admin-ajax.php' ),
|
58 |
+
'data-siteurl' => home_url(),
|
59 |
+
'data-lang' => $current_lang ? $current_lang : '',
|
60 |
+
'data-show-loader' => $show_loader,
|
61 |
+
'data-show-more' => $show_more,
|
62 |
+
'data-show-page' => $show_page,
|
63 |
+
'data-show-clear' => $show_clear,
|
64 |
+
'data-mobile-screen' => $mobile_screen,
|
65 |
+
'data-use-analytics' => $use_analytics,
|
66 |
+
'data-min-chars' => $min_chars,
|
67 |
+
'data-buttons-order' => $buttons_order,
|
68 |
+
'data-timeout' => $search_timeout,
|
69 |
+
'data-is-mobile' => wp_is_mobile() ? 'true' : 'false',
|
70 |
+
'data-page-id' => get_queried_object_id(),
|
71 |
+
'data-tax' => get_query_var('taxonomy')
|
72 |
+
);
|
73 |
+
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Filter form data parameters before output
|
77 |
+
* @since 1.69
|
78 |
+
* @param array $params Data parameters array
|
79 |
+
*/
|
80 |
+
$params = apply_filters( 'aws_front_data_parameters', $params );
|
81 |
+
|
82 |
+
|
83 |
+
foreach( $params as $key => $value ) {
|
84 |
+
$params_string .= $key . '="' . esc_attr( $value ) . '" ';
|
85 |
+
}
|
86 |
+
|
87 |
+
$markup = '';
|
88 |
+
$markup .= '<div class="aws-container" ' . $params_string . '>';
|
89 |
+
$markup .= '<form class="aws-search-form" action="' . $form_action . '" method="get" role="search" >';
|
90 |
+
|
91 |
+
$markup .= '<div class="aws-wrapper">';
|
92 |
+
|
93 |
+
$markup .= '<label class="aws-search-label" for="' . esc_attr( $input_id ) . '">' . esc_attr( $placeholder ) . '</label>';
|
94 |
+
$markup .= '<input type="search" name="s" id="' . esc_attr( $input_id ) . '" value="' . get_search_query() . '" class="aws-search-field" placeholder="' . esc_attr( $placeholder ) . '" autocomplete="off" />';
|
95 |
+
$markup .= '<input type="hidden" name="post_type" value="product">';
|
96 |
+
$markup .= '<input type="hidden" name="type_aws" value="true">';
|
97 |
+
|
98 |
+
if ( $current_lang ) {
|
99 |
+
$markup .= '<input type="hidden" name="lang" value="' . esc_attr( $current_lang ) . '">';
|
100 |
+
}
|
101 |
+
|
102 |
+
if ( $url_query_parts ) {
|
103 |
+
foreach( $url_query_parts as $url_query_key => $url_query_value ) {
|
104 |
+
$markup .= '<input type="hidden" name="' . esc_attr( $url_query_key ) . '" value="' . esc_attr( $url_query_value ) . '">';
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
$markup .= '<div class="aws-search-clear">';
|
109 |
+
$markup .= '<span>×</span>';
|
110 |
+
$markup .= '</div>';
|
111 |
+
|
112 |
+
$markup .= '<div class="aws-loader"></div>';
|
113 |
+
|
114 |
+
$markup .= '</div>';
|
115 |
+
|
116 |
+
if ( $buttons_order && $buttons_order !== '1' ) {
|
117 |
+
|
118 |
+
$markup .= '<div class="aws-search-btn aws-form-btn">';
|
119 |
+
$markup .= '<span class="aws-search-btn_icon">';
|
120 |
+
$markup .= '<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24px">';
|
121 |
+
$markup .= '<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>';
|
122 |
+
$markup .= '</svg>';
|
123 |
+
$markup .= '</span>';
|
124 |
+
$markup .= '</div>';
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
$markup .= '</form>';
|
129 |
+
$markup .= '</div>';
|
130 |
+
|
131 |
+
return apply_filters( 'aws_searchbox_markup', $markup, $params );
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
endif;
|
includes/class-aws-order.php
CHANGED
@@ -1,584 +1,584 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Order' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for products sorting
|
11 |
-
*/
|
12 |
-
class AWS_Order {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @var AWS_Order Array of products
|
16 |
-
*/
|
17 |
-
private $products = array();
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Constructor
|
21 |
-
*/
|
22 |
-
public function __construct( $products, $query ) {
|
23 |
-
|
24 |
-
$this->products = $products;
|
25 |
-
|
26 |
-
// Filter
|
27 |
-
$this->filter_results( $query );
|
28 |
-
|
29 |
-
// Order
|
30 |
-
if ( $query->query && ( isset( $query->query['orderby'] ) || isset( $query->query_vars['orderby'] ) ) ) {
|
31 |
-
$this->order( $query );
|
32 |
-
}
|
33 |
-
|
34 |
-
}
|
35 |
-
|
36 |
-
/*
|
37 |
-
* Filter search results
|
38 |
-
*/
|
39 |
-
private function filter_results( $query ) {
|
40 |
-
|
41 |
-
$new_products = array();
|
42 |
-
$filters = array();
|
43 |
-
$attr_filter = array();
|
44 |
-
|
45 |
-
if ( isset( $query->query_vars['meta_query'] ) ) {
|
46 |
-
$meta_query = $query->query_vars['meta_query'];
|
47 |
-
|
48 |
-
if ( isset( $meta_query['price_filter'] ) && isset( $meta_query['price_filter']['value'] ) ) {
|
49 |
-
$price_values = $meta_query['price_filter']['value'];
|
50 |
-
if ( isset( $price_values[0] ) && isset( $price_values[1] ) ) {
|
51 |
-
$filters['price_min'] = $price_values[0];
|
52 |
-
$filters['price_max'] = $price_values[1];
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
}
|
57 |
-
|
58 |
-
if ( ! isset( $filters['price_min'] ) && isset( $_GET['min_price'] ) ) {
|
59 |
-
$filters['price_min'] = sanitize_text_field( $_GET['min_price'] );
|
60 |
-
}
|
61 |
-
|
62 |
-
if ( ! isset( $filters['price_max'] ) && isset( $_GET['max_price'] ) ) {
|
63 |
-
$filters['price_max'] = sanitize_text_field( $_GET['max_price'] );
|
64 |
-
}
|
65 |
-
|
66 |
-
if ( isset( $_GET['rating_filter'] ) && $_GET['rating_filter'] ) {
|
67 |
-
$filters['rating'] = explode( ',', sanitize_text_field( $_GET['rating_filter'] ) );
|
68 |
-
}
|
69 |
-
|
70 |
-
if ( isset( $_GET['filtering'] ) && $_GET['filtering'] && isset( $_GET['filter_product_brand'] ) ) {
|
71 |
-
$filters['brand'] = explode( ',', sanitize_text_field( $_GET['filter_product_brand'] ) );
|
72 |
-
}
|
73 |
-
|
74 |
-
if ( isset( $query->query_vars['tax_query'] ) ) {
|
75 |
-
$tax_query = $query->query_vars['tax_query'];
|
76 |
-
|
77 |
-
if ( $tax_query && is_array( $tax_query ) && ! empty( $tax_query ) ) {
|
78 |
-
foreach( $tax_query as $taxonomy_query ) {
|
79 |
-
if ( is_array( $taxonomy_query ) ) {
|
80 |
-
if ( isset( $taxonomy_query['taxonomy'] ) && strpos( $taxonomy_query['taxonomy'], 'pa_' ) === 0 ) {
|
81 |
-
$tax_name = $taxonomy_query['taxonomy'];
|
82 |
-
$attr_filter[$tax_name] = $taxonomy_query;
|
83 |
-
}
|
84 |
-
}
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Filter available search page filters before apply
|
93 |
-
* @since 2.04
|
94 |
-
* @param array $filters Filters
|
95 |
-
*/
|
96 |
-
$filters = apply_filters( 'aws_search_page_filters', $filters );
|
97 |
-
|
98 |
-
|
99 |
-
foreach( $this->products as $post_array ) {
|
100 |
-
|
101 |
-
if ( isset( $filters['in_status'] ) ) {
|
102 |
-
if ( $post_array['f_stock'] !== $filters['in_status'] ) {
|
103 |
-
continue;
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
if ( isset( $filters['on_sale'] ) ) {
|
108 |
-
if ( $post_array['f_sale'] !== $filters['on_sale'] ) {
|
109 |
-
continue;
|
110 |
-
}
|
111 |
-
}
|
112 |
-
|
113 |
-
if ( isset( $filters['price_min'] ) && isset( $filters['price_max'] ) ) {
|
114 |
-
if ( isset( $post_array['f_price'] ) && $post_array['f_price'] ) {
|
115 |
-
if ( $post_array['f_price'] > $filters['price_max'] || $post_array['f_price'] < $filters['price_min'] ) {
|
116 |
-
continue;
|
117 |
-
}
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
if ( isset( $filters['rating'] ) && is_array( $filters['rating'] ) ) {
|
122 |
-
if ( isset( $post_array['f_rating'] ) ) {
|
123 |
-
if ( array_search( floor( $post_array['f_rating'] ), $filters['rating'] ) === false ) {
|
124 |
-
continue;
|
125 |
-
}
|
126 |
-
}
|
127 |
-
}
|
128 |
-
|
129 |
-
if ( isset( $filters['brand'] ) && is_array( $filters['brand'] ) ) {
|
130 |
-
|
131 |
-
$skip = true;
|
132 |
-
$p_brands = get_the_terms( $post_array['id'], 'product_brand' );
|
133 |
-
|
134 |
-
if ( ! is_wp_error( $p_brands ) && ! empty( $p_brands ) ) {
|
135 |
-
foreach ( $p_brands as $p_brand ) {
|
136 |
-
if ( in_array( $p_brand->term_id, $filters['brand'] ) ) {
|
137 |
-
$skip = false;
|
138 |
-
break;
|
139 |
-
}
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
if ( $skip ) {
|
144 |
-
continue;
|
145 |
-
}
|
146 |
-
|
147 |
-
}
|
148 |
-
|
149 |
-
if ( isset( $filters['tax'] ) && is_array( $filters['tax'] ) ) {
|
150 |
-
|
151 |
-
$skip = true;
|
152 |
-
|
153 |
-
foreach( $filters['tax'] as $taxonomy => $taxonomy_terms ) {
|
154 |
-
|
155 |
-
$terms = get_the_terms( $post_array['id'], $taxonomy );
|
156 |
-
$operator = isset( $taxonomy_terms['operator'] ) ? $taxonomy_terms['operator'] : 'OR';
|
157 |
-
$include_parent = isset( $taxonomy_terms['include_parent'] ) ? $taxonomy_terms['include_parent'] : false;
|
158 |
-
$term_arr = array();
|
159 |
-
|
160 |
-
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
|
161 |
-
foreach ( $terms as $term ) {
|
162 |
-
$term_arr[] = $term->term_id;
|
163 |
-
if ( $include_parent && $term->parent ) {
|
164 |
-
$term_arr[] = $term->parent;
|
165 |
-
$term_parent = get_term( $term->parent, $taxonomy );
|
166 |
-
while ( ! is_wp_error( $term_parent ) && ! empty( $term_parent->parent ) && ! in_array( $term_parent->parent, $term_arr, true ) ) {
|
167 |
-
$term_arr[] = (int) $term_parent->parent;
|
168 |
-
$term_parent = get_term( $term_parent->parent, $taxonomy );
|
169 |
-
}
|
170 |
-
}
|
171 |
-
}
|
172 |
-
} elseif( strpos( $taxonomy, 'pa_' ) !== 0 ) {
|
173 |
-
$terms = get_the_terms( $post_array['id'], 'pa_' . $taxonomy );
|
174 |
-
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
|
175 |
-
foreach ( $terms as $term ) {
|
176 |
-
$term_arr[] = $term->term_id;
|
177 |
-
if ( $include_parent && $term->parent ) {
|
178 |
-
$term_arr[] = $term->parent;
|
179 |
-
$term_parent = get_term( $term->parent, $taxonomy );
|
180 |
-
while ( ! is_wp_error( $term_parent ) && ! empty( $term_parent->parent ) && ! in_array( $term_parent->parent, $term_arr, true ) ) {
|
181 |
-
$term_arr[] = (int) $term_parent->parent;
|
182 |
-
$term_parent = get_term( $term_parent->parent, $taxonomy );
|
183 |
-
}
|
184 |
-
}
|
185 |
-
}
|
186 |
-
}
|
187 |
-
}
|
188 |
-
|
189 |
-
$skip = AWS_Helpers::page_filter_tax( $term_arr, $taxonomy_terms['terms'], $operator );
|
190 |
-
|
191 |
-
if ( $skip ) {
|
192 |
-
break;
|
193 |
-
}
|
194 |
-
|
195 |
-
}
|
196 |
-
|
197 |
-
if ( $skip ) {
|
198 |
-
continue;
|
199 |
-
}
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
if ( $attr_filter && ! empty( $attr_filter ) && is_array( $attr_filter ) ) {
|
204 |
-
|
205 |
-
$product = wc_get_product( $post_array['id'] );
|
206 |
-
$attributes = $product->get_attributes();
|
207 |
-
$product_terms_array = array();
|
208 |
-
$skip = true;
|
209 |
-
|
210 |
-
if ( $attributes && ! empty( $attributes ) ) {
|
211 |
-
|
212 |
-
foreach( $attributes as $attr_name => $attribute_object ) {
|
213 |
-
if ( $attribute_object ) {
|
214 |
-
if ( ( is_object( $attribute_object ) && method_exists( $attribute_object, 'is_taxonomy' ) && $attribute_object->is_taxonomy() ) ||
|
215 |
-
( is_array( $attribute_object ) && isset( $attribute_object['is_taxonomy'] ) && $attribute_object['is_taxonomy'] )
|
216 |
-
) {
|
217 |
-
if ( isset( $attr_filter[$attr_name] ) ) {
|
218 |
-
$product_terms = wp_get_object_terms( $post_array['id'], $attr_name );
|
219 |
-
|
220 |
-
if ( ! is_wp_error( $product_terms ) && ! empty( $product_terms ) ) {
|
221 |
-
foreach ( $product_terms as $product_term ) {
|
222 |
-
$product_terms_array[] = $product_term->slug;
|
223 |
-
}
|
224 |
-
}
|
225 |
-
|
226 |
-
}
|
227 |
-
}
|
228 |
-
}
|
229 |
-
}
|
230 |
-
|
231 |
-
if ( $product_terms_array ) {
|
232 |
-
|
233 |
-
|
234 |
-
foreach( $attr_filter as $attr_filter_name => $attr_filter_object ) {
|
235 |
-
|
236 |
-
$operator = $attr_filter_object['operator'];
|
237 |
-
$attr_filter_terms = $attr_filter_object['terms'];
|
238 |
-
|
239 |
-
$skip = AWS_Helpers::page_filter_tax( $product_terms_array, $attr_filter_terms, $operator );
|
240 |
-
|
241 |
-
if ( $skip ) {
|
242 |
-
break;
|
243 |
-
}
|
244 |
-
|
245 |
-
}
|
246 |
-
|
247 |
-
}
|
248 |
-
|
249 |
-
}
|
250 |
-
|
251 |
-
if ( $skip ) {
|
252 |
-
continue;
|
253 |
-
}
|
254 |
-
|
255 |
-
}
|
256 |
-
|
257 |
-
$new_products[] = $post_array;
|
258 |
-
|
259 |
-
}
|
260 |
-
|
261 |
-
/**
|
262 |
-
* Filter search results after search page filters applied
|
263 |
-
* @since 2.04
|
264 |
-
* @param array $new_products Products
|
265 |
-
*/
|
266 |
-
$this->products = apply_filters( 'aws_products_search_page_filtered', $new_products );
|
267 |
-
|
268 |
-
}
|
269 |
-
|
270 |
-
/*
|
271 |
-
* Sort products
|
272 |
-
*/
|
273 |
-
private function order( $query ) {
|
274 |
-
|
275 |
-
if ( isset( $query->query['orderby'] ) ) {
|
276 |
-
|
277 |
-
$order_by = $query->query['orderby'];
|
278 |
-
|
279 |
-
} else {
|
280 |
-
|
281 |
-
$order_by = $query->query_vars['orderby'];
|
282 |
-
|
283 |
-
if ( $order_by === 'meta_value_num' ) {
|
284 |
-
$order_by = 'price';
|
285 |
-
}
|
286 |
-
|
287 |
-
if ( isset( $query->query_vars['order'] ) ) {
|
288 |
-
$order_by = $order_by . '-' . strtolower( $query->query_vars['order'] );
|
289 |
-
}
|
290 |
-
|
291 |
-
}
|
292 |
-
|
293 |
-
/**
|
294 |
-
* Filter order by value
|
295 |
-
* @since 2.13
|
296 |
-
* @param string $order_by Order by value
|
297 |
-
* @param object $query Page query
|
298 |
-
*/
|
299 |
-
$order_by = apply_filters( 'aws_products_order_by', $order_by, $query );
|
300 |
-
|
301 |
-
switch( $order_by ) {
|
302 |
-
|
303 |
-
case 'price':
|
304 |
-
case 'price-asc':
|
305 |
-
|
306 |
-
if ( isset( $this->products[0]['f_price'] ) ) {
|
307 |
-
usort( $this->products, array( $this, 'compare_price_asc' ) );
|
308 |
-
}
|
309 |
-
|
310 |
-
break;
|
311 |
-
|
312 |
-
case 'price-desc':
|
313 |
-
|
314 |
-
if ( isset( $this->products[0]['f_price'] ) ) {
|
315 |
-
usort( $this->products, array( $this, 'compare_price_desc' ) );
|
316 |
-
}
|
317 |
-
|
318 |
-
break;
|
319 |
-
|
320 |
-
case 'date':
|
321 |
-
case 'date-desc':
|
322 |
-
|
323 |
-
if ( isset( $this->products[0]['post_data'] ) ) {
|
324 |
-
usort( $this->products, array( $this, 'compare_date' ) );
|
325 |
-
}
|
326 |
-
|
327 |
-
break;
|
328 |
-
|
329 |
-
case 'date-asc':
|
330 |
-
|
331 |
-
if ( isset( $this->products[0]['post_data'] ) ) {
|
332 |
-
usort( $this->products, array( $this, 'compare_date_asc' ) );
|
333 |
-
}
|
334 |
-
|
335 |
-
break;
|
336 |
-
|
337 |
-
case 'rating':
|
338 |
-
case 'rating-desc':
|
339 |
-
|
340 |
-
if ( isset( $this->products[0]['f_rating'] ) ) {
|
341 |
-
usort( $this->products, array( $this, 'compare_rating' ) );
|
342 |
-
}
|
343 |
-
|
344 |
-
break;
|
345 |
-
|
346 |
-
case 'rating-asc':
|
347 |
-
|
348 |
-
if ( isset( $this->products[0]['f_rating'] ) ) {
|
349 |
-
usort( $this->products, array( $this, 'compare_rating_asc' ) );
|
350 |
-
}
|
351 |
-
|
352 |
-
break;
|
353 |
-
|
354 |
-
case 'popularity':
|
355 |
-
case 'popularity-desc':
|
356 |
-
|
357 |
-
if ( isset( $this->products[0]['f_reviews'] ) ) {
|
358 |
-
usort( $this->products, array( $this, 'compare_reviews' ) );
|
359 |
-
}
|
360 |
-
|
361 |
-
break;
|
362 |
-
|
363 |
-
case 'popularity-asc':
|
364 |
-
|
365 |
-
if ( isset( $this->products[0]['f_reviews'] ) ) {
|
366 |
-
usort( $this->products, array( $this, 'compare_reviews_asc' ) );
|
367 |
-
}
|
368 |
-
|
369 |
-
break;
|
370 |
-
|
371 |
-
case 'title':
|
372 |
-
case 'title-desc':
|
373 |
-
|
374 |
-
if ( isset( $this->products[0]['title'] ) ) {
|
375 |
-
usort( $this->products, array( $this, 'compare_title' ) );
|
376 |
-
}
|
377 |
-
|
378 |
-
break;
|
379 |
-
|
380 |
-
case 'title-asc':
|
381 |
-
|
382 |
-
if ( isset( $this->products[0]['title'] ) ) {
|
383 |
-
usort( $this->products, array( $this, 'compare_title' ) );
|
384 |
-
$this->products = array_reverse($this->products);
|
385 |
-
}
|
386 |
-
|
387 |
-
break;
|
388 |
-
|
389 |
-
case 'stock_quantity-asc':
|
390 |
-
|
391 |
-
if ( isset( $this->products[0]['id'] ) ) {
|
392 |
-
usort( $this->products, array( $this, 'compare_f_quantity_asc' ) );
|
393 |
-
}
|
394 |
-
|
395 |
-
break;
|
396 |
-
|
397 |
-
case 'stock_quantity-desc':
|
398 |
-
|
399 |
-
if ( isset( $this->products[0]['id'] ) ) {
|
400 |
-
usort( $this->products, array( $this, 'compare_f_quantity_desc' ) );
|
401 |
-
}
|
402 |
-
|
403 |
-
break;
|
404 |
-
|
405 |
-
}
|
406 |
-
|
407 |
-
/**
|
408 |
-
* Filter search results after ordering
|
409 |
-
* @since 2.00
|
410 |
-
* @param array $this->products Products
|
411 |
-
* @param string $order_by Order by value
|
412 |
-
*/
|
413 |
-
$this->products = apply_filters( 'aws_products_order', $this->products, $order_by );
|
414 |
-
|
415 |
-
}
|
416 |
-
|
417 |
-
/*
|
418 |
-
* Compare price values asc
|
419 |
-
*/
|
420 |
-
private function compare_price_asc( $a, $b ) {
|
421 |
-
if ( ! is_numeric( $a['f_price'] ) || ! is_numeric( $b['f_price'] ) ) {
|
422 |
-
return 0;
|
423 |
-
}
|
424 |
-
$a = intval( $a['f_price'] * 100 );
|
425 |
-
$b = intval( $b['f_price'] * 100 );
|
426 |
-
if ($a == $b) {
|
427 |
-
return 0;
|
428 |
-
}
|
429 |
-
return ($a < $b) ? -1 : 1;
|
430 |
-
}
|
431 |
-
|
432 |
-
/*
|
433 |
-
* Compare price values desc
|
434 |
-
*/
|
435 |
-
private function compare_price_desc( $a, $b ) {
|
436 |
-
if ( ! is_numeric( $a['f_price'] ) || ! is_numeric( $b['f_price'] ) ) {
|
437 |
-
return 0;
|
438 |
-
}
|
439 |
-
$a = intval( $a['f_price'] * 100 );
|
440 |
-
$b = intval( $b['f_price'] * 100 );
|
441 |
-
if ($a == $b) {
|
442 |
-
return 0;
|
443 |
-
}
|
444 |
-
return ($a < $b) ? 1 : -1;
|
445 |
-
}
|
446 |
-
|
447 |
-
/*
|
448 |
-
* Compare date
|
449 |
-
*/
|
450 |
-
private function compare_date( $a, $b ) {
|
451 |
-
$a = strtotime( $a['post_data']->post_date );
|
452 |
-
$b = strtotime( $b['post_data']->post_date );
|
453 |
-
if ($a == $b) {
|
454 |
-
return 0;
|
455 |
-
}
|
456 |
-
return ($a < $b) ? 1 : -1;
|
457 |
-
}
|
458 |
-
|
459 |
-
/*
|
460 |
-
* Compare date desc
|
461 |
-
*/
|
462 |
-
private function compare_date_asc( $a, $b ) {
|
463 |
-
$a = strtotime( $a['post_data']->post_date );
|
464 |
-
$b = strtotime( $b['post_data']->post_date );
|
465 |
-
if ($a == $b) {
|
466 |
-
return 0;
|
467 |
-
}
|
468 |
-
return ($a < $b) ? -1 : 1;
|
469 |
-
}
|
470 |
-
|
471 |
-
/*
|
472 |
-
* Compare rating
|
473 |
-
*/
|
474 |
-
private function compare_rating( $a, $b ) {
|
475 |
-
$a = intval( $a['f_rating'] * 100 );
|
476 |
-
$b = intval( $b['f_rating'] * 100 );
|
477 |
-
if ($a == $b) {
|
478 |
-
return 0;
|
479 |
-
}
|
480 |
-
return ($a < $b) ? 1 : -1;
|
481 |
-
}
|
482 |
-
|
483 |
-
/*
|
484 |
-
* Compare rating asc
|
485 |
-
*/
|
486 |
-
private function compare_rating_asc( $a, $b ) {
|
487 |
-
$a = intval( $a['f_rating'] * 100 );
|
488 |
-
$b = intval( $b['f_rating'] * 100 );
|
489 |
-
if ($a == $b) {
|
490 |
-
return 0;
|
491 |
-
}
|
492 |
-
return ($a < $b) ? -1 : 1;
|
493 |
-
}
|
494 |
-
|
495 |
-
/*
|
496 |
-
* Compare popularity
|
497 |
-
*/
|
498 |
-
private function compare_reviews( $a, $b ) {
|
499 |
-
$a = intval( $a['f_reviews'] * 100 );
|
500 |
-
$b = intval( $b['f_reviews'] * 100 );
|
501 |
-
if ($a == $b) {
|
502 |
-
return 0;
|
503 |
-
}
|
504 |
-
return ($a < $b) ? 1 : -1;
|
505 |
-
}
|
506 |
-
|
507 |
-
/*
|
508 |
-
* Compare rating asc
|
509 |
-
*/
|
510 |
-
private function compare_reviews_asc( $a, $b ) {
|
511 |
-
$a = intval( $a['f_reviews'] * 100 );
|
512 |
-
$b = intval( $b['f_reviews'] * 100 );
|
513 |
-
if ($a == $b) {
|
514 |
-
return 0;
|
515 |
-
}
|
516 |
-
return ($a < $b) ? -1 : 1;
|
517 |
-
}
|
518 |
-
|
519 |
-
/*
|
520 |
-
* Compare title desc
|
521 |
-
*/
|
522 |
-
private function compare_title( $a, $b ) {
|
523 |
-
$res = strcasecmp( $a["title"], $b["title"] );
|
524 |
-
return $res;
|
525 |
-
}
|
526 |
-
|
527 |
-
/*
|
528 |
-
* Compare quantity values asc
|
529 |
-
*/
|
530 |
-
private function compare_f_quantity_asc( $a, $b ) {
|
531 |
-
|
532 |
-
$product_a = wc_get_product( $a['id'] );
|
533 |
-
$product_b = wc_get_product( $b['id'] );
|
534 |
-
|
535 |
-
if ( ! is_a( $product_a, 'WC_Product' ) || ! is_a( $product_b, 'WC_Product' ) ) {
|
536 |
-
return 0;
|
537 |
-
}
|
538 |
-
|
539 |
-
$a_val = AWS_Helpers::get_quantity( $product_a );
|
540 |
-
$b_val = AWS_Helpers::get_quantity( $product_b );
|
541 |
-
|
542 |
-
if ($a_val == $b_val) {
|
543 |
-
return 0;
|
544 |
-
}
|
545 |
-
|
546 |
-
return ($a_val < $b_val) ? -1 : 1;
|
547 |
-
|
548 |
-
}
|
549 |
-
|
550 |
-
/*
|
551 |
-
* Compare quantity values desc
|
552 |
-
*/
|
553 |
-
private function compare_f_quantity_desc( $a, $b ) {
|
554 |
-
|
555 |
-
$product_a = wc_get_product( $a['id'] );
|
556 |
-
$product_b = wc_get_product( $b['id'] );
|
557 |
-
|
558 |
-
if ( ! is_a( $product_a, 'WC_Product' ) || ! is_a( $product_b, 'WC_Product' ) ) {
|
559 |
-
return 0;
|
560 |
-
}
|
561 |
-
|
562 |
-
$a_val = AWS_Helpers::get_quantity( $product_a );
|
563 |
-
$b_val = AWS_Helpers::get_quantity( $product_b );
|
564 |
-
|
565 |
-
if ($a_val == $b_val) {
|
566 |
-
return 0;
|
567 |
-
}
|
568 |
-
|
569 |
-
return ($a_val > $b_val) ? -1 : 1;
|
570 |
-
|
571 |
-
}
|
572 |
-
|
573 |
-
/*
|
574 |
-
* Return array of sorted products
|
575 |
-
*/
|
576 |
-
public function result() {
|
577 |
-
|
578 |
-
return $this->products;
|
579 |
-
|
580 |
-
}
|
581 |
-
|
582 |
-
}
|
583 |
-
|
584 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Order' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for products sorting
|
11 |
+
*/
|
12 |
+
class AWS_Order {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var AWS_Order Array of products
|
16 |
+
*/
|
17 |
+
private $products = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Constructor
|
21 |
+
*/
|
22 |
+
public function __construct( $products, $query ) {
|
23 |
+
|
24 |
+
$this->products = $products;
|
25 |
+
|
26 |
+
// Filter
|
27 |
+
$this->filter_results( $query );
|
28 |
+
|
29 |
+
// Order
|
30 |
+
if ( $query->query && ( isset( $query->query['orderby'] ) || isset( $query->query_vars['orderby'] ) ) ) {
|
31 |
+
$this->order( $query );
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
/*
|
37 |
+
* Filter search results
|
38 |
+
*/
|
39 |
+
private function filter_results( $query ) {
|
40 |
+
|
41 |
+
$new_products = array();
|
42 |
+
$filters = array();
|
43 |
+
$attr_filter = array();
|
44 |
+
|
45 |
+
if ( isset( $query->query_vars['meta_query'] ) ) {
|
46 |
+
$meta_query = $query->query_vars['meta_query'];
|
47 |
+
|
48 |
+
if ( isset( $meta_query['price_filter'] ) && isset( $meta_query['price_filter']['value'] ) ) {
|
49 |
+
$price_values = $meta_query['price_filter']['value'];
|
50 |
+
if ( isset( $price_values[0] ) && isset( $price_values[1] ) ) {
|
51 |
+
$filters['price_min'] = $price_values[0];
|
52 |
+
$filters['price_max'] = $price_values[1];
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( ! isset( $filters['price_min'] ) && isset( $_GET['min_price'] ) ) {
|
59 |
+
$filters['price_min'] = sanitize_text_field( $_GET['min_price'] );
|
60 |
+
}
|
61 |
+
|
62 |
+
if ( ! isset( $filters['price_max'] ) && isset( $_GET['max_price'] ) ) {
|
63 |
+
$filters['price_max'] = sanitize_text_field( $_GET['max_price'] );
|
64 |
+
}
|
65 |
+
|
66 |
+
if ( isset( $_GET['rating_filter'] ) && $_GET['rating_filter'] ) {
|
67 |
+
$filters['rating'] = explode( ',', sanitize_text_field( $_GET['rating_filter'] ) );
|
68 |
+
}
|
69 |
+
|
70 |
+
if ( isset( $_GET['filtering'] ) && $_GET['filtering'] && isset( $_GET['filter_product_brand'] ) ) {
|
71 |
+
$filters['brand'] = explode( ',', sanitize_text_field( $_GET['filter_product_brand'] ) );
|
72 |
+
}
|
73 |
+
|
74 |
+
if ( isset( $query->query_vars['tax_query'] ) ) {
|
75 |
+
$tax_query = $query->query_vars['tax_query'];
|
76 |
+
|
77 |
+
if ( $tax_query && is_array( $tax_query ) && ! empty( $tax_query ) ) {
|
78 |
+
foreach( $tax_query as $taxonomy_query ) {
|
79 |
+
if ( is_array( $taxonomy_query ) ) {
|
80 |
+
if ( isset( $taxonomy_query['taxonomy'] ) && strpos( $taxonomy_query['taxonomy'], 'pa_' ) === 0 ) {
|
81 |
+
$tax_name = $taxonomy_query['taxonomy'];
|
82 |
+
$attr_filter[$tax_name] = $taxonomy_query;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Filter available search page filters before apply
|
93 |
+
* @since 2.04
|
94 |
+
* @param array $filters Filters
|
95 |
+
*/
|
96 |
+
$filters = apply_filters( 'aws_search_page_filters', $filters );
|
97 |
+
|
98 |
+
|
99 |
+
foreach( $this->products as $post_array ) {
|
100 |
+
|
101 |
+
if ( isset( $filters['in_status'] ) ) {
|
102 |
+
if ( $post_array['f_stock'] !== $filters['in_status'] ) {
|
103 |
+
continue;
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
if ( isset( $filters['on_sale'] ) ) {
|
108 |
+
if ( $post_array['f_sale'] !== $filters['on_sale'] ) {
|
109 |
+
continue;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
if ( isset( $filters['price_min'] ) && isset( $filters['price_max'] ) ) {
|
114 |
+
if ( isset( $post_array['f_price'] ) && $post_array['f_price'] ) {
|
115 |
+
if ( $post_array['f_price'] > $filters['price_max'] || $post_array['f_price'] < $filters['price_min'] ) {
|
116 |
+
continue;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
if ( isset( $filters['rating'] ) && is_array( $filters['rating'] ) ) {
|
122 |
+
if ( isset( $post_array['f_rating'] ) ) {
|
123 |
+
if ( array_search( floor( $post_array['f_rating'] ), $filters['rating'] ) === false ) {
|
124 |
+
continue;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
if ( isset( $filters['brand'] ) && is_array( $filters['brand'] ) ) {
|
130 |
+
|
131 |
+
$skip = true;
|
132 |
+
$p_brands = get_the_terms( $post_array['id'], 'product_brand' );
|
133 |
+
|
134 |
+
if ( ! is_wp_error( $p_brands ) && ! empty( $p_brands ) ) {
|
135 |
+
foreach ( $p_brands as $p_brand ) {
|
136 |
+
if ( in_array( $p_brand->term_id, $filters['brand'] ) ) {
|
137 |
+
$skip = false;
|
138 |
+
break;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
if ( $skip ) {
|
144 |
+
continue;
|
145 |
+
}
|
146 |
+
|
147 |
+
}
|
148 |
+
|
149 |
+
if ( isset( $filters['tax'] ) && is_array( $filters['tax'] ) ) {
|
150 |
+
|
151 |
+
$skip = true;
|
152 |
+
|
153 |
+
foreach( $filters['tax'] as $taxonomy => $taxonomy_terms ) {
|
154 |
+
|
155 |
+
$terms = get_the_terms( $post_array['id'], $taxonomy );
|
156 |
+
$operator = isset( $taxonomy_terms['operator'] ) ? $taxonomy_terms['operator'] : 'OR';
|
157 |
+
$include_parent = isset( $taxonomy_terms['include_parent'] ) ? $taxonomy_terms['include_parent'] : false;
|
158 |
+
$term_arr = array();
|
159 |
+
|
160 |
+
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
|
161 |
+
foreach ( $terms as $term ) {
|
162 |
+
$term_arr[] = $term->term_id;
|
163 |
+
if ( $include_parent && $term->parent ) {
|
164 |
+
$term_arr[] = $term->parent;
|
165 |
+
$term_parent = get_term( $term->parent, $taxonomy );
|
166 |
+
while ( ! is_wp_error( $term_parent ) && ! empty( $term_parent->parent ) && ! in_array( $term_parent->parent, $term_arr, true ) ) {
|
167 |
+
$term_arr[] = (int) $term_parent->parent;
|
168 |
+
$term_parent = get_term( $term_parent->parent, $taxonomy );
|
169 |
+
}
|
170 |
+
}
|
171 |
+
}
|
172 |
+
} elseif( strpos( $taxonomy, 'pa_' ) !== 0 ) {
|
173 |
+
$terms = get_the_terms( $post_array['id'], 'pa_' . $taxonomy );
|
174 |
+
if ( ! is_wp_error( $terms ) && ! empty( $terms ) ) {
|
175 |
+
foreach ( $terms as $term ) {
|
176 |
+
$term_arr[] = $term->term_id;
|
177 |
+
if ( $include_parent && $term->parent ) {
|
178 |
+
$term_arr[] = $term->parent;
|
179 |
+
$term_parent = get_term( $term->parent, $taxonomy );
|
180 |
+
while ( ! is_wp_error( $term_parent ) && ! empty( $term_parent->parent ) && ! in_array( $term_parent->parent, $term_arr, true ) ) {
|
181 |
+
$term_arr[] = (int) $term_parent->parent;
|
182 |
+
$term_parent = get_term( $term_parent->parent, $taxonomy );
|
183 |
+
}
|
184 |
+
}
|
185 |
+
}
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
$skip = AWS_Helpers::page_filter_tax( $term_arr, $taxonomy_terms['terms'], $operator );
|
190 |
+
|
191 |
+
if ( $skip ) {
|
192 |
+
break;
|
193 |
+
}
|
194 |
+
|
195 |
+
}
|
196 |
+
|
197 |
+
if ( $skip ) {
|
198 |
+
continue;
|
199 |
+
}
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
if ( $attr_filter && ! empty( $attr_filter ) && is_array( $attr_filter ) ) {
|
204 |
+
|
205 |
+
$product = wc_get_product( $post_array['id'] );
|
206 |
+
$attributes = $product->get_attributes();
|
207 |
+
$product_terms_array = array();
|
208 |
+
$skip = true;
|
209 |
+
|
210 |
+
if ( $attributes && ! empty( $attributes ) ) {
|
211 |
+
|
212 |
+
foreach( $attributes as $attr_name => $attribute_object ) {
|
213 |
+
if ( $attribute_object ) {
|
214 |
+
if ( ( is_object( $attribute_object ) && method_exists( $attribute_object, 'is_taxonomy' ) && $attribute_object->is_taxonomy() ) ||
|
215 |
+
( is_array( $attribute_object ) && isset( $attribute_object['is_taxonomy'] ) && $attribute_object['is_taxonomy'] )
|
216 |
+
) {
|
217 |
+
if ( isset( $attr_filter[$attr_name] ) ) {
|
218 |
+
$product_terms = wp_get_object_terms( $post_array['id'], $attr_name );
|
219 |
+
|
220 |
+
if ( ! is_wp_error( $product_terms ) && ! empty( $product_terms ) ) {
|
221 |
+
foreach ( $product_terms as $product_term ) {
|
222 |
+
$product_terms_array[] = $product_term->slug;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
}
|
227 |
+
}
|
228 |
+
}
|
229 |
+
}
|
230 |
+
|
231 |
+
if ( $product_terms_array ) {
|
232 |
+
|
233 |
+
|
234 |
+
foreach( $attr_filter as $attr_filter_name => $attr_filter_object ) {
|
235 |
+
|
236 |
+
$operator = isset( $attr_filter_object['operator'] ) ? $attr_filter_object['operator'] : 'OR';
|
237 |
+
$attr_filter_terms = $attr_filter_object['terms'];
|
238 |
+
|
239 |
+
$skip = AWS_Helpers::page_filter_tax( $product_terms_array, $attr_filter_terms, $operator );
|
240 |
+
|
241 |
+
if ( $skip ) {
|
242 |
+
break;
|
243 |
+
}
|
244 |
+
|
245 |
+
}
|
246 |
+
|
247 |
+
}
|
248 |
+
|
249 |
+
}
|
250 |
+
|
251 |
+
if ( $skip ) {
|
252 |
+
continue;
|
253 |
+
}
|
254 |
+
|
255 |
+
}
|
256 |
+
|
257 |
+
$new_products[] = $post_array;
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Filter search results after search page filters applied
|
263 |
+
* @since 2.04
|
264 |
+
* @param array $new_products Products
|
265 |
+
*/
|
266 |
+
$this->products = apply_filters( 'aws_products_search_page_filtered', $new_products );
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
/*
|
271 |
+
* Sort products
|
272 |
+
*/
|
273 |
+
private function order( $query ) {
|
274 |
+
|
275 |
+
if ( isset( $query->query['orderby'] ) ) {
|
276 |
+
|
277 |
+
$order_by = $query->query['orderby'];
|
278 |
+
|
279 |
+
} else {
|
280 |
+
|
281 |
+
$order_by = $query->query_vars['orderby'];
|
282 |
+
|
283 |
+
if ( $order_by === 'meta_value_num' ) {
|
284 |
+
$order_by = 'price';
|
285 |
+
}
|
286 |
+
|
287 |
+
if ( isset( $query->query_vars['order'] ) ) {
|
288 |
+
$order_by = $order_by . '-' . strtolower( $query->query_vars['order'] );
|
289 |
+
}
|
290 |
+
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Filter order by value
|
295 |
+
* @since 2.13
|
296 |
+
* @param string $order_by Order by value
|
297 |
+
* @param object $query Page query
|
298 |
+
*/
|
299 |
+
$order_by = apply_filters( 'aws_products_order_by', $order_by, $query );
|
300 |
+
|
301 |
+
switch( $order_by ) {
|
302 |
+
|
303 |
+
case 'price':
|
304 |
+
case 'price-asc':
|
305 |
+
|
306 |
+
if ( isset( $this->products[0]['f_price'] ) ) {
|
307 |
+
usort( $this->products, array( $this, 'compare_price_asc' ) );
|
308 |
+
}
|
309 |
+
|
310 |
+
break;
|
311 |
+
|
312 |
+
case 'price-desc':
|
313 |
+
|
314 |
+
if ( isset( $this->products[0]['f_price'] ) ) {
|
315 |
+
usort( $this->products, array( $this, 'compare_price_desc' ) );
|
316 |
+
}
|
317 |
+
|
318 |
+
break;
|
319 |
+
|
320 |
+
case 'date':
|
321 |
+
case 'date-desc':
|
322 |
+
|
323 |
+
if ( isset( $this->products[0]['post_data'] ) ) {
|
324 |
+
usort( $this->products, array( $this, 'compare_date' ) );
|
325 |
+
}
|
326 |
+
|
327 |
+
break;
|
328 |
+
|
329 |
+
case 'date-asc':
|
330 |
+
|
331 |
+
if ( isset( $this->products[0]['post_data'] ) ) {
|
332 |
+
usort( $this->products, array( $this, 'compare_date_asc' ) );
|
333 |
+
}
|
334 |
+
|
335 |
+
break;
|
336 |
+
|
337 |
+
case 'rating':
|
338 |
+
case 'rating-desc':
|
339 |
+
|
340 |
+
if ( isset( $this->products[0]['f_rating'] ) ) {
|
341 |
+
usort( $this->products, array( $this, 'compare_rating' ) );
|
342 |
+
}
|
343 |
+
|
344 |
+
break;
|
345 |
+
|
346 |
+
case 'rating-asc':
|
347 |
+
|
348 |
+
if ( isset( $this->products[0]['f_rating'] ) ) {
|
349 |
+
usort( $this->products, array( $this, 'compare_rating_asc' ) );
|
350 |
+
}
|
351 |
+
|
352 |
+
break;
|
353 |
+
|
354 |
+
case 'popularity':
|
355 |
+
case 'popularity-desc':
|
356 |
+
|
357 |
+
if ( isset( $this->products[0]['f_reviews'] ) ) {
|
358 |
+
usort( $this->products, array( $this, 'compare_reviews' ) );
|
359 |
+
}
|
360 |
+
|
361 |
+
break;
|
362 |
+
|
363 |
+
case 'popularity-asc':
|
364 |
+
|
365 |
+
if ( isset( $this->products[0]['f_reviews'] ) ) {
|
366 |
+
usort( $this->products, array( $this, 'compare_reviews_asc' ) );
|
367 |
+
}
|
368 |
+
|
369 |
+
break;
|
370 |
+
|
371 |
+
case 'title':
|
372 |
+
case 'title-desc':
|
373 |
+
|
374 |
+
if ( isset( $this->products[0]['title'] ) ) {
|
375 |
+
usort( $this->products, array( $this, 'compare_title' ) );
|
376 |
+
}
|
377 |
+
|
378 |
+
break;
|
379 |
+
|
380 |
+
case 'title-asc':
|
381 |
+
|
382 |
+
if ( isset( $this->products[0]['title'] ) ) {
|
383 |
+
usort( $this->products, array( $this, 'compare_title' ) );
|
384 |
+
$this->products = array_reverse($this->products);
|
385 |
+
}
|
386 |
+
|
387 |
+
break;
|
388 |
+
|
389 |
+
case 'stock_quantity-asc':
|
390 |
+
|
391 |
+
if ( isset( $this->products[0]['id'] ) ) {
|
392 |
+
usort( $this->products, array( $this, 'compare_f_quantity_asc' ) );
|
393 |
+
}
|
394 |
+
|
395 |
+
break;
|
396 |
+
|
397 |
+
case 'stock_quantity-desc':
|
398 |
+
|
399 |
+
if ( isset( $this->products[0]['id'] ) ) {
|
400 |
+
usort( $this->products, array( $this, 'compare_f_quantity_desc' ) );
|
401 |
+
}
|
402 |
+
|
403 |
+
break;
|
404 |
+
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* Filter search results after ordering
|
409 |
+
* @since 2.00
|
410 |
+
* @param array $this->products Products
|
411 |
+
* @param string $order_by Order by value
|
412 |
+
*/
|
413 |
+
$this->products = apply_filters( 'aws_products_order', $this->products, $order_by );
|
414 |
+
|
415 |
+
}
|
416 |
+
|
417 |
+
/*
|
418 |
+
* Compare price values asc
|
419 |
+
*/
|
420 |
+
private function compare_price_asc( $a, $b ) {
|
421 |
+
if ( ! is_numeric( $a['f_price'] ) || ! is_numeric( $b['f_price'] ) ) {
|
422 |
+
return 0;
|
423 |
+
}
|
424 |
+
$a = intval( $a['f_price'] * 100 );
|
425 |
+
$b = intval( $b['f_price'] * 100 );
|
426 |
+
if ($a == $b) {
|
427 |
+
return 0;
|
428 |
+
}
|
429 |
+
return ($a < $b) ? -1 : 1;
|
430 |
+
}
|
431 |
+
|
432 |
+
/*
|
433 |
+
* Compare price values desc
|
434 |
+
*/
|
435 |
+
private function compare_price_desc( $a, $b ) {
|
436 |
+
if ( ! is_numeric( $a['f_price'] ) || ! is_numeric( $b['f_price'] ) ) {
|
437 |
+
return 0;
|
438 |
+
}
|
439 |
+
$a = intval( $a['f_price'] * 100 );
|
440 |
+
$b = intval( $b['f_price'] * 100 );
|
441 |
+
if ($a == $b) {
|
442 |
+
return 0;
|
443 |
+
}
|
444 |
+
return ($a < $b) ? 1 : -1;
|
445 |
+
}
|
446 |
+
|
447 |
+
/*
|
448 |
+
* Compare date
|
449 |
+
*/
|
450 |
+
private function compare_date( $a, $b ) {
|
451 |
+
$a = strtotime( $a['post_data']->post_date );
|
452 |
+
$b = strtotime( $b['post_data']->post_date );
|
453 |
+
if ($a == $b) {
|
454 |
+
return 0;
|
455 |
+
}
|
456 |
+
return ($a < $b) ? 1 : -1;
|
457 |
+
}
|
458 |
+
|
459 |
+
/*
|
460 |
+
* Compare date desc
|
461 |
+
*/
|
462 |
+
private function compare_date_asc( $a, $b ) {
|
463 |
+
$a = strtotime( $a['post_data']->post_date );
|
464 |
+
$b = strtotime( $b['post_data']->post_date );
|
465 |
+
if ($a == $b) {
|
466 |
+
return 0;
|
467 |
+
}
|
468 |
+
return ($a < $b) ? -1 : 1;
|
469 |
+
}
|
470 |
+
|
471 |
+
/*
|
472 |
+
* Compare rating
|
473 |
+
*/
|
474 |
+
private function compare_rating( $a, $b ) {
|
475 |
+
$a = intval( $a['f_rating'] * 100 );
|
476 |
+
$b = intval( $b['f_rating'] * 100 );
|
477 |
+
if ($a == $b) {
|
478 |
+
return 0;
|
479 |
+
}
|
480 |
+
return ($a < $b) ? 1 : -1;
|
481 |
+
}
|
482 |
+
|
483 |
+
/*
|
484 |
+
* Compare rating asc
|
485 |
+
*/
|
486 |
+
private function compare_rating_asc( $a, $b ) {
|
487 |
+
$a = intval( $a['f_rating'] * 100 );
|
488 |
+
$b = intval( $b['f_rating'] * 100 );
|
489 |
+
if ($a == $b) {
|
490 |
+
return 0;
|
491 |
+
}
|
492 |
+
return ($a < $b) ? -1 : 1;
|
493 |
+
}
|
494 |
+
|
495 |
+
/*
|
496 |
+
* Compare popularity
|
497 |
+
*/
|
498 |
+
private function compare_reviews( $a, $b ) {
|
499 |
+
$a = intval( $a['f_reviews'] * 100 );
|
500 |
+
$b = intval( $b['f_reviews'] * 100 );
|
501 |
+
if ($a == $b) {
|
502 |
+
return 0;
|
503 |
+
}
|
504 |
+
return ($a < $b) ? 1 : -1;
|
505 |
+
}
|
506 |
+
|
507 |
+
/*
|
508 |
+
* Compare rating asc
|
509 |
+
*/
|
510 |
+
private function compare_reviews_asc( $a, $b ) {
|
511 |
+
$a = intval( $a['f_reviews'] * 100 );
|
512 |
+
$b = intval( $b['f_reviews'] * 100 );
|
513 |
+
if ($a == $b) {
|
514 |
+
return 0;
|
515 |
+
}
|
516 |
+
return ($a < $b) ? -1 : 1;
|
517 |
+
}
|
518 |
+
|
519 |
+
/*
|
520 |
+
* Compare title desc
|
521 |
+
*/
|
522 |
+
private function compare_title( $a, $b ) {
|
523 |
+
$res = strcasecmp( $a["title"], $b["title"] );
|
524 |
+
return $res;
|
525 |
+
}
|
526 |
+
|
527 |
+
/*
|
528 |
+
* Compare quantity values asc
|
529 |
+
*/
|
530 |
+
private function compare_f_quantity_asc( $a, $b ) {
|
531 |
+
|
532 |
+
$product_a = wc_get_product( $a['id'] );
|
533 |
+
$product_b = wc_get_product( $b['id'] );
|
534 |
+
|
535 |
+
if ( ! is_a( $product_a, 'WC_Product' ) || ! is_a( $product_b, 'WC_Product' ) ) {
|
536 |
+
return 0;
|
537 |
+
}
|
538 |
+
|
539 |
+
$a_val = AWS_Helpers::get_quantity( $product_a );
|
540 |
+
$b_val = AWS_Helpers::get_quantity( $product_b );
|
541 |
+
|
542 |
+
if ($a_val == $b_val) {
|
543 |
+
return 0;
|
544 |
+
}
|
545 |
+
|
546 |
+
return ($a_val < $b_val) ? -1 : 1;
|
547 |
+
|
548 |
+
}
|
549 |
+
|
550 |
+
/*
|
551 |
+
* Compare quantity values desc
|
552 |
+
*/
|
553 |
+
private function compare_f_quantity_desc( $a, $b ) {
|
554 |
+
|
555 |
+
$product_a = wc_get_product( $a['id'] );
|
556 |
+
$product_b = wc_get_product( $b['id'] );
|
557 |
+
|
558 |
+
if ( ! is_a( $product_a, 'WC_Product' ) || ! is_a( $product_b, 'WC_Product' ) ) {
|
559 |
+
return 0;
|
560 |
+
}
|
561 |
+
|
562 |
+
$a_val = AWS_Helpers::get_quantity( $product_a );
|
563 |
+
$b_val = AWS_Helpers::get_quantity( $product_b );
|
564 |
+
|
565 |
+
if ($a_val == $b_val) {
|
566 |
+
return 0;
|
567 |
+
}
|
568 |
+
|
569 |
+
return ($a_val > $b_val) ? -1 : 1;
|
570 |
+
|
571 |
+
}
|
572 |
+
|
573 |
+
/*
|
574 |
+
* Return array of sorted products
|
575 |
+
*/
|
576 |
+
public function result() {
|
577 |
+
|
578 |
+
return $this->products;
|
579 |
+
|
580 |
+
}
|
581 |
+
|
582 |
+
}
|
583 |
+
|
584 |
endif;
|
includes/class-aws-plurals.php
CHANGED
@@ -1,188 +1,188 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Plurals' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for plurals words forms
|
11 |
-
*/
|
12 |
-
class AWS_Plurals {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Singular rules
|
16 |
-
*
|
17 |
-
* @var array
|
18 |
-
*/
|
19 |
-
protected static $_singular = array(
|
20 |
-
'/(s)tatuses$/i' => '\1\2tatus',
|
21 |
-
'/^(.*)(menu)s$/i' => '\1\2',
|
22 |
-
'/(quiz)zes$/i' => '\\1',
|
23 |
-
'/(matr)ices$/i' => '\1ix',
|
24 |
-
'/(vert|ind)ices$/i' => '\1ex',
|
25 |
-
'/^(ox)en/i' => '\1',
|
26 |
-
'/(alias)(es)*$/i' => '\1',
|
27 |
-
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
|
28 |
-
'/([ftw]ax)es/i' => '\1',
|
29 |
-
'/(cris|ax|test)es$/i' => '\1is',
|
30 |
-
'/(shoe)s$/i' => '\1',
|
31 |
-
'/(o)es$/i' => '\1',
|
32 |
-
'/ouses$/' => 'ouse',
|
33 |
-
'/([^a])uses$/' => '\1us',
|
34 |
-
'/([m|l])ice$/i' => '\1ouse',
|
35 |
-
'/(x|ch|ss|sh)es$/i' => '\1',
|
36 |
-
'/(m)ovies$/i' => '\1\2ovie',
|
37 |
-
'/(s)eries$/i' => '\1\2eries',
|
38 |
-
'/([^aeiouy]|qu)ies$/i' => '\1y',
|
39 |
-
'/(tive)s$/i' => '\1',
|
40 |
-
'/(hive)s$/i' => '\1',
|
41 |
-
'/(drive)s$/i' => '\1',
|
42 |
-
'/(^analy)ses$/i' => '\1sis',
|
43 |
-
'/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
|
44 |
-
'/([ti])a$/i' => '\1um',
|
45 |
-
'/(p)eople$/i' => '\1\2erson',
|
46 |
-
'/(m)en$/i' => '\1an',
|
47 |
-
'/(c)hildren$/i' => '\1\2hild',
|
48 |
-
'/(n)ews$/i' => '\1\2ews',
|
49 |
-
'/eaus$/' => 'eau',
|
50 |
-
'/^(.*us)$/' => '\\1',
|
51 |
-
'/s$/i' => ''
|
52 |
-
);
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Irregular rules
|
56 |
-
*
|
57 |
-
* @var array
|
58 |
-
*/
|
59 |
-
protected static $_irregular = array(
|
60 |
-
'atlases' => 'atlas',
|
61 |
-
'beefs' => 'beef',
|
62 |
-
'briefs' => 'brief',
|
63 |
-
'brothers' => 'brother',
|
64 |
-
'cafes' => 'cafe',
|
65 |
-
'children' => 'child',
|
66 |
-
'cookies' => 'cookie',
|
67 |
-
'corpuses' => 'corpus',
|
68 |
-
'cows' => 'cow',
|
69 |
-
'criteria' => 'criterion',
|
70 |
-
'ganglions' => 'ganglion',
|
71 |
-
'genies' => 'genie',
|
72 |
-
'genera' => 'genus',
|
73 |
-
'graffiti' => 'graffito',
|
74 |
-
'hoofs' => 'hoof',
|
75 |
-
'loaves' => 'loaf',
|
76 |
-
'men' => 'man',
|
77 |
-
'monies' => 'money',
|
78 |
-
'mongooses' => 'mongoose',
|
79 |
-
'moves' => 'move',
|
80 |
-
'mythoi' => 'mythos',
|
81 |
-
'niches' => 'niche',
|
82 |
-
'numina' => 'numen',
|
83 |
-
'occiputs' => 'occiput',
|
84 |
-
'octopuses' => 'octopus',
|
85 |
-
'opuses' => 'opus',
|
86 |
-
'oxen' => 'ox',
|
87 |
-
'penises' => 'penis',
|
88 |
-
'sexes' => 'sex',
|
89 |
-
'soliloquies' => 'soliloquy',
|
90 |
-
'testes' => 'testis',
|
91 |
-
'trilbys' => 'trilby',
|
92 |
-
'turfs' => 'turf',
|
93 |
-
'potatoes' => 'potato',
|
94 |
-
'heroes' => 'hero',
|
95 |
-
'teeth' => 'tooth',
|
96 |
-
'geese' => 'goose',
|
97 |
-
'feet' => 'foot',
|
98 |
-
'foes' => 'foe',
|
99 |
-
'sieves' => 'sieve',
|
100 |
-
'caches' => 'cache',
|
101 |
-
);
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Words that should not be inflected
|
105 |
-
*
|
106 |
-
* @var array
|
107 |
-
*/
|
108 |
-
protected static $_uninflected = array(
|
109 |
-
'.*[nrlm]ese', '.*data', '.*deer', '.*fish', '.*measles', '.*ois',
|
110 |
-
'.*pox', '.*sheep', 'feedback', 'stadia', '.*?media',
|
111 |
-
'chassis', 'clippers', 'debris', 'diabetes', 'equipment', 'gallows',
|
112 |
-
'graffiti', 'headquarters', 'information', 'innings', 'news', 'nexus',
|
113 |
-
'pokemon', 'proceedings', 'research', 'sea[- ]bass', 'series', 'species', 'weather'
|
114 |
-
);
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Method cache array.
|
118 |
-
*
|
119 |
-
* @var array
|
120 |
-
*/
|
121 |
-
protected static $_cache = array();
|
122 |
-
|
123 |
-
/**
|
124 |
-
* Cache inflected values, and return if already available
|
125 |
-
*
|
126 |
-
* @param string $type Inflection type
|
127 |
-
* @param string $key Original value
|
128 |
-
* @param string|bool $value Inflected value
|
129 |
-
* @return string|false Inflected value on cache hit or false on cache miss.
|
130 |
-
*/
|
131 |
-
protected static function _cache($type, $key, $value = false)
|
132 |
-
{
|
133 |
-
$key = '_' . $key;
|
134 |
-
$type = '_' . $type;
|
135 |
-
if ($value !== false) {
|
136 |
-
static::$_cache[$type][$key] = $value;
|
137 |
-
return $value;
|
138 |
-
}
|
139 |
-
if (!isset(static::$_cache[$type][$key])) {
|
140 |
-
return false;
|
141 |
-
}
|
142 |
-
return static::$_cache[$type][$key];
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* Return $word in singular form.
|
147 |
-
*
|
148 |
-
* @param string $word Word in plural
|
149 |
-
* @return string Word in singular
|
150 |
-
*/
|
151 |
-
public static function singularize( $word ) {
|
152 |
-
|
153 |
-
if ( isset( static::$_cache['singularize'][$word] ) ) {
|
154 |
-
return static::$_cache['singularize'][$word];
|
155 |
-
}
|
156 |
-
|
157 |
-
if ( isset( static::$_irregular[$word] ) ) {
|
158 |
-
static::$_cache['singularize'][$word] = static::$_irregular[$word];
|
159 |
-
return static::$_cache['singularize'][$word];
|
160 |
-
}
|
161 |
-
|
162 |
-
if ( !isset( static::$_cache['uninflected'] ) ) {
|
163 |
-
static::$_cache['uninflected'] = '(?:' . implode('|', static::$_uninflected) . ')';
|
164 |
-
}
|
165 |
-
|
166 |
-
if ( preg_match( '/^(' . static::$_cache['uninflected'] . ')$/i', $word, $regs ) ) {
|
167 |
-
static::$_cache['singularize'][$word] = $word;
|
168 |
-
return $word;
|
169 |
-
}
|
170 |
-
|
171 |
-
if ( preg_match( '/(s|es|ies)$/i', $word, $match ) ) {
|
172 |
-
foreach ( static::$_singular as $rule => $replacement ) {
|
173 |
-
if ( preg_match($rule, $word ) ) {
|
174 |
-
static::$_cache['singularize'][$word] = preg_replace( $rule, $replacement, $word );
|
175 |
-
return static::$_cache['singularize'][$word];
|
176 |
-
}
|
177 |
-
}
|
178 |
-
}
|
179 |
-
|
180 |
-
static::$_cache['singularize'][$word] = $word;
|
181 |
-
|
182 |
-
return $word;
|
183 |
-
|
184 |
-
}
|
185 |
-
|
186 |
-
}
|
187 |
-
|
188 |
-
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Plurals' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plurals words forms
|
11 |
+
*/
|
12 |
+
class AWS_Plurals {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Singular rules
|
16 |
+
*
|
17 |
+
* @var array
|
18 |
+
*/
|
19 |
+
protected static $_singular = array(
|
20 |
+
'/(s)tatuses$/i' => '\1\2tatus',
|
21 |
+
'/^(.*)(menu)s$/i' => '\1\2',
|
22 |
+
'/(quiz)zes$/i' => '\\1',
|
23 |
+
'/(matr)ices$/i' => '\1ix',
|
24 |
+
'/(vert|ind)ices$/i' => '\1ex',
|
25 |
+
'/^(ox)en/i' => '\1',
|
26 |
+
'/(alias)(es)*$/i' => '\1',
|
27 |
+
'/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|viri?)i$/i' => '\1us',
|
28 |
+
'/([ftw]ax)es/i' => '\1',
|
29 |
+
'/(cris|ax|test)es$/i' => '\1is',
|
30 |
+
'/(shoe)s$/i' => '\1',
|
31 |
+
'/(o)es$/i' => '\1',
|
32 |
+
'/ouses$/' => 'ouse',
|
33 |
+
'/([^a])uses$/' => '\1us',
|
34 |
+
'/([m|l])ice$/i' => '\1ouse',
|
35 |
+
'/(x|ch|ss|sh)es$/i' => '\1',
|
36 |
+
'/(m)ovies$/i' => '\1\2ovie',
|
37 |
+
'/(s)eries$/i' => '\1\2eries',
|
38 |
+
'/([^aeiouy]|qu)ies$/i' => '\1y',
|
39 |
+
'/(tive)s$/i' => '\1',
|
40 |
+
'/(hive)s$/i' => '\1',
|
41 |
+
'/(drive)s$/i' => '\1',
|
42 |
+
'/(^analy)ses$/i' => '\1sis',
|
43 |
+
'/(analy|diagno|^ba|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => '\1\2sis',
|
44 |
+
'/([ti])a$/i' => '\1um',
|
45 |
+
'/(p)eople$/i' => '\1\2erson',
|
46 |
+
'/(m)en$/i' => '\1an',
|
47 |
+
'/(c)hildren$/i' => '\1\2hild',
|
48 |
+
'/(n)ews$/i' => '\1\2ews',
|
49 |
+
'/eaus$/' => 'eau',
|
50 |
+
'/^(.*us)$/' => '\\1',
|
51 |
+
'/s$/i' => ''
|
52 |
+
);
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Irregular rules
|
56 |
+
*
|
57 |
+
* @var array
|
58 |
+
*/
|
59 |
+
protected static $_irregular = array(
|
60 |
+
'atlases' => 'atlas',
|
61 |
+
'beefs' => 'beef',
|
62 |
+
'briefs' => 'brief',
|
63 |
+
'brothers' => 'brother',
|
64 |
+
'cafes' => 'cafe',
|
65 |
+
'children' => 'child',
|
66 |
+
'cookies' => 'cookie',
|
67 |
+
'corpuses' => 'corpus',
|
68 |
+
'cows' => 'cow',
|
69 |
+
'criteria' => 'criterion',
|
70 |
+
'ganglions' => 'ganglion',
|
71 |
+
'genies' => 'genie',
|
72 |
+
'genera' => 'genus',
|
73 |
+
'graffiti' => 'graffito',
|
74 |
+
'hoofs' => 'hoof',
|
75 |
+
'loaves' => 'loaf',
|
76 |
+
'men' => 'man',
|
77 |
+
'monies' => 'money',
|
78 |
+
'mongooses' => 'mongoose',
|
79 |
+
'moves' => 'move',
|
80 |
+
'mythoi' => 'mythos',
|
81 |
+
'niches' => 'niche',
|
82 |
+
'numina' => 'numen',
|
83 |
+
'occiputs' => 'occiput',
|
84 |
+
'octopuses' => 'octopus',
|
85 |
+
'opuses' => 'opus',
|
86 |
+
'oxen' => 'ox',
|
87 |
+
'penises' => 'penis',
|
88 |
+
'sexes' => 'sex',
|
89 |
+
'soliloquies' => 'soliloquy',
|
90 |
+
'testes' => 'testis',
|
91 |
+
'trilbys' => 'trilby',
|
92 |
+
'turfs' => 'turf',
|
93 |
+
'potatoes' => 'potato',
|
94 |
+
'heroes' => 'hero',
|
95 |
+
'teeth' => 'tooth',
|
96 |
+
'geese' => 'goose',
|
97 |
+
'feet' => 'foot',
|
98 |
+
'foes' => 'foe',
|
99 |
+
'sieves' => 'sieve',
|
100 |
+
'caches' => 'cache',
|
101 |
+
);
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Words that should not be inflected
|
105 |
+
*
|
106 |
+
* @var array
|
107 |
+
*/
|
108 |
+
protected static $_uninflected = array(
|
109 |
+
'.*[nrlm]ese', '.*data', '.*deer', '.*fish', '.*measles', '.*ois',
|
110 |
+
'.*pox', '.*sheep', 'feedback', 'stadia', '.*?media',
|
111 |
+
'chassis', 'clippers', 'debris', 'diabetes', 'equipment', 'gallows',
|
112 |
+
'graffiti', 'headquarters', 'information', 'innings', 'news', 'nexus',
|
113 |
+
'pokemon', 'proceedings', 'research', 'sea[- ]bass', 'series', 'species', 'weather'
|
114 |
+
);
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Method cache array.
|
118 |
+
*
|
119 |
+
* @var array
|
120 |
+
*/
|
121 |
+
protected static $_cache = array();
|
122 |
+
|
123 |
+
/**
|
124 |
+
* Cache inflected values, and return if already available
|
125 |
+
*
|
126 |
+
* @param string $type Inflection type
|
127 |
+
* @param string $key Original value
|
128 |
+
* @param string|bool $value Inflected value
|
129 |
+
* @return string|false Inflected value on cache hit or false on cache miss.
|
130 |
+
*/
|
131 |
+
protected static function _cache($type, $key, $value = false)
|
132 |
+
{
|
133 |
+
$key = '_' . $key;
|
134 |
+
$type = '_' . $type;
|
135 |
+
if ($value !== false) {
|
136 |
+
static::$_cache[$type][$key] = $value;
|
137 |
+
return $value;
|
138 |
+
}
|
139 |
+
if (!isset(static::$_cache[$type][$key])) {
|
140 |
+
return false;
|
141 |
+
}
|
142 |
+
return static::$_cache[$type][$key];
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Return $word in singular form.
|
147 |
+
*
|
148 |
+
* @param string $word Word in plural
|
149 |
+
* @return string Word in singular
|
150 |
+
*/
|
151 |
+
public static function singularize( $word ) {
|
152 |
+
|
153 |
+
if ( isset( static::$_cache['singularize'][$word] ) ) {
|
154 |
+
return static::$_cache['singularize'][$word];
|
155 |
+
}
|
156 |
+
|
157 |
+
if ( isset( static::$_irregular[$word] ) ) {
|
158 |
+
static::$_cache['singularize'][$word] = static::$_irregular[$word];
|
159 |
+
return static::$_cache['singularize'][$word];
|
160 |
+
}
|
161 |
+
|
162 |
+
if ( !isset( static::$_cache['uninflected'] ) ) {
|
163 |
+
static::$_cache['uninflected'] = '(?:' . implode('|', static::$_uninflected) . ')';
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( preg_match( '/^(' . static::$_cache['uninflected'] . ')$/i', $word, $regs ) ) {
|
167 |
+
static::$_cache['singularize'][$word] = $word;
|
168 |
+
return $word;
|
169 |
+
}
|
170 |
+
|
171 |
+
if ( preg_match( '/(s|es|ies)$/i', $word, $match ) ) {
|
172 |
+
foreach ( static::$_singular as $rule => $replacement ) {
|
173 |
+
if ( preg_match($rule, $word ) ) {
|
174 |
+
static::$_cache['singularize'][$word] = preg_replace( $rule, $replacement, $word );
|
175 |
+
return static::$_cache['singularize'][$word];
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}
|
179 |
+
|
180 |
+
static::$_cache['singularize'][$word] = $word;
|
181 |
+
|
182 |
+
return $word;
|
183 |
+
|
184 |
+
}
|
185 |
+
|
186 |
+
}
|
187 |
+
|
188 |
+
endif;
|
includes/class-aws-search-page.php
CHANGED
@@ -1,590 +1,590 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Integrate with WP_Query
|
4 |
-
*/
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit; // Exit if accessed directly.
|
8 |
-
}
|
9 |
-
|
10 |
-
if ( ! class_exists( 'AWS_Search_Page' ) ) :
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class for plugin search
|
14 |
-
*/
|
15 |
-
class AWS_Search_Page {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Is set only when we are within a multisite loop
|
19 |
-
*
|
20 |
-
* @var bool|WP_Query
|
21 |
-
*/
|
22 |
-
private $query_stack = array();
|
23 |
-
|
24 |
-
private $posts_by_query = array();
|
25 |
-
|
26 |
-
private $data = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* Return a singleton instance of the current class
|
30 |
-
*
|
31 |
-
* @return object
|
32 |
-
*/
|
33 |
-
public static function factory() {
|
34 |
-
static $instance = false;
|
35 |
-
|
36 |
-
if ( ! $instance ) {
|
37 |
-
$instance = new self();
|
38 |
-
$instance->setup();
|
39 |
-
}
|
40 |
-
|
41 |
-
return $instance;
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Placeholder
|
46 |
-
*/
|
47 |
-
public function __construct() {}
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Setup actions and filters for all things settings
|
51 |
-
*/
|
52 |
-
public function setup() {
|
53 |
-
|
54 |
-
// Make sure we return nothing for MySQL posts query
|
55 |
-
add_filter( 'posts_request', array( $this, 'filter_posts_request' ), 999, 2 );
|
56 |
-
|
57 |
-
// Query and filter to WP_Query
|
58 |
-
add_filter( 'the_posts', array( $this, 'filter_the_posts' ), 999, 2 );
|
59 |
-
|
60 |
-
// Add header
|
61 |
-
add_action( 'pre_get_posts', array( $this, 'action_pre_get_posts' ), 5 );
|
62 |
-
|
63 |
-
// Overwrite query
|
64 |
-
add_action( 'pre_get_posts', array( $this, 'pre_get_posts_overwrite' ), 999 );
|
65 |
-
|
66 |
-
// Nukes the FOUND_ROWS() database query
|
67 |
-
add_filter( 'found_posts_query', array( $this, 'filter_found_posts_query' ), 5, 2 );
|
68 |
-
|
69 |
-
// Update found post query param
|
70 |
-
add_filter( 'found_posts', array( $this, 'filter_found_posts' ), 999, 2 );
|
71 |
-
|
72 |
-
// WooCommerce default widget filters
|
73 |
-
add_filter( 'woocommerce_layered_nav_link', array( $this, 'woocommerce_layered_nav_link' ) );
|
74 |
-
add_filter( 'woocommerce_get_filtered_term_product_counts_query', array( $this, 'woocommerce_get_filtered_term_product_counts_query' ), 999 );
|
75 |
-
add_filter( 'woocommerce_price_filter_sql', array( $this, 'woocommerce_price_filter_sql' ), 999 );
|
76 |
-
|
77 |
-
add_filter( 'posts_pre_query', array( $this, 'posts_pre_query' ), 999, 2 );
|
78 |
-
|
79 |
-
// Overwrite WooCommerce global products count if it is set to zero
|
80 |
-
add_filter( 'woocommerce_product_loop_start', array( $this, 'woocommerce_product_loop_start' ), 99999 );
|
81 |
-
|
82 |
-
add_filter( 'body_class', array( $this, 'body_class' ), 999 );
|
83 |
-
|
84 |
-
// Divi builder support
|
85 |
-
add_action( 'et_pb_shop_before_print_shop', array( $this, 'et_pb_shop_before_print_shop' ) );
|
86 |
-
add_action( 'et_pb_shop_after_print_shop', array( $this, 'et_pb_shop_after_print_shop' ) );
|
87 |
-
|
88 |
-
// FacetWP support
|
89 |
-
add_filter( 'facetwp_pre_filtered_post_ids', array( $this, 'facetwp_pre_filtered_post_ids' ), 10, 2 );
|
90 |
-
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Filter query string used for get_posts(). Query for posts and save for later.
|
95 |
-
* Return a query that will return nothing.
|
96 |
-
*
|
97 |
-
* @param string $request
|
98 |
-
* @param object $query
|
99 |
-
* @return string
|
100 |
-
*/
|
101 |
-
public function filter_posts_request( $request, $query ) {
|
102 |
-
if ( ! $this->aws_searchpage_enabled( $query ) ) {
|
103 |
-
return $request;
|
104 |
-
}
|
105 |
-
|
106 |
-
$new_posts = array();
|
107 |
-
$posts_per_page = apply_filters( 'aws_posts_per_page', $query->get( 'posts_per_page' ) );
|
108 |
-
$paged = $query->query_vars['paged'] ? $query->query_vars['paged'] : 1;
|
109 |
-
$search_res = $this->search( $query, $posts_per_page, $paged );
|
110 |
-
|
111 |
-
if ( $search_res ) {
|
112 |
-
|
113 |
-
$query->found_posts = count( $search_res['all'] );
|
114 |
-
$query->max_num_pages = ceil( count( $search_res['all'] ) / $posts_per_page );
|
115 |
-
$query->set( 'posts_per_page', $posts_per_page );
|
116 |
-
|
117 |
-
$new_posts = $this->set_posts_objects( $search_res, $query );
|
118 |
-
|
119 |
-
$this->posts_by_query[spl_object_hash( $query )] = $new_posts;
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
global $wpdb;
|
124 |
-
|
125 |
-
return "SELECT * FROM $wpdb->posts WHERE 1=0";
|
126 |
-
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Filter the posts array.
|
131 |
-
*
|
132 |
-
* @param array $posts
|
133 |
-
* @param object $query
|
134 |
-
* @return array|null
|
135 |
-
*/
|
136 |
-
public function posts_pre_query( $posts, $query ) {
|
137 |
-
|
138 |
-
/**
|
139 |
-
* Filter search results custom data array
|
140 |
-
* @since 2.19
|
141 |
-
* @param array $this->data Search results data array
|
142 |
-
* @param object $query Query
|
143 |
-
* @param array $posts Posts
|
144 |
-
*/
|
145 |
-
$this->data = apply_filters( 'aws_search_page_custom_data', $this->data, $query, $posts );
|
146 |
-
|
147 |
-
$post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true : false;
|
148 |
-
|
149 |
-
if ( $post_type_product && isset( $_GET['type_aws'] ) && isset( $query->query_vars['s'] ) && $query->query && isset( $query->query['fields'] ) && $query->query['fields'] == 'ids' &&
|
150 |
-
( ( isset( $this->data['force_ids'] ) && $this->data['force_ids'] ) || ( isset( $this->data['is_elementor'] ) && $this->data['is_elementor'] ) || ( isset( $this->data['is_divi_s_page'] ) && $this->data['is_divi_s_page'] ) )
|
151 |
-
)
|
152 |
-
{
|
153 |
-
|
154 |
-
$products_ids = array();
|
155 |
-
$posts_per_page = apply_filters( 'aws_posts_per_page', $query->get( 'posts_per_page' ) );
|
156 |
-
$paged = $query->query_vars['paged'] ? $query->query_vars['paged'] : 1;
|
157 |
-
|
158 |
-
$search_res = $this->search( $query, $posts_per_page, $paged );
|
159 |
-
|
160 |
-
if ( $search_res ) {
|
161 |
-
|
162 |
-
$query->found_posts = count( $search_res['all'] );
|
163 |
-
$query->max_num_pages = ceil( count( $search_res['all'] ) / $posts_per_page );
|
164 |
-
|
165 |
-
foreach ( $search_res['products'] as $product ) {
|
166 |
-
$products_ids[] = $product['id'];
|
167 |
-
}
|
168 |
-
|
169 |
-
$posts = $products_ids;
|
170 |
-
|
171 |
-
}
|
172 |
-
|
173 |
-
}
|
174 |
-
return $posts;
|
175 |
-
}
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Filter the posts array to contain search query result. Pull previously queried posts.
|
179 |
-
*
|
180 |
-
* @param array $posts
|
181 |
-
* @param object $query
|
182 |
-
* @return array
|
183 |
-
*/
|
184 |
-
public function filter_the_posts( $posts, $query ) {
|
185 |
-
if ( ! $this->aws_searchpage_enabled( $query ) || ! isset( $this->posts_by_query[spl_object_hash( $query )] ) ) {
|
186 |
-
return $posts;
|
187 |
-
}
|
188 |
-
|
189 |
-
$new_posts = $this->posts_by_query[spl_object_hash( $query )];
|
190 |
-
|
191 |
-
return $new_posts;
|
192 |
-
|
193 |
-
}
|
194 |
-
|
195 |
-
/**
|
196 |
-
* Disables cache_results, adds header.
|
197 |
-
*
|
198 |
-
* @param $query
|
199 |
-
*/
|
200 |
-
public function action_pre_get_posts( $query ) {
|
201 |
-
if ( ! $this->aws_searchpage_enabled( $query ) ) {
|
202 |
-
return;
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* `cache_results` defaults to false but can be enabled
|
207 |
-
*/
|
208 |
-
$query->set( 'cache_results', false );
|
209 |
-
if ( ! empty( $query->query['cache_results'] ) ) {
|
210 |
-
$query->set( 'cache_results', true );
|
211 |
-
}
|
212 |
-
|
213 |
-
if ( ! headers_sent() ) {
|
214 |
-
/**
|
215 |
-
* Manually setting a header as $wp_query isn't yet initialized
|
216 |
-
* when we call: add_filter('wp_headers', 'filter_wp_headers');
|
217 |
-
*/
|
218 |
-
header( 'X-AWS-Search: true' );
|
219 |
-
}
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* Make necessary changes in main query.
|
224 |
-
*
|
225 |
-
* @param $query
|
226 |
-
*/
|
227 |
-
public function pre_get_posts_overwrite( $query ) {
|
228 |
-
if ( ! $this->aws_searchpage_enabled( $query ) ) {
|
229 |
-
return;
|
230 |
-
}
|
231 |
-
|
232 |
-
// Divi builder fix
|
233 |
-
if ( defined( 'ET_CORE' ) && $GLOBALS && isset( $GLOBALS['et_builder_used_in_wc_shop'] ) && $GLOBALS['et_builder_used_in_wc_shop'] ) {
|
234 |
-
|
235 |
-
$GLOBALS['et_builder_used_in_wc_shop'] = false;
|
236 |
-
|
237 |
-
$query->set( 'page_id', 0 );
|
238 |
-
$query->set( 'post_type', 'product' );
|
239 |
-
$query->set( 'posts_per_page', apply_filters( 'aws_posts_per_page', get_option( 'posts_per_page' ) ) );
|
240 |
-
$query->set( 'wc_query', 'product_query' );
|
241 |
-
$query->set( 'meta_query', array() );
|
242 |
-
|
243 |
-
$query->is_singular = false;
|
244 |
-
$query->is_page = false;
|
245 |
-
$query->is_post_type_archive = true;
|
246 |
-
$query->is_archive = true;
|
247 |
-
|
248 |
-
}
|
249 |
-
|
250 |
-
$query->set( 'aws_query', true );
|
251 |
-
|
252 |
-
}
|
253 |
-
|
254 |
-
/**
|
255 |
-
* Remove the found_rows from the SQL Query
|
256 |
-
*
|
257 |
-
* @param string $sql
|
258 |
-
* @param object $query
|
259 |
-
* @return string
|
260 |
-
*/
|
261 |
-
public function filter_found_posts_query( $sql, $query ) {
|
262 |
-
if ( ! $this->aws_searchpage_enabled( $query ) ) {
|
263 |
-
return $sql;
|
264 |
-
}
|
265 |
-
|
266 |
-
return '';
|
267 |
-
}
|
268 |
-
|
269 |
-
/**
|
270 |
-
* Filters the number of found posts for the query.
|
271 |
-
*
|
272 |
-
* @param int $found_posts The number of posts found
|
273 |
-
* @param object $query
|
274 |
-
* @return string
|
275 |
-
*/
|
276 |
-
public function filter_found_posts( $found_posts, $query ) {
|
277 |
-
|
278 |
-
$post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true : false;
|
279 |
-
|
280 |
-
if ( $post_type_product && isset( $_GET['type_aws'] ) && isset( $this->data['all_products'] ) && $this->data['all_products'] && isset( $query->query_vars['nopaging'] ) && ! $query->query_vars['nopaging'] &&
|
281 |
-
( ( isset( $this->data['force_ids'] ) && $this->data['force_ids'] ) || ( isset( $this->data['is_elementor'] ) && $this->data['is_elementor'] ) || ( isset( $this->data['is_divi_s_page'] ) && $this->data['is_divi_s_page'] ) )
|
282 |
-
) {
|
283 |
-
$found_posts = count( $this->data['all_products'] );
|
284 |
-
}
|
285 |
-
|
286 |
-
return $found_posts;
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
/*
|
291 |
-
* FacetWP add unfiltered products IDs
|
292 |
-
*/
|
293 |
-
public function facetwp_pre_filtered_post_ids( $post_ids, $obj ) {
|
294 |
-
if ( isset( $_GET['type_aws'] ) && isset( $_GET['s'] ) ) {
|
295 |
-
$search_res = $this->search( $obj->query, $obj->query_args['posts_per_page'], $obj->query_args['paged'] );
|
296 |
-
if ( $search_res ) {
|
297 |
-
$products_ids = array();
|
298 |
-
foreach ( $search_res['all'] as $product ) {
|
299 |
-
$products_ids[] = $product['id'];
|
300 |
-
}
|
301 |
-
$post_ids = $products_ids;
|
302 |
-
}
|
303 |
-
}
|
304 |
-
return $post_ids;
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Perform the search.
|
309 |
-
*
|
310 |
-
* @param object $query
|
311 |
-
* @param int $posts_per_page
|
312 |
-
* @param int $paged
|
313 |
-
* @return array | bool
|
314 |
-
*/
|
315 |
-
private function search( $query, $posts_per_page, $paged = 1 ) {
|
316 |
-
|
317 |
-
if ( ! did_action( 'woocommerce_init' ) || ! did_action( 'woocommerce_after_register_taxonomy' ) || ! did_action( 'woocommerce_after_register_post_type' ) ) {
|
318 |
-
return false;
|
319 |
-
}
|
320 |
-
|
321 |
-
$s = $this->get_search_query( $query );
|
322 |
-
|
323 |
-
$hash = hash( 'md2', $s );
|
324 |
-
|
325 |
-
if ( isset( $this->data['search_res'][$hash] ) ) {
|
326 |
-
$posts_array = $this->data['search_res'][$hash];
|
327 |
-
} else {
|
328 |
-
$posts_array = (array) aws_search( $s );
|
329 |
-
$this->data['search_res'][$hash] = $posts_array;
|
330 |
-
}
|
331 |
-
|
332 |
-
$post_array_products = $posts_array['products'];
|
333 |
-
|
334 |
-
// Filter and order output
|
335 |
-
if ( $post_array_products && is_array( $post_array_products ) && ! empty( $post_array_products ) && is_object( $query ) ) {
|
336 |
-
$post_array_products = AWS()->order( $post_array_products, $query );
|
337 |
-
}
|
338 |
-
|
339 |
-
if ( is_numeric( $posts_per_page ) && (int) $posts_per_page < 0 ) {
|
340 |
-
$posts_per_page = 999999;
|
341 |
-
}
|
342 |
-
|
343 |
-
$offset = ( $paged > 1 ) ? $paged * $posts_per_page - $posts_per_page : 0;
|
344 |
-
|
345 |
-
$products = array_slice( $post_array_products, $offset, $posts_per_page );
|
346 |
-
|
347 |
-
$this->data['all_products'] = $post_array_products;
|
348 |
-
|
349 |
-
return array(
|
350 |
-
'all' => $post_array_products,
|
351 |
-
'products' => $products
|
352 |
-
);
|
353 |
-
|
354 |
-
}
|
355 |
-
|
356 |
-
/*
|
357 |
-
* Overwrite WooCommerce global products count if it is set to zero
|
358 |
-
*/
|
359 |
-
public function woocommerce_product_loop_start( $loop_start ) {
|
360 |
-
if ( isset( $_GET['type_aws'] ) && isset( $this->data['all_products'] ) && ! empty( $this->data['all_products'] ) ) {
|
361 |
-
if ( isset( $GLOBALS['woocommerce_loop'] ) && isset( $GLOBALS['woocommerce_loop']['total'] ) && $GLOBALS['woocommerce_loop']['total'] === 0 ) {
|
362 |
-
$GLOBALS['woocommerce_loop']['total'] = count( $this->data['all_products'] );
|
363 |
-
}
|
364 |
-
}
|
365 |
-
return $loop_start;
|
366 |
-
}
|
367 |
-
|
368 |
-
/*
|
369 |
-
* Update links for WooCommerce filter widgets
|
370 |
-
*/
|
371 |
-
public function woocommerce_layered_nav_link( $link ) {
|
372 |
-
if ( ! isset( $_GET['type_aws'] ) ) {
|
373 |
-
return $link;
|
374 |
-
}
|
375 |
-
|
376 |
-
$first_char = '&';
|
377 |
-
|
378 |
-
if ( strpos( $link, '?' ) === false ) {
|
379 |
-
$first_char = '?';
|
380 |
-
}
|
381 |
-
|
382 |
-
if ( isset( $_GET['type_aws'] ) && strpos( $link, 'type_aws' ) === false ) {
|
383 |
-
$link = $link . $first_char . 'type_aws=true';
|
384 |
-
}
|
385 |
-
|
386 |
-
return $link;
|
387 |
-
|
388 |
-
}
|
389 |
-
|
390 |
-
/*
|
391 |
-
* Enable cache for WooCommerce filter widget
|
392 |
-
*/
|
393 |
-
public function woocommerce_layered_nav_count_maybe_cache( $cache ) {
|
394 |
-
if ( ! isset( $_GET['type_aws'] ) ) {
|
395 |
-
return $cache;
|
396 |
-
}
|
397 |
-
return true;
|
398 |
-
}
|
399 |
-
|
400 |
-
/*
|
401 |
-
* Change WooCommerce attributes filter widget query
|
402 |
-
*/
|
403 |
-
public function woocommerce_get_filtered_term_product_counts_query( $query ) {
|
404 |
-
if ( ! isset( $_GET['type_aws'] ) ) {
|
405 |
-
return $query;
|
406 |
-
}
|
407 |
-
|
408 |
-
$search = ' AND ' . WC_Query::get_main_search_query_sql();
|
409 |
-
$product_ids = array();
|
410 |
-
|
411 |
-
$query['where'] = str_replace( $search, '', $query['where'] );
|
412 |
-
|
413 |
-
if ( isset( $this->data['all_products'] ) && $this->data['all_products'] ) {
|
414 |
-
global $wpdb;
|
415 |
-
|
416 |
-
foreach( $this->data['all_products'] as $sproduct ) {
|
417 |
-
$product_ids[] = $sproduct['id'];
|
418 |
-
}
|
419 |
-
|
420 |
-
$query['where'] .= " AND {$wpdb->posts}.ID IN (". implode( ',', array_map( 'absint', $product_ids ) ) .")";
|
421 |
-
|
422 |
-
}
|
423 |
-
|
424 |
-
return $query;
|
425 |
-
}
|
426 |
-
|
427 |
-
/*
|
428 |
-
* Change WooCommerce price filter widget query
|
429 |
-
*/
|
430 |
-
public function woocommerce_price_filter_sql( $sql ) {
|
431 |
-
|
432 |
-
if ( isset( $_GET['type_aws'] ) && isset( $this->data['all_products'] ) && $this->data['all_products'] ) {
|
433 |
-
global $wpdb;
|
434 |
-
|
435 |
-
foreach( $this->data['all_products'] as $sproduct ) {
|
436 |
-
$product_ids[] = $sproduct['id'];
|
437 |
-
}
|
438 |
-
|
439 |
-
$sql = "SELECT min( min_price ) as min_price, MAX( max_price ) as max_price
|
440 |
-
FROM {$wpdb->wc_product_meta_lookup}
|
441 |
-
WHERE product_id IN (". implode( ',', array_map( 'absint', $product_ids ) ) .")";
|
442 |
-
|
443 |
-
}
|
444 |
-
|
445 |
-
return $sql;
|
446 |
-
|
447 |
-
}
|
448 |
-
|
449 |
-
/*
|
450 |
-
* Check some strings inside body classes
|
451 |
-
*/
|
452 |
-
function body_class( $classes ) {
|
453 |
-
foreach( $classes as $class ) {
|
454 |
-
if ( strpos( $class, 'elementor-page-' ) !== false ) {
|
455 |
-
$this->data['is_elementor'] = true;
|
456 |
-
break;
|
457 |
-
}
|
458 |
-
}
|
459 |
-
return $classes;
|
460 |
-
}
|
461 |
-
|
462 |
-
/*
|
463 |
-
* Is it Divi builder search page template with Shop module?
|
464 |
-
*/
|
465 |
-
public function et_pb_shop_before_print_shop() {
|
466 |
-
$this->data['is_divi_s_page'] = true;
|
467 |
-
}
|
468 |
-
public function et_pb_shop_after_print_shop() {
|
469 |
-
$this->data['is_divi_s_page'] = false;
|
470 |
-
}
|
471 |
-
|
472 |
-
/**
|
473 |
-
* Check if we should override default search query
|
474 |
-
*
|
475 |
-
* @param string $query
|
476 |
-
* @return bool
|
477 |
-
*/
|
478 |
-
private function aws_searchpage_enabled( $query ) {
|
479 |
-
$enabled = true;
|
480 |
-
|
481 |
-
$post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true :
|
482 |
-
( ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' ) ? true : false );
|
483 |
-
|
484 |
-
if ( ( isset( $query->query_vars['s'] ) && ! isset( $_GET['type_aws'] ) ) ||
|
485 |
-
! isset( $query->query_vars['s'] ) ||
|
486 |
-
! $query->is_search() ||
|
487 |
-
! $post_type_product
|
488 |
-
) {
|
489 |
-
$enabled = false;
|
490 |
-
}
|
491 |
-
|
492 |
-
return apply_filters( 'aws_searchpage_enabled', $enabled, $query );
|
493 |
-
}
|
494 |
-
|
495 |
-
/**
|
496 |
-
* Get current page search query
|
497 |
-
*
|
498 |
-
* @param object|bool $query
|
499 |
-
* @return string
|
500 |
-
*/
|
501 |
-
private function get_search_query( $query = false ) {
|
502 |
-
|
503 |
-
$search_query = isset( $_GET['s'] ) ? $_GET['s'] : ( ( is_object( $query ) && $query->query_vars['s'] ) ? $query->query_vars['s'] : '' );
|
504 |
-
|
505 |
-
/**
|
506 |
-
* Filter search query string for search results page
|
507 |
-
* @since 2.22
|
508 |
-
* @param string $search_query Search query string
|
509 |
-
* @param object|bool $query Search query object
|
510 |
-
*/
|
511 |
-
|
512 |
-
return apply_filters( 'aws_search_page_query', $search_query, $query );
|
513 |
-
|
514 |
-
}
|
515 |
-
|
516 |
-
/*
|
517 |
-
* Set posts objects with data
|
518 |
-
*/
|
519 |
-
private function set_posts_objects( $search_res, $query ) {
|
520 |
-
|
521 |
-
$new_posts = array();
|
522 |
-
|
523 |
-
foreach ( $search_res['products'] as $post_array ) {
|
524 |
-
$post = new stdClass();
|
525 |
-
|
526 |
-
$post_array = (array) $post_array;
|
527 |
-
$post_data = $post_array['post_data'];
|
528 |
-
|
529 |
-
$post->ID = ( isset( $post_array['parent_id'] ) && $post_array['parent_id'] ) ? $post_array['parent_id'] : $post_data->ID;
|
530 |
-
$post->site_id = get_current_blog_id();
|
531 |
-
|
532 |
-
if ( ! empty( $post_data->site_id ) ) {
|
533 |
-
$post->site_id = $post_data->site_id;
|
534 |
-
}
|
535 |
-
|
536 |
-
$post_return_args = array(
|
537 |
-
'post_type',
|
538 |
-
'post_author',
|
539 |
-
'post_name',
|
540 |
-
'post_status',
|
541 |
-
'post_title',
|
542 |
-
'post_parent',
|
543 |
-
'post_content',
|
544 |
-
'post_excerpt',
|
545 |
-
'post_date',
|
546 |
-
'post_date_gmt',
|
547 |
-
'post_modified',
|
548 |
-
'post_modified_gmt',
|
549 |
-
'post_mime_type',
|
550 |
-
'comment_count',
|
551 |
-
'comment_status',
|
552 |
-
'ping_status',
|
553 |
-
'menu_order',
|
554 |
-
'permalink',
|
555 |
-
'terms',
|
556 |
-
'post_meta'
|
557 |
-
);
|
558 |
-
|
559 |
-
foreach ( $post_return_args as $key ) {
|
560 |
-
if ( isset( $post_data->$key ) ) {
|
561 |
-
$post->$key = $post_data->$key;
|
562 |
-
}
|
563 |
-
}
|
564 |
-
|
565 |
-
$post->awssearch = true; // Super useful for debugging
|
566 |
-
|
567 |
-
if ( $post ) {
|
568 |
-
$new_posts[] = $post;
|
569 |
-
}
|
570 |
-
}
|
571 |
-
|
572 |
-
/**
|
573 |
-
* Filter search page results
|
574 |
-
* @since 2.01
|
575 |
-
* @param array $new_posts Posts array
|
576 |
-
* @param object $query Query
|
577 |
-
* @param array $this->data Search results data array
|
578 |
-
*/
|
579 |
-
$new_posts = apply_filters( 'aws_search_page_results', $new_posts, $query, $this->data );
|
580 |
-
|
581 |
-
return $new_posts;
|
582 |
-
|
583 |
-
}
|
584 |
-
|
585 |
-
}
|
586 |
-
|
587 |
-
|
588 |
-
endif;
|
589 |
-
|
590 |
AWS_Search_Page::factory();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Integrate with WP_Query
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly.
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! class_exists( 'AWS_Search_Page' ) ) :
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class for plugin search
|
14 |
+
*/
|
15 |
+
class AWS_Search_Page {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Is set only when we are within a multisite loop
|
19 |
+
*
|
20 |
+
* @var bool|WP_Query
|
21 |
+
*/
|
22 |
+
private $query_stack = array();
|
23 |
+
|
24 |
+
private $posts_by_query = array();
|
25 |
+
|
26 |
+
private $data = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Return a singleton instance of the current class
|
30 |
+
*
|
31 |
+
* @return object
|
32 |
+
*/
|
33 |
+
public static function factory() {
|
34 |
+
static $instance = false;
|
35 |
+
|
36 |
+
if ( ! $instance ) {
|
37 |
+
$instance = new self();
|
38 |
+
$instance->setup();
|
39 |
+
}
|
40 |
+
|
41 |
+
return $instance;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Placeholder
|
46 |
+
*/
|
47 |
+
public function __construct() {}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Setup actions and filters for all things settings
|
51 |
+
*/
|
52 |
+
public function setup() {
|
53 |
+
|
54 |
+
// Make sure we return nothing for MySQL posts query
|
55 |
+
add_filter( 'posts_request', array( $this, 'filter_posts_request' ), 999, 2 );
|
56 |
+
|
57 |
+
// Query and filter to WP_Query
|
58 |
+
add_filter( 'the_posts', array( $this, 'filter_the_posts' ), 999, 2 );
|
59 |
+
|
60 |
+
// Add header
|
61 |
+
add_action( 'pre_get_posts', array( $this, 'action_pre_get_posts' ), 5 );
|
62 |
+
|
63 |
+
// Overwrite query
|
64 |
+
add_action( 'pre_get_posts', array( $this, 'pre_get_posts_overwrite' ), 999 );
|
65 |
+
|
66 |
+
// Nukes the FOUND_ROWS() database query
|
67 |
+
add_filter( 'found_posts_query', array( $this, 'filter_found_posts_query' ), 5, 2 );
|
68 |
+
|
69 |
+
// Update found post query param
|
70 |
+
add_filter( 'found_posts', array( $this, 'filter_found_posts' ), 999, 2 );
|
71 |
+
|
72 |
+
// WooCommerce default widget filters
|
73 |
+
add_filter( 'woocommerce_layered_nav_link', array( $this, 'woocommerce_layered_nav_link' ) );
|
74 |
+
add_filter( 'woocommerce_get_filtered_term_product_counts_query', array( $this, 'woocommerce_get_filtered_term_product_counts_query' ), 999 );
|
75 |
+
add_filter( 'woocommerce_price_filter_sql', array( $this, 'woocommerce_price_filter_sql' ), 999 );
|
76 |
+
|
77 |
+
add_filter( 'posts_pre_query', array( $this, 'posts_pre_query' ), 999, 2 );
|
78 |
+
|
79 |
+
// Overwrite WooCommerce global products count if it is set to zero
|
80 |
+
add_filter( 'woocommerce_product_loop_start', array( $this, 'woocommerce_product_loop_start' ), 99999 );
|
81 |
+
|
82 |
+
add_filter( 'body_class', array( $this, 'body_class' ), 999 );
|
83 |
+
|
84 |
+
// Divi builder support
|
85 |
+
add_action( 'et_pb_shop_before_print_shop', array( $this, 'et_pb_shop_before_print_shop' ) );
|
86 |
+
add_action( 'et_pb_shop_after_print_shop', array( $this, 'et_pb_shop_after_print_shop' ) );
|
87 |
+
|
88 |
+
// FacetWP support
|
89 |
+
add_filter( 'facetwp_pre_filtered_post_ids', array( $this, 'facetwp_pre_filtered_post_ids' ), 10, 2 );
|
90 |
+
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Filter query string used for get_posts(). Query for posts and save for later.
|
95 |
+
* Return a query that will return nothing.
|
96 |
+
*
|
97 |
+
* @param string $request
|
98 |
+
* @param object $query
|
99 |
+
* @return string
|
100 |
+
*/
|
101 |
+
public function filter_posts_request( $request, $query ) {
|
102 |
+
if ( ! $this->aws_searchpage_enabled( $query ) ) {
|
103 |
+
return $request;
|
104 |
+
}
|
105 |
+
|
106 |
+
$new_posts = array();
|
107 |
+
$posts_per_page = apply_filters( 'aws_posts_per_page', $query->get( 'posts_per_page' ) );
|
108 |
+
$paged = $query->query_vars['paged'] ? $query->query_vars['paged'] : 1;
|
109 |
+
$search_res = $this->search( $query, $posts_per_page, $paged );
|
110 |
+
|
111 |
+
if ( $search_res ) {
|
112 |
+
|
113 |
+
$query->found_posts = count( $search_res['all'] );
|
114 |
+
$query->max_num_pages = ceil( count( $search_res['all'] ) / $posts_per_page );
|
115 |
+
$query->set( 'posts_per_page', $posts_per_page );
|
116 |
+
|
117 |
+
$new_posts = $this->set_posts_objects( $search_res, $query );
|
118 |
+
|
119 |
+
$this->posts_by_query[spl_object_hash( $query )] = $new_posts;
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
global $wpdb;
|
124 |
+
|
125 |
+
return "SELECT * FROM $wpdb->posts WHERE 1=0";
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Filter the posts array.
|
131 |
+
*
|
132 |
+
* @param array $posts
|
133 |
+
* @param object $query
|
134 |
+
* @return array|null
|
135 |
+
*/
|
136 |
+
public function posts_pre_query( $posts, $query ) {
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Filter search results custom data array
|
140 |
+
* @since 2.19
|
141 |
+
* @param array $this->data Search results data array
|
142 |
+
* @param object $query Query
|
143 |
+
* @param array $posts Posts
|
144 |
+
*/
|
145 |
+
$this->data = apply_filters( 'aws_search_page_custom_data', $this->data, $query, $posts );
|
146 |
+
|
147 |
+
$post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true : false;
|
148 |
+
|
149 |
+
if ( $post_type_product && isset( $_GET['type_aws'] ) && isset( $query->query_vars['s'] ) && $query->query && isset( $query->query['fields'] ) && $query->query['fields'] == 'ids' &&
|
150 |
+
( ( isset( $this->data['force_ids'] ) && $this->data['force_ids'] ) || ( isset( $this->data['is_elementor'] ) && $this->data['is_elementor'] ) || ( isset( $this->data['is_divi_s_page'] ) && $this->data['is_divi_s_page'] ) )
|
151 |
+
)
|
152 |
+
{
|
153 |
+
|
154 |
+
$products_ids = array();
|
155 |
+
$posts_per_page = apply_filters( 'aws_posts_per_page', $query->get( 'posts_per_page' ) );
|
156 |
+
$paged = $query->query_vars['paged'] ? $query->query_vars['paged'] : 1;
|
157 |
+
|
158 |
+
$search_res = $this->search( $query, $posts_per_page, $paged );
|
159 |
+
|
160 |
+
if ( $search_res ) {
|
161 |
+
|
162 |
+
$query->found_posts = count( $search_res['all'] );
|
163 |
+
$query->max_num_pages = ceil( count( $search_res['all'] ) / $posts_per_page );
|
164 |
+
|
165 |
+
foreach ( $search_res['products'] as $product ) {
|
166 |
+
$products_ids[] = $product['id'];
|
167 |
+
}
|
168 |
+
|
169 |
+
$posts = $products_ids;
|
170 |
+
|
171 |
+
}
|
172 |
+
|
173 |
+
}
|
174 |
+
return $posts;
|
175 |
+
}
|
176 |
+
|
177 |
+
/**
|
178 |
+
* Filter the posts array to contain search query result. Pull previously queried posts.
|
179 |
+
*
|
180 |
+
* @param array $posts
|
181 |
+
* @param object $query
|
182 |
+
* @return array
|
183 |
+
*/
|
184 |
+
public function filter_the_posts( $posts, $query ) {
|
185 |
+
if ( ! $this->aws_searchpage_enabled( $query ) || ! isset( $this->posts_by_query[spl_object_hash( $query )] ) ) {
|
186 |
+
return $posts;
|
187 |
+
}
|
188 |
+
|
189 |
+
$new_posts = $this->posts_by_query[spl_object_hash( $query )];
|
190 |
+
|
191 |
+
return $new_posts;
|
192 |
+
|
193 |
+
}
|
194 |
+
|
195 |
+
/**
|
196 |
+
* Disables cache_results, adds header.
|
197 |
+
*
|
198 |
+
* @param $query
|
199 |
+
*/
|
200 |
+
public function action_pre_get_posts( $query ) {
|
201 |
+
if ( ! $this->aws_searchpage_enabled( $query ) ) {
|
202 |
+
return;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* `cache_results` defaults to false but can be enabled
|
207 |
+
*/
|
208 |
+
$query->set( 'cache_results', false );
|
209 |
+
if ( ! empty( $query->query['cache_results'] ) ) {
|
210 |
+
$query->set( 'cache_results', true );
|
211 |
+
}
|
212 |
+
|
213 |
+
if ( ! headers_sent() ) {
|
214 |
+
/**
|
215 |
+
* Manually setting a header as $wp_query isn't yet initialized
|
216 |
+
* when we call: add_filter('wp_headers', 'filter_wp_headers');
|
217 |
+
*/
|
218 |
+
header( 'X-AWS-Search: true' );
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* Make necessary changes in main query.
|
224 |
+
*
|
225 |
+
* @param $query
|
226 |
+
*/
|
227 |
+
public function pre_get_posts_overwrite( $query ) {
|
228 |
+
if ( ! $this->aws_searchpage_enabled( $query ) ) {
|
229 |
+
return;
|
230 |
+
}
|
231 |
+
|
232 |
+
// Divi builder fix
|
233 |
+
if ( defined( 'ET_CORE' ) && $GLOBALS && isset( $GLOBALS['et_builder_used_in_wc_shop'] ) && $GLOBALS['et_builder_used_in_wc_shop'] ) {
|
234 |
+
|
235 |
+
$GLOBALS['et_builder_used_in_wc_shop'] = false;
|
236 |
+
|
237 |
+
$query->set( 'page_id', 0 );
|
238 |
+
$query->set( 'post_type', 'product' );
|
239 |
+
$query->set( 'posts_per_page', apply_filters( 'aws_posts_per_page', get_option( 'posts_per_page' ) ) );
|
240 |
+
$query->set( 'wc_query', 'product_query' );
|
241 |
+
$query->set( 'meta_query', array() );
|
242 |
+
|
243 |
+
$query->is_singular = false;
|
244 |
+
$query->is_page = false;
|
245 |
+
$query->is_post_type_archive = true;
|
246 |
+
$query->is_archive = true;
|
247 |
+
|
248 |
+
}
|
249 |
+
|
250 |
+
$query->set( 'aws_query', true );
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* Remove the found_rows from the SQL Query
|
256 |
+
*
|
257 |
+
* @param string $sql
|
258 |
+
* @param object $query
|
259 |
+
* @return string
|
260 |
+
*/
|
261 |
+
public function filter_found_posts_query( $sql, $query ) {
|
262 |
+
if ( ! $this->aws_searchpage_enabled( $query ) ) {
|
263 |
+
return $sql;
|
264 |
+
}
|
265 |
+
|
266 |
+
return '';
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Filters the number of found posts for the query.
|
271 |
+
*
|
272 |
+
* @param int $found_posts The number of posts found
|
273 |
+
* @param object $query
|
274 |
+
* @return string
|
275 |
+
*/
|
276 |
+
public function filter_found_posts( $found_posts, $query ) {
|
277 |
+
|
278 |
+
$post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true : false;
|
279 |
+
|
280 |
+
if ( $post_type_product && isset( $_GET['type_aws'] ) && isset( $this->data['all_products'] ) && $this->data['all_products'] && isset( $query->query_vars['nopaging'] ) && ! $query->query_vars['nopaging'] &&
|
281 |
+
( ( isset( $this->data['force_ids'] ) && $this->data['force_ids'] ) || ( isset( $this->data['is_elementor'] ) && $this->data['is_elementor'] ) || ( isset( $this->data['is_divi_s_page'] ) && $this->data['is_divi_s_page'] ) )
|
282 |
+
) {
|
283 |
+
$found_posts = count( $this->data['all_products'] );
|
284 |
+
}
|
285 |
+
|
286 |
+
return $found_posts;
|
287 |
+
|
288 |
+
}
|
289 |
+
|
290 |
+
/*
|
291 |
+
* FacetWP add unfiltered products IDs
|
292 |
+
*/
|
293 |
+
public function facetwp_pre_filtered_post_ids( $post_ids, $obj ) {
|
294 |
+
if ( isset( $_GET['type_aws'] ) && isset( $_GET['s'] ) ) {
|
295 |
+
$search_res = $this->search( $obj->query, $obj->query_args['posts_per_page'], $obj->query_args['paged'] );
|
296 |
+
if ( $search_res ) {
|
297 |
+
$products_ids = array();
|
298 |
+
foreach ( $search_res['all'] as $product ) {
|
299 |
+
$products_ids[] = $product['id'];
|
300 |
+
}
|
301 |
+
$post_ids = $products_ids;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
return $post_ids;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Perform the search.
|
309 |
+
*
|
310 |
+
* @param object $query
|
311 |
+
* @param int $posts_per_page
|
312 |
+
* @param int $paged
|
313 |
+
* @return array | bool
|
314 |
+
*/
|
315 |
+
private function search( $query, $posts_per_page, $paged = 1 ) {
|
316 |
+
|
317 |
+
if ( ! did_action( 'woocommerce_init' ) || ! did_action( 'woocommerce_after_register_taxonomy' ) || ! did_action( 'woocommerce_after_register_post_type' ) ) {
|
318 |
+
return false;
|
319 |
+
}
|
320 |
+
|
321 |
+
$s = $this->get_search_query( $query );
|
322 |
+
|
323 |
+
$hash = hash( 'md2', $s );
|
324 |
+
|
325 |
+
if ( isset( $this->data['search_res'][$hash] ) ) {
|
326 |
+
$posts_array = $this->data['search_res'][$hash];
|
327 |
+
} else {
|
328 |
+
$posts_array = (array) aws_search( $s );
|
329 |
+
$this->data['search_res'][$hash] = $posts_array;
|
330 |
+
}
|
331 |
+
|
332 |
+
$post_array_products = $posts_array['products'];
|
333 |
+
|
334 |
+
// Filter and order output
|
335 |
+
if ( $post_array_products && is_array( $post_array_products ) && ! empty( $post_array_products ) && is_object( $query ) ) {
|
336 |
+
$post_array_products = AWS()->order( $post_array_products, $query );
|
337 |
+
}
|
338 |
+
|
339 |
+
if ( is_numeric( $posts_per_page ) && (int) $posts_per_page < 0 ) {
|
340 |
+
$posts_per_page = 999999;
|
341 |
+
}
|
342 |
+
|
343 |
+
$offset = ( $paged > 1 ) ? $paged * $posts_per_page - $posts_per_page : 0;
|
344 |
+
|
345 |
+
$products = array_slice( $post_array_products, $offset, $posts_per_page );
|
346 |
+
|
347 |
+
$this->data['all_products'] = $post_array_products;
|
348 |
+
|
349 |
+
return array(
|
350 |
+
'all' => $post_array_products,
|
351 |
+
'products' => $products
|
352 |
+
);
|
353 |
+
|
354 |
+
}
|
355 |
+
|
356 |
+
/*
|
357 |
+
* Overwrite WooCommerce global products count if it is set to zero
|
358 |
+
*/
|
359 |
+
public function woocommerce_product_loop_start( $loop_start ) {
|
360 |
+
if ( isset( $_GET['type_aws'] ) && isset( $this->data['all_products'] ) && ! empty( $this->data['all_products'] ) ) {
|
361 |
+
if ( isset( $GLOBALS['woocommerce_loop'] ) && isset( $GLOBALS['woocommerce_loop']['total'] ) && $GLOBALS['woocommerce_loop']['total'] === 0 ) {
|
362 |
+
$GLOBALS['woocommerce_loop']['total'] = count( $this->data['all_products'] );
|
363 |
+
}
|
364 |
+
}
|
365 |
+
return $loop_start;
|
366 |
+
}
|
367 |
+
|
368 |
+
/*
|
369 |
+
* Update links for WooCommerce filter widgets
|
370 |
+
*/
|
371 |
+
public function woocommerce_layered_nav_link( $link ) {
|
372 |
+
if ( ! isset( $_GET['type_aws'] ) ) {
|
373 |
+
return $link;
|
374 |
+
}
|
375 |
+
|
376 |
+
$first_char = '&';
|
377 |
+
|
378 |
+
if ( strpos( $link, '?' ) === false ) {
|
379 |
+
$first_char = '?';
|
380 |
+
}
|
381 |
+
|
382 |
+
if ( isset( $_GET['type_aws'] ) && strpos( $link, 'type_aws' ) === false ) {
|
383 |
+
$link = $link . $first_char . 'type_aws=true';
|
384 |
+
}
|
385 |
+
|
386 |
+
return $link;
|
387 |
+
|
388 |
+
}
|
389 |
+
|
390 |
+
/*
|
391 |
+
* Enable cache for WooCommerce filter widget
|
392 |
+
*/
|
393 |
+
public function woocommerce_layered_nav_count_maybe_cache( $cache ) {
|
394 |
+
if ( ! isset( $_GET['type_aws'] ) ) {
|
395 |
+
return $cache;
|
396 |
+
}
|
397 |
+
return true;
|
398 |
+
}
|
399 |
+
|
400 |
+
/*
|
401 |
+
* Change WooCommerce attributes filter widget query
|
402 |
+
*/
|
403 |
+
public function woocommerce_get_filtered_term_product_counts_query( $query ) {
|
404 |
+
if ( ! isset( $_GET['type_aws'] ) ) {
|
405 |
+
return $query;
|
406 |
+
}
|
407 |
+
|
408 |
+
$search = ' AND ' . WC_Query::get_main_search_query_sql();
|
409 |
+
$product_ids = array();
|
410 |
+
|
411 |
+
$query['where'] = str_replace( $search, '', $query['where'] );
|
412 |
+
|
413 |
+
if ( isset( $this->data['all_products'] ) && $this->data['all_products'] ) {
|
414 |
+
global $wpdb;
|
415 |
+
|
416 |
+
foreach( $this->data['all_products'] as $sproduct ) {
|
417 |
+
$product_ids[] = $sproduct['id'];
|
418 |
+
}
|
419 |
+
|
420 |
+
$query['where'] .= " AND {$wpdb->posts}.ID IN (". implode( ',', array_map( 'absint', $product_ids ) ) .")";
|
421 |
+
|
422 |
+
}
|
423 |
+
|
424 |
+
return $query;
|
425 |
+
}
|
426 |
+
|
427 |
+
/*
|
428 |
+
* Change WooCommerce price filter widget query
|
429 |
+
*/
|
430 |
+
public function woocommerce_price_filter_sql( $sql ) {
|
431 |
+
|
432 |
+
if ( isset( $_GET['type_aws'] ) && isset( $this->data['all_products'] ) && $this->data['all_products'] ) {
|
433 |
+
global $wpdb;
|
434 |
+
|
435 |
+
foreach( $this->data['all_products'] as $sproduct ) {
|
436 |
+
$product_ids[] = $sproduct['id'];
|
437 |
+
}
|
438 |
+
|
439 |
+
$sql = "SELECT min( min_price ) as min_price, MAX( max_price ) as max_price
|
440 |
+
FROM {$wpdb->wc_product_meta_lookup}
|
441 |
+
WHERE product_id IN (". implode( ',', array_map( 'absint', $product_ids ) ) .")";
|
442 |
+
|
443 |
+
}
|
444 |
+
|
445 |
+
return $sql;
|
446 |
+
|
447 |
+
}
|
448 |
+
|
449 |
+
/*
|
450 |
+
* Check some strings inside body classes
|
451 |
+
*/
|
452 |
+
function body_class( $classes ) {
|
453 |
+
foreach( $classes as $class ) {
|
454 |
+
if ( strpos( $class, 'elementor-page-' ) !== false ) {
|
455 |
+
$this->data['is_elementor'] = true;
|
456 |
+
break;
|
457 |
+
}
|
458 |
+
}
|
459 |
+
return $classes;
|
460 |
+
}
|
461 |
+
|
462 |
+
/*
|
463 |
+
* Is it Divi builder search page template with Shop module?
|
464 |
+
*/
|
465 |
+
public function et_pb_shop_before_print_shop() {
|
466 |
+
$this->data['is_divi_s_page'] = true;
|
467 |
+
}
|
468 |
+
public function et_pb_shop_after_print_shop() {
|
469 |
+
$this->data['is_divi_s_page'] = false;
|
470 |
+
}
|
471 |
+
|
472 |
+
/**
|
473 |
+
* Check if we should override default search query
|
474 |
+
*
|
475 |
+
* @param string $query
|
476 |
+
* @return bool
|
477 |
+
*/
|
478 |
+
private function aws_searchpage_enabled( $query ) {
|
479 |
+
$enabled = true;
|
480 |
+
|
481 |
+
$post_type_product = ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ? true :
|
482 |
+
( ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' ) ? true : false );
|
483 |
+
|
484 |
+
if ( ( isset( $query->query_vars['s'] ) && ! isset( $_GET['type_aws'] ) ) ||
|
485 |
+
! isset( $query->query_vars['s'] ) ||
|
486 |
+
! $query->is_search() ||
|
487 |
+
! $post_type_product
|
488 |
+
) {
|
489 |
+
$enabled = false;
|
490 |
+
}
|
491 |
+
|
492 |
+
return apply_filters( 'aws_searchpage_enabled', $enabled, $query );
|
493 |
+
}
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Get current page search query
|
497 |
+
*
|
498 |
+
* @param object|bool $query
|
499 |
+
* @return string
|
500 |
+
*/
|
501 |
+
private function get_search_query( $query = false ) {
|
502 |
+
|
503 |
+
$search_query = isset( $_GET['s'] ) ? $_GET['s'] : ( ( is_object( $query ) && $query->query_vars['s'] ) ? $query->query_vars['s'] : '' );
|
504 |
+
|
505 |
+
/**
|
506 |
+
* Filter search query string for search results page
|
507 |
+
* @since 2.22
|
508 |
+
* @param string $search_query Search query string
|
509 |
+
* @param object|bool $query Search query object
|
510 |
+
*/
|
511 |
+
|
512 |
+
return apply_filters( 'aws_search_page_query', $search_query, $query );
|
513 |
+
|
514 |
+
}
|
515 |
+
|
516 |
+
/*
|
517 |
+
* Set posts objects with data
|
518 |
+
*/
|
519 |
+
private function set_posts_objects( $search_res, $query ) {
|
520 |
+
|
521 |
+
$new_posts = array();
|
522 |
+
|
523 |
+
foreach ( $search_res['products'] as $post_array ) {
|
524 |
+
$post = new stdClass();
|
525 |
+
|
526 |
+
$post_array = (array) $post_array;
|
527 |
+
$post_data = $post_array['post_data'];
|
528 |
+
|
529 |
+
$post->ID = ( isset( $post_array['parent_id'] ) && $post_array['parent_id'] ) ? $post_array['parent_id'] : $post_data->ID;
|
530 |
+
$post->site_id = get_current_blog_id();
|
531 |
+
|
532 |
+
if ( ! empty( $post_data->site_id ) ) {
|
533 |
+
$post->site_id = $post_data->site_id;
|
534 |
+
}
|
535 |
+
|
536 |
+
$post_return_args = array(
|
537 |
+
'post_type',
|
538 |
+
'post_author',
|
539 |
+
'post_name',
|
540 |
+
'post_status',
|
541 |
+
'post_title',
|
542 |
+
'post_parent',
|
543 |
+
'post_content',
|
544 |
+
'post_excerpt',
|
545 |
+
'post_date',
|
546 |
+
'post_date_gmt',
|
547 |
+
'post_modified',
|
548 |
+
'post_modified_gmt',
|
549 |
+
'post_mime_type',
|
550 |
+
'comment_count',
|
551 |
+
'comment_status',
|
552 |
+
'ping_status',
|
553 |
+
'menu_order',
|
554 |
+
'permalink',
|
555 |
+
'terms',
|
556 |
+
'post_meta'
|
557 |
+
);
|
558 |
+
|
559 |
+
foreach ( $post_return_args as $key ) {
|
560 |
+
if ( isset( $post_data->$key ) ) {
|
561 |
+
$post->$key = $post_data->$key;
|
562 |
+
}
|
563 |
+
}
|
564 |
+
|
565 |
+
$post->awssearch = true; // Super useful for debugging
|
566 |
+
|
567 |
+
if ( $post ) {
|
568 |
+
$new_posts[] = $post;
|
569 |
+
}
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* Filter search page results
|
574 |
+
* @since 2.01
|
575 |
+
* @param array $new_posts Posts array
|
576 |
+
* @param object $query Query
|
577 |
+
* @param array $this->data Search results data array
|
578 |
+
*/
|
579 |
+
$new_posts = apply_filters( 'aws_search_page_results', $new_posts, $query, $this->data );
|
580 |
+
|
581 |
+
return $new_posts;
|
582 |
+
|
583 |
+
}
|
584 |
+
|
585 |
+
}
|
586 |
+
|
587 |
+
|
588 |
+
endif;
|
589 |
+
|
590 |
AWS_Search_Page::factory();
|
includes/class-aws-search.php
CHANGED
@@ -1,813 +1,813 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Search' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for plugin search
|
11 |
-
*/
|
12 |
-
class AWS_Search {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @var AWS_Search Array of all plugin data $data
|
16 |
-
*/
|
17 |
-
private $data = array();
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var AWS_Search Current language $lang
|
21 |
-
*/
|
22 |
-
private $lang = 0;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Return a singleton instance of the current class
|
26 |
-
*
|
27 |
-
* @return object
|
28 |
-
*/
|
29 |
-
public static function factory() {
|
30 |
-
static $instance = false;
|
31 |
-
|
32 |
-
if ( ! $instance ) {
|
33 |
-
$instance = new self();
|
34 |
-
$instance->setup();
|
35 |
-
}
|
36 |
-
|
37 |
-
return $instance;
|
38 |
-
}
|
39 |
-
|
40 |
-
/**
|
41 |
-
* Constructor
|
42 |
-
*/
|
43 |
-
public function __construct() {}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Setup actions and filters for all things settings
|
47 |
-
*/
|
48 |
-
public function setup() {
|
49 |
-
|
50 |
-
$this->data['settings'] = get_option( 'aws_settings' );
|
51 |
-
|
52 |
-
if ( isset( $_REQUEST['wc-ajax'] ) ) {
|
53 |
-
add_action( 'wc_ajax_aws_action', array( $this, 'action_callback' ) );
|
54 |
-
} else {
|
55 |
-
add_action( 'wp_ajax_aws_action', array( $this, 'action_callback' ) );
|
56 |
-
add_action( 'wp_ajax_nopriv_aws_action', array( $this, 'action_callback' ) );
|
57 |
-
}
|
58 |
-
|
59 |
-
}
|
60 |
-
|
61 |
-
/*
|
62 |
-
* AJAX call action callback
|
63 |
-
*/
|
64 |
-
public function action_callback() {
|
65 |
-
|
66 |
-
if ( ! defined( 'DOING_AJAX' ) ) {
|
67 |
-
define( 'DOING_AJAX', true );
|
68 |
-
}
|
69 |
-
|
70 |
-
if ( ! headers_sent() && isset( $_REQUEST['typedata'] ) ) {
|
71 |
-
header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
|
72 |
-
}
|
73 |
-
|
74 |
-
echo json_encode( $this->search() );
|
75 |
-
|
76 |
-
die;
|
77 |
-
|
78 |
-
}
|
79 |
-
|
80 |
-
/*
|
81 |
-
* Search
|
82 |
-
*/
|
83 |
-
public function search( $keyword = '' ) {
|
84 |
-
|
85 |
-
global $wpdb;
|
86 |
-
|
87 |
-
$this->lang = isset( $_REQUEST['lang'] ) ? sanitize_text_field( $_REQUEST['lang'] ) : '';
|
88 |
-
|
89 |
-
if ( $this->lang ) {
|
90 |
-
do_action( 'wpml_switch_language', $this->lang );
|
91 |
-
}
|
92 |
-
|
93 |
-
$cache = AWS()->get_settings( 'cache' );
|
94 |
-
|
95 |
-
$s = $keyword ? esc_attr( $keyword ) : esc_attr( $_POST['keyword'] );
|
96 |
-
$s = htmlspecialchars_decode( $s );
|
97 |
-
|
98 |
-
$this->data['s_nonormalize'] = $s;
|
99 |
-
|
100 |
-
$s = AWS_Helpers::normalize_string( $s );
|
101 |
-
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Fires each time when performing the search
|
105 |
-
* @since 1.59
|
106 |
-
* @param string $s Search query
|
107 |
-
*/
|
108 |
-
do_action( 'aws_search_start', $s );
|
109 |
-
|
110 |
-
|
111 |
-
$cache_option_name = '';
|
112 |
-
|
113 |
-
if ( $cache === 'true' && ! $keyword ) {
|
114 |
-
$cache_option_name = AWS()->cache->get_cache_name( $s );
|
115 |
-
$res = AWS()->cache->get_from_cache_table( $cache_option_name );
|
116 |
-
if ( $res ) {
|
117 |
-
$cached_value = json_decode( $res );
|
118 |
-
if ( $cached_value && ! empty( $cached_value ) ) {
|
119 |
-
return $cached_value;
|
120 |
-
}
|
121 |
-
}
|
122 |
-
}
|
123 |
-
|
124 |
-
$search_archives = AWS()->get_settings( 'search_archives' );
|
125 |
-
$show_cats = ( isset( $search_archives['archive_category'] ) && $search_archives['archive_category'] ) ? 'true' : 'false';
|
126 |
-
$show_tags = ( isset( $search_archives['archive_tag'] ) && $search_archives['archive_tag'] ) ? 'true' : 'false';
|
127 |
-
$results_num = $keyword ? apply_filters( 'aws_page_results', 100 ) : AWS()->get_settings( 'results_num' );
|
128 |
-
$search_in = AWS()->get_settings( 'search_in' );
|
129 |
-
$outofstock = AWS()->get_settings( 'outofstock' );
|
130 |
-
$search_rule = AWS()->get_settings( 'search_rule' );
|
131 |
-
|
132 |
-
$search_in_arr = array();
|
133 |
-
|
134 |
-
if ( is_array( $search_in ) && ! empty( $search_in ) ) {
|
135 |
-
foreach( $search_in as $search_in_source => $search_in_active ) {
|
136 |
-
if ( $search_in_active ) {
|
137 |
-
$search_in_arr[] = $search_in_source;
|
138 |
-
}
|
139 |
-
}
|
140 |
-
} elseif ( is_string( $search_in ) && $search_in ) {
|
141 |
-
$search_in_arr = explode( ',', $search_in );
|
142 |
-
}
|
143 |
-
|
144 |
-
$products_array = array();
|
145 |
-
$tax_to_display = array();
|
146 |
-
$custom_tax_array = array();
|
147 |
-
|
148 |
-
$this->data['s'] = $s;
|
149 |
-
$this->data['results_num'] = $results_num ? $results_num : 10;
|
150 |
-
$this->data['search_terms'] = array();
|
151 |
-
$this->data['search_in'] = $search_in_arr;
|
152 |
-
$this->data['outofstock'] = $outofstock;
|
153 |
-
$this->data['search_rule'] = $search_rule;
|
154 |
-
|
155 |
-
$search_array = array_unique( explode( ' ', $s ) );
|
156 |
-
|
157 |
-
$search_array = AWS_Helpers::filter_stopwords( $search_array );
|
158 |
-
|
159 |
-
if ( is_array( $search_array ) && ! empty( $search_array ) ) {
|
160 |
-
foreach ( $search_array as $search_term ) {
|
161 |
-
$search_term = trim( $search_term );
|
162 |
-
if ( $search_term ) {
|
163 |
-
$this->data['search_terms'][] = $search_term;
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
|
168 |
-
// if ( empty( $this->data['search_terms'] ) ) {
|
169 |
-
// $this->data['search_terms'][] = '';
|
170 |
-
// }
|
171 |
-
|
172 |
-
if ( ! empty( $this->data['search_terms'] ) ) {
|
173 |
-
|
174 |
-
if ( ! empty( $this->data['search_in'] ) ) {
|
175 |
-
|
176 |
-
$posts_ids = $this->query_index_table();
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Filters array of products ids
|
180 |
-
*
|
181 |
-
* @since 1.53
|
182 |
-
*
|
183 |
-
* @param array $posts_ids Array of products ids
|
184 |
-
* @param string $s Search query
|
185 |
-
*/
|
186 |
-
$posts_ids = apply_filters( 'aws_search_results_products_ids', $posts_ids, $s );
|
187 |
-
|
188 |
-
|
189 |
-
$products_array = $this->get_products( $posts_ids );
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Filters array of products before they displayed in search results
|
193 |
-
*
|
194 |
-
* @since 1.42
|
195 |
-
*
|
196 |
-
* @param array $products_array Array of products results
|
197 |
-
* @param string $s Search query
|
198 |
-
*/
|
199 |
-
$products_array = apply_filters( 'aws_search_results_products', $products_array, $s );
|
200 |
-
|
201 |
-
}
|
202 |
-
|
203 |
-
if ( $show_cats === 'true' ) {
|
204 |
-
$tax_to_display[] = 'product_cat';
|
205 |
-
}
|
206 |
-
|
207 |
-
if ( $show_tags === 'true' ) {
|
208 |
-
$tax_to_display[] = 'product_tag';
|
209 |
-
}
|
210 |
-
|
211 |
-
/**
|
212 |
-
* Filters array of custom taxonomies that must be displayed in search results
|
213 |
-
*
|
214 |
-
* @since 1.68
|
215 |
-
*
|
216 |
-
* @param array $taxonomies_archives Array of custom taxonomies
|
217 |
-
* @param string $s Search query
|
218 |
-
*/
|
219 |
-
$taxonomies_archives = apply_filters( 'aws_search_results_tax_archives', $tax_to_display, $s );
|
220 |
-
|
221 |
-
if ( $taxonomies_archives && is_array( $taxonomies_archives ) && ! empty( $taxonomies_archives ) ) {
|
222 |
-
|
223 |
-
$tax_search = new AWS_Tax_Search( $taxonomies_archives, $this->data );
|
224 |
-
$custom_tax_array = $tax_search->get_results();
|
225 |
-
|
226 |
-
}
|
227 |
-
|
228 |
-
}
|
229 |
-
|
230 |
-
|
231 |
-
$result_array = array(
|
232 |
-
'tax' => $custom_tax_array,
|
233 |
-
'products' => $products_array,
|
234 |
-
);
|
235 |
-
|
236 |
-
|
237 |
-
/**
|
238 |
-
* Filters array of all results data before they displayed in search results
|
239 |
-
*
|
240 |
-
* @since 1.43
|
241 |
-
*
|
242 |
-
* @param array $brands_array Array of products data
|
243 |
-
* @param string $s Search query
|
244 |
-
*/
|
245 |
-
$result_array = apply_filters( 'aws_search_results_all', $result_array, $s );
|
246 |
-
|
247 |
-
if ( $cache === 'true' && ! $keyword ) {
|
248 |
-
AWS()->cache->insert_into_cache_table( $cache_option_name, $result_array );
|
249 |
-
}
|
250 |
-
|
251 |
-
return $result_array;
|
252 |
-
|
253 |
-
}
|
254 |
-
|
255 |
-
/*
|
256 |
-
* Query in index table
|
257 |
-
*/
|
258 |
-
private function query_index_table() {
|
259 |
-
|
260 |
-
global $wpdb;
|
261 |
-
|
262 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
263 |
-
|
264 |
-
$search_in_arr = $this->data['search_in'];
|
265 |
-
$results_num = $this->data['results_num'];
|
266 |
-
$outofstock = $this->data['outofstock'];
|
267 |
-
$search_rule = $this->data['search_rule'];
|
268 |
-
|
269 |
-
$reindex_version = get_option( 'aws_reindex_version' );
|
270 |
-
|
271 |
-
$query = array();
|
272 |
-
|
273 |
-
$query['select'] = '';
|
274 |
-
$query['search'] = '';
|
275 |
-
$query['relevance'] = '';
|
276 |
-
$query['stock'] = '';
|
277 |
-
$query['visibility'] = '';
|
278 |
-
$query['exclude_products'] = '';
|
279 |
-
$query['lang'] = '';
|
280 |
-
|
281 |
-
$search_array = array();
|
282 |
-
$relevance_array = array();
|
283 |
-
$new_relevance_array = array();
|
284 |
-
|
285 |
-
|
286 |
-
/**
|
287 |
-
* Filters array of search terms before generating SQL query
|
288 |
-
*
|
289 |
-
* @since 1.49
|
290 |
-
*
|
291 |
-
* @param array $this->data['search_terms'] Array of search terms
|
292 |
-
*/
|
293 |
-
$this->data['search_terms'] = apply_filters( 'aws_search_terms', $this->data['search_terms'] );
|
294 |
-
|
295 |
-
|
296 |
-
foreach ( $this->data['search_terms'] as $search_term ) {
|
297 |
-
|
298 |
-
$search_term_len = strlen( $search_term );
|
299 |
-
|
300 |
-
$relevance_title = 200 + 20 * $search_term_len;
|
301 |
-
$relevance_content = 35 + 4 * $search_term_len;
|
302 |
-
$relevance_title_like = 40 + 2 * $search_term_len;
|
303 |
-
$relevance_content_like = 35 + 1 * $search_term_len;
|
304 |
-
|
305 |
-
$search_term_norm = AWS_Plurals::singularize( $search_term );
|
306 |
-
|
307 |
-
if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
|
308 |
-
$search_term = $search_term_norm;
|
309 |
-
}
|
310 |
-
|
311 |
-
if ( $search_rule === 'begins' ) {
|
312 |
-
$like = $wpdb->esc_like( $search_term ) . '%';
|
313 |
-
} else {
|
314 |
-
$like = '%' . $wpdb->esc_like( $search_term ) . '%';
|
315 |
-
}
|
316 |
-
|
317 |
-
if ( $search_term_len > 1 ) {
|
318 |
-
$search_array[] = $wpdb->prepare( '( term LIKE %s )', $like );
|
319 |
-
} else {
|
320 |
-
$search_array[] = $wpdb->prepare( '( term = "%s" )', $search_term );
|
321 |
-
}
|
322 |
-
|
323 |
-
foreach ( $search_in_arr as $search_in_term ) {
|
324 |
-
|
325 |
-
switch ( $search_in_term ) {
|
326 |
-
|
327 |
-
case 'title':
|
328 |
-
$relevance_array['title'][] = $wpdb->prepare( "( case when ( term_source = 'title' AND term = '%s' ) then {$relevance_title} * count else 0 end )", $search_term );
|
329 |
-
$relevance_array['title'][] = $wpdb->prepare( "( case when ( term_source = 'title' AND term LIKE %s ) then {$relevance_title_like} * count else 0 end )", $like );
|
330 |
-
break;
|
331 |
-
|
332 |
-
case 'content':
|
333 |
-
$relevance_array['content'][] = $wpdb->prepare( "( case when ( term_source = 'content' AND term = '%s' ) then {$relevance_content} * count else 0 end )", $search_term );
|
334 |
-
$relevance_array['content'][] = $wpdb->prepare( "( case when ( term_source = 'content' AND term LIKE %s ) then {$relevance_content_like} * count else 0 end )", $like );
|
335 |
-
break;
|
336 |
-
|
337 |
-
case 'excerpt':
|
338 |
-
$relevance_array['excerpt'][] = $wpdb->prepare( "( case when ( term_source = 'excerpt' AND term = '%s' ) then {$relevance_content} * count else 0 end )", $search_term );
|
339 |
-
$relevance_array['excerpt'][] = $wpdb->prepare( "( case when ( term_source = 'excerpt' AND term LIKE %s ) then {$relevance_content_like} * count else 0 end )", $like );
|
340 |
-
break;
|
341 |
-
|
342 |
-
case 'category':
|
343 |
-
$relevance_array['category'][] = $wpdb->prepare( "( case when ( term_source = 'category' AND term = '%s' ) then 35 else 0 end )", $search_term );
|
344 |
-
$relevance_array['category'][] = $wpdb->prepare( "( case when ( term_source = 'category' AND term LIKE %s ) then 5 else 0 end )", $like );
|
345 |
-
break;
|
346 |
-
|
347 |
-
case 'tag':
|
348 |
-
$relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term = '%s' ) then 35 else 0 end )", $search_term );
|
349 |
-
$relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term LIKE %s ) then 5 else 0 end )", $like );
|
350 |
-
break;
|
351 |
-
|
352 |
-
case 'sku':
|
353 |
-
$relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term = '%s' ) then 300 else 0 end )", $search_term );
|
354 |
-
$relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term LIKE %s ) then 50 else 0 end )", $like );
|
355 |
-
break;
|
356 |
-
|
357 |
-
case 'id':
|
358 |
-
$relevance_array['id'][] = $wpdb->prepare( "( case when ( term_source = 'id' AND term = '%s' ) then 300 else 0 end )", $search_term );
|
359 |
-
$relevance_array['id'][] = $wpdb->prepare( "( case when ( term_source = 'id' AND term LIKE %s ) then 5 else 0 end )", $like );
|
360 |
-
break;
|
361 |
-
|
362 |
-
}
|
363 |
-
|
364 |
-
}
|
365 |
-
|
366 |
-
}
|
367 |
-
|
368 |
-
// Sort 'relevance' queries in the array by search priority
|
369 |
-
foreach ( $search_in_arr as $search_in_item ) {
|
370 |
-
if ( isset( $relevance_array[$search_in_item] ) ) {
|
371 |
-
$new_relevance_array[$search_in_item] = implode( ' + ', $relevance_array[$search_in_item] );
|
372 |
-
}
|
373 |
-
}
|
374 |
-
|
375 |
-
$query['select'] = ' distinct ID';
|
376 |
-
$query['relevance'] = sprintf( ' (SUM( %s )) ', implode( ' + ', $new_relevance_array ) );
|
377 |
-
$query['search'] = sprintf( ' AND ( %s )', implode( ' OR ', $search_array ) );
|
378 |
-
|
379 |
-
|
380 |
-
if ( $reindex_version && version_compare( $reindex_version, '1.16', '>=' ) ) {
|
381 |
-
|
382 |
-
if ( $outofstock !== 'true' ) {
|
383 |
-
$query['stock'] = " AND in_stock = 1";
|
384 |
-
}
|
385 |
-
|
386 |
-
$query['visibility'] = " AND visibility NOT IN ( 'hidden', 'catalog' )";
|
387 |
-
|
388 |
-
}
|
389 |
-
|
390 |
-
|
391 |
-
/**
|
392 |
-
* Exclude certain products from search
|
393 |
-
*
|
394 |
-
* @since 1.58
|
395 |
-
*
|
396 |
-
* @param array
|
397 |
-
*/
|
398 |
-
$exclude_products_filter = apply_filters( 'aws_exclude_products', array() );
|
399 |
-
|
400 |
-
if ( $exclude_products_filter && is_array( $exclude_products_filter ) && ! empty( $exclude_products_filter ) ) {
|
401 |
-
$query['exclude_products'] = sprintf( ' AND ( id NOT IN ( %s ) )', implode( ',', $exclude_products_filter ) );
|
402 |
-
}
|
403 |
-
|
404 |
-
|
405 |
-
if ( $this->lang ) {
|
406 |
-
$current_lang = $this->lang;
|
407 |
-
} else {
|
408 |
-
$current_lang = AWS_Helpers::get_lang();
|
409 |
-
}
|
410 |
-
|
411 |
-
/**
|
412 |
-
* Filter current language code
|
413 |
-
* @since 1.59
|
414 |
-
* @param string $current_lang Lang code
|
415 |
-
*/
|
416 |
-
$current_lang = apply_filters( 'aws_search_current_lang', $current_lang );
|
417 |
-
|
418 |
-
if ( $current_lang && $reindex_version && version_compare( $reindex_version, '1.20', '>=' ) ) {
|
419 |
-
$query['lang'] = $wpdb->prepare( " AND ( lang LIKE %s OR lang = '' )", $current_lang );
|
420 |
-
}
|
421 |
-
|
422 |
-
/**
|
423 |
-
* Filter search query parameters
|
424 |
-
* @since 1.67
|
425 |
-
* @param array $query Query parameters
|
426 |
-
*/
|
427 |
-
$query = apply_filters( 'aws_search_query_array', $query );
|
428 |
-
|
429 |
-
$sql = "SELECT
|
430 |
-
{$query['select']},
|
431 |
-
{$query['relevance']} as relevance
|
432 |
-
FROM
|
433 |
-
{$table_name}
|
434 |
-
WHERE
|
435 |
-
1=1
|
436 |
-
{$query['search']}
|
437 |
-
{$query['stock']}
|
438 |
-
{$query['visibility']}
|
439 |
-
{$query['exclude_products']}
|
440 |
-
{$query['lang']}
|
441 |
-
GROUP BY ID
|
442 |
-
having relevance > 0
|
443 |
-
ORDER BY
|
444 |
-
relevance DESC, id DESC
|
445 |
-
LIMIT 0, {$results_num}
|
446 |
-
";
|
447 |
-
|
448 |
-
/**
|
449 |
-
* Filter search query string
|
450 |
-
* @since 2.06
|
451 |
-
* @param array $query Query string
|
452 |
-
*/
|
453 |
-
$sql = apply_filters( 'aws_search_query_string', $sql );
|
454 |
-
|
455 |
-
$this->data['sql'] = $sql;
|
456 |
-
|
457 |
-
$posts_ids = $this->get_posts_ids( $sql );
|
458 |
-
|
459 |
-
return $posts_ids;
|
460 |
-
|
461 |
-
}
|
462 |
-
|
463 |
-
/*
|
464 |
-
* Get array of included to search result posts ids
|
465 |
-
*/
|
466 |
-
private function get_posts_ids( $sql ) {
|
467 |
-
|
468 |
-
global $wpdb;
|
469 |
-
|
470 |
-
$posts_ids = array();
|
471 |
-
|
472 |
-
$search_results = $wpdb->get_results( $sql );
|
473 |
-
|
474 |
-
|
475 |
-
if ( !empty( $search_results ) && !is_wp_error( $search_results ) && is_array( $search_results ) ) {
|
476 |
-
foreach ( $search_results as $search_result ) {
|
477 |
-
$post_id = intval( $search_result->ID );
|
478 |
-
if ( ! in_array( $post_id, $posts_ids ) ) {
|
479 |
-
$posts_ids[] = $post_id;
|
480 |
-
}
|
481 |
-
}
|
482 |
-
}
|
483 |
-
|
484 |
-
unset( $search_results );
|
485 |
-
|
486 |
-
return $posts_ids;
|
487 |
-
|
488 |
-
}
|
489 |
-
|
490 |
-
/*
|
491 |
-
* Get products info
|
492 |
-
*/
|
493 |
-
private function get_products( $posts_ids ) {
|
494 |
-
|
495 |
-
$products_array = array();
|
496 |
-
|
497 |
-
if ( count( $posts_ids ) > 0 ) {
|
498 |
-
|
499 |
-
$show_excerpt = AWS()->get_settings( 'show_excerpt' );
|
500 |
-
$excerpt_source = AWS()->get_settings( 'desc_source' );
|
501 |
-
$excerpt_length = AWS()->get_settings( 'excerpt_length' );
|
502 |
-
$desc_scrap_words = AWS()->get_settings( 'mark_words' );
|
503 |
-
$highlight_words = AWS()->get_settings( 'highlight' );
|
504 |
-
$show_price = AWS()->get_settings( 'show_price' );
|
505 |
-
$show_outofstockprice = AWS()->get_settings( 'show_outofstock_price' );
|
506 |
-
$show_sale = AWS()->get_settings( 'show_sale' );
|
507 |
-
$show_image = AWS()->get_settings( 'show_image' );
|
508 |
-
$show_sku = AWS()->get_settings( 'show_sku' );
|
509 |
-
$show_stock_status = AWS()->get_settings( 'show_stock' );
|
510 |
-
$show_featured = AWS()->get_settings( 'show_featured' );
|
511 |
-
|
512 |
-
$posts_items = $posts_ids;
|
513 |
-
|
514 |
-
foreach ( $posts_items as $post_item ) {
|
515 |
-
|
516 |
-
if ( ! is_object( $post_item ) ) {
|
517 |
-
$product = wc_get_product( $post_item );
|
518 |
-
} else {
|
519 |
-
$product = $post_item;
|
520 |
-
}
|
521 |
-
|
522 |
-
if ( ! is_a( $product, 'WC_Product' ) ) {
|
523 |
-
continue;
|
524 |
-
}
|
525 |
-
|
526 |
-
setup_postdata( $post_item );
|
527 |
-
|
528 |
-
$post_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $post_item;
|
529 |
-
$parent_id = $product->is_type( 'variation' ) && method_exists( $product, 'get_parent_id' ) ? $product->get_parent_id() : $post_id;
|
530 |
-
|
531 |
-
/**
|
532 |
-
* Filter additional product data
|
533 |
-
* @since 1.60
|
534 |
-
* @param array $this->data Additional data
|
535 |
-
* @param int $post_id Product id
|
536 |
-
* @param object $product Product
|
537 |
-
*/
|
538 |
-
$this->data = apply_filters( 'aws_search_data_params', $this->data, $post_id, $product );
|
539 |
-
|
540 |
-
$post_data = get_post( $post_id );
|
541 |
-
|
542 |
-
$title = $product->get_title();
|
543 |
-
$title = AWS_Helpers::html2txt( $title );
|
544 |
-
|
545 |
-
$excerpt = '';
|
546 |
-
$price = '';
|
547 |
-
$on_sale = '';
|
548 |
-
$image = '';
|
549 |
-
$sku = '';
|
550 |
-
$stock_status = '';
|
551 |
-
$featured = '';
|
552 |
-
|
553 |
-
|
554 |
-
if ( $show_excerpt === 'true' ) {
|
555 |
-
|
556 |
-
$excerpt = ( $excerpt_source === 'excerpt' && $post_data->post_excerpt ) ? $post_data->post_excerpt : $post_data->post_content;
|
557 |
-
$excerpt = AWS_Helpers::html2txt( $excerpt );
|
558 |
-
$excerpt = str_replace('"', "'", $excerpt);
|
559 |
-
$excerpt = strip_shortcodes( $excerpt );
|
560 |
-
$excerpt = AWS_Helpers::strip_shortcodes( $excerpt );
|
561 |
-
|
562 |
-
if ( $desc_scrap_words === 'true' ) {
|
563 |
-
|
564 |
-
$marked_content = $this->scrap_content( $excerpt );
|
565 |
-
|
566 |
-
if ( $marked_content ) {
|
567 |
-
$excerpt = $marked_content;
|
568 |
-
} else {
|
569 |
-
$excerpt = wp_trim_words( $excerpt, $excerpt_length, '...' );
|
570 |
-
}
|
571 |
-
|
572 |
-
} else {
|
573 |
-
$excerpt = wp_trim_words( $excerpt, $excerpt_length, '...' );
|
574 |
-
}
|
575 |
-
|
576 |
-
}
|
577 |
-
|
578 |
-
|
579 |
-
if ( $show_price === 'true' && ( $product->is_in_stock() || ( ! $product->is_in_stock() && $show_outofstockprice === 'true' ) ) ) {
|
580 |
-
$price = $product->get_price_html();
|
581 |
-
$price = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "<span>$2</span>", $price);
|
582 |
-
}
|
583 |
-
|
584 |
-
if ( $show_sale === 'true' && ( $product->is_in_stock() || ( ! $product->is_in_stock() && $show_outofstockprice === 'true' ) ) ) {
|
585 |
-
$on_sale = $product->is_on_sale();
|
586 |
-
}
|
587 |
-
|
588 |
-
if ( $show_image === 'true' ) {
|
589 |
-
|
590 |
-
$image_id = $product->get_image_id();
|
591 |
-
$image_size = 'thumbnail';
|
592 |
-
|
593 |
-
/**
|
594 |
-
* Filter products images size
|
595 |
-
* @since 2.06
|
596 |
-
* @param string $image_size Image size
|
597 |
-
*/
|
598 |
-
$image_size = apply_filters( 'aws_image_size', $image_size );
|
599 |
-
|
600 |
-
if ( $image_id ) {
|
601 |
-
$image_attributes = wp_get_attachment_image_src( $image_id, $image_size );
|
602 |
-
$image = $image_attributes ? $image_attributes[0] : '';
|
603 |
-
}
|
604 |
-
|
605 |
-
}
|
606 |
-
|
607 |
-
if ( $show_sku === 'true' ) {
|
608 |
-
$sku = $product->get_sku();
|
609 |
-
}
|
610 |
-
|
611 |
-
if ( $show_featured === 'true' ) {
|
612 |
-
$featured = $product->is_featured();
|
613 |
-
}
|
614 |
-
|
615 |
-
if ( $show_stock_status === 'true' ) {
|
616 |
-
if ( $product->is_in_stock() ) {
|
617 |
-
$stock_status = array(
|
618 |
-
'status' => true,
|
619 |
-
'text' => esc_html__( 'In stock', 'advanced-woo-search' )
|
620 |
-
);
|
621 |
-
} else {
|
622 |
-
$stock_status = array(
|
623 |
-
'status' => false,
|
624 |
-
'text' => esc_html__( 'Out of stock', 'advanced-woo-search' )
|
625 |
-
);
|
626 |
-
}
|
627 |
-
}
|
628 |
-
|
629 |
-
if ( method_exists( $product, 'get_price' ) ) {
|
630 |
-
$f_price = $product->get_price();
|
631 |
-
}
|
632 |
-
|
633 |
-
if ( method_exists( $product, 'get_average_rating' ) ) {
|
634 |
-
$f_rating = $product->get_average_rating();
|
635 |
-
}
|
636 |
-
|
637 |
-
if ( method_exists( $product,'get_review_count' ) ) {
|
638 |
-
$f_reviews = $product->get_review_count();
|
639 |
-
}
|
640 |
-
|
641 |
-
$f_stock = $product->is_in_stock();
|
642 |
-
$f_sale = $product->is_on_sale();
|
643 |
-
|
644 |
-
// $categories = $product->get_categories( ',' );
|
645 |
-
// $tags = $product->get_tags( ',' );
|
646 |
-
|
647 |
-
if ( $highlight_words === 'true' ) {
|
648 |
-
$title = $this->highlight_words( $title );
|
649 |
-
$excerpt = $this->highlight_words( $excerpt );
|
650 |
-
$sku = $this->highlight_words( $sku );
|
651 |
-
}
|
652 |
-
|
653 |
-
$title = apply_filters( 'aws_title_search_result', $title, $post_id, $product );
|
654 |
-
$excerpt = apply_filters( 'aws_excerpt_search_result', $excerpt, $post_id, $product );
|
655 |
-
|
656 |
-
$new_result = array(
|
657 |
-
'id' => $post_id,
|
658 |
-
'parent_id' => $parent_id,
|
659 |
-
'title' => $title,
|
660 |
-
'excerpt' => $excerpt,
|
661 |
-
'link' => get_permalink( $post_id ),
|
662 |
-
'image' => $image,
|
663 |
-
'price' => $price,
|
664 |
-
'on_sale' => $on_sale,
|
665 |
-
'sku' => $sku,
|
666 |
-
'stock_status' => $stock_status,
|
667 |
-
'featured' => $featured,
|
668 |
-
'f_price' => $f_price,
|
669 |
-
'f_rating' => $f_rating,
|
670 |
-
'f_reviews' => $f_reviews,
|
671 |
-
'f_stock' => $f_stock,
|
672 |
-
'f_sale' => $f_sale,
|
673 |
-
'post_data' => $post_data
|
674 |
-
);
|
675 |
-
|
676 |
-
$products_array[] = $new_result;
|
677 |
-
|
678 |
-
wp_reset_postdata();
|
679 |
-
|
680 |
-
}
|
681 |
-
|
682 |
-
}
|
683 |
-
|
684 |
-
/**
|
685 |
-
* Filter products array before output
|
686 |
-
* @since 1.60
|
687 |
-
* @param array $products_array Products array
|
688 |
-
* @param array $this->data Additional data
|
689 |
-
*/
|
690 |
-
$products_array = apply_filters( 'aws_search_pre_filter_products', $products_array, $this->data );
|
691 |
-
|
692 |
-
return $products_array;
|
693 |
-
|
694 |
-
}
|
695 |
-
|
696 |
-
/*
|
697 |
-
* Scrap content excerpt
|
698 |
-
*/
|
699 |
-
private function scrap_content( $content ) {
|
700 |
-
|
701 |
-
$exact_words = array();
|
702 |
-
$words = array();
|
703 |
-
|
704 |
-
foreach( $this->data['search_terms'] as $search_in ) {
|
705 |
-
|
706 |
-
$exact_words[] = '\b' . $search_in . '\b';
|
707 |
-
|
708 |
-
if ( strlen( $search_in ) > 1 ) {
|
709 |
-
$words[] = $search_in;
|
710 |
-
} else {
|
711 |
-
$words[] = '\b' . $search_in . '\b';
|
712 |
-
}
|
713 |
-
|
714 |
-
}
|
715 |
-
|
716 |
-
usort( $exact_words, array( $this, 'sort_by_length' ) );
|
717 |
-
$exact_words = implode( '|', $exact_words );
|
718 |
-
|
719 |
-
usort( $words, array( $this, 'sort_by_length' ) );
|
720 |
-
$words = implode( '|', $words );
|
721 |
-
|
722 |
-
preg_match( '/([^.?!]*?)(' . $exact_words . '){1}(.*?[.!?])/i', $content, $matches );
|
723 |
-
|
724 |
-
if ( ! isset( $matches[0] ) ) {
|
725 |
-
preg_match( '/([^.?!]*?)(' . $words . '){1}(.*?[.!?])/i', $content, $matches );
|
726 |
-
}
|
727 |
-
|
728 |
-
if ( ! isset( $matches[0] ) ) {
|
729 |
-
preg_match( '/([^.?!]*?)(.*?)(.*?[.!?])/i', $content, $matches );
|
730 |
-
}
|
731 |
-
|
732 |
-
if ( isset( $matches[0] ) ) {
|
733 |
-
|
734 |
-
$content = $matches[0];
|
735 |
-
|
736 |
-
// Trim to long content
|
737 |
-
if (str_word_count(strip_tags($content)) > 34) {
|
738 |
-
|
739 |
-
if (str_word_count(strip_tags($matches[3])) > 34) {
|
740 |
-
$matches[3] = wp_trim_words($matches[3], 30, '...');
|
741 |
-
}
|
742 |
-
|
743 |
-
$content = '...' . $matches[2] . $matches[3];
|
744 |
-
|
745 |
-
}
|
746 |
-
|
747 |
-
} else {
|
748 |
-
|
749 |
-
$content = '';
|
750 |
-
|
751 |
-
}
|
752 |
-
|
753 |
-
return $content;
|
754 |
-
|
755 |
-
}
|
756 |
-
|
757 |
-
/*
|
758 |
-
* Highlight search words
|
759 |
-
*/
|
760 |
-
private function highlight_words( $text ) {
|
761 |
-
|
762 |
-
if ( ! $text ) {
|
763 |
-
return $text;
|
764 |
-
}
|
765 |
-
|
766 |
-
$pattern = array();
|
767 |
-
|
768 |
-
foreach( $this->data['search_terms'] as $search_in ) {
|
769 |
-
|
770 |
-
if ( strlen( $search_in ) > 1 ) {
|
771 |
-
$pattern[] = '(' . $search_in . ')+';
|
772 |
-
} else {
|
773 |
-
$pattern[] = '\b[' . $search_in . ']{1}\b';
|
774 |
-
}
|
775 |
-
|
776 |
-
}
|
777 |
-
|
778 |
-
usort( $pattern, array( $this, 'sort_by_length' ) );
|
779 |
-
$pattern = implode( '|', $pattern );
|
780 |
-
$pattern = sprintf( '/%s/i', $pattern );
|
781 |
-
|
782 |
-
/**
|
783 |
-
* Tag to use for highlighting search words inside content
|
784 |
-
* @since 1.88
|
785 |
-
* @param string Tag for highlighting
|
786 |
-
*/
|
787 |
-
$highlight_tag = apply_filters( 'aws_highlight_tag', 'strong' );
|
788 |
-
|
789 |
-
$highlight_tag_pattern = '<' . $highlight_tag . '>${0}</' . $highlight_tag . '>';
|
790 |
-
|
791 |
-
$text = preg_replace($pattern, $highlight_tag_pattern, $text );
|
792 |
-
|
793 |
-
return $text;
|
794 |
-
|
795 |
-
}
|
796 |
-
|
797 |
-
/*
|
798 |
-
* Sort array by its values length
|
799 |
-
*/
|
800 |
-
private function sort_by_length( $a, $b ) {
|
801 |
-
return strlen( $b ) - strlen( $a );
|
802 |
-
}
|
803 |
-
|
804 |
-
}
|
805 |
-
|
806 |
-
|
807 |
-
endif;
|
808 |
-
|
809 |
-
AWS_Search::factory();
|
810 |
-
|
811 |
-
function aws_search( $keyword = '' ) {
|
812 |
-
return AWS_Search::factory()->search( $keyword );
|
813 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Search' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plugin search
|
11 |
+
*/
|
12 |
+
class AWS_Search {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var AWS_Search Array of all plugin data $data
|
16 |
+
*/
|
17 |
+
private $data = array();
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var AWS_Search Current language $lang
|
21 |
+
*/
|
22 |
+
private $lang = 0;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Return a singleton instance of the current class
|
26 |
+
*
|
27 |
+
* @return object
|
28 |
+
*/
|
29 |
+
public static function factory() {
|
30 |
+
static $instance = false;
|
31 |
+
|
32 |
+
if ( ! $instance ) {
|
33 |
+
$instance = new self();
|
34 |
+
$instance->setup();
|
35 |
+
}
|
36 |
+
|
37 |
+
return $instance;
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Constructor
|
42 |
+
*/
|
43 |
+
public function __construct() {}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Setup actions and filters for all things settings
|
47 |
+
*/
|
48 |
+
public function setup() {
|
49 |
+
|
50 |
+
$this->data['settings'] = get_option( 'aws_settings' );
|
51 |
+
|
52 |
+
if ( isset( $_REQUEST['wc-ajax'] ) ) {
|
53 |
+
add_action( 'wc_ajax_aws_action', array( $this, 'action_callback' ) );
|
54 |
+
} else {
|
55 |
+
add_action( 'wp_ajax_aws_action', array( $this, 'action_callback' ) );
|
56 |
+
add_action( 'wp_ajax_nopriv_aws_action', array( $this, 'action_callback' ) );
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
60 |
+
|
61 |
+
/*
|
62 |
+
* AJAX call action callback
|
63 |
+
*/
|
64 |
+
public function action_callback() {
|
65 |
+
|
66 |
+
if ( ! defined( 'DOING_AJAX' ) ) {
|
67 |
+
define( 'DOING_AJAX', true );
|
68 |
+
}
|
69 |
+
|
70 |
+
if ( ! headers_sent() && isset( $_REQUEST['typedata'] ) ) {
|
71 |
+
header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) );
|
72 |
+
}
|
73 |
+
|
74 |
+
echo json_encode( $this->search() );
|
75 |
+
|
76 |
+
die;
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
/*
|
81 |
+
* Search
|
82 |
+
*/
|
83 |
+
public function search( $keyword = '' ) {
|
84 |
+
|
85 |
+
global $wpdb;
|
86 |
+
|
87 |
+
$this->lang = isset( $_REQUEST['lang'] ) ? sanitize_text_field( $_REQUEST['lang'] ) : '';
|
88 |
+
|
89 |
+
if ( $this->lang ) {
|
90 |
+
do_action( 'wpml_switch_language', $this->lang );
|
91 |
+
}
|
92 |
+
|
93 |
+
$cache = AWS()->get_settings( 'cache' );
|
94 |
+
|
95 |
+
$s = $keyword ? esc_attr( $keyword ) : esc_attr( $_POST['keyword'] );
|
96 |
+
$s = htmlspecialchars_decode( $s );
|
97 |
+
|
98 |
+
$this->data['s_nonormalize'] = $s;
|
99 |
+
|
100 |
+
$s = AWS_Helpers::normalize_string( $s );
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Fires each time when performing the search
|
105 |
+
* @since 1.59
|
106 |
+
* @param string $s Search query
|
107 |
+
*/
|
108 |
+
do_action( 'aws_search_start', $s );
|
109 |
+
|
110 |
+
|
111 |
+
$cache_option_name = '';
|
112 |
+
|
113 |
+
if ( $cache === 'true' && ! $keyword ) {
|
114 |
+
$cache_option_name = AWS()->cache->get_cache_name( $s );
|
115 |
+
$res = AWS()->cache->get_from_cache_table( $cache_option_name );
|
116 |
+
if ( $res ) {
|
117 |
+
$cached_value = json_decode( $res );
|
118 |
+
if ( $cached_value && ! empty( $cached_value ) ) {
|
119 |
+
return $cached_value;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
$search_archives = AWS()->get_settings( 'search_archives' );
|
125 |
+
$show_cats = ( isset( $search_archives['archive_category'] ) && $search_archives['archive_category'] ) ? 'true' : 'false';
|
126 |
+
$show_tags = ( isset( $search_archives['archive_tag'] ) && $search_archives['archive_tag'] ) ? 'true' : 'false';
|
127 |
+
$results_num = $keyword ? apply_filters( 'aws_page_results', 100 ) : AWS()->get_settings( 'results_num' );
|
128 |
+
$search_in = AWS()->get_settings( 'search_in' );
|
129 |
+
$outofstock = AWS()->get_settings( 'outofstock' );
|
130 |
+
$search_rule = AWS()->get_settings( 'search_rule' );
|
131 |
+
|
132 |
+
$search_in_arr = array();
|
133 |
+
|
134 |
+
if ( is_array( $search_in ) && ! empty( $search_in ) ) {
|
135 |
+
foreach( $search_in as $search_in_source => $search_in_active ) {
|
136 |
+
if ( $search_in_active ) {
|
137 |
+
$search_in_arr[] = $search_in_source;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
} elseif ( is_string( $search_in ) && $search_in ) {
|
141 |
+
$search_in_arr = explode( ',', $search_in );
|
142 |
+
}
|
143 |
+
|
144 |
+
$products_array = array();
|
145 |
+
$tax_to_display = array();
|
146 |
+
$custom_tax_array = array();
|
147 |
+
|
148 |
+
$this->data['s'] = $s;
|
149 |
+
$this->data['results_num'] = $results_num ? $results_num : 10;
|
150 |
+
$this->data['search_terms'] = array();
|
151 |
+
$this->data['search_in'] = $search_in_arr;
|
152 |
+
$this->data['outofstock'] = $outofstock;
|
153 |
+
$this->data['search_rule'] = $search_rule;
|
154 |
+
|
155 |
+
$search_array = array_unique( explode( ' ', $s ) );
|
156 |
+
|
157 |
+
$search_array = AWS_Helpers::filter_stopwords( $search_array );
|
158 |
+
|
159 |
+
if ( is_array( $search_array ) && ! empty( $search_array ) ) {
|
160 |
+
foreach ( $search_array as $search_term ) {
|
161 |
+
$search_term = trim( $search_term );
|
162 |
+
if ( $search_term ) {
|
163 |
+
$this->data['search_terms'][] = $search_term;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
// if ( empty( $this->data['search_terms'] ) ) {
|
169 |
+
// $this->data['search_terms'][] = '';
|
170 |
+
// }
|
171 |
+
|
172 |
+
if ( ! empty( $this->data['search_terms'] ) ) {
|
173 |
+
|
174 |
+
if ( ! empty( $this->data['search_in'] ) ) {
|
175 |
+
|
176 |
+
$posts_ids = $this->query_index_table();
|
177 |
+
|
178 |
+
/**
|
179 |
+
* Filters array of products ids
|
180 |
+
*
|
181 |
+
* @since 1.53
|
182 |
+
*
|
183 |
+
* @param array $posts_ids Array of products ids
|
184 |
+
* @param string $s Search query
|
185 |
+
*/
|
186 |
+
$posts_ids = apply_filters( 'aws_search_results_products_ids', $posts_ids, $s );
|
187 |
+
|
188 |
+
|
189 |
+
$products_array = $this->get_products( $posts_ids );
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Filters array of products before they displayed in search results
|
193 |
+
*
|
194 |
+
* @since 1.42
|
195 |
+
*
|
196 |
+
* @param array $products_array Array of products results
|
197 |
+
* @param string $s Search query
|
198 |
+
*/
|
199 |
+
$products_array = apply_filters( 'aws_search_results_products', $products_array, $s );
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
if ( $show_cats === 'true' ) {
|
204 |
+
$tax_to_display[] = 'product_cat';
|
205 |
+
}
|
206 |
+
|
207 |
+
if ( $show_tags === 'true' ) {
|
208 |
+
$tax_to_display[] = 'product_tag';
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* Filters array of custom taxonomies that must be displayed in search results
|
213 |
+
*
|
214 |
+
* @since 1.68
|
215 |
+
*
|
216 |
+
* @param array $taxonomies_archives Array of custom taxonomies
|
217 |
+
* @param string $s Search query
|
218 |
+
*/
|
219 |
+
$taxonomies_archives = apply_filters( 'aws_search_results_tax_archives', $tax_to_display, $s );
|
220 |
+
|
221 |
+
if ( $taxonomies_archives && is_array( $taxonomies_archives ) && ! empty( $taxonomies_archives ) ) {
|
222 |
+
|
223 |
+
$tax_search = new AWS_Tax_Search( $taxonomies_archives, $this->data );
|
224 |
+
$custom_tax_array = $tax_search->get_results();
|
225 |
+
|
226 |
+
}
|
227 |
+
|
228 |
+
}
|
229 |
+
|
230 |
+
|
231 |
+
$result_array = array(
|
232 |
+
'tax' => $custom_tax_array,
|
233 |
+
'products' => $products_array,
|
234 |
+
);
|
235 |
+
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Filters array of all results data before they displayed in search results
|
239 |
+
*
|
240 |
+
* @since 1.43
|
241 |
+
*
|
242 |
+
* @param array $brands_array Array of products data
|
243 |
+
* @param string $s Search query
|
244 |
+
*/
|
245 |
+
$result_array = apply_filters( 'aws_search_results_all', $result_array, $s );
|
246 |
+
|
247 |
+
if ( $cache === 'true' && ! $keyword ) {
|
248 |
+
AWS()->cache->insert_into_cache_table( $cache_option_name, $result_array );
|
249 |
+
}
|
250 |
+
|
251 |
+
return $result_array;
|
252 |
+
|
253 |
+
}
|
254 |
+
|
255 |
+
/*
|
256 |
+
* Query in index table
|
257 |
+
*/
|
258 |
+
private function query_index_table() {
|
259 |
+
|
260 |
+
global $wpdb;
|
261 |
+
|
262 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
263 |
+
|
264 |
+
$search_in_arr = $this->data['search_in'];
|
265 |
+
$results_num = $this->data['results_num'];
|
266 |
+
$outofstock = $this->data['outofstock'];
|
267 |
+
$search_rule = $this->data['search_rule'];
|
268 |
+
|
269 |
+
$reindex_version = get_option( 'aws_reindex_version' );
|
270 |
+
|
271 |
+
$query = array();
|
272 |
+
|
273 |
+
$query['select'] = '';
|
274 |
+
$query['search'] = '';
|
275 |
+
$query['relevance'] = '';
|
276 |
+
$query['stock'] = '';
|
277 |
+
$query['visibility'] = '';
|
278 |
+
$query['exclude_products'] = '';
|
279 |
+
$query['lang'] = '';
|
280 |
+
|
281 |
+
$search_array = array();
|
282 |
+
$relevance_array = array();
|
283 |
+
$new_relevance_array = array();
|
284 |
+
|
285 |
+
|
286 |
+
/**
|
287 |
+
* Filters array of search terms before generating SQL query
|
288 |
+
*
|
289 |
+
* @since 1.49
|
290 |
+
*
|
291 |
+
* @param array $this->data['search_terms'] Array of search terms
|
292 |
+
*/
|
293 |
+
$this->data['search_terms'] = apply_filters( 'aws_search_terms', $this->data['search_terms'] );
|
294 |
+
|
295 |
+
|
296 |
+
foreach ( $this->data['search_terms'] as $search_term ) {
|
297 |
+
|
298 |
+
$search_term_len = strlen( $search_term );
|
299 |
+
|
300 |
+
$relevance_title = 200 + 20 * $search_term_len;
|
301 |
+
$relevance_content = 35 + 4 * $search_term_len;
|
302 |
+
$relevance_title_like = 40 + 2 * $search_term_len;
|
303 |
+
$relevance_content_like = 35 + 1 * $search_term_len;
|
304 |
+
|
305 |
+
$search_term_norm = AWS_Plurals::singularize( $search_term );
|
306 |
+
|
307 |
+
if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
|
308 |
+
$search_term = $search_term_norm;
|
309 |
+
}
|
310 |
+
|
311 |
+
if ( $search_rule === 'begins' ) {
|
312 |
+
$like = $wpdb->esc_like( $search_term ) . '%';
|
313 |
+
} else {
|
314 |
+
$like = '%' . $wpdb->esc_like( $search_term ) . '%';
|
315 |
+
}
|
316 |
+
|
317 |
+
if ( $search_term_len > 1 ) {
|
318 |
+
$search_array[] = $wpdb->prepare( '( term LIKE %s )', $like );
|
319 |
+
} else {
|
320 |
+
$search_array[] = $wpdb->prepare( '( term = "%s" )', $search_term );
|
321 |
+
}
|
322 |
+
|
323 |
+
foreach ( $search_in_arr as $search_in_term ) {
|
324 |
+
|
325 |
+
switch ( $search_in_term ) {
|
326 |
+
|
327 |
+
case 'title':
|
328 |
+
$relevance_array['title'][] = $wpdb->prepare( "( case when ( term_source = 'title' AND term = '%s' ) then {$relevance_title} * count else 0 end )", $search_term );
|
329 |
+
$relevance_array['title'][] = $wpdb->prepare( "( case when ( term_source = 'title' AND term LIKE %s ) then {$relevance_title_like} * count else 0 end )", $like );
|
330 |
+
break;
|
331 |
+
|
332 |
+
case 'content':
|
333 |
+
$relevance_array['content'][] = $wpdb->prepare( "( case when ( term_source = 'content' AND term = '%s' ) then {$relevance_content} * count else 0 end )", $search_term );
|
334 |
+
$relevance_array['content'][] = $wpdb->prepare( "( case when ( term_source = 'content' AND term LIKE %s ) then {$relevance_content_like} * count else 0 end )", $like );
|
335 |
+
break;
|
336 |
+
|
337 |
+
case 'excerpt':
|
338 |
+
$relevance_array['excerpt'][] = $wpdb->prepare( "( case when ( term_source = 'excerpt' AND term = '%s' ) then {$relevance_content} * count else 0 end )", $search_term );
|
339 |
+
$relevance_array['excerpt'][] = $wpdb->prepare( "( case when ( term_source = 'excerpt' AND term LIKE %s ) then {$relevance_content_like} * count else 0 end )", $like );
|
340 |
+
break;
|
341 |
+
|
342 |
+
case 'category':
|
343 |
+
$relevance_array['category'][] = $wpdb->prepare( "( case when ( term_source = 'category' AND term = '%s' ) then 35 else 0 end )", $search_term );
|
344 |
+
$relevance_array['category'][] = $wpdb->prepare( "( case when ( term_source = 'category' AND term LIKE %s ) then 5 else 0 end )", $like );
|
345 |
+
break;
|
346 |
+
|
347 |
+
case 'tag':
|
348 |
+
$relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term = '%s' ) then 35 else 0 end )", $search_term );
|
349 |
+
$relevance_array['tag'][] = $wpdb->prepare( "( case when ( term_source = 'tag' AND term LIKE %s ) then 5 else 0 end )", $like );
|
350 |
+
break;
|
351 |
+
|
352 |
+
case 'sku':
|
353 |
+
$relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term = '%s' ) then 300 else 0 end )", $search_term );
|
354 |
+
$relevance_array['sku'][] = $wpdb->prepare( "( case when ( term_source = 'sku' AND term LIKE %s ) then 50 else 0 end )", $like );
|
355 |
+
break;
|
356 |
+
|
357 |
+
case 'id':
|
358 |
+
$relevance_array['id'][] = $wpdb->prepare( "( case when ( term_source = 'id' AND term = '%s' ) then 300 else 0 end )", $search_term );
|
359 |
+
$relevance_array['id'][] = $wpdb->prepare( "( case when ( term_source = 'id' AND term LIKE %s ) then 5 else 0 end )", $like );
|
360 |
+
break;
|
361 |
+
|
362 |
+
}
|
363 |
+
|
364 |
+
}
|
365 |
+
|
366 |
+
}
|
367 |
+
|
368 |
+
// Sort 'relevance' queries in the array by search priority
|
369 |
+
foreach ( $search_in_arr as $search_in_item ) {
|
370 |
+
if ( isset( $relevance_array[$search_in_item] ) ) {
|
371 |
+
$new_relevance_array[$search_in_item] = implode( ' + ', $relevance_array[$search_in_item] );
|
372 |
+
}
|
373 |
+
}
|
374 |
+
|
375 |
+
$query['select'] = ' distinct ID';
|
376 |
+
$query['relevance'] = sprintf( ' (SUM( %s )) ', implode( ' + ', $new_relevance_array ) );
|
377 |
+
$query['search'] = sprintf( ' AND ( %s )', implode( ' OR ', $search_array ) );
|
378 |
+
|
379 |
+
|
380 |
+
if ( $reindex_version && version_compare( $reindex_version, '1.16', '>=' ) ) {
|
381 |
+
|
382 |
+
if ( $outofstock !== 'true' ) {
|
383 |
+
$query['stock'] = " AND in_stock = 1";
|
384 |
+
}
|
385 |
+
|
386 |
+
$query['visibility'] = " AND visibility NOT IN ( 'hidden', 'catalog' )";
|
387 |
+
|
388 |
+
}
|
389 |
+
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Exclude certain products from search
|
393 |
+
*
|
394 |
+
* @since 1.58
|
395 |
+
*
|
396 |
+
* @param array
|
397 |
+
*/
|
398 |
+
$exclude_products_filter = apply_filters( 'aws_exclude_products', array() );
|
399 |
+
|
400 |
+
if ( $exclude_products_filter && is_array( $exclude_products_filter ) && ! empty( $exclude_products_filter ) ) {
|
401 |
+
$query['exclude_products'] = sprintf( ' AND ( id NOT IN ( %s ) )', implode( ',', $exclude_products_filter ) );
|
402 |
+
}
|
403 |
+
|
404 |
+
|
405 |
+
if ( $this->lang ) {
|
406 |
+
$current_lang = $this->lang;
|
407 |
+
} else {
|
408 |
+
$current_lang = AWS_Helpers::get_lang();
|
409 |
+
}
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Filter current language code
|
413 |
+
* @since 1.59
|
414 |
+
* @param string $current_lang Lang code
|
415 |
+
*/
|
416 |
+
$current_lang = apply_filters( 'aws_search_current_lang', $current_lang );
|
417 |
+
|
418 |
+
if ( $current_lang && $reindex_version && version_compare( $reindex_version, '1.20', '>=' ) ) {
|
419 |
+
$query['lang'] = $wpdb->prepare( " AND ( lang LIKE %s OR lang = '' )", $current_lang );
|
420 |
+
}
|
421 |
+
|
422 |
+
/**
|
423 |
+
* Filter search query parameters
|
424 |
+
* @since 1.67
|
425 |
+
* @param array $query Query parameters
|
426 |
+
*/
|
427 |
+
$query = apply_filters( 'aws_search_query_array', $query );
|
428 |
+
|
429 |
+
$sql = "SELECT
|
430 |
+
{$query['select']},
|
431 |
+
{$query['relevance']} as relevance
|
432 |
+
FROM
|
433 |
+
{$table_name}
|
434 |
+
WHERE
|
435 |
+
1=1
|
436 |
+
{$query['search']}
|
437 |
+
{$query['stock']}
|
438 |
+
{$query['visibility']}
|
439 |
+
{$query['exclude_products']}
|
440 |
+
{$query['lang']}
|
441 |
+
GROUP BY ID
|
442 |
+
having relevance > 0
|
443 |
+
ORDER BY
|
444 |
+
relevance DESC, id DESC
|
445 |
+
LIMIT 0, {$results_num}
|
446 |
+
";
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Filter search query string
|
450 |
+
* @since 2.06
|
451 |
+
* @param array $query Query string
|
452 |
+
*/
|
453 |
+
$sql = apply_filters( 'aws_search_query_string', $sql );
|
454 |
+
|
455 |
+
$this->data['sql'] = $sql;
|
456 |
+
|
457 |
+
$posts_ids = $this->get_posts_ids( $sql );
|
458 |
+
|
459 |
+
return $posts_ids;
|
460 |
+
|
461 |
+
}
|
462 |
+
|
463 |
+
/*
|
464 |
+
* Get array of included to search result posts ids
|
465 |
+
*/
|
466 |
+
private function get_posts_ids( $sql ) {
|
467 |
+
|
468 |
+
global $wpdb;
|
469 |
+
|
470 |
+
$posts_ids = array();
|
471 |
+
|
472 |
+
$search_results = $wpdb->get_results( $sql );
|
473 |
+
|
474 |
+
|
475 |
+
if ( !empty( $search_results ) && !is_wp_error( $search_results ) && is_array( $search_results ) ) {
|
476 |
+
foreach ( $search_results as $search_result ) {
|
477 |
+
$post_id = intval( $search_result->ID );
|
478 |
+
if ( ! in_array( $post_id, $posts_ids ) ) {
|
479 |
+
$posts_ids[] = $post_id;
|
480 |
+
}
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
unset( $search_results );
|
485 |
+
|
486 |
+
return $posts_ids;
|
487 |
+
|
488 |
+
}
|
489 |
+
|
490 |
+
/*
|
491 |
+
* Get products info
|
492 |
+
*/
|
493 |
+
private function get_products( $posts_ids ) {
|
494 |
+
|
495 |
+
$products_array = array();
|
496 |
+
|
497 |
+
if ( count( $posts_ids ) > 0 ) {
|
498 |
+
|
499 |
+
$show_excerpt = AWS()->get_settings( 'show_excerpt' );
|
500 |
+
$excerpt_source = AWS()->get_settings( 'desc_source' );
|
501 |
+
$excerpt_length = AWS()->get_settings( 'excerpt_length' );
|
502 |
+
$desc_scrap_words = AWS()->get_settings( 'mark_words' );
|
503 |
+
$highlight_words = AWS()->get_settings( 'highlight' );
|
504 |
+
$show_price = AWS()->get_settings( 'show_price' );
|
505 |
+
$show_outofstockprice = AWS()->get_settings( 'show_outofstock_price' );
|
506 |
+
$show_sale = AWS()->get_settings( 'show_sale' );
|
507 |
+
$show_image = AWS()->get_settings( 'show_image' );
|
508 |
+
$show_sku = AWS()->get_settings( 'show_sku' );
|
509 |
+
$show_stock_status = AWS()->get_settings( 'show_stock' );
|
510 |
+
$show_featured = AWS()->get_settings( 'show_featured' );
|
511 |
+
|
512 |
+
$posts_items = $posts_ids;
|
513 |
+
|
514 |
+
foreach ( $posts_items as $post_item ) {
|
515 |
+
|
516 |
+
if ( ! is_object( $post_item ) ) {
|
517 |
+
$product = wc_get_product( $post_item );
|
518 |
+
} else {
|
519 |
+
$product = $post_item;
|
520 |
+
}
|
521 |
+
|
522 |
+
if ( ! is_a( $product, 'WC_Product' ) ) {
|
523 |
+
continue;
|
524 |
+
}
|
525 |
+
|
526 |
+
setup_postdata( $post_item );
|
527 |
+
|
528 |
+
$post_id = method_exists( $product, 'get_id' ) ? $product->get_id() : $post_item;
|
529 |
+
$parent_id = $product->is_type( 'variation' ) && method_exists( $product, 'get_parent_id' ) ? $product->get_parent_id() : $post_id;
|
530 |
+
|
531 |
+
/**
|
532 |
+
* Filter additional product data
|
533 |
+
* @since 1.60
|
534 |
+
* @param array $this->data Additional data
|
535 |
+
* @param int $post_id Product id
|
536 |
+
* @param object $product Product
|
537 |
+
*/
|
538 |
+
$this->data = apply_filters( 'aws_search_data_params', $this->data, $post_id, $product );
|
539 |
+
|
540 |
+
$post_data = get_post( $post_id );
|
541 |
+
|
542 |
+
$title = $product->get_title();
|
543 |
+
$title = AWS_Helpers::html2txt( $title );
|
544 |
+
|
545 |
+
$excerpt = '';
|
546 |
+
$price = '';
|
547 |
+
$on_sale = '';
|
548 |
+
$image = '';
|
549 |
+
$sku = '';
|
550 |
+
$stock_status = '';
|
551 |
+
$featured = '';
|
552 |
+
|
553 |
+
|
554 |
+
if ( $show_excerpt === 'true' ) {
|
555 |
+
|
556 |
+
$excerpt = ( $excerpt_source === 'excerpt' && $post_data->post_excerpt ) ? $post_data->post_excerpt : $post_data->post_content;
|
557 |
+
$excerpt = AWS_Helpers::html2txt( $excerpt );
|
558 |
+
$excerpt = str_replace('"', "'", $excerpt);
|
559 |
+
$excerpt = strip_shortcodes( $excerpt );
|
560 |
+
$excerpt = AWS_Helpers::strip_shortcodes( $excerpt );
|
561 |
+
|
562 |
+
if ( $desc_scrap_words === 'true' ) {
|
563 |
+
|
564 |
+
$marked_content = $this->scrap_content( $excerpt );
|
565 |
+
|
566 |
+
if ( $marked_content ) {
|
567 |
+
$excerpt = $marked_content;
|
568 |
+
} else {
|
569 |
+
$excerpt = wp_trim_words( $excerpt, $excerpt_length, '...' );
|
570 |
+
}
|
571 |
+
|
572 |
+
} else {
|
573 |
+
$excerpt = wp_trim_words( $excerpt, $excerpt_length, '...' );
|
574 |
+
}
|
575 |
+
|
576 |
+
}
|
577 |
+
|
578 |
+
|
579 |
+
if ( $show_price === 'true' && ( $product->is_in_stock() || ( ! $product->is_in_stock() && $show_outofstockprice === 'true' ) ) ) {
|
580 |
+
$price = $product->get_price_html();
|
581 |
+
$price = preg_replace("/<a\s(.+?)>(.+?)<\/a>/is", "<span>$2</span>", $price);
|
582 |
+
}
|
583 |
+
|
584 |
+
if ( $show_sale === 'true' && ( $product->is_in_stock() || ( ! $product->is_in_stock() && $show_outofstockprice === 'true' ) ) ) {
|
585 |
+
$on_sale = $product->is_on_sale();
|
586 |
+
}
|
587 |
+
|
588 |
+
if ( $show_image === 'true' ) {
|
589 |
+
|
590 |
+
$image_id = $product->get_image_id();
|
591 |
+
$image_size = 'thumbnail';
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Filter products images size
|
595 |
+
* @since 2.06
|
596 |
+
* @param string $image_size Image size
|
597 |
+
*/
|
598 |
+
$image_size = apply_filters( 'aws_image_size', $image_size );
|
599 |
+
|
600 |
+
if ( $image_id ) {
|
601 |
+
$image_attributes = wp_get_attachment_image_src( $image_id, $image_size );
|
602 |
+
$image = $image_attributes ? $image_attributes[0] : '';
|
603 |
+
}
|
604 |
+
|
605 |
+
}
|
606 |
+
|
607 |
+
if ( $show_sku === 'true' ) {
|
608 |
+
$sku = $product->get_sku();
|
609 |
+
}
|
610 |
+
|
611 |
+
if ( $show_featured === 'true' ) {
|
612 |
+
$featured = $product->is_featured();
|
613 |
+
}
|
614 |
+
|
615 |
+
if ( $show_stock_status === 'true' ) {
|
616 |
+
if ( $product->is_in_stock() ) {
|
617 |
+
$stock_status = array(
|
618 |
+
'status' => true,
|
619 |
+
'text' => esc_html__( 'In stock', 'advanced-woo-search' )
|
620 |
+
);
|
621 |
+
} else {
|
622 |
+
$stock_status = array(
|
623 |
+
'status' => false,
|
624 |
+
'text' => esc_html__( 'Out of stock', 'advanced-woo-search' )
|
625 |
+
);
|
626 |
+
}
|
627 |
+
}
|
628 |
+
|
629 |
+
if ( method_exists( $product, 'get_price' ) ) {
|
630 |
+
$f_price = $product->get_price();
|
631 |
+
}
|
632 |
+
|
633 |
+
if ( method_exists( $product, 'get_average_rating' ) ) {
|
634 |
+
$f_rating = $product->get_average_rating();
|
635 |
+
}
|
636 |
+
|
637 |
+
if ( method_exists( $product,'get_review_count' ) ) {
|
638 |
+
$f_reviews = $product->get_review_count();
|
639 |
+
}
|
640 |
+
|
641 |
+
$f_stock = $product->is_in_stock();
|
642 |
+
$f_sale = $product->is_on_sale();
|
643 |
+
|
644 |
+
// $categories = $product->get_categories( ',' );
|
645 |
+
// $tags = $product->get_tags( ',' );
|
646 |
+
|
647 |
+
if ( $highlight_words === 'true' ) {
|
648 |
+
$title = $this->highlight_words( $title );
|
649 |
+
$excerpt = $this->highlight_words( $excerpt );
|
650 |
+
$sku = $this->highlight_words( $sku );
|
651 |
+
}
|
652 |
+
|
653 |
+
$title = apply_filters( 'aws_title_search_result', $title, $post_id, $product );
|
654 |
+
$excerpt = apply_filters( 'aws_excerpt_search_result', $excerpt, $post_id, $product );
|
655 |
+
|
656 |
+
$new_result = array(
|
657 |
+
'id' => $post_id,
|
658 |
+
'parent_id' => $parent_id,
|
659 |
+
'title' => $title,
|
660 |
+
'excerpt' => $excerpt,
|
661 |
+
'link' => get_permalink( $post_id ),
|
662 |
+
'image' => $image,
|
663 |
+
'price' => $price,
|
664 |
+
'on_sale' => $on_sale,
|
665 |
+
'sku' => $sku,
|
666 |
+
'stock_status' => $stock_status,
|
667 |
+
'featured' => $featured,
|
668 |
+
'f_price' => $f_price,
|
669 |
+
'f_rating' => $f_rating,
|
670 |
+
'f_reviews' => $f_reviews,
|
671 |
+
'f_stock' => $f_stock,
|
672 |
+
'f_sale' => $f_sale,
|
673 |
+
'post_data' => $post_data
|
674 |
+
);
|
675 |
+
|
676 |
+
$products_array[] = $new_result;
|
677 |
+
|
678 |
+
wp_reset_postdata();
|
679 |
+
|
680 |
+
}
|
681 |
+
|
682 |
+
}
|
683 |
+
|
684 |
+
/**
|
685 |
+
* Filter products array before output
|
686 |
+
* @since 1.60
|
687 |
+
* @param array $products_array Products array
|
688 |
+
* @param array $this->data Additional data
|
689 |
+
*/
|
690 |
+
$products_array = apply_filters( 'aws_search_pre_filter_products', $products_array, $this->data );
|
691 |
+
|
692 |
+
return $products_array;
|
693 |
+
|
694 |
+
}
|
695 |
+
|
696 |
+
/*
|
697 |
+
* Scrap content excerpt
|
698 |
+
*/
|
699 |
+
private function scrap_content( $content ) {
|
700 |
+
|
701 |
+
$exact_words = array();
|
702 |
+
$words = array();
|
703 |
+
|
704 |
+
foreach( $this->data['search_terms'] as $search_in ) {
|
705 |
+
|
706 |
+
$exact_words[] = '\b' . $search_in . '\b';
|
707 |
+
|
708 |
+
if ( strlen( $search_in ) > 1 ) {
|
709 |
+
$words[] = $search_in;
|
710 |
+
} else {
|
711 |
+
$words[] = '\b' . $search_in . '\b';
|
712 |
+
}
|
713 |
+
|
714 |
+
}
|
715 |
+
|
716 |
+
usort( $exact_words, array( $this, 'sort_by_length' ) );
|
717 |
+
$exact_words = implode( '|', $exact_words );
|
718 |
+
|
719 |
+
usort( $words, array( $this, 'sort_by_length' ) );
|
720 |
+
$words = implode( '|', $words );
|
721 |
+
|
722 |
+
preg_match( '/([^.?!]*?)(' . $exact_words . '){1}(.*?[.!?])/i', $content, $matches );
|
723 |
+
|
724 |
+
if ( ! isset( $matches[0] ) ) {
|
725 |
+
preg_match( '/([^.?!]*?)(' . $words . '){1}(.*?[.!?])/i', $content, $matches );
|
726 |
+
}
|
727 |
+
|
728 |
+
if ( ! isset( $matches[0] ) ) {
|
729 |
+
preg_match( '/([^.?!]*?)(.*?)(.*?[.!?])/i', $content, $matches );
|
730 |
+
}
|
731 |
+
|
732 |
+
if ( isset( $matches[0] ) ) {
|
733 |
+
|
734 |
+
$content = $matches[0];
|
735 |
+
|
736 |
+
// Trim to long content
|
737 |
+
if (str_word_count(strip_tags($content)) > 34) {
|
738 |
+
|
739 |
+
if (str_word_count(strip_tags($matches[3])) > 34) {
|
740 |
+
$matches[3] = wp_trim_words($matches[3], 30, '...');
|
741 |
+
}
|
742 |
+
|
743 |
+
$content = '...' . $matches[2] . $matches[3];
|
744 |
+
|
745 |
+
}
|
746 |
+
|
747 |
+
} else {
|
748 |
+
|
749 |
+
$content = '';
|
750 |
+
|
751 |
+
}
|
752 |
+
|
753 |
+
return $content;
|
754 |
+
|
755 |
+
}
|
756 |
+
|
757 |
+
/*
|
758 |
+
* Highlight search words
|
759 |
+
*/
|
760 |
+
private function highlight_words( $text ) {
|
761 |
+
|
762 |
+
if ( ! $text ) {
|
763 |
+
return $text;
|
764 |
+
}
|
765 |
+
|
766 |
+
$pattern = array();
|
767 |
+
|
768 |
+
foreach( $this->data['search_terms'] as $search_in ) {
|
769 |
+
|
770 |
+
if ( strlen( $search_in ) > 1 ) {
|
771 |
+
$pattern[] = '(' . $search_in . ')+';
|
772 |
+
} else {
|
773 |
+
$pattern[] = '\b[' . $search_in . ']{1}\b';
|
774 |
+
}
|
775 |
+
|
776 |
+
}
|
777 |
+
|
778 |
+
usort( $pattern, array( $this, 'sort_by_length' ) );
|
779 |
+
$pattern = implode( '|', $pattern );
|
780 |
+
$pattern = sprintf( '/%s/i', $pattern );
|
781 |
+
|
782 |
+
/**
|
783 |
+
* Tag to use for highlighting search words inside content
|
784 |
+
* @since 1.88
|
785 |
+
* @param string Tag for highlighting
|
786 |
+
*/
|
787 |
+
$highlight_tag = apply_filters( 'aws_highlight_tag', 'strong' );
|
788 |
+
|
789 |
+
$highlight_tag_pattern = '<' . $highlight_tag . '>${0}</' . $highlight_tag . '>';
|
790 |
+
|
791 |
+
$text = preg_replace($pattern, $highlight_tag_pattern, $text );
|
792 |
+
|
793 |
+
return $text;
|
794 |
+
|
795 |
+
}
|
796 |
+
|
797 |
+
/*
|
798 |
+
* Sort array by its values length
|
799 |
+
*/
|
800 |
+
private function sort_by_length( $a, $b ) {
|
801 |
+
return strlen( $b ) - strlen( $a );
|
802 |
+
}
|
803 |
+
|
804 |
+
}
|
805 |
+
|
806 |
+
|
807 |
+
endif;
|
808 |
+
|
809 |
+
AWS_Search::factory();
|
810 |
+
|
811 |
+
function aws_search( $keyword = '' ) {
|
812 |
+
return AWS_Search::factory()->search( $keyword );
|
813 |
}
|
includes/class-aws-table-data.php
CHANGED
@@ -1,477 +1,477 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Table_Data' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for admin condition rules
|
11 |
-
*/
|
12 |
-
class AWS_Table_Data {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @var object AWS_Table_Data Product object
|
16 |
-
*/
|
17 |
-
private $product;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var int AWS_Table_Data Product id
|
21 |
-
*/
|
22 |
-
private $id;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var array AWS_Table_Data Index options
|
26 |
-
*/
|
27 |
-
private $options;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var string AWS_Table_Data Current language
|
31 |
-
*/
|
32 |
-
private $lang = '';
|
33 |
-
|
34 |
-
/**
|
35 |
-
* @var array AWS_Table_Data Product data
|
36 |
-
*/
|
37 |
-
private $scraped_data = array();
|
38 |
-
|
39 |
-
/*
|
40 |
-
* Constructor
|
41 |
-
*/
|
42 |
-
public function __construct( $product, $id, $options ) {
|
43 |
-
|
44 |
-
$this->product = $product;
|
45 |
-
|
46 |
-
$this->id = $id;
|
47 |
-
|
48 |
-
$this->options = $options;
|
49 |
-
|
50 |
-
$this->lang = $this->get_lang();
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
/*
|
55 |
-
* Scrap data from product
|
56 |
-
*
|
57 |
-
* @return array
|
58 |
-
*/
|
59 |
-
public function scrap_data() {
|
60 |
-
|
61 |
-
$product = $this->product;
|
62 |
-
|
63 |
-
$data = array();
|
64 |
-
|
65 |
-
$data['id'] = $this->id;
|
66 |
-
|
67 |
-
$data['terms'] = array();
|
68 |
-
|
69 |
-
$data['in_stock'] = $this->get_stock_status();
|
70 |
-
$data['on_sale'] = $product->is_on_sale();
|
71 |
-
$data['visibility'] = $this->get_visibility();
|
72 |
-
$data['lang'] = $this->lang ? $this->lang : '';
|
73 |
-
|
74 |
-
$ids = $data['id'];
|
75 |
-
|
76 |
-
$sku = $product->get_sku();
|
77 |
-
$title = get_the_title( $data['id'] );
|
78 |
-
$content = get_post_field( 'post_content', $data['id'] );
|
79 |
-
$excerpt = get_post_field( 'post_excerpt', $data['id'] );
|
80 |
-
|
81 |
-
$cat_array = $this->options['index']['category'] ? AWS_Helpers::get_terms_array( $data['id'], 'product_cat' ) : false;
|
82 |
-
$tag_array = $this->options['index']['tag'] ? AWS_Helpers::get_terms_array( $data['id'], 'product_tag' ) : false;
|
83 |
-
|
84 |
-
if ( $this->options['apply_filters'] ) {
|
85 |
-
$content = apply_filters( 'the_content', $content, $data['id'] );
|
86 |
-
} else {
|
87 |
-
$content = do_shortcode( $content );
|
88 |
-
}
|
89 |
-
|
90 |
-
// Get all child products if exists
|
91 |
-
if ( $product->is_type( 'variable' ) && class_exists( 'WC_Product_Variation' ) && $this->options['index']['variations'] ) {
|
92 |
-
|
93 |
-
if ( sizeof( $product->get_children() ) > 0 ) {
|
94 |
-
|
95 |
-
foreach ( $product->get_children() as $child_id ) {
|
96 |
-
|
97 |
-
$variation_product = new WC_Product_Variation( $child_id );
|
98 |
-
|
99 |
-
if ( method_exists( $variation_product, 'get_status' ) && $variation_product->get_status() === 'private' ) {
|
100 |
-
continue;
|
101 |
-
}
|
102 |
-
|
103 |
-
$variation_sku = $variation_product->get_sku();
|
104 |
-
|
105 |
-
$variation_desc = '';
|
106 |
-
if ( method_exists( $variation_product, 'get_description' ) ) {
|
107 |
-
$variation_desc = $variation_product->get_description();
|
108 |
-
}
|
109 |
-
|
110 |
-
if ( $variation_sku ) {
|
111 |
-
$sku = $sku . ' ' . $variation_sku;
|
112 |
-
}
|
113 |
-
|
114 |
-
$ids = $ids . ' ' . $child_id;
|
115 |
-
|
116 |
-
if ( $variation_desc ) {
|
117 |
-
$content = $content . ' ' . $variation_desc;
|
118 |
-
}
|
119 |
-
|
120 |
-
}
|
121 |
-
|
122 |
-
}
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
// Get content from Custom Product Tabs
|
127 |
-
if ( $custom_tabs = get_post_meta( $data['id'], 'yikes_woo_products_tabs' ) ) {
|
128 |
-
if ( $custom_tabs && ! empty( $custom_tabs ) ) {
|
129 |
-
foreach( $custom_tabs as $custom_tab_array ) {
|
130 |
-
if ( $custom_tab_array && ! empty( $custom_tab_array ) ) {
|
131 |
-
foreach( $custom_tab_array as $custom_tab ) {
|
132 |
-
if ( isset( $custom_tab['content'] ) && $custom_tab['content'] ) {
|
133 |
-
$content = $content . ' ' . $custom_tab['content'];
|
134 |
-
}
|
135 |
-
}
|
136 |
-
}
|
137 |
-
}
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
// WP 4.2 emoji strip
|
142 |
-
if ( function_exists( 'wp_encode_emoji' ) ) {
|
143 |
-
$content = wp_encode_emoji( $content );
|
144 |
-
}
|
145 |
-
|
146 |
-
$content = AWS_Helpers::strip_shortcodes( $content );
|
147 |
-
$excerpt = AWS_Helpers::strip_shortcodes( $excerpt );
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Filters product title before it will be indexed.
|
151 |
-
*
|
152 |
-
* @since 1.37
|
153 |
-
*
|
154 |
-
* @param string $title Product title.
|
155 |
-
* @param int $data['id'] Product id.
|
156 |
-
* @param object $product Current product object.
|
157 |
-
*/
|
158 |
-
$title = apply_filters( 'aws_indexed_title', $title, $data['id'], $product );
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Filters product content before it will be indexed.
|
162 |
-
*
|
163 |
-
* @since 1.37
|
164 |
-
*
|
165 |
-
* @param string $content Product content.
|
166 |
-
* @param int $data['id'] Product id.
|
167 |
-
* @param object $product Current product object.
|
168 |
-
*/
|
169 |
-
$content = apply_filters( 'aws_indexed_content', $content, $data['id'], $product );
|
170 |
-
|
171 |
-
/**
|
172 |
-
* Filters product excerpt before it will be indexed.
|
173 |
-
*
|
174 |
-
* @since 1.37
|
175 |
-
*
|
176 |
-
* @param string $excerpt Product excerpt.
|
177 |
-
* @param int $data['id'] Product id.
|
178 |
-
* @param object $product Current product object.
|
179 |
-
*/
|
180 |
-
$excerpt = apply_filters( 'aws_indexed_excerpt', $excerpt, $data['id'], $product );
|
181 |
-
|
182 |
-
$data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $title, 'title' ) : '';
|
183 |
-
$data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $content, 'content' ) : '';
|
184 |
-
$data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $excerpt, 'excerpt' ) : '';
|
185 |
-
$data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
|
186 |
-
$data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $ids, 'id' ) : '';
|
187 |
-
|
188 |
-
|
189 |
-
if ( $cat_array && ! empty( $cat_array ) ) {
|
190 |
-
foreach( $cat_array as $cat_source => $cat_terms ) {
|
191 |
-
$data['terms'][$cat_source] = $this->extract_terms( $cat_terms, 'cat' );
|
192 |
-
}
|
193 |
-
}
|
194 |
-
|
195 |
-
if ( $tag_array && ! empty( $tag_array ) ) {
|
196 |
-
foreach( $tag_array as $tag_source => $tag_terms ) {
|
197 |
-
$data['terms'][$tag_source] = $this->extract_terms( $tag_terms, 'tag' );
|
198 |
-
}
|
199 |
-
}
|
200 |
-
|
201 |
-
// Get translations if exists ( WPML )
|
202 |
-
if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter('wpml_element_has_translations') && has_filter('wpml_get_element_translations') ) {
|
203 |
-
|
204 |
-
$is_translated = apply_filters( 'wpml_element_has_translations', NULL, $data['id'], 'post_product' );
|
205 |
-
|
206 |
-
if ( $is_translated ) {
|
207 |
-
|
208 |
-
$translations = apply_filters( 'wpml_get_element_translations', NULL, $data['id'], 'post_product');
|
209 |
-
|
210 |
-
foreach( $translations as $language => $lang_obj ) {
|
211 |
-
if ( ! $lang_obj->original && $lang_obj->post_status === 'publish' ) {
|
212 |
-
$translated_post = get_post( $lang_obj->element_id );
|
213 |
-
if ( $translated_post && !empty( $translated_post ) ) {
|
214 |
-
|
215 |
-
$translated_post_data = array();
|
216 |
-
$translated_post_data['id'] = $translated_post->ID;
|
217 |
-
$translated_post_data['in_stock'] = $data['in_stock'];
|
218 |
-
$translated_post_data['on_sale'] = $data['on_sale'];
|
219 |
-
$translated_post_data['visibility'] = $data['visibility'];
|
220 |
-
$translated_post_data['lang'] = $lang_obj->language_code;
|
221 |
-
$translated_post_data['terms'] = array();
|
222 |
-
|
223 |
-
$translated_title = get_the_title( $translated_post->ID );
|
224 |
-
$translated_content = get_post_field( 'post_content', $translated_post->ID );
|
225 |
-
$translated_excerpt = get_post_field( 'post_excerpt', $translated_post->ID );
|
226 |
-
|
227 |
-
if ( $this->options['apply_filters'] ) {
|
228 |
-
$translated_content = apply_filters( 'the_content', $translated_content, $translated_post->ID );
|
229 |
-
}
|
230 |
-
|
231 |
-
$translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
|
232 |
-
$translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
|
233 |
-
|
234 |
-
$translated_post_data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $translated_title, 'title' ) : '';
|
235 |
-
$translated_post_data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $translated_content, 'content' ) : '';
|
236 |
-
$translated_post_data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $translated_excerpt, 'excerpt' ) : '';
|
237 |
-
$translated_post_data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
|
238 |
-
$translated_post_data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $translated_post->ID, 'id' ) : '';
|
239 |
-
|
240 |
-
$this->scraped_data[] = $translated_post_data;
|
241 |
-
|
242 |
-
}
|
243 |
-
}
|
244 |
-
}
|
245 |
-
|
246 |
-
}
|
247 |
-
|
248 |
-
}
|
249 |
-
elseif ( function_exists( 'qtranxf_use' ) ) {
|
250 |
-
|
251 |
-
$enabled_languages = get_option( 'qtranslate_enabled_languages' );
|
252 |
-
|
253 |
-
if ( $enabled_languages ) {
|
254 |
-
|
255 |
-
foreach( $enabled_languages as $current_lang ) {
|
256 |
-
|
257 |
-
if ( $current_lang == $this->lang ) {
|
258 |
-
$default_lang_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
|
259 |
-
$data['terms']['title'] = $this->extract_terms( $default_lang_title, 'title' );
|
260 |
-
continue;
|
261 |
-
}
|
262 |
-
|
263 |
-
if ( function_exists( 'qtranxf_getAvailableLanguages' ) ) {
|
264 |
-
|
265 |
-
global $wpdb;
|
266 |
-
|
267 |
-
$qtrans_content = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $data['id'] ) );
|
268 |
-
|
269 |
-
if ( $qtrans_content ) {
|
270 |
-
|
271 |
-
$languages_title = qtranxf_getAvailableLanguages( $qtrans_content->post_title );
|
272 |
-
$languages_content = qtranxf_getAvailableLanguages( $qtrans_content->post_content );
|
273 |
-
|
274 |
-
if ( ( $languages_title && in_array( $current_lang, $languages_title ) ) || ( $languages_content && in_array( $current_lang, $languages_content ) ) ) {
|
275 |
-
|
276 |
-
if ( method_exists( $product, 'get_description' ) && method_exists( $product, 'get_name' ) && method_exists( $product, 'get_short_description' ) ) {
|
277 |
-
|
278 |
-
$translated_post_data = array();
|
279 |
-
$translated_post_data['id'] = $data['id'];
|
280 |
-
$translated_post_data['in_stock'] = $data['in_stock'];
|
281 |
-
$translated_post_data['on_sale'] = $data['on_sale'];
|
282 |
-
$translated_post_data['visibility'] = $data['visibility'];
|
283 |
-
$translated_post_data['lang'] = $current_lang;
|
284 |
-
$translated_post_data['terms'] = array();
|
285 |
-
|
286 |
-
$translated_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
|
287 |
-
$translated_content = qtranxf_use( $current_lang, $product->get_description(), true, true );
|
288 |
-
$translated_excerpt = qtranxf_use( $current_lang, $product->get_short_description(), true, true );
|
289 |
-
|
290 |
-
$translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
|
291 |
-
$translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
|
292 |
-
|
293 |
-
$translated_post_data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $translated_title, 'title' ) : '';
|
294 |
-
$translated_post_data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $translated_content, 'content' ) : '';
|
295 |
-
$translated_post_data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $translated_excerpt, 'excerpt' ) : '';
|
296 |
-
$translated_post_data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
|
297 |
-
$translated_post_data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $ids, 'id' ) : '';
|
298 |
-
|
299 |
-
$this->scraped_data[] = $translated_post_data;
|
300 |
-
|
301 |
-
}
|
302 |
-
|
303 |
-
}
|
304 |
-
|
305 |
-
}
|
306 |
-
|
307 |
-
}
|
308 |
-
|
309 |
-
}
|
310 |
-
|
311 |
-
}
|
312 |
-
|
313 |
-
}
|
314 |
-
|
315 |
-
$this->scraped_data[] = $data;
|
316 |
-
|
317 |
-
return $this->scraped_data;
|
318 |
-
|
319 |
-
}
|
320 |
-
|
321 |
-
/*
|
322 |
-
* Get current language
|
323 |
-
*
|
324 |
-
* @return string
|
325 |
-
*/
|
326 |
-
private function get_lang() {
|
327 |
-
|
328 |
-
$lang = '';
|
329 |
-
|
330 |
-
if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter( 'wpml_post_language_details' ) ) {
|
331 |
-
$lang = apply_filters( 'wpml_post_language_details', NULL, $this->id );
|
332 |
-
$lang = $lang['language_code'];
|
333 |
-
} elseif ( function_exists( 'pll_default_language' ) && function_exists( 'pll_get_post_language' ) ) {
|
334 |
-
$lang = pll_get_post_language( $this->id ) ? pll_get_post_language( $this->id ) : pll_default_language();
|
335 |
-
} elseif ( function_exists( 'qtranxf_getLanguageDefault' ) ) {
|
336 |
-
$lang = qtranxf_getLanguageDefault();
|
337 |
-
}
|
338 |
-
|
339 |
-
return $lang;
|
340 |
-
|
341 |
-
}
|
342 |
-
|
343 |
-
/*
|
344 |
-
* Extract terms from content
|
345 |
-
*/
|
346 |
-
private function extract_terms( $str, $source = '' ) {
|
347 |
-
|
348 |
-
// Avoid single A-Z.
|
349 |
-
//$str = preg_replace( '/\b\w{1}\b/i', " ", $str );
|
350 |
-
//if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z]$/i', $term ) ) )
|
351 |
-
|
352 |
-
$str = AWS_Helpers::normalize_string( $str );
|
353 |
-
|
354 |
-
$str = str_replace( array(
|
355 |
-
"ˇ",
|
356 |
-
"°",
|
357 |
-
"Ë›",
|
358 |
-
"Ă‹ĹĄ",
|
359 |
-
"¸",
|
360 |
-
"§",
|
361 |
-
"=",
|
362 |
-
"¨",
|
363 |
-
"’",
|
364 |
-
"â€",
|
365 |
-
"”",
|
366 |
-
"“",
|
367 |
-
"„",
|
368 |
-
"´",
|
369 |
-
"—",
|
370 |
-
"–",
|
371 |
-
"Ă—",
|
372 |
-
'’',
|
373 |
-
" ",
|
374 |
-
chr( 194 ) . chr( 160 )
|
375 |
-
), " ", $str );
|
376 |
-
|
377 |
-
$str = str_replace( 'Ăź', 'ss', $str );
|
378 |
-
|
379 |
-
$str = preg_replace( '/^[a-z]$/i', "", $str );
|
380 |
-
|
381 |
-
$str = preg_replace( '/\s+/', ' ', $str );
|
382 |
-
|
383 |
-
/**
|
384 |
-
* Filters extracted string
|
385 |
-
*
|
386 |
-
* @since 1.44
|
387 |
-
*
|
388 |
-
* @param string $str String of product content
|
389 |
-
* @param @since 1.97 string $source Terms source
|
390 |
-
*/
|
391 |
-
$str = apply_filters( 'aws_extracted_string', $str, $source );
|
392 |
-
|
393 |
-
$str_array = explode( ' ', $str );
|
394 |
-
$str_array = AWS_Helpers::filter_stopwords( $str_array );
|
395 |
-
$str_array = array_count_values( $str_array );
|
396 |
-
|
397 |
-
/**
|
398 |
-
* Filters extracted terms before adding to index table
|
399 |
-
*
|
400 |
-
* @since 1.44
|
401 |
-
*
|
402 |
-
* @param string $str_array Array of terms
|
403 |
-
* @param @since 1.97 string $source Terms source
|
404 |
-
*/
|
405 |
-
$str_array = apply_filters( 'aws_extracted_terms', $str_array, $source );
|
406 |
-
|
407 |
-
$str_new_array = array();
|
408 |
-
|
409 |
-
// Remove e, es, ies from the end of the string
|
410 |
-
if ( ! empty( $str_array ) && $str_array ) {
|
411 |
-
foreach( $str_array as $str_item_term => $str_item_num ) {
|
412 |
-
if ( $str_item_term ) {
|
413 |
-
$new_array_key = AWS_Plurals::singularize( $str_item_term );
|
414 |
-
|
415 |
-
if ( $new_array_key && strlen( $str_item_term ) > 3 && strlen( $new_array_key ) > 2 ) {
|
416 |
-
if ( ! isset( $str_new_array[$new_array_key] ) ) {
|
417 |
-
$str_new_array[$new_array_key] = $str_item_num;
|
418 |
-
}
|
419 |
-
} else {
|
420 |
-
if ( ! isset( $str_new_array[$str_item_term] ) ) {
|
421 |
-
$str_new_array[$str_item_term] = $str_item_num;
|
422 |
-
}
|
423 |
-
}
|
424 |
-
|
425 |
-
}
|
426 |
-
}
|
427 |
-
}
|
428 |
-
|
429 |
-
$str_new_array = AWS_Helpers::get_synonyms( $str_new_array );
|
430 |
-
|
431 |
-
return $str_new_array;
|
432 |
-
|
433 |
-
}
|
434 |
-
|
435 |
-
/*
|
436 |
-
* Get product stock status
|
437 |
-
*
|
438 |
-
* @return string
|
439 |
-
*/
|
440 |
-
private function get_stock_status() {
|
441 |
-
|
442 |
-
$stock_status = 1;
|
443 |
-
|
444 |
-
if ( method_exists( $this->product, 'get_stock_status' ) ) {
|
445 |
-
$stock_status = $this->product->get_stock_status() === 'outofstock' ? 0 : 1;
|
446 |
-
} elseif ( method_exists( $this->product, 'is_in_stock' ) ) {
|
447 |
-
$stock_status = $this->product->is_in_stock();
|
448 |
-
}
|
449 |
-
|
450 |
-
return $stock_status;
|
451 |
-
|
452 |
-
}
|
453 |
-
|
454 |
-
/*
|
455 |
-
* Get product visibility
|
456 |
-
*
|
457 |
-
* @return string
|
458 |
-
*/
|
459 |
-
private function get_visibility() {
|
460 |
-
|
461 |
-
$visibility = 'visible';
|
462 |
-
|
463 |
-
if ( method_exists( $this->product, 'get_catalog_visibility' ) ) {
|
464 |
-
$visibility = $this->product->get_catalog_visibility();
|
465 |
-
} elseif ( method_exists( $this->product, 'get_visibility' ) ) {
|
466 |
-
$visibility = $this->product->get_visibility();
|
467 |
-
} else {
|
468 |
-
$visibility = $this->product->visibility;
|
469 |
-
}
|
470 |
-
|
471 |
-
return $visibility;
|
472 |
-
|
473 |
-
}
|
474 |
-
|
475 |
-
}
|
476 |
-
|
477 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Table_Data' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for admin condition rules
|
11 |
+
*/
|
12 |
+
class AWS_Table_Data {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var object AWS_Table_Data Product object
|
16 |
+
*/
|
17 |
+
private $product;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var int AWS_Table_Data Product id
|
21 |
+
*/
|
22 |
+
private $id;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var array AWS_Table_Data Index options
|
26 |
+
*/
|
27 |
+
private $options;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var string AWS_Table_Data Current language
|
31 |
+
*/
|
32 |
+
private $lang = '';
|
33 |
+
|
34 |
+
/**
|
35 |
+
* @var array AWS_Table_Data Product data
|
36 |
+
*/
|
37 |
+
private $scraped_data = array();
|
38 |
+
|
39 |
+
/*
|
40 |
+
* Constructor
|
41 |
+
*/
|
42 |
+
public function __construct( $product, $id, $options ) {
|
43 |
+
|
44 |
+
$this->product = $product;
|
45 |
+
|
46 |
+
$this->id = $id;
|
47 |
+
|
48 |
+
$this->options = $options;
|
49 |
+
|
50 |
+
$this->lang = $this->get_lang();
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/*
|
55 |
+
* Scrap data from product
|
56 |
+
*
|
57 |
+
* @return array
|
58 |
+
*/
|
59 |
+
public function scrap_data() {
|
60 |
+
|
61 |
+
$product = $this->product;
|
62 |
+
|
63 |
+
$data = array();
|
64 |
+
|
65 |
+
$data['id'] = $this->id;
|
66 |
+
|
67 |
+
$data['terms'] = array();
|
68 |
+
|
69 |
+
$data['in_stock'] = $this->get_stock_status();
|
70 |
+
$data['on_sale'] = $product->is_on_sale();
|
71 |
+
$data['visibility'] = $this->get_visibility();
|
72 |
+
$data['lang'] = $this->lang ? $this->lang : '';
|
73 |
+
|
74 |
+
$ids = $data['id'];
|
75 |
+
|
76 |
+
$sku = $product->get_sku();
|
77 |
+
$title = get_the_title( $data['id'] );
|
78 |
+
$content = get_post_field( 'post_content', $data['id'] );
|
79 |
+
$excerpt = get_post_field( 'post_excerpt', $data['id'] );
|
80 |
+
|
81 |
+
$cat_array = $this->options['index']['category'] ? AWS_Helpers::get_terms_array( $data['id'], 'product_cat' ) : false;
|
82 |
+
$tag_array = $this->options['index']['tag'] ? AWS_Helpers::get_terms_array( $data['id'], 'product_tag' ) : false;
|
83 |
+
|
84 |
+
if ( $this->options['apply_filters'] ) {
|
85 |
+
$content = apply_filters( 'the_content', $content, $data['id'] );
|
86 |
+
} else {
|
87 |
+
$content = do_shortcode( $content );
|
88 |
+
}
|
89 |
+
|
90 |
+
// Get all child products if exists
|
91 |
+
if ( $product->is_type( 'variable' ) && class_exists( 'WC_Product_Variation' ) && $this->options['index']['variations'] ) {
|
92 |
+
|
93 |
+
if ( sizeof( $product->get_children() ) > 0 ) {
|
94 |
+
|
95 |
+
foreach ( $product->get_children() as $child_id ) {
|
96 |
+
|
97 |
+
$variation_product = new WC_Product_Variation( $child_id );
|
98 |
+
|
99 |
+
if ( method_exists( $variation_product, 'get_status' ) && $variation_product->get_status() === 'private' ) {
|
100 |
+
continue;
|
101 |
+
}
|
102 |
+
|
103 |
+
$variation_sku = $variation_product->get_sku();
|
104 |
+
|
105 |
+
$variation_desc = '';
|
106 |
+
if ( method_exists( $variation_product, 'get_description' ) ) {
|
107 |
+
$variation_desc = $variation_product->get_description();
|
108 |
+
}
|
109 |
+
|
110 |
+
if ( $variation_sku ) {
|
111 |
+
$sku = $sku . ' ' . $variation_sku;
|
112 |
+
}
|
113 |
+
|
114 |
+
$ids = $ids . ' ' . $child_id;
|
115 |
+
|
116 |
+
if ( $variation_desc ) {
|
117 |
+
$content = $content . ' ' . $variation_desc;
|
118 |
+
}
|
119 |
+
|
120 |
+
}
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
// Get content from Custom Product Tabs
|
127 |
+
if ( $custom_tabs = get_post_meta( $data['id'], 'yikes_woo_products_tabs' ) ) {
|
128 |
+
if ( $custom_tabs && ! empty( $custom_tabs ) ) {
|
129 |
+
foreach( $custom_tabs as $custom_tab_array ) {
|
130 |
+
if ( $custom_tab_array && ! empty( $custom_tab_array ) ) {
|
131 |
+
foreach( $custom_tab_array as $custom_tab ) {
|
132 |
+
if ( isset( $custom_tab['content'] ) && $custom_tab['content'] ) {
|
133 |
+
$content = $content . ' ' . $custom_tab['content'];
|
134 |
+
}
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
// WP 4.2 emoji strip
|
142 |
+
if ( function_exists( 'wp_encode_emoji' ) ) {
|
143 |
+
$content = wp_encode_emoji( $content );
|
144 |
+
}
|
145 |
+
|
146 |
+
$content = AWS_Helpers::strip_shortcodes( $content );
|
147 |
+
$excerpt = AWS_Helpers::strip_shortcodes( $excerpt );
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Filters product title before it will be indexed.
|
151 |
+
*
|
152 |
+
* @since 1.37
|
153 |
+
*
|
154 |
+
* @param string $title Product title.
|
155 |
+
* @param int $data['id'] Product id.
|
156 |
+
* @param object $product Current product object.
|
157 |
+
*/
|
158 |
+
$title = apply_filters( 'aws_indexed_title', $title, $data['id'], $product );
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Filters product content before it will be indexed.
|
162 |
+
*
|
163 |
+
* @since 1.37
|
164 |
+
*
|
165 |
+
* @param string $content Product content.
|
166 |
+
* @param int $data['id'] Product id.
|
167 |
+
* @param object $product Current product object.
|
168 |
+
*/
|
169 |
+
$content = apply_filters( 'aws_indexed_content', $content, $data['id'], $product );
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Filters product excerpt before it will be indexed.
|
173 |
+
*
|
174 |
+
* @since 1.37
|
175 |
+
*
|
176 |
+
* @param string $excerpt Product excerpt.
|
177 |
+
* @param int $data['id'] Product id.
|
178 |
+
* @param object $product Current product object.
|
179 |
+
*/
|
180 |
+
$excerpt = apply_filters( 'aws_indexed_excerpt', $excerpt, $data['id'], $product );
|
181 |
+
|
182 |
+
$data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $title, 'title' ) : '';
|
183 |
+
$data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $content, 'content' ) : '';
|
184 |
+
$data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $excerpt, 'excerpt' ) : '';
|
185 |
+
$data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
|
186 |
+
$data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $ids, 'id' ) : '';
|
187 |
+
|
188 |
+
|
189 |
+
if ( $cat_array && ! empty( $cat_array ) ) {
|
190 |
+
foreach( $cat_array as $cat_source => $cat_terms ) {
|
191 |
+
$data['terms'][$cat_source] = $this->extract_terms( $cat_terms, 'cat' );
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
if ( $tag_array && ! empty( $tag_array ) ) {
|
196 |
+
foreach( $tag_array as $tag_source => $tag_terms ) {
|
197 |
+
$data['terms'][$tag_source] = $this->extract_terms( $tag_terms, 'tag' );
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
// Get translations if exists ( WPML )
|
202 |
+
if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter('wpml_element_has_translations') && has_filter('wpml_get_element_translations') ) {
|
203 |
+
|
204 |
+
$is_translated = apply_filters( 'wpml_element_has_translations', NULL, $data['id'], 'post_product' );
|
205 |
+
|
206 |
+
if ( $is_translated ) {
|
207 |
+
|
208 |
+
$translations = apply_filters( 'wpml_get_element_translations', NULL, $data['id'], 'post_product');
|
209 |
+
|
210 |
+
foreach( $translations as $language => $lang_obj ) {
|
211 |
+
if ( ! $lang_obj->original && $lang_obj->post_status === 'publish' ) {
|
212 |
+
$translated_post = get_post( $lang_obj->element_id );
|
213 |
+
if ( $translated_post && !empty( $translated_post ) ) {
|
214 |
+
|
215 |
+
$translated_post_data = array();
|
216 |
+
$translated_post_data['id'] = $translated_post->ID;
|
217 |
+
$translated_post_data['in_stock'] = $data['in_stock'];
|
218 |
+
$translated_post_data['on_sale'] = $data['on_sale'];
|
219 |
+
$translated_post_data['visibility'] = $data['visibility'];
|
220 |
+
$translated_post_data['lang'] = $lang_obj->language_code;
|
221 |
+
$translated_post_data['terms'] = array();
|
222 |
+
|
223 |
+
$translated_title = get_the_title( $translated_post->ID );
|
224 |
+
$translated_content = get_post_field( 'post_content', $translated_post->ID );
|
225 |
+
$translated_excerpt = get_post_field( 'post_excerpt', $translated_post->ID );
|
226 |
+
|
227 |
+
if ( $this->options['apply_filters'] ) {
|
228 |
+
$translated_content = apply_filters( 'the_content', $translated_content, $translated_post->ID );
|
229 |
+
}
|
230 |
+
|
231 |
+
$translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
|
232 |
+
$translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
|
233 |
+
|
234 |
+
$translated_post_data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $translated_title, 'title' ) : '';
|
235 |
+
$translated_post_data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $translated_content, 'content' ) : '';
|
236 |
+
$translated_post_data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $translated_excerpt, 'excerpt' ) : '';
|
237 |
+
$translated_post_data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
|
238 |
+
$translated_post_data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $translated_post->ID, 'id' ) : '';
|
239 |
+
|
240 |
+
$this->scraped_data[] = $translated_post_data;
|
241 |
+
|
242 |
+
}
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
}
|
247 |
+
|
248 |
+
}
|
249 |
+
elseif ( function_exists( 'qtranxf_use' ) ) {
|
250 |
+
|
251 |
+
$enabled_languages = get_option( 'qtranslate_enabled_languages' );
|
252 |
+
|
253 |
+
if ( $enabled_languages ) {
|
254 |
+
|
255 |
+
foreach( $enabled_languages as $current_lang ) {
|
256 |
+
|
257 |
+
if ( $current_lang == $this->lang ) {
|
258 |
+
$default_lang_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
|
259 |
+
$data['terms']['title'] = $this->extract_terms( $default_lang_title, 'title' );
|
260 |
+
continue;
|
261 |
+
}
|
262 |
+
|
263 |
+
if ( function_exists( 'qtranxf_getAvailableLanguages' ) ) {
|
264 |
+
|
265 |
+
global $wpdb;
|
266 |
+
|
267 |
+
$qtrans_content = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $data['id'] ) );
|
268 |
+
|
269 |
+
if ( $qtrans_content ) {
|
270 |
+
|
271 |
+
$languages_title = qtranxf_getAvailableLanguages( $qtrans_content->post_title );
|
272 |
+
$languages_content = qtranxf_getAvailableLanguages( $qtrans_content->post_content );
|
273 |
+
|
274 |
+
if ( ( $languages_title && in_array( $current_lang, $languages_title ) ) || ( $languages_content && in_array( $current_lang, $languages_content ) ) ) {
|
275 |
+
|
276 |
+
if ( method_exists( $product, 'get_description' ) && method_exists( $product, 'get_name' ) && method_exists( $product, 'get_short_description' ) ) {
|
277 |
+
|
278 |
+
$translated_post_data = array();
|
279 |
+
$translated_post_data['id'] = $data['id'];
|
280 |
+
$translated_post_data['in_stock'] = $data['in_stock'];
|
281 |
+
$translated_post_data['on_sale'] = $data['on_sale'];
|
282 |
+
$translated_post_data['visibility'] = $data['visibility'];
|
283 |
+
$translated_post_data['lang'] = $current_lang;
|
284 |
+
$translated_post_data['terms'] = array();
|
285 |
+
|
286 |
+
$translated_title = qtranxf_use( $current_lang, $product->get_name(), true, true );
|
287 |
+
$translated_content = qtranxf_use( $current_lang, $product->get_description(), true, true );
|
288 |
+
$translated_excerpt = qtranxf_use( $current_lang, $product->get_short_description(), true, true );
|
289 |
+
|
290 |
+
$translated_content = AWS_Helpers::strip_shortcodes( $translated_content );
|
291 |
+
$translated_excerpt = AWS_Helpers::strip_shortcodes( $translated_excerpt );
|
292 |
+
|
293 |
+
$translated_post_data['terms']['title'] = $this->options['index']['title'] ? $this->extract_terms( $translated_title, 'title' ) : '';
|
294 |
+
$translated_post_data['terms']['content'] = $this->options['index']['content'] ? $this->extract_terms( $translated_content, 'content' ) : '';
|
295 |
+
$translated_post_data['terms']['excerpt'] = $this->options['index']['excerpt'] ? $this->extract_terms( $translated_excerpt, 'excerpt' ) : '';
|
296 |
+
$translated_post_data['terms']['sku'] = $this->options['index']['sku'] ? $this->extract_terms( $sku, 'sku' ) : '';
|
297 |
+
$translated_post_data['terms']['id'] = $this->options['index']['id'] ? $this->extract_terms( $ids, 'id' ) : '';
|
298 |
+
|
299 |
+
$this->scraped_data[] = $translated_post_data;
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
}
|
304 |
+
|
305 |
+
}
|
306 |
+
|
307 |
+
}
|
308 |
+
|
309 |
+
}
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
}
|
314 |
+
|
315 |
+
$this->scraped_data[] = $data;
|
316 |
+
|
317 |
+
return $this->scraped_data;
|
318 |
+
|
319 |
+
}
|
320 |
+
|
321 |
+
/*
|
322 |
+
* Get current language
|
323 |
+
*
|
324 |
+
* @return string
|
325 |
+
*/
|
326 |
+
private function get_lang() {
|
327 |
+
|
328 |
+
$lang = '';
|
329 |
+
|
330 |
+
if ( defined( 'ICL_SITEPRESS_VERSION' ) && has_filter( 'wpml_post_language_details' ) ) {
|
331 |
+
$lang = apply_filters( 'wpml_post_language_details', NULL, $this->id );
|
332 |
+
$lang = $lang['language_code'];
|
333 |
+
} elseif ( function_exists( 'pll_default_language' ) && function_exists( 'pll_get_post_language' ) ) {
|
334 |
+
$lang = pll_get_post_language( $this->id ) ? pll_get_post_language( $this->id ) : pll_default_language();
|
335 |
+
} elseif ( function_exists( 'qtranxf_getLanguageDefault' ) ) {
|
336 |
+
$lang = qtranxf_getLanguageDefault();
|
337 |
+
}
|
338 |
+
|
339 |
+
return $lang;
|
340 |
+
|
341 |
+
}
|
342 |
+
|
343 |
+
/*
|
344 |
+
* Extract terms from content
|
345 |
+
*/
|
346 |
+
private function extract_terms( $str, $source = '' ) {
|
347 |
+
|
348 |
+
// Avoid single A-Z.
|
349 |
+
//$str = preg_replace( '/\b\w{1}\b/i', " ", $str );
|
350 |
+
//if ( ! $term || ( 1 === strlen( $term ) && preg_match( '/^[a-z]$/i', $term ) ) )
|
351 |
+
|
352 |
+
$str = AWS_Helpers::normalize_string( $str );
|
353 |
+
|
354 |
+
$str = str_replace( array(
|
355 |
+
"ˇ",
|
356 |
+
"°",
|
357 |
+
"Ë›",
|
358 |
+
"Ă‹ĹĄ",
|
359 |
+
"¸",
|
360 |
+
"§",
|
361 |
+
"=",
|
362 |
+
"¨",
|
363 |
+
"’",
|
364 |
+
"â€",
|
365 |
+
"”",
|
366 |
+
"“",
|
367 |
+
"„",
|
368 |
+
"´",
|
369 |
+
"—",
|
370 |
+
"–",
|
371 |
+
"Ă—",
|
372 |
+
'’',
|
373 |
+
" ",
|
374 |
+
chr( 194 ) . chr( 160 )
|
375 |
+
), " ", $str );
|
376 |
+
|
377 |
+
$str = str_replace( 'Ăź', 'ss', $str );
|
378 |
+
|
379 |
+
$str = preg_replace( '/^[a-z]$/i', "", $str );
|
380 |
+
|
381 |
+
$str = preg_replace( '/\s+/', ' ', $str );
|
382 |
+
|
383 |
+
/**
|
384 |
+
* Filters extracted string
|
385 |
+
*
|
386 |
+
* @since 1.44
|
387 |
+
*
|
388 |
+
* @param string $str String of product content
|
389 |
+
* @param @since 1.97 string $source Terms source
|
390 |
+
*/
|
391 |
+
$str = apply_filters( 'aws_extracted_string', $str, $source );
|
392 |
+
|
393 |
+
$str_array = explode( ' ', $str );
|
394 |
+
$str_array = AWS_Helpers::filter_stopwords( $str_array );
|
395 |
+
$str_array = array_count_values( $str_array );
|
396 |
+
|
397 |
+
/**
|
398 |
+
* Filters extracted terms before adding to index table
|
399 |
+
*
|
400 |
+
* @since 1.44
|
401 |
+
*
|
402 |
+
* @param string $str_array Array of terms
|
403 |
+
* @param @since 1.97 string $source Terms source
|
404 |
+
*/
|
405 |
+
$str_array = apply_filters( 'aws_extracted_terms', $str_array, $source );
|
406 |
+
|
407 |
+
$str_new_array = array();
|
408 |
+
|
409 |
+
// Remove e, es, ies from the end of the string
|
410 |
+
if ( ! empty( $str_array ) && $str_array ) {
|
411 |
+
foreach( $str_array as $str_item_term => $str_item_num ) {
|
412 |
+
if ( $str_item_term ) {
|
413 |
+
$new_array_key = AWS_Plurals::singularize( $str_item_term );
|
414 |
+
|
415 |
+
if ( $new_array_key && strlen( $str_item_term ) > 3 && strlen( $new_array_key ) > 2 ) {
|
416 |
+
if ( ! isset( $str_new_array[$new_array_key] ) ) {
|
417 |
+
$str_new_array[$new_array_key] = $str_item_num;
|
418 |
+
}
|
419 |
+
} else {
|
420 |
+
if ( ! isset( $str_new_array[$str_item_term] ) ) {
|
421 |
+
$str_new_array[$str_item_term] = $str_item_num;
|
422 |
+
}
|
423 |
+
}
|
424 |
+
|
425 |
+
}
|
426 |
+
}
|
427 |
+
}
|
428 |
+
|
429 |
+
$str_new_array = AWS_Helpers::get_synonyms( $str_new_array );
|
430 |
+
|
431 |
+
return $str_new_array;
|
432 |
+
|
433 |
+
}
|
434 |
+
|
435 |
+
/*
|
436 |
+
* Get product stock status
|
437 |
+
*
|
438 |
+
* @return string
|
439 |
+
*/
|
440 |
+
private function get_stock_status() {
|
441 |
+
|
442 |
+
$stock_status = 1;
|
443 |
+
|
444 |
+
if ( method_exists( $this->product, 'get_stock_status' ) ) {
|
445 |
+
$stock_status = $this->product->get_stock_status() === 'outofstock' ? 0 : 1;
|
446 |
+
} elseif ( method_exists( $this->product, 'is_in_stock' ) ) {
|
447 |
+
$stock_status = $this->product->is_in_stock();
|
448 |
+
}
|
449 |
+
|
450 |
+
return $stock_status;
|
451 |
+
|
452 |
+
}
|
453 |
+
|
454 |
+
/*
|
455 |
+
* Get product visibility
|
456 |
+
*
|
457 |
+
* @return string
|
458 |
+
*/
|
459 |
+
private function get_visibility() {
|
460 |
+
|
461 |
+
$visibility = 'visible';
|
462 |
+
|
463 |
+
if ( method_exists( $this->product, 'get_catalog_visibility' ) ) {
|
464 |
+
$visibility = $this->product->get_catalog_visibility();
|
465 |
+
} elseif ( method_exists( $this->product, 'get_visibility' ) ) {
|
466 |
+
$visibility = $this->product->get_visibility();
|
467 |
+
} else {
|
468 |
+
$visibility = $this->product->visibility;
|
469 |
+
}
|
470 |
+
|
471 |
+
return $visibility;
|
472 |
+
|
473 |
+
}
|
474 |
+
|
475 |
+
}
|
476 |
+
|
477 |
endif;
|
includes/class-aws-table.php
CHANGED
@@ -1,620 +1,620 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Table' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for plugin index table
|
11 |
-
*/
|
12 |
-
class AWS_Table {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @var AWS_Table Index table name
|
16 |
-
*/
|
17 |
-
private $table_name;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var AWS_Table Data
|
21 |
-
*/
|
22 |
-
private $data;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Constructor
|
26 |
-
*/
|
27 |
-
public function __construct() {
|
28 |
-
|
29 |
-
global $wpdb;
|
30 |
-
|
31 |
-
$this->table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
32 |
-
|
33 |
-
add_action( 'wp_insert_post', array( $this, 'product_changed' ), 10, 3 );
|
34 |
-
add_action( 'delete_post', array( $this, 'product_deleted' ), 10, 2 );
|
35 |
-
|
36 |
-
add_action( 'create_term', array( &$this, 'term_changed' ), 10, 3 );
|
37 |
-
add_action( 'delete_term', array( &$this, 'term_changed' ), 10, 3 );
|
38 |
-
add_action( 'edit_term', array( &$this, 'term_changed' ), 10, 3 );
|
39 |
-
|
40 |
-
add_action( 'delete_term', array( $this, 'term_deleted' ), 10, 4 );
|
41 |
-
|
42 |
-
if ( defined('WOOCOMMERCE_VERSION') ) {
|
43 |
-
if ( version_compare( WOOCOMMERCE_VERSION, '3.0', ">=" ) ) {
|
44 |
-
add_action( 'woocommerce_variable_product_sync_data', array( $this, 'variable_product_changed' ) );
|
45 |
-
} else {
|
46 |
-
add_action( 'woocommerce_variable_product_sync', array( $this, 'variable_product_changed' ), 10, 2 );
|
47 |
-
}
|
48 |
-
}
|
49 |
-
|
50 |
-
add_action( 'woocommerce_product_set_stock_status', array( $this, 'stock_status_changes' ), 10, 3 );
|
51 |
-
|
52 |
-
add_action( 'updated_postmeta', array( $this, 'updated_custom_tabs' ), 10, 4 );
|
53 |
-
|
54 |
-
add_action( 'wp_ajax_aws-reindex', array( $this, 'reindex_table_ajax' ) );
|
55 |
-
|
56 |
-
add_action( 'aws_reindex_table', array( $this, 'reindex_table_job' ) );
|
57 |
-
|
58 |
-
add_action( 'aws_reindex_product', array( $this, 'reindex_product_action' ) );
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
/*
|
63 |
-
* Reindex plugin table ajax hook
|
64 |
-
*/
|
65 |
-
public function reindex_table_ajax() {
|
66 |
-
|
67 |
-
check_ajax_referer( 'aws_admin_ajax_nonce' );
|
68 |
-
|
69 |
-
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
70 |
-
wp_raise_memory_limit( 'admin' );
|
71 |
-
}
|
72 |
-
|
73 |
-
@set_time_limit( 600 );
|
74 |
-
|
75 |
-
$this->reindex_table();
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
/*
|
80 |
-
* Reindex plugin table
|
81 |
-
*/
|
82 |
-
public function reindex_table( $data = false ) {
|
83 |
-
|
84 |
-
global $wpdb;
|
85 |
-
|
86 |
-
$index_meta = $data ? $data : $_POST['data'];
|
87 |
-
$status = false;
|
88 |
-
|
89 |
-
// If something goes wrong during last index start from latest indexed product
|
90 |
-
if ( 'start' === $index_meta ) {
|
91 |
-
$aws_index_processed = get_transient( 'aws_index_processed' );
|
92 |
-
|
93 |
-
if ( $aws_index_processed ) {
|
94 |
-
$index_meta = $aws_index_processed;
|
95 |
-
}
|
96 |
-
}
|
97 |
-
|
98 |
-
// No current index going on. Let's start over
|
99 |
-
if ( 'start' === $index_meta ) {
|
100 |
-
$status = 'start';
|
101 |
-
$index_meta = array(
|
102 |
-
'offset' => 0,
|
103 |
-
'start' => true,
|
104 |
-
);
|
105 |
-
|
106 |
-
$wpdb->query("DROP TABLE IF EXISTS {$this->table_name}");
|
107 |
-
|
108 |
-
$this->create_table();
|
109 |
-
|
110 |
-
$index_meta['found_posts'] = $this->get_number_of_products();
|
111 |
-
|
112 |
-
} else if ( ! empty( $index_meta['site_stack'] ) && $index_meta['offset'] >= $index_meta['found_posts'] ) {
|
113 |
-
$status = 'start';
|
114 |
-
|
115 |
-
$index_meta['start'] = true;
|
116 |
-
$index_meta['offset'] = 0;
|
117 |
-
$index_meta['current_site'] = array_shift( $index_meta['site_stack'] );
|
118 |
-
} else {
|
119 |
-
$index_meta['start'] = false;
|
120 |
-
}
|
121 |
-
|
122 |
-
$index_meta = apply_filters( 'aws_index_meta', $index_meta );
|
123 |
-
$posts_per_page = apply_filters( 'aws_index_posts_per_page', 20 );
|
124 |
-
|
125 |
-
if ( $status !== 'start' ) {
|
126 |
-
|
127 |
-
$posts = array();
|
128 |
-
|
129 |
-
$queued_posts = get_posts( array(
|
130 |
-
'posts_per_page' => $posts_per_page,
|
131 |
-
'fields' => 'ids',
|
132 |
-
'post_type' => 'product',
|
133 |
-
'post_status' => 'publish',
|
134 |
-
'offset' => $index_meta['offset'],
|
135 |
-
'ignore_sticky_posts' => true,
|
136 |
-
'suppress_filters' => true,
|
137 |
-
'has_password' => false,
|
138 |
-
'no_found_rows' => 1,
|
139 |
-
'orderby' => 'ID',
|
140 |
-
'order' => 'DESC',
|
141 |
-
'lang' => ''
|
142 |
-
) );
|
143 |
-
|
144 |
-
if ( $queued_posts && count( $queued_posts ) ) {
|
145 |
-
foreach( $queued_posts as $post_id ) {
|
146 |
-
$posts[] = absint( $post_id );
|
147 |
-
}
|
148 |
-
}
|
149 |
-
|
150 |
-
if ( $posts && count( $posts ) > 0 ) {
|
151 |
-
|
152 |
-
$this->fill_table( $posts );
|
153 |
-
|
154 |
-
$index_meta['offset'] = absint( $index_meta['offset'] + $posts_per_page );
|
155 |
-
|
156 |
-
if ( $index_meta['offset'] >= $index_meta['found_posts'] ) {
|
157 |
-
$index_meta['offset'] = $index_meta['found_posts'];
|
158 |
-
}
|
159 |
-
|
160 |
-
set_transient( 'aws_index_processed', $index_meta, 60*60 );
|
161 |
-
|
162 |
-
} else {
|
163 |
-
// We are done (with this site)
|
164 |
-
|
165 |
-
$index_meta['offset'] = (int) count( $posts );
|
166 |
-
|
167 |
-
do_action('aws_cache_clear');
|
168 |
-
|
169 |
-
update_option( 'aws_reindex_version', AWS_VERSION );
|
170 |
-
|
171 |
-
delete_transient( 'aws_index_processed' );
|
172 |
-
|
173 |
-
do_action( 'aws_index_complete', $index_meta );
|
174 |
-
|
175 |
-
}
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
if ( $data ) {
|
180 |
-
return $index_meta;
|
181 |
-
} else {
|
182 |
-
wp_send_json_success( $index_meta );
|
183 |
-
}
|
184 |
-
|
185 |
-
}
|
186 |
-
|
187 |
-
/*
|
188 |
-
* Cron job function
|
189 |
-
*/
|
190 |
-
public function reindex_table_job() {
|
191 |
-
|
192 |
-
/*
|
193 |
-
* Added in WordPress v4.6.0
|
194 |
-
*/
|
195 |
-
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
196 |
-
wp_raise_memory_limit( 'admin' );
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Max execution time for script
|
201 |
-
* @since 1.59
|
202 |
-
* @param integer
|
203 |
-
*/
|
204 |
-
@set_time_limit( apply_filters( 'aws_index_cron_runner_time_limit', 600 ) );
|
205 |
-
|
206 |
-
$meta = get_option( 'aws_cron_job' );
|
207 |
-
|
208 |
-
if ( ! $meta || ! is_array( $meta ) ) {
|
209 |
-
$meta = 'start';
|
210 |
-
} else {
|
211 |
-
$meta['attemps'] = (int) isset( $meta['attemps'] ) ? $meta['attemps'] + 1 : 1;
|
212 |
-
}
|
213 |
-
|
214 |
-
/**
|
215 |
-
* Max number of script repeats
|
216 |
-
* @since 1.59
|
217 |
-
* @param integer
|
218 |
-
*/
|
219 |
-
$max_cron_attemps = apply_filters( 'aws_index_max_cron_attemps', 10 );
|
220 |
-
|
221 |
-
try {
|
222 |
-
|
223 |
-
do {
|
224 |
-
|
225 |
-
wp_clear_scheduled_hook( 'aws_reindex_table', array( 'inner' ) );
|
226 |
-
|
227 |
-
// Fallback if re-index failed by timeout in this iteration
|
228 |
-
if ( ! isset( $meta['attemps'] ) || ( isset( $meta['attemps'] ) && $meta['attemps'] < $max_cron_attemps ) ) {
|
229 |
-
if ( ! wp_next_scheduled( 'aws_reindex_table', array( 'inner' ) ) ) {
|
230 |
-
wp_schedule_single_event( time() + 60, 'aws_reindex_table', array( 'inner' ) );
|
231 |
-
}
|
232 |
-
}
|
233 |
-
|
234 |
-
$meta = $this->reindex_table( $meta );
|
235 |
-
$offset = (int) isset( $meta['offset'] ) ? $meta['offset'] : 0;
|
236 |
-
$start = (int) isset( $meta['start'] ) ? $meta['start'] : 0;
|
237 |
-
|
238 |
-
// No more attemps
|
239 |
-
if ( isset( $meta['attemps'] ) && $meta['attemps'] >= $max_cron_attemps ) {
|
240 |
-
delete_option( 'aws_cron_job' );
|
241 |
-
} else {
|
242 |
-
update_option( 'aws_cron_job', $meta );
|
243 |
-
}
|
244 |
-
|
245 |
-
} while ( !( $offset === 0 && ! $start ) );
|
246 |
-
|
247 |
-
} catch ( Exception $e ) {
|
248 |
-
|
249 |
-
}
|
250 |
-
|
251 |
-
// Its no longer needs
|
252 |
-
wp_clear_scheduled_hook( 'aws_reindex_table', array( 'inner' ) );
|
253 |
-
|
254 |
-
delete_option( 'aws_cron_job' );
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
/*
|
259 |
-
* Get total number of products
|
260 |
-
*/
|
261 |
-
private function get_number_of_products() {
|
262 |
-
|
263 |
-
$args = array(
|
264 |
-
'posts_per_page' => -1,
|
265 |
-
'fields' => 'ids',
|
266 |
-
'post_type' => 'product',
|
267 |
-
'post_status' => 'publish',
|
268 |
-
'ignore_sticky_posts' => true,
|
269 |
-
'suppress_filters' => true,
|
270 |
-
'has_password' => false,
|
271 |
-
'no_found_rows' => 1,
|
272 |
-
'orderby' => 'ID',
|
273 |
-
'order' => 'DESC',
|
274 |
-
'lang' => ''
|
275 |
-
);
|
276 |
-
|
277 |
-
|
278 |
-
$posts = get_posts( $args );
|
279 |
-
|
280 |
-
if ( $posts && count( $posts ) > 0 ) {
|
281 |
-
$count = count( $posts );
|
282 |
-
} else {
|
283 |
-
$count = 0;
|
284 |
-
}
|
285 |
-
|
286 |
-
return $count;
|
287 |
-
|
288 |
-
}
|
289 |
-
|
290 |
-
/*
|
291 |
-
* Create index table
|
292 |
-
*/
|
293 |
-
private function create_table() {
|
294 |
-
|
295 |
-
global $wpdb;
|
296 |
-
|
297 |
-
$charset_collate = $wpdb->get_charset_collate();
|
298 |
-
$terms_key = '';
|
299 |
-
|
300 |
-
$search_rule = AWS()->get_settings( 'search_rule' );
|
301 |
-
if ( $search_rule === 'begins' ) {
|
302 |
-
$terms_key = 'KEY term (term),';
|
303 |
-
}
|
304 |
-
|
305 |
-
$sql = "CREATE TABLE {$this->table_name} (
|
306 |
-
id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
|
307 |
-
term VARCHAR(50) NOT NULL DEFAULT 0,
|
308 |
-
term_source VARCHAR(50) NOT NULL DEFAULT 0,
|
309 |
-
type VARCHAR(50) NOT NULL DEFAULT 0,
|
310 |
-
count BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
|
311 |
-
in_stock INT(11) NOT NULL DEFAULT 0,
|
312 |
-
on_sale INT(11) NOT NULL DEFAULT 0,
|
313 |
-
term_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
|
314 |
-
visibility VARCHAR(20) NOT NULL DEFAULT 0,
|
315 |
-
lang VARCHAR(20) NOT NULL DEFAULT 0,
|
316 |
-
KEY id (id),
|
317 |
-
{$terms_key}
|
318 |
-
KEY term_id (term_id),
|
319 |
-
UNIQUE KEY source_term (id,term,term_source,lang)
|
320 |
-
) $charset_collate;";
|
321 |
-
|
322 |
-
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
323 |
-
dbDelta( $sql );
|
324 |
-
|
325 |
-
do_action( 'aws_create_index_table' );
|
326 |
-
|
327 |
-
}
|
328 |
-
|
329 |
-
/*
|
330 |
-
* Insert data into the index table
|
331 |
-
*/
|
332 |
-
private function fill_table( $posts ) {
|
333 |
-
|
334 |
-
/**
|
335 |
-
* Products that will be indexed
|
336 |
-
* @since 1.79
|
337 |
-
* @param array $posts Array of products IDs or product objects
|
338 |
-
*/
|
339 |
-
$posts = apply_filters( 'aws_index_product_ids', $posts );
|
340 |
-
|
341 |
-
$options = AWS_Helpers::get_index_options();
|
342 |
-
|
343 |
-
foreach ( $posts as $post_item ) {
|
344 |
-
|
345 |
-
if ( ! is_object( $post_item ) ) {
|
346 |
-
$product = wc_get_product( $post_item );
|
347 |
-
} else {
|
348 |
-
$product = $post_item;
|
349 |
-
}
|
350 |
-
|
351 |
-
if( ! is_a( $product, 'WC_Product' ) ) {
|
352 |
-
continue;
|
353 |
-
}
|
354 |
-
|
355 |
-
$id = method_exists( $product, 'get_id' ) ? $product->get_id() : $post_item;
|
356 |
-
|
357 |
-
$table_data = new AWS_Table_Data( $product, $id, $options );
|
358 |
-
|
359 |
-
$scraped_data = $table_data->scrap_data();
|
360 |
-
|
361 |
-
if ( ! empty( $scraped_data ) ) {
|
362 |
-
foreach ( $scraped_data as $product_data ) {
|
363 |
-
|
364 |
-
//Insert data into table
|
365 |
-
$this->insert_into_table( $product_data );
|
366 |
-
|
367 |
-
}
|
368 |
-
}
|
369 |
-
|
370 |
-
}
|
371 |
-
|
372 |
-
}
|
373 |
-
|
374 |
-
/*
|
375 |
-
* Scrap all product data and insert to table
|
376 |
-
*/
|
377 |
-
private function insert_into_table( $data ) {
|
378 |
-
|
379 |
-
global $wpdb;
|
380 |
-
|
381 |
-
/**
|
382 |
-
* Filters product data array before it will be added to index table.
|
383 |
-
*
|
384 |
-
* @since 1.62
|
385 |
-
*
|
386 |
-
* @param array $data Product data array.
|
387 |
-
* @param int $data['id'] Product id.
|
388 |
-
* @param null ( since 1.82 )
|
389 |
-
*/
|
390 |
-
$data = apply_filters( 'aws_indexed_data', $data, $data['id'], null );
|
391 |
-
|
392 |
-
$values = array();
|
393 |
-
|
394 |
-
if ( $data && is_array( $data ) && isset( $data['terms'] ) ) {
|
395 |
-
|
396 |
-
foreach( $data['terms'] as $source => $all_terms ) {
|
397 |
-
|
398 |
-
$term_id = 0;
|
399 |
-
|
400 |
-
if ( preg_match( '/\%(\d+)\%/', $source, $matches ) ) {
|
401 |
-
if ( isset( $matches[1] ) ) {
|
402 |
-
$term_id = $matches[1];
|
403 |
-
$source = preg_replace( '/\%(\d+)\%/', '', $source );
|
404 |
-
}
|
405 |
-
}
|
406 |
-
|
407 |
-
if ( is_array( $all_terms ) && ! empty( $all_terms ) ) {
|
408 |
-
foreach ( $all_terms as $term => $count ) {
|
409 |
-
|
410 |
-
if ( ! $term ) {
|
411 |
-
continue;
|
412 |
-
}
|
413 |
-
|
414 |
-
$value = $wpdb->prepare(
|
415 |
-
"(%d, %s, %s, %s, %d, %d, %d, %d, %s, %s)",
|
416 |
-
$data['id'], $term, $source, 'product', $count, $data['in_stock'], $data['on_sale'], $term_id, $data['visibility'], $data['lang']
|
417 |
-
);
|
418 |
-
|
419 |
-
$values[] = $value;
|
420 |
-
|
421 |
-
}
|
422 |
-
}
|
423 |
-
|
424 |
-
}
|
425 |
-
|
426 |
-
}
|
427 |
-
|
428 |
-
if ( count( $values ) > 0 ) {
|
429 |
-
|
430 |
-
$values = implode( ', ', $values );
|
431 |
-
|
432 |
-
$query = "INSERT IGNORE INTO {$this->table_name}
|
433 |
-
(`id`, `term`, `term_source`, `type`, `count`, `in_stock`, `on_sale`, `term_id`, `visibility`, `lang`)
|
434 |
-
VALUES $values
|
435 |
-
";
|
436 |
-
|
437 |
-
$wpdb->query( $query );
|
438 |
-
|
439 |
-
}
|
440 |
-
|
441 |
-
}
|
442 |
-
|
443 |
-
/*
|
444 |
-
* Fires when products terms are changed
|
445 |
-
*/
|
446 |
-
public function term_changed( $term_id, $tt_id, $taxonomy ) {
|
447 |
-
|
448 |
-
if ( $taxonomy === 'product_cat' || $taxonomy === 'product_tag' ) {
|
449 |
-
do_action( 'aws_cache_clear' );
|
450 |
-
}
|
451 |
-
|
452 |
-
}
|
453 |
-
|
454 |
-
/*
|
455 |
-
* Fires when product term is deleted
|
456 |
-
*/
|
457 |
-
public function term_deleted( $term_id, $tt_id, $taxonomy, $deleted_term ) {
|
458 |
-
|
459 |
-
$source_name = AWS_Helpers::get_source_name( $taxonomy );
|
460 |
-
|
461 |
-
if ( $source_name ) {
|
462 |
-
|
463 |
-
if ( AWS_Helpers::is_index_table_has_terms() == 'has_terms' ) {
|
464 |
-
|
465 |
-
global $wpdb;
|
466 |
-
|
467 |
-
$sql = "DELETE FROM {$this->table_name}
|
468 |
-
WHERE term_source = '{$source_name}'
|
469 |
-
AND term_id = {$term_id}";
|
470 |
-
|
471 |
-
$wpdb->query( $sql );
|
472 |
-
|
473 |
-
do_action( 'aws_cache_clear' );
|
474 |
-
|
475 |
-
}
|
476 |
-
|
477 |
-
}
|
478 |
-
|
479 |
-
}
|
480 |
-
|
481 |
-
/*
|
482 |
-
* Update index table
|
483 |
-
*/
|
484 |
-
public function product_changed( $post_id, $post, $update ) {
|
485 |
-
|
486 |
-
$slug = 'product';
|
487 |
-
|
488 |
-
if ( $slug != $post->post_type ) {
|
489 |
-
return;
|
490 |
-
}
|
491 |
-
|
492 |
-
if ( wp_is_post_revision( $post_id ) ) {
|
493 |
-
return;
|
494 |
-
}
|
495 |
-
|
496 |
-
$this->update_table( $post_id );
|
497 |
-
|
498 |
-
}
|
499 |
-
|
500 |
-
/*
|
501 |
-
* Product removed hook
|
502 |
-
*/
|
503 |
-
public function product_deleted( $post_id, $post = false ) {
|
504 |
-
|
505 |
-
$slug = 'product';
|
506 |
-
|
507 |
-
if ( $post && $slug != $post->post_type ) {
|
508 |
-
return;
|
509 |
-
}
|
510 |
-
|
511 |
-
if ( ! $post ) {
|
512 |
-
$post_type = get_post_type( $post_id );
|
513 |
-
if ( $post_type && $slug != $post_type ) {
|
514 |
-
return;
|
515 |
-
}
|
516 |
-
}
|
517 |
-
|
518 |
-
$this->update_table( $post_id );
|
519 |
-
|
520 |
-
}
|
521 |
-
|
522 |
-
/*
|
523 |
-
* Fires when products variations are changed
|
524 |
-
*/
|
525 |
-
public function variable_product_changed( $product, $children = null ) {
|
526 |
-
|
527 |
-
$product_id = '';
|
528 |
-
|
529 |
-
if ( is_object( $product ) ) {
|
530 |
-
$product_id = $product->get_id();
|
531 |
-
} else {
|
532 |
-
$product_id = $product;
|
533 |
-
}
|
534 |
-
|
535 |
-
$this->update_table( $product_id );
|
536 |
-
|
537 |
-
}
|
538 |
-
|
539 |
-
/*
|
540 |
-
* Product stock status changed
|
541 |
-
*/
|
542 |
-
public function stock_status_changes( $product_id, $stock_status, $product ) {
|
543 |
-
global $wp_current_filter, $wpdb;
|
544 |
-
if ( ! in_array( 'save_post', $wp_current_filter ) || in_array( 'woocommerce_process_shop_order_meta', $wp_current_filter ) ) {
|
545 |
-
$sync = AWS()->get_settings( 'autoupdates' );
|
546 |
-
if ( AWS_Helpers::is_table_not_exist() ) {
|
547 |
-
$this->create_table();
|
548 |
-
}
|
549 |
-
if ( $sync !== 'false' ) {
|
550 |
-
$in_stock = $stock_status === 'instock' ? 1 : 0;
|
551 |
-
$wpdb->update( $this->table_name, array( 'in_stock' => $in_stock ), array( 'id' => $product_id ) );
|
552 |
-
do_action('aws_cache_clear');
|
553 |
-
}
|
554 |
-
}
|
555 |
-
}
|
556 |
-
|
557 |
-
/*
|
558 |
-
* Custom Tabs was updated
|
559 |
-
*/
|
560 |
-
public function updated_custom_tabs( $meta_id, $object_id, $meta_key, $meta_value ) {
|
561 |
-
|
562 |
-
if ( $meta_key === 'yikes_woo_products_tabs' && apply_filters( 'aws_filter_yikes_woo_products_tabs_sync', true ) ) {
|
563 |
-
|
564 |
-
$this->update_table( $object_id );
|
565 |
-
|
566 |
-
}
|
567 |
-
|
568 |
-
}
|
569 |
-
|
570 |
-
/*
|
571 |
-
* Re-index single product action
|
572 |
-
*/
|
573 |
-
public function reindex_product_action( $product_id ) {
|
574 |
-
$this->update_table( $product_id );
|
575 |
-
}
|
576 |
-
|
577 |
-
/*
|
578 |
-
* Update index table
|
579 |
-
*/
|
580 |
-
private function update_table( $product_id ) {
|
581 |
-
|
582 |
-
global $wpdb;
|
583 |
-
|
584 |
-
$sunc = AWS()->get_settings( 'autoupdates' );
|
585 |
-
|
586 |
-
if ( AWS_Helpers::is_table_not_exist() ) {
|
587 |
-
$this->create_table();
|
588 |
-
}
|
589 |
-
|
590 |
-
if ( $sunc === 'false' ) {
|
591 |
-
return;
|
592 |
-
}
|
593 |
-
|
594 |
-
$wpdb->delete( $this->table_name, array( 'id' => $product_id ) );
|
595 |
-
|
596 |
-
$posts = get_posts( array(
|
597 |
-
'posts_per_page' => -1,
|
598 |
-
'fields' => 'ids',
|
599 |
-
'post_type' => 'product',
|
600 |
-
'post_status' => 'publish',
|
601 |
-
'has_password' => false,
|
602 |
-
'no_found_rows' => 1,
|
603 |
-
'include' => $product_id,
|
604 |
-
'lang' => ''
|
605 |
-
) );
|
606 |
-
|
607 |
-
if ( $posts ) {
|
608 |
-
$this->fill_table( $posts );
|
609 |
-
}
|
610 |
-
|
611 |
-
do_action('aws_cache_clear');
|
612 |
-
|
613 |
-
}
|
614 |
-
|
615 |
-
}
|
616 |
-
|
617 |
-
endif;
|
618 |
-
|
619 |
-
|
620 |
new AWS_Table();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Table' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for plugin index table
|
11 |
+
*/
|
12 |
+
class AWS_Table {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var AWS_Table Index table name
|
16 |
+
*/
|
17 |
+
private $table_name;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var AWS_Table Data
|
21 |
+
*/
|
22 |
+
private $data;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Constructor
|
26 |
+
*/
|
27 |
+
public function __construct() {
|
28 |
+
|
29 |
+
global $wpdb;
|
30 |
+
|
31 |
+
$this->table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
32 |
+
|
33 |
+
add_action( 'wp_insert_post', array( $this, 'product_changed' ), 10, 3 );
|
34 |
+
add_action( 'delete_post', array( $this, 'product_deleted' ), 10, 2 );
|
35 |
+
|
36 |
+
add_action( 'create_term', array( &$this, 'term_changed' ), 10, 3 );
|
37 |
+
add_action( 'delete_term', array( &$this, 'term_changed' ), 10, 3 );
|
38 |
+
add_action( 'edit_term', array( &$this, 'term_changed' ), 10, 3 );
|
39 |
+
|
40 |
+
add_action( 'delete_term', array( $this, 'term_deleted' ), 10, 4 );
|
41 |
+
|
42 |
+
if ( defined('WOOCOMMERCE_VERSION') ) {
|
43 |
+
if ( version_compare( WOOCOMMERCE_VERSION, '3.0', ">=" ) ) {
|
44 |
+
add_action( 'woocommerce_variable_product_sync_data', array( $this, 'variable_product_changed' ) );
|
45 |
+
} else {
|
46 |
+
add_action( 'woocommerce_variable_product_sync', array( $this, 'variable_product_changed' ), 10, 2 );
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
add_action( 'woocommerce_product_set_stock_status', array( $this, 'stock_status_changes' ), 10, 3 );
|
51 |
+
|
52 |
+
add_action( 'updated_postmeta', array( $this, 'updated_custom_tabs' ), 10, 4 );
|
53 |
+
|
54 |
+
add_action( 'wp_ajax_aws-reindex', array( $this, 'reindex_table_ajax' ) );
|
55 |
+
|
56 |
+
add_action( 'aws_reindex_table', array( $this, 'reindex_table_job' ) );
|
57 |
+
|
58 |
+
add_action( 'aws_reindex_product', array( $this, 'reindex_product_action' ) );
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
/*
|
63 |
+
* Reindex plugin table ajax hook
|
64 |
+
*/
|
65 |
+
public function reindex_table_ajax() {
|
66 |
+
|
67 |
+
check_ajax_referer( 'aws_admin_ajax_nonce' );
|
68 |
+
|
69 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
70 |
+
wp_raise_memory_limit( 'admin' );
|
71 |
+
}
|
72 |
+
|
73 |
+
@set_time_limit( 600 );
|
74 |
+
|
75 |
+
$this->reindex_table();
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
/*
|
80 |
+
* Reindex plugin table
|
81 |
+
*/
|
82 |
+
public function reindex_table( $data = false ) {
|
83 |
+
|
84 |
+
global $wpdb;
|
85 |
+
|
86 |
+
$index_meta = $data ? $data : $_POST['data'];
|
87 |
+
$status = false;
|
88 |
+
|
89 |
+
// If something goes wrong during last index start from latest indexed product
|
90 |
+
if ( 'start' === $index_meta ) {
|
91 |
+
$aws_index_processed = get_transient( 'aws_index_processed' );
|
92 |
+
|
93 |
+
if ( $aws_index_processed ) {
|
94 |
+
$index_meta = $aws_index_processed;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
// No current index going on. Let's start over
|
99 |
+
if ( 'start' === $index_meta ) {
|
100 |
+
$status = 'start';
|
101 |
+
$index_meta = array(
|
102 |
+
'offset' => 0,
|
103 |
+
'start' => true,
|
104 |
+
);
|
105 |
+
|
106 |
+
$wpdb->query("DROP TABLE IF EXISTS {$this->table_name}");
|
107 |
+
|
108 |
+
$this->create_table();
|
109 |
+
|
110 |
+
$index_meta['found_posts'] = $this->get_number_of_products();
|
111 |
+
|
112 |
+
} else if ( ! empty( $index_meta['site_stack'] ) && $index_meta['offset'] >= $index_meta['found_posts'] ) {
|
113 |
+
$status = 'start';
|
114 |
+
|
115 |
+
$index_meta['start'] = true;
|
116 |
+
$index_meta['offset'] = 0;
|
117 |
+
$index_meta['current_site'] = array_shift( $index_meta['site_stack'] );
|
118 |
+
} else {
|
119 |
+
$index_meta['start'] = false;
|
120 |
+
}
|
121 |
+
|
122 |
+
$index_meta = apply_filters( 'aws_index_meta', $index_meta );
|
123 |
+
$posts_per_page = apply_filters( 'aws_index_posts_per_page', 20 );
|
124 |
+
|
125 |
+
if ( $status !== 'start' ) {
|
126 |
+
|
127 |
+
$posts = array();
|
128 |
+
|
129 |
+
$queued_posts = get_posts( array(
|
130 |
+
'posts_per_page' => $posts_per_page,
|
131 |
+
'fields' => 'ids',
|
132 |
+
'post_type' => 'product',
|
133 |
+
'post_status' => 'publish',
|
134 |
+
'offset' => $index_meta['offset'],
|
135 |
+
'ignore_sticky_posts' => true,
|
136 |
+
'suppress_filters' => true,
|
137 |
+
'has_password' => false,
|
138 |
+
'no_found_rows' => 1,
|
139 |
+
'orderby' => 'ID',
|
140 |
+
'order' => 'DESC',
|
141 |
+
'lang' => ''
|
142 |
+
) );
|
143 |
+
|
144 |
+
if ( $queued_posts && count( $queued_posts ) ) {
|
145 |
+
foreach( $queued_posts as $post_id ) {
|
146 |
+
$posts[] = absint( $post_id );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( $posts && count( $posts ) > 0 ) {
|
151 |
+
|
152 |
+
$this->fill_table( $posts );
|
153 |
+
|
154 |
+
$index_meta['offset'] = absint( $index_meta['offset'] + $posts_per_page );
|
155 |
+
|
156 |
+
if ( $index_meta['offset'] >= $index_meta['found_posts'] ) {
|
157 |
+
$index_meta['offset'] = $index_meta['found_posts'];
|
158 |
+
}
|
159 |
+
|
160 |
+
set_transient( 'aws_index_processed', $index_meta, 60*60 );
|
161 |
+
|
162 |
+
} else {
|
163 |
+
// We are done (with this site)
|
164 |
+
|
165 |
+
$index_meta['offset'] = (int) count( $posts );
|
166 |
+
|
167 |
+
do_action('aws_cache_clear');
|
168 |
+
|
169 |
+
update_option( 'aws_reindex_version', AWS_VERSION );
|
170 |
+
|
171 |
+
delete_transient( 'aws_index_processed' );
|
172 |
+
|
173 |
+
do_action( 'aws_index_complete', $index_meta );
|
174 |
+
|
175 |
+
}
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
if ( $data ) {
|
180 |
+
return $index_meta;
|
181 |
+
} else {
|
182 |
+
wp_send_json_success( $index_meta );
|
183 |
+
}
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
/*
|
188 |
+
* Cron job function
|
189 |
+
*/
|
190 |
+
public function reindex_table_job() {
|
191 |
+
|
192 |
+
/*
|
193 |
+
* Added in WordPress v4.6.0
|
194 |
+
*/
|
195 |
+
if ( function_exists( 'wp_raise_memory_limit' ) ) {
|
196 |
+
wp_raise_memory_limit( 'admin' );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Max execution time for script
|
201 |
+
* @since 1.59
|
202 |
+
* @param integer
|
203 |
+
*/
|
204 |
+
@set_time_limit( apply_filters( 'aws_index_cron_runner_time_limit', 600 ) );
|
205 |
+
|
206 |
+
$meta = get_option( 'aws_cron_job' );
|
207 |
+
|
208 |
+
if ( ! $meta || ! is_array( $meta ) ) {
|
209 |
+
$meta = 'start';
|
210 |
+
} else {
|
211 |
+
$meta['attemps'] = (int) isset( $meta['attemps'] ) ? $meta['attemps'] + 1 : 1;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Max number of script repeats
|
216 |
+
* @since 1.59
|
217 |
+
* @param integer
|
218 |
+
*/
|
219 |
+
$max_cron_attemps = apply_filters( 'aws_index_max_cron_attemps', 10 );
|
220 |
+
|
221 |
+
try {
|
222 |
+
|
223 |
+
do {
|
224 |
+
|
225 |
+
wp_clear_scheduled_hook( 'aws_reindex_table', array( 'inner' ) );
|
226 |
+
|
227 |
+
// Fallback if re-index failed by timeout in this iteration
|
228 |
+
if ( ! isset( $meta['attemps'] ) || ( isset( $meta['attemps'] ) && $meta['attemps'] < $max_cron_attemps ) ) {
|
229 |
+
if ( ! wp_next_scheduled( 'aws_reindex_table', array( 'inner' ) ) ) {
|
230 |
+
wp_schedule_single_event( time() + 60, 'aws_reindex_table', array( 'inner' ) );
|
231 |
+
}
|
232 |
+
}
|
233 |
+
|
234 |
+
$meta = $this->reindex_table( $meta );
|
235 |
+
$offset = (int) isset( $meta['offset'] ) ? $meta['offset'] : 0;
|
236 |
+
$start = (int) isset( $meta['start'] ) ? $meta['start'] : 0;
|
237 |
+
|
238 |
+
// No more attemps
|
239 |
+
if ( isset( $meta['attemps'] ) && $meta['attemps'] >= $max_cron_attemps ) {
|
240 |
+
delete_option( 'aws_cron_job' );
|
241 |
+
} else {
|
242 |
+
update_option( 'aws_cron_job', $meta );
|
243 |
+
}
|
244 |
+
|
245 |
+
} while ( !( $offset === 0 && ! $start ) );
|
246 |
+
|
247 |
+
} catch ( Exception $e ) {
|
248 |
+
|
249 |
+
}
|
250 |
+
|
251 |
+
// Its no longer needs
|
252 |
+
wp_clear_scheduled_hook( 'aws_reindex_table', array( 'inner' ) );
|
253 |
+
|
254 |
+
delete_option( 'aws_cron_job' );
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
/*
|
259 |
+
* Get total number of products
|
260 |
+
*/
|
261 |
+
private function get_number_of_products() {
|
262 |
+
|
263 |
+
$args = array(
|
264 |
+
'posts_per_page' => -1,
|
265 |
+
'fields' => 'ids',
|
266 |
+
'post_type' => 'product',
|
267 |
+
'post_status' => 'publish',
|
268 |
+
'ignore_sticky_posts' => true,
|
269 |
+
'suppress_filters' => true,
|
270 |
+
'has_password' => false,
|
271 |
+
'no_found_rows' => 1,
|
272 |
+
'orderby' => 'ID',
|
273 |
+
'order' => 'DESC',
|
274 |
+
'lang' => ''
|
275 |
+
);
|
276 |
+
|
277 |
+
|
278 |
+
$posts = get_posts( $args );
|
279 |
+
|
280 |
+
if ( $posts && count( $posts ) > 0 ) {
|
281 |
+
$count = count( $posts );
|
282 |
+
} else {
|
283 |
+
$count = 0;
|
284 |
+
}
|
285 |
+
|
286 |
+
return $count;
|
287 |
+
|
288 |
+
}
|
289 |
+
|
290 |
+
/*
|
291 |
+
* Create index table
|
292 |
+
*/
|
293 |
+
private function create_table() {
|
294 |
+
|
295 |
+
global $wpdb;
|
296 |
+
|
297 |
+
$charset_collate = $wpdb->get_charset_collate();
|
298 |
+
$terms_key = '';
|
299 |
+
|
300 |
+
$search_rule = AWS()->get_settings( 'search_rule' );
|
301 |
+
if ( $search_rule === 'begins' ) {
|
302 |
+
$terms_key = 'KEY term (term),';
|
303 |
+
}
|
304 |
+
|
305 |
+
$sql = "CREATE TABLE {$this->table_name} (
|
306 |
+
id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
|
307 |
+
term VARCHAR(50) NOT NULL DEFAULT 0,
|
308 |
+
term_source VARCHAR(50) NOT NULL DEFAULT 0,
|
309 |
+
type VARCHAR(50) NOT NULL DEFAULT 0,
|
310 |
+
count BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
|
311 |
+
in_stock INT(11) NOT NULL DEFAULT 0,
|
312 |
+
on_sale INT(11) NOT NULL DEFAULT 0,
|
313 |
+
term_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
|
314 |
+
visibility VARCHAR(20) NOT NULL DEFAULT 0,
|
315 |
+
lang VARCHAR(20) NOT NULL DEFAULT 0,
|
316 |
+
KEY id (id),
|
317 |
+
{$terms_key}
|
318 |
+
KEY term_id (term_id),
|
319 |
+
UNIQUE KEY source_term (id,term,term_source,lang)
|
320 |
+
) $charset_collate;";
|
321 |
+
|
322 |
+
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
|
323 |
+
dbDelta( $sql );
|
324 |
+
|
325 |
+
do_action( 'aws_create_index_table' );
|
326 |
+
|
327 |
+
}
|
328 |
+
|
329 |
+
/*
|
330 |
+
* Insert data into the index table
|
331 |
+
*/
|
332 |
+
private function fill_table( $posts ) {
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Products that will be indexed
|
336 |
+
* @since 1.79
|
337 |
+
* @param array $posts Array of products IDs or product objects
|
338 |
+
*/
|
339 |
+
$posts = apply_filters( 'aws_index_product_ids', $posts );
|
340 |
+
|
341 |
+
$options = AWS_Helpers::get_index_options();
|
342 |
+
|
343 |
+
foreach ( $posts as $post_item ) {
|
344 |
+
|
345 |
+
if ( ! is_object( $post_item ) ) {
|
346 |
+
$product = wc_get_product( $post_item );
|
347 |
+
} else {
|
348 |
+
$product = $post_item;
|
349 |
+
}
|
350 |
+
|
351 |
+
if( ! is_a( $product, 'WC_Product' ) ) {
|
352 |
+
continue;
|
353 |
+
}
|
354 |
+
|
355 |
+
$id = method_exists( $product, 'get_id' ) ? $product->get_id() : $post_item;
|
356 |
+
|
357 |
+
$table_data = new AWS_Table_Data( $product, $id, $options );
|
358 |
+
|
359 |
+
$scraped_data = $table_data->scrap_data();
|
360 |
+
|
361 |
+
if ( ! empty( $scraped_data ) ) {
|
362 |
+
foreach ( $scraped_data as $product_data ) {
|
363 |
+
|
364 |
+
//Insert data into table
|
365 |
+
$this->insert_into_table( $product_data );
|
366 |
+
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
}
|
371 |
+
|
372 |
+
}
|
373 |
+
|
374 |
+
/*
|
375 |
+
* Scrap all product data and insert to table
|
376 |
+
*/
|
377 |
+
private function insert_into_table( $data ) {
|
378 |
+
|
379 |
+
global $wpdb;
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Filters product data array before it will be added to index table.
|
383 |
+
*
|
384 |
+
* @since 1.62
|
385 |
+
*
|
386 |
+
* @param array $data Product data array.
|
387 |
+
* @param int $data['id'] Product id.
|
388 |
+
* @param null ( since 1.82 )
|
389 |
+
*/
|
390 |
+
$data = apply_filters( 'aws_indexed_data', $data, $data['id'], null );
|
391 |
+
|
392 |
+
$values = array();
|
393 |
+
|
394 |
+
if ( $data && is_array( $data ) && isset( $data['terms'] ) ) {
|
395 |
+
|
396 |
+
foreach( $data['terms'] as $source => $all_terms ) {
|
397 |
+
|
398 |
+
$term_id = 0;
|
399 |
+
|
400 |
+
if ( preg_match( '/\%(\d+)\%/', $source, $matches ) ) {
|
401 |
+
if ( isset( $matches[1] ) ) {
|
402 |
+
$term_id = $matches[1];
|
403 |
+
$source = preg_replace( '/\%(\d+)\%/', '', $source );
|
404 |
+
}
|
405 |
+
}
|
406 |
+
|
407 |
+
if ( is_array( $all_terms ) && ! empty( $all_terms ) ) {
|
408 |
+
foreach ( $all_terms as $term => $count ) {
|
409 |
+
|
410 |
+
if ( ! $term ) {
|
411 |
+
continue;
|
412 |
+
}
|
413 |
+
|
414 |
+
$value = $wpdb->prepare(
|
415 |
+
"(%d, %s, %s, %s, %d, %d, %d, %d, %s, %s)",
|
416 |
+
$data['id'], $term, $source, 'product', $count, $data['in_stock'], $data['on_sale'], $term_id, $data['visibility'], $data['lang']
|
417 |
+
);
|
418 |
+
|
419 |
+
$values[] = $value;
|
420 |
+
|
421 |
+
}
|
422 |
+
}
|
423 |
+
|
424 |
+
}
|
425 |
+
|
426 |
+
}
|
427 |
+
|
428 |
+
if ( count( $values ) > 0 ) {
|
429 |
+
|
430 |
+
$values = implode( ', ', $values );
|
431 |
+
|
432 |
+
$query = "INSERT IGNORE INTO {$this->table_name}
|
433 |
+
(`id`, `term`, `term_source`, `type`, `count`, `in_stock`, `on_sale`, `term_id`, `visibility`, `lang`)
|
434 |
+
VALUES $values
|
435 |
+
";
|
436 |
+
|
437 |
+
$wpdb->query( $query );
|
438 |
+
|
439 |
+
}
|
440 |
+
|
441 |
+
}
|
442 |
+
|
443 |
+
/*
|
444 |
+
* Fires when products terms are changed
|
445 |
+
*/
|
446 |
+
public function term_changed( $term_id, $tt_id, $taxonomy ) {
|
447 |
+
|
448 |
+
if ( $taxonomy === 'product_cat' || $taxonomy === 'product_tag' ) {
|
449 |
+
do_action( 'aws_cache_clear' );
|
450 |
+
}
|
451 |
+
|
452 |
+
}
|
453 |
+
|
454 |
+
/*
|
455 |
+
* Fires when product term is deleted
|
456 |
+
*/
|
457 |
+
public function term_deleted( $term_id, $tt_id, $taxonomy, $deleted_term ) {
|
458 |
+
|
459 |
+
$source_name = AWS_Helpers::get_source_name( $taxonomy );
|
460 |
+
|
461 |
+
if ( $source_name ) {
|
462 |
+
|
463 |
+
if ( AWS_Helpers::is_index_table_has_terms() == 'has_terms' ) {
|
464 |
+
|
465 |
+
global $wpdb;
|
466 |
+
|
467 |
+
$sql = "DELETE FROM {$this->table_name}
|
468 |
+
WHERE term_source = '{$source_name}'
|
469 |
+
AND term_id = {$term_id}";
|
470 |
+
|
471 |
+
$wpdb->query( $sql );
|
472 |
+
|
473 |
+
do_action( 'aws_cache_clear' );
|
474 |
+
|
475 |
+
}
|
476 |
+
|
477 |
+
}
|
478 |
+
|
479 |
+
}
|
480 |
+
|
481 |
+
/*
|
482 |
+
* Update index table
|
483 |
+
*/
|
484 |
+
public function product_changed( $post_id, $post, $update ) {
|
485 |
+
|
486 |
+
$slug = 'product';
|
487 |
+
|
488 |
+
if ( $slug != $post->post_type ) {
|
489 |
+
return;
|
490 |
+
}
|
491 |
+
|
492 |
+
if ( wp_is_post_revision( $post_id ) ) {
|
493 |
+
return;
|
494 |
+
}
|
495 |
+
|
496 |
+
$this->update_table( $post_id );
|
497 |
+
|
498 |
+
}
|
499 |
+
|
500 |
+
/*
|
501 |
+
* Product removed hook
|
502 |
+
*/
|
503 |
+
public function product_deleted( $post_id, $post = false ) {
|
504 |
+
|
505 |
+
$slug = 'product';
|
506 |
+
|
507 |
+
if ( $post && $slug != $post->post_type ) {
|
508 |
+
return;
|
509 |
+
}
|
510 |
+
|
511 |
+
if ( ! $post ) {
|
512 |
+
$post_type = get_post_type( $post_id );
|
513 |
+
if ( $post_type && $slug != $post_type ) {
|
514 |
+
return;
|
515 |
+
}
|
516 |
+
}
|
517 |
+
|
518 |
+
$this->update_table( $post_id );
|
519 |
+
|
520 |
+
}
|
521 |
+
|
522 |
+
/*
|
523 |
+
* Fires when products variations are changed
|
524 |
+
*/
|
525 |
+
public function variable_product_changed( $product, $children = null ) {
|
526 |
+
|
527 |
+
$product_id = '';
|
528 |
+
|
529 |
+
if ( is_object( $product ) ) {
|
530 |
+
$product_id = $product->get_id();
|
531 |
+
} else {
|
532 |
+
$product_id = $product;
|
533 |
+
}
|
534 |
+
|
535 |
+
$this->update_table( $product_id );
|
536 |
+
|
537 |
+
}
|
538 |
+
|
539 |
+
/*
|
540 |
+
* Product stock status changed
|
541 |
+
*/
|
542 |
+
public function stock_status_changes( $product_id, $stock_status, $product ) {
|
543 |
+
global $wp_current_filter, $wpdb;
|
544 |
+
if ( ! in_array( 'save_post', $wp_current_filter ) || in_array( 'woocommerce_process_shop_order_meta', $wp_current_filter ) ) {
|
545 |
+
$sync = AWS()->get_settings( 'autoupdates' );
|
546 |
+
if ( AWS_Helpers::is_table_not_exist() ) {
|
547 |
+
$this->create_table();
|
548 |
+
}
|
549 |
+
if ( $sync !== 'false' ) {
|
550 |
+
$in_stock = $stock_status === 'instock' ? 1 : 0;
|
551 |
+
$wpdb->update( $this->table_name, array( 'in_stock' => $in_stock ), array( 'id' => $product_id ) );
|
552 |
+
do_action('aws_cache_clear');
|
553 |
+
}
|
554 |
+
}
|
555 |
+
}
|
556 |
+
|
557 |
+
/*
|
558 |
+
* Custom Tabs was updated
|
559 |
+
*/
|
560 |
+
public function updated_custom_tabs( $meta_id, $object_id, $meta_key, $meta_value ) {
|
561 |
+
|
562 |
+
if ( $meta_key === 'yikes_woo_products_tabs' && apply_filters( 'aws_filter_yikes_woo_products_tabs_sync', true ) ) {
|
563 |
+
|
564 |
+
$this->update_table( $object_id );
|
565 |
+
|
566 |
+
}
|
567 |
+
|
568 |
+
}
|
569 |
+
|
570 |
+
/*
|
571 |
+
* Re-index single product action
|
572 |
+
*/
|
573 |
+
public function reindex_product_action( $product_id ) {
|
574 |
+
$this->update_table( $product_id );
|
575 |
+
}
|
576 |
+
|
577 |
+
/*
|
578 |
+
* Update index table
|
579 |
+
*/
|
580 |
+
private function update_table( $product_id ) {
|
581 |
+
|
582 |
+
global $wpdb;
|
583 |
+
|
584 |
+
$sunc = AWS()->get_settings( 'autoupdates' );
|
585 |
+
|
586 |
+
if ( AWS_Helpers::is_table_not_exist() ) {
|
587 |
+
$this->create_table();
|
588 |
+
}
|
589 |
+
|
590 |
+
if ( $sunc === 'false' ) {
|
591 |
+
return;
|
592 |
+
}
|
593 |
+
|
594 |
+
$wpdb->delete( $this->table_name, array( 'id' => $product_id ) );
|
595 |
+
|
596 |
+
$posts = get_posts( array(
|
597 |
+
'posts_per_page' => -1,
|
598 |
+
'fields' => 'ids',
|
599 |
+
'post_type' => 'product',
|
600 |
+
'post_status' => 'publish',
|
601 |
+
'has_password' => false,
|
602 |
+
'no_found_rows' => 1,
|
603 |
+
'include' => $product_id,
|
604 |
+
'lang' => ''
|
605 |
+
) );
|
606 |
+
|
607 |
+
if ( $posts ) {
|
608 |
+
$this->fill_table( $posts );
|
609 |
+
}
|
610 |
+
|
611 |
+
do_action('aws_cache_clear');
|
612 |
+
|
613 |
+
}
|
614 |
+
|
615 |
+
}
|
616 |
+
|
617 |
+
endif;
|
618 |
+
|
619 |
+
|
620 |
new AWS_Table();
|
includes/class-aws-tax-search.php
CHANGED
@@ -1,415 +1,415 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
-
exit;
|
5 |
-
}
|
6 |
-
|
7 |
-
if ( ! class_exists( 'AWS_Tax_Search' ) ) :
|
8 |
-
|
9 |
-
/**
|
10 |
-
* Class for admin condition rules
|
11 |
-
*/
|
12 |
-
class AWS_Tax_Search {
|
13 |
-
|
14 |
-
/**
|
15 |
-
* @var array AWS_Tax_Search Taxonomy name
|
16 |
-
*/
|
17 |
-
private $taxonomy;
|
18 |
-
|
19 |
-
/**
|
20 |
-
* @var string AWS_Tax_Search Search string
|
21 |
-
*/
|
22 |
-
private $search_string;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* @var string AWS_Tax_Search Unfiltered search string
|
26 |
-
*/
|
27 |
-
private $search_string_unfiltered;
|
28 |
-
|
29 |
-
/**
|
30 |
-
* @var array AWS_Tax_Search Search terms array
|
31 |
-
*/
|
32 |
-
private $search_terms;
|
33 |
-
|
34 |
-
/*
|
35 |
-
* Constructor
|
36 |
-
*/
|
37 |
-
public function __construct( $taxonomy, $data ) {
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Filters array taxonomies search data
|
41 |
-
* @since 1.93
|
42 |
-
* @param array $data Array of search data
|
43 |
-
* @param string $taxonomy Taxonomy name
|
44 |
-
*/
|
45 |
-
$data = apply_filters( 'aws_tax_search_data', $data, $taxonomy );
|
46 |
-
|
47 |
-
$this->taxonomy = $taxonomy;
|
48 |
-
$this->search_string = isset( $data['s'] ) ? $data['s'] : '';
|
49 |
-
$this->search_string_unfiltered = isset( $data['s_nonormalize'] ) ? $data['s_nonormalize'] : $this->search_string ;
|
50 |
-
$this->search_terms = isset( $data['search_terms'] ) ? $data['search_terms'] : array();
|
51 |
-
|
52 |
-
}
|
53 |
-
|
54 |
-
/**
|
55 |
-
* Get search results
|
56 |
-
* @return array Results array
|
57 |
-
*/
|
58 |
-
public function get_results() {
|
59 |
-
|
60 |
-
if ( ! $this->search_terms || empty( $this->search_terms ) ) {
|
61 |
-
return array();
|
62 |
-
}
|
63 |
-
|
64 |
-
global $wpdb;
|
65 |
-
|
66 |
-
$search_query = '';
|
67 |
-
$search_string_unfiltered = '';
|
68 |
-
|
69 |
-
$filtered_terms_full = $wpdb->prepare( '( name LIKE %s )', '%' . $wpdb->esc_like( $this->search_string_unfiltered ) . '%' );
|
70 |
-
|
71 |
-
$search_array = array_map( array( 'AWS_Helpers', 'singularize' ), $this->search_terms );
|
72 |
-
$search_array = $this->synonyms( $search_array );
|
73 |
-
$search_array = $this->get_search_array( $search_array );
|
74 |
-
|
75 |
-
$search_array_chars = $this->get_unfiltered_search_array();
|
76 |
-
|
77 |
-
if ( $search_array_chars ) {
|
78 |
-
$search_string_unfiltered = sprintf( 'OR ( %s )', implode( ' OR ', $this->get_search_array( $search_array_chars ) ) );
|
79 |
-
}
|
80 |
-
|
81 |
-
$search_query .= sprintf( ' AND ( ( %s ) OR %s %s )', implode( ' OR ', $search_array ), $filtered_terms_full, $search_string_unfiltered );
|
82 |
-
|
83 |
-
$search_results = $this->query( $search_query );
|
84 |
-
$result_array = $this->output( $search_results );
|
85 |
-
|
86 |
-
return $result_array;
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Search query
|
92 |
-
* @param string $search_query SQL query
|
93 |
-
* @return array SQL query results
|
94 |
-
*/
|
95 |
-
private function query( $search_query ) {
|
96 |
-
|
97 |
-
global $wpdb;
|
98 |
-
|
99 |
-
$excludes = '';
|
100 |
-
$taxonomies_array = array_map( array( $this, 'prepare_tax_names' ), $this->taxonomy );
|
101 |
-
$taxonomies_names = implode( ',', $taxonomies_array );
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Max number of terms to show
|
105 |
-
* @since 1.73
|
106 |
-
* @param int
|
107 |
-
*/
|
108 |
-
$terms_number = apply_filters( 'aws_search_terms_number', 10 );
|
109 |
-
|
110 |
-
$excludes_array = $this->get_excluded_terms();
|
111 |
-
if ( $excludes_array && ! empty( $excludes_array ) ) {
|
112 |
-
$excludes = sprintf( " AND ( " . $wpdb->terms . ".term_id NOT IN ( %s ) )", implode( ',', array_map( array( $this, 'prepare_tax_names' ), $excludes_array ) ) );
|
113 |
-
}
|
114 |
-
|
115 |
-
$relevance_array = $this->get_relevance_array();
|
116 |
-
|
117 |
-
if ( $relevance_array && ! empty( $relevance_array ) ) {
|
118 |
-
$relevance_query = sprintf( ' (SUM( %s )) ', implode( ' + ', $relevance_array ) );
|
119 |
-
} else {
|
120 |
-
$relevance_query = '0';
|
121 |
-
}
|
122 |
-
|
123 |
-
$lang = isset( $_REQUEST['lang'] ) ? sanitize_text_field( $_REQUEST['lang'] ) : '';
|
124 |
-
if ( $lang ) {
|
125 |
-
$terms = get_terms( array(
|
126 |
-
'taxonomy' => $this->taxonomy,
|
127 |
-
'hide_empty' => true,
|
128 |
-
'fields' => 'ids',
|
129 |
-
'lang' => $lang
|
130 |
-
) );
|
131 |
-
if ( $terms ) {
|
132 |
-
$search_query .= sprintf( " AND ( " . $wpdb->terms . ".term_id IN ( %s ) )", implode( ',', $terms ) );
|
133 |
-
}
|
134 |
-
}
|
135 |
-
|
136 |
-
$sql = "
|
137 |
-
SELECT
|
138 |
-
distinct($wpdb->terms.name),
|
139 |
-
$wpdb->terms.term_id,
|
140 |
-
$wpdb->term_taxonomy.taxonomy,
|
141 |
-
$wpdb->term_taxonomy.count,
|
142 |
-
{$relevance_query} as relevance
|
143 |
-
FROM
|
144 |
-
$wpdb->terms
|
145 |
-
, $wpdb->term_taxonomy
|
146 |
-
WHERE 1 = 1
|
147 |
-
{$search_query}
|
148 |
-
AND $wpdb->term_taxonomy.taxonomy IN ( {$taxonomies_names} )
|
149 |
-
AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id
|
150 |
-
AND count > 0
|
151 |
-
{$excludes}
|
152 |
-
GROUP BY term_id
|
153 |
-
ORDER BY relevance DESC, term_id DESC
|
154 |
-
LIMIT 0, {$terms_number}";
|
155 |
-
|
156 |
-
|
157 |
-
$sql = trim( preg_replace( '/\s+/', ' ', $sql ) );
|
158 |
-
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Filter terms search query
|
162 |
-
* @since 1.91
|
163 |
-
* @param string $sql Sql query
|
164 |
-
* @param string $taxonomy Taxonomy name
|
165 |
-
* @param string $search_query Search query
|
166 |
-
*/
|
167 |
-
$sql = apply_filters( 'aws_terms_search_query', $sql, $this->taxonomy, $search_query );
|
168 |
-
|
169 |
-
$search_results = $wpdb->get_results( $sql );
|
170 |
-
|
171 |
-
return $search_results;
|
172 |
-
|
173 |
-
}
|
174 |
-
|
175 |
-
/**
|
176 |
-
* Order and output search results
|
177 |
-
* @param array SQL query results
|
178 |
-
* @return array Array of taxonomies results
|
179 |
-
*/
|
180 |
-
private function output( $search_results ) {
|
181 |
-
|
182 |
-
$result_array = array();
|
183 |
-
|
184 |
-
if ( ! empty( $search_results ) && !is_wp_error( $search_results ) ) {
|
185 |
-
|
186 |
-
foreach ( $search_results as $result ) {
|
187 |
-
|
188 |
-
$parent = '';
|
189 |
-
|
190 |
-
$term = get_term( $result->term_id, $result->taxonomy );
|
191 |
-
|
192 |
-
if ( $term != null && !is_wp_error( $term ) ) {
|
193 |
-
$term_link = get_term_link( $term );
|
194 |
-
$parent = is_object( $term ) && property_exists( $term, 'parent' ) ? $term->parent : '';
|
195 |
-
} else {
|
196 |
-
continue;
|
197 |
-
}
|
198 |
-
|
199 |
-
$new_result = array(
|
200 |
-
'name' => $result->name,
|
201 |
-
'id' => $result->term_id,
|
202 |
-
'count' => ( $result->count > 0 ) ? $result->count : '',
|
203 |
-
'link' => $term_link,
|
204 |
-
'excerpt' => '',
|
205 |
-
'parent' => $parent
|
206 |
-
);
|
207 |
-
|
208 |
-
$result_array[$result->taxonomy][] = $new_result;
|
209 |
-
|
210 |
-
}
|
211 |
-
|
212 |
-
/**
|
213 |
-
* Filters array of custom taxonomies that must be displayed in search results
|
214 |
-
*
|
215 |
-
* @since 1.63
|
216 |
-
*
|
217 |
-
* @param array $result_array Array of custom taxonomies
|
218 |
-
* @param string $taxonomy Name of taxonomy
|
219 |
-
* @param string $s Search query
|
220 |
-
*/
|
221 |
-
$result_array = apply_filters( 'aws_search_tax_results', $result_array, $this->taxonomy, $this->search_string );
|
222 |
-
|
223 |
-
}
|
224 |
-
|
225 |
-
// Deprecated filters support
|
226 |
-
if ( is_array( $this->taxonomy ) ) {
|
227 |
-
|
228 |
-
if ( in_array( 'product_cat', $this->taxonomy ) ) {
|
229 |
-
$result_array = apply_filters( 'aws_search_results_categories', $result_array, $this->search_string );
|
230 |
-
}
|
231 |
-
|
232 |
-
if ( in_array( 'product_tag', $this->taxonomy ) ) {
|
233 |
-
$result_array = apply_filters( 'aws_search_results_tags', $result_array, $this->search_string );
|
234 |
-
}
|
235 |
-
|
236 |
-
}
|
237 |
-
|
238 |
-
return $result_array;
|
239 |
-
|
240 |
-
}
|
241 |
-
|
242 |
-
/**
|
243 |
-
* Get taxonomies relevance array
|
244 |
-
*
|
245 |
-
* @return array Relevance array
|
246 |
-
*/
|
247 |
-
private function get_relevance_array() {
|
248 |
-
|
249 |
-
global $wpdb;
|
250 |
-
|
251 |
-
$relevance_array = array();
|
252 |
-
|
253 |
-
foreach ( $this->search_terms as $search_term ) {
|
254 |
-
|
255 |
-
$search_term_len = strlen( $search_term );
|
256 |
-
|
257 |
-
$relevance = 40 + 2 * $search_term_len;
|
258 |
-
|
259 |
-
$search_term_norm = AWS_Plurals::singularize( $search_term );
|
260 |
-
|
261 |
-
if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
|
262 |
-
$search_term = $search_term_norm;
|
263 |
-
}
|
264 |
-
|
265 |
-
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
266 |
-
|
267 |
-
$relevance_array[] = $wpdb->prepare( "( case when ( name LIKE %s ) then {$relevance} else 0 end )", $like );
|
268 |
-
|
269 |
-
if ( $terms_desc_search = apply_filters( 'aws_search_terms_description', false ) ) {
|
270 |
-
$relevance_desc = 10 + 2 * $search_term_len;
|
271 |
-
$relevance_array[] = $wpdb->prepare( "( case when ( description LIKE %s ) then {$relevance_desc} else 0 end )", $like );
|
272 |
-
}
|
273 |
-
|
274 |
-
}
|
275 |
-
|
276 |
-
return $relevance_array;
|
277 |
-
|
278 |
-
}
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Get taxonomies search array
|
282 |
-
* @param array Search terms array
|
283 |
-
* @return array Terms
|
284 |
-
*/
|
285 |
-
private function get_search_array( $search_terms ) {
|
286 |
-
|
287 |
-
global $wpdb;
|
288 |
-
|
289 |
-
$search_array = array();
|
290 |
-
|
291 |
-
foreach ( $search_terms as $search_term ) {
|
292 |
-
|
293 |
-
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
294 |
-
|
295 |
-
$search_array[] = $wpdb->prepare('( name LIKE %s )', $like);
|
296 |
-
|
297 |
-
if ( $terms_desc_search = apply_filters( 'aws_search_terms_description', false ) ) {
|
298 |
-
$search_array[] = $wpdb->prepare('( description LIKE %s )', $like);
|
299 |
-
}
|
300 |
-
|
301 |
-
}
|
302 |
-
|
303 |
-
return $search_array;
|
304 |
-
|
305 |
-
}
|
306 |
-
|
307 |
-
/**
|
308 |
-
* Get taxonomies search array with special chars
|
309 |
-
*
|
310 |
-
* @return array Terms
|
311 |
-
*/
|
312 |
-
private function get_unfiltered_search_array() {
|
313 |
-
|
314 |
-
$no_normalized_str = $this->search_string_unfiltered;
|
315 |
-
|
316 |
-
$no_normalized_str = AWS_Helpers::html2txt( $no_normalized_str );
|
317 |
-
$no_normalized_str = trim( $no_normalized_str );
|
318 |
-
|
319 |
-
$no_normalized_str = strtr( $no_normalized_str, AWS_Helpers::get_diacritic_chars() );
|
320 |
-
|
321 |
-
if ( function_exists( 'mb_strtolower' ) ) {
|
322 |
-
$no_normalized_str = mb_strtolower( $no_normalized_str );
|
323 |
-
}
|
324 |
-
|
325 |
-
$search_array_chars = array_unique( explode( ' ', $no_normalized_str ) );
|
326 |
-
$search_array_chars = AWS_Helpers::filter_stopwords( $search_array_chars );
|
327 |
-
|
328 |
-
if ( $search_array_chars ) {
|
329 |
-
foreach ( $search_array_chars as $search_array_chars_index => $search_array_chars_term ) {
|
330 |
-
if ( array_search( $search_array_chars_term, $this->search_terms ) ) {
|
331 |
-
unset( $search_array_chars[$search_array_chars_index] );
|
332 |
-
}
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
if ( count( $search_array_chars ) === 1 && $search_array_chars[0] === $this->search_string_unfiltered ) {
|
337 |
-
$search_array_chars = array();
|
338 |
-
}
|
339 |
-
|
340 |
-
return $search_array_chars;
|
341 |
-
|
342 |
-
}
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Get array of terms that must be excluded
|
346 |
-
* @return array Terms ids
|
347 |
-
*/
|
348 |
-
private function get_excluded_terms() {
|
349 |
-
|
350 |
-
$excludes_array = array();
|
351 |
-
|
352 |
-
/**
|
353 |
-
* Exclude certain taxonomies terms from search
|
354 |
-
* @since 1.92
|
355 |
-
* @param array $excludes_array Array of terms Ids
|
356 |
-
*/
|
357 |
-
$excludes_array = apply_filters( 'aws_search_tax_exclude', $excludes_array, $this->taxonomy, $this->search_string );
|
358 |
-
|
359 |
-
foreach( $this->taxonomy as $taxonomy_name ) {
|
360 |
-
|
361 |
-
/**
|
362 |
-
* Exclude certain terms from search ( deprecated )
|
363 |
-
* @since 1.58
|
364 |
-
* @param array
|
365 |
-
*/
|
366 |
-
$exclude_terms = apply_filters( 'aws_terms_exclude_' . $taxonomy_name, array() );
|
367 |
-
|
368 |
-
if ( $exclude_terms && is_array( $exclude_terms ) && ! empty( $exclude_terms ) ) {
|
369 |
-
$excludes_array = array_merge( $excludes_array, $exclude_terms );
|
370 |
-
}
|
371 |
-
|
372 |
-
}
|
373 |
-
|
374 |
-
return $excludes_array;
|
375 |
-
|
376 |
-
}
|
377 |
-
|
378 |
-
/*
|
379 |
-
* Prepare taxonomy names for query
|
380 |
-
* @param string $name Taxonomy name
|
381 |
-
* @return string Prepared string
|
382 |
-
*/
|
383 |
-
private function prepare_tax_names( $name ) {
|
384 |
-
global $wpdb;
|
385 |
-
return $wpdb->prepare('%s', $name);
|
386 |
-
}
|
387 |
-
|
388 |
-
/*
|
389 |
-
* Add synonyms
|
390 |
-
* @param array $search_terms Search term
|
391 |
-
* @return array Search term with synonyms
|
392 |
-
*/
|
393 |
-
private function synonyms( $search_terms ) {
|
394 |
-
|
395 |
-
if ( $search_terms && ! empty( $search_terms ) ) {
|
396 |
-
|
397 |
-
$new_search_terms = array();
|
398 |
-
|
399 |
-
foreach( $search_terms as $search_term ) {
|
400 |
-
$new_search_terms[$search_term] = 1;
|
401 |
-
}
|
402 |
-
|
403 |
-
$new_search_terms = AWS_Helpers::get_synonyms( $new_search_terms, true );
|
404 |
-
|
405 |
-
return array_keys( $new_search_terms );
|
406 |
-
|
407 |
-
}
|
408 |
-
|
409 |
-
return $search_terms;
|
410 |
-
|
411 |
-
}
|
412 |
-
|
413 |
-
}
|
414 |
-
|
415 |
endif;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
4 |
+
exit;
|
5 |
+
}
|
6 |
+
|
7 |
+
if ( ! class_exists( 'AWS_Tax_Search' ) ) :
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Class for admin condition rules
|
11 |
+
*/
|
12 |
+
class AWS_Tax_Search {
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var array AWS_Tax_Search Taxonomy name
|
16 |
+
*/
|
17 |
+
private $taxonomy;
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @var string AWS_Tax_Search Search string
|
21 |
+
*/
|
22 |
+
private $search_string;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @var string AWS_Tax_Search Unfiltered search string
|
26 |
+
*/
|
27 |
+
private $search_string_unfiltered;
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @var array AWS_Tax_Search Search terms array
|
31 |
+
*/
|
32 |
+
private $search_terms;
|
33 |
+
|
34 |
+
/*
|
35 |
+
* Constructor
|
36 |
+
*/
|
37 |
+
public function __construct( $taxonomy, $data ) {
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Filters array taxonomies search data
|
41 |
+
* @since 1.93
|
42 |
+
* @param array $data Array of search data
|
43 |
+
* @param string $taxonomy Taxonomy name
|
44 |
+
*/
|
45 |
+
$data = apply_filters( 'aws_tax_search_data', $data, $taxonomy );
|
46 |
+
|
47 |
+
$this->taxonomy = $taxonomy;
|
48 |
+
$this->search_string = isset( $data['s'] ) ? $data['s'] : '';
|
49 |
+
$this->search_string_unfiltered = isset( $data['s_nonormalize'] ) ? $data['s_nonormalize'] : $this->search_string ;
|
50 |
+
$this->search_terms = isset( $data['search_terms'] ) ? $data['search_terms'] : array();
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Get search results
|
56 |
+
* @return array Results array
|
57 |
+
*/
|
58 |
+
public function get_results() {
|
59 |
+
|
60 |
+
if ( ! $this->search_terms || empty( $this->search_terms ) ) {
|
61 |
+
return array();
|
62 |
+
}
|
63 |
+
|
64 |
+
global $wpdb;
|
65 |
+
|
66 |
+
$search_query = '';
|
67 |
+
$search_string_unfiltered = '';
|
68 |
+
|
69 |
+
$filtered_terms_full = $wpdb->prepare( '( name LIKE %s )', '%' . $wpdb->esc_like( $this->search_string_unfiltered ) . '%' );
|
70 |
+
|
71 |
+
$search_array = array_map( array( 'AWS_Helpers', 'singularize' ), $this->search_terms );
|
72 |
+
$search_array = $this->synonyms( $search_array );
|
73 |
+
$search_array = $this->get_search_array( $search_array );
|
74 |
+
|
75 |
+
$search_array_chars = $this->get_unfiltered_search_array();
|
76 |
+
|
77 |
+
if ( $search_array_chars ) {
|
78 |
+
$search_string_unfiltered = sprintf( 'OR ( %s )', implode( ' OR ', $this->get_search_array( $search_array_chars ) ) );
|
79 |
+
}
|
80 |
+
|
81 |
+
$search_query .= sprintf( ' AND ( ( %s ) OR %s %s )', implode( ' OR ', $search_array ), $filtered_terms_full, $search_string_unfiltered );
|
82 |
+
|
83 |
+
$search_results = $this->query( $search_query );
|
84 |
+
$result_array = $this->output( $search_results );
|
85 |
+
|
86 |
+
return $result_array;
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Search query
|
92 |
+
* @param string $search_query SQL query
|
93 |
+
* @return array SQL query results
|
94 |
+
*/
|
95 |
+
private function query( $search_query ) {
|
96 |
+
|
97 |
+
global $wpdb;
|
98 |
+
|
99 |
+
$excludes = '';
|
100 |
+
$taxonomies_array = array_map( array( $this, 'prepare_tax_names' ), $this->taxonomy );
|
101 |
+
$taxonomies_names = implode( ',', $taxonomies_array );
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Max number of terms to show
|
105 |
+
* @since 1.73
|
106 |
+
* @param int
|
107 |
+
*/
|
108 |
+
$terms_number = apply_filters( 'aws_search_terms_number', 10 );
|
109 |
+
|
110 |
+
$excludes_array = $this->get_excluded_terms();
|
111 |
+
if ( $excludes_array && ! empty( $excludes_array ) ) {
|
112 |
+
$excludes = sprintf( " AND ( " . $wpdb->terms . ".term_id NOT IN ( %s ) )", implode( ',', array_map( array( $this, 'prepare_tax_names' ), $excludes_array ) ) );
|
113 |
+
}
|
114 |
+
|
115 |
+
$relevance_array = $this->get_relevance_array();
|
116 |
+
|
117 |
+
if ( $relevance_array && ! empty( $relevance_array ) ) {
|
118 |
+
$relevance_query = sprintf( ' (SUM( %s )) ', implode( ' + ', $relevance_array ) );
|
119 |
+
} else {
|
120 |
+
$relevance_query = '0';
|
121 |
+
}
|
122 |
+
|
123 |
+
$lang = isset( $_REQUEST['lang'] ) ? sanitize_text_field( $_REQUEST['lang'] ) : '';
|
124 |
+
if ( $lang ) {
|
125 |
+
$terms = get_terms( array(
|
126 |
+
'taxonomy' => $this->taxonomy,
|
127 |
+
'hide_empty' => true,
|
128 |
+
'fields' => 'ids',
|
129 |
+
'lang' => $lang
|
130 |
+
) );
|
131 |
+
if ( $terms ) {
|
132 |
+
$search_query .= sprintf( " AND ( " . $wpdb->terms . ".term_id IN ( %s ) )", implode( ',', $terms ) );
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
$sql = "
|
137 |
+
SELECT
|
138 |
+
distinct($wpdb->terms.name),
|
139 |
+
$wpdb->terms.term_id,
|
140 |
+
$wpdb->term_taxonomy.taxonomy,
|
141 |
+
$wpdb->term_taxonomy.count,
|
142 |
+
{$relevance_query} as relevance
|
143 |
+
FROM
|
144 |
+
$wpdb->terms
|
145 |
+
, $wpdb->term_taxonomy
|
146 |
+
WHERE 1 = 1
|
147 |
+
{$search_query}
|
148 |
+
AND $wpdb->term_taxonomy.taxonomy IN ( {$taxonomies_names} )
|
149 |
+
AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id
|
150 |
+
AND count > 0
|
151 |
+
{$excludes}
|
152 |
+
GROUP BY term_id
|
153 |
+
ORDER BY relevance DESC, term_id DESC
|
154 |
+
LIMIT 0, {$terms_number}";
|
155 |
+
|
156 |
+
|
157 |
+
$sql = trim( preg_replace( '/\s+/', ' ', $sql ) );
|
158 |
+
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Filter terms search query
|
162 |
+
* @since 1.91
|
163 |
+
* @param string $sql Sql query
|
164 |
+
* @param string $taxonomy Taxonomy name
|
165 |
+
* @param string $search_query Search query
|
166 |
+
*/
|
167 |
+
$sql = apply_filters( 'aws_terms_search_query', $sql, $this->taxonomy, $search_query );
|
168 |
+
|
169 |
+
$search_results = $wpdb->get_results( $sql );
|
170 |
+
|
171 |
+
return $search_results;
|
172 |
+
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Order and output search results
|
177 |
+
* @param array SQL query results
|
178 |
+
* @return array Array of taxonomies results
|
179 |
+
*/
|
180 |
+
private function output( $search_results ) {
|
181 |
+
|
182 |
+
$result_array = array();
|
183 |
+
|
184 |
+
if ( ! empty( $search_results ) && !is_wp_error( $search_results ) ) {
|
185 |
+
|
186 |
+
foreach ( $search_results as $result ) {
|
187 |
+
|
188 |
+
$parent = '';
|
189 |
+
|
190 |
+
$term = get_term( $result->term_id, $result->taxonomy );
|
191 |
+
|
192 |
+
if ( $term != null && !is_wp_error( $term ) ) {
|
193 |
+
$term_link = get_term_link( $term );
|
194 |
+
$parent = is_object( $term ) && property_exists( $term, 'parent' ) ? $term->parent : '';
|
195 |
+
} else {
|
196 |
+
continue;
|
197 |
+
}
|
198 |
+
|
199 |
+
$new_result = array(
|
200 |
+
'name' => $result->name,
|
201 |
+
'id' => $result->term_id,
|
202 |
+
'count' => ( $result->count > 0 ) ? $result->count : '',
|
203 |
+
'link' => $term_link,
|
204 |
+
'excerpt' => '',
|
205 |
+
'parent' => $parent
|
206 |
+
);
|
207 |
+
|
208 |
+
$result_array[$result->taxonomy][] = $new_result;
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Filters array of custom taxonomies that must be displayed in search results
|
214 |
+
*
|
215 |
+
* @since 1.63
|
216 |
+
*
|
217 |
+
* @param array $result_array Array of custom taxonomies
|
218 |
+
* @param string $taxonomy Name of taxonomy
|
219 |
+
* @param string $s Search query
|
220 |
+
*/
|
221 |
+
$result_array = apply_filters( 'aws_search_tax_results', $result_array, $this->taxonomy, $this->search_string );
|
222 |
+
|
223 |
+
}
|
224 |
+
|
225 |
+
// Deprecated filters support
|
226 |
+
if ( is_array( $this->taxonomy ) ) {
|
227 |
+
|
228 |
+
if ( in_array( 'product_cat', $this->taxonomy ) ) {
|
229 |
+
$result_array = apply_filters( 'aws_search_results_categories', $result_array, $this->search_string );
|
230 |
+
}
|
231 |
+
|
232 |
+
if ( in_array( 'product_tag', $this->taxonomy ) ) {
|
233 |
+
$result_array = apply_filters( 'aws_search_results_tags', $result_array, $this->search_string );
|
234 |
+
}
|
235 |
+
|
236 |
+
}
|
237 |
+
|
238 |
+
return $result_array;
|
239 |
+
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Get taxonomies relevance array
|
244 |
+
*
|
245 |
+
* @return array Relevance array
|
246 |
+
*/
|
247 |
+
private function get_relevance_array() {
|
248 |
+
|
249 |
+
global $wpdb;
|
250 |
+
|
251 |
+
$relevance_array = array();
|
252 |
+
|
253 |
+
foreach ( $this->search_terms as $search_term ) {
|
254 |
+
|
255 |
+
$search_term_len = strlen( $search_term );
|
256 |
+
|
257 |
+
$relevance = 40 + 2 * $search_term_len;
|
258 |
+
|
259 |
+
$search_term_norm = AWS_Plurals::singularize( $search_term );
|
260 |
+
|
261 |
+
if ( $search_term_norm && $search_term_len > 3 && strlen( $search_term_norm ) > 2 ) {
|
262 |
+
$search_term = $search_term_norm;
|
263 |
+
}
|
264 |
+
|
265 |
+
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
266 |
+
|
267 |
+
$relevance_array[] = $wpdb->prepare( "( case when ( name LIKE %s ) then {$relevance} else 0 end )", $like );
|
268 |
+
|
269 |
+
if ( $terms_desc_search = apply_filters( 'aws_search_terms_description', false ) ) {
|
270 |
+
$relevance_desc = 10 + 2 * $search_term_len;
|
271 |
+
$relevance_array[] = $wpdb->prepare( "( case when ( description LIKE %s ) then {$relevance_desc} else 0 end )", $like );
|
272 |
+
}
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
return $relevance_array;
|
277 |
+
|
278 |
+
}
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Get taxonomies search array
|
282 |
+
* @param array Search terms array
|
283 |
+
* @return array Terms
|
284 |
+
*/
|
285 |
+
private function get_search_array( $search_terms ) {
|
286 |
+
|
287 |
+
global $wpdb;
|
288 |
+
|
289 |
+
$search_array = array();
|
290 |
+
|
291 |
+
foreach ( $search_terms as $search_term ) {
|
292 |
+
|
293 |
+
$like = '%' . $wpdb->esc_like($search_term) . '%';
|
294 |
+
|
295 |
+
$search_array[] = $wpdb->prepare('( name LIKE %s )', $like);
|
296 |
+
|
297 |
+
if ( $terms_desc_search = apply_filters( 'aws_search_terms_description', false ) ) {
|
298 |
+
$search_array[] = $wpdb->prepare('( description LIKE %s )', $like);
|
299 |
+
}
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
return $search_array;
|
304 |
+
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Get taxonomies search array with special chars
|
309 |
+
*
|
310 |
+
* @return array Terms
|
311 |
+
*/
|
312 |
+
private function get_unfiltered_search_array() {
|
313 |
+
|
314 |
+
$no_normalized_str = $this->search_string_unfiltered;
|
315 |
+
|
316 |
+
$no_normalized_str = AWS_Helpers::html2txt( $no_normalized_str );
|
317 |
+
$no_normalized_str = trim( $no_normalized_str );
|
318 |
+
|
319 |
+
$no_normalized_str = strtr( $no_normalized_str, AWS_Helpers::get_diacritic_chars() );
|
320 |
+
|
321 |
+
if ( function_exists( 'mb_strtolower' ) ) {
|
322 |
+
$no_normalized_str = mb_strtolower( $no_normalized_str );
|
323 |
+
}
|
324 |
+
|
325 |
+
$search_array_chars = array_unique( explode( ' ', $no_normalized_str ) );
|
326 |
+
$search_array_chars = AWS_Helpers::filter_stopwords( $search_array_chars );
|
327 |
+
|
328 |
+
if ( $search_array_chars ) {
|
329 |
+
foreach ( $search_array_chars as $search_array_chars_index => $search_array_chars_term ) {
|
330 |
+
if ( array_search( $search_array_chars_term, $this->search_terms ) ) {
|
331 |
+
unset( $search_array_chars[$search_array_chars_index] );
|
332 |
+
}
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
if ( count( $search_array_chars ) === 1 && $search_array_chars[0] === $this->search_string_unfiltered ) {
|
337 |
+
$search_array_chars = array();
|
338 |
+
}
|
339 |
+
|
340 |
+
return $search_array_chars;
|
341 |
+
|
342 |
+
}
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Get array of terms that must be excluded
|
346 |
+
* @return array Terms ids
|
347 |
+
*/
|
348 |
+
private function get_excluded_terms() {
|
349 |
+
|
350 |
+
$excludes_array = array();
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Exclude certain taxonomies terms from search
|
354 |
+
* @since 1.92
|
355 |
+
* @param array $excludes_array Array of terms Ids
|
356 |
+
*/
|
357 |
+
$excludes_array = apply_filters( 'aws_search_tax_exclude', $excludes_array, $this->taxonomy, $this->search_string );
|
358 |
+
|
359 |
+
foreach( $this->taxonomy as $taxonomy_name ) {
|
360 |
+
|
361 |
+
/**
|
362 |
+
* Exclude certain terms from search ( deprecated )
|
363 |
+
* @since 1.58
|
364 |
+
* @param array
|
365 |
+
*/
|
366 |
+
$exclude_terms = apply_filters( 'aws_terms_exclude_' . $taxonomy_name, array() );
|
367 |
+
|
368 |
+
if ( $exclude_terms && is_array( $exclude_terms ) && ! empty( $exclude_terms ) ) {
|
369 |
+
$excludes_array = array_merge( $excludes_array, $exclude_terms );
|
370 |
+
}
|
371 |
+
|
372 |
+
}
|
373 |
+
|
374 |
+
return $excludes_array;
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
/*
|
379 |
+
* Prepare taxonomy names for query
|
380 |
+
* @param string $name Taxonomy name
|
381 |
+
* @return string Prepared string
|
382 |
+
*/
|
383 |
+
private function prepare_tax_names( $name ) {
|
384 |
+
global $wpdb;
|
385 |
+
return $wpdb->prepare('%s', $name);
|
386 |
+
}
|
387 |
+
|
388 |
+
/*
|
389 |
+
* Add synonyms
|
390 |
+
* @param array $search_terms Search term
|
391 |
+
* @return array Search term with synonyms
|
392 |
+
*/
|
393 |
+
private function synonyms( $search_terms ) {
|
394 |
+
|
395 |
+
if ( $search_terms && ! empty( $search_terms ) ) {
|
396 |
+
|
397 |
+
$new_search_terms = array();
|
398 |
+
|
399 |
+
foreach( $search_terms as $search_term ) {
|
400 |
+
$new_search_terms[$search_term] = 1;
|
401 |
+
}
|
402 |
+
|
403 |
+
$new_search_terms = AWS_Helpers::get_synonyms( $new_search_terms, true );
|
404 |
+
|
405 |
+
return array_keys( $new_search_terms );
|
406 |
+
|
407 |
+
}
|
408 |
+
|
409 |
+
return $search_terms;
|
410 |
+
|
411 |
+
}
|
412 |
+
|
413 |
+
}
|
414 |
+
|
415 |
endif;
|
includes/class-aws-versions.php
CHANGED
@@ -1,416 +1,416 @@
|
|
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 ) && current_user_can( 'manage_options' ) ) {
|
47 |
-
add_action( 'admin_notices', array( $this, 'admin_notice_no_index' ) );
|
48 |
-
}
|
49 |
-
|
50 |
-
if ( $reindex_version && version_compare( $reindex_version, '1.23', '<' ) && current_user_can( 'manage_options' ) ) {
|
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 ( ! isset( $settings['outofstock'] ) ) {
|
62 |
-
$settings['outofstock'] = 'false';
|
63 |
-
update_option( 'aws_settings', $settings );
|
64 |
-
}
|
65 |
-
}
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
if ( version_compare( $current_version, '1.17', '<' ) ) {
|
70 |
-
|
71 |
-
$settings = get_option( 'aws_settings' );
|
72 |
-
|
73 |
-
if ( $settings ) {
|
74 |
-
if ( ! isset( $settings['use_analytics'] ) ) {
|
75 |
-
$settings['use_analytics'] = 'false';
|
76 |
-
update_option( 'aws_settings', $settings );
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
}
|
81 |
-
|
82 |
-
if ( version_compare( $current_version, '1.21', '<' ) ) {
|
83 |
-
|
84 |
-
$settings = get_option( 'aws_settings' );
|
85 |
-
|
86 |
-
if ( $settings ) {
|
87 |
-
if ( ! isset( $settings['show_page'] ) ) {
|
88 |
-
$settings['show_page'] = 'false';
|
89 |
-
update_option( 'aws_settings', $settings );
|
90 |
-
}
|
91 |
-
}
|
92 |
-
|
93 |
-
}
|
94 |
-
|
95 |
-
if ( version_compare( $current_version, '1.23', '<' ) ) {
|
96 |
-
|
97 |
-
$settings = get_option( 'aws_settings' );
|
98 |
-
|
99 |
-
if ( $settings ) {
|
100 |
-
if ( ! isset( $settings['stopwords'] ) ) {
|
101 |
-
$settings['stopwords'] = 'a, also, am, an, and, are, as, at, be, but, by, call, can, co, con, de, do, due, eg, eight, etc, even, ever, every, for, from, full, go, had, has, hasnt, have, he, hence, her, here, his, how, ie, if, in, inc, into, is, it, its, ltd, me, my, no, none, nor, not, now, of, off, on, once, one, only, onto, or, our, ours, out, over, own, part, per, put, re, see, so, some, ten, than, that, the, their, there, these, they, this, three, thru, thus, to, too, top, un, up, us, very, via, was, we, well, were, what, when, where, who, why, will';
|
102 |
-
update_option( 'aws_settings', $settings );
|
103 |
-
}
|
104 |
-
}
|
105 |
-
|
106 |
-
}
|
107 |
-
|
108 |
-
if ( version_compare( $current_version, '1.27', '<' ) ) {
|
109 |
-
|
110 |
-
$settings = get_option( 'aws_settings' );
|
111 |
-
|
112 |
-
if ( $settings ) {
|
113 |
-
if ( ! isset( $settings['show_stock'] ) ) {
|
114 |
-
$settings['show_stock'] = 'false';
|
115 |
-
update_option( 'aws_settings', $settings );
|
116 |
-
}
|
117 |
-
}
|
118 |
-
|
119 |
-
}
|
120 |
-
|
121 |
-
if ( version_compare( $current_version, '1.41', '<' ) ) {
|
122 |
-
|
123 |
-
if ( AWS_Helpers::is_index_table_has_terms() == 'no_terms' ) {
|
124 |
-
|
125 |
-
global $wpdb;
|
126 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
127 |
-
|
128 |
-
$wpdb->query("
|
129 |
-
ALTER TABLE {$table_name}
|
130 |
-
ADD COLUMN `term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0
|
131 |
-
");
|
132 |
-
|
133 |
-
}
|
134 |
-
|
135 |
-
}
|
136 |
-
|
137 |
-
if ( version_compare( $current_version, '1.42', '<' ) ) {
|
138 |
-
|
139 |
-
$settings = get_option( 'aws_settings' );
|
140 |
-
|
141 |
-
if ( $settings ) {
|
142 |
-
if ( ! isset( $settings['show_more'] ) ) {
|
143 |
-
$settings['show_more'] = 'false';
|
144 |
-
update_option( 'aws_settings', $settings );
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
}
|
149 |
-
|
150 |
-
if ( version_compare( $current_version, '1.43', '<' ) ) {
|
151 |
-
|
152 |
-
if ( ! AWS_Helpers::is_table_not_exist() ) {
|
153 |
-
|
154 |
-
global $wpdb;
|
155 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
156 |
-
|
157 |
-
$wpdb->query("
|
158 |
-
ALTER TABLE {$table_name}
|
159 |
-
MODIFY term_source varchar(50);
|
160 |
-
");
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
}
|
165 |
-
|
166 |
-
if ( version_compare( $current_version, '1.47', '<' ) ) {
|
167 |
-
|
168 |
-
$settings = get_option( 'aws_settings' );
|
169 |
-
|
170 |
-
if ( $settings ) {
|
171 |
-
if ( ! isset( $settings['seamless'] ) ) {
|
172 |
-
$settings['seamless'] = 'false';
|
173 |
-
update_option( 'aws_settings', $settings );
|
174 |
-
}
|
175 |
-
}
|
176 |
-
|
177 |
-
}
|
178 |
-
|
179 |
-
if ( version_compare( $current_version, '1.48', '<' ) ) {
|
180 |
-
|
181 |
-
$settings = get_option( 'aws_settings' );
|
182 |
-
|
183 |
-
if ( $settings ) {
|
184 |
-
if ( ! isset( $settings['show_clear'] ) ) {
|
185 |
-
$settings['show_clear'] = 'false';
|
186 |
-
update_option( 'aws_settings', $settings );
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
}
|
191 |
-
|
192 |
-
if ( version_compare( $current_version, '1.49', '<' ) ) {
|
193 |
-
|
194 |
-
$settings = get_option( 'aws_settings' );
|
195 |
-
|
196 |
-
if ( $settings ) {
|
197 |
-
if ( ! isset( $settings['show_more_text'] ) ) {
|
198 |
-
$settings['show_more_text'] = __('View all results', 'advanced-woo-search');
|
199 |
-
update_option( 'aws_settings', $settings );
|
200 |
-
}
|
201 |
-
}
|
202 |
-
|
203 |
-
}
|
204 |
-
|
205 |
-
if ( version_compare( $current_version, '1.53', '<' ) ) {
|
206 |
-
|
207 |
-
$settings = get_option( 'aws_settings' );
|
208 |
-
|
209 |
-
if ( $settings ) {
|
210 |
-
if ( ! isset( $settings['show_featured'] ) ) {
|
211 |
-
$settings['show_featured'] = 'false';
|
212 |
-
update_option( 'aws_settings', $settings );
|
213 |
-
}
|
214 |
-
}
|
215 |
-
|
216 |
-
}
|
217 |
-
|
218 |
-
if ( version_compare( $current_version, '1.54', '<' ) ) {
|
219 |
-
|
220 |
-
if ( AWS_Helpers::is_index_table_has_on_sale() == 'no' ) {
|
221 |
-
|
222 |
-
global $wpdb;
|
223 |
-
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
224 |
-
|
225 |
-
$wpdb->query("
|
226 |
-
ALTER TABLE {$table_name}
|
227 |
-
ADD COLUMN `on_sale` INT(11) NOT NULL DEFAULT 0
|
228 |
-
");
|
229 |
-
|
230 |
-
}
|
231 |
-
|
232 |
-
}
|
233 |
-
|
234 |
-
if ( version_compare( $current_version, '1.56', '<' ) ) {
|
235 |
-
|
236 |
-
$settings = get_option( 'aws_settings' );
|
237 |
-
|
238 |
-
if ( $settings ) {
|
239 |
-
if ( ! isset( $settings['buttons_order'] ) ) {
|
240 |
-
$settings['buttons_order'] = '1';
|
241 |
-
update_option( 'aws_settings', $settings );
|
242 |
-
}
|
243 |
-
}
|
244 |
-
|
245 |
-
}
|
246 |
-
|
247 |
-
if ( version_compare( $current_version, '1.59', '<' ) ) {
|
248 |
-
|
249 |
-
$settings = get_option( 'aws_settings' );
|
250 |
-
|
251 |
-
if ( $settings ) {
|
252 |
-
if ( ! isset( $settings['show_outofstock_price'] ) ) {
|
253 |
-
$settings['show_outofstock_price'] = 'true';
|
254 |
-
update_option( 'aws_settings', $settings );
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
}
|
259 |
-
|
260 |
-
if ( version_compare( $current_version, '1.60', '<' ) ) {
|
261 |
-
|
262 |
-
$settings = get_option( 'aws_settings' );
|
263 |
-
|
264 |
-
if ( $settings ) {
|
265 |
-
if ( ! isset( $settings['autoupdates'] ) ) {
|
266 |
-
$settings['autoupdates'] = 'true';
|
267 |
-
update_option( 'aws_settings', $settings );
|
268 |
-
}
|
269 |
-
}
|
270 |
-
|
271 |
-
}
|
272 |
-
|
273 |
-
if ( version_compare( $current_version, '1.79', '<' ) ) {
|
274 |
-
|
275 |
-
$settings = get_option( 'aws_settings' );
|
276 |
-
|
277 |
-
if ( $settings ) {
|
278 |
-
if ( ! isset( $settings['synonyms'] ) ) {
|
279 |
-
$settings['synonyms'] = 'buy, pay, purchase, acquire box, housing, unit, package';
|
280 |
-
update_option( 'aws_settings', $settings );
|
281 |
-
}
|
282 |
-
}
|
283 |
-
|
284 |
-
}
|
285 |
-
|
286 |
-
if ( version_compare( $current_version, '1.89', '<' ) ) {
|
287 |
-
|
288 |
-
$settings = get_option( 'aws_settings' );
|
289 |
-
|
290 |
-
if ( $settings ) {
|
291 |
-
if ( ! isset( $settings['highlight'] ) && isset( $settings['mark_words'] ) ) {
|
292 |
-
$mark_words = $settings['mark_words'];
|
293 |
-
$settings['highlight'] = $mark_words;
|
294 |
-
update_option( 'aws_settings', $settings );
|
295 |
-
}
|
296 |
-
}
|
297 |
-
|
298 |
-
}
|
299 |
-
|
300 |
-
if ( version_compare( $current_version, '1.96', '<' ) ) {
|
301 |
-
|
302 |
-
$settings = get_option( 'aws_settings' );
|
303 |
-
|
304 |
-
if ( $settings ) {
|
305 |
-
if ( ! isset( $settings['mobile_overlay'] ) ) {
|
306 |
-
$settings['mobile_overlay'] = 'false';
|
307 |
-
update_option( 'aws_settings', $settings );
|
308 |
-
}
|
309 |
-
}
|
310 |
-
|
311 |
-
}
|
312 |
-
|
313 |
-
if ( version_compare( $current_version, '2.03', '<' ) ) {
|
314 |
-
|
315 |
-
$settings = get_option( 'aws_settings' );
|
316 |
-
|
317 |
-
if ( $settings ) {
|
318 |
-
|
319 |
-
if ( isset( $settings['search_in'] ) && is_string( $settings['search_in'] ) ) {
|
320 |
-
$current_search_in = explode( ',', $settings['search_in'] );
|
321 |
-
$new_search_in = array();
|
322 |
-
$options_array = AWS_Admin_Options::include_options();
|
323 |
-
foreach( $options_array['general'] as $def_option ) {
|
324 |
-
if ( isset( $def_option['id'] ) && $def_option['id'] === 'search_in' && isset( $def_option['choices'] ) ) {
|
325 |
-
foreach( $def_option['choices'] as $choice_key => $choice_label ) {
|
326 |
-
$new_search_in[$choice_key] = in_array( $choice_key, $current_search_in ) ? 1 : 0;
|
327 |
-
}
|
328 |
-
$settings['search_in'] = $new_search_in;
|
329 |
-
break;
|
330 |
-
}
|
331 |
-
}
|
332 |
-
update_option( 'aws_settings', $settings );
|
333 |
-
}
|
334 |
-
|
335 |
-
if ( ! isset( $settings['search_archives'] ) ) {
|
336 |
-
$new_search_archives = array();
|
337 |
-
$new_search_archives['archive_category'] = ( isset( $settings['show_cats'] ) && $settings['show_cats'] === 'true' ) ? 1 : 0;
|
338 |
-
$new_search_archives['archive_tag'] = ( isset( $settings['show_tags'] ) && $settings['show_tags'] === 'true' ) ? 1 : 0;
|
339 |
-
$settings['search_archives'] = $new_search_archives;
|
340 |
-
update_option( 'aws_settings', $settings );
|
341 |
-
}
|
342 |
-
|
343 |
-
}
|
344 |
-
|
345 |
-
}
|
346 |
-
|
347 |
-
if ( version_compare( $current_version, '2.23', '<' ) ) {
|
348 |
-
|
349 |
-
$settings = get_option( 'aws_settings' );
|
350 |
-
|
351 |
-
if ( $settings ) {
|
352 |
-
|
353 |
-
if ( ! isset( $settings['search_rule'] ) ) {
|
354 |
-
$settings['search_rule'] = 'contains';
|
355 |
-
update_option( 'aws_settings', $settings );
|
356 |
-
}
|
357 |
-
|
358 |
-
if ( ! isset( $settings['search_timeout'] ) ) {
|
359 |
-
$settings['search_timeout'] = '300';
|
360 |
-
update_option( 'aws_settings', $settings );
|
361 |
-
}
|
362 |
-
|
363 |
-
if ( ! isset( $settings['index_sources'] ) ) {
|
364 |
-
$index_sources = array();
|
365 |
-
$options_array = AWS_Admin_Options::include_options();
|
366 |
-
foreach( $options_array['performance'] as $def_option ) {
|
367 |
-
if ( isset( $def_option['id'] ) && $def_option['id'] === 'index_sources' && isset( $def_option['choices'] ) ) {
|
368 |
-
foreach( $def_option['choices'] as $choice_key => $choice_label ) {
|
369 |
-
$index_sources[$choice_key] = 1;
|
370 |
-
}
|
371 |
-
$settings['index_sources'] = $index_sources;
|
372 |
-
break;
|
373 |
-
}
|
374 |
-
}
|
375 |
-
update_option( 'aws_settings', $settings );
|
376 |
-
}
|
377 |
-
|
378 |
-
if ( ! isset( $settings['index_variations'] ) ) {
|
379 |
-
$settings['index_variations'] = 'true';
|
380 |
-
update_option( 'aws_settings', $settings );
|
381 |
-
}
|
382 |
-
|
383 |
-
}
|
384 |
-
|
385 |
-
}
|
386 |
-
|
387 |
-
}
|
388 |
-
|
389 |
-
update_option( 'aws_plugin_ver', AWS_VERSION );
|
390 |
-
|
391 |
-
}
|
392 |
-
|
393 |
-
/**
|
394 |
-
* Admin notice for table first reindex
|
395 |
-
*/
|
396 |
-
public function admin_notice_no_index() { ?>
|
397 |
-
<div class="updated notice is-dismissible">
|
398 |
-
<p><?php printf( esc_html__( 'Advanced Woo Search: Please go to the plugin setting page and start indexing your products. %s', 'advanced-woo-search' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Go to Settings Page', 'advanced-woo-search' ).'</a>' ); ?></p>
|
399 |
-
</div>
|
400 |
-
<?php }
|
401 |
-
|
402 |
-
/**
|
403 |
-
* Admin notice for table reindex
|
404 |
-
*/
|
405 |
-
public function admin_notice_reindex() { ?>
|
406 |
-
<div class="updated notice is-dismissible">
|
407 |
-
<p><?php printf( esc_html__( 'Advanced Woo Search: Please reindex table for proper work of new plugin features. %s', 'advanced-woo-search' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Go to Settings Page', 'advanced-woo-search' ).'</a>' ); ?></p>
|
408 |
-
</div>
|
409 |
-
<?php }
|
410 |
-
|
411 |
-
}
|
412 |
-
|
413 |
-
|
414 |
-
endif;
|
415 |
-
|
416 |
add_action( 'admin_init', 'AWS_Versions::factory' );
|
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 ) && current_user_can( 'manage_options' ) ) {
|
47 |
+
add_action( 'admin_notices', array( $this, 'admin_notice_no_index' ) );
|
48 |
+
}
|
49 |
+
|
50 |
+
if ( $reindex_version && version_compare( $reindex_version, '1.23', '<' ) && current_user_can( 'manage_options' ) ) {
|
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 ( ! isset( $settings['outofstock'] ) ) {
|
62 |
+
$settings['outofstock'] = 'false';
|
63 |
+
update_option( 'aws_settings', $settings );
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
if ( version_compare( $current_version, '1.17', '<' ) ) {
|
70 |
+
|
71 |
+
$settings = get_option( 'aws_settings' );
|
72 |
+
|
73 |
+
if ( $settings ) {
|
74 |
+
if ( ! isset( $settings['use_analytics'] ) ) {
|
75 |
+
$settings['use_analytics'] = 'false';
|
76 |
+
update_option( 'aws_settings', $settings );
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( version_compare( $current_version, '1.21', '<' ) ) {
|
83 |
+
|
84 |
+
$settings = get_option( 'aws_settings' );
|
85 |
+
|
86 |
+
if ( $settings ) {
|
87 |
+
if ( ! isset( $settings['show_page'] ) ) {
|
88 |
+
$settings['show_page'] = 'false';
|
89 |
+
update_option( 'aws_settings', $settings );
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
94 |
+
|
95 |
+
if ( version_compare( $current_version, '1.23', '<' ) ) {
|
96 |
+
|
97 |
+
$settings = get_option( 'aws_settings' );
|
98 |
+
|
99 |
+
if ( $settings ) {
|
100 |
+
if ( ! isset( $settings['stopwords'] ) ) {
|
101 |
+
$settings['stopwords'] = 'a, also, am, an, and, are, as, at, be, but, by, call, can, co, con, de, do, due, eg, eight, etc, even, ever, every, for, from, full, go, had, has, hasnt, have, he, hence, her, here, his, how, ie, if, in, inc, into, is, it, its, ltd, me, my, no, none, nor, not, now, of, off, on, once, one, only, onto, or, our, ours, out, over, own, part, per, put, re, see, so, some, ten, than, that, the, their, there, these, they, this, three, thru, thus, to, too, top, un, up, us, very, via, was, we, well, were, what, when, where, who, why, will';
|
102 |
+
update_option( 'aws_settings', $settings );
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
if ( version_compare( $current_version, '1.27', '<' ) ) {
|
109 |
+
|
110 |
+
$settings = get_option( 'aws_settings' );
|
111 |
+
|
112 |
+
if ( $settings ) {
|
113 |
+
if ( ! isset( $settings['show_stock'] ) ) {
|
114 |
+
$settings['show_stock'] = 'false';
|
115 |
+
update_option( 'aws_settings', $settings );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
|
119 |
+
}
|
120 |
+
|
121 |
+
if ( version_compare( $current_version, '1.41', '<' ) ) {
|
122 |
+
|
123 |
+
if ( AWS_Helpers::is_index_table_has_terms() == 'no_terms' ) {
|
124 |
+
|
125 |
+
global $wpdb;
|
126 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
127 |
+
|
128 |
+
$wpdb->query("
|
129 |
+
ALTER TABLE {$table_name}
|
130 |
+
ADD COLUMN `term_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0
|
131 |
+
");
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
}
|
136 |
+
|
137 |
+
if ( version_compare( $current_version, '1.42', '<' ) ) {
|
138 |
+
|
139 |
+
$settings = get_option( 'aws_settings' );
|
140 |
+
|
141 |
+
if ( $settings ) {
|
142 |
+
if ( ! isset( $settings['show_more'] ) ) {
|
143 |
+
$settings['show_more'] = 'false';
|
144 |
+
update_option( 'aws_settings', $settings );
|
145 |
+
}
|
146 |
+
}
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
if ( version_compare( $current_version, '1.43', '<' ) ) {
|
151 |
+
|
152 |
+
if ( ! AWS_Helpers::is_table_not_exist() ) {
|
153 |
+
|
154 |
+
global $wpdb;
|
155 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
156 |
+
|
157 |
+
$wpdb->query("
|
158 |
+
ALTER TABLE {$table_name}
|
159 |
+
MODIFY term_source varchar(50);
|
160 |
+
");
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( version_compare( $current_version, '1.47', '<' ) ) {
|
167 |
+
|
168 |
+
$settings = get_option( 'aws_settings' );
|
169 |
+
|
170 |
+
if ( $settings ) {
|
171 |
+
if ( ! isset( $settings['seamless'] ) ) {
|
172 |
+
$settings['seamless'] = 'false';
|
173 |
+
update_option( 'aws_settings', $settings );
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
}
|
178 |
+
|
179 |
+
if ( version_compare( $current_version, '1.48', '<' ) ) {
|
180 |
+
|
181 |
+
$settings = get_option( 'aws_settings' );
|
182 |
+
|
183 |
+
if ( $settings ) {
|
184 |
+
if ( ! isset( $settings['show_clear'] ) ) {
|
185 |
+
$settings['show_clear'] = 'false';
|
186 |
+
update_option( 'aws_settings', $settings );
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
if ( version_compare( $current_version, '1.49', '<' ) ) {
|
193 |
+
|
194 |
+
$settings = get_option( 'aws_settings' );
|
195 |
+
|
196 |
+
if ( $settings ) {
|
197 |
+
if ( ! isset( $settings['show_more_text'] ) ) {
|
198 |
+
$settings['show_more_text'] = __('View all results', 'advanced-woo-search');
|
199 |
+
update_option( 'aws_settings', $settings );
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
if ( version_compare( $current_version, '1.53', '<' ) ) {
|
206 |
+
|
207 |
+
$settings = get_option( 'aws_settings' );
|
208 |
+
|
209 |
+
if ( $settings ) {
|
210 |
+
if ( ! isset( $settings['show_featured'] ) ) {
|
211 |
+
$settings['show_featured'] = 'false';
|
212 |
+
update_option( 'aws_settings', $settings );
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
}
|
217 |
+
|
218 |
+
if ( version_compare( $current_version, '1.54', '<' ) ) {
|
219 |
+
|
220 |
+
if ( AWS_Helpers::is_index_table_has_on_sale() == 'no' ) {
|
221 |
+
|
222 |
+
global $wpdb;
|
223 |
+
$table_name = $wpdb->prefix . AWS_INDEX_TABLE_NAME;
|
224 |
+
|
225 |
+
$wpdb->query("
|
226 |
+
ALTER TABLE {$table_name}
|
227 |
+
ADD COLUMN `on_sale` INT(11) NOT NULL DEFAULT 0
|
228 |
+
");
|
229 |
+
|
230 |
+
}
|
231 |
+
|
232 |
+
}
|
233 |
+
|
234 |
+
if ( version_compare( $current_version, '1.56', '<' ) ) {
|
235 |
+
|
236 |
+
$settings = get_option( 'aws_settings' );
|
237 |
+
|
238 |
+
if ( $settings ) {
|
239 |
+
if ( ! isset( $settings['buttons_order'] ) ) {
|
240 |
+
$settings['buttons_order'] = '1';
|
241 |
+
update_option( 'aws_settings', $settings );
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
}
|
246 |
+
|
247 |
+
if ( version_compare( $current_version, '1.59', '<' ) ) {
|
248 |
+
|
249 |
+
$settings = get_option( 'aws_settings' );
|
250 |
+
|
251 |
+
if ( $settings ) {
|
252 |
+
if ( ! isset( $settings['show_outofstock_price'] ) ) {
|
253 |
+
$settings['show_outofstock_price'] = 'true';
|
254 |
+
update_option( 'aws_settings', $settings );
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
}
|
259 |
+
|
260 |
+
if ( version_compare( $current_version, '1.60', '<' ) ) {
|
261 |
+
|
262 |
+
$settings = get_option( 'aws_settings' );
|
263 |
+
|
264 |
+
if ( $settings ) {
|
265 |
+
if ( ! isset( $settings['autoupdates'] ) ) {
|
266 |
+
$settings['autoupdates'] = 'true';
|
267 |
+
update_option( 'aws_settings', $settings );
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
}
|
272 |
+
|
273 |
+
if ( version_compare( $current_version, '1.79', '<' ) ) {
|
274 |
+
|
275 |
+
$settings = get_option( 'aws_settings' );
|
276 |
+
|
277 |
+
if ( $settings ) {
|
278 |
+
if ( ! isset( $settings['synonyms'] ) ) {
|
279 |
+
$settings['synonyms'] = 'buy, pay, purchase, acquire box, housing, unit, package';
|
280 |
+
update_option( 'aws_settings', $settings );
|
281 |
+
}
|
282 |
+
}
|
283 |
+
|
284 |
+
}
|
285 |
+
|
286 |
+
if ( version_compare( $current_version, '1.89', '<' ) ) {
|
287 |
+
|
288 |
+
$settings = get_option( 'aws_settings' );
|
289 |
+
|
290 |
+
if ( $settings ) {
|
291 |
+
if ( ! isset( $settings['highlight'] ) && isset( $settings['mark_words'] ) ) {
|
292 |
+
$mark_words = $settings['mark_words'];
|
293 |
+
$settings['highlight'] = $mark_words;
|
294 |
+
update_option( 'aws_settings', $settings );
|
295 |
+
}
|
296 |
+
}
|
297 |
+
|
298 |
+
}
|
299 |
+
|
300 |
+
if ( version_compare( $current_version, '1.96', '<' ) ) {
|
301 |
+
|
302 |
+
$settings = get_option( 'aws_settings' );
|
303 |
+
|
304 |
+
if ( $settings ) {
|
305 |
+
if ( ! isset( $settings['mobile_overlay'] ) ) {
|
306 |
+
$settings['mobile_overlay'] = 'false';
|
307 |
+
update_option( 'aws_settings', $settings );
|
308 |
+
}
|
309 |
+
}
|
310 |
+
|
311 |
+
}
|
312 |
+
|
313 |
+
if ( version_compare( $current_version, '2.03', '<' ) ) {
|
314 |
+
|
315 |
+
$settings = get_option( 'aws_settings' );
|
316 |
+
|
317 |
+
if ( $settings ) {
|
318 |
+
|
319 |
+
if ( isset( $settings['search_in'] ) && is_string( $settings['search_in'] ) ) {
|
320 |
+
$current_search_in = explode( ',', $settings['search_in'] );
|
321 |
+
$new_search_in = array();
|
322 |
+
$options_array = AWS_Admin_Options::include_options();
|
323 |
+
foreach( $options_array['general'] as $def_option ) {
|
324 |
+
if ( isset( $def_option['id'] ) && $def_option['id'] === 'search_in' && isset( $def_option['choices'] ) ) {
|
325 |
+
foreach( $def_option['choices'] as $choice_key => $choice_label ) {
|
326 |
+
$new_search_in[$choice_key] = in_array( $choice_key, $current_search_in ) ? 1 : 0;
|
327 |
+
}
|
328 |
+
$settings['search_in'] = $new_search_in;
|
329 |
+
break;
|
330 |
+
}
|
331 |
+
}
|
332 |
+
update_option( 'aws_settings', $settings );
|
333 |
+
}
|
334 |
+
|
335 |
+
if ( ! isset( $settings['search_archives'] ) ) {
|
336 |
+
$new_search_archives = array();
|
337 |
+
$new_search_archives['archive_category'] = ( isset( $settings['show_cats'] ) && $settings['show_cats'] === 'true' ) ? 1 : 0;
|
338 |
+
$new_search_archives['archive_tag'] = ( isset( $settings['show_tags'] ) && $settings['show_tags'] === 'true' ) ? 1 : 0;
|
339 |
+
$settings['search_archives'] = $new_search_archives;
|
340 |
+
update_option( 'aws_settings', $settings );
|
341 |
+
}
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
}
|
346 |
+
|
347 |
+
if ( version_compare( $current_version, '2.23', '<' ) ) {
|
348 |
+
|
349 |
+
$settings = get_option( 'aws_settings' );
|
350 |
+
|
351 |
+
if ( $settings ) {
|
352 |
+
|
353 |
+
if ( ! isset( $settings['search_rule'] ) ) {
|
354 |
+
$settings['search_rule'] = 'contains';
|
355 |
+
update_option( 'aws_settings', $settings );
|
356 |
+
}
|
357 |
+
|
358 |
+
if ( ! isset( $settings['search_timeout'] ) ) {
|
359 |
+
$settings['search_timeout'] = '300';
|
360 |
+
update_option( 'aws_settings', $settings );
|
361 |
+
}
|
362 |
+
|
363 |
+
if ( ! isset( $settings['index_sources'] ) ) {
|
364 |
+
$index_sources = array();
|
365 |
+
$options_array = AWS_Admin_Options::include_options();
|
366 |
+
foreach( $options_array['performance'] as $def_option ) {
|
367 |
+
if ( isset( $def_option['id'] ) && $def_option['id'] === 'index_sources' && isset( $def_option['choices'] ) ) {
|
368 |
+
foreach( $def_option['choices'] as $choice_key => $choice_label ) {
|
369 |
+
$index_sources[$choice_key] = 1;
|
370 |
+
}
|
371 |
+
$settings['index_sources'] = $index_sources;
|
372 |
+
break;
|
373 |
+
}
|
374 |
+
}
|
375 |
+
update_option( 'aws_settings', $settings );
|
376 |
+
}
|
377 |
+
|
378 |
+
if ( ! isset( $settings['index_variations'] ) ) {
|
379 |
+
$settings['index_variations'] = 'true';
|
380 |
+
update_option( 'aws_settings', $settings );
|
381 |
+
}
|
382 |
+
|
383 |
+
}
|
384 |
+
|
385 |
+
}
|
386 |
+
|
387 |
+
}
|
388 |
+
|
389 |
+
update_option( 'aws_plugin_ver', AWS_VERSION );
|
390 |
+
|
391 |
+
}
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Admin notice for table first reindex
|
395 |
+
*/
|
396 |
+
public function admin_notice_no_index() { ?>
|
397 |
+
<div class="updated notice is-dismissible">
|
398 |
+
<p><?php printf( esc_html__( 'Advanced Woo Search: Please go to the plugin setting page and start indexing your products. %s', 'advanced-woo-search' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Go to Settings Page', 'advanced-woo-search' ).'</a>' ); ?></p>
|
399 |
+
</div>
|
400 |
+
<?php }
|
401 |
+
|
402 |
+
/**
|
403 |
+
* Admin notice for table reindex
|
404 |
+
*/
|
405 |
+
public function admin_notice_reindex() { ?>
|
406 |
+
<div class="updated notice is-dismissible">
|
407 |
+
<p><?php printf( esc_html__( 'Advanced Woo Search: Please reindex table for proper work of new plugin features. %s', 'advanced-woo-search' ), '<a class="button button-secondary" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'Go to Settings Page', 'advanced-woo-search' ).'</a>' ); ?></p>
|
408 |
+
</div>
|
409 |
+
<?php }
|
410 |
+
|
411 |
+
}
|
412 |
+
|
413 |
+
|
414 |
+
endif;
|
415 |
+
|
416 |
add_action( 'admin_init', 'AWS_Versions::factory' );
|
includes/modules/bb-aws-search/class-aws-bb-module.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class AwsSearchModule extends FLBuilderModule {
|
4 |
-
|
5 |
-
public function __construct() {
|
6 |
-
|
7 |
-
parent::__construct(array(
|
8 |
-
'name' => __( 'Advanced Woo Search', 'advanced-woo-search' ),
|
9 |
-
'description' => __( 'WooCommerce search form', 'advanced-woo-search' ),
|
10 |
-
'category' => __( 'WooCommerce', 'fl-builder' ),
|
11 |
-
'dir' => AWS_DIR . '/includes/modules/bb-aws-search/',
|
12 |
-
'url' => AWS_URL . '/includes/modules/bb-aws-search/',
|
13 |
-
'icon' => 'search.svg',
|
14 |
-
'partial_refresh' => true,
|
15 |
-
));
|
16 |
-
|
17 |
-
}
|
18 |
-
|
19 |
-
}
|
20 |
-
|
21 |
-
$placeholder = AWS_Helpers::translate( 'search_field_text', AWS()->get_settings( 'search_field_text' ) );
|
22 |
-
|
23 |
-
FLBuilder::register_module( 'AwsSearchModule', array(
|
24 |
-
'general' => array(
|
25 |
-
'title' => __( 'General', 'advanced-woo-search' ),
|
26 |
-
'sections' => array(
|
27 |
-
'general' => array(
|
28 |
-
'title' => '',
|
29 |
-
'fields' => array(
|
30 |
-
'placeholder' => array(
|
31 |
-
'type' => 'text',
|
32 |
-
'label' => __( 'Placeholder', 'advanced-woo-search' ),
|
33 |
-
'default' => $placeholder,
|
34 |
-
'preview' => array(
|
35 |
-
'type' => 'text',
|
36 |
-
'selector' => '.fl-heading-text',
|
37 |
-
),
|
38 |
-
'connections' => array( 'string' ),
|
39 |
-
),
|
40 |
-
),
|
41 |
-
),
|
42 |
-
),
|
43 |
-
'description' => sprintf( esc_html__( 'To configure your Advanced Woo Search form please visit %s.', 'advanced-woo-search' ), '<a target="_blank" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'plugin settings page', 'advanced-woo-search' ).'</a>' ),
|
44 |
-
),
|
45 |
) );
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class AwsSearchModule extends FLBuilderModule {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
|
7 |
+
parent::__construct(array(
|
8 |
+
'name' => __( 'Advanced Woo Search', 'advanced-woo-search' ),
|
9 |
+
'description' => __( 'WooCommerce search form', 'advanced-woo-search' ),
|
10 |
+
'category' => __( 'WooCommerce', 'fl-builder' ),
|
11 |
+
'dir' => AWS_DIR . '/includes/modules/bb-aws-search/',
|
12 |
+
'url' => AWS_URL . '/includes/modules/bb-aws-search/',
|
13 |
+
'icon' => 'search.svg',
|
14 |
+
'partial_refresh' => true,
|
15 |
+
));
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
$placeholder = AWS_Helpers::translate( 'search_field_text', AWS()->get_settings( 'search_field_text' ) );
|
22 |
+
|
23 |
+
FLBuilder::register_module( 'AwsSearchModule', array(
|
24 |
+
'general' => array(
|
25 |
+
'title' => __( 'General', 'advanced-woo-search' ),
|
26 |
+
'sections' => array(
|
27 |
+
'general' => array(
|
28 |
+
'title' => '',
|
29 |
+
'fields' => array(
|
30 |
+
'placeholder' => array(
|
31 |
+
'type' => 'text',
|
32 |
+
'label' => __( 'Placeholder', 'advanced-woo-search' ),
|
33 |
+
'default' => $placeholder,
|
34 |
+
'preview' => array(
|
35 |
+
'type' => 'text',
|
36 |
+
'selector' => '.fl-heading-text',
|
37 |
+
),
|
38 |
+
'connections' => array( 'string' ),
|
39 |
+
),
|
40 |
+
),
|
41 |
+
),
|
42 |
+
),
|
43 |
+
'description' => sprintf( esc_html__( 'To configure your Advanced Woo Search form please visit %s.', 'advanced-woo-search' ), '<a target="_blank" href="'.esc_url( admin_url('admin.php?page=aws-options') ).'">'.esc_html__( 'plugin settings page', 'advanced-woo-search' ).'</a>' ),
|
44 |
+
),
|
45 |
) );
|
includes/modules/bb-aws-search/includes/frontend.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$search_form = aws_get_search_form( false );
|
4 |
-
$search_form = preg_replace( '/placeholder="([\S\s]*?)"/i', 'placeholder="' . esc_attr( $settings->placeholder ) . '"', $search_form );
|
5 |
-
|
6 |
-
echo $search_form;
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$search_form = aws_get_search_form( false );
|
4 |
+
$search_form = preg_replace( '/placeholder="([\S\s]*?)"/i', 'placeholder="' . esc_attr( $settings->placeholder ) . '"', $search_form );
|
5 |
+
|
6 |
+
echo $search_form;
|
includes/modules/class-aws-um.php
CHANGED
@@ -1,270 +1,270 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Ultimate Member plugin
|
4 |
-
*/
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit; // Exit if accessed directly.
|
8 |
-
}
|
9 |
-
|
10 |
-
if ( ! class_exists( 'AWS_UM' ) ) :
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class
|
14 |
-
*/
|
15 |
-
class AWS_UM {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Main AWS_UM Instance
|
19 |
-
*
|
20 |
-
* Ensures only one instance of AWS_UM is loaded or can be loaded.
|
21 |
-
*
|
22 |
-
* @static
|
23 |
-
* @return AWS_UM - Main instance
|
24 |
-
*/
|
25 |
-
protected static $_instance = null;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Main AWS_UM Instance
|
29 |
-
*
|
30 |
-
* Ensures only one instance of AWS_UM is loaded or can be loaded.
|
31 |
-
*
|
32 |
-
* @static
|
33 |
-
* @return AWS_UM - Main instance
|
34 |
-
*/
|
35 |
-
public static function instance() {
|
36 |
-
if ( is_null( self::$_instance ) ) {
|
37 |
-
self::$_instance = new self();
|
38 |
-
}
|
39 |
-
return self::$_instance;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Constructor
|
44 |
-
*/
|
45 |
-
public function __construct() {
|
46 |
-
|
47 |
-
add_filter( 'aws_exclude_products', array( $this, 'exclude_products' ) );
|
48 |
-
|
49 |
-
add_filter( 'aws_search_tax_results', array( $this, 'exclude_tax' ), 10, 2 );
|
50 |
-
|
51 |
-
}
|
52 |
-
|
53 |
-
/*
|
54 |
-
* Restrict products
|
55 |
-
*/
|
56 |
-
public function exclude_products( $products_ids ) {
|
57 |
-
|
58 |
-
$restricted_products_by_terms = $this->get_restricted_products_by_terms();
|
59 |
-
|
60 |
-
$restricted_products = get_posts( array(
|
61 |
-
'posts_per_page' => -1,
|
62 |
-
'fields' => 'ids',
|
63 |
-
'post_type' => 'product',
|
64 |
-
'post_status' => 'publish',
|
65 |
-
'ignore_sticky_posts' => true,
|
66 |
-
'suppress_filters' => true,
|
67 |
-
'has_password' => false,
|
68 |
-
'no_found_rows' => 1,
|
69 |
-
'orderby' => 'ID',
|
70 |
-
'order' => 'DESC',
|
71 |
-
'lang' => '',
|
72 |
-
'meta_query' => array(
|
73 |
-
array(
|
74 |
-
'key' => 'um_content_restriction',
|
75 |
-
'compare' => 'EXISTS',
|
76 |
-
)
|
77 |
-
)
|
78 |
-
) );
|
79 |
-
|
80 |
-
if ( $restricted_products ) {
|
81 |
-
foreach( $restricted_products as $restricted_product_id ) {
|
82 |
-
|
83 |
-
$um_content_restriction = get_post_meta( $restricted_product_id, 'um_content_restriction', true );
|
84 |
-
|
85 |
-
$is_restricted = $this->is_restricted( $um_content_restriction );
|
86 |
-
|
87 |
-
if ( $is_restricted ) {
|
88 |
-
$products_ids[] = $restricted_product_id;
|
89 |
-
}
|
90 |
-
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
if ( ! empty( $restricted_products_by_terms ) ) {
|
95 |
-
$products_ids = array_merge($products_ids, $restricted_products_by_terms);
|
96 |
-
|
97 |
-
}
|
98 |
-
|
99 |
-
return $products_ids;
|
100 |
-
|
101 |
-
}
|
102 |
-
|
103 |
-
/*
|
104 |
-
* Restrict taxonomies
|
105 |
-
*/
|
106 |
-
public function exclude_tax( $result_array, $taxonomy ) {
|
107 |
-
|
108 |
-
$new_result_array = array();
|
109 |
-
|
110 |
-
foreach ( $result_array as $result_tax_name => $result_tax ) {
|
111 |
-
foreach ( $result_tax as $tax_key => $tax_item ) {
|
112 |
-
$um_content_restriction = get_term_meta( $tax_item['id'], 'um_content_restriction', true );
|
113 |
-
$is_restricted = $this->is_restricted( $um_content_restriction );
|
114 |
-
if ( $is_restricted ) {
|
115 |
-
continue;
|
116 |
-
}
|
117 |
-
$new_result_array[$result_tax_name][] = $tax_item;
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
return $new_result_array;
|
122 |
-
|
123 |
-
}
|
124 |
-
|
125 |
-
/*
|
126 |
-
* Check is product/term is restricted for current user
|
127 |
-
*/
|
128 |
-
private function is_restricted( $um_content_restriction ) {
|
129 |
-
|
130 |
-
if ( $um_content_restriction && is_array( $um_content_restriction ) && ! empty( $um_content_restriction ) ) {
|
131 |
-
|
132 |
-
$um_custom_access_settings = isset( $um_content_restriction['_um_custom_access_settings'] ) ? $um_content_restriction['_um_custom_access_settings'] : false;
|
133 |
-
$um_access_hide_from_queries = isset( $um_content_restriction['_um_access_hide_from_queries'] ) ? $um_content_restriction['_um_access_hide_from_queries'] : false;
|
134 |
-
|
135 |
-
if ( $um_custom_access_settings && $um_custom_access_settings === '1' && $um_access_hide_from_queries && $um_access_hide_from_queries === '1' ) {
|
136 |
-
|
137 |
-
$um_accessible = isset( $um_content_restriction['_um_accessible'] ) ? $um_content_restriction['_um_accessible'] : false;
|
138 |
-
|
139 |
-
if ( $um_accessible ) {
|
140 |
-
|
141 |
-
if ( $um_accessible === '1' && is_user_logged_in() ) {
|
142 |
-
return true;
|
143 |
-
}
|
144 |
-
elseif ( $um_accessible === '2' && ! is_user_logged_in() ) {
|
145 |
-
return true;
|
146 |
-
}
|
147 |
-
elseif ( $um_accessible === '2' && is_user_logged_in() ) {
|
148 |
-
|
149 |
-
$um_access_roles = isset( $um_content_restriction['_um_access_roles'] ) ? $um_content_restriction['_um_access_roles'] : false;
|
150 |
-
|
151 |
-
if ( $um_access_roles && is_array( $um_access_roles ) && ! empty( $um_access_roles ) ) {
|
152 |
-
$user = wp_get_current_user();
|
153 |
-
$role = ( array ) $user->roles;
|
154 |
-
$user_role = $role[0];
|
155 |
-
if ( $user_role && $user_role !== 'administrator' && ! isset( $um_access_roles[$user_role] ) ) {
|
156 |
-
return true;
|
157 |
-
}
|
158 |
-
}
|
159 |
-
|
160 |
-
}
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
}
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
return false;
|
169 |
-
|
170 |
-
}
|
171 |
-
|
172 |
-
/*
|
173 |
-
* Get restricted products by restricted terms
|
174 |
-
*/
|
175 |
-
private function get_restricted_products_by_terms() {
|
176 |
-
|
177 |
-
$restricted_products = array();
|
178 |
-
$restricted_terms = $this->get_restricted_terms();
|
179 |
-
|
180 |
-
if ( $restricted_terms && ! empty( $restricted_terms ) ) {
|
181 |
-
|
182 |
-
$args = array(
|
183 |
-
'posts_per_page' => -1,
|
184 |
-
'fields' => 'ids',
|
185 |
-
'post_type' => 'product',
|
186 |
-
'post_status' => 'publish',
|
187 |
-
'ignore_sticky_posts' => true,
|
188 |
-
'suppress_filters' => true,
|
189 |
-
'has_password' => false,
|
190 |
-
'no_found_rows' => 1,
|
191 |
-
'orderby' => 'ID',
|
192 |
-
'order' => 'DESC',
|
193 |
-
'lang' => '',
|
194 |
-
) ;
|
195 |
-
|
196 |
-
$args['tax_query']['relation'] = 'OR';
|
197 |
-
|
198 |
-
foreach ( $restricted_terms as $restricted_tax_name => $restricted_tax ) {
|
199 |
-
$args['tax_query'][] = array(
|
200 |
-
'taxonomy' => $restricted_tax_name,
|
201 |
-
'field' => 'id',
|
202 |
-
'terms' => $restricted_tax,
|
203 |
-
);
|
204 |
-
}
|
205 |
-
|
206 |
-
$restricted_products = get_posts( $args );
|
207 |
-
|
208 |
-
}
|
209 |
-
|
210 |
-
return $restricted_products;
|
211 |
-
|
212 |
-
}
|
213 |
-
|
214 |
-
/*
|
215 |
-
* Get restricted terms
|
216 |
-
*/
|
217 |
-
private function get_restricted_terms() {
|
218 |
-
|
219 |
-
$restricted_terms_arr = array();
|
220 |
-
|
221 |
-
if ( function_exists( 'UM' ) ) {
|
222 |
-
|
223 |
-
$restricted_taxonomies_option = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
224 |
-
$restricted_taxonomies = array();
|
225 |
-
if ( $restricted_taxonomies_option && is_array( $restricted_taxonomies_option ) ) {
|
226 |
-
foreach( $restricted_taxonomies_option as $restricted_taxonomy => $restricted_taxonomy_val ) {
|
227 |
-
if ( $restricted_taxonomy_val ) {
|
228 |
-
$restricted_taxonomies[] = $restricted_taxonomy;
|
229 |
-
}
|
230 |
-
}
|
231 |
-
}
|
232 |
-
|
233 |
-
if ( ! empty( $restricted_taxonomies ) ) {
|
234 |
-
|
235 |
-
$restricted_terms = get_terms( array(
|
236 |
-
'taxonomy' => $restricted_taxonomies,
|
237 |
-
'hide_empty' => false,
|
238 |
-
'lang' => '',
|
239 |
-
'meta_query' => array(
|
240 |
-
array(
|
241 |
-
'key' => 'um_content_restriction',
|
242 |
-
'compare' => 'EXISTS',
|
243 |
-
)
|
244 |
-
)
|
245 |
-
) );
|
246 |
-
|
247 |
-
if ( $restricted_terms ) {
|
248 |
-
foreach( $restricted_terms as $restricted_term ) {
|
249 |
-
$um_content_restriction = get_term_meta( $restricted_term->term_id, 'um_content_restriction', true );
|
250 |
-
$is_restricted = $this->is_restricted( $um_content_restriction );
|
251 |
-
if ( $is_restricted ) {
|
252 |
-
$restricted_terms_arr[$restricted_term->taxonomy][] = $restricted_term->term_id;
|
253 |
-
}
|
254 |
-
|
255 |
-
}
|
256 |
-
}
|
257 |
-
|
258 |
-
|
259 |
-
}
|
260 |
-
}
|
261 |
-
|
262 |
-
return $restricted_terms_arr;
|
263 |
-
|
264 |
-
}
|
265 |
-
|
266 |
-
}
|
267 |
-
|
268 |
-
endif;
|
269 |
-
|
270 |
AWS_UM::instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Ultimate Member plugin
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly.
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! class_exists( 'AWS_UM' ) ) :
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class
|
14 |
+
*/
|
15 |
+
class AWS_UM {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Main AWS_UM Instance
|
19 |
+
*
|
20 |
+
* Ensures only one instance of AWS_UM is loaded or can be loaded.
|
21 |
+
*
|
22 |
+
* @static
|
23 |
+
* @return AWS_UM - Main instance
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Main AWS_UM Instance
|
29 |
+
*
|
30 |
+
* Ensures only one instance of AWS_UM is loaded or can be loaded.
|
31 |
+
*
|
32 |
+
* @static
|
33 |
+
* @return AWS_UM - Main instance
|
34 |
+
*/
|
35 |
+
public static function instance() {
|
36 |
+
if ( is_null( self::$_instance ) ) {
|
37 |
+
self::$_instance = new self();
|
38 |
+
}
|
39 |
+
return self::$_instance;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Constructor
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
|
47 |
+
add_filter( 'aws_exclude_products', array( $this, 'exclude_products' ) );
|
48 |
+
|
49 |
+
add_filter( 'aws_search_tax_results', array( $this, 'exclude_tax' ), 10, 2 );
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/*
|
54 |
+
* Restrict products
|
55 |
+
*/
|
56 |
+
public function exclude_products( $products_ids ) {
|
57 |
+
|
58 |
+
$restricted_products_by_terms = $this->get_restricted_products_by_terms();
|
59 |
+
|
60 |
+
$restricted_products = get_posts( array(
|
61 |
+
'posts_per_page' => -1,
|
62 |
+
'fields' => 'ids',
|
63 |
+
'post_type' => 'product',
|
64 |
+
'post_status' => 'publish',
|
65 |
+
'ignore_sticky_posts' => true,
|
66 |
+
'suppress_filters' => true,
|
67 |
+
'has_password' => false,
|
68 |
+
'no_found_rows' => 1,
|
69 |
+
'orderby' => 'ID',
|
70 |
+
'order' => 'DESC',
|
71 |
+
'lang' => '',
|
72 |
+
'meta_query' => array(
|
73 |
+
array(
|
74 |
+
'key' => 'um_content_restriction',
|
75 |
+
'compare' => 'EXISTS',
|
76 |
+
)
|
77 |
+
)
|
78 |
+
) );
|
79 |
+
|
80 |
+
if ( $restricted_products ) {
|
81 |
+
foreach( $restricted_products as $restricted_product_id ) {
|
82 |
+
|
83 |
+
$um_content_restriction = get_post_meta( $restricted_product_id, 'um_content_restriction', true );
|
84 |
+
|
85 |
+
$is_restricted = $this->is_restricted( $um_content_restriction );
|
86 |
+
|
87 |
+
if ( $is_restricted ) {
|
88 |
+
$products_ids[] = $restricted_product_id;
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
if ( ! empty( $restricted_products_by_terms ) ) {
|
95 |
+
$products_ids = array_merge($products_ids, $restricted_products_by_terms);
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
return $products_ids;
|
100 |
+
|
101 |
+
}
|
102 |
+
|
103 |
+
/*
|
104 |
+
* Restrict taxonomies
|
105 |
+
*/
|
106 |
+
public function exclude_tax( $result_array, $taxonomy ) {
|
107 |
+
|
108 |
+
$new_result_array = array();
|
109 |
+
|
110 |
+
foreach ( $result_array as $result_tax_name => $result_tax ) {
|
111 |
+
foreach ( $result_tax as $tax_key => $tax_item ) {
|
112 |
+
$um_content_restriction = get_term_meta( $tax_item['id'], 'um_content_restriction', true );
|
113 |
+
$is_restricted = $this->is_restricted( $um_content_restriction );
|
114 |
+
if ( $is_restricted ) {
|
115 |
+
continue;
|
116 |
+
}
|
117 |
+
$new_result_array[$result_tax_name][] = $tax_item;
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
return $new_result_array;
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
/*
|
126 |
+
* Check is product/term is restricted for current user
|
127 |
+
*/
|
128 |
+
private function is_restricted( $um_content_restriction ) {
|
129 |
+
|
130 |
+
if ( $um_content_restriction && is_array( $um_content_restriction ) && ! empty( $um_content_restriction ) ) {
|
131 |
+
|
132 |
+
$um_custom_access_settings = isset( $um_content_restriction['_um_custom_access_settings'] ) ? $um_content_restriction['_um_custom_access_settings'] : false;
|
133 |
+
$um_access_hide_from_queries = isset( $um_content_restriction['_um_access_hide_from_queries'] ) ? $um_content_restriction['_um_access_hide_from_queries'] : false;
|
134 |
+
|
135 |
+
if ( $um_custom_access_settings && $um_custom_access_settings === '1' && $um_access_hide_from_queries && $um_access_hide_from_queries === '1' ) {
|
136 |
+
|
137 |
+
$um_accessible = isset( $um_content_restriction['_um_accessible'] ) ? $um_content_restriction['_um_accessible'] : false;
|
138 |
+
|
139 |
+
if ( $um_accessible ) {
|
140 |
+
|
141 |
+
if ( $um_accessible === '1' && is_user_logged_in() ) {
|
142 |
+
return true;
|
143 |
+
}
|
144 |
+
elseif ( $um_accessible === '2' && ! is_user_logged_in() ) {
|
145 |
+
return true;
|
146 |
+
}
|
147 |
+
elseif ( $um_accessible === '2' && is_user_logged_in() ) {
|
148 |
+
|
149 |
+
$um_access_roles = isset( $um_content_restriction['_um_access_roles'] ) ? $um_content_restriction['_um_access_roles'] : false;
|
150 |
+
|
151 |
+
if ( $um_access_roles && is_array( $um_access_roles ) && ! empty( $um_access_roles ) ) {
|
152 |
+
$user = wp_get_current_user();
|
153 |
+
$role = ( array ) $user->roles;
|
154 |
+
$user_role = $role[0];
|
155 |
+
if ( $user_role && $user_role !== 'administrator' && ! isset( $um_access_roles[$user_role] ) ) {
|
156 |
+
return true;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
}
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
return false;
|
169 |
+
|
170 |
+
}
|
171 |
+
|
172 |
+
/*
|
173 |
+
* Get restricted products by restricted terms
|
174 |
+
*/
|
175 |
+
private function get_restricted_products_by_terms() {
|
176 |
+
|
177 |
+
$restricted_products = array();
|
178 |
+
$restricted_terms = $this->get_restricted_terms();
|
179 |
+
|
180 |
+
if ( $restricted_terms && ! empty( $restricted_terms ) ) {
|
181 |
+
|
182 |
+
$args = array(
|
183 |
+
'posts_per_page' => -1,
|
184 |
+
'fields' => 'ids',
|
185 |
+
'post_type' => 'product',
|
186 |
+
'post_status' => 'publish',
|
187 |
+
'ignore_sticky_posts' => true,
|
188 |
+
'suppress_filters' => true,
|
189 |
+
'has_password' => false,
|
190 |
+
'no_found_rows' => 1,
|
191 |
+
'orderby' => 'ID',
|
192 |
+
'order' => 'DESC',
|
193 |
+
'lang' => '',
|
194 |
+
) ;
|
195 |
+
|
196 |
+
$args['tax_query']['relation'] = 'OR';
|
197 |
+
|
198 |
+
foreach ( $restricted_terms as $restricted_tax_name => $restricted_tax ) {
|
199 |
+
$args['tax_query'][] = array(
|
200 |
+
'taxonomy' => $restricted_tax_name,
|
201 |
+
'field' => 'id',
|
202 |
+
'terms' => $restricted_tax,
|
203 |
+
);
|
204 |
+
}
|
205 |
+
|
206 |
+
$restricted_products = get_posts( $args );
|
207 |
+
|
208 |
+
}
|
209 |
+
|
210 |
+
return $restricted_products;
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
+
/*
|
215 |
+
* Get restricted terms
|
216 |
+
*/
|
217 |
+
private function get_restricted_terms() {
|
218 |
+
|
219 |
+
$restricted_terms_arr = array();
|
220 |
+
|
221 |
+
if ( function_exists( 'UM' ) ) {
|
222 |
+
|
223 |
+
$restricted_taxonomies_option = UM()->options()->get( 'restricted_access_taxonomy_metabox' );
|
224 |
+
$restricted_taxonomies = array();
|
225 |
+
if ( $restricted_taxonomies_option && is_array( $restricted_taxonomies_option ) ) {
|
226 |
+
foreach( $restricted_taxonomies_option as $restricted_taxonomy => $restricted_taxonomy_val ) {
|
227 |
+
if ( $restricted_taxonomy_val ) {
|
228 |
+
$restricted_taxonomies[] = $restricted_taxonomy;
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
if ( ! empty( $restricted_taxonomies ) ) {
|
234 |
+
|
235 |
+
$restricted_terms = get_terms( array(
|
236 |
+
'taxonomy' => $restricted_taxonomies,
|
237 |
+
'hide_empty' => false,
|
238 |
+
'lang' => '',
|
239 |
+
'meta_query' => array(
|
240 |
+
array(
|
241 |
+
'key' => 'um_content_restriction',
|
242 |
+
'compare' => 'EXISTS',
|
243 |
+
)
|
244 |
+
)
|
245 |
+
) );
|
246 |
+
|
247 |
+
if ( $restricted_terms ) {
|
248 |
+
foreach( $restricted_terms as $restricted_term ) {
|
249 |
+
$um_content_restriction = get_term_meta( $restricted_term->term_id, 'um_content_restriction', true );
|
250 |
+
$is_restricted = $this->is_restricted( $um_content_restriction );
|
251 |
+
if ( $is_restricted ) {
|
252 |
+
$restricted_terms_arr[$restricted_term->taxonomy][] = $restricted_term->term_id;
|
253 |
+
}
|
254 |
+
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
return $restricted_terms_arr;
|
263 |
+
|
264 |
+
}
|
265 |
+
|
266 |
+
}
|
267 |
+
|
268 |
+
endif;
|
269 |
+
|
270 |
AWS_UM::instance();
|
includes/modules/class-aws-wcfm.php
CHANGED
@@ -1,198 +1,198 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WCFM - WooCommerce Multivendor Marketplace plugin support
|
4 |
-
*/
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit; // Exit if accessed directly.
|
8 |
-
}
|
9 |
-
|
10 |
-
if ( ! class_exists( 'AWS_WCFM' ) ) :
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class
|
14 |
-
*/
|
15 |
-
class AWS_WCFM {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Main AWS_WCFM Instance
|
19 |
-
*
|
20 |
-
* Ensures only one instance of AWS_WCFM is loaded or can be loaded.
|
21 |
-
*
|
22 |
-
* @static
|
23 |
-
* @return AWS_WCFM - Main instance
|
24 |
-
*/
|
25 |
-
protected static $_instance = null;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Main AWS_WCFM Instance
|
29 |
-
*
|
30 |
-
* Ensures only one instance of AWS_WCFM is loaded or can be loaded.
|
31 |
-
*
|
32 |
-
* @static
|
33 |
-
* @return AWS_WCFM - Main instance
|
34 |
-
*/
|
35 |
-
public static function instance() {
|
36 |
-
if ( is_null( self::$_instance ) ) {
|
37 |
-
self::$_instance = new self();
|
38 |
-
}
|
39 |
-
return self::$_instance;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Constructor
|
44 |
-
*/
|
45 |
-
public function __construct() {
|
46 |
-
add_filter( 'aws_excerpt_search_result', array( $this, 'wcfm_excerpt_search_result' ), 1, 3 );
|
47 |
-
add_filter( 'aws_searchbox_markup', array( $this, 'wcfm_searchbox_markup' ), 1, 2 );
|
48 |
-
add_filter( 'aws_front_data_parameters', array( $this, 'wcfm_front_data_parameters' ), 1 );
|
49 |
-
add_filter( 'aws_search_query_array', array( $this, 'wcfm_search_query_array' ), 1 );
|
50 |
-
}
|
51 |
-
|
52 |
-
/*
|
53 |
-
* Add store name and logo inside search results
|
54 |
-
*/
|
55 |
-
function wcfm_excerpt_search_result( $excerpt, $post_id, $product ) {
|
56 |
-
|
57 |
-
if ( function_exists( 'wcfm_get_vendor_id_by_post' ) ) {
|
58 |
-
|
59 |
-
$vendor_id = wcfm_get_vendor_id_by_post( $post_id );
|
60 |
-
|
61 |
-
if ( $vendor_id ) {
|
62 |
-
if ( apply_filters( 'wcfmmp_is_allow_sold_by', true, $vendor_id ) && wcfm_vendor_has_capability( $vendor_id, 'sold_by' ) ) {
|
63 |
-
|
64 |
-
global $WCFM, $WCFMmp;
|
65 |
-
|
66 |
-
$is_store_offline = get_user_meta( $vendor_id, '_wcfm_store_offline', true );
|
67 |
-
|
68 |
-
if ( ! $is_store_offline ) {
|
69 |
-
|
70 |
-
$store_name = wcfm_get_vendor_store_name( absint( $vendor_id ) );
|
71 |
-
$store_url = $WCFMmp->wcfmmp_store->get_shop_url();
|
72 |
-
|
73 |
-
$logo = '';
|
74 |
-
|
75 |
-
if ( apply_filters( 'wcfmmp_is_allow_sold_by_logo', true ) ) {
|
76 |
-
$store_logo = wcfm_get_vendor_store_logo_by_vendor( $vendor_id );
|
77 |
-
if ( ! $store_logo ) {
|
78 |
-
$store_logo = apply_filters( 'wcfmmp_store_default_logo', $WCFM->plugin_url . 'assets/images/wcfmmp-blue.png' );
|
79 |
-
}
|
80 |
-
$logo = '<img style="margin-right:4px;" width="24px" src="' . $store_logo . '" />';
|
81 |
-
}
|
82 |
-
|
83 |
-
$excerpt .= '<br><span style="margin-top:4px;display:block;" data-link="' . $store_url . '">' . $logo . $store_name . '</span>';
|
84 |
-
|
85 |
-
}
|
86 |
-
|
87 |
-
}
|
88 |
-
}
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
return $excerpt;
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
/*
|
97 |
-
* WCFM - WooCommerce Multivendor Marketplace update search page url for vendors shops
|
98 |
-
*/
|
99 |
-
public function wcfm_searchbox_markup( $markup, $params ) {
|
100 |
-
|
101 |
-
$store = $this->get_current_store();
|
102 |
-
|
103 |
-
if ( $store ) {
|
104 |
-
$markup = preg_replace( '/action="(.+?)"/i', 'action="' . $store->get_shop_url() . '"', $markup );
|
105 |
-
}
|
106 |
-
|
107 |
-
return $markup;
|
108 |
-
|
109 |
-
}
|
110 |
-
|
111 |
-
/*
|
112 |
-
* WCFM - WooCommerce Multivendor Marketplace limit search inside vendors shop
|
113 |
-
*/
|
114 |
-
public function wcfm_front_data_parameters( $params ) {
|
115 |
-
|
116 |
-
$store = $this->get_current_store();
|
117 |
-
|
118 |
-
if ( $store ) {
|
119 |
-
$params['data-tax'] = 'store:' . $store->get_id();
|
120 |
-
}
|
121 |
-
|
122 |
-
return $params;
|
123 |
-
|
124 |
-
}
|
125 |
-
|
126 |
-
/*
|
127 |
-
* WCFM - WooCommerce Multivendor Marketplace limit search inside vendoes shop
|
128 |
-
*/
|
129 |
-
public function wcfm_search_query_array( $query ) {
|
130 |
-
|
131 |
-
$vendor_id = false;
|
132 |
-
|
133 |
-
if ( isset( $_REQUEST['aws_tax'] ) && $_REQUEST['aws_tax'] && strpos( $_REQUEST['aws_tax'], 'store:' ) !== false ) {
|
134 |
-
$vendor_id = intval( str_replace( 'store:', '', $_REQUEST['aws_tax'] ) );
|
135 |
-
} else {
|
136 |
-
$store = $this->get_current_store();
|
137 |
-
if ( $store ) {
|
138 |
-
$vendor_id = $store->get_id();
|
139 |
-
}
|
140 |
-
}
|
141 |
-
|
142 |
-
if ( $vendor_id ) {
|
143 |
-
|
144 |
-
$store_products = get_posts( array(
|
145 |
-
'posts_per_page' => -1,
|
146 |
-
'fields' => 'ids',
|
147 |
-
'post_type' => 'product',
|
148 |
-
'post_status' => 'publish',
|
149 |
-
'ignore_sticky_posts' => true,
|
150 |
-
'suppress_filters' => true,
|
151 |
-
'no_found_rows' => 1,
|
152 |
-
'orderby' => 'ID',
|
153 |
-
'order' => 'DESC',
|
154 |
-
'lang' => '',
|
155 |
-
'author' => $vendor_id
|
156 |
-
) );
|
157 |
-
|
158 |
-
if ( $store_products ) {
|
159 |
-
$query['search'] .= " AND ( id IN ( " . implode( ',', $store_products ) . " ) )";
|
160 |
-
}
|
161 |
-
|
162 |
-
}
|
163 |
-
|
164 |
-
return $query;
|
165 |
-
|
166 |
-
}
|
167 |
-
|
168 |
-
/*
|
169 |
-
* Get current store object
|
170 |
-
*/
|
171 |
-
private function get_current_store() {
|
172 |
-
|
173 |
-
$store = false;
|
174 |
-
|
175 |
-
if ( function_exists('wcfmmp_is_store_page') && function_exists('wcfm_get_option') && wcfmmp_is_store_page() ) {
|
176 |
-
|
177 |
-
$wcfm_store_url = wcfm_get_option( 'wcfm_store_url', 'store' );
|
178 |
-
$wcfm_store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
|
179 |
-
|
180 |
-
if ( $wcfm_store_name ) {
|
181 |
-
$seller_info = get_user_by( 'slug', $wcfm_store_name );
|
182 |
-
if ( $seller_info && function_exists( 'wcfmmp_get_store' ) ) {
|
183 |
-
$store_user = wcfmmp_get_store( $seller_info->ID );
|
184 |
-
if ( $store_user ) {
|
185 |
-
$store = $store_user;
|
186 |
-
}
|
187 |
-
}
|
188 |
-
}
|
189 |
-
|
190 |
-
}
|
191 |
-
|
192 |
-
return $store;
|
193 |
-
|
194 |
-
}
|
195 |
-
|
196 |
-
}
|
197 |
-
|
198 |
endif;
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WCFM - WooCommerce Multivendor Marketplace plugin support
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly.
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! class_exists( 'AWS_WCFM' ) ) :
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class
|
14 |
+
*/
|
15 |
+
class AWS_WCFM {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Main AWS_WCFM Instance
|
19 |
+
*
|
20 |
+
* Ensures only one instance of AWS_WCFM is loaded or can be loaded.
|
21 |
+
*
|
22 |
+
* @static
|
23 |
+
* @return AWS_WCFM - Main instance
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Main AWS_WCFM Instance
|
29 |
+
*
|
30 |
+
* Ensures only one instance of AWS_WCFM is loaded or can be loaded.
|
31 |
+
*
|
32 |
+
* @static
|
33 |
+
* @return AWS_WCFM - Main instance
|
34 |
+
*/
|
35 |
+
public static function instance() {
|
36 |
+
if ( is_null( self::$_instance ) ) {
|
37 |
+
self::$_instance = new self();
|
38 |
+
}
|
39 |
+
return self::$_instance;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Constructor
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
add_filter( 'aws_excerpt_search_result', array( $this, 'wcfm_excerpt_search_result' ), 1, 3 );
|
47 |
+
add_filter( 'aws_searchbox_markup', array( $this, 'wcfm_searchbox_markup' ), 1, 2 );
|
48 |
+
add_filter( 'aws_front_data_parameters', array( $this, 'wcfm_front_data_parameters' ), 1 );
|
49 |
+
add_filter( 'aws_search_query_array', array( $this, 'wcfm_search_query_array' ), 1 );
|
50 |
+
}
|
51 |
+
|
52 |
+
/*
|
53 |
+
* Add store name and logo inside search results
|
54 |
+
*/
|
55 |
+
function wcfm_excerpt_search_result( $excerpt, $post_id, $product ) {
|
56 |
+
|
57 |
+
if ( function_exists( 'wcfm_get_vendor_id_by_post' ) ) {
|
58 |
+
|
59 |
+
$vendor_id = wcfm_get_vendor_id_by_post( $post_id );
|
60 |
+
|
61 |
+
if ( $vendor_id ) {
|
62 |
+
if ( apply_filters( 'wcfmmp_is_allow_sold_by', true, $vendor_id ) && wcfm_vendor_has_capability( $vendor_id, 'sold_by' ) ) {
|
63 |
+
|
64 |
+
global $WCFM, $WCFMmp;
|
65 |
+
|
66 |
+
$is_store_offline = get_user_meta( $vendor_id, '_wcfm_store_offline', true );
|
67 |
+
|
68 |
+
if ( ! $is_store_offline ) {
|
69 |
+
|
70 |
+
$store_name = wcfm_get_vendor_store_name( absint( $vendor_id ) );
|
71 |
+
$store_url = $WCFMmp->wcfmmp_store->get_shop_url();
|
72 |
+
|
73 |
+
$logo = '';
|
74 |
+
|
75 |
+
if ( apply_filters( 'wcfmmp_is_allow_sold_by_logo', true ) ) {
|
76 |
+
$store_logo = wcfm_get_vendor_store_logo_by_vendor( $vendor_id );
|
77 |
+
if ( ! $store_logo ) {
|
78 |
+
$store_logo = apply_filters( 'wcfmmp_store_default_logo', $WCFM->plugin_url . 'assets/images/wcfmmp-blue.png' );
|
79 |
+
}
|
80 |
+
$logo = '<img style="margin-right:4px;" width="24px" src="' . $store_logo . '" />';
|
81 |
+
}
|
82 |
+
|
83 |
+
$excerpt .= '<br><span style="margin-top:4px;display:block;" data-link="' . $store_url . '">' . $logo . $store_name . '</span>';
|
84 |
+
|
85 |
+
}
|
86 |
+
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
return $excerpt;
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
/*
|
97 |
+
* WCFM - WooCommerce Multivendor Marketplace update search page url for vendors shops
|
98 |
+
*/
|
99 |
+
public function wcfm_searchbox_markup( $markup, $params ) {
|
100 |
+
|
101 |
+
$store = $this->get_current_store();
|
102 |
+
|
103 |
+
if ( $store ) {
|
104 |
+
$markup = preg_replace( '/action="(.+?)"/i', 'action="' . $store->get_shop_url() . '"', $markup );
|
105 |
+
}
|
106 |
+
|
107 |
+
return $markup;
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
/*
|
112 |
+
* WCFM - WooCommerce Multivendor Marketplace limit search inside vendors shop
|
113 |
+
*/
|
114 |
+
public function wcfm_front_data_parameters( $params ) {
|
115 |
+
|
116 |
+
$store = $this->get_current_store();
|
117 |
+
|
118 |
+
if ( $store ) {
|
119 |
+
$params['data-tax'] = 'store:' . $store->get_id();
|
120 |
+
}
|
121 |
+
|
122 |
+
return $params;
|
123 |
+
|
124 |
+
}
|
125 |
+
|
126 |
+
/*
|
127 |
+
* WCFM - WooCommerce Multivendor Marketplace limit search inside vendoes shop
|
128 |
+
*/
|
129 |
+
public function wcfm_search_query_array( $query ) {
|
130 |
+
|
131 |
+
$vendor_id = false;
|
132 |
+
|
133 |
+
if ( isset( $_REQUEST['aws_tax'] ) && $_REQUEST['aws_tax'] && strpos( $_REQUEST['aws_tax'], 'store:' ) !== false ) {
|
134 |
+
$vendor_id = intval( str_replace( 'store:', '', $_REQUEST['aws_tax'] ) );
|
135 |
+
} else {
|
136 |
+
$store = $this->get_current_store();
|
137 |
+
if ( $store ) {
|
138 |
+
$vendor_id = $store->get_id();
|
139 |
+
}
|
140 |
+
}
|
141 |
+
|
142 |
+
if ( $vendor_id ) {
|
143 |
+
|
144 |
+
$store_products = get_posts( array(
|
145 |
+
'posts_per_page' => -1,
|
146 |
+
'fields' => 'ids',
|
147 |
+
'post_type' => 'product',
|
148 |
+
'post_status' => 'publish',
|
149 |
+
'ignore_sticky_posts' => true,
|
150 |
+
'suppress_filters' => true,
|
151 |
+
'no_found_rows' => 1,
|
152 |
+
'orderby' => 'ID',
|
153 |
+
'order' => 'DESC',
|
154 |
+
'lang' => '',
|
155 |
+
'author' => $vendor_id
|
156 |
+
) );
|
157 |
+
|
158 |
+
if ( $store_products ) {
|
159 |
+
$query['search'] .= " AND ( id IN ( " . implode( ',', $store_products ) . " ) )";
|
160 |
+
}
|
161 |
+
|
162 |
+
}
|
163 |
+
|
164 |
+
return $query;
|
165 |
+
|
166 |
+
}
|
167 |
+
|
168 |
+
/*
|
169 |
+
* Get current store object
|
170 |
+
*/
|
171 |
+
private function get_current_store() {
|
172 |
+
|
173 |
+
$store = false;
|
174 |
+
|
175 |
+
if ( function_exists('wcfmmp_is_store_page') && function_exists('wcfm_get_option') && wcfmmp_is_store_page() ) {
|
176 |
+
|
177 |
+
$wcfm_store_url = wcfm_get_option( 'wcfm_store_url', 'store' );
|
178 |
+
$wcfm_store_name = apply_filters( 'wcfmmp_store_query_var', get_query_var( $wcfm_store_url ) );
|
179 |
+
|
180 |
+
if ( $wcfm_store_name ) {
|
181 |
+
$seller_info = get_user_by( 'slug', $wcfm_store_name );
|
182 |
+
if ( $seller_info && function_exists( 'wcfmmp_get_store' ) ) {
|
183 |
+
$store_user = wcfmmp_get_store( $seller_info->ID );
|
184 |
+
if ( $store_user ) {
|
185 |
+
$store = $store_user;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
}
|
191 |
+
|
192 |
+
return $store;
|
193 |
+
|
194 |
+
}
|
195 |
+
|
196 |
+
}
|
197 |
+
|
198 |
endif;
|
includes/modules/class-aws-wholesale.php
CHANGED
@@ -1,226 +1,226 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Wholesale plugin support
|
4 |
-
*/
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit; // Exit if accessed directly.
|
8 |
-
}
|
9 |
-
|
10 |
-
if ( ! class_exists( 'AWS_Wholesale' ) ) :
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class
|
14 |
-
*/
|
15 |
-
class AWS_Wholesale {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Main AWS_Wholesale Instance
|
19 |
-
*
|
20 |
-
* Ensures only one instance of AWS_Wholesale is loaded or can be loaded.
|
21 |
-
*
|
22 |
-
* @static
|
23 |
-
* @return AWS_Wholesale - Main instance
|
24 |
-
*/
|
25 |
-
protected static $_instance = null;
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Main AWS_Wholesale Instance
|
29 |
-
*
|
30 |
-
* Ensures only one instance of AWS_Wholesale is loaded or can be loaded.
|
31 |
-
*
|
32 |
-
* @static
|
33 |
-
* @return AWS_Wholesale - Main instance
|
34 |
-
*/
|
35 |
-
public static function instance() {
|
36 |
-
if ( is_null( self::$_instance ) ) {
|
37 |
-
self::$_instance = new self();
|
38 |
-
}
|
39 |
-
return self::$_instance;
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Constructor
|
44 |
-
*/
|
45 |
-
public function __construct() {
|
46 |
-
|
47 |
-
add_filter( 'aws_exclude_products', array( $this, 'exclude_products' ) );
|
48 |
-
|
49 |
-
add_filter( 'aws_search_tax_exclude', array( $this, 'exclude_tax' ), 10, 2 );
|
50 |
-
|
51 |
-
}
|
52 |
-
|
53 |
-
/*
|
54 |
-
* Restrict products
|
55 |
-
*/
|
56 |
-
public function exclude_products( $products_ids ) {
|
57 |
-
|
58 |
-
$excluded = $this->get_excluded_products();
|
59 |
-
$excluded_by_cat = $this->get_excluded_products_by_cat();
|
60 |
-
|
61 |
-
if ( ! empty( $excluded ) || ! empty( $excluded_by_cat ) ) {
|
62 |
-
$products_ids = array_merge( $products_ids, $excluded, $excluded_by_cat );
|
63 |
-
}
|
64 |
-
|
65 |
-
return $products_ids;
|
66 |
-
|
67 |
-
}
|
68 |
-
|
69 |
-
/*
|
70 |
-
* Restrict product_cat taxonomy
|
71 |
-
*/
|
72 |
-
public function exclude_tax( $excludes_array, $taxonomy ) {
|
73 |
-
|
74 |
-
if ( array_search( 'product_cat', $taxonomy ) !== false ) {
|
75 |
-
|
76 |
-
$user_role = $this->get_current_user();
|
77 |
-
$product_cat_wholesale_role_filter = get_option( 'wwpp_option_product_cat_wholesale_role_filter' );
|
78 |
-
$categories_exclude_list = array();
|
79 |
-
|
80 |
-
if ( is_array( $product_cat_wholesale_role_filter ) && ! empty( $product_cat_wholesale_role_filter ) && $user_role !== 'administrator' ) {
|
81 |
-
foreach( $product_cat_wholesale_role_filter as $term_id => $term_roles ) {
|
82 |
-
if ( array_search( $user_role, $term_roles ) === false ) {
|
83 |
-
$categories_exclude_list[] = $term_id;
|
84 |
-
}
|
85 |
-
}
|
86 |
-
}
|
87 |
-
|
88 |
-
$excludes_array = array_merge( $excludes_array, $categories_exclude_list );
|
89 |
-
|
90 |
-
}
|
91 |
-
|
92 |
-
return $excludes_array;
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
/*
|
97 |
-
* Get current user role
|
98 |
-
*/
|
99 |
-
private function get_current_user() {
|
100 |
-
|
101 |
-
$user_role = 'all';
|
102 |
-
if ( is_user_logged_in() ) {
|
103 |
-
$user = wp_get_current_user();
|
104 |
-
$roles = ( array ) $user->roles;
|
105 |
-
$user_role = $roles[0];
|
106 |
-
}
|
107 |
-
|
108 |
-
return $user_role;
|
109 |
-
|
110 |
-
}
|
111 |
-
|
112 |
-
/*
|
113 |
-
* Get excluded products by category
|
114 |
-
*/
|
115 |
-
private function get_excluded_products_by_cat() {
|
116 |
-
|
117 |
-
$user_role = $this->get_current_user();
|
118 |
-
|
119 |
-
$products_ids = array();
|
120 |
-
$product_cat_wholesale_role_filter = get_option( 'wwpp_option_product_cat_wholesale_role_filter' );
|
121 |
-
$categories_exclude_list = array();
|
122 |
-
|
123 |
-
if ( is_array( $product_cat_wholesale_role_filter ) && ! empty( $product_cat_wholesale_role_filter ) && $user_role !== 'administrator' ) {
|
124 |
-
foreach( $product_cat_wholesale_role_filter as $term_id => $term_roles ) {
|
125 |
-
if ( array_search( $user_role, $term_roles ) === false ) {
|
126 |
-
$categories_exclude_list[] = $term_id;
|
127 |
-
}
|
128 |
-
}
|
129 |
-
}
|
130 |
-
|
131 |
-
if ( $categories_exclude_list && ! empty( $categories_exclude_list ) ) {
|
132 |
-
|
133 |
-
$restricted_products = get_posts( array(
|
134 |
-
'posts_per_page' => -1,
|
135 |
-
'fields' => 'ids',
|
136 |
-
'post_type' => array( 'product', 'product_variation' ),
|
137 |
-
'post_status' => 'publish',
|
138 |
-
'ignore_sticky_posts' => true,
|
139 |
-
'suppress_filters' => true,
|
140 |
-
'has_password' => false,
|
141 |
-
'no_found_rows' => 1,
|
142 |
-
'orderby' => 'ID',
|
143 |
-
'order' => 'DESC',
|
144 |
-
'lang' => '',
|
145 |
-
'tax_query' => array(
|
146 |
-
'relation' => 'OR',
|
147 |
-
array(
|
148 |
-
'taxonomy' => 'product_cat',
|
149 |
-
'field' => 'id',
|
150 |
-
'terms' => $categories_exclude_list,
|
151 |
-
),
|
152 |
-
),
|
153 |
-
) );
|
154 |
-
|
155 |
-
if ( $restricted_products ) {
|
156 |
-
$products_ids = $restricted_products;
|
157 |
-
}
|
158 |
-
|
159 |
-
}
|
160 |
-
|
161 |
-
return $products_ids;
|
162 |
-
|
163 |
-
}
|
164 |
-
|
165 |
-
/*
|
166 |
-
* Get excluded products
|
167 |
-
*/
|
168 |
-
private function get_excluded_products() {
|
169 |
-
|
170 |
-
$user_role = $this->get_current_user();
|
171 |
-
|
172 |
-
$all_registered_wholesale_roles = unserialize( get_option( 'wwp_options_registered_custom_roles' ) );
|
173 |
-
if ( ! is_array( $all_registered_wholesale_roles ) ) {
|
174 |
-
$all_registered_wholesale_roles = array();
|
175 |
-
}
|
176 |
-
|
177 |
-
$products_ids = array();
|
178 |
-
$restricted_products = get_posts( array(
|
179 |
-
'posts_per_page' => -1,
|
180 |
-
'fields' => 'ids',
|
181 |
-
'post_type' => array( 'product', 'product_variation' ),
|
182 |
-
'post_status' => 'publish',
|
183 |
-
'ignore_sticky_posts' => true,
|
184 |
-
'suppress_filters' => true,
|
185 |
-
'has_password' => false,
|
186 |
-
'no_found_rows' => 1,
|
187 |
-
'orderby' => 'ID',
|
188 |
-
'order' => 'DESC',
|
189 |
-
'lang' => '',
|
190 |
-
'meta_query' => array(
|
191 |
-
array(
|
192 |
-
'key' => 'wwpp_product_wholesale_visibility_filter',
|
193 |
-
'compare' => 'EXISTS',
|
194 |
-
)
|
195 |
-
)
|
196 |
-
) );
|
197 |
-
|
198 |
-
if ( $restricted_products ) {
|
199 |
-
foreach ($restricted_products as $restricted_product_id) {
|
200 |
-
|
201 |
-
$custom_fields = get_post_meta( $restricted_product_id, 'wwpp_product_wholesale_visibility_filter' );
|
202 |
-
$custom_price = get_post_meta( $restricted_product_id, 'wholesale_customer_wholesale_price' );
|
203 |
-
|
204 |
-
if ( $custom_fields && ! empty( $custom_fields ) && $custom_fields[0] !== 'all' && $custom_fields[0] !== $user_role ) {
|
205 |
-
$products_ids[] = $restricted_product_id;
|
206 |
-
continue;
|
207 |
-
}
|
208 |
-
|
209 |
-
if ( is_user_logged_in() && !empty( $all_registered_wholesale_roles ) && isset( $all_registered_wholesale_roles[$user_role] )
|
210 |
-
&& get_option( 'wwpp_settings_only_show_wholesale_products_to_wholesale_users', false ) === 'yes' && ! $custom_price ) {
|
211 |
-
$products_ids[] = $restricted_product_id;
|
212 |
-
continue;
|
213 |
-
}
|
214 |
-
|
215 |
-
}
|
216 |
-
}
|
217 |
-
|
218 |
-
return $products_ids;
|
219 |
-
|
220 |
-
}
|
221 |
-
|
222 |
-
}
|
223 |
-
|
224 |
-
endif;
|
225 |
-
|
226 |
AWS_Wholesale::instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Wholesale plugin support
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly.
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! class_exists( 'AWS_Wholesale' ) ) :
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class
|
14 |
+
*/
|
15 |
+
class AWS_Wholesale {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Main AWS_Wholesale Instance
|
19 |
+
*
|
20 |
+
* Ensures only one instance of AWS_Wholesale is loaded or can be loaded.
|
21 |
+
*
|
22 |
+
* @static
|
23 |
+
* @return AWS_Wholesale - Main instance
|
24 |
+
*/
|
25 |
+
protected static $_instance = null;
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Main AWS_Wholesale Instance
|
29 |
+
*
|
30 |
+
* Ensures only one instance of AWS_Wholesale is loaded or can be loaded.
|
31 |
+
*
|
32 |
+
* @static
|
33 |
+
* @return AWS_Wholesale - Main instance
|
34 |
+
*/
|
35 |
+
public static function instance() {
|
36 |
+
if ( is_null( self::$_instance ) ) {
|
37 |
+
self::$_instance = new self();
|
38 |
+
}
|
39 |
+
return self::$_instance;
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Constructor
|
44 |
+
*/
|
45 |
+
public function __construct() {
|
46 |
+
|
47 |
+
add_filter( 'aws_exclude_products', array( $this, 'exclude_products' ) );
|
48 |
+
|
49 |
+
add_filter( 'aws_search_tax_exclude', array( $this, 'exclude_tax' ), 10, 2 );
|
50 |
+
|
51 |
+
}
|
52 |
+
|
53 |
+
/*
|
54 |
+
* Restrict products
|
55 |
+
*/
|
56 |
+
public function exclude_products( $products_ids ) {
|
57 |
+
|
58 |
+
$excluded = $this->get_excluded_products();
|
59 |
+
$excluded_by_cat = $this->get_excluded_products_by_cat();
|
60 |
+
|
61 |
+
if ( ! empty( $excluded ) || ! empty( $excluded_by_cat ) ) {
|
62 |
+
$products_ids = array_merge( $products_ids, $excluded, $excluded_by_cat );
|
63 |
+
}
|
64 |
+
|
65 |
+
return $products_ids;
|
66 |
+
|
67 |
+
}
|
68 |
+
|
69 |
+
/*
|
70 |
+
* Restrict product_cat taxonomy
|
71 |
+
*/
|
72 |
+
public function exclude_tax( $excludes_array, $taxonomy ) {
|
73 |
+
|
74 |
+
if ( array_search( 'product_cat', $taxonomy ) !== false ) {
|
75 |
+
|
76 |
+
$user_role = $this->get_current_user();
|
77 |
+
$product_cat_wholesale_role_filter = get_option( 'wwpp_option_product_cat_wholesale_role_filter' );
|
78 |
+
$categories_exclude_list = array();
|
79 |
+
|
80 |
+
if ( is_array( $product_cat_wholesale_role_filter ) && ! empty( $product_cat_wholesale_role_filter ) && $user_role !== 'administrator' ) {
|
81 |
+
foreach( $product_cat_wholesale_role_filter as $term_id => $term_roles ) {
|
82 |
+
if ( array_search( $user_role, $term_roles ) === false ) {
|
83 |
+
$categories_exclude_list[] = $term_id;
|
84 |
+
}
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
$excludes_array = array_merge( $excludes_array, $categories_exclude_list );
|
89 |
+
|
90 |
+
}
|
91 |
+
|
92 |
+
return $excludes_array;
|
93 |
+
|
94 |
+
}
|
95 |
+
|
96 |
+
/*
|
97 |
+
* Get current user role
|
98 |
+
*/
|
99 |
+
private function get_current_user() {
|
100 |
+
|
101 |
+
$user_role = 'all';
|
102 |
+
if ( is_user_logged_in() ) {
|
103 |
+
$user = wp_get_current_user();
|
104 |
+
$roles = ( array ) $user->roles;
|
105 |
+
$user_role = $roles[0];
|
106 |
+
}
|
107 |
+
|
108 |
+
return $user_role;
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
/*
|
113 |
+
* Get excluded products by category
|
114 |
+
*/
|
115 |
+
private function get_excluded_products_by_cat() {
|
116 |
+
|
117 |
+
$user_role = $this->get_current_user();
|
118 |
+
|
119 |
+
$products_ids = array();
|
120 |
+
$product_cat_wholesale_role_filter = get_option( 'wwpp_option_product_cat_wholesale_role_filter' );
|
121 |
+
$categories_exclude_list = array();
|
122 |
+
|
123 |
+
if ( is_array( $product_cat_wholesale_role_filter ) && ! empty( $product_cat_wholesale_role_filter ) && $user_role !== 'administrator' ) {
|
124 |
+
foreach( $product_cat_wholesale_role_filter as $term_id => $term_roles ) {
|
125 |
+
if ( array_search( $user_role, $term_roles ) === false ) {
|
126 |
+
$categories_exclude_list[] = $term_id;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
+
|
131 |
+
if ( $categories_exclude_list && ! empty( $categories_exclude_list ) ) {
|
132 |
+
|
133 |
+
$restricted_products = get_posts( array(
|
134 |
+
'posts_per_page' => -1,
|
135 |
+
'fields' => 'ids',
|
136 |
+
'post_type' => array( 'product', 'product_variation' ),
|
137 |
+
'post_status' => 'publish',
|
138 |
+
'ignore_sticky_posts' => true,
|
139 |
+
'suppress_filters' => true,
|
140 |
+
'has_password' => false,
|
141 |
+
'no_found_rows' => 1,
|
142 |
+
'orderby' => 'ID',
|
143 |
+
'order' => 'DESC',
|
144 |
+
'lang' => '',
|
145 |
+
'tax_query' => array(
|
146 |
+
'relation' => 'OR',
|
147 |
+
array(
|
148 |
+
'taxonomy' => 'product_cat',
|
149 |
+
'field' => 'id',
|
150 |
+
'terms' => $categories_exclude_list,
|
151 |
+
),
|
152 |
+
),
|
153 |
+
) );
|
154 |
+
|
155 |
+
if ( $restricted_products ) {
|
156 |
+
$products_ids = $restricted_products;
|
157 |
+
}
|
158 |
+
|
159 |
+
}
|
160 |
+
|
161 |
+
return $products_ids;
|
162 |
+
|
163 |
+
}
|
164 |
+
|
165 |
+
/*
|
166 |
+
* Get excluded products
|
167 |
+
*/
|
168 |
+
private function get_excluded_products() {
|
169 |
+
|
170 |
+
$user_role = $this->get_current_user();
|
171 |
+
|
172 |
+
$all_registered_wholesale_roles = unserialize( get_option( 'wwp_options_registered_custom_roles' ) );
|
173 |
+
if ( ! is_array( $all_registered_wholesale_roles ) ) {
|
174 |
+
$all_registered_wholesale_roles = array();
|
175 |
+
}
|
176 |
+
|
177 |
+
$products_ids = array();
|
178 |
+
$restricted_products = get_posts( array(
|
179 |
+
'posts_per_page' => -1,
|
180 |
+
'fields' => 'ids',
|
181 |
+
'post_type' => array( 'product', 'product_variation' ),
|
182 |
+
'post_status' => 'publish',
|
183 |
+
'ignore_sticky_posts' => true,
|
184 |
+
'suppress_filters' => true,
|
185 |
+
'has_password' => false,
|
186 |
+
'no_found_rows' => 1,
|
187 |
+
'orderby' => 'ID',
|
188 |
+
'order' => 'DESC',
|
189 |
+
'lang' => '',
|
190 |
+
'meta_query' => array(
|
191 |
+
array(
|
192 |
+
'key' => 'wwpp_product_wholesale_visibility_filter',
|
193 |
+
'compare' => 'EXISTS',
|
194 |
+
)
|
195 |
+
)
|
196 |
+
) );
|
197 |
+
|
198 |
+
if ( $restricted_products ) {
|
199 |
+
foreach ($restricted_products as $restricted_product_id) {
|
200 |
+
|
201 |
+
$custom_fields = get_post_meta( $restricted_product_id, 'wwpp_product_wholesale_visibility_filter' );
|
202 |
+
$custom_price = get_post_meta( $restricted_product_id, 'wholesale_customer_wholesale_price' );
|
203 |
+
|
204 |
+
if ( $custom_fields && ! empty( $custom_fields ) && $custom_fields[0] !== 'all' && $custom_fields[0] !== $user_role ) {
|
205 |
+
$products_ids[] = $restricted_product_id;
|
206 |
+
continue;
|
207 |
+
}
|
208 |
+
|
209 |
+
if ( is_user_logged_in() && !empty( $all_registered_wholesale_roles ) && isset( $all_registered_wholesale_roles[$user_role] )
|
210 |
+
&& get_option( 'wwpp_settings_only_show_wholesale_products_to_wholesale_users', false ) === 'yes' && ! $custom_price ) {
|
211 |
+
$products_ids[] = $restricted_product_id;
|
212 |
+
continue;
|
213 |
+
}
|
214 |
+
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return $products_ids;
|
219 |
+
|
220 |
+
}
|
221 |
+
|
222 |
+
}
|
223 |
+
|
224 |
+
endif;
|
225 |
+
|
226 |
AWS_Wholesale::instance();
|
includes/modules/class-aws-woof-filter.php
CHANGED
@@ -1,165 +1,165 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* AWS plugin WOOF - WooCommerce Products Filter integration
|
5 |
-
*/
|
6 |
-
|
7 |
-
if (!defined('ABSPATH')) {
|
8 |
-
exit; // Exit if accessed directly.
|
9 |
-
}
|
10 |
-
|
11 |
-
if (!class_exists('AWS_Woof_Filter_Init')) :
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Class for main plugin functions
|
15 |
-
*/
|
16 |
-
class AWS_Woof_Filter_Init {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var AWS_Woof_Filter_Init The single instance of the class
|
20 |
-
*/
|
21 |
-
protected static $_instance = null;
|
22 |
-
|
23 |
-
private $data = array();
|
24 |
-
|
25 |
-
/**
|
26 |
-
* Main AWS_Woof_Filter_Init Instance
|
27 |
-
*
|
28 |
-
* Ensures only one instance of AWS_Woof_Filter_Init is loaded or can be loaded.
|
29 |
-
*
|
30 |
-
* @static
|
31 |
-
* @return AWS_Woof_Filter_Init - Main instance
|
32 |
-
*/
|
33 |
-
public static function instance()
|
34 |
-
{
|
35 |
-
if (is_null(self::$_instance)) {
|
36 |
-
self::$_instance = new self();
|
37 |
-
}
|
38 |
-
return self::$_instance;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* Constructor
|
43 |
-
*/
|
44 |
-
public function __construct() {
|
45 |
-
|
46 |
-
add_filter( 'aws_search_page_filters', array( $this, 'woof_search_page_filters' ) );
|
47 |
-
|
48 |
-
add_filter( 'aws_searchpage_enabled', array( $this, 'woof_searchpage_enabled' ), 1, 2 );
|
49 |
-
|
50 |
-
add_filter( 'aws_search_page_query', array( $this, 'woof_aws_searchpage_query' ) );
|
51 |
-
|
52 |
-
add_filter( 'woof_text_search_like_option', array( $this, 'woof_text_search_like_option' ) );
|
53 |
-
|
54 |
-
add_filter( 'woof_get_request_data', array( $this, 'woof_get_request_data' ), 999 );
|
55 |
-
|
56 |
-
add_filter( 'posts_where_request', array( $this, 'posts_where_request' ), 1 );
|
57 |
-
|
58 |
-
add_filter( 'aws_search_page_custom_data', array( $this, 'aws_search_page_custom_data' ) );
|
59 |
-
|
60 |
-
}
|
61 |
-
|
62 |
-
/*
|
63 |
-
* Filter products
|
64 |
-
*/
|
65 |
-
public function woof_search_page_filters( $filters ) {
|
66 |
-
|
67 |
-
if ( isset( $_GET['swoof'] ) || isset( $_GET['woof_text'] ) ) {
|
68 |
-
foreach ( $_GET as $key => $param ) {
|
69 |
-
|
70 |
-
if ( $key === 'product_cat' || $key === 'product_tag' || strpos($key, 'pa_') !== false ) {
|
71 |
-
|
72 |
-
$slugs_arr = explode(',', $param);
|
73 |
-
$term_ids = array();
|
74 |
-
|
75 |
-
if ( $slugs_arr ) {
|
76 |
-
foreach( $slugs_arr as $slug ) {
|
77 |
-
$term = get_term_by('slug', $slug, $key );
|
78 |
-
if ( $term ) {
|
79 |
-
$term_ids[] = $term->term_id;
|
80 |
-
}
|
81 |
-
}
|
82 |
-
}
|
83 |
-
|
84 |
-
$operator = 'OR';
|
85 |
-
$filters['tax'][$key] = array(
|
86 |
-
'terms' => $term_ids,
|
87 |
-
'operator' => $operator
|
88 |
-
);
|
89 |
-
}
|
90 |
-
|
91 |
-
}
|
92 |
-
}
|
93 |
-
|
94 |
-
return $filters;
|
95 |
-
|
96 |
-
}
|
97 |
-
|
98 |
-
/*
|
99 |
-
* Enable aws search
|
100 |
-
*/
|
101 |
-
public function woof_searchpage_enabled( $enabled, $query ) {
|
102 |
-
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' && isset( $_GET['type_aws'] ) && isset( $_GET['woof_text'] ) && ! isset( $_REQUEST['woof_dyn_recount_going'] ) && ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ) {
|
103 |
-
return true;
|
104 |
-
}
|
105 |
-
return $enabled;
|
106 |
-
}
|
107 |
-
|
108 |
-
/*
|
109 |
-
* WOOF - WooCommerce Products Filter: set search query string
|
110 |
-
*/
|
111 |
-
public function woof_aws_searchpage_query( $search_query ) {
|
112 |
-
if ( ! $search_query && isset( $_GET['woof_text'] ) ) {
|
113 |
-
return $_GET['woof_text'];
|
114 |
-
}
|
115 |
-
return $search_query;
|
116 |
-
}
|
117 |
-
|
118 |
-
/*
|
119 |
-
* Enable text search feature
|
120 |
-
*/
|
121 |
-
public function woof_text_search_like_option( $enable ) {
|
122 |
-
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' && isset( $_GET['type_aws'] ) ) {
|
123 |
-
return true;
|
124 |
-
}
|
125 |
-
return $enable;
|
126 |
-
}
|
127 |
-
|
128 |
-
/*
|
129 |
-
* Add woof_text query if it is not exists
|
130 |
-
*/
|
131 |
-
public function woof_get_request_data( $request ) {
|
132 |
-
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' && isset( $_GET['type_aws'] ) && isset( $_GET['s'] ) && ! isset( $_GET['woof_text'] ) ) {
|
133 |
-
$request['woof_text'] = $request['s'];
|
134 |
-
}
|
135 |
-
if ( isset( $_REQUEST['woof_dyn_recount_going'] ) ) {
|
136 |
-
return '';
|
137 |
-
}
|
138 |
-
return $request;
|
139 |
-
}
|
140 |
-
|
141 |
-
/*
|
142 |
-
* Set WHERE request for filters counter
|
143 |
-
*/
|
144 |
-
public function posts_where_request( $where ) {
|
145 |
-
if ( isset( $_REQUEST['woof_dyn_recount_going'] ) && $this->data && isset( $this->data['ids'] ) ) {
|
146 |
-
global $wpdb;
|
147 |
-
$where .= " AND {$wpdb->posts}.ID IN ( " . implode( ',', $this->data['ids'] ) . " ) ";
|
148 |
-
}
|
149 |
-
return $where;
|
150 |
-
}
|
151 |
-
|
152 |
-
/*
|
153 |
-
* Set search query custom data
|
154 |
-
*/
|
155 |
-
public function aws_search_page_custom_data( $data ) {
|
156 |
-
$this->data = $data;
|
157 |
-
return $data;
|
158 |
-
}
|
159 |
-
|
160 |
-
}
|
161 |
-
|
162 |
-
|
163 |
-
endif;
|
164 |
-
|
165 |
AWS_Woof_Filter_Init::instance();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* AWS plugin WOOF - WooCommerce Products Filter integration
|
5 |
+
*/
|
6 |
+
|
7 |
+
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly.
|
9 |
+
}
|
10 |
+
|
11 |
+
if (!class_exists('AWS_Woof_Filter_Init')) :
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class for main plugin functions
|
15 |
+
*/
|
16 |
+
class AWS_Woof_Filter_Init {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var AWS_Woof_Filter_Init The single instance of the class
|
20 |
+
*/
|
21 |
+
protected static $_instance = null;
|
22 |
+
|
23 |
+
private $data = array();
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Main AWS_Woof_Filter_Init Instance
|
27 |
+
*
|
28 |
+
* Ensures only one instance of AWS_Woof_Filter_Init is loaded or can be loaded.
|
29 |
+
*
|
30 |
+
* @static
|
31 |
+
* @return AWS_Woof_Filter_Init - Main instance
|
32 |
+
*/
|
33 |
+
public static function instance()
|
34 |
+
{
|
35 |
+
if (is_null(self::$_instance)) {
|
36 |
+
self::$_instance = new self();
|
37 |
+
}
|
38 |
+
return self::$_instance;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Constructor
|
43 |
+
*/
|
44 |
+
public function __construct() {
|
45 |
+
|
46 |
+
add_filter( 'aws_search_page_filters', array( $this, 'woof_search_page_filters' ) );
|
47 |
+
|
48 |
+
add_filter( 'aws_searchpage_enabled', array( $this, 'woof_searchpage_enabled' ), 1, 2 );
|
49 |
+
|
50 |
+
add_filter( 'aws_search_page_query', array( $this, 'woof_aws_searchpage_query' ) );
|
51 |
+
|
52 |
+
add_filter( 'woof_text_search_like_option', array( $this, 'woof_text_search_like_option' ) );
|
53 |
+
|
54 |
+
add_filter( 'woof_get_request_data', array( $this, 'woof_get_request_data' ), 999 );
|
55 |
+
|
56 |
+
add_filter( 'posts_where_request', array( $this, 'posts_where_request' ), 1 );
|
57 |
+
|
58 |
+
add_filter( 'aws_search_page_custom_data', array( $this, 'aws_search_page_custom_data' ) );
|
59 |
+
|
60 |
+
}
|
61 |
+
|
62 |
+
/*
|
63 |
+
* Filter products
|
64 |
+
*/
|
65 |
+
public function woof_search_page_filters( $filters ) {
|
66 |
+
|
67 |
+
if ( isset( $_GET['swoof'] ) || isset( $_GET['woof_text'] ) ) {
|
68 |
+
foreach ( $_GET as $key => $param ) {
|
69 |
+
|
70 |
+
if ( $key === 'product_cat' || $key === 'product_tag' || strpos($key, 'pa_') !== false ) {
|
71 |
+
|
72 |
+
$slugs_arr = explode(',', $param);
|
73 |
+
$term_ids = array();
|
74 |
+
|
75 |
+
if ( $slugs_arr ) {
|
76 |
+
foreach( $slugs_arr as $slug ) {
|
77 |
+
$term = get_term_by('slug', $slug, $key );
|
78 |
+
if ( $term ) {
|
79 |
+
$term_ids[] = $term->term_id;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
|
84 |
+
$operator = 'OR';
|
85 |
+
$filters['tax'][$key] = array(
|
86 |
+
'terms' => $term_ids,
|
87 |
+
'operator' => $operator
|
88 |
+
);
|
89 |
+
}
|
90 |
+
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
return $filters;
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
/*
|
99 |
+
* Enable aws search
|
100 |
+
*/
|
101 |
+
public function woof_searchpage_enabled( $enabled, $query ) {
|
102 |
+
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' && isset( $_GET['type_aws'] ) && isset( $_GET['woof_text'] ) && ! isset( $_REQUEST['woof_dyn_recount_going'] ) && ( $query->get( 'post_type' ) && is_string( $query->get( 'post_type' ) ) && $query->get( 'post_type' ) === 'product' ) ) {
|
103 |
+
return true;
|
104 |
+
}
|
105 |
+
return $enabled;
|
106 |
+
}
|
107 |
+
|
108 |
+
/*
|
109 |
+
* WOOF - WooCommerce Products Filter: set search query string
|
110 |
+
*/
|
111 |
+
public function woof_aws_searchpage_query( $search_query ) {
|
112 |
+
if ( ! $search_query && isset( $_GET['woof_text'] ) ) {
|
113 |
+
return $_GET['woof_text'];
|
114 |
+
}
|
115 |
+
return $search_query;
|
116 |
+
}
|
117 |
+
|
118 |
+
/*
|
119 |
+
* Enable text search feature
|
120 |
+
*/
|
121 |
+
public function woof_text_search_like_option( $enable ) {
|
122 |
+
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' && isset( $_GET['type_aws'] ) ) {
|
123 |
+
return true;
|
124 |
+
}
|
125 |
+
return $enable;
|
126 |
+
}
|
127 |
+
|
128 |
+
/*
|
129 |
+
* Add woof_text query if it is not exists
|
130 |
+
*/
|
131 |
+
public function woof_get_request_data( $request ) {
|
132 |
+
if ( isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' && isset( $_GET['type_aws'] ) && isset( $_GET['s'] ) && ! isset( $_GET['woof_text'] ) ) {
|
133 |
+
$request['woof_text'] = $request['s'];
|
134 |
+
}
|
135 |
+
if ( isset( $_REQUEST['woof_dyn_recount_going'] ) ) {
|
136 |
+
return '';
|
137 |
+
}
|
138 |
+
return $request;
|
139 |
+
}
|
140 |
+
|
141 |
+
/*
|
142 |
+
* Set WHERE request for filters counter
|
143 |
+
*/
|
144 |
+
public function posts_where_request( $where ) {
|
145 |
+
if ( isset( $_REQUEST['woof_dyn_recount_going'] ) && $this->data && isset( $this->data['ids'] ) ) {
|
146 |
+
global $wpdb;
|
147 |
+
$where .= " AND {$wpdb->posts}.ID IN ( " . implode( ',', $this->data['ids'] ) . " ) ";
|
148 |
+
}
|
149 |
+
return $where;
|
150 |
+
}
|
151 |
+
|
152 |
+
/*
|
153 |
+
* Set search query custom data
|
154 |
+
*/
|
155 |
+
public function aws_search_page_custom_data( $data ) {
|
156 |
+
$this->data = $data;
|
157 |
+
return $data;
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
endif;
|
164 |
+
|
165 |
AWS_Woof_Filter_Init::instance();
|
includes/modules/divi/class-divi-aws-module.php
CHANGED
@@ -1,52 +1,52 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
add_action('et_builder_ready', 'aws_divi_register_modules');
|
4 |
-
function aws_divi_register_modules() {
|
5 |
-
|
6 |
-
if ( class_exists( 'ET_Builder_Module' ) ):
|
7 |
-
|
8 |
-
class Divi_AWS_Module extends ET_Builder_Module {
|
9 |
-
|
10 |
-
public $slug = 'aws';
|
11 |
-
public $vb_support = 'partial';
|
12 |
-
|
13 |
-
public function init() {
|
14 |
-
$this->name = esc_html__( 'Advanced Woo Search', 'advanced-woo-search' );
|
15 |
-
}
|
16 |
-
|
17 |
-
public function get_fields() {
|
18 |
-
|
19 |
-
wp_enqueue_style(
|
20 |
-
'aws-divi',
|
21 |
-
AWS_URL . '/includes/modules/divi/divi.css', array(), AWS_VERSION
|
22 |
-
);
|
23 |
-
|
24 |
-
return array(
|
25 |
-
'placeholder' => array(
|
26 |
-
'label' => esc_html__( 'Placeholder', 'advanced-woo-search' ),
|
27 |
-
'type' => 'text',
|
28 |
-
'option_category' => 'basic_option',
|
29 |
-
'description' => esc_html__( 'Add placeholder text or leave empty to use default.', 'advanced-woo-search' ),
|
30 |
-
'toggle_slug' => 'main_content',
|
31 |
-
),
|
32 |
-
);
|
33 |
-
}
|
34 |
-
|
35 |
-
public function render( $unprocessed_props, $content = null, $render_slug ) {
|
36 |
-
if ( function_exists( 'aws_get_search_form' ) ) {
|
37 |
-
$search_form = aws_get_search_form( false );
|
38 |
-
if ( $this->props['placeholder'] ) {
|
39 |
-
$search_form = preg_replace( '/placeholder="([\S\s]*?)"/i', 'placeholder="' . $this->props['placeholder'] . '"', $search_form );
|
40 |
-
}
|
41 |
-
return $search_form;
|
42 |
-
}
|
43 |
-
return '';
|
44 |
-
}
|
45 |
-
|
46 |
-
}
|
47 |
-
|
48 |
-
new Divi_AWS_Module;
|
49 |
-
|
50 |
-
endif;
|
51 |
-
|
52 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
add_action('et_builder_ready', 'aws_divi_register_modules');
|
4 |
+
function aws_divi_register_modules() {
|
5 |
+
|
6 |
+
if ( class_exists( 'ET_Builder_Module' ) ):
|
7 |
+
|
8 |
+
class Divi_AWS_Module extends ET_Builder_Module {
|
9 |
+
|
10 |
+
public $slug = 'aws';
|
11 |
+
public $vb_support = 'partial';
|
12 |
+
|
13 |
+
public function init() {
|
14 |
+
$this->name = esc_html__( 'Advanced Woo Search', 'advanced-woo-search' );
|
15 |
+
}
|
16 |
+
|
17 |
+
public function get_fields() {
|
18 |
+
|
19 |
+
wp_enqueue_style(
|
20 |
+
'aws-divi',
|
21 |
+
AWS_URL . '/includes/modules/divi/divi.css', array(), AWS_VERSION
|
22 |
+
);
|
23 |
+
|
24 |
+
return array(
|
25 |
+
'placeholder' => array(
|
26 |
+
'label' => esc_html__( 'Placeholder', 'advanced-woo-search' ),
|
27 |
+
'type' => 'text',
|
28 |
+
'option_category' => 'basic_option',
|
29 |
+
'description' => esc_html__( 'Add placeholder text or leave empty to use default.', 'advanced-woo-search' ),
|
30 |
+
'toggle_slug' => 'main_content',
|
31 |
+
),
|
32 |
+
);
|
33 |
+
}
|
34 |
+
|
35 |
+
public function render( $unprocessed_props, $content = null, $render_slug ) {
|
36 |
+
if ( function_exists( 'aws_get_search_form' ) ) {
|
37 |
+
$search_form = aws_get_search_form( false );
|
38 |
+
if ( $this->props['placeholder'] ) {
|
39 |
+
$search_form = preg_replace( '/placeholder="([\S\s]*?)"/i', 'placeholder="' . $this->props['placeholder'] . '"', $search_form );
|
40 |
+
}
|
41 |
+
return $search_form;
|
42 |
+
}
|
43 |
+
return '';
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
new Divi_AWS_Module;
|
49 |
+
|
50 |
+
endif;
|
51 |
+
|
52 |
}
|
includes/modules/divi/divi.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
.et-db #et-boc .et-l .et-fb-modules-list .aws:before {
|
2 |
-
content: "}";
|
3 |
-
color: #b76d9e;
|
4 |
}
|
1 |
+
.et-db #et-boc .et-l .et-fb-modules-list .aws:before {
|
2 |
+
content: "}";
|
3 |
+
color: #b76d9e;
|
4 |
}
|
includes/modules/elementor-widget/class-elementor-aws-init.php
CHANGED
@@ -1,203 +1,203 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* AWS plugin elementor integrations init
|
4 |
-
*/
|
5 |
-
|
6 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
-
exit; // Exit if accessed directly.
|
8 |
-
}
|
9 |
-
|
10 |
-
if ( ! class_exists( 'AWS_Elementor_Init' ) ) :
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Class for main plugin functions
|
14 |
-
*/
|
15 |
-
class AWS_Elementor_Init {
|
16 |
-
|
17 |
-
/**
|
18 |
-
* @var AWS_Elementor_Init The single instance of the class
|
19 |
-
*/
|
20 |
-
protected static $_instance = null;
|
21 |
-
|
22 |
-
/**
|
23 |
-
* Main AWS_Elementor_Init Instance
|
24 |
-
*
|
25 |
-
* Ensures only one instance of AWS_Elementor_Init is loaded or can be loaded.
|
26 |
-
*
|
27 |
-
* @static
|
28 |
-
* @return AWS_Elementor_Init - Main instance
|
29 |
-
*/
|
30 |
-
public static function instance() {
|
31 |
-
if ( is_null( self::$_instance ) ) {
|
32 |
-
self::$_instance = new self();
|
33 |
-
}
|
34 |
-
return self::$_instance;
|
35 |
-
}
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Constructor
|
39 |
-
*/
|
40 |
-
public function __construct() {
|
41 |
-
|
42 |
-
add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_elementor_widgets' ) );
|
43 |
-
add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'filter_editor_styles' ) );
|
44 |
-
add_action( 'elementor/preview/enqueue_styles', array( $this, 'filter_editor_styles' ) );
|
45 |
-
|
46 |
-
if ( AWS()->get_settings( 'seamless' ) === 'true' ) {
|
47 |
-
|
48 |
-
add_filter( 'elementor/widget/render_content', array( $this, 'elementor_render_content' ), 10, 2 );
|
49 |
-
|
50 |
-
// Elementor pro
|
51 |
-
if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) {
|
52 |
-
add_action( 'wp_footer', array( $this, 'elementor_pro_popup' ) );
|
53 |
-
}
|
54 |
-
|
55 |
-
}
|
56 |
-
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Register elementor widget
|
61 |
-
*/
|
62 |
-
public function register_elementor_widgets() {
|
63 |
-
include_once( 'class-elementor-aws-widget.php' );
|
64 |
-
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor_AWS_Widget() );
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Enqueue editor filter styles
|
69 |
-
*/
|
70 |
-
public function filter_editor_styles() {
|
71 |
-
|
72 |
-
wp_enqueue_style(
|
73 |
-
'aws-icons',
|
74 |
-
AWS_URL . '/includes/modules/elementor-widget/elementor.css', array(), AWS_VERSION
|
75 |
-
);
|
76 |
-
|
77 |
-
}
|
78 |
-
|
79 |
-
/*
|
80 |
-
* Elementor replace search form widget
|
81 |
-
*/
|
82 |
-
public function elementor_render_content( $content, $widget ) {
|
83 |
-
if ( method_exists( $widget, 'get_name' ) && $widget->get_name() === 'search-form' ) {
|
84 |
-
if ( method_exists( $widget, 'get_settings' ) ) {
|
85 |
-
$settings = $widget->get_settings();
|
86 |
-
if ( is_array( $settings ) && isset( $settings['skin'] ) && $settings['skin'] === 'full_screen' ) {
|
87 |
-
$content = '<style>
|
88 |
-
.elementor-search-form--skin-full_screen .elementor-search-form__container {
|
89 |
-
overflow: hidden;
|
90 |
-
}
|
91 |
-
.elementor-search-form--full-screen .aws-container {
|
92 |
-
width: 100%;
|
93 |
-
}
|
94 |
-
.elementor-search-form--full-screen .aws-container .aws-search-form {
|
95 |
-
height: auto !important;
|
96 |
-
}
|
97 |
-
.elementor-search-form--full-screen .aws-container .aws-search-form .aws-search-btn.aws-form-btn {
|
98 |
-
display: none;
|
99 |
-
}
|
100 |
-
.elementor-search-form--full-screen .aws-container .aws-search-field {
|
101 |
-
border-bottom: 1px solid #fff !important;
|
102 |
-
font-size: 50px !important;
|
103 |
-
text-align: center !important;
|
104 |
-
line-height: 1.5 !important;
|
105 |
-
color: #7a7a7a !important;
|
106 |
-
}
|
107 |
-
.elementor-search-form--full-screen .aws-container .aws-search-field:focus {
|
108 |
-
background-color: transparent !important;
|
109 |
-
}
|
110 |
-
</style>' . $content;
|
111 |
-
$content = str_replace( array( '<form', '</form>' ), array( '<div', '</div>' ), $content );
|
112 |
-
$content = preg_replace( '/(<input[\S\s]*?elementor-search-form__input[\S\s]*?\>)/i', aws_get_search_form( false ), $content );
|
113 |
-
return $content;
|
114 |
-
}
|
115 |
-
}
|
116 |
-
return aws_get_search_form( false );
|
117 |
-
}
|
118 |
-
|
119 |
-
// Elementskit plugin header search
|
120 |
-
if ( method_exists( $widget, 'get_name' ) && $widget->get_name() === 'elementskit-header-search' ) {
|
121 |
-
$content = '<style>
|
122 |
-
.ekit-search-panel .aws-container .aws-search-form {
|
123 |
-
height: 50px;
|
124 |
-
}
|
125 |
-
.ekit-search-panel .aws-container .aws-search-field {
|
126 |
-
border-radius: 50px !important;
|
127 |
-
}
|
128 |
-
.ekit-search-panel .aws-container .aws-search-form .aws-search-btn.aws-form-btn,
|
129 |
-
.ekit-search-panel .aws-container .aws-search-form .aws-form-btn:last-of-type {
|
130 |
-
width: 60px;
|
131 |
-
}
|
132 |
-
.ekit-search-panel .aws-container .aws-search-form,
|
133 |
-
.ekit-search-panel .aws-container .aws-search-form .aws-form-btn,
|
134 |
-
.ekit-search-panel .aws-container .aws-search-field {
|
135 |
-
background: transparent;
|
136 |
-
}
|
137 |
-
.ekit-search-panel .aws-container .aws-search-form .aws-main-filter .aws-main-filter__current,
|
138 |
-
.ekit-search-panel .aws-container .aws-search-form .aws-search-btn_icon,
|
139 |
-
.ekit-search-panel .aws-container .aws-search-field,
|
140 |
-
.ekit-search-panel .aws-container .aws-search-field::-webkit-input-placeholder {
|
141 |
-
color: #fff;
|
142 |
-
}
|
143 |
-
.ekit-search-panel .aws-container .aws-search-field,
|
144 |
-
.ekit-search-panel .aws-container .aws-search-form .aws-form-btn{
|
145 |
-
border: 2px solid #fff;
|
146 |
-
}
|
147 |
-
.ekit-search-panel .aws-container .aws-search-field {
|
148 |
-
padding-left: 20px;
|
149 |
-
}
|
150 |
-
.ekit-search-panel .aws-container[data-buttons-order="2"] .aws-search-field {
|
151 |
-
border-top-right-radius: 0 !important;
|
152 |
-
border-bottom-right-radius: 0 !important;
|
153 |
-
}
|
154 |
-
.ekit-search-panel .aws-container[data-buttons-order="2"] .aws-search-form .aws-search-btn {
|
155 |
-
border-top-left-radius: 0 !important;
|
156 |
-
border-bottom-left-radius: 0 !important;
|
157 |
-
border-top-right-radius: 50px !important;
|
158 |
-
border-bottom-right-radius: 50px !important;
|
159 |
-
}
|
160 |
-
.ekit-search-panel .aws-container[data-buttons-order="3"] .aws-search-field {
|
161 |
-
border-top-left-radius: 0 !important;
|
162 |
-
border-bottom-left-radius: 0 !important;
|
163 |
-
}
|
164 |
-
.ekit-search-panel .aws-container[data-buttons-order="3"] .aws-search-form .aws-search-btn {
|
165 |
-
border-top-left-radius: 50px !important;
|
166 |
-
border-bottom-left-radius: 50px !important;
|
167 |
-
border-top-right-radius: 0 !important;
|
168 |
-
border-bottom-right-radius: 0 !important;
|
169 |
-
}
|
170 |
-
</style>' . $content;
|
171 |
-
$content = preg_replace( '/<form[\S\s]*?<\/form>/i', aws_get_search_form( false ), $content );
|
172 |
-
}
|
173 |
-
|
174 |
-
return $content;
|
175 |
-
|
176 |
-
}
|
177 |
-
|
178 |
-
/*
|
179 |
-
* Elementor popup search form init
|
180 |
-
*/
|
181 |
-
public function elementor_pro_popup() { ?>
|
182 |
-
|
183 |
-
<script>
|
184 |
-
window.addEventListener('load', function() {
|
185 |
-
if (window.jQuery) {
|
186 |
-
jQuery( document ).on( 'elementor/popup/show', function() {
|
187 |
-
window.setTimeout(function(){
|
188 |
-
jQuery('.elementor-container .aws-container').each( function() {
|
189 |
-
jQuery(this).aws_search();
|
190 |
-
});
|
191 |
-
}, 1000);
|
192 |
-
} );
|
193 |
-
}
|
194 |
-
}, false);
|
195 |
-
</script>
|
196 |
-
|
197 |
-
<?php }
|
198 |
-
|
199 |
-
}
|
200 |
-
|
201 |
-
endif;
|
202 |
-
|
203 |
AWS_Elementor_Init::instance();
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* AWS plugin elementor integrations init
|
4 |
+
*/
|
5 |
+
|
6 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
7 |
+
exit; // Exit if accessed directly.
|
8 |
+
}
|
9 |
+
|
10 |
+
if ( ! class_exists( 'AWS_Elementor_Init' ) ) :
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Class for main plugin functions
|
14 |
+
*/
|
15 |
+
class AWS_Elementor_Init {
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var AWS_Elementor_Init The single instance of the class
|
19 |
+
*/
|
20 |
+
protected static $_instance = null;
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Main AWS_Elementor_Init Instance
|
24 |
+
*
|
25 |
+
* Ensures only one instance of AWS_Elementor_Init is loaded or can be loaded.
|
26 |
+
*
|
27 |
+
* @static
|
28 |
+
* @return AWS_Elementor_Init - Main instance
|
29 |
+
*/
|
30 |
+
public static function instance() {
|
31 |
+
if ( is_null( self::$_instance ) ) {
|
32 |
+
self::$_instance = new self();
|
33 |
+
}
|
34 |
+
return self::$_instance;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Constructor
|
39 |
+
*/
|
40 |
+
public function __construct() {
|
41 |
+
|
42 |
+
add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_elementor_widgets' ) );
|
43 |
+
add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'filter_editor_styles' ) );
|
44 |
+
add_action( 'elementor/preview/enqueue_styles', array( $this, 'filter_editor_styles' ) );
|
45 |
+
|
46 |
+
if ( AWS()->get_settings( 'seamless' ) === 'true' ) {
|
47 |
+
|
48 |
+
add_filter( 'elementor/widget/render_content', array( $this, 'elementor_render_content' ), 10, 2 );
|
49 |
+
|
50 |
+
// Elementor pro
|
51 |
+
if ( defined( 'ELEMENTOR_PRO_VERSION' ) ) {
|
52 |
+
add_action( 'wp_footer', array( $this, 'elementor_pro_popup' ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Register elementor widget
|
61 |
+
*/
|
62 |
+
public function register_elementor_widgets() {
|
63 |
+
include_once( 'class-elementor-aws-widget.php' );
|
64 |
+
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor_AWS_Widget() );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Enqueue editor filter styles
|
69 |
+
*/
|
70 |
+
public function filter_editor_styles() {
|
71 |
+
|
72 |
+
wp_enqueue_style(
|
73 |
+
'aws-icons',
|
74 |
+
AWS_URL . '/includes/modules/elementor-widget/elementor.css', array(), AWS_VERSION
|
75 |
+
);
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
/*
|
80 |
+
* Elementor replace search form widget
|
81 |
+
*/
|
82 |
+
public function elementor_render_content( $content, $widget ) {
|
83 |
+
if ( method_exists( $widget, 'get_name' ) && $widget->get_name() === 'search-form' ) {
|
84 |
+
if ( method_exists( $widget, 'get_settings' ) ) {
|
85 |
+
$settings = $widget->get_settings();
|
86 |
+
if ( is_array( $settings ) && isset( $settings['skin'] ) && $settings['skin'] === 'full_screen' ) {
|
87 |
+
$content = '<style>
|
88 |
+
.elementor-search-form--skin-full_screen .elementor-search-form__container {
|
89 |
+
overflow: hidden;
|
90 |
+
}
|
91 |
+
.elementor-search-form--full-screen .aws-container {
|
92 |
+
width: 100%;
|
93 |
+
}
|
94 |
+
.elementor-search-form--full-screen .aws-container .aws-search-form {
|
95 |
+
height: auto !important;
|
96 |
+
}
|
97 |
+
.elementor-search-form--full-screen .aws-container .aws-search-form .aws-search-btn.aws-form-btn {
|
98 |
+
display: none;
|
99 |
+
}
|
100 |
+
.elementor-search-form--full-screen .aws-container .aws-search-field {
|
101 |
+
border-bottom: 1px solid #fff !important;
|
102 |
+
font-size: 50px !important;
|
103 |
+
text-align: center !important;
|
104 |
+
line-height: 1.5 !important;
|
105 |
+
color: #7a7a7a !important;
|
106 |
+
}
|
107 |
+
.elementor-search-form--full-screen .aws-container .aws-search-field:focus {
|
108 |
+
background-color: transparent !important;
|
109 |
+
}
|
110 |
+
</style>' . $content;
|
111 |
+
$content = str_replace( array( '<form', '</form>' ), array( '<div', '</div>' ), $content );
|
112 |
+
$content = preg_replace( '/(<input[\S\s]*?elementor-search-form__input[\S\s]*?\>)/i', aws_get_search_form( false ), $content );
|
113 |
+
return $content;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
return aws_get_search_form( false );
|
117 |
+
}
|
118 |
+
|
119 |
+
// Elementskit plugin header search
|
120 |
+
if ( method_exists( $widget, 'get_name' ) && $widget->get_name() === 'elementskit-header-search' ) {
|
121 |
+
$content = '<style>
|
122 |
+
.ekit-search-panel .aws-container .aws-search-form {
|
123 |
+
height: 50px;
|
124 |
+
}
|
125 |
+
.ekit-search-panel .aws-container .aws-search-field {
|
126 |
+
border-radius: 50px !important;
|
127 |
+
}
|
128 |
+
.ekit-search-panel .aws-container .aws-search-form .aws-search-btn.aws-form-btn,
|
129 |
+
.ekit-search-panel .aws-container .aws-search-form .aws-form-btn:last-of-type {
|
130 |
+
width: 60px;
|
131 |
+
}
|
132 |
+
.ekit-search-panel .aws-container .aws-search-form,
|
133 |
+
.ekit-search-panel .aws-container .aws-search-form .aws-form-btn,
|
134 |
+
.ekit-search-panel .aws-container .aws-search-field {
|
135 |
+
background: transparent;
|
136 |
+
}
|
137 |
+
.ekit-search-panel .aws-container .aws-search-form .aws-main-filter .aws-main-filter__current,
|
138 |
+
.ekit-search-panel .aws-container .aws-search-form .aws-search-btn_icon,
|
139 |
+
.ekit-search-panel .aws-container .aws-search-field,
|
140 |
+
.ekit-search-panel .aws-container .aws-search-field::-webkit-input-placeholder {
|
141 |
+
color: #fff;
|
142 |
+
}
|
143 |
+
.ekit-search-panel .aws-container .aws-search-field,
|
144 |
+
.ekit-search-panel .aws-container .aws-search-form .aws-form-btn{
|
145 |
+
border: 2px solid #fff;
|
146 |
+
}
|
147 |
+
.ekit-search-panel .aws-container .aws-search-field {
|
148 |
+
padding-left: 20px;
|
149 |
+
}
|
150 |
+
.ekit-search-panel .aws-container[data-buttons-order="2"] .aws-search-field {
|
151 |
+
border-top-right-radius: 0 !important;
|
152 |
+
border-bottom-right-radius: 0 !important;
|
153 |
+
}
|
154 |
+
.ekit-search-panel .aws-container[data-buttons-order="2"] .aws-search-form .aws-search-btn {
|
155 |
+
border-top-left-radius: 0 !important;
|
156 |
+
border-bottom-left-radius: 0 !important;
|
157 |
+
border-top-right-radius: 50px !important;
|
158 |
+
border-bottom-right-radius: 50px !important;
|
159 |
+
}
|
160 |
+
.ekit-search-panel .aws-container[data-buttons-order="3"] .aws-search-field {
|
161 |
+
border-top-left-radius: 0 !important;
|
162 |
+
border-bottom-left-radius: 0 !important;
|
163 |
+
}
|
164 |
+
.ekit-search-panel .aws-container[data-buttons-order="3"] .aws-search-form .aws-search-btn {
|
165 |
+
border-top-left-radius: 50px !important;
|
166 |
+
border-bottom-left-radius: 50px !important;
|
167 |
+
border-top-right-radius: 0 !important;
|
168 |
+
border-bottom-right-radius: 0 !important;
|
169 |
+
}
|
170 |
+
</style>' . $content;
|
171 |
+
$content = preg_replace( '/<form[\S\s]*?<\/form>/i', aws_get_search_form( false ), $content );
|
172 |
+
}
|
173 |
+
|
174 |
+
return $content;
|
175 |
+
|
176 |
+
}
|
177 |
+
|
178 |
+
/*
|
179 |
+
* Elementor popup search form init
|
180 |
+
*/
|
181 |
+
public function elementor_pro_popup() { ?>
|
182 |
+
|
183 |
+
<script>
|
184 |
+
window.addEventListener('load', function() {
|
185 |
+
if (window.jQuery) {
|
186 |
+
jQuery( document ).on( 'elementor/popup/show', function() {
|
187 |
+
window.setTimeout(function(){
|
188 |
+
jQuery('.elementor-container .aws-container').each( function() {
|
189 |
+
jQuery(this).aws_search();
|
190 |
+
});
|
191 |
+
}, 1000);
|
192 |
+
} );
|
193 |
+
}
|
194 |
+
}, false);
|
195 |
+
</script>
|
196 |
+
|
197 |
+
<?php }
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
endif;
|
202 |
+
|
203 |
AWS_Elementor_Init::instance();
|
includes/modules/elementor-widget/class-elementor-aws-widget.php
CHANGED
@@ -1,110 +1,110 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Elementor AWS Widget.
|
5 |
-
*
|
6 |
-
* Elementor widget to add AWS search form
|
7 |
-
*
|
8 |
-
* @since 1.0.0
|
9 |
-
*/
|
10 |
-
class Elementor_AWS_Widget extends \Elementor\Widget_Base {
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Get widget name.
|
14 |
-
*
|
15 |
-
* @since 1.0.0
|
16 |
-
* @access public
|
17 |
-
*
|
18 |
-
* @return string Widget name.
|
19 |
-
*/
|
20 |
-
public function get_name() {
|
21 |
-
return 'aws';
|
22 |
-
}
|
23 |
-
|
24 |
-
/**
|
25 |
-
* Get widget title.
|
26 |
-
*
|
27 |
-
* @since 1.0.0
|
28 |
-
* @access public
|
29 |
-
*
|
30 |
-
* @return string Widget title.
|
31 |
-
*/
|
32 |
-
public function get_title() {
|
33 |
-
return __( 'Advanced Woo Search', 'advanced-woo-search' );
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Get widget icon.
|
38 |
-
*
|
39 |
-
* @since 1.0.0
|
40 |
-
* @access public
|
41 |
-
*
|
42 |
-
* @return string Widget icon.
|
43 |
-
*/
|
44 |
-
public function get_icon() {
|
45 |
-
return 'aws-elementor-icon';
|
46 |
-
}
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Get widget categories.
|
50 |
-
*
|
51 |
-
* @since 1.0.0
|
52 |
-
* @access public
|
53 |
-
*
|
54 |
-
* @return array Widget categories.
|
55 |
-
*/
|
56 |
-
public function get_categories() {
|
57 |
-
return array( 'general', 'woocommerce-elements' );
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Register widget controls.
|
62 |
-
*
|
63 |
-
* @since 1.0.0
|
64 |
-
* @access protected
|
65 |
-
*/
|
66 |
-
protected function _register_controls() {
|
67 |
-
|
68 |
-
$this->start_controls_section(
|
69 |
-
'content_section',
|
70 |
-
array(
|
71 |
-
'label' => __( 'Content', 'advanced-woo-search' ),
|
72 |
-
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
|
73 |
-
)
|
74 |
-
);
|
75 |
-
|
76 |
-
$this->add_control(
|
77 |
-
'placeholder',
|
78 |
-
array(
|
79 |
-
'label' => __( 'Placeholder', 'advanced-woo-search' ),
|
80 |
-
'type' => \Elementor\Controls_Manager::TEXT,
|
81 |
-
'input_type' => 'text',
|
82 |
-
'placeholder' => '',
|
83 |
-
)
|
84 |
-
);
|
85 |
-
|
86 |
-
$this->end_controls_section();
|
87 |
-
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Render widget output on the frontend.
|
92 |
-
*
|
93 |
-
* @since 1.0.0
|
94 |
-
* @access protected
|
95 |
-
*/
|
96 |
-
protected function render() {
|
97 |
-
|
98 |
-
$settings = $this->get_settings_for_display();
|
99 |
-
|
100 |
-
if ( function_exists( 'aws_get_search_form' ) ) {
|
101 |
-
$search_form = aws_get_search_form( false );
|
102 |
-
if ( $settings['placeholder'] ) {
|
103 |
-
$search_form = preg_replace( '/placeholder="([\S\s]*?)"/i', 'placeholder="' . $settings['placeholder'] . '"', $search_form );
|
104 |
-
}
|
105 |
-
echo $search_form;
|
106 |
-
}
|
107 |
-
|
108 |
-
}
|
109 |
-
|
110 |
}
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Elementor AWS Widget.
|
5 |
+
*
|
6 |
+
* Elementor widget to add AWS search form
|
7 |
+
*
|
8 |
+
* @since 1.0.0
|
9 |
+
*/
|
10 |
+
class Elementor_AWS_Widget extends \Elementor\Widget_Base {
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Get widget name.
|
14 |
+
*
|
15 |
+
* @since 1.0.0
|
16 |
+
* @access public
|
17 |
+
*
|
18 |
+
* @return string Widget name.
|
19 |
+
*/
|
20 |
+
public function get_name() {
|
21 |
+
return 'aws';
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Get widget title.
|
26 |
+
*
|
27 |
+
* @since 1.0.0
|
28 |
+
* @access public
|
29 |
+
*
|
30 |
+
* @return string Widget title.
|
31 |
+
*/
|
32 |
+
public function get_title() {
|
33 |
+
return __( 'Advanced Woo Search', 'advanced-woo-search' );
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Get widget icon.
|
38 |
+
*
|
39 |
+
* @since 1.0.0
|
40 |
+
* @access public
|
41 |
+
*
|
42 |
+
* @return string Widget icon.
|
43 |
+
*/
|
44 |
+
public function get_icon() {
|
45 |
+
return 'aws-elementor-icon';
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Get widget categories.
|
50 |
+
*
|
51 |
+
* @since 1.0.0
|
52 |
+
* @access public
|
53 |
+
*
|
54 |
+
* @return array Widget categories.
|
55 |
+
*/
|
56 |
+
public function get_categories() {
|
57 |
+
return array( 'general', 'woocommerce-elements' );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Register widget controls.
|
62 |
+
*
|
63 |
+
* @since 1.0.0
|
64 |
+
* @access protected
|
65 |
+
*/
|
66 |
+
protected function _register_controls() {
|
67 |
+
|
68 |
+
$this->start_controls_section(
|
69 |
+
'content_section',
|
70 |
+
array(
|
71 |
+
'label' => __( 'Content', 'advanced-woo-search' ),
|
72 |
+
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
|
73 |
+
)
|
74 |
+
);
|
75 |
+
|
76 |
+
$this->add_control(
|
77 |
+
'placeholder',
|
78 |
+
array(
|
79 |
+
'label' => __( 'Placeholder', 'advanced-woo-search' ),
|
80 |
+
'type' => \Elementor\Controls_Manager::TEXT,
|
81 |
+
'input_type' => 'text',
|
82 |
+
'placeholder' => '',
|
83 |
+
)
|
84 |
+
);
|
85 |
+
|
86 |
+
$this->end_controls_section();
|
87 |
+
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Render widget output on the frontend.
|
92 |
+
*
|
93 |
+
* @since 1.0.0
|
94 |
+
* @access protected
|
95 |
+
*/
|
96 |
+
protected function render() {
|
97 |
+
|
98 |
+
$settings = $this->get_settings_for_display();
|
99 |
+
|
100 |
+
if ( function_exists( 'aws_get_search_form' ) ) {
|
101 |
+
$search_form = aws_get_search_form( false );
|
102 |
+
if ( $settings['placeholder'] ) {
|
103 |
+
$search_form = preg_replace( '/placeholder="([\S\s]*?)"/i', 'placeholder="' . $settings['placeholder'] . '"', $search_form );
|
104 |
+
}
|
105 |
+
echo $search_form;
|
106 |
+
}
|
107 |
+
|
108 |
+
}
|
109 |
+
|
110 |
}
|
includes/modules/elementor-widget/elementor.css
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
|
2 |
-
.aws-elementor-icon:before {
|
3 |
-
content: '';
|
4 |
-
display: block;
|
5 |
-
width: 1em;
|
6 |
-
height: 1em;
|
7 |
-
margin: 0 auto;
|
8 |
-
background-position: center;
|
9 |
-
background-repeat: no-repeat;
|
10 |
-
background-size: contain;
|
11 |
-
background-image: url("data:image/svg+xml,%3Csvg height='40px' viewBox='0 0 64 64' width='40px' xmlns='http://www.w3.org/2000/svg' style=' fill: %23b76d9e; stroke: %23b76d9e;%0A'%3E%3Cdefs id='defs3848'%3E%3C/defs%3E%3Cg id='layer1'%3E%3Cg id='g5183' transform='translate(25.5,-27)'%3E%3Ccircle class='fil0 str1' cx='0.73810571' cy='53.392174' id='circle15' r='20.063322' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:3;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision'%3E%3C/circle%3E%3Cline class='fil0 str2' id='line25' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:3.99974346;stroke-linecap:round;stroke-linejoin:round;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision' x1='15.617603' x2='30.305107' y1='68.559662' y2='83.151169'%3E%3C/line%3E%3Cpath class='fil0 str0' d='m -12.701441,53.392174 c 0,-7.391751 6.047795,-13.439547 13.43954602,-13.439547' id='path281' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:2.00005412;stroke-linecap:round;stroke-linejoin:round;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision'%3E%3C/path%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); /*background-image: url("data:image/svg+xml,%3Csvg height='40px' viewBox='0 0 64 64' width='40px' xmlns='http://www.w3.org/2000/svg' style=' stroke: %234498c6;%0A'%3E%3Cdefs id='defs3848'%3E%3C/defs%3E%3Cg id='layer1'%3E%3Cg id='g5183' transform='translate(25.5,-27)'%3E%3Ccircle class='fil0 str1' cx='0.73810571' cy='53.392174' id='circle15' r='20.063322' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:2.00005412;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision'%3E%3C/circle%3E%3Cline class='fil0 str2' id='line25' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:3.99974346;stroke-linecap:round;stroke-linejoin:round;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision' x1='15.617603' x2='30.305107' y1='68.559662' y2='83.151169'%3E%3C/line%3E%3Cpath class='fil0 str0' d='m -12.701441,53.392174 c 0,-7.391751 6.047795,-13.439547 13.43954602,-13.439547' id='path281' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:2.00005412;stroke-linecap:round;stroke-linejoin:round;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision'%3E%3C/path%3E%3C/g%3E%3C/g%3E%3C/svg%3E");*/
|
12 |
}
|
1 |
+
|
2 |
+
.aws-elementor-icon:before {
|
3 |
+
content: '';
|
4 |
+
display: block;
|
5 |
+
width: 1em;
|
6 |
+
height: 1em;
|
7 |
+
margin: 0 auto;
|
8 |
+
background-position: center;
|
9 |
+
background-repeat: no-repeat;
|
10 |
+
background-size: contain;
|
11 |
+
background-image: url("data:image/svg+xml,%3Csvg height='40px' viewBox='0 0 64 64' width='40px' xmlns='http://www.w3.org/2000/svg' style=' fill: %23b76d9e; stroke: %23b76d9e;%0A'%3E%3Cdefs id='defs3848'%3E%3C/defs%3E%3Cg id='layer1'%3E%3Cg id='g5183' transform='translate(25.5,-27)'%3E%3Ccircle class='fil0 str1' cx='0.73810571' cy='53.392174' id='circle15' r='20.063322' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:3;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision'%3E%3C/circle%3E%3Cline class='fil0 str2' id='line25' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:3.99974346;stroke-linecap:round;stroke-linejoin:round;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision' x1='15.617603' x2='30.305107' y1='68.559662' y2='83.151169'%3E%3C/line%3E%3Cpath class='fil0 str0' d='m -12.701441,53.392174 c 0,-7.391751 6.047795,-13.439547 13.43954602,-13.439547' id='path281' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:2.00005412;stroke-linecap:round;stroke-linejoin:round;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision'%3E%3C/path%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); /*background-image: url("data:image/svg+xml,%3Csvg height='40px' viewBox='0 0 64 64' width='40px' xmlns='http://www.w3.org/2000/svg' style=' stroke: %234498c6;%0A'%3E%3Cdefs id='defs3848'%3E%3C/defs%3E%3Cg id='layer1'%3E%3Cg id='g5183' transform='translate(25.5,-27)'%3E%3Ccircle class='fil0 str1' cx='0.73810571' cy='53.392174' id='circle15' r='20.063322' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:2.00005412;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision'%3E%3C/circle%3E%3Cline class='fil0 str2' id='line25' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:3.99974346;stroke-linecap:round;stroke-linejoin:round;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision' x1='15.617603' x2='30.305107' y1='68.559662' y2='83.151169'%3E%3C/line%3E%3Cpath class='fil0 str0' d='m -12.701441,53.392174 c 0,-7.391751 6.047795,-13.439547 13.43954602,-13.439547' id='path281' style='clip-rule:evenodd;fill:none;fill-rule:evenodd;stroke-width:2.00005412;stroke-linecap:round;stroke-linejoin:round;image-rendering:optimizeQuality;shape-rendering:geometricPrecision;text-rendering:geometricPrecision'%3E%3C/path%3E%3C/g%3E%3C/g%3E%3C/svg%3E");*/
|
12 |
}
|
includes/modules/gutenberg/aws-gutenberg-search-block.js
CHANGED
@@ -1,84 +1,84 @@
|
|
1 |
-
( function( blocks, element, serverSideRender, blockEditor, components ) {
|
2 |
-
|
3 |
-
var el = element.createElement;
|
4 |
-
var useBlockProps = blockEditor.useBlockProps;
|
5 |
-
var RichText = blockEditor.RichText;
|
6 |
-
var ServerSideRender = serverSideRender;
|
7 |
-
|
8 |
-
var InspectorControls = blockEditor.InspectorControls;
|
9 |
-
var Fragment = element.Fragment;
|
10 |
-
|
11 |
-
var TextControl = components.TextControl;
|
12 |
-
var Panel = components.Panel;
|
13 |
-
var PanelBody = components.PanelBody;
|
14 |
-
var PanelRow = components.PanelRow;
|
15 |
-
|
16 |
-
var sIcon = el('svg', { width: 20, height: 20 },
|
17 |
-
el('path', { fill: "#7f54b3", d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" } )
|
18 |
-
);
|
19 |
-
|
20 |
-
blocks.updateCategory('aws', { icon: sIcon });
|
21 |
-
|
22 |
-
var blockStyle = {
|
23 |
-
backgroundColor: '#900',
|
24 |
-
color: '#fff',
|
25 |
-
padding: '20px',
|
26 |
-
};
|
27 |
-
|
28 |
-
blocks.registerBlockType( 'advanced-woo-search/search-block', {
|
29 |
-
apiVersion: 2,
|
30 |
-
title: 'Search Form',
|
31 |
-
description: 'Advanced Woo Search form block inserts plugin search form into the page.',
|
32 |
-
icon: sIcon,
|
33 |
-
category: 'aws',
|
34 |
-
example: {},
|
35 |
-
edit: function( props ) {
|
36 |
-
|
37 |
-
var blockProps = blockEditor.hasOwnProperty('useBlockProps') ? blockEditor.useBlockProps() : null;
|
38 |
-
|
39 |
-
return (
|
40 |
-
el( Fragment, {},
|
41 |
-
el( InspectorControls, {},
|
42 |
-
el( PanelBody, { title: 'Search Form Settings', initialOpen: true },
|
43 |
-
|
44 |
-
/* Text Field */
|
45 |
-
el( PanelRow, {},
|
46 |
-
el( TextControl,
|
47 |
-
{
|
48 |
-
label: 'Placeholder text',
|
49 |
-
onChange: ( value ) => {
|
50 |
-
props.setAttributes( { placeholder: value } );
|
51 |
-
},
|
52 |
-
value: props.attributes.placeholder
|
53 |
-
}
|
54 |
-
)
|
55 |
-
),
|
56 |
-
|
57 |
-
),
|
58 |
-
|
59 |
-
),
|
60 |
-
el(
|
61 |
-
'div',
|
62 |
-
blockProps,
|
63 |
-
el( ServerSideRender, {
|
64 |
-
block: 'advanced-woo-search/search-block',
|
65 |
-
attributes: props.attributes,
|
66 |
-
} )
|
67 |
-
)
|
68 |
-
)
|
69 |
-
|
70 |
-
);
|
71 |
-
|
72 |
-
|
73 |
-
},
|
74 |
-
save: function( props ) {
|
75 |
-
return null;
|
76 |
-
},
|
77 |
-
} );
|
78 |
-
}(
|
79 |
-
window.wp.blocks,
|
80 |
-
window.wp.element,
|
81 |
-
window.wp.serverSideRender,
|
82 |
-
window.wp.blockEditor,
|
83 |
-
window.wp.components,
|
84 |
) );
|
1 |
+
( function( blocks, element, serverSideRender, blockEditor, components ) {
|
2 |
+
|
3 |
+
var el = element.createElement;
|
4 |
+
var useBlockProps = blockEditor.useBlockProps;
|
5 |
+
var RichText = blockEditor.RichText;
|
6 |
+
var ServerSideRender = serverSideRender;
|
7 |
+
|
8 |
+
var InspectorControls = blockEditor.InspectorControls;
|
9 |
+
var Fragment = element.Fragment;
|
10 |
+
|
11 |
+
var TextControl = components.TextControl;
|
12 |
+
var Panel = components.Panel;
|
13 |
+
var PanelBody = components.PanelBody;
|
14 |
+
var PanelRow = components.PanelRow;
|
15 |
+
|
16 |
+
var sIcon = el('svg', { width: 20, height: 20 },
|
17 |
+
el('path', { fill: "#7f54b3", d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" } )
|
18 |
+
);
|
19 |
+
|
20 |
+
blocks.updateCategory('aws', { icon: sIcon });
|
21 |
+
|
22 |
+
var blockStyle = {
|
23 |
+
backgroundColor: '#900',
|
24 |
+
color: '#fff',
|
25 |
+
padding: '20px',
|
26 |
+
};
|
27 |
+
|
28 |
+
blocks.registerBlockType( 'advanced-woo-search/search-block', {
|
29 |
+
apiVersion: 2,
|
30 |
+
title: 'Search Form',
|
31 |
+
description: 'Advanced Woo Search form block inserts plugin search form into the page.',
|
32 |
+
icon: sIcon,
|
33 |
+
category: 'aws',
|
34 |
+
example: {},
|
35 |
+
edit: function( props ) {
|
36 |
+
|
37 |
+
var blockProps = blockEditor.hasOwnProperty('useBlockProps') ? blockEditor.useBlockProps() : null;
|
38 |
+
|
39 |
+
return (
|
40 |
+
el( Fragment, {},
|
41 |
+
el( InspectorControls, {},
|
42 |
+
el( PanelBody, { title: 'Search Form Settings', initialOpen: true },
|
43 |
+
|
44 |
+
/* Text Field */
|
45 |
+
el( PanelRow, {},
|
46 |
+
el( TextControl,
|
47 |
+
{
|
48 |
+
label: 'Placeholder text',
|
49 |
+
onChange: ( value ) => {
|
50 |
+
props.setAttributes( { placeholder: value } );
|
51 |
+
},
|
52 |
+
value: props.attributes.placeholder
|
53 |
+
}
|
54 |
+
)
|
55 |
+
),
|
56 |
+
|
57 |
+
),
|
58 |
+
|
59 |
+
),
|
60 |
+
el(
|
61 |
+
'div',
|
62 |
+
blockProps,
|
63 |
+
el( ServerSideRender, {
|
64 |
+
block: 'advanced-woo-search/search-block',
|
65 |
+
attributes: props.attributes,
|
66 |
+
} )
|
67 |
+
)
|
68 |
+
)
|
69 |
+
|
70 |
+
);
|
71 |
+
|
72 |
+
|
73 |
+
},
|
74 |
+
save: function( props ) {
|
75 |
+
return null;
|
76 |
+
},
|
77 |
+
} );
|
78 |
+
}(
|
79 |
+
window.wp.blocks,
|
80 |
+
window.wp.element,
|
81 |
+
window.wp.serverSideRender,
|
82 |
+
window.wp.blockEditor,
|
83 |
+
window.wp.components,
|
84 |
) );
|
includes/modules/gutenberg/class-aws-gutenberg-init.php
CHANGED
@@ -1,122 +1,122 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* AWS plugin gutenberg integrations init
|
5 |
-
*/
|
6 |
-
|
7 |
-
if (!defined('ABSPATH')) {
|
8 |
-
exit; // Exit if accessed directly.
|
9 |
-
}
|
10 |
-
|
11 |
-
if (!class_exists('AWS_Gutenberg_Init')) :
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Class for main plugin functions
|
15 |
-
*/
|
16 |
-
class AWS_Gutenberg_Init {
|
17 |
-
|
18 |
-
/**
|
19 |
-
* @var AWS_Gutenberg_Init The single instance of the class
|
20 |
-
*/
|
21 |
-
protected static $_instance = null;
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Main AWS_Gutenberg_Init Instance
|
25 |
-
*
|
26 |
-
* Ensures only one instance of AWS_Gutenberg_Init is loaded or can be loaded.
|
27 |
-
*
|
28 |
-
* @static
|
29 |
-
* @return AWS_Gutenberg_Init - Main instance
|
30 |
-
*/
|
31 |
-
public static function instance()
|
32 |
-
{
|
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 |
-
add_action( 'init', array( $this, 'register_block' ) );
|
45 |
-
|
46 |
-
add_filter( 'block_categories', array( $this, 'add_block_category' ), 10, 2 );
|
47 |
-
|
48 |
-
}
|
49 |
-
|
50 |
-
/*
|
51 |
-
* Register gutenberg blocks
|
52 |
-
*/
|
53 |
-
public function register_block() {
|
54 |
-
|
55 |
-
wp_register_script(
|
56 |
-
'aws-gutenberg-search-block',
|
57 |
-
AWS_URL . '/includes/modules/gutenberg/aws-gutenberg-search-block.js',
|
58 |
-
array('wp-blocks','wp-editor'),
|
59 |
-
AWS_VERSION
|
60 |
-
);
|
61 |
-
|
62 |
-
wp_register_style(
|
63 |
-
'aws-gutenberg-styles-editor',
|
64 |
-
AWS_URL . '/assets/css/common.css',
|
65 |
-
array( 'wp-edit-blocks' ),
|
66 |
-
AWS_VERSION
|
67 |
-
);
|
68 |
-
|
69 |
-
register_block_type( 'advanced-woo-search/search-block', array(
|
70 |
-
'apiVersion' => 2,
|
71 |
-
'editor_script' => 'aws-gutenberg-search-block',
|
72 |
-
'editor_style' => 'aws-gutenberg-styles-editor',
|
73 |
-
'render_callback' => array( $this, 'search_block_dynamic_render_callback' ),
|
74 |
-
'attributes' => array(
|
75 |
-
'placeholder' => array(
|
76 |
-
'type' => 'string',
|
77 |
-
'default' => AWS_Helpers::translate( 'search_field_text', AWS()->get_settings( 'search_field_text' ) ),
|
78 |
-
),
|
79 |
-
),
|
80 |
-
) );
|
81 |
-
|
82 |
-
}
|
83 |
-
|
84 |
-
/*
|
85 |
-
* Render dynamic content
|
86 |
-
*/
|
87 |
-
public function search_block_dynamic_render_callback( $block_attributes, $content ) {
|
88 |
-
|
89 |
-
$placeholder = $block_attributes['placeholder'];
|
90 |
-
$search_form = aws_get_search_form( false );
|
91 |
-
|
92 |
-
if ( $placeholder ) {
|
93 |
-
$search_form = preg_replace( '/placeholder="([\S\s]*?)"/i', 'placeholder="' . esc_attr( $placeholder ) . '"', $search_form );
|
94 |
-
|
95 |
-
}
|
96 |
-
|
97 |
-
return $search_form;
|
98 |
-
|
99 |
-
}
|
100 |
-
|
101 |
-
/*
|
102 |
-
* Add new blocks category
|
103 |
-
*/
|
104 |
-
public function add_block_category( $categories, $post ) {
|
105 |
-
return array_merge(
|
106 |
-
$categories,
|
107 |
-
array(
|
108 |
-
array(
|
109 |
-
'slug' => 'aws',
|
110 |
-
'title' => 'Advanced Woo Search',
|
111 |
-
'icon' => 'search',
|
112 |
-
),
|
113 |
-
)
|
114 |
-
);
|
115 |
-
}
|
116 |
-
|
117 |
-
}
|
118 |
-
|
119 |
-
|
120 |
-
endif;
|
121 |
-
|
122 |
AWS_Gutenberg_Init::instance();
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* AWS plugin gutenberg integrations init
|
5 |
+
*/
|
6 |
+
|
7 |
+
if (!defined('ABSPATH')) {
|
8 |
+
exit; // Exit if accessed directly.
|
9 |
+
}
|
10 |
+
|
11 |
+
if (!class_exists('AWS_Gutenberg_Init')) :
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class for main plugin functions
|
15 |
+
*/
|
16 |
+
class AWS_Gutenberg_Init {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* @var AWS_Gutenberg_Init The single instance of the class
|
20 |
+
*/
|
21 |
+
protected static $_instance = null;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Main AWS_Gutenberg_Init Instance
|
25 |
+
*
|
26 |
+
* Ensures only one instance of AWS_Gutenberg_Init is loaded or can be loaded.
|
27 |
+
*
|
28 |
+
* @static
|
29 |
+
* @return AWS_Gutenberg_Init - Main instance
|
30 |
+
*/
|
31 |
+
public static function instance()
|
32 |
+
{
|
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 |
+
add_action( 'init', array( $this, 'register_block' ) );
|
45 |
+
|
46 |
+
add_filter( 'block_categories', array( $this, 'add_block_category' ), 10, 2 );
|
47 |
+
|
48 |
+
}
|
49 |
+
|
50 |
+
/*
|
51 |
+
* Register gutenberg blocks
|
52 |
+
*/
|
53 |
+
public function register_block() {
|
54 |
+
|
55 |
+
wp_register_script(
|
56 |
+
'aws-gutenberg-search-block',
|
57 |
+
AWS_URL . '/includes/modules/gutenberg/aws-gutenberg-search-block.js',
|
58 |
+
array('wp-blocks','wp-editor'),
|
59 |
+
AWS_VERSION
|
60 |
+
);
|
61 |
+
|
62 |
+
wp_register_style(
|
63 |
+
'aws-gutenberg-styles-editor',
|
64 |
+
AWS_URL . '/assets/css/common.css',
|
65 |
+
array( 'wp-edit-blocks' ),
|
66 |
+
AWS_VERSION
|
67 |
+
);
|
68 |
+
|
69 |
+
register_block_type( 'advanced-woo-search/search-block', array(
|
70 |
+
'apiVersion' => 2,
|
71 |
+
'editor_script' => 'aws-gutenberg-search-block',
|
72 |
+
'editor_style' => 'aws-gutenberg-styles-editor',
|
73 |
+
'render_callback' => array( $this, 'search_block_dynamic_render_callback' ),
|
74 |
+
'attributes' => array(
|
75 |
+
'placeholder' => array(
|
76 |
+
'type' => 'string',
|
77 |
+
'default' => AWS_Helpers::translate( 'search_field_text', AWS()->get_settings( 'search_field_text' ) ),
|
78 |
+
),
|
79 |
+
),
|
80 |
+
) );
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
/*
|
85 |
+
* Render dynamic content
|
86 |
+
*/
|
87 |
+
public function search_block_dynamic_render_callback( $block_attributes, $content ) {
|
88 |
+
|
89 |
+
$placeholder = $block_attributes['placeholder'];
|
90 |
+
$search_form = aws_get_search_form( false );
|
91 |
+
|
92 |
+
if ( $placeholder ) {
|
93 |
+
$search_form = preg_replace( '/placeholder="([\S\s]*?)"/i', 'placeholder="' . esc_attr( $placeholder ) . '"', $search_form );
|
94 |
+
|
95 |
+
}
|
96 |
+
|
97 |
+
return $search_form;
|
98 |
+
|
99 |
+
}
|
100 |
+
|
101 |
+
/*
|
102 |
+
* Add new blocks category
|
103 |
+
*/
|
104 |
+
public function add_block_category( $categories, $post ) {
|
105 |
+
return array_merge(
|
106 |
+
$categories,
|
107 |
+
array(
|
108 |
+
array(
|
109 |
+
'slug' => 'aws',
|
110 |
+
'title' => 'Advanced Woo Search',
|
111 |
+
'icon' => 'search',
|
112 |
+
),
|
113 |
+
)
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
endif;
|
121 |
+
|
122 |
AWS_Gutenberg_Init::instance();
|
includes/widget.php
CHANGED
@@ -1,80 +1,80 @@
|
|
1 |
-
<?php
|
2 |
-
/*
|
3 |
-
* Initialized plugins widget
|
4 |
-
*/
|
5 |
-
|
6 |
-
add_action( 'widgets_init', 'aws_register_widget' );
|
7 |
-
|
8 |
-
function aws_register_widget() {
|
9 |
-
register_widget("AWS_Widget");
|
10 |
-
}
|
11 |
-
|
12 |
-
class AWS_Widget extends WP_Widget {
|
13 |
-
|
14 |
-
/*
|
15 |
-
* Constructor
|
16 |
-
*/
|
17 |
-
function __construct() {
|
18 |
-
$widget_ops = array( 'description' => __('Advanced WooCommerce search widget', 'advanced-woo-search' ) );
|
19 |
-
$control_ops = array( 'width' => 400 );
|
20 |
-
parent::__construct( false, __( '» AWS Widget', 'advanced-woo-search' ), $widget_ops, $control_ops );
|
21 |
-
}
|
22 |
-
|
23 |
-
/*
|
24 |
-
* Display widget
|
25 |
-
*/
|
26 |
-
function widget( $args, $instance ) {
|
27 |
-
extract( $args );
|
28 |
-
|
29 |
-
$title = apply_filters( 'widget_title',
|
30 |
-
( ! empty( $instance['title'] ) ? $instance['title'] : '' ),
|
31 |
-
$instance,
|
32 |
-
$this->id_base
|
33 |
-
);
|
34 |
-
|
35 |
-
echo $before_widget;
|
36 |
-
|
37 |
-
if ( $title ) {
|
38 |
-
echo $before_title;
|
39 |
-
echo $title;
|
40 |
-
echo $after_title;
|
41 |
-
}
|
42 |
-
|
43 |
-
// Generate search form markup
|
44 |
-
echo AWS()->markup();
|
45 |
-
|
46 |
-
echo $after_widget;
|
47 |
-
}
|
48 |
-
|
49 |
-
/*
|
50 |
-
* Update widget settings
|
51 |
-
*/
|
52 |
-
function update( $new_instance, $old_instance ) {
|
53 |
-
$instance = $old_instance;
|
54 |
-
$params = array( 'title' );
|
55 |
-
foreach ( $params as $k ) {
|
56 |
-
$instance[$k] = strip_tags( $new_instance[$k] );
|
57 |
-
}
|
58 |
-
return $instance;
|
59 |
-
}
|
60 |
-
|
61 |
-
/*
|
62 |
-
* Widget settings form
|
63 |
-
*/
|
64 |
-
function form( $instance ) {
|
65 |
-
global $shortname;
|
66 |
-
$defaults = array(
|
67 |
-
'title' => __( 'Search...', 'advanced-woo-search' )
|
68 |
-
);
|
69 |
-
$instance = wp_parse_args( (array) $instance, $defaults );
|
70 |
-
?>
|
71 |
-
|
72 |
-
<p>
|
73 |
-
<label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php esc_html_e( 'Title:', 'advanced-woo-search' ); ?></label>
|
74 |
-
<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>">
|
75 |
-
</p>
|
76 |
-
|
77 |
-
<?php
|
78 |
-
}
|
79 |
-
}
|
80 |
?>
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* Initialized plugins widget
|
4 |
+
*/
|
5 |
+
|
6 |
+
add_action( 'widgets_init', 'aws_register_widget' );
|
7 |
+
|
8 |
+
function aws_register_widget() {
|
9 |
+
register_widget("AWS_Widget");
|
10 |
+
}
|
11 |
+
|
12 |
+
class AWS_Widget extends WP_Widget {
|
13 |
+
|
14 |
+
/*
|
15 |
+
* Constructor
|
16 |
+
*/
|
17 |
+
function __construct() {
|
18 |
+
$widget_ops = array( 'description' => __('Advanced WooCommerce search widget', 'advanced-woo-search' ) );
|
19 |
+
$control_ops = array( 'width' => 400 );
|
20 |
+
parent::__construct( false, __( '» AWS Widget', 'advanced-woo-search' ), $widget_ops, $control_ops );
|
21 |
+
}
|
22 |
+
|
23 |
+
/*
|
24 |
+
* Display widget
|
25 |
+
*/
|
26 |
+
function widget( $args, $instance ) {
|
27 |
+
extract( $args );
|
28 |
+
|
29 |
+
$title = apply_filters( 'widget_title',
|
30 |
+
( ! empty( $instance['title'] ) ? $instance['title'] : '' ),
|
31 |
+
$instance,
|
32 |
+
$this->id_base
|
33 |
+
);
|
34 |
+
|
35 |
+
echo $before_widget;
|
36 |
+
|
37 |
+
if ( $title ) {
|
38 |
+
echo $before_title;
|
39 |
+
echo $title;
|
40 |
+
echo $after_title;
|
41 |
+
}
|
42 |
+
|
43 |
+
// Generate search form markup
|
44 |
+
echo AWS()->markup();
|
45 |
+
|
46 |
+
echo $after_widget;
|
47 |
+
}
|
48 |
+
|
49 |
+
/*
|
50 |
+
* Update widget settings
|
51 |
+
*/
|
52 |
+
function update( $new_instance, $old_instance ) {
|
53 |
+
$instance = $old_instance;
|
54 |
+
$params = array( 'title' );
|
55 |
+
foreach ( $params as $k ) {
|
56 |
+
$instance[$k] = strip_tags( $new_instance[$k] );
|
57 |
+
}
|
58 |
+
return $instance;
|
59 |
+
}
|
60 |
+
|
61 |
+
/*
|
62 |
+
* Widget settings form
|
63 |
+
*/
|
64 |
+
function form( $instance ) {
|
65 |
+
global $shortname;
|
66 |
+
$defaults = array(
|
67 |
+
'title' => __( 'Search...', 'advanced-woo-search' )
|
68 |
+
);
|
69 |
+
$instance = wp_parse_args( (array) $instance, $defaults );
|
70 |
+
?>
|
71 |
+
|
72 |
+
<p>
|
73 |
+
<label for="<?php echo esc_attr( $this->get_field_id('title') ); ?>"><?php esc_html_e( 'Title:', 'advanced-woo-search' ); ?></label>
|
74 |
+
<input type="text" class="widefat" id="<?php echo esc_attr( $this->get_field_id('title') ); ?>" name="<?php echo esc_attr( $this->get_field_name('title') ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>">
|
75 |
+
</p>
|
76 |
+
|
77 |
+
<?php
|
78 |
+
}
|
79 |
+
}
|
80 |
?>
|
languages/advanced-woo-search-de_DE.po
CHANGED
@@ -1,546 +1,546 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: Advanced Woo Search\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"MIME-Version: 1.0\n"
|
6 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
7 |
-
"Content-Transfer-Encoding: 8bit\n"
|
8 |
-
"X-Generator: Loco https://localise.biz/\n"
|
9 |
-
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
|
10 |
-
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
|
11 |
-
"esc_html_x:1,2c;\n"
|
12 |
-
"Language: de_DE_formal\n"
|
13 |
-
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
14 |
-
"X-Poedit-Country: United States\n"
|
15 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
-
"X-Poedit-Basepath: ../\n"
|
17 |
-
"X-Poedit-SearchPath-0: .\n"
|
18 |
-
"X-Poedit-Bookmarks: \n"
|
19 |
-
"X-Textdomain-Support: yes\n"
|
20 |
-
"POT-Creation-Date: 2020-04-30 16:05+0000\n"
|
21 |
-
"PO-Revision-Date: 2020-05-14 08:05+0000\n"
|
22 |
-
"Last-Translator: Tafel Geschäft\n"
|
23 |
-
"Language-Team: Deutsch (Sie)\n"
|
24 |
-
"X-Loco-Version: 2.3.3; wp-5.4.1"
|
25 |
-
|
26 |
-
#: includes/class-aws-admin.php:129
|
27 |
-
msgid "Save Changes"
|
28 |
-
msgstr "speichern"
|
29 |
-
|
30 |
-
#: includes/class-aws-admin.php:351
|
31 |
-
msgid "Reindex table"
|
32 |
-
msgstr "Tabelle erneut indizieren"
|
33 |
-
|
34 |
-
msgid ""
|
35 |
-
"This action only need for %s one time %s - after you activate this plugin. "
|
36 |
-
"After this all products changes will be re-indexed automatically."
|
37 |
-
msgstr ""
|
38 |
-
"Diese Aktion benötigt nur einmal % s % s - nachdem Sie dieses Plugin "
|
39 |
-
"aktiviert haben. Danach werden alle Produktänderungen automatisch neu "
|
40 |
-
"indiziert."
|
41 |
-
|
42 |
-
msgid "Go to Settings Page"
|
43 |
-
msgstr "Zu den Einstellungen"
|
44 |
-
|
45 |
-
#: includes/class-aws-admin.php:352
|
46 |
-
msgid ""
|
47 |
-
"Update all data in plugins index table. Index table - table with products "
|
48 |
-
"data where plugin is searching all typed terms.<br>Use this button if you "
|
49 |
-
"think that plugin not shows last actual data in its search results.<br>"
|
50 |
-
"<strong>CAUTION:</strong> this can take large amount of time.</span>"
|
51 |
-
msgstr ""
|
52 |
-
"Aktualisieren Sie alle Daten in der Plugins-Indextabelle. Indextabelle - "
|
53 |
-
"Tabelle mit Produktdaten, in der das Plugin alle eingegebenen Begriffe "
|
54 |
-
"durchsucht. <br> Verwenden Sie diese Schaltfläche, wenn Sie der Meinung sind,"
|
55 |
-
" dass das Plugin in seinen Suchergebnissen nicht die letzten tatsächlichen "
|
56 |
-
"Daten anzeigt. <br> <strong> VORSICHT: </ strong> Dies kann längere Zeit "
|
57 |
-
"dauern. </ span>"
|
58 |
-
|
59 |
-
#: includes/class-aws-admin.php:362
|
60 |
-
msgid "Clear cache"
|
61 |
-
msgstr "Cache löschen"
|
62 |
-
|
63 |
-
#: includes/class-aws-admin.php:363
|
64 |
-
msgid "Clear cache for all search results."
|
65 |
-
msgstr "Cache löschen für alle Suchergebnisse"
|
66 |
-
|
67 |
-
#: includes/options.php:111
|
68 |
-
msgid ""
|
69 |
-
"Smart scrapping sentences with searching terms from product description."
|
70 |
-
msgstr ""
|
71 |
-
"Intelligente Verkürzung von Sätzen mit Suchbegriffen aus der "
|
72 |
-
"Produktbeschreibung."
|
73 |
-
|
74 |
-
#: includes/options.php:112
|
75 |
-
msgid ""
|
76 |
-
"First N words of product description ( number of words that you choose below."
|
77 |
-
" )"
|
78 |
-
msgstr ""
|
79 |
-
"Die ersten N Worde der Produktbeschreibung (Anzahl an Wörtern, die du unten "
|
80 |
-
"auswählst)"
|
81 |
-
|
82 |
-
#: advanced-woo-search.php:113
|
83 |
-
msgid "Sale!"
|
84 |
-
msgstr "Abverkauf!"
|
85 |
-
|
86 |
-
msgid "SKU"
|
87 |
-
msgstr "SKU"
|
88 |
-
|
89 |
-
msgid "View all results"
|
90 |
-
msgstr "Alle Ergebnisse anzeigen"
|
91 |
-
|
92 |
-
#: advanced-woo-search.php:127
|
93 |
-
msgid "Settings"
|
94 |
-
msgstr "Einstellungen"
|
95 |
-
|
96 |
-
#: advanced-woo-search.php:130 includes/class-aws-admin.php:63
|
97 |
-
msgid "Get Premium"
|
98 |
-
msgstr "Hol' dir Premium"
|
99 |
-
|
100 |
-
#: advanced-woo-search.php:166
|
101 |
-
msgid ""
|
102 |
-
"Advanced Woo Search plugin is enabled but not effective. It requires "
|
103 |
-
"WooCommerce in order to work."
|
104 |
-
msgstr ""
|
105 |
-
"Advanced Woo Search plugin ist aktiviert, jedoch nicht in Verwendung. Es "
|
106 |
-
"benötigt WooCommerce um zu funktionieren. "
|
107 |
-
|
108 |
-
#: includes/widget.php:15
|
109 |
-
msgid "Advanced WooCommerce search widget"
|
110 |
-
msgstr "Advanced WooCommerce search widget"
|
111 |
-
|
112 |
-
#: includes/widget.php:17
|
113 |
-
msgid "» AWS Widget"
|
114 |
-
msgstr "» AWS Widget"
|
115 |
-
|
116 |
-
#: includes/widget.php:56
|
117 |
-
msgid "Search..."
|
118 |
-
msgstr "Suche..."
|
119 |
-
|
120 |
-
#: includes/widget.php:62
|
121 |
-
msgid "Title:"
|
122 |
-
msgstr "Titel:"
|
123 |
-
|
124 |
-
#: includes/class-aws-admin.php:38 includes/class-aws-admin.php:38
|
125 |
-
msgid "Adv. Woo Search"
|
126 |
-
msgstr "Adv. Woo Search"
|
127 |
-
|
128 |
-
#: includes/class-aws-admin.php:49
|
129 |
-
msgid "General"
|
130 |
-
msgstr "Allgemein"
|
131 |
-
|
132 |
-
#: includes/class-aws-admin.php:296
|
133 |
-
msgid "Active sources"
|
134 |
-
msgstr "Aktive Quellen"
|
135 |
-
|
136 |
-
#: includes/class-aws-admin.php:297
|
137 |
-
msgid "Change order by drag&drop"
|
138 |
-
msgstr "Ändere die Reihenfolge per Drag&Drop"
|
139 |
-
|
140 |
-
#: includes/class-aws-admin.php:316
|
141 |
-
msgid "Deactivated sources"
|
142 |
-
msgstr "Deaktivierte Quellen"
|
143 |
-
|
144 |
-
#: includes/class-aws-admin.php:317
|
145 |
-
msgid "Excluded from search results"
|
146 |
-
msgstr "Ausgeschlossen aus Suchergebnissen"
|
147 |
-
|
148 |
-
#: includes/options.php:9
|
149 |
-
msgid "Cache results"
|
150 |
-
msgstr "Cache Ergebnisse"
|
151 |
-
|
152 |
-
msgid "Sync index table"
|
153 |
-
msgstr "Indizierungstabelle synchronisieren"
|
154 |
-
|
155 |
-
msgid ""
|
156 |
-
"Automatically update plugin index table when product content was changed. "
|
157 |
-
"This means that in search there will be always latest product data."
|
158 |
-
msgstr ""
|
159 |
-
"Bei Produktänderungen automatisch die Indextabelle updaten, wenn "
|
160 |
-
"Produktinhalte geändert wereden. Das bedeutet, dass in der Suche jeweils die "
|
161 |
-
"aktuellen Produktdaten verwendet werden. "
|
162 |
-
|
163 |
-
msgid "Turn this off if you have any problems with performance."
|
164 |
-
msgstr ""
|
165 |
-
"Deaktivieren Sie diese Option, wenn Sie Probleme mit der Leistung haben."
|
166 |
-
|
167 |
-
msgid "Main Settings"
|
168 |
-
msgstr "Haupteinstellungen"
|
169 |
-
|
170 |
-
msgid "Seamless integration"
|
171 |
-
msgstr "nahtlose Integration"
|
172 |
-
|
173 |
-
msgid ""
|
174 |
-
"Replace all the standard search forms on your website ( may not work with "
|
175 |
-
"some themes )."
|
176 |
-
msgstr ""
|
177 |
-
"Ersetzt alle Standard Suchformulare auf Webseite (funktioniert "
|
178 |
-
"möglicherweise nicht mit jedem Theme)."
|
179 |
-
|
180 |
-
msgid "Activation"
|
181 |
-
msgstr "Aktivierung"
|
182 |
-
|
183 |
-
msgid ""
|
184 |
-
"In case you need to add plugin search form on your website, you can do it in "
|
185 |
-
"several ways:"
|
186 |
-
msgstr ""
|
187 |
-
"Wenn Sie das Plugin Suchformular in Ihre Webseite hinzufügen wollen, gibt es "
|
188 |
-
"dafür mehrere Wege:"
|
189 |
-
|
190 |
-
msgid ""
|
191 |
-
"Enable a \"Seamless integration\" option ( may not work with some themes )"
|
192 |
-
msgstr ""
|
193 |
-
"Aktiviere die \"nahtlose Integration\" (funktioniert möglicherweise nicht "
|
194 |
-
"mit jedem Theme)"
|
195 |
-
|
196 |
-
msgid "Add search form using shortcode %s"
|
197 |
-
msgstr "Füge das Suchformular per Shortcode hinzu %s"
|
198 |
-
|
199 |
-
msgid ""
|
200 |
-
"Add search form as widget for one of your theme widget areas. Go to "
|
201 |
-
"Appearance -> Widgets and drag&drop AWS Widget to one of your widget areas"
|
202 |
-
msgstr ""
|
203 |
-
"Füge ein Suchformular als Widget in den Widget-Bereichen deines Themes hinzu."
|
204 |
-
" Gehe zu Design-> Widget und ziehe das AWS Widget in einen deiner Widget-"
|
205 |
-
"Bereiche. "
|
206 |
-
|
207 |
-
msgid "Add PHP code to the necessary files of your theme: %s"
|
208 |
-
msgstr "Füge PHP Code zu den notwendigen Dateien deines Themes hinzu. %s"
|
209 |
-
|
210 |
-
#: includes/options.php:10
|
211 |
-
msgid ""
|
212 |
-
"Turn off if you have old data in the search results after content of "
|
213 |
-
"products was changed.<br><strong>CAUTION:</strong> can dramatically increase "
|
214 |
-
"search speed"
|
215 |
-
msgstr ""
|
216 |
-
"Deaktivieren Sie diese Option, wenn Sie alte Daten in den Suchergebnissen "
|
217 |
-
"haben, nachdem der Inhalt von Produkten geändert wurde. <br> <strong> "
|
218 |
-
"VORSICHT: </ strong> kann die Suchgeschwindigkeit erheblich erhöhen"
|
219 |
-
|
220 |
-
#: includes/options.php:15 includes/options.php:43 includes/options.php:55
|
221 |
-
#: includes/options.php:67 includes/options.php:99 includes/options.php:123
|
222 |
-
#: includes/options.php:135 includes/options.php:147 includes/options.php:159
|
223 |
-
msgid "On"
|
224 |
-
msgstr "an"
|
225 |
-
|
226 |
-
#: includes/options.php:16 includes/options.php:44 includes/options.php:56
|
227 |
-
#: includes/options.php:68 includes/options.php:100 includes/options.php:124
|
228 |
-
#: includes/options.php:136 includes/options.php:148 includes/options.php:160
|
229 |
-
msgid "Off"
|
230 |
-
msgstr "Aus"
|
231 |
-
|
232 |
-
#: includes/options.php:21
|
233 |
-
msgid "Text for search field"
|
234 |
-
msgstr "Text für das Suchfeld"
|
235 |
-
|
236 |
-
#: includes/options.php:22
|
237 |
-
msgid "Text for search field placeholder."
|
238 |
-
msgstr "Text als Platzhalter im Suchfeld."
|
239 |
-
|
240 |
-
#: includes/options.php:35
|
241 |
-
msgid "Search"
|
242 |
-
msgstr "Suche"
|
243 |
-
|
244 |
-
msgid "Text for show more button"
|
245 |
-
msgstr "Text für die ...mehr anzeigen Schaltfläche"
|
246 |
-
|
247 |
-
msgid ""
|
248 |
-
"Text for link to search results page at the bottom of search results block."
|
249 |
-
msgstr ""
|
250 |
-
"Text für den Link auf die Suchergebnisse Seite am Ende des "
|
251 |
-
"Suchergebnisblocks im Suchformular."
|
252 |
-
|
253 |
-
#: includes/options.php:40
|
254 |
-
msgid "Nothing found field"
|
255 |
-
msgstr "Feld nichts gefunden"
|
256 |
-
|
257 |
-
#: includes/options.php:41
|
258 |
-
msgid "Text when there is no search results."
|
259 |
-
msgstr "Text wenn kein Suchergebnis angezeigt werden kann"
|
260 |
-
|
261 |
-
#: includes/options.php:43
|
262 |
-
msgid "Nothing found"
|
263 |
-
msgstr "Nichts gefunden"
|
264 |
-
|
265 |
-
#: includes/options.php:29
|
266 |
-
msgid "Minimum number of characters"
|
267 |
-
msgstr "Mindestanzahl an Buchstaben"
|
268 |
-
|
269 |
-
#: includes/options.php:30
|
270 |
-
msgid "Minimum number of characters required to run ajax search."
|
271 |
-
msgstr "Mindestanzahl an Buchstaben um die Ajax-Suche zu starten. "
|
272 |
-
|
273 |
-
#: includes/options.php:37
|
274 |
-
msgid "Show loader"
|
275 |
-
msgstr "Ladeanimation anzeigen"
|
276 |
-
|
277 |
-
#: includes/options.php:38
|
278 |
-
msgid "Show loader animation while searching."
|
279 |
-
msgstr "Ladeanimation während des Suchvorgangs anzeigen"
|
280 |
-
|
281 |
-
msgid "Show clear button"
|
282 |
-
msgstr "Schaltfläche zum Löschen anzeigen"
|
283 |
-
|
284 |
-
msgid ""
|
285 |
-
"Show 'Clear search string' button for desktop devices ( for mobile it is "
|
286 |
-
"always visible )."
|
287 |
-
msgstr ""
|
288 |
-
"Zeige 'Suchbegriff löschen' Knopf für Desktopgeräte (für Mobilgeräte ist "
|
289 |
-
"dies immer sichtbar)"
|
290 |
-
|
291 |
-
msgid "Show 'View All Results'"
|
292 |
-
msgstr "Zeige 'Alle Ergebnisse anzeigen'"
|
293 |
-
|
294 |
-
msgid "Show link to search results page at the bottom of search results block."
|
295 |
-
msgstr ""
|
296 |
-
"Link zur Suchergebnis-Seite am Ende des Blocks mit der Liste der "
|
297 |
-
"Suchergebnisse anzeigen"
|
298 |
-
|
299 |
-
msgid "Mobile full screen"
|
300 |
-
msgstr "Mobilgeräte-Ansicht volle Bildschirmgröße"
|
301 |
-
|
302 |
-
msgid ""
|
303 |
-
"Full screen search on focus. Will not work if the search form is inside the block "
|
304 |
-
"with position: fixed."
|
305 |
-
msgstr ""
|
306 |
-
"Bildschirmfüllende Suche im Fokus. Wird nicht funktionieren, wenn das "
|
307 |
-
"Suchformular innerhalb eines CSS-Blocks mit position: fixed ist. "
|
308 |
-
|
309 |
-
msgid "Search Results"
|
310 |
-
msgstr "Suchergebnisse"
|
311 |
-
|
312 |
-
msgid "Choose how to view search results."
|
313 |
-
msgstr "Wähle, wie die Suchergebnisse angezeigt werden"
|
314 |
-
|
315 |
-
msgid "Both ajax search results and search results page"
|
316 |
-
msgstr "Beide für die Ajax Suchergebnisse und die Suchergebnis Seite"
|
317 |
-
|
318 |
-
msgid "Only ajax search results ( no search results page )"
|
319 |
-
msgstr "Nur Ajax Suchergebnisse (keine Suchergebnis-Seite)"
|
320 |
-
|
321 |
-
msgid "Only search results page ( no ajax search results )"
|
322 |
-
msgstr "Nur Suchergebnis-Seite (keine Ajax-Suchergebnisse)"
|
323 |
-
|
324 |
-
msgid "Form Styling"
|
325 |
-
msgstr "Formular Styling"
|
326 |
-
|
327 |
-
msgid "Choose search form layout"
|
328 |
-
msgstr "Wähle das Formularlayout für das Such-Feld"
|
329 |
-
|
330 |
-
msgid ""
|
331 |
-
"Filter button will be visible only if you have more than one active filter "
|
332 |
-
"for current search form instance."
|
333 |
-
msgstr ""
|
334 |
-
"Der Button zum Filtern wird nur dann sichtbar, wenn mehr als ein aktiver "
|
335 |
-
"Filter für die derzeitige Suche vorhanden ist. "
|
336 |
-
|
337 |
-
msgid "Highlight words"
|
338 |
-
msgstr "Markiere Wörter"
|
339 |
-
|
340 |
-
msgid "Highlight search words inside products content."
|
341 |
-
msgstr "Suchbegriffe markieren innerhalb der Produktbeschreibung"
|
342 |
-
|
343 |
-
#: includes/options.php:49
|
344 |
-
msgid "Show image"
|
345 |
-
msgstr "Bild anzeigen"
|
346 |
-
|
347 |
-
#: includes/options.php:50
|
348 |
-
msgid "Show product image for each search result."
|
349 |
-
msgstr "Produktbild für jedes Suchergebnis anzeigen"
|
350 |
-
|
351 |
-
#: includes/options.php:61
|
352 |
-
msgid "Show description"
|
353 |
-
msgstr "Beschreibung anzeigen"
|
354 |
-
|
355 |
-
#: includes/options.php:62
|
356 |
-
msgid "Show product description for each search result."
|
357 |
-
msgstr "Produktbeschreibung für jedes Suchergebnis anzeigen"
|
358 |
-
|
359 |
-
#: includes/options.php:73
|
360 |
-
msgid "Description source"
|
361 |
-
msgstr "Beschreibungsquelle"
|
362 |
-
|
363 |
-
#: includes/options.php:74
|
364 |
-
msgid ""
|
365 |
-
"From where to take product description.<br>If first source is empty data "
|
366 |
-
"will be taken from other sources."
|
367 |
-
msgstr ""
|
368 |
-
"Von wo die Produktbeschreibung verwendet wird. <br>Wenn die erste Quelle "
|
369 |
-
"leer ist, werden die Daten von anderen Quellen verwendet. "
|
370 |
-
|
371 |
-
#: includes/options.php:79
|
372 |
-
msgid "Content"
|
373 |
-
msgstr "Inhalt"
|
374 |
-
|
375 |
-
#: includes/options.php:80
|
376 |
-
msgid "Short description"
|
377 |
-
msgstr "Kurzbeschreibung"
|
378 |
-
|
379 |
-
#: includes/options.php:85
|
380 |
-
msgid "Description length"
|
381 |
-
msgstr "Beschreibungslänge"
|
382 |
-
|
383 |
-
#: includes/options.php:86
|
384 |
-
msgid "Maximal allowed number of words for product description."
|
385 |
-
msgstr "Maximal erlaubte Anzahl an Wörtern in der Produktbeschreibung."
|
386 |
-
|
387 |
-
#: includes/options.php:93
|
388 |
-
msgid "Show price"
|
389 |
-
msgstr "Preis anzeigen"
|
390 |
-
|
391 |
-
#: includes/options.php:94
|
392 |
-
msgid "Show product price for each search result."
|
393 |
-
msgstr "Produktpreis für jedes Suchergebnis anzeigen"
|
394 |
-
|
395 |
-
msgid "Show price for out of stock"
|
396 |
-
msgstr "Zeige Preise für nicht vorrätig"
|
397 |
-
|
398 |
-
msgid "Show product price for out of stock products."
|
399 |
-
msgstr "Zeige Produkt Preis für nicht vorrätige Artikel"
|
400 |
-
|
401 |
-
#: includes/options.php:105
|
402 |
-
msgid "Description content"
|
403 |
-
msgstr "Beschreibungs-Inhalt"
|
404 |
-
|
405 |
-
#: includes/options.php:106
|
406 |
-
msgid "What to show in product description?"
|
407 |
-
msgstr "Was soll in der Produktbeschreibung angezeigt werden?"
|
408 |
-
|
409 |
-
#: includes/options.php:117
|
410 |
-
msgid "Show categories archive"
|
411 |
-
msgstr "Zeige Kategorie Archiv"
|
412 |
-
|
413 |
-
#: includes/options.php:118
|
414 |
-
msgid "Include categories archives pages to search result."
|
415 |
-
msgstr "Schließt die Kategorie-Archiv-Seiten in die Suchergebnisse ein."
|
416 |
-
|
417 |
-
#: includes/options.php:129
|
418 |
-
msgid "Show tags archive"
|
419 |
-
msgstr "Tags Archiv anzeigen"
|
420 |
-
|
421 |
-
#: includes/options.php:130
|
422 |
-
msgid "Include tags archives pages to search results."
|
423 |
-
msgstr "Schließt die Tag-Archiv-Seiten in die Suchergebnisse ein."
|
424 |
-
|
425 |
-
#: includes/options.php:141
|
426 |
-
msgid "Show sale badge"
|
427 |
-
msgstr "Sale Abzeichen anzeigen"
|
428 |
-
|
429 |
-
#: includes/options.php:142
|
430 |
-
msgid "Show sale badge for products in search results."
|
431 |
-
msgstr "Das Zeichen für Abverkaufsprodukte in den Suchergebnissen anzeigen"
|
432 |
-
|
433 |
-
#: includes/options.php:153
|
434 |
-
msgid "Show product SKU"
|
435 |
-
msgstr "Produkt SKU anzeigen"
|
436 |
-
|
437 |
-
#: includes/options.php:154
|
438 |
-
msgid "Show product SKU in search results."
|
439 |
-
msgstr "Produkt SKU für jedes Suchergebnis anzeigen"
|
440 |
-
|
441 |
-
msgid "Show stock status"
|
442 |
-
msgstr "Zeige den Lagerstatus"
|
443 |
-
|
444 |
-
msgid "Show stock status for every product in search results."
|
445 |
-
msgstr "Zeige den Lagerstatus für jedes Produkt in den Suchergebnissen"
|
446 |
-
|
447 |
-
msgid "Show featured icon"
|
448 |
-
msgstr "Featured Symbol anzeigen"
|
449 |
-
|
450 |
-
msgid "Show or not star icon for featured products."
|
451 |
-
msgstr "Sternsymbol bei Feature Produkten anzeigen oder nicht"
|
452 |
-
|
453 |
-
#: includes/options.php:167
|
454 |
-
msgid "Max number of results"
|
455 |
-
msgstr "Maximale Anzahl an Ergebnissen"
|
456 |
-
|
457 |
-
#: includes/options.php:168
|
458 |
-
msgid "Maximum number of displayed search results."
|
459 |
-
msgstr "Maximale Anzahl an angezeigten Suchergebnissen."
|
460 |
-
|
461 |
-
#: includes/options.php:175
|
462 |
-
msgid "Search in"
|
463 |
-
msgstr "Suche in"
|
464 |
-
|
465 |
-
#: includes/options.php:176
|
466 |
-
msgid "Search source: Drag&drop sources to activate or deactivate them."
|
467 |
-
msgstr ""
|
468 |
-
"Suchquellen: Ziehen & Ablegen von Quellen, um diese zu aktivieren oder zu "
|
469 |
-
"deaktivieren. "
|
470 |
-
|
471 |
-
#: includes/options.php:30
|
472 |
-
msgid "Show out-of-stock"
|
473 |
-
msgstr "Zeige nicht vorrätige Artikel"
|
474 |
-
|
475 |
-
#: includes/options.php:31
|
476 |
-
msgid "Show out-of-stock products in search"
|
477 |
-
msgstr "Nicht vorrätige Artikel in der Suche anzeigen"
|
478 |
-
|
479 |
-
msgid "Stop words list"
|
480 |
-
msgstr "Stop Wörter Liste"
|
481 |
-
|
482 |
-
msgid "Comma separated list of words that will be excluded from search."
|
483 |
-
msgstr ""
|
484 |
-
"Komma-separierte Liste von Wörtern, die von der Suche ausgeschlossen werden."
|
485 |
-
|
486 |
-
msgid "Re-index required on change."
|
487 |
-
msgstr "Re-Indizierung bei Änderung."
|
488 |
-
|
489 |
-
msgid "Synonyms"
|
490 |
-
msgstr "Synonyme"
|
491 |
-
|
492 |
-
msgid ""
|
493 |
-
"Comma separated list of synonym words. Each group of synonyms must be on "
|
494 |
-
"separated text line."
|
495 |
-
msgstr ""
|
496 |
-
"Kommaseparierte Liste von Synonymen. Jede Gruppe von Synonymen auf eine "
|
497 |
-
"einzelne Zeile"
|
498 |
-
|
499 |
-
#: includes/options.php:42
|
500 |
-
msgid "Use Google Analytics"
|
501 |
-
msgstr "Verwenden Sie Google Analytics"
|
502 |
-
|
503 |
-
#: includes/options.php:42
|
504 |
-
msgid ""
|
505 |
-
"Use google analytics to track searches. You need google analytics to be "
|
506 |
-
"installed on your site."
|
507 |
-
msgstr ""
|
508 |
-
"Verwenden Sie Google Analytics, um Suchanfragen zu verfolgen. Dazu muss "
|
509 |
-
"Google Analytics eingerichtet sein, um mit Ihrer Webseite interagieren zu "
|
510 |
-
"können. (Code eingefügt)"
|
511 |
-
|
512 |
-
msgid ""
|
513 |
-
"Data will be visible inside Google Analytics 'Site Search' report. Need to "
|
514 |
-
"activate 'Site Search' feature inside GA. %s"
|
515 |
-
msgstr ""
|
516 |
-
"Daten werden innerhalb von Google Analytics 'Site Search' angezeigt. Dafür "
|
517 |
-
"muss dieses Feature in GA aktiviert sein. %s"
|
518 |
-
|
519 |
-
msgid "More info"
|
520 |
-
msgstr "weitere Informationen"
|
521 |
-
|
522 |
-
#: includes/options.php:42
|
523 |
-
msgid ""
|
524 |
-
"Also will send event with category - 'AWS search', action - 'AWS Search "
|
525 |
-
"Term' and label of value of search term."
|
526 |
-
msgstr ""
|
527 |
-
"Wird zusätzlich ein Ereignis mit Kategorie 'AWS search ', action - 'AWS "
|
528 |
-
"Suchbegriff' und den Wert des Labels des Suchbegriffs senden."
|
529 |
-
|
530 |
-
msgid "In stock"
|
531 |
-
msgstr "vorrätig"
|
532 |
-
|
533 |
-
msgid "Out of stock"
|
534 |
-
msgstr "nicht vorrätig"
|
535 |
-
|
536 |
-
#. Name of the plugin
|
537 |
-
msgid "Advanced Woo Search"
|
538 |
-
msgstr "Advanced Woo Search"
|
539 |
-
|
540 |
-
#. Description of the plugin
|
541 |
-
msgid "Advance ajax WooCommerce product search."
|
542 |
-
msgstr "Advance Ajax WooCommerce Produkt Suche."
|
543 |
-
|
544 |
-
#. Author of the plugin
|
545 |
-
msgid "ILLID"
|
546 |
-
msgstr "ILLID"
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Advanced Woo Search\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"MIME-Version: 1.0\n"
|
6 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
7 |
+
"Content-Transfer-Encoding: 8bit\n"
|
8 |
+
"X-Generator: Loco https://localise.biz/\n"
|
9 |
+
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
|
10 |
+
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
|
11 |
+
"esc_html_x:1,2c;\n"
|
12 |
+
"Language: de_DE_formal\n"
|
13 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
14 |
+
"X-Poedit-Country: United States\n"
|
15 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
16 |
+
"X-Poedit-Basepath: ../\n"
|
17 |
+
"X-Poedit-SearchPath-0: .\n"
|
18 |
+
"X-Poedit-Bookmarks: \n"
|
19 |
+
"X-Textdomain-Support: yes\n"
|
20 |
+
"POT-Creation-Date: 2020-04-30 16:05+0000\n"
|
21 |
+
"PO-Revision-Date: 2020-05-14 08:05+0000\n"
|
22 |
+
"Last-Translator: Tafel Geschäft\n"
|
23 |
+
"Language-Team: Deutsch (Sie)\n"
|
24 |
+
"X-Loco-Version: 2.3.3; wp-5.4.1"
|
25 |
+
|
26 |
+
#: includes/class-aws-admin.php:129
|
27 |
+
msgid "Save Changes"
|
28 |
+
msgstr "speichern"
|
29 |
+
|
30 |
+
#: includes/class-aws-admin.php:351
|
31 |
+
msgid "Reindex table"
|
32 |
+
msgstr "Tabelle erneut indizieren"
|
33 |
+
|
34 |
+
msgid ""
|
35 |
+
"This action only need for %s one time %s - after you activate this plugin. "
|
36 |
+
"After this all products changes will be re-indexed automatically."
|
37 |
+
msgstr ""
|
38 |
+
"Diese Aktion benötigt nur einmal % s % s - nachdem Sie dieses Plugin "
|
39 |
+
"aktiviert haben. Danach werden alle Produktänderungen automatisch neu "
|
40 |
+
"indiziert."
|
41 |
+
|
42 |
+
msgid "Go to Settings Page"
|
43 |
+
msgstr "Zu den Einstellungen"
|
44 |
+
|
45 |
+
#: includes/class-aws-admin.php:352
|
46 |
+
msgid ""
|
47 |
+
"Update all data in plugins index table. Index table - table with products "
|
48 |
+
"data where plugin is searching all typed terms.<br>Use this button if you "
|
49 |
+
"think that plugin not shows last actual data in its search results.<br>"
|
50 |
+
"<strong>CAUTION:</strong> this can take large amount of time.</span>"
|
51 |
+
msgstr ""
|
52 |
+
"Aktualisieren Sie alle Daten in der Plugins-Indextabelle. Indextabelle - "
|
53 |
+
"Tabelle mit Produktdaten, in der das Plugin alle eingegebenen Begriffe "
|
54 |
+
"durchsucht. <br> Verwenden Sie diese Schaltfläche, wenn Sie der Meinung sind,"
|
55 |
+
" dass das Plugin in seinen Suchergebnissen nicht die letzten tatsächlichen "
|
56 |
+
"Daten anzeigt. <br> <strong> VORSICHT: </ strong> Dies kann längere Zeit "
|
57 |
+
"dauern. </ span>"
|
58 |
+
|
59 |
+
#: includes/class-aws-admin.php:362
|
60 |
+
msgid "Clear cache"
|
61 |
+
msgstr "Cache löschen"
|
62 |
+
|
63 |
+
#: includes/class-aws-admin.php:363
|
64 |
+
msgid "Clear cache for all search results."
|
65 |
+
msgstr "Cache löschen für alle Suchergebnisse"
|
66 |
+
|
67 |
+
#: includes/options.php:111
|
68 |
+
msgid ""
|
69 |
+
"Smart scrapping sentences with searching terms from product description."
|
70 |
+
msgstr ""
|
71 |
+
"Intelligente Verkürzung von Sätzen mit Suchbegriffen aus der "
|
72 |
+
"Produktbeschreibung."
|
73 |
+
|
74 |
+
#: includes/options.php:112
|
75 |
+
msgid ""
|
76 |
+
"First N words of product description ( number of words that you choose below."
|
77 |
+
" )"
|
78 |
+
msgstr ""
|
79 |
+
"Die ersten N Worde der Produktbeschreibung (Anzahl an Wörtern, die du unten "
|
80 |
+
"auswählst)"
|
81 |
+
|
82 |
+
#: advanced-woo-search.php:113
|
83 |
+
msgid "Sale!"
|
84 |
+
msgstr "Abverkauf!"
|
85 |
+
|
86 |
+
msgid "SKU"
|
87 |
+
msgstr "SKU"
|
88 |
+
|
89 |
+
msgid "View all results"
|
90 |
+
msgstr "Alle Ergebnisse anzeigen"
|
91 |
+
|
92 |
+
#: advanced-woo-search.php:127
|
93 |
+
msgid "Settings"
|
94 |
+
msgstr "Einstellungen"
|
95 |
+
|
96 |
+
#: advanced-woo-search.php:130 includes/class-aws-admin.php:63
|
97 |
+
msgid "Get Premium"
|
98 |
+
msgstr "Hol' dir Premium"
|
99 |
+
|
100 |
+
#: advanced-woo-search.php:166
|
101 |
+
msgid ""
|
102 |
+
"Advanced Woo Search plugin is enabled but not effective. It requires "
|
103 |
+
"WooCommerce in order to work."
|
104 |
+
msgstr ""
|
105 |
+
"Advanced Woo Search plugin ist aktiviert, jedoch nicht in Verwendung. Es "
|
106 |
+
"benötigt WooCommerce um zu funktionieren. "
|
107 |
+
|
108 |
+
#: includes/widget.php:15
|
109 |
+
msgid "Advanced WooCommerce search widget"
|
110 |
+
msgstr "Advanced WooCommerce search widget"
|
111 |
+
|
112 |
+
#: includes/widget.php:17
|
113 |
+
msgid "» AWS Widget"
|
114 |
+
msgstr "» AWS Widget"
|
115 |
+
|
116 |
+
#: includes/widget.php:56
|
117 |
+
msgid "Search..."
|
118 |
+
msgstr "Suche..."
|
119 |
+
|
120 |
+
#: includes/widget.php:62
|
121 |
+
msgid "Title:"
|
122 |
+
msgstr "Titel:"
|
123 |
+
|
124 |
+
#: includes/class-aws-admin.php:38 includes/class-aws-admin.php:38
|
125 |
+
msgid "Adv. Woo Search"
|
126 |
+
msgstr "Adv. Woo Search"
|
127 |
+
|
128 |
+
#: includes/class-aws-admin.php:49
|
129 |
+
msgid "General"
|
130 |
+
msgstr "Allgemein"
|
131 |
+
|
132 |
+
#: includes/class-aws-admin.php:296
|
133 |
+
msgid "Active sources"
|
134 |
+
msgstr "Aktive Quellen"
|
135 |
+
|
136 |
+
#: includes/class-aws-admin.php:297
|
137 |
+
msgid "Change order by drag&drop"
|
138 |
+
msgstr "Ändere die Reihenfolge per Drag&Drop"
|
139 |
+
|
140 |
+
#: includes/class-aws-admin.php:316
|
141 |
+
msgid "Deactivated sources"
|
142 |
+
msgstr "Deaktivierte Quellen"
|
143 |
+
|
144 |
+
#: includes/class-aws-admin.php:317
|
145 |
+
msgid "Excluded from search results"
|
146 |
+
msgstr "Ausgeschlossen aus Suchergebnissen"
|
147 |
+
|
148 |
+
#: includes/options.php:9
|
149 |
+
msgid "Cache results"
|
150 |
+
msgstr "Cache Ergebnisse"
|
151 |
+
|
152 |
+
msgid "Sync index table"
|
153 |
+
msgstr "Indizierungstabelle synchronisieren"
|
154 |
+
|
155 |
+
msgid ""
|
156 |
+
"Automatically update plugin index table when product content was changed. "
|
157 |
+
"This means that in search there will be always latest product data."
|
158 |
+
msgstr ""
|
159 |
+
"Bei Produktänderungen automatisch die Indextabelle updaten, wenn "
|
160 |
+
"Produktinhalte geändert wereden. Das bedeutet, dass in der Suche jeweils die "
|
161 |
+
"aktuellen Produktdaten verwendet werden. "
|
162 |
+
|
163 |
+
msgid "Turn this off if you have any problems with performance."
|
164 |
+
msgstr ""
|
165 |
+
"Deaktivieren Sie diese Option, wenn Sie Probleme mit der Leistung haben."
|
166 |
+
|
167 |
+
msgid "Main Settings"
|
168 |
+
msgstr "Haupteinstellungen"
|
169 |
+
|
170 |
+
msgid "Seamless integration"
|
171 |
+
msgstr "nahtlose Integration"
|
172 |
+
|
173 |
+
msgid ""
|
174 |
+
"Replace all the standard search forms on your website ( may not work with "
|
175 |
+
"some themes )."
|
176 |
+
msgstr ""
|
177 |
+
"Ersetzt alle Standard Suchformulare auf Webseite (funktioniert "
|
178 |
+
"möglicherweise nicht mit jedem Theme)."
|
179 |
+
|
180 |
+
msgid "Activation"
|
181 |
+
msgstr "Aktivierung"
|
182 |
+
|
183 |
+
msgid ""
|
184 |
+
"In case you need to add plugin search form on your website, you can do it in "
|
185 |
+
"several ways:"
|
186 |
+
msgstr ""
|
187 |
+
"Wenn Sie das Plugin Suchformular in Ihre Webseite hinzufügen wollen, gibt es "
|
188 |
+
"dafür mehrere Wege:"
|
189 |
+
|
190 |
+
msgid ""
|
191 |
+
"Enable a \"Seamless integration\" option ( may not work with some themes )"
|
192 |
+
msgstr ""
|
193 |
+
"Aktiviere die \"nahtlose Integration\" (funktioniert möglicherweise nicht "
|
194 |
+
"mit jedem Theme)"
|
195 |
+
|
196 |
+
msgid "Add search form using shortcode %s"
|
197 |
+
msgstr "Füge das Suchformular per Shortcode hinzu %s"
|
198 |
+
|
199 |
+
msgid ""
|
200 |
+
"Add search form as widget for one of your theme widget areas. Go to "
|
201 |
+
"Appearance -> Widgets and drag&drop AWS Widget to one of your widget areas"
|
202 |
+
msgstr ""
|
203 |
+
"Füge ein Suchformular als Widget in den Widget-Bereichen deines Themes hinzu."
|
204 |
+
" Gehe zu Design-> Widget und ziehe das AWS Widget in einen deiner Widget-"
|
205 |
+
"Bereiche. "
|
206 |
+
|
207 |
+
msgid "Add PHP code to the necessary files of your theme: %s"
|
208 |
+
msgstr "Füge PHP Code zu den notwendigen Dateien deines Themes hinzu. %s"
|
209 |
+
|
210 |
+
#: includes/options.php:10
|
211 |
+
msgid ""
|
212 |
+
"Turn off if you have old data in the search results after content of "
|
213 |
+
"products was changed.<br><strong>CAUTION:</strong> can dramatically increase "
|
214 |
+
"search speed"
|
215 |
+
msgstr ""
|
216 |
+
"Deaktivieren Sie diese Option, wenn Sie alte Daten in den Suchergebnissen "
|
217 |
+
"haben, nachdem der Inhalt von Produkten geändert wurde. <br> <strong> "
|
218 |
+
"VORSICHT: </ strong> kann die Suchgeschwindigkeit erheblich erhöhen"
|
219 |
+
|
220 |
+
#: includes/options.php:15 includes/options.php:43 includes/options.php:55
|
221 |
+
#: includes/options.php:67 includes/options.php:99 includes/options.php:123
|
222 |
+
#: includes/options.php:135 includes/options.php:147 includes/options.php:159
|
223 |
+
msgid "On"
|
224 |
+
msgstr "an"
|
225 |
+
|
226 |
+
#: includes/options.php:16 includes/options.php:44 includes/options.php:56
|
227 |
+
#: includes/options.php:68 includes/options.php:100 includes/options.php:124
|
228 |
+
#: includes/options.php:136 includes/options.php:148 includes/options.php:160
|
229 |
+
msgid "Off"
|
230 |
+
msgstr "Aus"
|
231 |
+
|
232 |
+
#: includes/options.php:21
|
233 |
+
msgid "Text for search field"
|
234 |
+
msgstr "Text für das Suchfeld"
|
235 |
+
|
236 |
+
#: includes/options.php:22
|
237 |
+
msgid "Text for search field placeholder."
|
238 |
+
msgstr "Text als Platzhalter im Suchfeld."
|
239 |
+
|
240 |
+
#: includes/options.php:35
|
241 |
+
msgid "Search"
|
242 |
+
msgstr "Suche"
|
243 |
+
|
244 |
+
msgid "Text for show more button"
|
245 |
+
msgstr "Text für die ...mehr anzeigen Schaltfläche"
|
246 |
+
|
247 |
+
msgid ""
|
248 |
+
"Text for link to search results page at the bottom of search results block."
|
249 |
+
msgstr ""
|
250 |
+
"Text für den Link auf die Suchergebnisse Seite am Ende des "
|
251 |
+
"Suchergebnisblocks im Suchformular."
|
252 |
+
|
253 |
+
#: includes/options.php:40
|
254 |
+
msgid "Nothing found field"
|
255 |
+
msgstr "Feld nichts gefunden"
|
256 |
+
|
257 |
+
#: includes/options.php:41
|
258 |
+
msgid "Text when there is no search results."
|
259 |
+
msgstr "Text wenn kein Suchergebnis angezeigt werden kann"
|
260 |
+
|
261 |
+
#: includes/options.php:43
|
262 |
+
msgid "Nothing found"
|
263 |
+
msgstr "Nichts gefunden"
|
264 |
+
|
265 |
+
#: includes/options.php:29
|
266 |
+
msgid "Minimum number of characters"
|
267 |
+
msgstr "Mindestanzahl an Buchstaben"
|
268 |
+
|
269 |
+
#: includes/options.php:30
|
270 |
+
msgid "Minimum number of characters required to run ajax search."
|
271 |
+
msgstr "Mindestanzahl an Buchstaben um die Ajax-Suche zu starten. "
|
272 |
+
|
273 |
+
#: includes/options.php:37
|
274 |
+
msgid "Show loader"
|
275 |
+
msgstr "Ladeanimation anzeigen"
|
276 |
+
|
277 |
+
#: includes/options.php:38
|
278 |
+
msgid "Show loader animation while searching."
|
279 |
+
msgstr "Ladeanimation während des Suchvorgangs anzeigen"
|
280 |
+
|
281 |
+
msgid "Show clear button"
|
282 |
+
msgstr "Schaltfläche zum Löschen anzeigen"
|
283 |
+
|
284 |
+
msgid ""
|
285 |
+
"Show 'Clear search string' button for desktop devices ( for mobile it is "
|
286 |
+
"always visible )."
|
287 |
+
msgstr ""
|
288 |
+
"Zeige 'Suchbegriff löschen' Knopf für Desktopgeräte (für Mobilgeräte ist "
|
289 |
+
"dies immer sichtbar)"
|
290 |
+
|
291 |
+
msgid "Show 'View All Results'"
|
292 |
+
msgstr "Zeige 'Alle Ergebnisse anzeigen'"
|
293 |
+
|
294 |
+
msgid "Show link to search results page at the bottom of search results block."
|
295 |
+
msgstr ""
|
296 |
+
"Link zur Suchergebnis-Seite am Ende des Blocks mit der Liste der "
|
297 |
+
"Suchergebnisse anzeigen"
|
298 |
+
|
299 |
+
msgid "Mobile full screen"
|
300 |
+
msgstr "Mobilgeräte-Ansicht volle Bildschirmgröße"
|
301 |
+
|
302 |
+
msgid ""
|
303 |
+
"Full screen search on focus. Will not work if the search form is inside the block "
|
304 |
+
"with position: fixed."
|
305 |
+
msgstr ""
|
306 |
+
"Bildschirmfüllende Suche im Fokus. Wird nicht funktionieren, wenn das "
|
307 |
+
"Suchformular innerhalb eines CSS-Blocks mit position: fixed ist. "
|
308 |
+
|
309 |
+
msgid "Search Results"
|
310 |
+
msgstr "Suchergebnisse"
|
311 |
+
|
312 |
+
msgid "Choose how to view search results."
|
313 |
+
msgstr "Wähle, wie die Suchergebnisse angezeigt werden"
|
314 |
+
|
315 |
+
msgid "Both ajax search results and search results page"
|
316 |
+
msgstr "Beide für die Ajax Suchergebnisse und die Suchergebnis Seite"
|
317 |
+
|
318 |
+
msgid "Only ajax search results ( no search results page )"
|
319 |
+
msgstr "Nur Ajax Suchergebnisse (keine Suchergebnis-Seite)"
|
320 |
+
|
321 |
+
msgid "Only search results page ( no ajax search results )"
|
322 |
+
msgstr "Nur Suchergebnis-Seite (keine Ajax-Suchergebnisse)"
|
323 |
+
|
324 |
+
msgid "Form Styling"
|
325 |
+
msgstr "Formular Styling"
|
326 |
+
|
327 |
+
msgid "Choose search form layout"
|
328 |
+
msgstr "Wähle das Formularlayout für das Such-Feld"
|
329 |
+
|
330 |
+
msgid ""
|
331 |
+
"Filter button will be visible only if you have more than one active filter "
|
332 |
+
"for current search form instance."
|
333 |
+
msgstr ""
|
334 |
+
"Der Button zum Filtern wird nur dann sichtbar, wenn mehr als ein aktiver "
|
335 |
+
"Filter für die derzeitige Suche vorhanden ist. "
|
336 |
+
|
337 |
+
msgid "Highlight words"
|
338 |
+
msgstr "Markiere Wörter"
|
339 |
+
|
340 |
+
msgid "Highlight search words inside products content."
|
341 |
+
msgstr "Suchbegriffe markieren innerhalb der Produktbeschreibung"
|
342 |
+
|
343 |
+
#: includes/options.php:49
|
344 |
+
msgid "Show image"
|
345 |
+
msgstr "Bild anzeigen"
|
346 |
+
|
347 |
+
#: includes/options.php:50
|
348 |
+
msgid "Show product image for each search result."
|
349 |
+
msgstr "Produktbild für jedes Suchergebnis anzeigen"
|
350 |
+
|
351 |
+
#: includes/options.php:61
|
352 |
+
msgid "Show description"
|
353 |
+
msgstr "Beschreibung anzeigen"
|
354 |
+
|
355 |
+
#: includes/options.php:62
|
356 |
+
msgid "Show product description for each search result."
|
357 |
+
msgstr "Produktbeschreibung für jedes Suchergebnis anzeigen"
|
358 |
+
|
359 |
+
#: includes/options.php:73
|
360 |
+
msgid "Description source"
|
361 |
+
msgstr "Beschreibungsquelle"
|
362 |
+
|
363 |
+
#: includes/options.php:74
|
364 |
+
msgid ""
|
365 |
+
"From where to take product description.<br>If first source is empty data "
|
366 |
+
"will be taken from other sources."
|
367 |
+
msgstr ""
|
368 |
+
"Von wo die Produktbeschreibung verwendet wird. <br>Wenn die erste Quelle "
|
369 |
+
"leer ist, werden die Daten von anderen Quellen verwendet. "
|
370 |
+
|
371 |
+
#: includes/options.php:79
|
372 |
+
msgid "Content"
|
373 |
+
msgstr "Inhalt"
|
374 |
+
|
375 |
+
#: includes/options.php:80
|
376 |
+
msgid "Short description"
|
377 |
+
msgstr "Kurzbeschreibung"
|
378 |
+
|
379 |
+
#: includes/options.php:85
|
380 |
+
msgid "Description length"
|
381 |
+
msgstr "Beschreibungslänge"
|
382 |
+
|
383 |
+
#: includes/options.php:86
|
384 |
+
msgid "Maximal allowed number of words for product description."
|
385 |
+
msgstr "Maximal erlaubte Anzahl an Wörtern in der Produktbeschreibung."
|
386 |
+
|
387 |
+
#: includes/options.php:93
|
388 |
+
msgid "Show price"
|
389 |
+
msgstr "Preis anzeigen"
|
390 |
+
|
391 |
+
#: includes/options.php:94
|
392 |
+
msgid "Show product price for each search result."
|
393 |
+
msgstr "Produktpreis für jedes Suchergebnis anzeigen"
|
394 |
+
|
395 |
+
msgid "Show price for out of stock"
|
396 |
+
msgstr "Zeige Preise für nicht vorrätig"
|
397 |
+
|
398 |
+
msgid "Show product price for out of stock products."
|
399 |
+
msgstr "Zeige Produkt Preis für nicht vorrätige Artikel"
|
400 |
+
|
401 |
+
#: includes/options.php:105
|
402 |
+
msgid "Description content"
|
403 |
+
msgstr "Beschreibungs-Inhalt"
|
404 |
+
|
405 |
+
#: includes/options.php:106
|
406 |
+
msgid "What to show in product description?"
|
407 |
+
msgstr "Was soll in der Produktbeschreibung angezeigt werden?"
|
408 |
+
|
409 |
+
#: includes/options.php:117
|
410 |
+
msgid "Show categories archive"
|
411 |
+
msgstr "Zeige Kategorie Archiv"
|
412 |
+
|
413 |
+
#: includes/options.php:118
|
414 |
+
msgid "Include categories archives pages to search result."
|
415 |
+
msgstr "Schließt die Kategorie-Archiv-Seiten in die Suchergebnisse ein."
|
416 |
+
|
417 |
+
#: includes/options.php:129
|
418 |
+
msgid "Show tags archive"
|
419 |
+
msgstr "Tags Archiv anzeigen"
|
420 |
+
|
421 |
+
#: includes/options.php:130
|
422 |
+
msgid "Include tags archives pages to search results."
|
423 |
+
msgstr "Schließt die Tag-Archiv-Seiten in die Suchergebnisse ein."
|
424 |
+
|
425 |
+
#: includes/options.php:141
|
426 |
+
msgid "Show sale badge"
|
427 |
+
msgstr "Sale Abzeichen anzeigen"
|
428 |
+
|
429 |
+
#: includes/options.php:142
|
430 |
+
msgid "Show sale badge for products in search results."
|
431 |
+
msgstr "Das Zeichen für Abverkaufsprodukte in den Suchergebnissen anzeigen"
|
432 |
+
|
433 |
+
#: includes/options.php:153
|
434 |
+
msgid "Show product SKU"
|
435 |
+
msgstr "Produkt SKU anzeigen"
|
436 |
+
|
437 |
+
#: includes/options.php:154
|
438 |
+
msgid "Show product SKU in search results."
|
439 |
+
msgstr "Produkt SKU für jedes Suchergebnis anzeigen"
|
440 |
+
|
441 |
+
msgid "Show stock status"
|
442 |
+
msgstr "Zeige den Lagerstatus"
|
443 |
+
|
444 |
+
msgid "Show stock status for every product in search results."
|
445 |
+
msgstr "Zeige den Lagerstatus für jedes Produkt in den Suchergebnissen"
|
446 |
+
|
447 |
+
msgid "Show featured icon"
|
448 |
+
msgstr "Featured Symbol anzeigen"
|
449 |
+
|
450 |
+
msgid "Show or not star icon for featured products."
|
451 |
+
msgstr "Sternsymbol bei Feature Produkten anzeigen oder nicht"
|
452 |
+
|
453 |
+
#: includes/options.php:167
|
454 |
+
msgid "Max number of results"
|
455 |
+
msgstr "Maximale Anzahl an Ergebnissen"
|
456 |
+
|
457 |
+
#: includes/options.php:168
|
458 |
+
msgid "Maximum number of displayed search results."
|
459 |
+
msgstr "Maximale Anzahl an angezeigten Suchergebnissen."
|
460 |
+
|
461 |
+
#: includes/options.php:175
|
462 |
+
msgid "Search in"
|
463 |
+
msgstr "Suche in"
|
464 |
+
|
465 |
+
#: includes/options.php:176
|
466 |
+
msgid "Search source: Drag&drop sources to activate or deactivate them."
|
467 |
+
msgstr ""
|
468 |
+
"Suchquellen: Ziehen & Ablegen von Quellen, um diese zu aktivieren oder zu "
|
469 |
+
"deaktivieren. "
|
470 |
+
|
471 |
+
#: includes/options.php:30
|
472 |
+
msgid "Show out-of-stock"
|
473 |
+
msgstr "Zeige nicht vorrätige Artikel"
|
474 |
+
|
475 |
+
#: includes/options.php:31
|
476 |
+
msgid "Show out-of-stock products in search"
|
477 |
+
msgstr "Nicht vorrätige Artikel in der Suche anzeigen"
|
478 |
+
|
479 |
+
msgid "Stop words list"
|
480 |
+
msgstr "Stop Wörter Liste"
|
481 |
+
|
482 |
+
msgid "Comma separated list of words that will be excluded from search."
|
483 |
+
msgstr ""
|
484 |
+
"Komma-separierte Liste von Wörtern, die von der Suche ausgeschlossen werden."
|
485 |
+
|
486 |
+
msgid "Re-index required on change."
|
487 |
+
msgstr "Re-Indizierung bei Änderung."
|
488 |
+
|
489 |
+
msgid "Synonyms"
|
490 |
+
msgstr "Synonyme"
|
491 |
+
|
492 |
+
msgid ""
|
493 |
+
"Comma separated list of synonym words. Each group of synonyms must be on "
|
494 |
+
"separated text line."
|
495 |
+
msgstr ""
|
496 |
+
"Kommaseparierte Liste von Synonymen. Jede Gruppe von Synonymen auf eine "
|
497 |
+
"einzelne Zeile"
|
498 |
+
|
499 |
+
#: includes/options.php:42
|
500 |
+
msgid "Use Google Analytics"
|
501 |
+
msgstr "Verwenden Sie Google Analytics"
|
502 |
+
|
503 |
+
#: includes/options.php:42
|
504 |
+
msgid ""
|
505 |
+
"Use google analytics to track searches. You need google analytics to be "
|
506 |
+
"installed on your site."
|
507 |
+
msgstr ""
|
508 |
+
"Verwenden Sie Google Analytics, um Suchanfragen zu verfolgen. Dazu muss "
|
509 |
+
"Google Analytics eingerichtet sein, um mit Ihrer Webseite interagieren zu "
|
510 |
+
"können. (Code eingefügt)"
|
511 |
+
|
512 |
+
msgid ""
|
513 |
+
"Data will be visible inside Google Analytics 'Site Search' report. Need to "
|
514 |
+
"activate 'Site Search' feature inside GA. %s"
|
515 |
+
msgstr ""
|
516 |
+
"Daten werden innerhalb von Google Analytics 'Site Search' angezeigt. Dafür "
|
517 |
+
"muss dieses Feature in GA aktiviert sein. %s"
|
518 |
+
|
519 |
+
msgid "More info"
|
520 |
+
msgstr "weitere Informationen"
|
521 |
+
|
522 |
+
#: includes/options.php:42
|
523 |
+
msgid ""
|
524 |
+
"Also will send event with category - 'AWS search', action - 'AWS Search "
|
525 |
+
"Term' and label of value of search term."
|
526 |
+
msgstr ""
|
527 |
+
"Wird zusätzlich ein Ereignis mit Kategorie 'AWS search ', action - 'AWS "
|
528 |
+
"Suchbegriff' und den Wert des Labels des Suchbegriffs senden."
|
529 |
+
|
530 |
+
msgid "In stock"
|
531 |
+
msgstr "vorrätig"
|
532 |
+
|
533 |
+
msgid "Out of stock"
|
534 |
+
msgstr "nicht vorrätig"
|
535 |
+
|
536 |
+
#. Name of the plugin
|
537 |
+
msgid "Advanced Woo Search"
|
538 |
+
msgstr "Advanced Woo Search"
|
539 |
+
|
540 |
+
#. Description of the plugin
|
541 |
+
msgid "Advance ajax WooCommerce product search."
|
542 |
+
msgstr "Advance Ajax WooCommerce Produkt Suche."
|
543 |
+
|
544 |
+
#. Author of the plugin
|
545 |
+
msgid "ILLID"
|
546 |
+
msgstr "ILLID"
|
languages/advanced-woo-search-hu_HU.po
CHANGED
@@ -1,284 +1,284 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: Advanced Woo Search\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"POT-Creation-Date: 2016-08-22 17:10+0000\n"
|
6 |
-
"PO-Revision-Date: 2016-08-22 17:22+0000\n"
|
7 |
-
"Last-Translator: Gasparics Sándor <gs@viky.hu>\n"
|
8 |
-
"Language-Team: Hungarian\n"
|
9 |
-
"Language: hu-HU\n"
|
10 |
-
"Plural-Forms: nplurals=2; plural=n != 1\n"
|
11 |
-
"MIME-Version: 1.0\n"
|
12 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
-
"Content-Transfer-Encoding: 8bit\n"
|
14 |
-
"X-Generator: Loco - https://localise.biz/"
|
15 |
-
|
16 |
-
#: includes/class-aws-admin.php:129
|
17 |
-
msgid "Save Changes"
|
18 |
-
msgstr "Beállítások mentése"
|
19 |
-
|
20 |
-
#: includes/class-aws-admin.php:351
|
21 |
-
msgid "Reindex table"
|
22 |
-
msgstr "Táblák újraindexelése"
|
23 |
-
|
24 |
-
#: includes/class-aws-admin.php:352
|
25 |
-
msgid ""
|
26 |
-
"Update all data in plugins index table. Index table - table with products "
|
27 |
-
"data where plugin is searching all typed terms.<br>Use this button if you "
|
28 |
-
"think that plugin not shows last actual data in its search results.<br>"
|
29 |
-
"<strong>CAUTION:</strong> this can take large amount of time.</span>"
|
30 |
-
msgstr ""
|
31 |
-
"A bővítmény indexének frissítése. Az index tábla tartalmazza az összes "
|
32 |
-
"használt keresőszót a hozzá tartozó termék adataival.<br>Akkor használjuk "
|
33 |
-
"ezt a gombot, ha érzéseink szerint a keresési eredmények között nem pontos, "
|
34 |
-
"aktuális adatok jelennek meg.<br><strong>FIGYELEM:</strong> ez sokáig fog "
|
35 |
-
"tartani.</span>"
|
36 |
-
|
37 |
-
#: includes/class-aws-admin.php:362
|
38 |
-
msgid "Clear cache"
|
39 |
-
msgstr "Gyorsítótár törlése"
|
40 |
-
|
41 |
-
#: includes/class-aws-admin.php:363
|
42 |
-
msgid "Clear cache for all search results."
|
43 |
-
msgstr "Az összes keresési eredmény törlése a gyorsítótárból"
|
44 |
-
|
45 |
-
#: includes/options.php:111
|
46 |
-
msgid ""
|
47 |
-
"Smart scrapping sentences with searching terms from product description."
|
48 |
-
msgstr ""
|
49 |
-
"A keresési kifejezést tartalmazó mondatot jelenítsük meg leírásként a "
|
50 |
-
"találat alatt."
|
51 |
-
|
52 |
-
#: includes/options.php:112
|
53 |
-
msgid ""
|
54 |
-
"First N words of product description ( number of words that you choose below."
|
55 |
-
" )"
|
56 |
-
msgstr ""
|
57 |
-
"A termékleírás fix első néhány szavát (a \"Leírás hossza\" beállításnál "
|
58 |
-
"adhatjuk meg) jelenítsük meg leírásként a találat alatt."
|
59 |
-
|
60 |
-
#: advanced-woo-search.php:127
|
61 |
-
msgid "Settings"
|
62 |
-
msgstr "Beállítások"
|
63 |
-
|
64 |
-
#: advanced-woo-search.php:130 includes/class-aws-admin.php:63
|
65 |
-
msgid "Get Premium"
|
66 |
-
msgstr "Frissítés prémium verzióra"
|
67 |
-
|
68 |
-
#: advanced-woo-search.php:166
|
69 |
-
msgid ""
|
70 |
-
"Advanced Woo Search plugin is enabled but not effective. It requires "
|
71 |
-
"WooCommerce in order to work."
|
72 |
-
msgstr ""
|
73 |
-
"Az Advanced Woo Search bővítmény be van kapcsolva, de nem használható. "
|
74 |
-
"Működéséhez a WooCommerce is szükséges."
|
75 |
-
|
76 |
-
#: includes/widget.php:15
|
77 |
-
msgid "Advanced WooCommerce search widget"
|
78 |
-
msgstr "Advanced WooCommerce kereső widget"
|
79 |
-
|
80 |
-
#: includes/widget.php:17
|
81 |
-
msgid "» AWS Widget"
|
82 |
-
msgstr "» AWS Widget"
|
83 |
-
|
84 |
-
#: includes/widget.php:56
|
85 |
-
msgid "Search..."
|
86 |
-
msgstr "Keresés..."
|
87 |
-
|
88 |
-
#: includes/widget.php:62
|
89 |
-
msgid "Title:"
|
90 |
-
msgstr "Cím:"
|
91 |
-
|
92 |
-
#: includes/class-aws-admin.php:38 includes/class-aws-admin.php:38
|
93 |
-
msgid "Adv. Woo Search"
|
94 |
-
msgstr "Adv. Woo Search"
|
95 |
-
|
96 |
-
#: includes/class-aws-admin.php:49
|
97 |
-
msgid "General"
|
98 |
-
msgstr "Általános"
|
99 |
-
|
100 |
-
#: includes/class-aws-admin.php:295
|
101 |
-
msgid "Available fields"
|
102 |
-
msgstr "Elérhető mezők"
|
103 |
-
|
104 |
-
#: includes/class-aws-admin.php:311
|
105 |
-
msgid "Drag&drop to enable"
|
106 |
-
msgstr "Az engedélyezni kívánt mezőket ide kell húzni"
|
107 |
-
|
108 |
-
#: includes/options.php:9
|
109 |
-
msgid "Cache results"
|
110 |
-
msgstr "Gyorsítótárazás"
|
111 |
-
|
112 |
-
#: includes/options.php:10
|
113 |
-
msgid ""
|
114 |
-
"Turn off if you have old data in the search results after content of "
|
115 |
-
"products was changed.<br><strong>CAUTION:</strong> can dramatically increase "
|
116 |
-
"search speed"
|
117 |
-
msgstr ""
|
118 |
-
"Ki kell kapcsolni, ha a keresési találatokban régi adatok vannak "
|
119 |
-
"termékmódosítás után.<br><strong>FIGYELEM:</strong> drámaian megnöveli "
|
120 |
-
"keresési időt"
|
121 |
-
|
122 |
-
#: includes/options.php:15 includes/options.php:43 includes/options.php:55
|
123 |
-
#: includes/options.php:67 includes/options.php:99 includes/options.php:123
|
124 |
-
#: includes/options.php:135 includes/options.php:147 includes/options.php:159
|
125 |
-
msgid "On"
|
126 |
-
msgstr "Be"
|
127 |
-
|
128 |
-
#: includes/options.php:16 includes/options.php:44 includes/options.php:56
|
129 |
-
#: includes/options.php:68 includes/options.php:100 includes/options.php:124
|
130 |
-
#: includes/options.php:136 includes/options.php:148 includes/options.php:160
|
131 |
-
msgid "Off"
|
132 |
-
msgstr "Ki"
|
133 |
-
|
134 |
-
#: includes/options.php:21
|
135 |
-
msgid "Text for search field"
|
136 |
-
msgstr "Keresőmező szövege"
|
137 |
-
|
138 |
-
#: includes/options.php:22
|
139 |
-
msgid "Text for search field placeholder."
|
140 |
-
msgstr "Keresőmező helyőrző szövege"
|
141 |
-
|
142 |
-
#: includes/options.php:29
|
143 |
-
msgid "Minimum number of characters"
|
144 |
-
msgstr "Karakterek minimális száma"
|
145 |
-
|
146 |
-
#: includes/options.php:30
|
147 |
-
msgid "Minimum number of characters required to run ajax search."
|
148 |
-
msgstr ""
|
149 |
-
"Minimum hány karaktert kell a felhasználónak beírni, hogy az AWS működésbe "
|
150 |
-
"lépjen."
|
151 |
-
|
152 |
-
#: includes/options.php:37
|
153 |
-
msgid "Show loader"
|
154 |
-
msgstr "Betöltő animáció"
|
155 |
-
|
156 |
-
#: includes/options.php:38
|
157 |
-
msgid "Show loader animation while searching."
|
158 |
-
msgstr "Betöltő animáció mutatása keresés közben"
|
159 |
-
|
160 |
-
#: includes/options.php:49
|
161 |
-
msgid "Show image"
|
162 |
-
msgstr "Termékkép mutatása"
|
163 |
-
|
164 |
-
#: includes/options.php:50
|
165 |
-
msgid "Show product image for each search result."
|
166 |
-
msgstr "Minden keresési találathoz mutatja a termék képet is."
|
167 |
-
|
168 |
-
#: includes/options.php:61
|
169 |
-
msgid "Show description"
|
170 |
-
msgstr "Leírás mutatása"
|
171 |
-
|
172 |
-
#: includes/options.php:62
|
173 |
-
msgid "Show product description for each search result."
|
174 |
-
msgstr "Minden keresési találathoz mutatja a termék leírását is."
|
175 |
-
|
176 |
-
#: includes/options.php:73
|
177 |
-
msgid "Description source"
|
178 |
-
msgstr "Leírás forrása"
|
179 |
-
|
180 |
-
#: includes/options.php:74
|
181 |
-
msgid ""
|
182 |
-
"From where to take product description.<br>If first source is empty data "
|
183 |
-
"will be taken from other sources."
|
184 |
-
msgstr ""
|
185 |
-
"Honnan jelenjen meg a termékleírás.<br>Ha a választott mezőben nincs adat, "
|
186 |
-
"akkor másik mezőből próbálja kivenni."
|
187 |
-
|
188 |
-
#: includes/options.php:79
|
189 |
-
msgid "Content"
|
190 |
-
msgstr "Teljes leírás"
|
191 |
-
|
192 |
-
#: includes/options.php:80
|
193 |
-
msgid "Short description"
|
194 |
-
msgstr "Rövid leírás"
|
195 |
-
|
196 |
-
#: includes/options.php:85
|
197 |
-
msgid "Description length"
|
198 |
-
msgstr "Leírás hossza"
|
199 |
-
|
200 |
-
#: includes/options.php:86
|
201 |
-
msgid "Maximal allowed number of words for product description."
|
202 |
-
msgstr "A maximálisan megengedett szó szám amit a termékleírásból megjelenít."
|
203 |
-
|
204 |
-
#: includes/options.php:93
|
205 |
-
msgid "Show price"
|
206 |
-
msgstr "Ár mutatása"
|
207 |
-
|
208 |
-
#: includes/options.php:94
|
209 |
-
msgid "Show product price for each search result."
|
210 |
-
msgstr "Minden keresési találathoz mutatja a termék árát is."
|
211 |
-
|
212 |
-
#: includes/options.php:105
|
213 |
-
msgid "Description content"
|
214 |
-
msgstr "Leírás tartalma"
|
215 |
-
|
216 |
-
#: includes/options.php:106
|
217 |
-
msgid "What to show in product description?"
|
218 |
-
msgstr "Mit mutassunk a termék leírásnál?"
|
219 |
-
|
220 |
-
#: includes/options.php:117
|
221 |
-
msgid "Show categories"
|
222 |
-
msgstr "Kategóriák mutatása"
|
223 |
-
|
224 |
-
#: includes/options.php:118
|
225 |
-
msgid "Include categories in search result."
|
226 |
-
msgstr "Minden keresési találathoz mutatja a termék kategóriáit is."
|
227 |
-
|
228 |
-
#: includes/options.php:129
|
229 |
-
msgid "Show tags"
|
230 |
-
msgstr "Címkék mutatása"
|
231 |
-
|
232 |
-
#: includes/options.php:130
|
233 |
-
msgid "Include tags in search result."
|
234 |
-
msgstr "Minden keresési találathoz mutatja a termék címkéit is."
|
235 |
-
|
236 |
-
#: includes/options.php:141
|
237 |
-
msgid "Show sale badge"
|
238 |
-
msgstr "Akciós matrica mutatása"
|
239 |
-
|
240 |
-
#: includes/options.php:142
|
241 |
-
msgid "Show sale badge for products in search results."
|
242 |
-
msgstr "Minden keresési találathoz mutatja a termék akciós matricáját is."
|
243 |
-
|
244 |
-
#: includes/options.php:153
|
245 |
-
msgid "Show product SKU"
|
246 |
-
msgstr "Cikkszám mutatása"
|
247 |
-
|
248 |
-
#: includes/options.php:154
|
249 |
-
msgid "Show product SKU in search results."
|
250 |
-
msgstr "Minden keresési találathoz mutatja a termék cikkszámát is."
|
251 |
-
|
252 |
-
#: includes/options.php:167
|
253 |
-
msgid "Max number of results"
|
254 |
-
msgstr "Találatok maximális száma"
|
255 |
-
|
256 |
-
#: includes/options.php:168
|
257 |
-
msgid "Maximum number of displayed search results."
|
258 |
-
msgstr "A maximálisan megjelenítendő keresési találatok száma"
|
259 |
-
|
260 |
-
#: includes/options.php:175
|
261 |
-
msgid "Search in"
|
262 |
-
msgstr "Miben keressek?"
|
263 |
-
|
264 |
-
#: includes/options.php:176
|
265 |
-
msgid ""
|
266 |
-
"Source of searching. Set the source of searching by drag&drop needed fields "
|
267 |
-
"to the right area."
|
268 |
-
msgstr ""
|
269 |
-
"Az alábbi termék mezőkben van lehetőség keresni, engedélyezéshez csupán a "
|
270 |
-
"bal oldalról a jobb oldalra kell a mezőt áthúzni."
|
271 |
-
|
272 |
-
#. Name of the plugin
|
273 |
-
msgid "Advanced Woo Search"
|
274 |
-
msgstr "Advanced Woo Search"
|
275 |
-
|
276 |
-
#. Description of the plugin
|
277 |
-
msgid "Advance ajax WooCommerce product search."
|
278 |
-
msgstr ""
|
279 |
-
"Ajax alapú, keresőszó gépelése közben működésbe lépő (prediktív) termék "
|
280 |
-
"kereső WooCommerce áruházhoz."
|
281 |
-
|
282 |
-
#. Author of the plugin
|
283 |
-
msgid "ILLID"
|
284 |
-
msgstr "ILLID - Magyar fordítás: DuraSoft"
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Advanced Woo Search\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"POT-Creation-Date: 2016-08-22 17:10+0000\n"
|
6 |
+
"PO-Revision-Date: 2016-08-22 17:22+0000\n"
|
7 |
+
"Last-Translator: Gasparics Sándor <gs@viky.hu>\n"
|
8 |
+
"Language-Team: Hungarian\n"
|
9 |
+
"Language: hu-HU\n"
|
10 |
+
"Plural-Forms: nplurals=2; plural=n != 1\n"
|
11 |
+
"MIME-Version: 1.0\n"
|
12 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
13 |
+
"Content-Transfer-Encoding: 8bit\n"
|
14 |
+
"X-Generator: Loco - https://localise.biz/"
|
15 |
+
|
16 |
+
#: includes/class-aws-admin.php:129
|
17 |
+
msgid "Save Changes"
|
18 |
+
msgstr "Beállítások mentése"
|
19 |
+
|
20 |
+
#: includes/class-aws-admin.php:351
|
21 |
+
msgid "Reindex table"
|
22 |
+
msgstr "Táblák újraindexelése"
|
23 |
+
|
24 |
+
#: includes/class-aws-admin.php:352
|
25 |
+
msgid ""
|
26 |
+
"Update all data in plugins index table. Index table - table with products "
|
27 |
+
"data where plugin is searching all typed terms.<br>Use this button if you "
|
28 |
+
"think that plugin not shows last actual data in its search results.<br>"
|
29 |
+
"<strong>CAUTION:</strong> this can take large amount of time.</span>"
|
30 |
+
msgstr ""
|
31 |
+
"A bővítmény indexének frissítése. Az index tábla tartalmazza az összes "
|
32 |
+
"használt keresőszót a hozzá tartozó termék adataival.<br>Akkor használjuk "
|
33 |
+
"ezt a gombot, ha érzéseink szerint a keresési eredmények között nem pontos, "
|
34 |
+
"aktuális adatok jelennek meg.<br><strong>FIGYELEM:</strong> ez sokáig fog "
|
35 |
+
"tartani.</span>"
|
36 |
+
|
37 |
+
#: includes/class-aws-admin.php:362
|
38 |
+
msgid "Clear cache"
|
39 |
+
msgstr "Gyorsítótár törlése"
|
40 |
+
|
41 |
+
#: includes/class-aws-admin.php:363
|
42 |
+
msgid "Clear cache for all search results."
|
43 |
+
msgstr "Az összes keresési eredmény törlése a gyorsítótárból"
|
44 |
+
|
45 |
+
#: includes/options.php:111
|
46 |
+
msgid ""
|
47 |
+
"Smart scrapping sentences with searching terms from product description."
|
48 |
+
msgstr ""
|
49 |
+
"A keresési kifejezést tartalmazó mondatot jelenítsük meg leírásként a "
|
50 |
+
"találat alatt."
|
51 |
+
|
52 |
+
#: includes/options.php:112
|
53 |
+
msgid ""
|
54 |
+
"First N words of product description ( number of words that you choose below."
|
55 |
+
" )"
|
56 |
+
msgstr ""
|
57 |
+
"A termékleírás fix első néhány szavát (a \"Leírás hossza\" beállításnál "
|
58 |
+
"adhatjuk meg) jelenítsük meg leírásként a találat alatt."
|
59 |
+
|
60 |
+
#: advanced-woo-search.php:127
|
61 |
+
msgid "Settings"
|
62 |
+
msgstr "Beállítások"
|
63 |
+
|
64 |
+
#: advanced-woo-search.php:130 includes/class-aws-admin.php:63
|
65 |
+
msgid "Get Premium"
|
66 |
+
msgstr "Frissítés prémium verzióra"
|
67 |
+
|
68 |
+
#: advanced-woo-search.php:166
|
69 |
+
msgid ""
|
70 |
+
"Advanced Woo Search plugin is enabled but not effective. It requires "
|
71 |
+
"WooCommerce in order to work."
|
72 |
+
msgstr ""
|
73 |
+
"Az Advanced Woo Search bővítmény be van kapcsolva, de nem használható. "
|
74 |
+
"Működéséhez a WooCommerce is szükséges."
|
75 |
+
|
76 |
+
#: includes/widget.php:15
|
77 |
+
msgid "Advanced WooCommerce search widget"
|
78 |
+
msgstr "Advanced WooCommerce kereső widget"
|
79 |
+
|
80 |
+
#: includes/widget.php:17
|
81 |
+
msgid "» AWS Widget"
|
82 |
+
msgstr "» AWS Widget"
|
83 |
+
|
84 |
+
#: includes/widget.php:56
|
85 |
+
msgid "Search..."
|
86 |
+
msgstr "Keresés..."
|
87 |
+
|
88 |
+
#: includes/widget.php:62
|
89 |
+
msgid "Title:"
|
90 |
+
msgstr "Cím:"
|
91 |
+
|
92 |
+
#: includes/class-aws-admin.php:38 includes/class-aws-admin.php:38
|
93 |
+
msgid "Adv. Woo Search"
|
94 |
+
msgstr "Adv. Woo Search"
|
95 |
+
|
96 |
+
#: includes/class-aws-admin.php:49
|
97 |
+
msgid "General"
|
98 |
+
msgstr "Általános"
|
99 |
+
|
100 |
+
#: includes/class-aws-admin.php:295
|
101 |
+
msgid "Available fields"
|
102 |
+
msgstr "Elérhető mezők"
|
103 |
+
|
104 |
+
#: includes/class-aws-admin.php:311
|
105 |
+
msgid "Drag&drop to enable"
|
106 |
+
msgstr "Az engedélyezni kívánt mezőket ide kell húzni"
|
107 |
+
|
108 |
+
#: includes/options.php:9
|
109 |
+
msgid "Cache results"
|
110 |
+
msgstr "Gyorsítótárazás"
|
111 |
+
|
112 |
+
#: includes/options.php:10
|
113 |
+
msgid ""
|
114 |
+
"Turn off if you have old data in the search results after content of "
|
115 |
+
"products was changed.<br><strong>CAUTION:</strong> can dramatically increase "
|
116 |
+
"search speed"
|
117 |
+
msgstr ""
|
118 |
+
"Ki kell kapcsolni, ha a keresési találatokban régi adatok vannak "
|
119 |
+
"termékmódosítás után.<br><strong>FIGYELEM:</strong> drámaian megnöveli "
|
120 |
+
"keresési időt"
|
121 |
+
|
122 |
+
#: includes/options.php:15 includes/options.php:43 includes/options.php:55
|
123 |
+
#: includes/options.php:67 includes/options.php:99 includes/options.php:123
|
124 |
+
#: includes/options.php:135 includes/options.php:147 includes/options.php:159
|
125 |
+
msgid "On"
|
126 |
+
msgstr "Be"
|
127 |
+
|
128 |
+
#: includes/options.php:16 includes/options.php:44 includes/options.php:56
|
129 |
+
#: includes/options.php:68 includes/options.php:100 includes/options.php:124
|
130 |
+
#: includes/options.php:136 includes/options.php:148 includes/options.php:160
|
131 |
+
msgid "Off"
|
132 |
+
msgstr "Ki"
|
133 |
+
|
134 |
+
#: includes/options.php:21
|
135 |
+
msgid "Text for search field"
|
136 |
+
msgstr "Keresőmező szövege"
|
137 |
+
|
138 |
+
#: includes/options.php:22
|
139 |
+
msgid "Text for search field placeholder."
|
140 |
+
msgstr "Keresőmező helyőrző szövege"
|
141 |
+
|
142 |
+
#: includes/options.php:29
|
143 |
+
msgid "Minimum number of characters"
|
144 |
+
msgstr "Karakterek minimális száma"
|
145 |
+
|
146 |
+
#: includes/options.php:30
|
147 |
+
msgid "Minimum number of characters required to run ajax search."
|
148 |
+
msgstr ""
|
149 |
+
"Minimum hány karaktert kell a felhasználónak beírni, hogy az AWS működésbe "
|
150 |
+
"lépjen."
|
151 |
+
|
152 |
+
#: includes/options.php:37
|
153 |
+
msgid "Show loader"
|
154 |
+
msgstr "Betöltő animáció"
|
155 |
+
|
156 |
+
#: includes/options.php:38
|
157 |
+
msgid "Show loader animation while searching."
|
158 |
+
msgstr "Betöltő animáció mutatása keresés közben"
|
159 |
+
|
160 |
+
#: includes/options.php:49
|
161 |
+
msgid "Show image"
|
162 |
+
msgstr "Termékkép mutatása"
|
163 |
+
|
164 |
+
#: includes/options.php:50
|
165 |
+
msgid "Show product image for each search result."
|
166 |
+
msgstr "Minden keresési találathoz mutatja a termék képet is."
|
167 |
+
|
168 |
+
#: includes/options.php:61
|
169 |
+
msgid "Show description"
|
170 |
+
msgstr "Leírás mutatása"
|
171 |
+
|
172 |
+
#: includes/options.php:62
|
173 |
+
msgid "Show product description for each search result."
|
174 |
+
msgstr "Minden keresési találathoz mutatja a termék leírását is."
|
175 |
+
|
176 |
+
#: includes/options.php:73
|
177 |
+
msgid "Description source"
|
178 |
+
msgstr "Leírás forrása"
|
179 |
+
|
180 |
+
#: includes/options.php:74
|
181 |
+
msgid ""
|
182 |
+
"From where to take product description.<br>If first source is empty data "
|
183 |
+
"will be taken from other sources."
|
184 |
+
msgstr ""
|
185 |
+
"Honnan jelenjen meg a termékleírás.<br>Ha a választott mezőben nincs adat, "
|
186 |
+
"akkor másik mezőből próbálja kivenni."
|
187 |
+
|
188 |
+
#: includes/options.php:79
|
189 |
+
msgid "Content"
|
190 |
+
msgstr "Teljes leírás"
|
191 |
+
|
192 |
+
#: includes/options.php:80
|
193 |
+
msgid "Short description"
|
194 |
+
msgstr "Rövid leírás"
|
195 |
+
|
196 |
+
#: includes/options.php:85
|
197 |
+
msgid "Description length"
|
198 |
+
msgstr "Leírás hossza"
|
199 |
+
|
200 |
+
#: includes/options.php:86
|
201 |
+
msgid "Maximal allowed number of words for product description."
|
202 |
+
msgstr "A maximálisan megengedett szó szám amit a termékleírásból megjelenít."
|
203 |
+
|
204 |
+
#: includes/options.php:93
|
205 |
+
msgid "Show price"
|
206 |
+
msgstr "Ár mutatása"
|
207 |
+
|
208 |
+
#: includes/options.php:94
|
209 |
+
msgid "Show product price for each search result."
|
210 |
+
msgstr "Minden keresési találathoz mutatja a termék árát is."
|
211 |
+
|
212 |
+
#: includes/options.php:105
|
213 |
+
msgid "Description content"
|
214 |
+
msgstr "Leírás tartalma"
|
215 |
+
|
216 |
+
#: includes/options.php:106
|
217 |
+
msgid "What to show in product description?"
|
218 |
+
msgstr "Mit mutassunk a termék leírásnál?"
|
219 |
+
|
220 |
+
#: includes/options.php:117
|
221 |
+
msgid "Show categories"
|
222 |
+
msgstr "Kategóriák mutatása"
|
223 |
+
|
224 |
+
#: includes/options.php:118
|
225 |
+
msgid "Include categories in search result."
|
226 |
+
msgstr "Minden keresési találathoz mutatja a termék kategóriáit is."
|
227 |
+
|
228 |
+
#: includes/options.php:129
|
229 |
+
msgid "Show tags"
|
230 |
+
msgstr "Címkék mutatása"
|
231 |
+
|
232 |
+
#: includes/options.php:130
|
233 |
+
msgid "Include tags in search result."
|
234 |
+
msgstr "Minden keresési találathoz mutatja a termék címkéit is."
|
235 |
+
|
236 |
+
#: includes/options.php:141
|
237 |
+
msgid "Show sale badge"
|
238 |
+
msgstr "Akciós matrica mutatása"
|
239 |
+
|
240 |
+
#: includes/options.php:142
|
241 |
+
msgid "Show sale badge for products in search results."
|
242 |
+
msgstr "Minden keresési találathoz mutatja a termék akciós matricáját is."
|
243 |
+
|
244 |
+
#: includes/options.php:153
|
245 |
+
msgid "Show product SKU"
|
246 |
+
msgstr "Cikkszám mutatása"
|
247 |
+
|
248 |
+
#: includes/options.php:154
|
249 |
+
msgid "Show product SKU in search results."
|
250 |
+
msgstr "Minden keresési találathoz mutatja a termék cikkszámát is."
|
251 |
+
|
252 |
+
#: includes/options.php:167
|
253 |
+
msgid "Max number of results"
|
254 |
+
msgstr "Találatok maximális száma"
|
255 |
+
|
256 |
+
#: includes/options.php:168
|
257 |
+
msgid "Maximum number of displayed search results."
|
258 |
+
msgstr "A maximálisan megjelenítendő keresési találatok száma"
|
259 |
+
|
260 |
+
#: includes/options.php:175
|
261 |
+
msgid "Search in"
|
262 |
+
msgstr "Miben keressek?"
|
263 |
+
|
264 |
+
#: includes/options.php:176
|
265 |
+
msgid ""
|
266 |
+
"Source of searching. Set the source of searching by drag&drop needed fields "
|
267 |
+
"to the right area."
|
268 |
+
msgstr ""
|
269 |
+
"Az alábbi termék mezőkben van lehetőség keresni, engedélyezéshez csupán a "
|
270 |
+
"bal oldalról a jobb oldalra kell a mezőt áthúzni."
|
271 |
+
|
272 |
+
#. Name of the plugin
|
273 |
+
msgid "Advanced Woo Search"
|
274 |
+
msgstr "Advanced Woo Search"
|
275 |
+
|
276 |
+
#. Description of the plugin
|
277 |
+
msgid "Advance ajax WooCommerce product search."
|
278 |
+
msgstr ""
|
279 |
+
"Ajax alapú, keresőszó gépelése közben működésbe lépő (prediktív) termék "
|
280 |
+
"kereső WooCommerce áruházhoz."
|
281 |
+
|
282 |
+
#. Author of the plugin
|
283 |
+
msgid "ILLID"
|
284 |
+
msgstr "ILLID - Magyar fordítás: DuraSoft"
|
languages/advanced-woo-search-ru_RU.po
CHANGED
@@ -1,502 +1,502 @@
|
|
1 |
-
msgid ""
|
2 |
-
msgstr ""
|
3 |
-
"Project-Id-Version: Advanced Woo Search\n"
|
4 |
-
"Report-Msgid-Bugs-To: \n"
|
5 |
-
"MIME-Version: 1.0\n"
|
6 |
-
"Content-Type: text/plain; charset=UTF-8\n"
|
7 |
-
"Content-Transfer-Encoding: 8bit\n"
|
8 |
-
"X-Generator: Loco https://localise.biz/\n"
|
9 |
-
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
|
10 |
-
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
|
11 |
-
"esc_html_x:1,2c;\n"
|
12 |
-
"Language: ru_RU\n"
|
13 |
-
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10 >= 2 && "
|
14 |
-
"n%10<=4 &&(n%100<10||n%100 >= 20)? 1 : 2);\n"
|
15 |
-
"X-Poedit-Country: United States\n"
|
16 |
-
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
-
"X-Poedit-Basepath: ../\n"
|
18 |
-
"X-Poedit-SearchPath-0: .\n"
|
19 |
-
"X-Poedit-Bookmarks: \n"
|
20 |
-
"X-Textdomain-Support: yes\n"
|
21 |
-
"POT-Creation-Date: 2019-07-18 11:26+0000\n"
|
22 |
-
"PO-Revision-Date: 2019-07-25 14:43+0000\n"
|
23 |
-
"Last-Translator: Алексей Казаков <hdelta045@yandex.ru>\n"
|
24 |
-
"Language-Team: Русский\n"
|
25 |
-
"X-Loco-Version: 2.3.0; wp-5.2.2"
|
26 |
-
|
27 |
-
#: includes/class-aws-admin.php:129
|
28 |
-
msgid "Save Changes"
|
29 |
-
msgstr "Сохранить изменения"
|
30 |
-
|
31 |
-
#: includes/class-aws-admin.php:351
|
32 |
-
msgid "Reindex table"
|
33 |
-
msgstr "Переиндексировать таблицу"
|
34 |
-
|
35 |
-
msgid ""
|
36 |
-
"This action only need for %s one time %s - after you activate this plugin. "
|
37 |
-
"After this all products changes will be re-indexed automatically."
|
38 |
-
msgstr ""
|
39 |
-
"Это действие нужно только % s один раз % s - после активации этого плагина. "
|
40 |
-
"После этого все изменения товаров будут автоматически переиндексированы."
|
41 |
-
|
42 |
-
msgid "Go to Settings Page"
|
43 |
-
msgstr "На страницу настроек"
|
44 |
-
|
45 |
-
#: includes/class-aws-admin.php:352
|
46 |
-
msgid ""
|
47 |
-
"Update all data in plugins index table. Index table - table with products "
|
48 |
-
"data where plugin is searching all typed terms.<br>Use this button if you "
|
49 |
-
"think that plugin not shows last actual data in its search results.<br>"
|
50 |
-
"<strong>CAUTION:</strong> this can take large amount of time.</span>"
|
51 |
-
msgstr ""
|
52 |
-
"Обновите все данные в таблице индексов плагинов. Индексная таблица - таблица "
|
53 |
-
"с данными о товарах, где плагин ищет все введенные термины.<br>Используйте "
|
54 |
-
"эту кнопку, если считаете, что плагин не отображает последние фактические "
|
55 |
-
"данные в результатах поиска.<br><strong> ВНИМАНИЕ: </strong> это может "
|
56 |
-
"займет много времени.</span>"
|
57 |
-
|
58 |
-
#: includes/class-aws-admin.php:362
|
59 |
-
msgid "Clear cache"
|
60 |
-
msgstr "Очистить кеш"
|
61 |
-
|
62 |
-
#: includes/class-aws-admin.php:363
|
63 |
-
msgid "Clear cache for all search results."
|
64 |
-
msgstr "Очищает кеш от всех результатов поиска"
|
65 |
-
|
66 |
-
#: includes/options.php:111
|
67 |
-
msgid ""
|
68 |
-
"Smart scrapping sentences with searching terms from product description."
|
69 |
-
msgstr "Умные списки предложений с поисковыми терминами из описания продукта."
|
70 |
-
|
71 |
-
#: includes/options.php:112
|
72 |
-
msgid ""
|
73 |
-
"First N words of product description ( number of words that you choose below."
|
74 |
-
" )"
|
75 |
-
msgstr ""
|
76 |
-
"Первые N слов описания продукта (количество слов, которые вы выбираете ниже.)"
|
77 |
-
|
78 |
-
#: advanced-woo-search.php:113
|
79 |
-
msgid "Sale!"
|
80 |
-
msgstr "Распродажа!"
|
81 |
-
|
82 |
-
msgid "SKU"
|
83 |
-
msgstr "SKU"
|
84 |
-
|
85 |
-
msgid "View all results"
|
86 |
-
msgstr "Посмотреть все результаты"
|
87 |
-
|
88 |
-
#: advanced-woo-search.php:127
|
89 |
-
msgid "Settings"
|
90 |
-
msgstr "Настройки"
|
91 |
-
|
92 |
-
#: advanced-woo-search.php:130 includes/class-aws-admin.php:63
|
93 |
-
msgid "Get Premium"
|
94 |
-
msgstr "Получить Premium-версию"
|
95 |
-
|
96 |
-
#: advanced-woo-search.php:166
|
97 |
-
msgid ""
|
98 |
-
"Advanced Woo Search plugin is enabled but not effective. It requires "
|
99 |
-
"WooCommerce in order to work."
|
100 |
-
msgstr ""
|
101 |
-
"Плагин Advanced Woo Search включен, но не эффективен. Для работы требуется "
|
102 |
-
"WooCommerce."
|
103 |
-
|
104 |
-
#: includes/widget.php:15
|
105 |
-
msgid "Advanced WooCommerce search widget"
|
106 |
-
msgstr "Advanced WooCommerce search widget"
|
107 |
-
|
108 |
-
#: includes/widget.php:17
|
109 |
-
msgid "» AWS Widget"
|
110 |
-
msgstr "» AWS Widget"
|
111 |
-
|
112 |
-
#: includes/widget.php:56
|
113 |
-
msgid "Search..."
|
114 |
-
msgstr "Ищу..."
|
115 |
-
|
116 |
-
#: includes/widget.php:62
|
117 |
-
msgid "Title:"
|
118 |
-
msgstr "Заголовок:"
|
119 |
-
|
120 |
-
#: includes/class-aws-admin.php:38 includes/class-aws-admin.php:38
|
121 |
-
msgid "Adv. Woo Search"
|
122 |
-
msgstr "Adv. Woo Search"
|
123 |
-
|
124 |
-
#: includes/class-aws-admin.php:49
|
125 |
-
msgid "General"
|
126 |
-
msgstr "Основные"
|
127 |
-
|
128 |
-
#: includes/class-aws-admin.php:296
|
129 |
-
msgid "Active sources"
|
130 |
-
msgstr "Активированные источник "
|
131 |
-
|
132 |
-
#: includes/class-aws-admin.php:297
|
133 |
-
msgid "Change order by drag&drop"
|
134 |
-
msgstr "Измените порядок путем перетаскивания"
|
135 |
-
|
136 |
-
#: includes/class-aws-admin.php:316
|
137 |
-
msgid "Deactivated sources"
|
138 |
-
msgstr "Деактивированные источники"
|
139 |
-
|
140 |
-
#: includes/class-aws-admin.php:317
|
141 |
-
msgid "Excluded from search results"
|
142 |
-
msgstr "Исключено из поисковых результатов"
|
143 |
-
|
144 |
-
#: includes/options.php:9
|
145 |
-
msgid "Cache results"
|
146 |
-
msgstr "Результаты кеширования"
|
147 |
-
|
148 |
-
msgid "Sync index table"
|
149 |
-
msgstr "Синхронизировать индексную таблицу"
|
150 |
-
|
151 |
-
msgid ""
|
152 |
-
"Automatically update plugin index table when product content was changed. "
|
153 |
-
"This means that in search there will be always latest product data."
|
154 |
-
msgstr ""
|
155 |
-
"Автоматически обновлять индексную таблицу плагинов при изменении содержимого "
|
156 |
-
"продукта. Это означает, что в поиске всегда будут последние данные о товаре."
|
157 |
-
|
158 |
-
msgid "Turn this off if you have any problems with performance."
|
159 |
-
msgstr ""
|
160 |
-
"Выключите это, если у вас есть какие-либо проблемы с производительностью."
|
161 |
-
|
162 |
-
msgid "Main Settings"
|
163 |
-
msgstr "Основные настройки"
|
164 |
-
|
165 |
-
msgid "Seamless integration"
|
166 |
-
msgstr "Бесшовная интеграция"
|
167 |
-
|
168 |
-
msgid ""
|
169 |
-
"Replace all the standard search forms on your website ( may not work with "
|
170 |
-
"some themes )."
|
171 |
-
msgstr ""
|
172 |
-
"Заменяет все стандартные формы поиска на вашем сайте (может не работать с "
|
173 |
-
"некоторыми темами)."
|
174 |
-
|
175 |
-
msgid "Activation"
|
176 |
-
msgstr "Активация"
|
177 |
-
|
178 |
-
msgid ""
|
179 |
-
"In case you need to add plugin search form on your website, you can do it in "
|
180 |
-
"several ways:"
|
181 |
-
msgstr ""
|
182 |
-
"Если вам нужно добавить форму поиска плагинов на ваш сайт, вы можете сделать "
|
183 |
-
"это несколькими способами:"
|
184 |
-
|
185 |
-
msgid ""
|
186 |
-
"Enable a \"Seamless integration\" option ( may not work with some themes )"
|
187 |
-
msgstr ""
|
188 |
-
"Включите опцию «Бесшовная интеграция» (может не работать с некоторыми темами)"
|
189 |
-
|
190 |
-
msgid "Add search form using shortcode %s"
|
191 |
-
msgstr "Добавить форму поиска, используя шорткод %s"
|
192 |
-
|
193 |
-
msgid ""
|
194 |
-
"Add search form as widget for one of your theme widget areas. Go to "
|
195 |
-
"Appearance -> Widgets and drag&drop AWS Widget to one of your widget areas"
|
196 |
-
msgstr ""
|
197 |
-
"Добавить форму поиска в качестве виджета в одной из областей виджетов вашей "
|
198 |
-
"темы. Перейдите в Внешний вид -> Виджеты и перетащите AWS Widget в одну из "
|
199 |
-
"областей виджетов"
|
200 |
-
|
201 |
-
msgid "Add PHP code to the necessary files of your theme: %s"
|
202 |
-
msgstr "Добавьте PHP-код в нужные файлы вашей темы: %s"
|
203 |
-
|
204 |
-
#: includes/options.php:10
|
205 |
-
msgid ""
|
206 |
-
"Turn off if you have old data in the search results after content of "
|
207 |
-
"products was changed.<br><strong>CAUTION:</strong> can dramatically increase "
|
208 |
-
"search speed"
|
209 |
-
msgstr ""
|
210 |
-
"Установите off, если у вас остались старые данные в результатах поиска после "
|
211 |
-
"изменения содержания товаров.<br><strong>ВНИМАНИЕ:</strong> может "
|
212 |
-
"значительно увеличить скорость поиска"
|
213 |
-
|
214 |
-
#: includes/options.php:15 includes/options.php:43 includes/options.php:55
|
215 |
-
#: includes/options.php:67 includes/options.php:99 includes/options.php:123
|
216 |
-
#: includes/options.php:135 includes/options.php:147 includes/options.php:159
|
217 |
-
msgid "On"
|
218 |
-
msgstr "On"
|
219 |
-
|
220 |
-
#: includes/options.php:16 includes/options.php:44 includes/options.php:56
|
221 |
-
#: includes/options.php:68 includes/options.php:100 includes/options.php:124
|
222 |
-
#: includes/options.php:136 includes/options.php:148 includes/options.php:160
|
223 |
-
msgid "Off"
|
224 |
-
msgstr "Off"
|
225 |
-
|
226 |
-
#: includes/options.php:21
|
227 |
-
msgid "Text for search field"
|
228 |
-
msgstr "Текст в поле поиска"
|
229 |
-
|
230 |
-
#: includes/options.php:22
|
231 |
-
msgid "Text for search field placeholder."
|
232 |
-
msgstr " Текст, который будет указан в поле поиска"
|
233 |
-
|
234 |
-
#: includes/options.php:35
|
235 |
-
msgid "Search"
|
236 |
-
msgstr "Искать"
|
237 |
-
|
238 |
-
msgid "Text for show more button"
|
239 |
-
msgstr "Текст для кнопки Показать больше"
|
240 |
-
|
241 |
-
msgid ""
|
242 |
-
"Text for link to search results page at the bottom of search results block."
|
243 |
-
msgstr ""
|
244 |
-
"Текст ссылки на страницу результатов поиска в нижней части блока результатов "
|
245 |
-
"поиска."
|
246 |
-
|
247 |
-
#: includes/options.php:40
|
248 |
-
msgid "Nothing found field"
|
249 |
-
msgstr "Поле Ничего не найдено"
|
250 |
-
|
251 |
-
#: includes/options.php:41
|
252 |
-
msgid "Text when there is no search results."
|
253 |
-
msgstr "Текст, который сообщает, что ничего не нашлось"
|
254 |
-
|
255 |
-
#: includes/options.php:43
|
256 |
-
msgid "Nothing found"
|
257 |
-
msgstr "Нет результатов"
|
258 |
-
|
259 |
-
#: includes/options.php:29
|
260 |
-
msgid "Minimum number of characters"
|
261 |
-
msgstr "Минимальное количество символов"
|
262 |
-
|
263 |
-
#: includes/options.php:30
|
264 |
-
msgid "Minimum number of characters required to run ajax search."
|
265 |
-
msgstr ""
|
266 |
-
"Минимальное количество символов, которое требуется для запуска ajax поиска."
|
267 |
-
|
268 |
-
#: includes/options.php:37
|
269 |
-
msgid "Show loader"
|
270 |
-
msgstr "Показать загрузчик"
|
271 |
-
|
272 |
-
#: includes/options.php:38
|
273 |
-
msgid "Show loader animation while searching."
|
274 |
-
msgstr "Показывать процесс загрузки пока идет поиск"
|
275 |
-
|
276 |
-
msgid "Show clear button"
|
277 |
-
msgstr "Показать кнопку очистки"
|
278 |
-
|
279 |
-
msgid ""
|
280 |
-
"Show 'Clear search string' button for desktop devices ( for mobile it is "
|
281 |
-
"always visible )."
|
282 |
-
msgstr ""
|
283 |
-
"Показать кнопку «Очистить строку поиска» для настольных устройств (для "
|
284 |
-
"мобильных устройств она всегда видна)."
|
285 |
-
|
286 |
-
msgid "Show 'View All Results'"
|
287 |
-
msgstr "Показать \"Посмотреть все результаты\""
|
288 |
-
|
289 |
-
msgid "Show link to search results page at the bottom of search results block."
|
290 |
-
msgstr ""
|
291 |
-
"Показать ссылку на страницу результатов поиска внизу блока результатов "
|
292 |
-
"поиска."
|
293 |
-
|
294 |
-
msgid "Search Results"
|
295 |
-
msgstr "Результаты поиска"
|
296 |
-
|
297 |
-
msgid "Choose how to view search results."
|
298 |
-
msgstr "Выберите, в каком виде выводить результаты поиска"
|
299 |
-
|
300 |
-
msgid "Both ajax search results and search results page"
|
301 |
-
msgstr "Оба варианта: Результаты поиска ajax и страница результатов поиска "
|
302 |
-
|
303 |
-
msgid "Only ajax search results ( no search results page )"
|
304 |
-
msgstr "Только результаты поиска ajax ( нет страница результатов поиска )"
|
305 |
-
|
306 |
-
msgid "Only search results page ( no ajax search results )"
|
307 |
-
msgstr "Только страница результатов поиска ( нет результатов поиска ajax )"
|
308 |
-
|
309 |
-
msgid "Form Styling"
|
310 |
-
msgstr "Вид поисковой формы "
|
311 |
-
|
312 |
-
msgid "Choose search form layout"
|
313 |
-
msgstr "Выберите форму поиска"
|
314 |
-
|
315 |
-
msgid ""
|
316 |
-
"Filter button will be visible only if you have more than one active filter "
|
317 |
-
"for current search form instance."
|
318 |
-
msgstr ""
|
319 |
-
"Кнопка фильтра будет видна, только если у вас есть более одного активного "
|
320 |
-
"фильтра для текущего экземпляра формы поиска."
|
321 |
-
|
322 |
-
#: includes/options.php:49
|
323 |
-
msgid "Show image"
|
324 |
-
msgstr "Показывать изображения"
|
325 |
-
|
326 |
-
#: includes/options.php:50
|
327 |
-
msgid "Show product image for each search result."
|
328 |
-
msgstr "Показать изображения товара для каждого результата поиска"
|
329 |
-
|
330 |
-
#: includes/options.php:61
|
331 |
-
msgid "Show description"
|
332 |
-
msgstr "Показывать описание"
|
333 |
-
|
334 |
-
#: includes/options.php:62
|
335 |
-
msgid "Show product description for each search result."
|
336 |
-
msgstr "Показывать описание товара для каждого результата поиска"
|
337 |
-
|
338 |
-
#: includes/options.php:73
|
339 |
-
msgid "Description source"
|
340 |
-
msgstr "Источник Описание"
|
341 |
-
|
342 |
-
#: includes/options.php:74
|
343 |
-
msgid ""
|
344 |
-
"From where to take product description.<br>If first source is empty data "
|
345 |
-
"will be taken from other sources."
|
346 |
-
msgstr ""
|
347 |
-
"Откуда взять описание товара.<br>Если первый источник пуст, данные будут "
|
348 |
-
"взяты из других источников."
|
349 |
-
|
350 |
-
#: includes/options.php:79
|
351 |
-
msgid "Content"
|
352 |
-
msgstr "Содержание"
|
353 |
-
|
354 |
-
#: includes/options.php:80
|
355 |
-
msgid "Short description"
|
356 |
-
msgstr "Отрывок"
|
357 |
-
|
358 |
-
#: includes/options.php:85
|
359 |
-
msgid "Description length"
|
360 |
-
msgstr "Длина Описания"
|
361 |
-
|
362 |
-
#: includes/options.php:86
|
363 |
-
msgid "Maximal allowed number of words for product description."
|
364 |
-
msgstr "Максимально допустимое количество слов для описания продукта."
|
365 |
-
|
366 |
-
#: includes/options.php:93
|
367 |
-
msgid "Show price"
|
368 |
-
msgstr "Показывать стоимость"
|
369 |
-
|
370 |
-
#: includes/options.php:94
|
371 |
-
msgid "Show product price for each search result."
|
372 |
-
msgstr "Показывать стоимость товара для каждого результата поиска"
|
373 |
-
|
374 |
-
msgid "Show price for out of stock"
|
375 |
-
msgstr "Показывать стоимость товаров, которых нет в наличии"
|
376 |
-
|
377 |
-
msgid "Show product price for out of stock products."
|
378 |
-
msgstr "Показывать стоимость товаров, которых нет в наличии"
|
379 |
-
|
380 |
-
#: includes/options.php:105
|
381 |
-
msgid "Description content"
|
382 |
-
msgstr "Содержимое Описания"
|
383 |
-
|
384 |
-
#: includes/options.php:106
|
385 |
-
msgid "What to show in product description?"
|
386 |
-
msgstr "Что показывать в описании товара?"
|
387 |
-
|
388 |
-
#: includes/options.php:117
|
389 |
-
msgid "Show categories archive"
|
390 |
-
msgstr "Показывать категории архивов"
|
391 |
-
|
392 |
-
#: includes/options.php:118
|
393 |
-
msgid "Include categories archives pages to search result."
|
394 |
-
msgstr "Включить категории архивных страниц в результаты поиска."
|
395 |
-
|
396 |
-
#: includes/options.php:129
|
397 |
-
msgid "Show tags archive"
|
398 |
-
msgstr "Показывать метки архивов"
|
399 |
-
|
400 |
-
#: includes/options.php:130
|
401 |
-
msgid "Include tags archives pages to search results."
|
402 |
-
msgstr "Включить метки архивных страниц в результаты поиска"
|
403 |
-
|
404 |
-
#: includes/options.php:141
|
405 |
-
msgid "Show sale badge"
|
406 |
-
msgstr "Показывать знак распродажи"
|
407 |
-
|
408 |
-
#: includes/options.php:142
|
409 |
-
msgid "Show sale badge for products in search results."
|
410 |
-
msgstr "Показывать значок распродажи в результатах поиска"
|
411 |
-
|
412 |
-
#: includes/options.php:153
|
413 |
-
msgid "Show product SKU"
|
414 |
-
msgstr "Показывать SKU товара"
|
415 |
-
|
416 |
-
#: includes/options.php:154
|
417 |
-
msgid "Show product SKU in search results."
|
418 |
-
msgstr "Показывать SKU товара в результатах поиска"
|
419 |
-
|
420 |
-
msgid "Show stock status"
|
421 |
-
msgstr "Показывать статус в наличии"
|
422 |
-
|
423 |
-
msgid "Show stock status for every product in search results."
|
424 |
-
msgstr "Показывать статус наличия для каждого товара из поиска"
|
425 |
-
|
426 |
-
msgid "Show featured icon"
|
427 |
-
msgstr "Показывать значок рекомендации"
|
428 |
-
|
429 |
-
msgid "Show or not star icon for featured products."
|
430 |
-
msgstr "Показать или нет значок звезды для рекомендуемых продуктов."
|
431 |
-
|
432 |
-
#: includes/options.php:167
|
433 |
-
msgid "Max number of results"
|
434 |
-
msgstr "Максимальное число найденных результатов"
|
435 |
-
|
436 |
-
#: includes/options.php:168
|
437 |
-
msgid "Maximum number of displayed search results."
|
438 |
-
msgstr "Максимальное число найденных результатов, которые будут показаны"
|
439 |
-
|
440 |
-
#: includes/options.php:175
|
441 |
-
msgid "Search in"
|
442 |
-
msgstr "Искать в"
|
443 |
-
|
444 |
-
#: includes/options.php:176
|
445 |
-
msgid "Search source: Drag&drop sources to activate or deactivate them."
|
446 |
-
msgstr ""
|
447 |
-
"Где искать: перетащите источники, чтобы активировать или деактивировать их."
|
448 |
-
|
449 |
-
#: includes/options.php:30
|
450 |
-
msgid "Show out-of-stock"
|
451 |
-
msgstr "Показать товары, которых нет в наличии"
|
452 |
-
|
453 |
-
#: includes/options.php:31
|
454 |
-
msgid "Show out-of-stock products in search"
|
455 |
-
msgstr "Показать в результатах поиска те товары, которых нет в наличии"
|
456 |
-
|
457 |
-
msgid "Stop words list"
|
458 |
-
msgstr "Список стоп-слов"
|
459 |
-
|
460 |
-
msgid "Comma separated list of words that will be excluded
|
461 |
-
msgstr "Разделенный запятыми список слов, которые будут исключены из поиска."
|
462 |
-
|
463 |
-
msgid "Re-index required on change."
|
464 |
-
msgstr "При изменении требуется переиндексация."
|
465 |
-
|
466 |
-
#: includes/options.php:42
|
467 |
-
msgid "Use Google Analytics"
|
468 |
-
msgstr "Использовать Google Analytics"
|
469 |
-
|
470 |
-
#: includes/options.php:42
|
471 |
-
msgid ""
|
472 |
-
"Use google analytics to track searches. You need google analytics to be "
|
473 |
-
"installed on your site."
|
474 |
-
msgstr ""
|
475 |
-
"Используйте Google Analytics для отслеживания поисковых запросов. Вам нужно "
|
476 |
-
"установить Google Analytics на вашем сайте."
|
477 |
-
|
478 |
-
#: includes/options.php:42
|
479 |
-
msgid ""
|
480 |
-
"Will send event with category - 'AWS search', action - 'AWS Search Term' and "
|
481 |
-
"label of value of search term."
|
482 |
-
msgstr ""
|
483 |
-
"Отправит событие с категорией - 'AWS search', действие - 'AWS Search Term' и "
|
484 |
-
"меткой значения поискового термина."
|
485 |
-
|
486 |
-
msgid "In stock"
|
487 |
-
msgstr "В наличии"
|
488 |
-
|
489 |
-
msgid "Out of stock"
|
490 |
-
msgstr "Нет в наличии"
|
491 |
-
|
492 |
-
#. Name of the plugin
|
493 |
-
msgid "Advanced Woo Search"
|
494 |
-
msgstr "Advanced Woo Search"
|
495 |
-
|
496 |
-
#. Description of the plugin
|
497 |
-
msgid "Advance ajax WooCommerce product search."
|
498 |
-
msgstr "Расширенный ajax-поиск товаров в Woocommerce"
|
499 |
-
|
500 |
-
#. Author of the plugin
|
501 |
-
msgid "ILLID"
|
502 |
-
msgstr "ILLID"
|
1 |
+
msgid ""
|
2 |
+
msgstr ""
|
3 |
+
"Project-Id-Version: Advanced Woo Search\n"
|
4 |
+
"Report-Msgid-Bugs-To: \n"
|
5 |
+
"MIME-Version: 1.0\n"
|
6 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
7 |
+
"Content-Transfer-Encoding: 8bit\n"
|
8 |
+
"X-Generator: Loco https://localise.biz/\n"
|
9 |
+
"X-Poedit-KeywordsList: __;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;"
|
10 |
+
"_nx_noop:1,2,3c;esc_attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;"
|
11 |
+
"esc_html_x:1,2c;\n"
|
12 |
+
"Language: ru_RU\n"
|
13 |
+
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10 >= 2 && "
|
14 |
+
"n%10<=4 &&(n%100<10||n%100 >= 20)? 1 : 2);\n"
|
15 |
+
"X-Poedit-Country: United States\n"
|
16 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
17 |
+
"X-Poedit-Basepath: ../\n"
|
18 |
+
"X-Poedit-SearchPath-0: .\n"
|
19 |
+
"X-Poedit-Bookmarks: \n"
|
20 |
+
"X-Textdomain-Support: yes\n"
|
21 |
+
"POT-Creation-Date: 2019-07-18 11:26+0000\n"
|
22 |
+
"PO-Revision-Date: 2019-07-25 14:43+0000\n"
|
23 |
+
"Last-Translator: Алексей Казаков <hdelta045@yandex.ru>\n"
|
24 |
+
"Language-Team: Русский\n"
|
25 |
+
"X-Loco-Version: 2.3.0; wp-5.2.2"
|
26 |
+
|
27 |
+
#: includes/class-aws-admin.php:129
|
28 |
+
msgid "Save Changes"
|
29 |
+
msgstr "Сохранить изменения"
|
30 |
+
|
31 |
+
#: includes/class-aws-admin.php:351
|
32 |
+
msgid "Reindex table"
|
33 |
+
msgstr "Переиндексировать таблицу"
|
34 |
+
|
35 |
+
msgid ""
|
36 |
+
"This action only need for %s one time %s - after you activate this plugin. "
|
37 |
+
"After this all products changes will be re-indexed automatically."
|
38 |
+
msgstr ""
|
39 |
+
"Это действие нужно только % s один раз % s - после активации этого плагина. "
|
40 |
+
"После этого все изменения товаров будут автоматически переиндексированы."
|
41 |
+
|
42 |
+
msgid "Go to Settings Page"
|
43 |
+
msgstr "На страницу настроек"
|
44 |
+
|
45 |
+
#: includes/class-aws-admin.php:352
|
46 |
+
msgid ""
|
47 |
+
"Update all data in plugins index table. Index table - table with products "
|
48 |
+
"data where plugin is searching all typed terms.<br>Use this button if you "
|
49 |
+
"think that plugin not shows last actual data in its search results.<br>"
|
50 |
+
"<strong>CAUTION:</strong> this can take large amount of time.</span>"
|
51 |
+
msgstr ""
|
52 |
+
"Обновите все данные в таблице индексов плагинов. Индексная таблица - таблица "
|
53 |
+
"с данными о товарах, где плагин ищет все введенные термины.<br>Используйте "
|
54 |
+
"эту кнопку, если считаете, что плагин не отображает последние фактические "
|
55 |
+
"данные в результатах поиска.<br><strong> ВНИМАНИЕ: </strong> это может "
|
56 |
+
"займет много времени.</span>"
|
57 |
+
|
58 |
+
#: includes/class-aws-admin.php:362
|
59 |
+
msgid "Clear cache"
|
60 |
+
msgstr "Очистить кеш"
|
61 |
+
|
62 |
+
#: includes/class-aws-admin.php:363
|
63 |
+
msgid "Clear cache for all search results."
|
64 |
+
msgstr "Очищает кеш от всех результатов поиска"
|
65 |
+
|
66 |
+
#: includes/options.php:111
|
67 |
+
msgid ""
|
68 |
+
"Smart scrapping sentences with searching terms from product description."
|
69 |
+
msgstr "Умные списки предложений с поисковыми терминами из описания продукта."
|
70 |
+
|
71 |
+
#: includes/options.php:112
|
72 |
+
msgid ""
|
73 |
+
"First N words of product description ( number of words that you choose below."
|
74 |
+
" )"
|
75 |
+
msgstr ""
|
76 |
+
"Первые N слов описания продукта (количество слов, которые вы выбираете ниже.)"
|
77 |
+
|
78 |
+
#: advanced-woo-search.php:113
|
79 |
+
msgid "Sale!"
|
80 |
+
msgstr "Распродажа!"
|
81 |
+
|
82 |
+
msgid "SKU"
|
83 |
+
msgstr "SKU"
|
84 |
+
|
85 |
+
msgid "View all results"
|
86 |
+
msgstr "Посмотреть все результаты"
|
87 |
+
|
88 |
+
#: advanced-woo-search.php:127
|
89 |
+
msgid "Settings"
|
90 |
+
msgstr "Настройки"
|
91 |
+
|
92 |
+
#: advanced-woo-search.php:130 includes/class-aws-admin.php:63
|
93 |
+
msgid "Get Premium"
|
94 |
+
msgstr "Получить Premium-версию"
|
95 |
+
|
96 |
+
#: advanced-woo-search.php:166
|
97 |
+
msgid ""
|
98 |
+
"Advanced Woo Search plugin is enabled but not effective. It requires "
|
99 |
+
"WooCommerce in order to work."
|
100 |
+
msgstr ""
|
101 |
+
"Плагин Advanced Woo Search включен, но не эффективен. Для работы требуется "
|
102 |
+
"WooCommerce."
|
103 |
+
|
104 |
+
#: includes/widget.php:15
|
105 |
+
msgid "Advanced WooCommerce search widget"
|
106 |
+
msgstr "Advanced WooCommerce search widget"
|
107 |
+
|
108 |
+
#: includes/widget.php:17
|
109 |
+
msgid "» AWS Widget"
|
110 |
+
msgstr "» AWS Widget"
|
111 |
+
|
112 |
+
#: includes/widget.php:56
|
113 |
+
msgid "Search..."
|
114 |
+
msgstr "Ищу..."
|
115 |
+
|
116 |
+
#: includes/widget.php:62
|
117 |
+
msgid "Title:"
|
118 |
+
msgstr "Заголовок:"
|
119 |
+
|
120 |
+
#: includes/class-aws-admin.php:38 includes/class-aws-admin.php:38
|
121 |
+
msgid "Adv. Woo Search"
|
122 |
+
msgstr "Adv. Woo Search"
|
123 |
+
|
124 |
+
#: includes/class-aws-admin.php:49
|
125 |
+
msgid "General"
|
126 |
+
msgstr "Основные"
|
127 |
+
|
128 |
+
#: includes/class-aws-admin.php:296
|
129 |
+
msgid "Active sources"
|
130 |
+
msgstr "Активированные источник "
|
131 |
+
|
132 |
+
#: includes/class-aws-admin.php:297
|
133 |
+
msgid "Change order by drag&drop"
|
134 |
+
msgstr "Измените порядок путем перетаскивания"
|
135 |
+
|
136 |
+
#: includes/class-aws-admin.php:316
|
137 |
+
msgid "Deactivated sources"
|
138 |
+
msgstr "Деактивированные источники"
|
139 |
+
|
140 |
+
#: includes/class-aws-admin.php:317
|
141 |
+
msgid "Excluded from search results"
|
142 |
+
msgstr "Исключено из поисковых результатов"
|
143 |
+
|
144 |
+
#: includes/options.php:9
|
145 |
+
msgid "Cache results"
|
146 |
+
msgstr "Результаты кеширования"
|
147 |
+
|
148 |
+
msgid "Sync index table"
|
149 |
+
msgstr "Синхронизировать индексную таблицу"
|
150 |
+
|
151 |
+
msgid ""
|
152 |
+
"Automatically update plugin index table when product content was changed. "
|
153 |
+
"This means that in search there will be always latest product data."
|
154 |
+
msgstr ""
|
155 |
+
"Автоматически обновлять индексную таблицу плагинов при изменении содержимого "
|
156 |
+
"продукта. Это означает, что в поиске всегда будут последние данные о товаре."
|
157 |
+
|
158 |
+
msgid "Turn this off if you have any problems with performance."
|
159 |
+
msgstr ""
|
160 |
+
"Выключите это, если у вас есть какие-либо проблемы с производительностью."
|
161 |
+
|
162 |
+
msgid "Main Settings"
|
163 |
+
msgstr "Основные настройки"
|
164 |
+
|
165 |
+
msgid "Seamless integration"
|
166 |
+
msgstr "Бесшовная интеграция"
|
167 |
+
|
168 |
+
msgid ""
|
169 |
+
"Replace all the standard search forms on your website ( may not work with "
|
170 |
+
"some themes )."
|
171 |
+
msgstr ""
|
172 |
+
"Заменяет все стандартные формы поиска на вашем сайте (может не работать с "
|
173 |
+
"некоторыми темами)."
|
174 |
+
|
175 |
+
msgid "Activation"
|
176 |
+
msgstr "Активация"
|
177 |
+
|
178 |
+
msgid ""
|
179 |
+
"In case you need to add plugin search form on your website, you can do it in "
|
180 |
+
"several ways:"
|
181 |
+
msgstr ""
|
182 |
+
"Если вам нужно добавить форму поиска плагинов на ваш сайт, вы можете сделать "
|
183 |
+
"это несколькими способами:"
|
184 |
+
|
185 |
+
msgid ""
|
186 |
+
"Enable a \"Seamless integration\" option ( may not work with some themes )"
|
187 |
+
msgstr ""
|
188 |
+
"Включите опцию «Бесшовная интеграция» (может не работать с некоторыми темами)"
|
189 |
+
|
190 |
+
msgid "Add search form using shortcode %s"
|
191 |
+
msgstr "Добавить форму поиска, используя шорткод %s"
|
192 |
+
|
193 |
+
msgid ""
|
194 |
+
"Add search form as widget for one of your theme widget areas. Go to "
|
195 |
+
"Appearance -> Widgets and drag&drop AWS Widget to one of your widget areas"
|
196 |
+
msgstr ""
|
197 |
+
"Добавить форму поиска в качестве виджета в одной из областей виджетов вашей "
|
198 |
+
"темы. Перейдите в Внешний вид -> Виджеты и перетащите AWS Widget в одну из "
|
199 |
+
"областей виджетов"
|
200 |
+
|
201 |
+
msgid "Add PHP code to the necessary files of your theme: %s"
|
202 |
+
msgstr "Добавьте PHP-код в нужные файлы вашей темы: %s"
|
203 |
+
|
204 |
+
#: includes/options.php:10
|
205 |
+
msgid ""
|
206 |
+
"Turn off if you have old data in the search results after content of "
|
207 |
+
"products was changed.<br><strong>CAUTION:</strong> can dramatically increase "
|
208 |
+
"search speed"
|
209 |
+
msgstr ""
|
210 |
+
"Установите off, если у вас остались старые данные в результатах поиска после "
|
211 |
+
"изменения содержания товаров.<br><strong>ВНИМАНИЕ:</strong> может "
|
212 |
+
"значительно увеличить скорость поиска"
|
213 |
+
|
214 |
+
#: includes/options.php:15 includes/options.php:43 includes/options.php:55
|
215 |
+
#: includes/options.php:67 includes/options.php:99 includes/options.php:123
|
216 |
+
#: includes/options.php:135 includes/options.php:147 includes/options.php:159
|
217 |
+
msgid "On"
|
218 |
+
msgstr "On"
|
219 |
+
|
220 |
+
#: includes/options.php:16 includes/options.php:44 includes/options.php:56
|
221 |
+
#: includes/options.php:68 includes/options.php:100 includes/options.php:124
|
222 |
+
#: includes/options.php:136 includes/options.php:148 includes/options.php:160
|
223 |
+
msgid "Off"
|
224 |
+
msgstr "Off"
|
225 |
+
|
226 |
+
#: includes/options.php:21
|
227 |
+
msgid "Text for search field"
|
228 |
+
msgstr "Текст в поле поиска"
|
229 |
+
|
230 |
+
#: includes/options.php:22
|
231 |
+
msgid "Text for search field placeholder."
|
232 |
+
msgstr " Текст, который будет указан в поле поиска"
|
233 |
+
|
234 |
+
#: includes/options.php:35
|
235 |
+
msgid "Search"
|
236 |
+
msgstr "Искать"
|
237 |
+
|
238 |
+
msgid "Text for show more button"
|
239 |
+
msgstr "Текст для кнопки Показать больше"
|
240 |
+
|
241 |
+
msgid ""
|
242 |
+
"Text for link to search results page at the bottom of search results block."
|
243 |
+
msgstr ""
|
244 |
+
"Текст ссылки на страницу результатов поиска в нижней части блока результатов "
|
245 |
+
"поиска."
|
246 |
+
|
247 |
+
#: includes/options.php:40
|
248 |
+
msgid "Nothing found field"
|
249 |
+
msgstr "Поле Ничего не найдено"
|
250 |
+
|
251 |
+
#: includes/options.php:41
|
252 |
+
msgid "Text when there is no search results."
|
253 |
+
msgstr "Текст, который сообщает, что ничего не нашлось"
|
254 |
+
|
255 |
+
#: includes/options.php:43
|
256 |
+
msgid "Nothing found"
|
257 |
+
msgstr "Нет результатов"
|
258 |
+
|
259 |
+
#: includes/options.php:29
|
260 |
+
msgid "Minimum number of characters"
|
261 |
+
msgstr "Минимальное количество символов"
|
262 |
+
|
263 |
+
#: includes/options.php:30
|
264 |
+
msgid "Minimum number of characters required to run ajax search."
|
265 |
+
msgstr ""
|
266 |
+
"Минимальное количество символов, которое требуется для запуска ajax поиска."
|
267 |
+
|
268 |
+
#: includes/options.php:37
|
269 |
+
msgid "Show loader"
|
270 |
+
msgstr "Показать загрузчик"
|
271 |
+
|
272 |
+
#: includes/options.php:38
|
273 |
+
msgid "Show loader animation while searching."
|
274 |
+
msgstr "Показывать процесс загрузки пока идет поиск"
|
275 |
+
|
276 |
+
msgid "Show clear button"
|
277 |
+
msgstr "Показать кнопку очистки"
|
278 |
+
|
279 |
+
msgid ""
|
280 |
+
"Show 'Clear search string' button for desktop devices ( for mobile it is "
|
281 |
+
"always visible )."
|
282 |
+
msgstr ""
|
283 |
+
"Показать кнопку «Очистить строку поиска» для настольных устройств (для "
|
284 |
+
"мобильных устройств она всегда видна)."
|
285 |
+
|
286 |
+
msgid "Show 'View All Results'"
|
287 |
+
msgstr "Показать \"Посмотреть все результаты\""
|
288 |
+
|
289 |
+
msgid "Show link to search results page at the bottom of search results block."
|
290 |
+
msgstr ""
|
291 |
+
"Показать ссылку на страницу результатов поиска внизу блока результатов "
|
292 |
+
"поиска."
|
293 |
+
|
294 |
+
msgid "Search Results"
|
295 |
+
msgstr "Результаты поиска"
|
296 |
+
|
297 |
+
msgid "Choose how to view search results."
|
298 |
+
msgstr "Выберите, в каком виде выводить результаты поиска"
|
299 |
+
|
300 |
+
msgid "Both ajax search results and search results page"
|
301 |
+
msgstr "Оба варианта: Результаты поиска ajax и страница результатов поиска "
|
302 |
+
|
303 |
+
msgid "Only ajax search results ( no search results page )"
|
304 |
+
msgstr "Только результаты поиска ajax ( нет страница результатов поиска )"
|
305 |
+
|
306 |
+
msgid "Only search results page ( no ajax search results )"
|
307 |
+
msgstr "Только страница результатов поиска ( нет результатов поиска ajax )"
|
308 |
+
|
309 |
+
msgid "Form Styling"
|
310 |
+
msgstr "Вид поисковой формы "
|
311 |
+
|
312 |
+
msgid "Choose search form layout"
|
313 |
+
msgstr "Выберите форму поиска"
|
314 |
+
|
315 |
+
msgid ""
|
316 |
+
"Filter button will be visible only if you have more than one active filter "
|
317 |
+
"for current search form instance."
|
318 |
+
msgstr ""
|
319 |
+
"Кнопка фильтра будет видна, только если у вас есть более одного активного "
|
320 |
+
"фильтра для текущего экземпляра формы поиска."
|
321 |
+
|
322 |
+
#: includes/options.php:49
|
323 |
+
msgid "Show image"
|
324 |
+
msgstr "Показывать изображения"
|
325 |
+
|
326 |
+
#: includes/options.php:50
|
327 |
+
msgid "Show product image for each search result."
|
328 |
+
msgstr "Показать изображения товара для каждого результата поиска"
|
329 |
+
|
330 |
+
#: includes/options.php:61
|
331 |
+
msgid "Show description"
|
332 |
+
msgstr "Показывать описание"
|
333 |
+
|
334 |
+
#: includes/options.php:62
|
335 |
+
msgid "Show product description for each search result."
|
336 |
+
msgstr "Показывать описание товара для каждого результата поиска"
|
337 |
+
|
338 |
+
#: includes/options.php:73
|
339 |
+
msgid "Description source"
|
340 |
+
msgstr "Источник Описание"
|
341 |
+
|
342 |
+
#: includes/options.php:74
|
343 |
+
msgid ""
|
344 |
+
"From where to take product description.<br>If first source is empty data "
|
345 |
+
"will be taken from other sources."
|
346 |
+
msgstr ""
|
347 |
+
"Откуда взять описание товара.<br>Если первый источник пуст, данные будут "
|
348 |
+
"взяты из других источников."
|
349 |
+
|
350 |
+
#: includes/options.php:79
|
351 |
+
msgid "Content"
|
352 |
+
msgstr "Содержание"
|
353 |
+
|
354 |
+
#: includes/options.php:80
|
355 |
+
msgid "Short description"
|
356 |
+
msgstr "Отрывок"
|
357 |
+
|
358 |
+
#: includes/options.php:85
|
359 |
+
msgid "Description length"
|
360 |
+
msgstr "Длина Описания"
|
361 |
+
|
362 |
+
#: includes/options.php:86
|
363 |
+
msgid "Maximal allowed number of words for product description."
|
364 |
+
msgstr "Максимально допустимое количество слов для описания продукта."
|
365 |
+
|
366 |
+
#: includes/options.php:93
|
367 |
+
msgid "Show price"
|
368 |
+
msgstr "Показывать стоимость"
|
369 |
+
|
370 |
+
#: includes/options.php:94
|
371 |
+
msgid "Show product price for each search result."
|
372 |
+
msgstr "Показывать стоимость товара для каждого результата поиска"
|
373 |
+
|
374 |
+
msgid "Show price for out of stock"
|
375 |
+
msgstr "Показывать стоимость товаров, которых нет в наличии"
|
376 |
+
|
377 |
+
msgid "Show product price for out of stock products."
|
378 |
+
msgstr "Показывать стоимость товаров, которых нет в наличии"
|
379 |
+
|
380 |
+
#: includes/options.php:105
|
381 |
+
msgid "Description content"
|
382 |
+
msgstr "Содержимое Описания"
|
383 |
+
|
384 |
+
#: includes/options.php:106
|
385 |
+
msgid "What to show in product description?"
|
386 |
+
msgstr "Что показывать в описании товара?"
|
387 |
+
|
388 |
+
#: includes/options.php:117
|
389 |
+
msgid "Show categories archive"
|
390 |
+
msgstr "Показывать категории архивов"
|
391 |
+
|
392 |
+
#: includes/options.php:118
|
393 |
+
msgid "Include categories archives pages to search result."
|
394 |
+
msgstr "Включить категории архивных страниц в результаты поиска."
|
395 |
+
|
396 |
+
#: includes/options.php:129
|
397 |
+
msgid "Show tags archive"
|
398 |
+
msgstr "Показывать метки архивов"
|
399 |
+
|
400 |
+
#: includes/options.php:130
|
401 |
+
msgid "Include tags archives pages to search results."
|
402 |
+
msgstr "Включить метки архивных страниц в результаты поиска"
|
403 |
+
|
404 |
+
#: includes/options.php:141
|
405 |
+
msgid "Show sale badge"
|
406 |
+
msgstr "Показывать знак распродажи"
|
407 |
+
|
408 |
+
#: includes/options.php:142
|
409 |
+
msgid "Show sale badge for products in search results."
|
410 |
+
msgstr "Показывать значок распродажи в результатах поиска"
|
411 |
+
|
412 |
+
#: includes/options.php:153
|
413 |
+
msgid "Show product SKU"
|
414 |
+
msgstr "Показывать SKU товара"
|
415 |
+
|
416 |
+
#: includes/options.php:154
|
417 |
+
msgid "Show product SKU in search results."
|
418 |
+
msgstr "Показывать SKU товара в результатах поиска"
|
419 |
+
|
420 |
+
msgid "Show stock status"
|
421 |
+
msgstr "Показывать статус в наличии"
|
422 |
+
|
423 |
+
msgid "Show stock status for every product in search results."
|
424 |
+
msgstr "Показывать статус наличия для каждого товара из поиска"
|
425 |
+
|
426 |
+
msgid "Show featured icon"
|
427 |
+
msgstr "Показывать значок рекомендации"
|
428 |
+
|
429 |
+
msgid "Show or not star icon for featured products."
|
430 |
+
msgstr "Показать или нет значок звезды для рекомендуемых продуктов."
|
431 |
+
|
432 |
+
#: includes/options.php:167
|
433 |
+
msgid "Max number of results"
|
434 |
+
msgstr "Максимальное число найденных результатов"
|
435 |
+
|
436 |
+
#: includes/options.php:168
|
437 |
+
msgid "Maximum number of displayed search results."
|
438 |
+
msgstr "Максимальное число найденных результатов, которые будут показаны"
|
439 |
+
|
440 |
+
#: includes/options.php:175
|
441 |
+
msgid "Search in"
|
442 |
+
msgstr "Искать в"
|
443 |
+
|
444 |
+
#: includes/options.php:176
|
445 |
+
msgid "Search source: Drag&drop sources to activate or deactivate them."
|
446 |
+
msgstr ""
|
447 |
+
"Где искать: перетащите источники, чтобы активировать или деактивировать их."
|
448 |
+
|
449 |
+
#: includes/options.php:30
|
450 |
+
msgid "Show out-of-stock"
|
451 |
+
msgstr "Показать товары, которых нет в наличии"
|
452 |
+
|
453 |
+
#: includes/options.php:31
|
454 |
+
msgid "Show out-of-stock products in search"
|
455 |
+
msgstr "Показать в результатах поиска те товары, которых нет в наличии"
|
456 |
+
|
457 |
+
msgid "Stop words list"
|
458 |
+
msgstr "Список стоп-слов"
|
459 |
+
|
460 |
+
msgid "Comma separated list of words that will be excluded fro
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|