Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2015
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. /**
  2. * list of vendors by location
  3. *
  4. * @param $atts shortcode attributs
  5. */
  6. function wc_vendors_location( $atts ) {
  7. $html = '';
  8.  
  9. extract( shortcode_atts( array(
  10. 'orderby' => 'display_name',
  11. 'order' => 'ASC',
  12. 'per_page' => '12',
  13. 'columns' => '4',
  14. 'show_products' => 'yes',
  15. 'location' => '',
  16. 'org' => '',
  17. ), $atts ) );
  18. // Hook into the user query to modify the query to return users that have at least one product
  19. if ($show_products == 'yes') remove_action( 'pre_user_query', array( $this, 'vendors_with_products') );
  20. // Get all vendors
  21. $vendor_total_args = array (
  22. 'role' => 'vendor',
  23. 'meta_key' => 'pv_shop_slug',
  24. 'meta_value' => '',
  25. 'meta_key' => 'location',
  26. 'meta_value' => $location,
  27. 'meta_key' => 'organization',
  28. 'meta_value' => $org,
  29. 'orderby' => $orderby,
  30. 'order' => $order,
  31. );
  32. if ($show_products == 'yes') $vendor_total_args['query_id'] = 'vendors_with_products';
  33. $vendor_query = New WP_User_Query( $vendor_total_args );
  34. $all_vendors =$vendor_query->get_results();
  35.  
  36. ob_start();
  37. // Loop through all vendors and output a simple link to their vendor pages
  38. foreach ($all_vendors as $vendor) {
  39. wc_get_template( 'vendor-list.php', array(
  40. 'shop_link' => WCV_Vendors::get_vendor_shop_page($vendor->ID),
  41. 'shop_name' => $vendor->pv_shop_name,
  42. 'vendor_id' => $vendor->ID,
  43. 'shop_description' => $vendor->pv_shop_description,
  44. ), 'wc-vendors/front/', wcv_plugin_dir . 'templates/front/' );
  45. } // End foreach
  46.  
  47. $html .= '<ul class="wcv_vendorslist">' . ob_get_clean() . '</ul>';
  48. return $html;
  49. }
  50. add_shortcode('wc_vendors_location', 'wc_vendors_location');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement