Advertisement
Guest User

cartpress

a guest
May 8th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1. function request( $query ) {
  2. if ( ! is_admin() ) {
  3. $wp_query = new WP_Query();
  4. $wp_query->parse_query( $query );
  5. $apply_filters = false;
  6. if ( $wp_query->is_home() || isset( $wp_query->tax_query ) || $wp_query->is_archive() ) {
  7. if ( $wp_query->is_home() ) {
  8. global $thecartpress;
  9. $activate_frontpage = $thecartpress->get_setting( 'activate_frontpage' );
  10. if ( ! $activate_frontpage ) return $query;
  11. $apply_filters = true;
  12. $taxonomy_term = $thecartpress->get_setting( 'taxonomy_term', '' );
  13. if ( strlen( $taxonomy_term ) > 0 ) {
  14. $taxonomy_term = explode( ':', $taxonomy_term );
  15. $query[$taxonomy_term[0]] = $taxonomy_term[1];
  16. }
  17. }
  18. if ( isset( $wp_query->tax_query ) ) {
  19. foreach ( $wp_query->tax_query->queries as $tax_query ) { //@See Query.php: 1530
  20. if ( tcp_is_saleable_taxonomy( $tax_query['taxonomy'] ) ) {
  21. $apply_filters = true;
  22. break;
  23. }
  24. }
  25. }
  26. if ( $wp_query->is_archive() && isset( $wp_query->query_vars['post_type'] ) ) { //&& tcp_is_saleable_post_type( $wp_query->query_vars['post_type'] ) ) {
  27. $apply_filters = true;
  28. }
  29. }
  30. if ( $apply_filters || isset( $wp_query->query_vars['post_type'] ) && tcp_is_saleable_post_type( $wp_query->query_vars['post_type'] ) ) {
  31. $query['meta_query'][] = array(
  32. 'key' => 'tcp_is_visible',
  33. 'value' => 1,
  34. 'compare' => '='
  35. );
  36. }
  37. $filter = new TCPFilterNavigation();
  38. if ( $apply_filters ) {
  39. //if ( isset( $wp_query->query_vars['post_type'] ) && tcp_is_saleable_post_type( $wp_query->query_vars['post_type'] ) ) {
  40. $query['posts_per_page'] = (int)$this->get_setting( 'products_per_page', 10 );
  41. if ( $filter->is_filter_by_layered() ) {
  42. $layered = $filter->get_layered();
  43. foreach( $layered as $tax => $layers ) {
  44. $query[$tax] = '';
  45. foreach( $layers as $layer ) {
  46. $query[$tax] .= $layer . ',';
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement