br_aapf_parse_order_by

Br_aapf_parse_order_by - parsing order by data and saving to $args array that was passed into.

Description

br_aapf_parse_order_by( &$args ); 

Parameters (1)

0. $args
The args.

Usage

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

Defined (1)

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

/includes/functions.php  
  1. function br_aapf_parse_order_by( &$args ) { 
  2. $orderby = $_GET['orderby'] = $_POST['orderby']; 
  3. $order = "ASK"; 
  4. if( @ preg_match( "/-/", $orderby ) ) { 
  5. list( $orderby, $order ) = explode( "-", $orderby ); 
  6.  
  7. // needed for woocommerce sorting funtionality 
  8. if( @ $orderby and @ $order ) { 
  9.  
  10. // Get ordering from query string unless defined 
  11. $orderby = strtolower( $orderby ); 
  12. $order = strtoupper( $order ); 
  13.  
  14. // default - menu_order 
  15. $args['orderby'] = 'menu_order title'; 
  16. $args['order'] = $order == 'DESC' ? 'DESC' : 'ASC'; 
  17.  
  18. switch ( $orderby ) { 
  19. case 'rand' : 
  20. $args['orderby'] = 'rand'; 
  21. break; 
  22. case 'date' : 
  23. $args['orderby'] = 'date'; 
  24. $args['order'] = $order == 'ASC' ? 'ASC' : 'DESC'; 
  25. break; 
  26. case 'price' : 
  27. $args['orderby'] = 'meta_value_num'; 
  28. $args['order'] = $order == 'DESC' ? 'DESC' : 'ASC'; 
  29. $args['meta_key'] = '_price'; 
  30. break; 
  31. case 'popularity' : 
  32. $args['meta_key'] = 'total_sales'; 
  33.  
  34. // Sorting handled later though a hook 
  35. add_filter( 'posts_clauses', array( 'BeRocket_AAPF', 'order_by_popularity_post_clauses' ) ); 
  36. break; 
  37. case 'rating' : 
  38. // Sorting handled later though a hook 
  39. add_filter( 'posts_clauses', array( 'BeRocket_AAPF', 'order_by_rating_post_clauses' ) ); 
  40. break; 
  41. case 'title' : 
  42. $args['orderby'] = 'title'; 
  43. $args['order'] = $order == 'DESC' ? 'DESC' : 'ASC'; 
  44. break;