Advanced AJAX Product Filters - Version 1.1.2

Version Description

Download this release

Release Info

Developer dholovnia
Plugin Icon wp plugin Advanced AJAX Product Filters
Version 1.1.2
Comparing to
See all releases

Code changes from version 1.1.1 to 1.1.2

README.md CHANGED
@@ -4,8 +4,8 @@ Contributors: dholovnia, berocket
4
  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.2.2
8
- Stable tag: 1.1.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -139,6 +139,15 @@ http://woocommerce-product-filter.berocket.com
139
 
140
  == Changelog ==
141
 
 
 
 
 
 
 
 
 
 
142
  = 1.1.0.7 =
143
  * Enhancement - Option to hide selected values and/or without products. Add at the bottom button to show them
144
  * Enhancement - Filters are using product variations now
4
  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.3.1
8
+ Stable tag: 1.1.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
139
 
140
  == Changelog ==
141
 
142
+ = 1.1.1.1 =
143
+ * Fix - fixes for the bugs from the support forum
144
+
145
+ = 1.1.1 =
146
+ * Fix - most of the bugs for almost a month period
147
+
148
+ = 1.1.0.8 =
149
+ * Fix - removing PHP 5.5 code
150
+
151
  = 1.1.0.7 =
152
  * Enhancement - Option to hide selected values and/or without products. Add at the bottom button to show them
153
  * Enhancement - Filters are using product variations now
includes/functions.php CHANGED
@@ -125,14 +125,16 @@ if( ! function_exists( 'br_aapf_args_parser' ) ){
125
 
126
  if ( @$attributes ) {
127
  foreach ( $attributes as $k => $v ) {
128
- $terms = get_terms( array( $k ), $args = array( 'orderby' => 'name', 'order' => 'ASC' ) );
129
  if ( $terms ) {
130
- foreach ( $terms as $term ) {
131
- $attributes_terms[ $k ][ $term->term_id ] = $term->slug;
132
  }
133
  }
 
134
  }
135
  }
 
136
 
137
  if ( @$_POST['terms'] ) {
138
  foreach ( $_POST['terms'] as $t ) {
@@ -143,6 +145,7 @@ if( ! function_exists( 'br_aapf_args_parser' ) ){
143
  $taxonomies_operator[ $t[0] ] = $t[2];
144
  }
145
  }
 
146
 
147
  $taxonomies = apply_filters( 'berocket_aapf_listener_taxonomies', @$taxonomies );
148
  $taxonomies_operator = apply_filters( 'berocket_aapf_listener_taxonomies_operator', @$taxonomies_operator );
125
 
126
  if ( @$attributes ) {
127
  foreach ( $attributes as $k => $v ) {
128
+ $terms = get_terms( array( $k ), $args = array( 'orderby' => 'name', 'order' => 'ASC', 'fields' => 'id=>slug' ) );
129
  if ( $terms ) {
130
+ foreach ( $terms as $term_id => $term_slug ) {
131
+ $attributes_terms[ $k ][ $term_id ] = $term_slug;
132
  }
133
  }
134
+ unset( $terms );
135
  }
136
  }
137
+ unset( $attributes );
138
 
139
  if ( @$_POST['terms'] ) {
140
  foreach ( $_POST['terms'] as $t ) {
145
  $taxonomies_operator[ $t[0] ] = $t[2];
146
  }
147
  }
148
+ unset( $attributes_terms );
149
 
150
  $taxonomies = apply_filters( 'berocket_aapf_listener_taxonomies', @$taxonomies );
151
  $taxonomies_operator = apply_filters( 'berocket_aapf_listener_taxonomies_operator', @$taxonomies_operator );
includes/widget.php CHANGED
@@ -29,7 +29,11 @@ class BeRocket_AAPF_Widget extends WP_Widget {
29
  $control_ops = array( 'id_base' => 'berocket_aapf_widget' );
30
 
31
  /* Create the widget. */
32
- $this->WP_Widget( 'berocket_aapf_widget', __('AJAX Product Filters', BeRocket_AJAX_domain), $widget_ops, $control_ops );
 
 
 
 
33
 
34
  add_filter( 'berocket_aapf_listener_wp_query_args', 'br_aapf_args_parser' );
35
  }
@@ -84,7 +88,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
84
  'control_sorting' => @ $br_options['control_sorting'],
85
  'seo_friendly_urls' => @ $br_options['seo_friendly_urls'],
86
  'berocket_aapf_widget_product_filters' => $post_temrs,
87
- 'user_func' => @ $br_options['user_func'],
88
  'default_sorting' => get_option('woocommerce_default_catalog_orderby'),
89
  'first_page' => @ $br_options['first_page_jump'],
90
  'scroll_shop_top' => @ $br_options['scroll_shop_top'],
@@ -92,9 +96,13 @@ class BeRocket_AAPF_Widget extends WP_Widget {
92
  'ajax_request_load' => @ $br_options['ajax_request_load'],
93
  )
94
  );
 
 
95
 
96
  extract( $args );
97
  extract( $instance );
 
 
98
 
99
  if ( $widget_type == 'update_button' ) {
100
  set_query_var( 'title', apply_filters( 'berocket_aapf_widget_title', $title ) );
@@ -133,6 +141,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
133
  return true;
134
  }
135
  }
 
