br_aapf_args_converter

Convert args-url to normal filters.

Description

br_aapf_args_converter(); 

Usage

  1. if ( !function_exists( 'br_aapf_args_converter' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'advanced-ajax-product-filters-for-woocommerce/includes/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = br_aapf_args_converter(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/functions.php  
  1. function br_aapf_args_converter() { 
  2. if ( preg_match( "~\|~", $_GET['filters'] ) ) { 
  3. $filters = explode( "|", $_GET['filters'] ); 
  4. } else { 
  5. $filters[0] = $_GET['filters']; 
  6.  
  7. foreach ( $filters as $filter ) { 
  8.  
  9. if ( preg_match( "~\[~", $filter ) ) { 
  10. list( $attribute, $value ) = explode( "[", trim( preg_replace( "~\]~", "", $filter) ), 2 ); 
  11. if ( preg_match( "~\-~", $value ) ) { 
  12. $value = explode( "-", $value ); 
  13. $operator = 'OR'; 
  14. } elseif ( preg_match( "~\_~", $value ) ) { 
  15. list( $min, $max ) = explode( "_", $value ); 
  16. $operator = ''; 
  17. } else { 
  18. $value = explode( " ", $value ); 
  19. $operator = 'AND'; 
  20. }else{ 
  21. list( $attribute, $value ) = explode( "-", $filter, 2 ); 
  22.  
  23. if ( $attribute == 'price' ) { 
  24. $_POST['price'] = array( $min, $max ); 
  25. } elseif ( $attribute == 'order' ) { 
  26. $_GET['orderby'] = $value; 
  27. } else { 
  28. if ( $operator ) { 
  29. foreach ( $value as $v ) { 
  30. $_POST['terms'][] = array( "pa_" . $attribute, $v, $operator ); 
  31. } else { 
  32. $_POST['limits'][] = array( "pa_" . $attribute, $min, $max );