Advanced AJAX Product Filters - Version 1.0.4.3

Version Description

Download this release

Release Info

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

Code changes from version 1.0.4.2 to 1.0.4.3

includes/functions.php CHANGED
@@ -41,13 +41,14 @@ if( ! function_exists( 'br_parse_order_by' ) ){
41
  * @param $args
42
  */
43
  function br_aapf_parse_order_by( &$args ){
44
- $orderby = $_POST['orderby'];
45
  $order = "ASK";
46
  if( @ preg_match( "/-/", $orderby ) ){
47
  list( $orderby, $order ) = explode( "-", $orderby );
48
  }
49
 
50
- if( @ $orderby and @ $order ) {
 
51
 
52
  // Get ordering from query string unless defined
53
  $orderby = strtolower( $orderby );
@@ -173,7 +174,7 @@ if( ! function_exists( 'br_aapf_args_converter' ) ) {
173
  $filters[0] = $_GET['filters'];
174
  }
175
 
176
- foreach ( $filters as $filter ) {
177
  list( $attribute, $value ) = explode( "=", $filter );
178
 
179
  if ( $attribute == 'price' ) {
@@ -181,8 +182,8 @@ if( ! function_exists( 'br_aapf_args_converter' ) ) {
181
  } elseif ( $attribute == 'order' ) {
182
  $_GET['orderby'] = $value;
183
  } else {
184
- $term_or_limit = explode( "^", $value );
185
- if ( $term_or_limit[1] == 'OR' or $term_or_limit[1] == 'AND' ) {
186
  $_POST['terms'][] = array( "pa_" . $attribute, $term_or_limit[0], $term_or_limit[1] );
187
  } else {
188
  $_POST['limits'][] = array( "pa_" . $attribute, $term_or_limit[0], $term_or_limit[1] );
41
  * @param $args
42
  */
43
  function br_aapf_parse_order_by( &$args ){
44
+ $orderby = $_GET['orderby'] = $_POST['orderby'];
45
  $order = "ASK";
46
  if( @ preg_match( "/-/", $orderby ) ){
47
  list( $orderby, $order ) = explode( "-", $orderby );
48
  }
49
 
50
+ // needed for woocommerce sorting funtionality
51
+ if( @ $orderby and @ $order ) {
52
 
53
  // Get ordering from query string unless defined
54
  $orderby = strtolower( $orderby );
174
  $filters[0] = $_GET['filters'];
175
  }
176
 
177
+ foreach ( $filters as $filter ) {
178
  list( $attribute, $value ) = explode( "=", $filter );
179
 
180
  if ( $attribute == 'price' ) {
182
  } elseif ( $attribute == 'order' ) {
183
  $_GET['orderby'] = $value;
184
  } else {
185
+ $term_or_limit = explode( "^", $value );
186
+ if ( $term_or_limit[1] == 'OR' or $term_or_limit[1] == 'AND' ) {
187
  $_POST['terms'][] = array( "pa_" . $attribute, $term_or_limit[0], $term_or_limit[1] );
188
  } else {
189
  $_POST['limits'][] = array( "pa_" . $attribute, $term_or_limit[0], $term_or_limit[1] );
includes/widget.php CHANGED
@@ -385,44 +385,43 @@ class BeRocket_AAPF_Widget extends WP_Widget {
385
 
386
  $args['post__in'] = BeRocket_AAPF::limits_filter( array() );
387
  $args['post__in'] = BeRocket_AAPF::price_filter( $args['post__in'] );
388
- $args['post_status'] = 'publish';
389
  $args['post_type'] = 'product';
390
 
391
- // it is killing post_type=product, not sure why
392
- //add_filter( 'posts_where', array( 'WC_QUERY', 'exclude_protected_products' ) );
393
-
394
  $wp_query = new WP_Query( $args );
395
 
396
  // here we get max products to know if current page is not too big
397
- if ( $wp_rewrite->using_permalinks() and preg_match( "~/page/([0-9]+)~", $_POST['location'], $mathces ) ) {
398
- $args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
399
- $wp_query = new WP_Query( $args );
400
- } elseif( preg_match( "~paged?=([0-9]+)~", $_POST['location'], $mathces ) ) {
401
  $args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
402
  $wp_query = new WP_Query( $args );
403
  }
404
 
405
  ob_start();
406
- woocommerce_result_count();
407
- $_RESPONSE['results_num_html'] = apply_filters( 'berocket_aapf_listener_results_num_text', ob_get_contents() );
408
- ob_end_clean();
409
 
410
- ob_start();
411
- woocommerce_pagination();
412
- $_RESPONSE['pagination_html'] = apply_filters( 'berocket_aapf_listener_pagination_html', ob_get_contents() );
413
- ob_end_clean();
414
-
415
- ob_start();
416
  if ( $wp_query->have_posts() ) {
417
- while ( $wp_query->have_posts() ) {
418
- $wp_query->the_post();
419
- woocommerce_get_template_part( 'content', 'product' );
420
- }
 
 
 
 
 
 
 
 
 
 
 
421
  wp_reset_postdata();
 
 
422
  } else {
423
  echo apply_filters( 'berocket_aapf_listener_no_products_message', "<div class='no-products" . ( ( $br_options['no_products_class'] ) ? ' '.$br_options['no_products_class'] : '' ) . "'>" . $br_options['no_products_message'] . "</div>" );
 
 
424
  }
425
- $_RESPONSE['products'] = ob_get_contents();
426
  ob_end_clean();
427
 
428
  echo json_encode( $_RESPONSE );
385
 
386
  $args['post__in'] = BeRocket_AAPF::limits_filter( array() );
387
  $args['post__in'] = BeRocket_AAPF::price_filter( $args['post__in'] );
388
+ $args['post_status'] = 'publish';
389
  $args['post_type'] = 'product';
390
 
 
 
 
391
  $wp_query = new WP_Query( $args );
392
 
393
  // here we get max products to know if current page is not too big
394
+ if ( $wp_rewrite->using_permalinks() and preg_match( "~/page/([0-9]+)~", $_POST['location'], $mathces ) or preg_match( "~paged?=([0-9]+)~", $_POST['location'], $mathces ) ) {
 
 
 
395
  $args['paged'] = min( $mathces[1], $wp_query->max_num_pages );
396
  $wp_query = new WP_Query( $args );
397
  }
398
 
399
  ob_start();
 
 
 
400
 
 
 
 
 
 
 
401
  if ( $wp_query->have_posts() ) {
402
+
403
+ do_action('woocommerce_before_shop_loop');
404
+
405
+ woocommerce_product_loop_start();
406
+ woocommerce_product_subcategories();
407
+
408
+ while ( have_posts() ) {
409
+ the_post();
410
+ wc_get_template_part( 'content', 'product' );
411
+ }
412
+
413
+ woocommerce_product_loop_end();
414
+
415
+ do_action('woocommerce_after_shop_loop');
416
+
417
  wp_reset_postdata();
418
+
419
+ $_RESPONSE['products'] = ob_get_contents();
420
  } else {
421
  echo apply_filters( 'berocket_aapf_listener_no_products_message', "<div class='no-products" . ( ( $br_options['no_products_class'] ) ? ' '.$br_options['no_products_class'] : '' ) . "'>" . $br_options['no_products_message'] . "</div>" );
422
+
423
+ $_RESPONSE['no_products'] = ob_get_contents();
424
  }
 
425
  ob_end_clean();
426
 
427
  echo json_encode( $_RESPONSE );
js/widget.min.js CHANGED
@@ -1,2 +1,2 @@
1
  /* http://dean.edwards.name/packer/ */
2
- eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$(1I).1J(5(){12 d=1K.1L(n.1M),F=[],N=[],O=1;4($(\'.8-h\').G(\'.8-h\')){O=u($(\'.8-h .y\').P());4(O<1)O=1}5 H(b){$(n.1c).1N(\'1d\').1O(\'<1e 1f="1g" />\');4(b){$v=b.1h().1h();4(b.Q("I"))$v=b.1P("1i:1j");w=$v.6(\'w\');J=$v.6(\'J\');R=$v.6(\'R\');4(b.Q("I")){$(d).s(5(i,o){4(o[0]==w){d.1k(i,1)}});4($v.z())d[d.j]=[w,J,R]}p{4(b.Q(\':1Q\')||b.Q(\':1j\')){d[d.j]=[w,J,R]}p{$(d).s(5(i,o){4(o[0]==w&&o[1]==J){d.1k(i,1)}})}}}F=[];N=[];$t=$(\'.S\');4($t.G(\'S\')){$t.s(5(i,o){T=$(\'#\'+$(o).6(\'1l\')).z();U=$(\'#\'+$(o).6(\'1m\')).z();4(T!=$(o).6(\'V\')||U!=$(o).6(\'W\')){4($(o).G(\'13\')){N=[T,U]}p{F[F.j]=[$(o).6(\'w\'),T,U]}}})}4($(\'.8-h\').G(\'.8-h\')){$(\'.8-h 1R.l-1n v a\')}q={14:d,r:N,15:F,K:n.K,1S:\'1T\',A:$(\'.8-16 I.A\').z()};4(n.1U&&\'X\'1o 1V&&\'1p\'1o X){1q(q);q.g=g.B}p{q.g=n.1r;e=$(\'.8-h L.y\').P();4(C=g.B.D(/.+\\/l\\/([0-9]+).+/,"$1")){4(!u(e)){e=C}q.g=q.g.D(/\\/?/,"")+"/l/"+e+"/"}p 4(C=g.B.D(/.+1s?=([0-9]+).+/,"$1")){4(!u(e)){e=C}q.g=q.g.D(/\\/?/,"")+"?l="+e+""}}$.1W(n.1X,q,5(a){$(\'.8-1Y-1Z\').1t(a.20);$(\'.8-h\').17();$(n.1c).1u(a.21).1t(a.22).1v(\'1d\');$(\'.1g\').17();18()},"23")}5 1q(a){f=[];m=\'\';4(a.A&&$(\'.8-16 I.A 1i:24\').25(\'26\')!=a.A){f[f.j]=\'27=\'+a.A}4(a.K&&a.K>0){f[f.j]=\'28=\'+a.K}4(a.r){$19=$(\'.13\');4(a.r[0]&&a.r[1]&&(a.r[0]!=$19.6(\'V\')||a.r[1]!=$19.6(\'W\'))){f[f.j]=\'r=\'+a.r[0]+\'^\'+a.r[1]}}4(a.15){$(a.15).s(5(i,o){f[f.j]=o[0].1w(3)+\'=\'+o[1]+\'^\'+o[2]})}4(a.14){$(a.14).s(5(i,o){f[f.j]=o[0].1w(3)+\'=\'+o[1]+\'^\'+o[2]})}12 b=n.1r;4(f.j){$(f).s(5(i,o){4(m)m+="|";m+=o})}e=$(\'.8-h L.y\').P();4(C=u(g.B.D(/.+\\/l\\/([0-9]+).+/,"$1"))){4(!u(e)){e=C}b=b.D(/\\/?$/,"")+"/l/"+e+"/";4(m){b=b+"?Y="+m}}p{Z=10;4(/\\?/.1x(g.B)){M=g.B.11(\'?\');4(M[1]){7=[];29=[];4(/&/.1x(M[1])){7=M[1].11(\'&\');1y=7.j;1z(k=0;k<1y;k++){E=7[k].11(\'=\');7[k]=[];7[k][0]=E.1A();7[k][1]=E.1B("=")}}p{7[0]=[];E=M[1].11(\'=\');7[0][0]=E.1A();7[0][1]=E.1B("=")}1z(k=0;k<7.j;k++){4(7[k][0]==\'Y\'||7[k][0]==\'l\'||7[k][0]==\'1s\')2a;4(Z)b+=\'&\';p b+=\'?\';b+=7[k][0]+\'=\'+7[k][1];Z=1C}}}4(Z&&m){b=b+"&Y="+m;4(e>1){b=b+"&l="+u(e)}}p 4(m){b=b+"?Y="+m;4(e>1){b=b+"&l="+u(e)}}}2b.2c(b);12 c={1D:"1E"};X.1p(c,"1D 1E",b);X.2d=b}5 18(){$(\'.8-h\').1a(\'2e\',\'a\',5(a){a.1F();$(\'.8-h L.y\').1v(\'y\');$(1b).1u("<L 1f=\'l-1n y\'>"+$(1b).P()+"</L>").17();H(10)})}$(\'.2f\').1a("2g","2h, I",5(){H($(1b))});$(".S").s(5(i,o){$(o).2i({2j:1C,V:$(o).6(\'V\')>>0,W:$(o).6(\'W\')>>0,1G:[$(o).6(\'2k\')>>0,$(o).6(\'2l\')>>0],2m:5(a,b){$o=$(b.2n).2o(\'1e.S\');x=b.1G;4($(o).G(\'13\')){x[0]=x[0].1H(2);x[1]=x[1].1H(2)}$(\'#\'+$o.6(\'1l\')).z(x[0]);$(\'#\'+$o.6(\'1m\')).z(x[1])},2p:5(){H(10)}})});$(".2q").s(5(i,o){$(o).2r({2s:"2t",2u:$(o).6(\'2v\'),2w:2x})});4(n.2y){$(\'.8-16\').1a(\'2z\',5(a){a.1F();H(10)})}18()})})(2A);',62,161,'||||if|function|data|passed_vars2|woocommerce||||||cur_page|uri_request_array|location|pagination||length||page|uri_request|the_ajax_script||else|args|price|each||parseInt|li|taxonomy|vals|current|val|orderby|href|prev_page|replace|temp|berocket_aapf_widget_product_limits|hasClass|updateProducts|select|term_id|product_cat|span|passed_vars1|berocket_aapf_widget_product_price_limit|woocommerce_pagination_page|text|is|operator|berocket_filter_slider|val1|val2|min|max|history|filters|something_added|false|split|var|berocket_filter_price_slider|terms|limits|ordering|remove|pagin_action_init|price_obj|on|this|products_holder_id|hide_products|div|class|berocket_aapf_widget_loading|parent|option|selected|splice|fields_1|fields_2|numbers|in|pushState|updateLocation|current_page_url|paged|html|after|removeClass|substring|test|passed_vars2_length|for|shift|join|true|BeRocket|Rules|preventDefault|values|toFixed|document|ready|JSON|parse|berocket_aapf_widget_product_filters|addClass|append|find|checked|ul|action|berocket_aapf_listener|seo_friendly_urls|window|post|ajaxurl|result|count|results_num_html|pagination_html|products|json|first|attr|value|order|pcategory|temp2|continue|console|log|pathname|click|berocket_aapf_widget|change|input|slider|range|value1|value2|slide|handle|parents|stop|berocket_aapf_widget_height_control|mCustomScrollbar|axis|xy|theme|scroll_theme|scrollInertia|300|control_sorting|submit|jQuery'.split('|'),0,{}))
1
  /* http://dean.edwards.name/packer/ */
2
+ eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$(15).1P(5(){16 d=1Q.1R(j.1S),G=[],P=[],Q=1;4($(\'.6-l\').y(\'.6-l\')){Q=s($(\'.6-l .z\').R());4(Q<1)Q=1}5 H(b){$(j.S).1T(\'17\').1U(\'<1j 1k="1l" />\');4(b){4(b.I("A"))m=b.1V("1m:1n").8();f m=b.8();4(b.I("A")){$(d).u(5(i,o){4(o[0]==m.J){d.1o(i,1)}});4($1p.B())d[d.n]=[m.J,m.18,m.1q]}f{4(b.I(\':1W\')||b.I(\':1n\')){d[d.n]=[m.J,m.18,m.1q]}f{$(d).u(5(i,o){4(o[0]==m.J&&o[1]==m.18){d.1o(i,1)}})}}}G=[];P=[];$t=$(\'.T\');4($t.y(\'T\')){$t.u(5(i,o){U=$(\'#\'+$(o).8(\'1r\')).B();V=$(\'#\'+$(o).8(\'1s\')).B();4(U!=$(o).8(\'W\')||V!=$(o).8(\'X\')){4($(o).y(\'19\')){P=[U,V]}f{G[G.n]=[$(o).8(\'J\'),U,V]}}})}4($(\'.6-l\').y(\'.6-l\')){$(\'.6-l 1X.v-1t 1p a\')}q={1a:d,r:P,1b:G,K:j.K,1Y:\'1Z\',w:$(\'.6-Y A.w\').B()};4(j.20&&\'Z\'1u 21&&\'1v\'1u Z){1w(q);q.h=h.C}f{q.h=j.1x;7=$(\'.6-l L.z\').R();4(D=h.C.E(/.+\\/v\\/([0-9]+).+/,"$1")){4(!s(7)){7=D}q.h=q.h.E(/\\/?/,"")+"/v/"+7+"/"}f 4(D=h.C.E(/.+M?=([0-9]+).+/,"$1")){4(!s(7)){7=D}q.h=q.h.E(/\\/?/,"")+"?v="+7+""}}$.22(j.23,q,5(a){$(\'.6-24-25\').N();$(\'.6-l\').N();$(\'1y.6-Y\').N();4($(\'.6-1c\').y(\'6-1c\')&&!$(j.S).I(\':26\')){4(1z a.1d!=\'1A\'){$(\'.6-1c\').1B(a.1d)}}f{4(1z a.1C!=\'1A\'){$(j.S).27(a.1C).1e(\'17\')}f{$(j.S).1B(a.1d).1e(\'17\')}}$(\'.1l\').N();1f()},"28")}5 1w(a){g=[];p=\'\';4(a.w&&$(\'.6-Y A.w 1m:29\').2a(\'2b\')!=a.w){g[g.n]=\'2c=\'+a.w}4(a.K&&a.K>0){g[g.n]=\'2d=\'+a.K}4(a.r){$1g=$(\'.19\');4(a.r[0]&&a.r[1]&&(a.r[0]!=$1g.8(\'W\')||a.r[1]!=$1g.8(\'X\'))){g[g.n]=\'r=\'+a.r[0]+\'^\'+a.r[1]}}4(a.1b){$(a.1b).u(5(i,o){g[g.n]=o[0].1D(3)+\'=\'+o[1]+\'^\'+o[2]})}4(a.1a){$(a.1a).u(5(i,o){g[g.n]=o[0].1D(3)+\'=\'+o[1]+\'^\'+o[2]})}16 b=j.1x;4(g.n){$(g).u(5(i,o){4(p)p+="|";p+=o})}7=$(\'.6-l L.z\').R();4(D=s(h.C.E(/.+\\/v\\/([0-9]+).+/,"$1"))){4(!s(7)){7=D}b=b.E(/\\/?$/,"")+"/v/"+7+"/";4(p){b=b+"?10="+p}}f{11=12;4(/\\?/.1E(h.C)){O=h.C.13(\'?\');4(O[1]){e=[];2e=[];4(/&/.1E(O[1])){e=O[1].13(\'&\');1F=e.n;1G(k=0;k<1F;k++){F=e[k].13(\'=\');e[k]=[];e[k][0]=F.1H();e[k][1]=F.1I("=")}}f{e[0]=[];F=O[1].13(\'=\');e[0][0]=F.1H();e[0][1]=F.1I("=")}1G(k=0;k<e.n;k++){4(e[k][0]==\'10\'||e[k][0]==\'v\'||e[k][0]==\'M\')2f;4(11)b+=\'&\';f b+=\'?\';b+=e[k][0]+\'=\'+e[k][1];11=1J}}}4(11&&p){b=b+"&10="+p;4(7>1){b=b+"&M="+s(7)}}f 4(p){b=b+"?10="+p;4(7>1){b=b+"&M="+s(7)}}f 4(7>1){b=b+"?M="+s(7)}}16 c={1K:"1L"};Z.1v(c,"1K 1L",b);Z.2g=b}5 1f(){$(\'.6-l\').14(\'2h\',\'a\',5(a){a.1h();$(\'.6-l L.z\').1e(\'z\');$(1i).2i("<L 1k=\'v-1t z\'>"+$(1i).R()+"</L>").N();H(12)})}$(\'.2j\').14("1M","2k, A",5(){H($(1i))});$(".T").u(5(i,o){$(o).2l({2m:1J,W:$(o).8(\'W\')>>0,X:$(o).8(\'X\')>>0,1N:[$(o).8(\'2n\')>>0,$(o).8(\'2o\')>>0],2p:5(a,b){$o=$(b.2q).2r(\'1j.T\');x=b.1N;4($(o).y(\'19\')){x[0]=x[0].1O(2);x[1]=x[1].1O(2)}$(\'#\'+$o.8(\'1r\')).B(x[0]);$(\'#\'+$o.8(\'1s\')).B(x[1])},2s:5(){H(12)}})});$(".2t").u(5(i,o){$(o).2u({2v:"2w",2x:$(o).8(\'2y\'),2z:2A})});4(j.2B){$(15).14(\'2C\',\'1y.6-Y\',5(a){a.1h()});$(15).14(\'1M\',\'A.w\',5(a){a.1h();H(12)})}1f()})})(2D);',62,164,'||||if|function|woocommerce|cur_page|data||||||passed_vars2|else|uri_request_array|location||the_ajax_script||pagination|el_data|length||uri_request|args|price|parseInt||each|page|orderby|vals|hasClass|current|select|val|href|prev_page|replace|temp|berocket_aapf_widget_product_limits|updateProducts|is|taxonomy|product_cat|span|paged|remove|passed_vars1|berocket_aapf_widget_product_price_limit|woocommerce_pagination_page|text|products_holder_id|berocket_filter_slider|val1|val2|min|max|ordering|history|filters|something_added|false|split|on|document|var|hide_products|term_id|berocket_filter_price_slider|terms|limits|info|products|removeClass|aapf_action_init|price_obj|preventDefault|this|div|class|berocket_aapf_widget_loading|option|selected|splice|li|operator|fields_1|fields_2|numbers|in|pushState|updateLocation|current_page_url|form|typeof|undefined|replaceWith|no_products|substring|test|passed_vars2_length|for|shift|join|true|BeRocket|Rules|change|values|toFixed|ready|JSON|parse|berocket_aapf_widget_product_filters|addClass|append|find|checked|ul|action|berocket_aapf_listener|seo_friendly_urls|window|post|ajaxurl|result|count|visible|html|json|first|attr|value|order|pcategory|temp2|continue|pathname|click|after|berocket_aapf_widget|input|slider|range|value1|value2|slide|handle|parents|stop|berocket_aapf_widget_height_control|mCustomScrollbar|axis|xy|theme|scroll_theme|scrollInertia|300|control_sorting|submit|jQuery'.split('|'),0,{}))
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
6
  Requires at least: 3.9
7
  Tested up to: 4.1
8
- Stable tag: 1.0.4.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -22,6 +22,7 @@ WooCommerce AJAX Filters - advanced AJAX product filters plugin for WooCommerce.
22
  * Multiple User Interface Elements
23
  * SEO Friendly Urls ( with HTML5 PushState )
24
  * Filter Visibility By Product Category And Globals.
 
25
  * Filter box height limit with scroll themes
26
  * Working great with custom widget area
27
  * Drag and Drop Filter Building
@@ -30,9 +31,6 @@ WooCommerce AJAX Filters - advanced AJAX product filters plugin for WooCommerce.
30
  = Demo =
31
  http://woocommerce-product-filter.berocket.com
32
 
33
- = Plugin Documentation Page =
34
- http://berocket.com/wp-plugins/product-filters
35
-
36
  = How It Works: =
37
 
38
  = Step 1: =
@@ -52,6 +50,20 @@ http://berocket.com/wp-plugins/product-filters
52
  * That's it =)
53
 
54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
 
57
  = Advanced Settings (Widget area): =
@@ -66,6 +78,15 @@ http://berocket.com/wp-plugins/product-filters
66
  how it looks depends on the theme you choose.
67
 
68
 
 
 
 
 
 
 
 
 
 
69
 
70
 
71
  == Installation ==
@@ -84,6 +105,13 @@ http://berocket.com/wp-plugins/product-filters
84
 
85
  == Changelog ==
86
 
 
 
 
 
 
 
 
87
  = 1.0.4.2 =
88
  * Enhancement/Fix - Better support for SEO urls with permalinks on/off
89
  * Fix - Critical bug that was returning incorrect products.
5
  Tags: filters, product filters, ajax product filters, advanced product filters, woocommerce filters, woocommerce product filters, woocommerce ajax product filters
6
  Requires at least: 3.9
7
  Tested up to: 4.1
8
+ Stable tag: 1.0.4.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
22
  * Multiple User Interface Elements
23
  * SEO Friendly Urls ( with HTML5 PushState )
24
  * Filter Visibility By Product Category And Globals.
25
+ * Accessible through shortcode
26
  * Filter box height limit with scroll themes
27
  * Working great with custom widget area
28
  * Drag and Drop Filter Building
31
  = Demo =
32
  http://woocommerce-product-filter.berocket.com
33
 
 
 
 
34
  = How It Works: =
35
 
36
  = Step 1: =
50
  * That's it =)
51
 
52
 
53
+ = Shortcode: =
54
+ * In editor `[br_filters attribute=price type=slider title="Price Filter"]`
55
+ * In PHP `do_shortcode('[br_filters attribute=price type=slider title="Price Filter"]');`
56
+
57
+ = Shortcode Options: =
58
+ * `attribute`(required) - product attribute, eg price or length. Don't forget that woocommerce adding pa_ suffix for created attributes.
59
+ So if you create new attribute `jump` its name is `pa_jump`
60
+ * `type`(required) - checkbox, radio, slider or select
61
+ * `operator` - OR or AND
62
+ * `title` - whatever you want to see as title. Can be empty
63
+ * `product_cat` - parent category id
64
+ * `cat_propagation` - should we propagate this filter to child categories? set 1 to turn this on
65
+ * `height` - max filter box height. When height is met scroll will be added
66
+ * `scroll_theme` - pretty clear name, scroll theme. Will be used if height is set and real height of box is more
67
 
68
 
69
  = Advanced Settings (Widget area): =
78
  how it looks depends on the theme you choose.
79
 
80
 
81
+ = Advanced Settings (Plugin Settings): =
82
+ * Plugin settings can be found in admin area, WooCommerce -> Product Filters
83
+ * "No Products" message - Text that will be shown if no products found
84
+ * "No Products" class - Add class and use it to style "No Products" box
85
+ * Products selector - Selector for tag that is holding products
86
+ * Sorting control - Take control over WooCommerce's sorting selectbox
87
+ * SEO friendly urls - url will be changed when filter is selected/changed
88
+ * Turn all filters off - If you want to hide filters without losing current configuration just turn them off
89
+
90
 
91
 
92
  == Installation ==
105
 
106
  == Changelog ==
107
 
108
+ = 1.0.4.2 =
109
+ * Enhancement - shortcode added
110
+ * Critical/Fix - If slider match none its values wasn't counted
111
+ * Enhancement/Fix - Changing attribute data location from url to action-element, providing more flexibility for template
112
+ * Enhancement/Templating - Using full products loop instead of including product content template
113
+ * Fix - Pagination with SEO url issue
114
+
115
  = 1.0.4.2 =
116
  * Enhancement/Fix - Better support for SEO urls with permalinks on/off
117
  * Fix - Critical bug that was returning incorrect products.
templates/checkbox.php CHANGED
@@ -10,9 +10,10 @@
10
  */
11
  ?>
12
  <?php foreach( $terms as $term ):?>
13
- <li data-term_id='<?=$term->term_id?>' data-taxonomy='<?=$term->taxonomy?>' data-operator='<?=$operator?>'>
14
  <span>
15
  <input type='checkbox' id='radio_<?=$term->term_id?>'
 
16
  <?php
17
  if( $_POST['terms'] ){
18
  foreach( $_POST['terms'] as $p_term ){
10
  */
11
  ?>
12
  <?php foreach( $terms as $term ):?>
13
+ <li>
14
  <span>
15
  <input type='checkbox' id='radio_<?=$term->term_id?>'
16
+ data-term_id='<?=$term->term_id?>' data-taxonomy='<?=$term->taxonomy?>' data-operator='<?=$operator?>'
17
  <?php
18
  if( $_POST['terms'] ){
19
  foreach( $_POST['terms'] as $p_term ){
templates/radio.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php foreach( $terms as $term ): ?>
2
- <li data-term_id='<?=$term->term_id?>' data-taxonomy='<?=$term->taxonomy?>' data-operator='<?=$operator?>'>
3
  <span>
4
  <input type='radio' id='radio_<?=$term->term_id?>' name='radio_<?=$term->taxonomy?>_<?=$x?>'
 
5
  <?php
6
  if( $_POST['terms'] ){
7
  foreach( $_POST['terms'] as $p_term ){
1
  <?php foreach( $terms as $term ): ?>
2
+ <li>
3
  <span>
4
  <input type='radio' id='radio_<?=$term->term_id?>' name='radio_<?=$term->taxonomy?>_<?=$x?>'
5
+ data-term_id='<?=$term->term_id?>' data-taxonomy='<?=$term->taxonomy?>' data-operator='<?=$operator?>'
6
  <?php
7
  if( $_POST['terms'] ){
8
  foreach( $_POST['terms'] as $p_term ){
templates/select.php CHANGED
@@ -3,7 +3,7 @@
3
  <select>
4
  <option data-taxonomy='<?=$terms[0]->taxonomy?>' value=''>Any</option>
5
  <?php foreach( $terms as $term ): ?>
6
- <option data-term_id='<?=$term->term_id?>' data-taxonomy='<?=$term->taxonomy?>'
7
  <?php
8
  if( $_POST['terms'] ){
9
  foreach( $_POST['terms'] as $p_term ){
@@ -14,7 +14,7 @@
14
  }
15
  }
16
  ?>
17
- data-operator='<?=$operator?>'><?=$term->name?></option>
18
  <?php endforeach; ?>
19
  </select>
20
  </span>
3
  <select>
4
  <option data-taxonomy='<?=$terms[0]->taxonomy?>' value=''>Any</option>
5
  <?php foreach( $terms as $term ): ?>
6
+ <option data-term_id='<?=$term->term_id?>' data-taxonomy='<?=$term->taxonomy?>' data-operator='<?=$operator?>'
7
  <?php
8
  if( $_POST['terms'] ){
9
  foreach( $_POST['terms'] as $p_term ){
14
  }
15
  }
16
  ?>
17
+ ><?=$term->name?></option>
18
  <?php endforeach; ?>
19
  </select>
20
  </span>
woocommerce-filters.php CHANGED
@@ -3,7 +3,7 @@
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.0.4.2
7
  Author: BeRocket
8
  Author URI: http://berocket.com
9
  */
@@ -35,8 +35,9 @@ class BeRocket_AAPF {
35
  add_action( 'admin_menu', array( __CLASS__, 'br_add_options_page' ) );
36
  add_action( 'admin_init', array( __CLASS__, 'register_br_options' ) );
37
 
38
- if( @ $_GET['filters'] and ! @ defined( 'DOING_AJAX' ) ) {
39
- br_aapf_args_converter();
 
40
  add_filter( 'pre_get_posts', array( __CLASS__, 'apply_user_filters' ) );
41
  }
42
  }
@@ -45,20 +46,37 @@ class BeRocket_AAPF {
45
  add_submenu_page( 'woocommerce', 'Product Filters Settings', 'Product Filters', 'manage_options', 'br-product-filters', array( __CLASS__, 'br_render_form' ) );
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  public static function br_render_form(){
49
  include AAPF_TEMPLATE_PATH . "admin-settings.php";
50
  }
51
 
52
  public static function apply_user_filters( $query ){
53
-
54
- if( $query->is_main_query() and
55
  ( $query->get( 'post_type' ) == 'product' or $query->get( 'product_cat' ) )
56
  or
57
  $query->is_page() && 'page' == get_option( 'show_on_front' ) && $query->get('page_id') == wc_get_page_id('shop')
58
  ){
 
59
  $args = br_aapf_args_parser();
60
 
61
- if( @ $_POST['price'] ){
62
  list( $_GET['min_price'], $_GET['max_price'] ) = $_POST['price'];
63
  add_filter( 'loop_shop_post_in', array( 'WC_QUERY', 'price_filter' ) );
64
  }
@@ -82,7 +100,7 @@ class BeRocket_AAPF {
82
  global $wpdb;
83
 
84
  if ( $_POST['limits'] ) {
85
- $matched_products = array();
86
 
87
  foreach ( $_POST['limits'] as $v ) {
88
  $matched_products_query = $wpdb->get_results( $wpdb->prepare("
@@ -121,7 +139,7 @@ class BeRocket_AAPF {
121
  global $wpdb;
122
 
123
  if ( $_POST['price'] ) {
124
- $matched_products = array();
125
  $min = floatval( $_POST['price'][0] );
126
  $max = floatval( $_POST['price'][1] );
127
 
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.0.4.3
7
  Author: BeRocket
8
  Author URI: http://berocket.com
9
  */
35
  add_action( 'admin_menu', array( __CLASS__, 'br_add_options_page' ) );
36
  add_action( 'admin_init', array( __CLASS__, 'register_br_options' ) );
37
 
38
+ add_shortcode( 'br_filters', array( __CLASS__, 'shortcode' ) );
39
+
40
+ if( @ $_GET['filters'] and ! @ defined( 'DOING_AJAX' ) ) {
41
  add_filter( 'pre_get_posts', array( __CLASS__, 'apply_user_filters' ) );
42
  }
43
  }
46
  add_submenu_page( 'woocommerce', 'Product Filters Settings', 'Product Filters', 'manage_options', 'br-product-filters', array( __CLASS__, 'br_render_form' ) );
47
  }
48
 
49
+ public static function shortcode( $atts = array() ){
50
+ $a = shortcode_atts(
51
+ array(
52
+ 'attribute' => '',
53
+ 'type' => 'checkbox',
54
+ 'operator' => 'OR',
55
+ 'title' => '',
56
+ 'product_cat' => '',
57
+ 'cat_propagation' => '',
58
+ 'height' => 'auto',
59
+ 'scroll_theme' => 'dark',
60
+ ), $atts );
61
+ if ( ! $a['attribute'] || ! $a['type'] ) return false;
62
+
63
+ BeRocket_AAPF_Widget::widget( array(), $a );
64
+ }
65
+
66
  public static function br_render_form(){
67
  include AAPF_TEMPLATE_PATH . "admin-settings.php";
68
  }
69
 
70
  public static function apply_user_filters( $query ){
71
+ if( $query->is_main_query() and
 
72
  ( $query->get( 'post_type' ) == 'product' or $query->get( 'product_cat' ) )
73
  or
74
  $query->is_page() && 'page' == get_option( 'show_on_front' ) && $query->get('page_id') == wc_get_page_id('shop')
75
  ){
76
+ br_aapf_args_converter();
77
  $args = br_aapf_args_parser();
78
 
79
+ if( @ $_POST['price'] ){
80
  list( $_GET['min_price'], $_GET['max_price'] ) = $_POST['price'];
81
  add_filter( 'loop_shop_post_in', array( 'WC_QUERY', 'price_filter' ) );
82
  }
100
  global $wpdb;
101
 
102
  if ( $_POST['limits'] ) {
103
+ $matched_products = array( 0 );
104
 
105
  foreach ( $_POST['limits'] as $v ) {
106
  $matched_products_query = $wpdb->get_results( $wpdb->prepare("
139
  global $wpdb;
140
 
141
  if ( $_POST['price'] ) {
142
+ $matched_products = array( 0 );
143
  $min = floatval( $_POST['price'][0] );
144
  $max = floatval( $_POST['price'][1] );
145