136
 
137
  $woocommerce_hide_out_of_stock_items = BeRocket_AAPF_Widget::woocommerce_hide_out_of_stock_items();
138
  $terms = $sort_terms = $price_range = array();
@@ -284,10 +293,11 @@ class BeRocket_AAPF_Widget extends WP_Widget {
284
 
285
  public static function get_price_range( $wp_query_product_cat, $woocommerce_hide_out_of_stock_items ){
286
  global $wp_query;
287
- $price_range = array();
288
  $wp_query_product_cat_save = $wp_query;
289
- $products = BeRocket_AAPF_Widget::get_filter_products( $wp_query_product_cat, $woocommerce_hide_out_of_stock_items, false );
290
- $wp_query = $wp_query_product_cat_save;
 
 
291
 
292
  foreach ( $products as $ID ) {
293
  $meta_values = get_post_meta( $ID, '_price' );
@@ -318,19 +328,32 @@ class BeRocket_AAPF_Widget extends WP_Widget {
318
  global $wp_query, $post;
319
  $terms = array();
320
  $q_args = $wp_query->query_vars;
321
- $q_args['nopaging'] = true;
322
- $q_args['post__in'] = '';
323
- $q_args['tax_query'] = '';
324
- $the_query = new WP_Query($q_args);
325
- while ( $the_query -> have_posts() ) {
326
- $the_query->the_post();
327
- $curent_terms = wp_get_object_terms( $post->ID, $taxonomy);
328
- foreach ( $curent_terms as $t ) {
329
- if ( ! in_array($t,$terms) ) {
330
- $terms[] = $t->term_id;
 
 
 
 
 
 
 
 
 
 
331
  }
332
  }
333
- }
 
 
 
334
  wp_reset_query();
335
  $args = array(
336
  'orderby' => $order_by,
@@ -499,6 +522,9 @@ class BeRocket_AAPF_Widget extends WP_Widget {
499
  $args['post_status'] = 'publish';
500
  $args['post_type'] = 'product';
501
  $args['post__in'] = BeRocket_AAPF::price_filter( $args['post__in'] );
 
 
 
502
 
503
  $wp_query = new WP_Query( $args );
504
 
@@ -507,6 +533,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
507
  $args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
508
  $wp_query = new WP_Query( $args );
509
  }
 
510
 
511
  if( @ ! $br_options['ajax_request_load'] ) {
512
  ob_start();
@@ -557,12 +584,13 @@ class BeRocket_AAPF_Widget extends WP_Widget {
557
  $_RESPONSE['products'] = $_RESPONSE['products'][1];
558
  ob_end_clean();
559
  global $wp_query, $wp_rewrite;
560
- $br_options = apply_filters( 'berocket_aapf_listener_br_options', get_option('br_filters_options') );
561
 
562
  if( $_RESPONSE['products'] == null ) {
563
  unset( $_RESPONSE['products'] );
564
  ob_start();
 
565
  echo apply_filters( 'berocket_aapf_listener_no_products_message', "<p class='no-products woocommerce-info" . ( ( $br_options['no_products_class'] ) ? ' '.$br_options['no_products_class'] : '' ) . "'>" . $br_options['no_products_message'] . "</p>" );
 
566
  $_RESPONSE['no_products'] = ob_get_contents();
567
  ob_end_clean();
568
  } else {
@@ -591,6 +619,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
591
  );
592
 
593
  $product_cats = get_terms( 'product_cat', apply_filters( 'wc_product_dropdown_categories_get_terms_args', $args ) );
 
594
  if ( ! empty( $product_cats ) ) {
595
  foreach ( $product_cats as $single_cat ) {
596
  $single_cat->depth = $depth;
@@ -608,7 +637,9 @@ class BeRocket_AAPF_Widget extends WP_Widget {
608
  }
609
 
610
  public static function pagination_args( $args = array() ) {
611
- $args['base'] = str_replace( 999999999, '%#%', self::get_pagenum_link( 999999999 ) );
 
 
612
  return $args;
613
  }
614
 
@@ -625,6 +656,7 @@ class BeRocket_AAPF_Widget extends WP_Widget {
625
  $home_root = preg_quote( $home_root, '|' );
626
 
627
  $request = preg_replace('|^'. $home_root . '|i', '', $request);
 
628
  $request = preg_replace('|^/+|', '', $request);
629
 
630
  if ( !$wp_rewrite->using_permalinks() ) {
29
  $control_ops = array( 'id_base' => 'berocket_aapf_widget' );
30
 
31
  /* Create the widget. */
32
+ if( strcmp( $wp_version, '4.3') < 0 ) {
33
+ $this->WP_Widget( 'berocket_aapf_widget', __('AJAX Product Filters', BeRocket_AJAX_domain), $widget_ops, $control_ops );
34
+ } else {
35
+ $this->__construct( 'berocket_aapf_widget', __('AJAX Product Filters', BeRocket_AJAX_domain), $widget_ops, $control_ops );
36
+ }
37
 
38
  add_filter( 'berocket_aapf_listener_wp_query_args', 'br_aapf_args_parser' );
39
  }
88
  'control_sorting' => @ $br_options['control_sorting'],
89
  'seo_friendly_urls' => @ $br_options['seo_friendly_urls'],
90
  'berocket_aapf_widget_product_filters' => $post_temrs,
91
+ 'user_func' => apply_filters( 'berocket_aapf_user_func', @ $br_options['user_func'] ),
92
  'default_sorting' => get_option('woocommerce_default_catalog_orderby'),
93
  'first_page' => @ $br_options['first_page_jump'],
94
  'scroll_shop_top' => @ $br_options['scroll_shop_top'],
96
  'ajax_request_load' => @ $br_options['ajax_request_load'],
97
  )
98
  );
99
+ unset( $current_language );
100
+ unset( $post_temrs );
101
 
102
  extract( $args );
103
  extract( $instance );
104
+ unset( $args );
105
+ unset( $instance );
106
 
107
  if ( $widget_type == 'update_button' ) {
108
  set_query_var( 'title', apply_filters( 'berocket_aapf_widget_title', $title ) );
141
  return true;
142
  }
143
  }
144
+ unset( $product_cat );
145
 
146
  $woocommerce_hide_out_of_stock_items = BeRocket_AAPF_Widget::woocommerce_hide_out_of_stock_items();
147
  $terms = $sort_terms = $price_range = array();
293
 
294
  public static function get_price_range( $wp_query_product_cat, $woocommerce_hide_out_of_stock_items ){
295
  global $wp_query;
 
296
  $wp_query_product_cat_save = $wp_query;
297
+ $products = BeRocket_AAPF_Widget::get_filter_products( $wp_query_product_cat, $woocommerce_hide_out_of_stock_items, false );
298
+ $wp_query = $wp_query_product_cat_save;
299
+ unset( $wp_query_product_cat_save );
300
+ $price_range = array();
301
 
302
  foreach ( $products as $ID ) {
303
  $meta_values = get_post_meta( $ID, '_price' );
328
  global $wp_query, $post;
329
  $terms = array();
330
  $q_args = $wp_query->query_vars;
331
+ $q_args['posts_per_page'] = 2000;
332
+ $q_args['post__in'] = '';
333
+ $q_args['tax_query'] = '';
334
+ $q_args['product_tag'] = '';
335
+ $q_args['taxonomy'] = '';
336
+ $q_args['term'] = '';
337
+ $q_args['meta_query'] = '';
338
+ $q_args['fields'] = 'ids';
339
+ $paged = 1;
340
+ do{
341
+ $q_args['paged'] = $paged;
342
+ $the_query = new WP_Query($q_args);
343
+ if ( $the_query->have_posts() ) {
344
+ foreach ( $the_query->posts as $post_id ) {
345
+ $curent_terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'ids' ) );
346
+ foreach ( $curent_terms as $t ) {
347
+ if ( ! in_array( $t,$terms ) ) {
348
+ $terms[] = $t;
349
+ }
350
+ }
351
  }
352
  }
353
+ $paged++;
354
+ } while($paged <= $the_query->max_num_pages);
355
+ unset( $q_args );
356
+ unset( $the_query );
357
  wp_reset_query();
358
  $args = array(
359
  'orderby' => $order_by,
522
  $args['post_status'] = 'publish';
523
  $args['post_type'] = 'product';
524
  $args['post__in'] = BeRocket_AAPF::price_filter( $args['post__in'] );
525
+ $default_posts_per_page = get_option( 'posts_per_page' );
526
+ $args['posts_per_page'] = apply_filters( 'loop_shop_per_page', $default_posts_per_page );
527
+ unset( $default_posts_per_page );
528
 
529
  $wp_query = new WP_Query( $args );
530
 
533
  $args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
534
  $wp_query = new WP_Query( $args );
535
  }
536
+ unset( $args );
537
 
538
  if( @ ! $br_options['ajax_request_load'] ) {
539
  ob_start();
584
  $_RESPONSE['products'] = $_RESPONSE['products'][1];
585
  ob_end_clean();
586
  global $wp_query, $wp_rewrite;
 
587
 
588
  if( $_RESPONSE['products'] == null ) {
589
  unset( $_RESPONSE['products'] );
590
  ob_start();
591
+ $br_options = apply_filters( 'berocket_aapf_listener_br_options', get_option('br_filters_options') );
592
  echo apply_filters( 'berocket_aapf_listener_no_products_message', "<p class='no-products woocommerce-info" . ( ( $br_options['no_products_class'] ) ? ' '.$br_options['no_products_class'] : '' ) . "'>" . $br_options['no_products_message'] . "</p>" );
593
+ unset( $br_options );
594
  $_RESPONSE['no_products'] = ob_get_contents();
595
  ob_end_clean();
596
  } else {
619
  );
620
 
621
  $product_cats = get_terms( 'product_cat', apply_filters( 'wc_product_dropdown_categories_get_terms_args', $args ) );
622
+ unset( $args );
623
  if ( ! empty( $product_cats ) ) {
624
  foreach ( $product_cats as $single_cat ) {
625
  $single_cat->depth = $depth;
637
  }
638
 
639
  public static function pagination_args( $args = array() ) {
640
+ if ( defined('DOING_AJAX') && DOING_AJAX ) {
641
+ $args['base'] = str_replace( 999999999, '%#%', self::get_pagenum_link( 999999999 ) );
642
+ }
643
  return $args;
644
  }
645
 
656
  $home_root = preg_quote( $home_root, '|' );
657
 
658
  $request = preg_replace('|^'. $home_root . '|i', '', $request);
659
+ unset( $home_root );
660
  $request = preg_replace('|^/+|', '', $request);
661
 
662
  if ( !$wp_rewrite->using_permalinks() ) {
readme.txt CHANGED
@@ -4,8 +4,8 @@ Contributors: dholovnia, berocket
4
  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.2.2
8
- Stable tag: 1.1.1
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -139,6 +139,9 @@ http://woocommerce-product-filter.berocket.com
139
 
140
  == Changelog ==
141
 
 
 
 
142
  = 1.1.1 =
143
  * Fix - most of the bugs for almost a month period
144
 
4
  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.3.1
8
+ Stable tag: 1.1.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
139
 
140
  == Changelog ==
141
 
142
+ = 1.1.1.1 =
143
+ * Fix - fixes for the bugs from the support forum
144
+
145
  = 1.1.1 =
146
  * Fix - most of the bugs for almost a month period
147
 
woocommerce-filters.php CHANGED
@@ -3,12 +3,12 @@
3
  * Plugin Name: Advanced AJAX Product Filters for WooCommerce
4
  * Plugin URI: http://berocket.com/wp-plugins/product-filters
5
  * Description: Advanced AJAX Product Filters for WooCommerce
6
- * Version: 1.1.1
7
  * Author: BeRocket
8
  * Author URI: http://berocket.com
9
  */
10
 
11
- define( "BeRocket_AJAX_filters_version", '1.1.0.7' );
12
  define( "BeRocket_AJAX_domain", 'BRaapf' );
13
 
14
  define( "AAPF_TEMPLATE_PATH", plugin_dir_path( __FILE__ ) . "templates/" );
3
  * Plugin Name: Advanced AJAX Product Filters for WooCommerce
4
  * Plugin URI: http://berocket.com/wp-plugins/product-filters
5
  * Description: Advanced AJAX Product Filters for WooCommerce
6
+ * Version: 1.1.2
7
  * Author: BeRocket
8
  * Author URI: http://berocket.com
9
  */
10
 
11
+ define( "BeRocket_AJAX_filters_version", '1.1.1' );
12
  define( "BeRocket_AJAX_domain", 'BRaapf' );
13
 
14
  define( "AAPF_TEMPLATE_PATH", plugin_dir_path( __FILE__ ) . "templates/" );