Version Description
- Premium Feature - best support for the themes moved from premium version of the plugin. If you have any issues ith theme update and set Template ajax load fix to jQuery
- Enhancement - No Products message
- Enhancement - No Products class
- Enhancement - Count Results holder
- Enhancement - Pagination holder
- Fix - no errors if terms found
- Fix - remove notices
Download this release
Release Info
Developer | dholovnia |
Plugin | Advanced AJAX Product Filters |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.8.1 to 1.2.0
- includes/functions.php +6 -6
- includes/widget.php +70 -56
- js/widget.min.js +67 -35
- readme.txt +11 -2
- templates/admin-settings.php +42 -2
- templates/checkbox.php +7 -7
- templates/radio.php +7 -7
- templates/slider.php +2 -2
- templates/widget_start.php +2 -2
- woocommerce-filters.php +56 -21
includes/functions.php
CHANGED
@@ -79,7 +79,7 @@ if( ! function_exists( 'br_parse_order_by' ) ){
|
|
79 |
}
|
80 |
|
81 |
// needed for woocommerce sorting funtionality
|
82 |
-
if(
|
83 |
|
84 |
// Get ordering from query string unless defined
|
85 |
$orderby = strtolower( $orderby );
|
@@ -134,7 +134,7 @@ if( ! function_exists( 'br_aapf_args_parser' ) ){
|
|
134 |
$attributes = apply_filters( 'berocket_aapf_listener_get_attributes', br_aapf_get_attributes() );
|
135 |
$taxonomies = array();
|
136 |
|
137 |
-
if (
|
138 |
foreach ( $attributes as $k => $v ) {
|
139 |
$terms = get_terms( array( $k ), $args = array( 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'id=>slug' ) );
|
140 |
if ( $terms ) {
|
@@ -147,7 +147,7 @@ if( ! function_exists( 'br_aapf_args_parser' ) ){
|
|
147 |
}
|
148 |
unset( $attributes );
|
149 |
|
150 |
-
if (
|
151 |
foreach ( $_POST['terms'] as $t ) {
|
152 |
if( !isset($taxonomies[ $t[0] ]) ){
|
153 |
$taxonomies[ $t[0] ] = array();
|
@@ -161,7 +161,7 @@ if( ! function_exists( 'br_aapf_args_parser' ) ){
|
|
161 |
$taxonomies = apply_filters( 'berocket_aapf_listener_taxonomies', @$taxonomies );
|
162 |
$taxonomies_operator = apply_filters( 'berocket_aapf_listener_taxonomies_operator', @$taxonomies_operator );
|
163 |
|
164 |
-
if (
|
165 |
$tax_query['relation'] = 'AND';
|
166 |
if ( $taxonomies ) {
|
167 |
foreach ( $taxonomies as $k => $v ) {
|
@@ -181,7 +181,7 @@ if( ! function_exists( 'br_aapf_args_parser' ) ){
|
|
181 |
}
|
182 |
}
|
183 |
|
184 |
-
if (
|
185 |
$tax_query[] = array(
|
186 |
'taxonomy' => 'product_cat',
|
187 |
'field' => 'slug',
|
@@ -193,7 +193,7 @@ if( ! function_exists( 'br_aapf_args_parser' ) ){
|
|
193 |
$args['tax_query'] = $tax_query;
|
194 |
$args['post_type'] = 'product';
|
195 |
|
196 |
-
if (
|
197 |
br_aapf_parse_order_by( $args );
|
198 |
}
|
199 |
|
79 |
}
|
80 |
|
81 |
// needed for woocommerce sorting funtionality
|
82 |
+
if( ! empty($orderby) and ! empty($order) ) {
|
83 |
|
84 |
// Get ordering from query string unless defined
|
85 |
$orderby = strtolower( $orderby );
|
134 |
$attributes = apply_filters( 'berocket_aapf_listener_get_attributes', br_aapf_get_attributes() );
|
135 |
$taxonomies = array();
|
136 |
|
137 |
+
if ( ! empty($attributes) ) {
|
138 |
foreach ( $attributes as $k => $v ) {
|
139 |
$terms = get_terms( array( $k ), $args = array( 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'id=>slug' ) );
|
140 |
if ( $terms ) {
|
147 |
}
|
148 |
unset( $attributes );
|
149 |
|
150 |
+
if ( ! empty($_POST['terms']) ) {
|
151 |
foreach ( $_POST['terms'] as $t ) {
|
152 |
if( !isset($taxonomies[ $t[0] ]) ){
|
153 |
$taxonomies[ $t[0] ] = array();
|
161 |
$taxonomies = apply_filters( 'berocket_aapf_listener_taxonomies', @$taxonomies );
|
162 |
$taxonomies_operator = apply_filters( 'berocket_aapf_listener_taxonomies_operator', @$taxonomies_operator );
|
163 |
|
164 |
+
if ( ! empty($taxonomies) ) {
|
165 |
$tax_query['relation'] = 'AND';
|
166 |
if ( $taxonomies ) {
|
167 |
foreach ( $taxonomies as $k => $v ) {
|
181 |
}
|
182 |
}
|
183 |
|
184 |
+
if ( isset($_POST['product_cat']) and $_POST['product_cat'] != '-1' ) {
|
185 |
$tax_query[] = array(
|
186 |
'taxonomy' => 'product_cat',
|
187 |
'field' => 'slug',
|
193 |
$args['tax_query'] = $tax_query;
|
194 |
$args['post_type'] = 'product';
|
195 |
|
196 |
+
if ( ! empty($_POST['orderby']) ) {
|
197 |
br_aapf_parse_order_by( $args );
|
198 |
}
|
199 |
|
includes/widget.php
CHANGED
@@ -45,7 +45,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
45 |
function widget( $args, $instance ) {
|
46 |
$br_options = apply_filters( 'berocket_aapf_listener_br_options', get_option('br_filters_options') );
|
47 |
|
48 |
-
if(
|
49 |
|
50 |
global $wp_query, $wp, $sitepress;
|
51 |
|
@@ -56,7 +56,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
56 |
wp_enqueue_script( 'berocket_aapf_widget-hack-script', plugins_url( '../js/mobiles.min.js', __FILE__ ), array( 'jquery' ), BeRocket_AJAX_filters_version );
|
57 |
|
58 |
$wp_query_product_cat = '-1';
|
59 |
-
if (
|
60 |
$wp_query_product_cat = explode( "/", $wp_query->query['product_cat'] );
|
61 |
$wp_query_product_cat = $wp_query_product_cat[ count( $wp_query_product_cat ) - 1 ];
|
62 |
}
|
@@ -64,8 +64,8 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
64 |
if ( ! $br_options['products_holder_id'] ) $br_options['products_holder_id'] = 'ul.products';
|
65 |
|
66 |
$post_temrs = "[]";
|
67 |
-
if (
|
68 |
-
$post_temrs =
|
69 |
}
|
70 |
|
71 |
if ( method_exists($sitepress, 'get_current_language') ) {
|
@@ -89,17 +89,23 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
89 |
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
90 |
'product_cat' => $wp_query_product_cat,
|
91 |
'product_taxonomy' => $product_taxonomy,
|
92 |
-
'products_holder_id' =>
|
93 |
-
'
|
94 |
-
'
|
|
|
|
|
|
|
|
|
|
|
95 |
'berocket_aapf_widget_product_filters' => $post_temrs,
|
96 |
-
'user_func' => apply_filters( 'berocket_aapf_user_func',
|
97 |
'default_sorting' => get_option('woocommerce_default_catalog_orderby'),
|
98 |
-
'first_page' =>
|
99 |
-
'scroll_shop_top' =>
|
100 |
-
'hide_sel_value' =>
|
101 |
-
'ajax_request_load' =>
|
102 |
-
'
|
|
|
103 |
)
|
104 |
);
|
105 |
unset( $current_language );
|
@@ -132,7 +138,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
132 |
foreach ( $product_cat as $cat ) {
|
133 |
$cat = get_term_by( 'slug', $cat, 'product_cat' );
|
134 |
|
135 |
-
if (
|
136 |
$hide_widget = false;
|
137 |
}
|
138 |
}
|
@@ -161,13 +167,13 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
161 |
$sort_array = array();
|
162 |
$wc_order_by = wc_attribute_orderby( $attribute );
|
163 |
|
164 |
-
if (
|
165 |
$terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute );
|
166 |
} else {
|
167 |
$terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute, 'id', true );
|
168 |
}
|
169 |
|
170 |
-
if (
|
171 |
|
172 |
if ( $wc_order_by == 'menu_order' ) {
|
173 |
foreach ( $terms as $term ) {
|
@@ -189,7 +195,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
189 |
}
|
190 |
|
191 |
$style = $class = '';
|
192 |
-
if(
|
193 |
$style = "style='height: {$height}px; overflow: hidden;'";
|
194 |
$class = "berocket_aapf_widget_height_control";
|
195 |
}
|
@@ -200,14 +206,14 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
200 |
set_query_var( 'type', $type );
|
201 |
set_query_var( 'title', apply_filters( 'berocket_aapf_widget_title', $title ) );
|
202 |
set_query_var( 'class', apply_filters( 'berocket_aapf_widget_class', $class ) );
|
203 |
-
set_query_var( 'css_class', apply_filters( 'berocket_aapf_widget_css_class',
|
204 |
set_query_var( 'style', apply_filters( 'berocket_aapf_widget_style', $style ) );
|
205 |
set_query_var( 'scroll_theme', $scroll_theme );
|
206 |
set_query_var( 'x', time() );
|
207 |
-
set_query_var( 'hide_o_value',
|
208 |
-
set_query_var( 'hide_sel_value',
|
209 |
-
set_query_var( 'before_title',
|
210 |
-
set_query_var( 'after_title',
|
211 |
|
212 |
echo $before_widget;
|
213 |
|
@@ -224,8 +230,8 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
224 |
'berocket_aapf_widget-script',
|
225 |
'br_price_text',
|
226 |
array(
|
227 |
-
'before' =>
|
228 |
-
'after' =>
|
229 |
)
|
230 |
);
|
231 |
if( $price_range ) {
|
@@ -245,7 +251,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
245 |
$min = number_format( floor( $min ), 2, '.', '' );
|
246 |
$max = number_format( ceil( $max ), 2, '.', '' );
|
247 |
} else {
|
248 |
-
if(
|
249 |
foreach ( $terms as $term ) {
|
250 |
if ( $min === false or $min > (int) $term->name ) {
|
251 |
$min = floor( (float) $term->name );
|
@@ -261,11 +267,11 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
261 |
$slider_value1 = $min;
|
262 |
$slider_value2 = $max;
|
263 |
|
264 |
-
if( $attribute == 'price' and
|
265 |
$slider_value1 = apply_filters('woocommerce_price_filter_widget_min_amount', $_POST['price'][0]);
|
266 |
$slider_value2 = apply_filters('woocommerce_price_filter_widget_max_amount', $_POST['price'][1]);
|
267 |
}
|
268 |
-
if( $attribute != 'price' and
|
269 |
foreach( $_POST['limits'] as $p_limit ){
|
270 |
if( $p_limit[0] == $attribute ){
|
271 |
$slider_value1 = $p_limit[1];
|
@@ -281,10 +287,10 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
281 |
set_query_var( 'slider_class', $slider_class );
|
282 |
set_query_var( 'min', $min );
|
283 |
set_query_var( 'max', $max );
|
284 |
-
set_query_var( 'text_before_price',
|
285 |
-
set_query_var( 'text_after_price',
|
286 |
}
|
287 |
-
set_query_var( 'first_page_jump',
|
288 |
|
289 |
br_get_template_part( $type );
|
290 |
|
@@ -353,7 +359,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
353 |
$_POST['product_cat'] = $wp_query_product_cat;
|
354 |
$extra_inner = $extra_where = '';
|
355 |
|
356 |
-
if (
|
357 |
$product_cat = get_term_by( 'slug', $_POST['product_cat'], 'product_cat' );
|
358 |
$sub_categories = get_term_children($product_cat->term_id, 'product_cat');
|
359 |
if( empty($sub_categories) || ! is_array($sub_categories) ) {
|
@@ -440,25 +446,28 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
440 |
$term_ids = wp_list_pluck( $re, 'term_id' );
|
441 |
|
442 |
// Generate query
|
443 |
-
$
|
444 |
-
$
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
|
|
|
|
|
|
462 |
$term_count = array();
|
463 |
$terms = array();
|
464 |
foreach($re as &$res_count) {
|
@@ -541,7 +550,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
541 |
$args['post__in'] = BeRocket_AAPF::price_filter( $args['post__in'] );
|
542 |
} else {
|
543 |
$args = array( 'posts_per_page' => -1 );
|
544 |
-
if (
|
545 |
$args['tax_query'][] = array(
|
546 |
'taxonomy' => 'product_cat',
|
547 |
'field' => 'slug',
|
@@ -557,9 +566,11 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
557 |
$wp_query = new WP_Query( $args );
|
558 |
|
559 |
// here we get max products to know if current page is not too big
|
560 |
-
if
|
561 |
-
$
|
562 |
-
|
|
|
|
|
563 |
}
|
564 |
|
565 |
$products = array();
|
@@ -699,7 +710,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
699 |
//echo '<pre>', print_r($wp_query, true), '</pre>';
|
700 |
unset( $args );
|
701 |
|
702 |
-
if(
|
703 |
ob_start();
|
704 |
|
705 |
if ( $wp_query->have_posts() ) {
|
@@ -810,10 +821,13 @@ class BeRocket_AAPF_Widget extends WP_Widget {
|
|
810 |
// 99% copy of WordPress' get_pagenum_link.
|
811 |
public static function get_pagenum_link($pagenum = 1, $escape = true ) {
|
812 |
global $wp_rewrite;
|
|
|
|
|
|
|
813 |
|
814 |
$pagenum = (int) $pagenum;
|
815 |
|
816 |
-
$request = remove_query_arg( 'paged', preg_replace( "~".home_url()."~", "",
|
817 |
|
818 |
$home_root = parse_url(home_url());
|
819 |
$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
|
45 |
function widget( $args, $instance ) {
|
46 |
$br_options = apply_filters( 'berocket_aapf_listener_br_options', get_option('br_filters_options') );
|
47 |
|
48 |
+
if( ! empty($br_options['filters_turn_off']) || ( ! is_shop() && ! is_product_category() && ! is_product_taxonomy() && ! is_product_tag() ) ) return false;
|
49 |
|
50 |
global $wp_query, $wp, $sitepress;
|
51 |
|
56 |
wp_enqueue_script( 'berocket_aapf_widget-hack-script', plugins_url( '../js/mobiles.min.js', __FILE__ ), array( 'jquery' ), BeRocket_AJAX_filters_version );
|
57 |
|
58 |
$wp_query_product_cat = '-1';
|
59 |
+
if ( ! empty($wp_query->query['product_cat']) ) {
|
60 |
$wp_query_product_cat = explode( "/", $wp_query->query['product_cat'] );
|
61 |
$wp_query_product_cat = $wp_query_product_cat[ count( $wp_query_product_cat ) - 1 ];
|
62 |
}
|
64 |
if ( ! $br_options['products_holder_id'] ) $br_options['products_holder_id'] = 'ul.products';
|
65 |
|
66 |
$post_temrs = "[]";
|
67 |
+
if ( ! empty($_POST['terms']) ) {
|
68 |
+
$post_temrs = json_encode( $_POST['terms'] );
|
69 |
}
|
70 |
|
71 |
if ( method_exists($sitepress, 'get_current_language') ) {
|
89 |
'ajaxurl' => admin_url( 'admin-ajax.php' ),
|
90 |
'product_cat' => $wp_query_product_cat,
|
91 |
'product_taxonomy' => $product_taxonomy,
|
92 |
+
'products_holder_id' => ( ! empty($br_options['products_holder_id']) ? $br_options['products_holder_id'] : BeRocket_AAPF::$defaults['products_holder_id'] ),
|
93 |
+
'result_count_class' => ( ! empty($br_options['woocommerce_result_count_class']) ? $br_options['woocommerce_result_count_class'] : BeRocket_AAPF::$defaults['woocommerce_result_count_class'] ),
|
94 |
+
'ordering_class' => ( ! empty($br_options['woocommerce_ordering_class']) ? $br_options['woocommerce_ordering_class'] : BeRocket_AAPF::$defaults['woocommerce_ordering_class'] ),
|
95 |
+
'pagination_class' => ( ! empty($br_options['woocommerce_pagination_class']) ? $br_options['woocommerce_pagination_class'] : BeRocket_AAPF::$defaults['woocommerce_pagination_class'] ),
|
96 |
+
'no_products_message' => ( isset($br_options['no_products_message']) ? $br_options['no_products_message'] : '' ),
|
97 |
+
'no_products_class' => ( isset($br_options['no_products_class']) ? $br_options['no_products_class'] : '' ),
|
98 |
+
'control_sorting' => ( isset($br_options['control_sorting']) ? $br_options['control_sorting'] : '' ),
|
99 |
+
'seo_friendly_urls' => ( isset($br_options['seo_friendly_urls']) ? $br_options['seo_friendly_urls'] : '' ),
|
100 |
'berocket_aapf_widget_product_filters' => $post_temrs,
|
101 |
+
'user_func' => apply_filters( 'berocket_aapf_user_func', ( isset($br_options['user_func']) ? $br_options['user_func'] : '' ) ),
|
102 |
'default_sorting' => get_option('woocommerce_default_catalog_orderby'),
|
103 |
+
'first_page' => ( isset($br_options['first_page_jump']) ? $br_options['first_page_jump'] : '' ),
|
104 |
+
'scroll_shop_top' => ( isset($br_options['scroll_shop_top']) ? $br_options['scroll_shop_top'] : '' ),
|
105 |
+
'hide_sel_value' => ( isset($br_options['hide_value']['sel']) ? $br_options['hide_value']['sel'] : '' ),
|
106 |
+
'ajax_request_load' => ( isset($br_options['ajax_request_load']) ? $br_options['ajax_request_load'] : '' ),
|
107 |
+
'ajax_request_load_style' => ( isset($br_options['ajax_request_load_style']) ? $br_options['ajax_request_load_style'] : BeRocket_AAPF::$defaults['ajax_request_load_style'] ),
|
108 |
+
's' => ( isset($_GET['s']) ? $_GET['s'] : '' ),
|
109 |
)
|
110 |
);
|
111 |
unset( $current_language );
|
138 |
foreach ( $product_cat as $cat ) {
|
139 |
$cat = get_term_by( 'slug', $cat, 'product_cat' );
|
140 |
|
141 |
+
if ( is_array($cur_cat_ancestors) && in_array( $cat->term_id, $cur_cat_ancestors ) ) {
|
142 |
$hide_widget = false;
|
143 |
}
|
144 |
}
|
167 |
$sort_array = array();
|
168 |
$wc_order_by = wc_attribute_orderby( $attribute );
|
169 |
|
170 |
+
if ( ! empty($br_options['show_all_values']) ) {
|
171 |
$terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute );
|
172 |
} else {
|
173 |
$terms = BeRocket_AAPF_Widget::get_attribute_values( $attribute, 'id', true );
|
174 |
}
|
175 |
|
176 |
+
if ( empty($terms) || ! is_array($terms) || count( $terms ) < 1 ) return false;
|
177 |
|
178 |
if ( $wc_order_by == 'menu_order' ) {
|
179 |
foreach ( $terms as $term ) {
|
195 |
}
|
196 |
|
197 |
$style = $class = '';
|
198 |
+
if( ! empty($height) and $height != 'auto' ){
|
199 |
$style = "style='height: {$height}px; overflow: hidden;'";
|
200 |
$class = "berocket_aapf_widget_height_control";
|
201 |
}
|
206 |
set_query_var( 'type', $type );
|
207 |
set_query_var( 'title', apply_filters( 'berocket_aapf_widget_title', $title ) );
|
208 |
set_query_var( 'class', apply_filters( 'berocket_aapf_widget_class', $class ) );
|
209 |
+
set_query_var( 'css_class', apply_filters( 'berocket_aapf_widget_css_class', ( isset($css_class) ? $css_class : '' ) ) );
|
210 |
set_query_var( 'style', apply_filters( 'berocket_aapf_widget_style', $style ) );
|
211 |
set_query_var( 'scroll_theme', $scroll_theme );
|
212 |
set_query_var( 'x', time() );
|
213 |
+
set_query_var( 'hide_o_value', ! empty($br_options['hide_value']['o']) );
|
214 |
+
set_query_var( 'hide_sel_value', ! empty($br_options['hide_value']['sel']) );
|
215 |
+
set_query_var( 'before_title', ( isset($before_title) ? $before_title : '' ) );
|
216 |
+
set_query_var( 'after_title', ( isset($after_title) ? $after_title : '' ) );
|
217 |
|
218 |
echo $before_widget;
|
219 |
|
230 |
'berocket_aapf_widget-script',
|
231 |
'br_price_text',
|
232 |
array(
|
233 |
+
'before' => ( isset($text_before_price) ? $text_before_price : '' ),
|
234 |
+
'after' => ( isset($text_after_price) ? $text_after_price : '' ),
|
235 |
)
|
236 |
);
|
237 |
if( $price_range ) {
|
251 |
$min = number_format( floor( $min ), 2, '.', '' );
|
252 |
$max = number_format( ceil( $max ), 2, '.', '' );
|
253 |
} else {
|
254 |
+
if( ! empty($terms) ) {
|
255 |
foreach ( $terms as $term ) {
|
256 |
if ( $min === false or $min > (int) $term->name ) {
|
257 |
$min = floor( (float) $term->name );
|
267 |
$slider_value1 = $min;
|
268 |
$slider_value2 = $max;
|
269 |
|
270 |
+
if( $attribute == 'price' and ! empty($_POST['price']) ){
|
271 |
$slider_value1 = apply_filters('woocommerce_price_filter_widget_min_amount', $_POST['price'][0]);
|
272 |
$slider_value2 = apply_filters('woocommerce_price_filter_widget_max_amount', $_POST['price'][1]);
|
273 |
}
|
274 |
+
if( $attribute != 'price' and ! empty($_POST['limits']) ){
|
275 |
foreach( $_POST['limits'] as $p_limit ){
|
276 |
if( $p_limit[0] == $attribute ){
|
277 |
$slider_value1 = $p_limit[1];
|
287 |
set_query_var( 'slider_class', $slider_class );
|
288 |
set_query_var( 'min', $min );
|
289 |
set_query_var( 'max', $max );
|
290 |
+
set_query_var( 'text_before_price', ( isset($text_before_price) ? $text_before_price : '' ) );
|
291 |
+
set_query_var( 'text_after_price', ( isset($text_after_price) ? $text_after_price : '' ) );
|
292 |
}
|
293 |
+
set_query_var( 'first_page_jump', ( isset($first_page_jump) ? $first_page_jump : '' ) );
|
294 |
|
295 |
br_get_template_part( $type );
|
296 |
|
359 |
$_POST['product_cat'] = $wp_query_product_cat;
|
360 |
$extra_inner = $extra_where = '';
|
361 |
|
362 |
+
if ( isset($_POST['product_cat']) and $_POST['product_cat'] != '-1' ) {
|
363 |
$product_cat = get_term_by( 'slug', $_POST['product_cat'], 'product_cat' );
|
364 |
$sub_categories = get_term_children($product_cat->term_id, 'product_cat');
|
365 |
if( empty($sub_categories) || ! is_array($sub_categories) ) {
|
446 |
$term_ids = wp_list_pluck( $re, 'term_id' );
|
447 |
|
448 |
// Generate query
|
449 |
+
$results = array();
|
450 |
+
if( is_array($term_ids) && count($term_ids) > 0 ) {
|
451 |
+
$query = array();
|
452 |
+
$query['select'] = "SELECT COUNT( DISTINCT {$wpdb->posts}.ID ) as term_count, terms.term_id as term_count_id";
|
453 |
+
$query['from'] = "FROM {$wpdb->posts}";
|
454 |
+
$query['join'] = "
|
455 |
+
INNER JOIN {$wpdb->term_relationships} AS term_relationships ON {$wpdb->posts}.ID = term_relationships.object_id
|
456 |
+
INNER JOIN {$wpdb->term_taxonomy} AS term_taxonomy USING( term_taxonomy_id )
|
457 |
+
INNER JOIN {$wpdb->terms} AS terms USING( term_id )
|
458 |
+
" . $tax_query_sql['join'] . $meta_query_sql['join'];
|
459 |
+
$query['where'] = "
|
460 |
+
WHERE {$wpdb->posts}.post_type IN ( 'product' )
|
461 |
+
AND {$wpdb->posts}.post_status = 'publish'
|
462 |
+
" . $tax_query_sql['where'] . $meta_query_sql['where'] . "
|
463 |
+
AND terms.term_id IN (" . implode( ',', array_map( 'absint', $term_ids ) ) . ")
|
464 |
+
";
|
465 |
+
$query['group_by'] = "GROUP BY terms.term_id";
|
466 |
+
$query = apply_filters( 'woocommerce_get_filtered_term_product_counts_query', $query );
|
467 |
+
$query = implode( ' ', $query );
|
468 |
+
$results = $wpdb->get_results( $query );
|
469 |
+
$results = wp_list_pluck( $results, 'term_count', 'term_count_id' );
|
470 |
+
}
|
471 |
$term_count = array();
|
472 |
$terms = array();
|
473 |
foreach($re as &$res_count) {
|
550 |
$args['post__in'] = BeRocket_AAPF::price_filter( $args['post__in'] );
|
551 |
} else {
|
552 |
$args = array( 'posts_per_page' => -1 );
|
553 |
+
if ( isset($_POST['product_cat']) and $_POST['product_cat'] != '-1' ) {
|
554 |
$args['tax_query'][] = array(
|
555 |
'taxonomy' => 'product_cat',
|
556 |
'field' => 'slug',
|
566 |
$wp_query = new WP_Query( $args );
|
567 |
|
568 |
// here we get max products to know if current page is not too big
|
569 |
+
if( isset($_POST['location']) ) {
|
570 |
+
if ( $wp_rewrite->using_permalinks() and preg_match( "~/page/([0-9]+)~", $_POST['location'], $mathces ) or preg_match( "~paged?=([0-9]+)~", $_POST['location'], $mathces ) ) {
|
571 |
+
$args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
|
572 |
+
$wp_query = new WP_Query( $args );
|
573 |
+
}
|
574 |
}
|
575 |
|
576 |
$products = array();
|
710 |
//echo '<pre>', print_r($wp_query, true), '</pre>';
|
711 |
unset( $args );
|
712 |
|
713 |
+
if( empty($br_options['ajax_request_load']) ) {
|
714 |
ob_start();
|
715 |
|
716 |
if ( $wp_query->have_posts() ) {
|
821 |
// 99% copy of WordPress' get_pagenum_link.
|
822 |
public static function get_pagenum_link($pagenum = 1, $escape = true ) {
|
823 |
global $wp_rewrite;
|
824 |
+
if( empty( $_POST['location'] ) ) {
|
825 |
+
$_POST['location'] = '';
|
826 |
+
}
|
827 |
|
828 |
$pagenum = (int) $pagenum;
|
829 |
|
830 |
+
$request = remove_query_arg( 'paged', preg_replace( "~".home_url()."~", "", $_POST['location'] ) );
|
831 |
|
832 |
$home_root = parse_url(home_url());
|
833 |
$home_root = ( isset($home_root['path']) ) ? $home_root['path'] : '';
|
js/widget.min.js
CHANGED
@@ -13,8 +13,8 @@
|
|
13 |
berocket_last_ajax_request = null,
|
14 |
berocket_last_ajax_request_id = 1;
|
15 |
|
16 |
-
if( $(
|
17 |
-
woocommerce_pagination_page = parseInt( $('
|
18 |
if( woocommerce_pagination_page < 1 ) woocommerce_pagination_page = 1;
|
19 |
}
|
20 |
|
@@ -174,8 +174,8 @@
|
|
174 |
update_selected_area();
|
175 |
|
176 |
var orderby = the_ajax_script.default_sorting;
|
177 |
-
if ( $('
|
178 |
-
orderby = $('
|
179 |
}
|
180 |
|
181 |
args = {
|
@@ -196,7 +196,7 @@
|
|
196 |
}else{
|
197 |
args.location = the_ajax_script.current_page_url;
|
198 |
|
199 |
-
cur_page = $('
|
200 |
if( prev_page = location.href.replace(/.+\/page\/([0-9]+).+/, "$1") ){
|
201 |
if( ! parseInt( cur_page ) ){
|
202 |
cur_page = prev_page;
|
@@ -235,45 +235,77 @@
|
|
235 |
}
|
236 |
args.location = updateLocation(args, true, true);
|
237 |
if(the_ajax_script.ajax_request_load) {
|
238 |
-
if(
|
239 |
-
url = args.location
|
|
|
|
|
240 |
} else {
|
241 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
} else {
|
|
|
244 |
url = the_ajax_script.ajaxurl;
|
245 |
-
}
|
246 |
-
if(the_ajax_script.ajax_request_load) {
|
247 |
-
new_args = {
|
248 |
-
location: args.location
|
249 |
-
};
|
250 |
-
}
|
251 |
-
else
|
252 |
-
{
|
253 |
new_args = args;
|
254 |
}
|
255 |
var berocket_this_ajax_request = berocket_last_ajax_request = $.post(url, new_args, function (data) {
|
256 |
berocket_last_ajax_request = null;
|
257 |
berocket_last_ajax_request_id = 1;
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
|
|
|
|
263 |
|
264 |
// call user func on_update
|
265 |
if( the_ajax_script.user_func != null )
|
266 |
berocket_fire( the_ajax_script.user_func.on_update );
|
267 |
|
268 |
-
if
|
269 |
-
if (
|
270 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
}
|
272 |
} else {
|
273 |
-
if (
|
274 |
-
$(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
275 |
} else {
|
276 |
-
$(the_ajax_script.
|
277 |
}
|
278 |
}
|
279 |
|
@@ -285,7 +317,7 @@
|
|
285 |
// call user func after_update
|
286 |
if( the_ajax_script.user_func != null )
|
287 |
berocket_fire( the_ajax_script.user_func.after_update );
|
288 |
-
},
|
289 |
}
|
290 |
|
291 |
function updateLocation( args, pushstate, return_request ){
|
@@ -372,7 +404,7 @@
|
|
372 |
return uri_request;
|
373 |
}
|
374 |
|
375 |
-
cur_page = $('
|
376 |
if( prev_page = parseInt( location.href.replace(/.+\/page\/([0-9]+).+/, "$1") ) ){
|
377 |
if( ! parseInt( cur_page ) ){
|
378 |
cur_page = prev_page;
|
@@ -449,16 +481,16 @@
|
|
449 |
|
450 |
function aapf_action_init(){
|
451 |
// Take control over (default) pagination and sorting, make it AJAXy and work with filters
|
452 |
-
$(
|
453 |
event.preventDefault();
|
454 |
if ( $(this).hasClass('next') ) {
|
455 |
-
_next_page = parseInt( $('
|
456 |
} else if ( $(this).hasClass('prev') ) {
|
457 |
-
_next_page = parseInt( $('
|
458 |
} else {
|
459 |
_next_page = $(this).text();
|
460 |
}
|
461 |
-
$('
|
462 |
$(this).after("<span class='page-numbers current' style='display:none!important;'>"+_next_page+"</span>");
|
463 |
berocket_aapf_widget_first_page_jump = false;
|
464 |
updateProducts(true);
|
@@ -607,7 +639,7 @@
|
|
607 |
|
608 |
// Option to take control over (default) sorting, make it AJAXy and work with filters
|
609 |
if( the_ajax_script.control_sorting ) {
|
610 |
-
$(document).on('submit',
|
611 |
event.preventDefault();
|
612 |
});
|
613 |
$(document).on('change', 'select.orderby', function (event) {
|
@@ -707,4 +739,4 @@ function load_hash_test() {
|
|
707 |
location.href = test_loc;
|
708 |
}
|
709 |
}
|
710 |
-
load_hash_test();
|
13 |
berocket_last_ajax_request = null,
|
14 |
berocket_last_ajax_request_id = 1;
|
15 |
|
16 |
+
if( $(the_ajax_script.pagination_class).hasClass(the_ajax_script.pagination_class) ){
|
17 |
+
woocommerce_pagination_page = parseInt( $(the_ajax_script.pagination_class+' .current').first().text() );
|
18 |
if( woocommerce_pagination_page < 1 ) woocommerce_pagination_page = 1;
|
19 |
}
|
20 |
|
174 |
update_selected_area();
|
175 |
|
176 |
var orderby = the_ajax_script.default_sorting;
|
177 |
+
if ( $(the_ajax_script.ordering_class+' select.orderby').length > 0 ) {
|
178 |
+
orderby = $(the_ajax_script.ordering_class+' select.orderby').val();
|
179 |
}
|
180 |
|
181 |
args = {
|
196 |
}else{
|
197 |
args.location = the_ajax_script.current_page_url;
|
198 |
|
199 |
+
cur_page = $(the_ajax_script.pagination_class+' .current').first().text();
|
200 |
if( prev_page = location.href.replace(/.+\/page\/([0-9]+).+/, "$1") ){
|
201 |
if( ! parseInt( cur_page ) ){
|
202 |
cur_page = prev_page;
|
235 |
}
|
236 |
args.location = updateLocation(args, true, true);
|
237 |
if(the_ajax_script.ajax_request_load) {
|
238 |
+
if( the_ajax_script.ajax_request_load_style == 'jquery' ) {
|
239 |
+
url = args.location;
|
240 |
+
return_type = 'html';
|
241 |
+
new_args = {};
|
242 |
} else {
|
243 |
+
return_type = 'json';
|
244 |
+
if( args.location.indexOf('?') > 0 ) {
|
245 |
+
url = args.location+'&explode=explode';
|
246 |
+
} else {
|
247 |
+
url = args.location+'/?explode=explode';
|
248 |
+
}
|
249 |
+
new_args = {
|
250 |
+
location: args.location
|
251 |
+
};
|
252 |
}
|
253 |
} else {
|
254 |
+
return_type = 'json';
|
255 |
url = the_ajax_script.ajaxurl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
256 |
new_args = args;
|
257 |
}
|
258 |
var berocket_this_ajax_request = berocket_last_ajax_request = $.post(url, new_args, function (data) {
|
259 |
berocket_last_ajax_request = null;
|
260 |
berocket_last_ajax_request_id = 1;
|
261 |
+
if(! the_ajax_script.ajax_request_load || the_ajax_script.ajax_request_load_style != 'jquery' ) {
|
262 |
+
$(the_ajax_script.result_count_class).remove();
|
263 |
+
$(the_ajax_script.pagination_class).remove();
|
264 |
+
$(the_ajax_script.ordering_class).remove();
|
265 |
+
$('#content .berocket_lgv_widget').remove();
|
266 |
+
$('#content .br_lgv_product_count_block').remove();
|
267 |
+
}
|
268 |
|
269 |
// call user func on_update
|
270 |
if( the_ajax_script.user_func != null )
|
271 |
berocket_fire( the_ajax_script.user_func.on_update );
|
272 |
|
273 |
+
if(! the_ajax_script.ajax_request_load || the_ajax_script.ajax_request_load_style != 'jquery' ) {
|
274 |
+
if ( $('.woocommerce-info').hasClass('woocommerce-info') && ! $(the_ajax_script.products_holder_id).is(':visible') ) {
|
275 |
+
if ( typeof data.products != 'undefined' ) {
|
276 |
+
$('.woocommerce-info').replaceWith(data.products);
|
277 |
+
}
|
278 |
+
} else {
|
279 |
+
if ( typeof data.no_products != 'undefined' ) {
|
280 |
+
$(the_ajax_script.products_holder_id).html(data.no_products).removeClass('hide_products');
|
281 |
+
} else {
|
282 |
+
$(the_ajax_script.products_holder_id).replaceWith(data.products).removeClass('hide_products');
|
283 |
+
}
|
284 |
}
|
285 |
} else {
|
286 |
+
if( $(data).find(the_ajax_script.products_holder_id).length == 0 ) {
|
287 |
+
if( $(data).find('.woocommerce-info').length == 0 ) {
|
288 |
+
$(the_ajax_script.products_holder_id).html('<div class="'+the_ajax_script.no_products_class+'">'+the_ajax_script.no_products_message+'</div>');
|
289 |
+
} else {
|
290 |
+
$(the_ajax_script.products_holder_id).html($(data).find('.woocommerce-info').first());
|
291 |
+
}
|
292 |
+
} else {
|
293 |
+
$(the_ajax_script.products_holder_id).replaceWith($(data).find(the_ajax_script.products_holder_id).first());
|
294 |
+
}
|
295 |
+
if( $(data).find(the_ajax_script.result_count_class).length == 0 ) {
|
296 |
+
$(the_ajax_script.result_count_class).html('');
|
297 |
+
} else {
|
298 |
+
$(the_ajax_script.result_count_class).replaceWith($(data).find(the_ajax_script.result_count_class).first());
|
299 |
+
}
|
300 |
+
if( $(data).find(the_ajax_script.ordering_class).length == 0 ) {
|
301 |
+
$(the_ajax_script.ordering_class).html('');
|
302 |
+
} else {
|
303 |
+
$(the_ajax_script.ordering_class).replaceWith($(data).find(the_ajax_script.ordering_class).first());
|
304 |
+
}
|
305 |
+
if( $(data).find(the_ajax_script.pagination_class).length == 0 ) {
|
306 |
+
$(the_ajax_script.pagination_class).html('');
|
307 |
} else {
|
308 |
+
$(the_ajax_script.pagination_class).replaceWith($(data).find(the_ajax_script.pagination_class).first());
|
309 |
}
|
310 |
}
|
311 |
|
317 |
// call user func after_update
|
318 |
if( the_ajax_script.user_func != null )
|
319 |
berocket_fire( the_ajax_script.user_func.after_update );
|
320 |
+
}, return_type);
|
321 |
}
|
322 |
|
323 |
function updateLocation( args, pushstate, return_request ){
|
404 |
return uri_request;
|
405 |
}
|
406 |
|
407 |
+
cur_page = $(the_ajax_script.pagination_class+' .current').first().text();
|
408 |
if( prev_page = parseInt( location.href.replace(/.+\/page\/([0-9]+).+/, "$1") ) ){
|
409 |
if( ! parseInt( cur_page ) ){
|
410 |
cur_page = prev_page;
|
481 |
|
482 |
function aapf_action_init(){
|
483 |
// Take control over (default) pagination and sorting, make it AJAXy and work with filters
|
484 |
+
$(the_ajax_script.pagination_class).on('click', 'a', function (event) {
|
485 |
event.preventDefault();
|
486 |
if ( $(this).hasClass('next') ) {
|
487 |
+
_next_page = parseInt( $(the_ajax_script.pagination_class+' .current').first().text() ) + 1;
|
488 |
} else if ( $(this).hasClass('prev') ) {
|
489 |
+
_next_page = parseInt( $(the_ajax_script.pagination_class+' .current').first().text() ) - 1;
|
490 |
} else {
|
491 |
_next_page = $(this).text();
|
492 |
}
|
493 |
+
$(the_ajax_script.pagination_class+' .current').removeClass('current');
|
494 |
$(this).after("<span class='page-numbers current' style='display:none!important;'>"+_next_page+"</span>");
|
495 |
berocket_aapf_widget_first_page_jump = false;
|
496 |
updateProducts(true);
|
639 |
|
640 |
// Option to take control over (default) sorting, make it AJAXy and work with filters
|
641 |
if( the_ajax_script.control_sorting ) {
|
642 |
+
$(document).on('submit', the_ajax_script.ordering_class, function (event) {
|
643 |
event.preventDefault();
|
644 |
});
|
645 |
$(document).on('change', 'select.orderby', function (event) {
|
739 |
location.href = test_loc;
|
740 |
}
|
741 |
}
|
742 |
+
load_hash_test();
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Donate link: http://berocket.com
|
|
5 |
Tags: filters, product filters, ajax product filters, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce ajax product filters, widget, plugin
|
6 |
Requires at least: 4.0
|
7 |
Tested up to: 4.7.4
|
8 |
-
Stable tag: 1.
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
@@ -20,6 +20,7 @@ WooCommerce AJAX Product Filters - advanced AJAX product filters plugin for WooC
|
|
20 |
* AJAX Filters, Pagination and Sorting!
|
21 |
* Unlimited Filters
|
22 |
* Multiple User Interface Elements
|
|
|
23 |
* SEO Friendly Urls ( with HTML5 PushState )
|
24 |
* Filter Visibility By Product Category And Globals.
|
25 |
* Accessible through shortcode
|
@@ -45,7 +46,6 @@ WooCommerce AJAX Product Filters - advanced AJAX product filters plugin for WooC
|
|
45 |
* Option to upload "Loading..." gif image and set label after/before/above/under it
|
46 |
* Scroll top position can be controlled by the admin
|
47 |
* Option to hide on mobile devices
|
48 |
-
* Much better support for custom theme
|
49 |
* Enhancements of the free features
|
50 |
* Shortcode Builder for Easy Shortcode Creation
|
51 |
* Show amount of products before update with "Update button" widget
|
@@ -155,6 +155,15 @@ http://woocommerce-products-filter.berocket.com/
|
|
155 |
|
156 |
== Changelog ==
|
157 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
= 1.1.8.1 =
|
159 |
* Fix - WooCommerce 3.0.1 issues
|
160 |
* Fix - Premium plugin link on settings page.
|
5 |
Tags: filters, product filters, ajax product filters, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce ajax product filters, widget, plugin
|
6 |
Requires at least: 4.0
|
7 |
Tested up to: 4.7.4
|
8 |
+
Stable tag: 1.2.0
|
9 |
License: GPLv2 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
20 |
* AJAX Filters, Pagination and Sorting!
|
21 |
* Unlimited Filters
|
22 |
* Multiple User Interface Elements
|
23 |
+
* Great support for custom/premium themes
|
24 |
* SEO Friendly Urls ( with HTML5 PushState )
|
25 |
* Filter Visibility By Product Category And Globals.
|
26 |
* Accessible through shortcode
|
46 |
* Option to upload "Loading..." gif image and set label after/before/above/under it
|
47 |
* Scroll top position can be controlled by the admin
|
48 |
* Option to hide on mobile devices
|
|
|
49 |
* Enhancements of the free features
|
50 |
* Shortcode Builder for Easy Shortcode Creation
|
51 |
* Show amount of products before update with "Update button" widget
|
155 |
|
156 |
== Changelog ==
|
157 |
|
158 |
+
= 1.2.0 =
|
159 |
+
* Premium Feature - best support for the themes moved from premium version of the plugin. If you have any issues ith theme update and set Template ajax load fix to jQuery
|
160 |
+
* Enhancement - No Products message
|
161 |
+
* Enhancement - No Products class
|
162 |
+
* Enhancement - Count Results holder
|
163 |
+
* Enhancement - Pagination holder
|
164 |
+
* Fix - no errors if terms found
|
165 |
+
* Fix - remove notices
|
166 |
+
|
167 |
= 1.1.8.1 =
|
168 |
* Fix - WooCommerce 3.0.1 issues
|
169 |
* Fix - Premium plugin link on settings page.
|
templates/admin-settings.php
CHANGED
@@ -45,6 +45,30 @@ $dplugin_desc = '';
|
|
45 |
<span style="color:#666666;margin-left:2px;"><?php _e("Selector for tag that is holding products. Don't change this if you don't know what it is", 'BeRocket_AJAX_domain') ?></span>
|
46 |
</td>
|
47 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
<tr>
|
49 |
<th scope="row"><?php _e('Sorting control', 'BeRocket_AJAX_domain') ?></th>
|
50 |
<td>
|
@@ -101,7 +125,23 @@ $dplugin_desc = '';
|
|
101 |
<th scope="row"><?php _e('Template ajax load fix', 'BeRocket_AJAX_domain') ?></th>
|
102 |
<td>
|
103 |
<input name="br_filters_options[ajax_request_load]" type='checkbox' value='1' <?php if( @$options['ajax_request_load'] ) echo "checked='checked'";?>/>
|
104 |
-
<span style="color:#666666;margin-left:2px;"><?php _e('Use all plugins on ajax load
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
</td>
|
106 |
</tr>
|
107 |
</table>
|
@@ -198,4 +238,4 @@ $feature_list = array(
|
|
198 |
'Price as checkbox with min and max values',
|
199 |
);
|
200 |
@ include 'settings_footer.php';
|
201 |
-
?>
|
45 |
<span style="color:#666666;margin-left:2px;"><?php _e("Selector for tag that is holding products. Don't change this if you don't know what it is", 'BeRocket_AJAX_domain') ?></span>
|
46 |
</td>
|
47 |
</tr>
|
48 |
+
<tr>
|
49 |
+
<th scope="row"><?php _e('Product count selector', 'BeRocket_AJAX_domain') ?></th>
|
50 |
+
<td>
|
51 |
+
<input size="30" name="br_filters_options[woocommerce_result_count_class]" type='text' value='<?php echo @$options['woocommerce_result_count_class']?$options['woocommerce_result_count_class']:BeRocket_AAPF::$defaults['woocommerce_result_count_class']?>'/>
|
52 |
+
<br />
|
53 |
+
<span style="color:#666666;margin-left:2px;"><?php _e('Selector for tag with product result count("Showing 1–8 of 61 results"). Don\'t change this if you don\'t know what it is', 'BeRocket_AJAX_domain') ?></span>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
<tr>
|
57 |
+
<th scope="row"><?php _e('Product order by selector', 'BeRocket_AJAX_domain') ?></th>
|
58 |
+
<td>
|
59 |
+
<input size="30" name="br_filters_options[woocommerce_ordering_class]" type='text' value='<?php echo @$options['woocommerce_ordering_class']?$options['woocommerce_ordering_class']:BeRocket_AAPF::$defaults['woocommerce_ordering_class']?>'/>
|
60 |
+
<br />
|
61 |
+
<span style="color:#666666;margin-left:2px;"><?php _e("Selector for order by form with drop down menu. Don't change this if you don't know what it is", 'BeRocket_AJAX_domain') ?></span>
|
62 |
+
</td>
|
63 |
+
</tr>
|
64 |
+
<tr>
|
65 |
+
<th scope="row"><?php _e('Products pagination selector', 'BeRocket_AJAX_domain') ?></th>
|
66 |
+
<td>
|
67 |
+
<input size="30" name="br_filters_options[woocommerce_pagination_class]" type='text' value='<?php echo @$options['woocommerce_pagination_class']?$options['woocommerce_pagination_class']:BeRocket_AAPF::$defaults['woocommerce_pagination_class']?>'/>
|
68 |
+
<br />
|
69 |
+
<span style="color:#666666;margin-left:2px;"><?php _e("Selector for tag that is holding products. Don't change this if you don't know what it is", 'BeRocket_AJAX_domain') ?></span>
|
70 |
+
</td>
|
71 |
+
</tr>
|
72 |
<tr>
|
73 |
<th scope="row"><?php _e('Sorting control', 'BeRocket_AJAX_domain') ?></th>
|
74 |
<td>
|
125 |
<th scope="row"><?php _e('Template ajax load fix', 'BeRocket_AJAX_domain') ?></th>
|
126 |
<td>
|
127 |
<input name="br_filters_options[ajax_request_load]" type='checkbox' value='1' <?php if( @$options['ajax_request_load'] ) echo "checked='checked'";?>/>
|
128 |
+
<span style="color:#666666;margin-left:2px;"><?php _e('Use all plugins on ajax load(can slow down products loading)', 'BeRocket_AJAX_domain') ?></span>
|
129 |
+
<div class="settings-sub-option">
|
130 |
+
<span style="color:#666666;margin-left:2px;"><?php _e('Use', 'BeRocket_AJAX_domain') ?></span>
|
131 |
+
<select name="br_filters_options[ajax_request_load_style]">
|
132 |
+
<option <?php echo ( ! @ $options['ajax_request_load_style'] ) ? 'selected' : '' ?> value=""><?php _e('PHP', 'BeRocket_AJAX_domain') ?></option>
|
133 |
+
<option <?php echo ( @ $options['ajax_request_load_style'] == 'jquery' ) ? 'selected' : '' ?> value="jquery"><?php _e('JavaScript (jQuery)', 'BeRocket_AJAX_domain') ?></option>
|
134 |
+
</select>
|
135 |
+
<span style="color:#666666;margin-left:2px;"><?php _e('for fix', 'BeRocket_AJAX_domain') ?></span>
|
136 |
+
<br>
|
137 |
+
<span style="color:#666666;margin-left:2px;">
|
138 |
+
<?php _e('PHP - loads the full page and cuts products from the page via PHP. Slow down server, but users take only needed information.', 'BeRocket_AJAX_domain') ?>
|
139 |
+
</span>
|
140 |
+
<br>
|
141 |
+
<span style="color:#666666;margin-left:2px;">
|
142 |
+
<?php _e('JavaScript (jQuery) - loads the full page and copy all products from the loaded page to the current page using JQuery. Slow down server and users take the full page. Works good with different themes and plugins.', 'BeRocket_AJAX_domain') ?>
|
143 |
+
</span>
|
144 |
+
</div>
|
145 |
</td>
|
146 |
</tr>
|
147 |
</table>
|
238 |
'Price as checkbox with min and max values',
|
239 |
);
|
240 |
@ include 'settings_footer.php';
|
241 |
+
?>
|
templates/checkbox.php
CHANGED
@@ -11,10 +11,10 @@
|
|
11 |
?>
|
12 |
<?php
|
13 |
$hiden_value = false;
|
14 |
-
if (
|
15 |
foreach( $terms as $term ):
|
16 |
$selected = false;
|
17 |
-
if(
|
18 |
foreach( $_POST['terms'] as $p_term ){
|
19 |
if( @ $p_term[0] == $term->taxonomy and $term->term_id == @ $p_term[1] ){
|
20 |
$selected = true;
|
@@ -23,12 +23,12 @@ if ( @ $terms ):
|
|
23 |
}
|
24 |
}
|
25 |
?>
|
26 |
-
<li class="<?php if(
|
27 |
<span>
|
28 |
-
<input id='checkbox_<?=$term->term_id?>' class="
|
29 |
data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>' data-operator='<?php echo $operator ?>'
|
30 |
<?php
|
31 |
-
if(
|
32 |
foreach( $_POST['terms'] as $p_term ){
|
33 |
if( @ $p_term[0] == $term->taxonomy and $term->term_id == @ $p_term[1] ){
|
34 |
echo ' checked="checked"';
|
@@ -37,7 +37,7 @@ if ( @ $terms ):
|
|
37 |
}
|
38 |
}
|
39 |
?> /><label for='checkbox_<?php echo $term->term_id ?>' class="berocket_label_widgets<?php
|
40 |
-
if(
|
41 |
foreach( $_POST['terms'] as $p_term ){
|
42 |
if( @ $p_term[0] == $term->taxonomy and $term->term_id == @ $p_term[1] ){
|
43 |
echo ' berocket_checked';
|
@@ -51,4 +51,4 @@ if ( @ $terms ):
|
|
51 |
<?php
|
52 |
endforeach; ?>
|
53 |
<li class="berocket_widget_show_values"<?php if( !$hiden_value ) echo ' style="display: none;"'; ?>><?php _e( 'Show value', 'BeRocket_AJAX_domain' ) ?><span class="show_button"></span></li>
|
54 |
-
<?php endif; ?>
|
11 |
?>
|
12 |
<?php
|
13 |
$hiden_value = false;
|
14 |
+
if ( ! empty($terms) ):
|
15 |
foreach( $terms as $term ):
|
16 |
$selected = false;
|
17 |
+
if( ! empty($_POST['terms']) ){
|
18 |
foreach( $_POST['terms'] as $p_term ){
|
19 |
if( @ $p_term[0] == $term->taxonomy and $term->term_id == @ $p_term[1] ){
|
20 |
$selected = true;
|
23 |
}
|
24 |
}
|
25 |
?>
|
26 |
+
<li class="<?php if( ! empty($hide_o_value) && isset($term->count) && $term->count == 0 ) { echo 'berocket_hide_o_value '; $hiden_value = true; } if( ! empty($hide_sel_value) && $selected ) { echo 'berocket_hide_sel_value'; $hiden_value = true; } ?>">
|
27 |
<span>
|
28 |
+
<input id='checkbox_<?=$term->term_id?>' class="checkbox_<?php echo $term->term_id ?>" type='checkbox'
|
29 |
data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>' data-operator='<?php echo $operator ?>'
|
30 |
<?php
|
31 |
+
if( ! empty($_POST['terms']) ){
|
32 |
foreach( $_POST['terms'] as $p_term ){
|
33 |
if( @ $p_term[0] == $term->taxonomy and $term->term_id == @ $p_term[1] ){
|
34 |
echo ' checked="checked"';
|
37 |
}
|
38 |
}
|
39 |
?> /><label for='checkbox_<?php echo $term->term_id ?>' class="berocket_label_widgets<?php
|
40 |
+
if( ! empty($_POST['terms']) ){
|
41 |
foreach( $_POST['terms'] as $p_term ){
|
42 |
if( @ $p_term[0] == $term->taxonomy and $term->term_id == @ $p_term[1] ){
|
43 |
echo ' berocket_checked';
|
51 |
<?php
|
52 |
endforeach; ?>
|
53 |
<li class="berocket_widget_show_values"<?php if( !$hiden_value ) echo ' style="display: none;"'; ?>><?php _e( 'Show value', 'BeRocket_AJAX_domain' ) ?><span class="show_button"></span></li>
|
54 |
+
<?php endif; ?>
|
templates/radio.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
$random_name = rand();
|
3 |
$hiden_value = false;
|
4 |
-
if ( $terms ):
|
5 |
foreach( $terms as $term ):
|
6 |
$selected = false;
|
7 |
-
if(
|
8 |
foreach( $_POST['terms'] as $p_term ){
|
9 |
if( @ $p_term[0] == $term->taxonomy and $term->term_id == @ $p_term[1] ){
|
10 |
$selected = true;
|
@@ -13,13 +13,13 @@ if ( $terms ):
|
|
13 |
}
|
14 |
}
|
15 |
?>
|
16 |
-
<li class="<?php if(
|
17 |
<span>
|
18 |
-
<input class="
|
19 |
name='radio_<?php echo $term->taxonomy ?>_<?php echo $x ?>_<?php echo $random_name ?>'
|
20 |
data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>' data-operator='<?php echo $operator ?>'
|
21 |
<?php
|
22 |
-
if(
|
23 |
foreach( $_POST['terms'] as $p_term ){
|
24 |
if( $p_term[0] == $term->taxonomy and $term->term_id == $p_term[1] ){
|
25 |
echo ' checked="checked"';
|
@@ -28,7 +28,7 @@ if ( $terms ):
|
|
28 |
}
|
29 |
}
|
30 |
?> /><label for='radio_<?php echo $term->term_id ?>' class="berocket_label_widgets<?php
|
31 |
-
if(
|
32 |
foreach( $_POST['terms'] as $p_term ){
|
33 |
if( $p_term[0] == $term->taxonomy and $term->term_id == $p_term[1] ){
|
34 |
echo ' berocket_checked';
|
@@ -41,4 +41,4 @@ if ( $terms ):
|
|
41 |
</li>
|
42 |
<?php endforeach; ?>
|
43 |
<li class="berocket_widget_show_values"<?php if( !$hiden_value ) echo ' style="display: none;"'; ?>><?php _e( 'Show value', 'BeRocket_AJAX_domain' ) ?><span class="show_button"></span></li>
|
44 |
-
<?php endif; ?>
|
1 |
<?php
|
2 |
$random_name = rand();
|
3 |
$hiden_value = false;
|
4 |
+
if ( ! empty($terms) ):
|
5 |
foreach( $terms as $term ):
|
6 |
$selected = false;
|
7 |
+
if( ! empty($_POST['terms']) ){
|
8 |
foreach( $_POST['terms'] as $p_term ){
|
9 |
if( @ $p_term[0] == $term->taxonomy and $term->term_id == @ $p_term[1] ){
|
10 |
$selected = true;
|
13 |
}
|
14 |
}
|
15 |
?>
|
16 |
+
<li class="<?php if( ! empty($hide_o_value) && isset($term->count) && $term->count == 0 ) { echo 'berocket_hide_o_value '; $hiden_value = true; } if( ! empty($hide_sel_value) && $selected ) { echo 'berocket_hide_sel_value'; $hiden_value = true; } ?>">
|
17 |
<span>
|
18 |
+
<input class="radio_<?php echo $term->term_id?>" type='radio' id='radio_<?php echo $term->term_id?>_<?php echo $random_name ?>'
|
19 |
name='radio_<?php echo $term->taxonomy ?>_<?php echo $x ?>_<?php echo $random_name ?>'
|
20 |
data-term_id='<?php echo $term->term_id ?>' data-taxonomy='<?php echo $term->taxonomy ?>' data-operator='<?php echo $operator ?>'
|
21 |
<?php
|
22 |
+
if( ! empty($_POST['terms']) ){
|
23 |
foreach( $_POST['terms'] as $p_term ){
|
24 |
if( $p_term[0] == $term->taxonomy and $term->term_id == $p_term[1] ){
|
25 |
echo ' checked="checked"';
|
28 |
}
|
29 |
}
|
30 |
?> /><label for='radio_<?php echo $term->term_id ?>' class="berocket_label_widgets<?php
|
31 |
+
if( ! empty($_POST['terms']) ){
|
32 |
foreach( $_POST['terms'] as $p_term ){
|
33 |
if( $p_term[0] == $term->taxonomy and $term->term_id == $p_term[1] ){
|
34 |
echo ' berocket_checked';
|
41 |
</li>
|
42 |
<?php endforeach; ?>
|
43 |
<li class="berocket_widget_show_values"<?php if( !$hiden_value ) echo ' style="display: none;"'; ?>><?php _e( 'Show value', 'BeRocket_AJAX_domain' ) ?><span class="show_button"></span></li>
|
44 |
+
<?php endif; ?>
|
templates/slider.php
CHANGED
@@ -8,11 +8,11 @@
|
|
8 |
<?php echo $text_before_price ?><input type='text' disabled id='text_<?php echo $filter_slider_id . $unique ?>_2' value='<?php echo $slider_value2 ?>'
|
9 |
/><?php echo $text_after_price ?>
|
10 |
</span>
|
11 |
-
<div class='slide
|
12 |
<div class='<?php echo $slider_class ?>' data-taxonomy='<?php echo $filter_slider_id ?>'
|
13 |
data-min='<?php echo $min ?>' data-max='<?php echo $max ?>'
|
14 |
data-value1='<?php echo $slider_value1 ?>' data-value2='<?php echo $slider_value2 ?>'
|
15 |
data-fields_1='text_<?php echo $filter_slider_id . $unique ?>_1'
|
16 |
data-fields_2='text_<?php echo $filter_slider_id . $unique ?>_2'></div>
|
17 |
</div>
|
18 |
-
</li>
|
8 |
<?php echo $text_before_price ?><input type='text' disabled id='text_<?php echo $filter_slider_id . $unique ?>_2' value='<?php echo $slider_value2 ?>'
|
9 |
/><?php echo $text_after_price ?>
|
10 |
</span>
|
11 |
+
<div class='slide'>
|
12 |
<div class='<?php echo $slider_class ?>' data-taxonomy='<?php echo $filter_slider_id ?>'
|
13 |
data-min='<?php echo $min ?>' data-max='<?php echo $max ?>'
|
14 |
data-value1='<?php echo $slider_value1 ?>' data-value2='<?php echo $slider_value2 ?>'
|
15 |
data-fields_1='text_<?php echo $filter_slider_id . $unique ?>_1'
|
16 |
data-fields_2='text_<?php echo $filter_slider_id . $unique ?>_2'></div>
|
17 |
</div>
|
18 |
+
</li>
|
templates/widget_start.php
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
<div class="berocket_aapf_widget-wrapper">
|
2 |
-
<?php if (
|
3 |
-
<ul class='berocket_aapf_widget <?php echo $class ?> <?php echo $css_class ?>' <?php echo $style ?> data-scroll_theme='<?php echo $scroll_theme ?>'>
|
1 |
<div class="berocket_aapf_widget-wrapper">
|
2 |
+
<?php if ( ! empty($title) ) { ?><h3 class="widget-title berocket_aapf_widget-title <?php echo $css_class ?>"><span><?php echo $title ?></span></h3><?php } ?>
|
3 |
+
<ul class='berocket_aapf_widget <?php echo $class ?> <?php echo $css_class ?>' <?php echo $style ?> data-scroll_theme='<?php echo $scroll_theme ?>'>
|
woocommerce-filters.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Advanced AJAX Product Filter for WooCommerce
|
4 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/
|
5 |
* Description: Take a look at this fantastic AJAX products filter plugin for WooCommerce. Add unlimited filters with one widget.
|
6 |
-
* Version: 1.
|
7 |
* Author: BeRocket
|
8 |
* Requires at least: 4.0
|
9 |
* Author URI: http://berocket.com
|
@@ -11,7 +11,7 @@
|
|
11 |
* Domain Path: /languages/
|
12 |
*/
|
13 |
|
14 |
-
define( "BeRocket_AJAX_filters_version", '1.
|
15 |
define( "BeRocket_AJAX_domain", 'BeRocket_AJAX_domain' );
|
16 |
|
17 |
define( "AAPF_TEMPLATE_PATH", plugin_dir_path( __FILE__ ) . "templates/" );
|
@@ -28,12 +28,35 @@ require_once dirname( __FILE__ ) . '/includes/functions.php';
|
|
28 |
class BeRocket_AAPF {
|
29 |
|
30 |
public static $defaults = array(
|
31 |
-
"
|
32 |
-
"
|
33 |
-
"
|
34 |
-
"
|
35 |
-
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
);
|
38 |
public static $values = array(
|
39 |
'settings_name' => '',
|
@@ -55,12 +78,12 @@ class BeRocket_AAPF {
|
|
55 |
|
56 |
add_shortcode( 'br_filters', array( __CLASS__, 'shortcode' ) );
|
57 |
|
58 |
-
if(
|
59 |
add_filter( 'pre_get_posts', array( __CLASS__, 'apply_user_price' ) );
|
60 |
add_filter( 'pre_get_posts', array( __CLASS__, 'apply_user_filters' ), 99999 );
|
61 |
}
|
62 |
|
63 |
-
if(
|
64 |
add_action( 'woocommerce_before_template_part', array( 'BeRocket_AAPF_Widget', 'pre_get_posts'), 999999 );
|
65 |
add_action( 'wp_footer', array( 'BeRocket_AAPF_Widget', 'end_clean'), 999999 );
|
66 |
add_action( 'init', array( 'BeRocket_AAPF_Widget', 'start_clean'), 1 );
|
@@ -166,10 +189,10 @@ class BeRocket_AAPF {
|
|
166 |
|
167 |
public static function apply_user_price( $query, $is_shortcode = FALSE ) {
|
168 |
$option_permalink = get_option( 'berocket_permalink_option' );
|
169 |
-
if ( ( ( ! is_admin() && $query->is_main_query() ) || $is_shortcode ) && (
|
170 |
br_aapf_args_converter( $query );
|
171 |
|
172 |
-
if (
|
173 |
list( $_GET['min_price'], $_GET['max_price'] ) = $_POST['price'];
|
174 |
add_filter( 'loop_shop_post_in', array( __CLASS__, 'price_filter' ) );
|
175 |
}
|
@@ -183,18 +206,18 @@ class BeRocket_AAPF {
|
|
183 |
br_aapf_args_converter();
|
184 |
$args = br_aapf_args_parser();
|
185 |
|
186 |
-
if (
|
187 |
list( $_GET['min_price'], $_GET['max_price'] ) = $_POST['price'];
|
188 |
add_filter( 'loop_shop_post_in', array( __CLASS__, 'price_filter' ) );
|
189 |
}
|
190 |
|
191 |
-
if (
|
192 |
add_filter( 'loop_shop_post_in', array( __CLASS__, 'limits_filter' ) );
|
193 |
}
|
194 |
|
195 |
$args_fields = array( 'meta_key', 'tax_query', 'fields', 'where', 'join', 'meta_query' );
|
196 |
foreach ( $args_fields as $args_field ) {
|
197 |
-
if (
|
198 |
$query->set( $args_field, $args[$args_field] );
|
199 |
}
|
200 |
}
|
@@ -219,7 +242,11 @@ class BeRocket_AAPF {
|
|
219 |
$matched_products[] = $product->post_parent;
|
220 |
}
|
221 |
|
222 |
-
|
|
|
|
|
|
|
|
|
223 |
|
224 |
if ( sizeof( $filtered_posts ) == 0) {
|
225 |
$filtered_posts = $matched_products;
|
@@ -246,7 +273,11 @@ class BeRocket_AAPF {
|
|
246 |
$matched_products[] = $product->post_parent;
|
247 |
}
|
248 |
|
249 |
-
|
|
|
|
|
|
|
|
|
250 |
|
251 |
if ( sizeof( $filtered_posts ) == 0) {
|
252 |
$filtered_posts = $matched_products;
|
@@ -260,7 +291,7 @@ class BeRocket_AAPF {
|
|
260 |
public static function limits_filter( $filtered_posts ) {
|
261 |
global $wpdb;
|
262 |
|
263 |
-
if (
|
264 |
$matched_products = false;
|
265 |
|
266 |
foreach ( $_POST['limits'] as $v ) {
|
@@ -299,7 +330,11 @@ class BeRocket_AAPF {
|
|
299 |
$matched_products = array( 0 );
|
300 |
}
|
301 |
|
302 |
-
|
|
|
|
|
|
|
|
|
303 |
|
304 |
// Filter the id's
|
305 |
if ( sizeof( $filtered_posts ) == 0 ) {
|
@@ -315,7 +350,7 @@ class BeRocket_AAPF {
|
|
315 |
public static function price_filter( $filtered_posts ){
|
316 |
global $wpdb;
|
317 |
|
318 |
-
if (
|
319 |
$matched_products = array( 0 );
|
320 |
$min = floatval( $_POST['price'][0] );
|
321 |
$max = floatval( $_POST['price'][1] );
|
@@ -382,7 +417,7 @@ class BeRocket_AAPF {
|
|
382 |
|
383 |
public static function br_add_defaults() {
|
384 |
$tmp = get_option( 'br_filters_options' );
|
385 |
-
if (
|
386 |
delete_option( 'br_filters_options' );
|
387 |
update_option( 'br_filters_options', BeRocket_AAPF::$defaults );
|
388 |
}
|
3 |
* Plugin Name: Advanced AJAX Product Filter for WooCommerce
|
4 |
* Plugin URI: https://wordpress.org/plugins/woocommerce-ajax-filters/
|
5 |
* Description: Take a look at this fantastic AJAX products filter plugin for WooCommerce. Add unlimited filters with one widget.
|
6 |
+
* Version: 1.2.0
|
7 |
* Author: BeRocket
|
8 |
* Requires at least: 4.0
|
9 |
* Author URI: http://berocket.com
|
11 |
* Domain Path: /languages/
|
12 |
*/
|
13 |
|
14 |
+
define( "BeRocket_AJAX_filters_version", '1.2.0' );
|
15 |
define( "BeRocket_AJAX_domain", 'BeRocket_AJAX_domain' );
|
16 |
|
17 |
define( "AAPF_TEMPLATE_PATH", plugin_dir_path( __FILE__ ) . "templates/" );
|
28 |
class BeRocket_AAPF {
|
29 |
|
30 |
public static $defaults = array(
|
31 |
+
"br_opened_tab" => "general",
|
32 |
+
"no_products_message" => "There are no products meeting your criteria",
|
33 |
+
"no_products_class" => "",
|
34 |
+
"control_sorting" => "0",
|
35 |
+
'products_holder_id' => 'ul.products',
|
36 |
+
'woocommerce_result_count_class' => '.woocommerce-result-count',
|
37 |
+
'woocommerce_ordering_class' => 'form.woocommerce-ordering',
|
38 |
+
'woocommerce_pagination_class' => '.woocommerce-pagination',
|
39 |
+
'woocommerce_removes' => array(
|
40 |
+
'result_count' => '',
|
41 |
+
'ordering' => '',
|
42 |
+
'pagination' => '',
|
43 |
+
),
|
44 |
+
"seo_friendly_urls" => "0",
|
45 |
+
"filters_turn_off" => "0",
|
46 |
+
"show_all_values" => "0",
|
47 |
+
"hide_value" => array(
|
48 |
+
'o' => '0',
|
49 |
+
'sel' => '0',
|
50 |
+
),
|
51 |
+
'first_page_jump' => '0',
|
52 |
+
'scroll_shop_top' => '0',
|
53 |
+
'ajax_request_load' => '1',
|
54 |
+
'ajax_request_load_style' => 'jquery',
|
55 |
+
'user_func' => array(
|
56 |
+
'before_update' => '',
|
57 |
+
'on_update' => '',
|
58 |
+
'after_update' => '',
|
59 |
+
),
|
60 |
);
|
61 |
public static $values = array(
|
62 |
'settings_name' => '',
|
78 |
|
79 |
add_shortcode( 'br_filters', array( __CLASS__, 'shortcode' ) );
|
80 |
|
81 |
+
if( ! empty($_GET['filters']) and ! defined( 'DOING_AJAX' ) ) {
|
82 |
add_filter( 'pre_get_posts', array( __CLASS__, 'apply_user_price' ) );
|
83 |
add_filter( 'pre_get_posts', array( __CLASS__, 'apply_user_filters' ), 99999 );
|
84 |
}
|
85 |
|
86 |
+
if( ! empty($_GET['explode']) && $_GET['explode'] == 'explode' ) {
|
87 |
add_action( 'woocommerce_before_template_part', array( 'BeRocket_AAPF_Widget', 'pre_get_posts'), 999999 );
|
88 |
add_action( 'wp_footer', array( 'BeRocket_AAPF_Widget', 'end_clean'), 999999 );
|
89 |
add_action( 'init', array( 'BeRocket_AAPF_Widget', 'start_clean'), 1 );
|
189 |
|
190 |
public static function apply_user_price( $query, $is_shortcode = FALSE ) {
|
191 |
$option_permalink = get_option( 'berocket_permalink_option' );
|
192 |
+
if ( ( ( ! is_admin() && $query->is_main_query() ) || $is_shortcode ) && ( ! empty($_GET['filters']) || $query->get( $option_permalink['variable'], '' ) ) ) {
|
193 |
br_aapf_args_converter( $query );
|
194 |
|
195 |
+
if ( ! empty($_POST['price']) ) {
|
196 |
list( $_GET['min_price'], $_GET['max_price'] ) = $_POST['price'];
|
197 |
add_filter( 'loop_shop_post_in', array( __CLASS__, 'price_filter' ) );
|
198 |
}
|
206 |
br_aapf_args_converter();
|
207 |
$args = br_aapf_args_parser();
|
208 |
|
209 |
+
if ( ! empty($_POST['price']) ) {
|
210 |
list( $_GET['min_price'], $_GET['max_price'] ) = $_POST['price'];
|
211 |
add_filter( 'loop_shop_post_in', array( __CLASS__, 'price_filter' ) );
|
212 |
}
|
213 |
|
214 |
+
if ( ! empty($_POST['limits']) ) {
|
215 |
add_filter( 'loop_shop_post_in', array( __CLASS__, 'limits_filter' ) );
|
216 |
}
|
217 |
|
218 |
$args_fields = array( 'meta_key', 'tax_query', 'fields', 'where', 'join', 'meta_query' );
|
219 |
foreach ( $args_fields as $args_field ) {
|
220 |
+
if ( ! empty($args[$args_field]) ) {
|
221 |
$query->set( $args_field, $args[$args_field] );
|
222 |
}
|
223 |
}
|
242 |
$matched_products[] = $product->post_parent;
|
243 |
}
|
244 |
|
245 |
+
if( is_array($matched_products) ) {
|
246 |
+
$matched_products = array_unique( $matched_products );
|
247 |
+
} else {
|
248 |
+
$matched_products = array( 0 );
|
249 |
+
}
|
250 |
|
251 |
if ( sizeof( $filtered_posts ) == 0) {
|
252 |
$filtered_posts = $matched_products;
|
273 |
$matched_products[] = $product->post_parent;
|
274 |
}
|
275 |
|
276 |
+
if( is_array($matched_products) ) {
|
277 |
+
$matched_products = array_unique( $matched_products );
|
278 |
+
} else {
|
279 |
+
$matched_products = array( 0 );
|
280 |
+
}
|
281 |
|
282 |
if ( sizeof( $filtered_posts ) == 0) {
|
283 |
$filtered_posts = $matched_products;
|
291 |
public static function limits_filter( $filtered_posts ) {
|
292 |
global $wpdb;
|
293 |
|
294 |
+
if ( ! empty($_POST['limits']) ) {
|
295 |
$matched_products = false;
|
296 |
|
297 |
foreach ( $_POST['limits'] as $v ) {
|
330 |
$matched_products = array( 0 );
|
331 |
}
|
332 |
|
333 |
+
if( is_array($matched_products) ) {
|
334 |
+
$matched_products = array_unique( $matched_products );
|
335 |
+
} else {
|
336 |
+
$matched_products = array( 0 );
|
337 |
+
}
|
338 |
|
339 |
// Filter the id's
|
340 |
if ( sizeof( $filtered_posts ) == 0 ) {
|
350 |
public static function price_filter( $filtered_posts ){
|
351 |
global $wpdb;
|
352 |
|
353 |
+
if ( ! empty($_POST['price']) ) {
|
354 |
$matched_products = array( 0 );
|
355 |
$min = floatval( $_POST['price'][0] );
|
356 |
$max = floatval( $_POST['price'][1] );
|
417 |
|
418 |
public static function br_add_defaults() {
|
419 |
$tmp = get_option( 'br_filters_options' );
|
420 |
+
if ( empty($tmp) or empty($tmp['chk_default_options_db']) or $tmp['chk_default_options_db'] == '1' or ! is_array( $tmp ) ){
|
421 |
delete_option( 'br_filters_options' );
|
422 |
update_option( 'br_filters_options', BeRocket_AAPF::$defaults );
|
423 |
}
|