Guest User

Untitled

a guest
Jun 22nd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. add_shortcode('publish_party', 'party_contact_suppliers');
  2.  
  3. function party_contact_suppliers(){
  4. $alerts = new WP_Query (array (
  5. 'post_type' => 'alert',
  6. 'post_status' => 'publish'));
  7. $address_cache = get_option( 'toolset_maps_address_coordinates' );
  8.  
  9. // Ballito
  10. $home_lat = -29.4872902;
  11. $home_lon = 31.1613188;
  12. echo '<h3>Ballito</h3>';
  13. echo '<ol>';
  14. while($alerts->have_posts()) {
  15. $alerts->the_post();
  16. $id = get_the_ID();
  17. $author = get_the_author();
  18. $author_id = get_the_author_id();
  19. $emailaddress = the_author_meta('user_email',$author_id);
  20. $center_location = get_post_meta($id,'wpcf-center-location',true);
  21. $radius = get_post_meta($id,'wpcf-radius',true);
  22. $lat = 0;
  23. $lon = 0;
  24. foreach ($address_cache as $key => $value) {
  25. if ( $value['address_passed'] == $center_location ) {
  26. $lat = $value['lat'];
  27. $lon = $value['lon'];
  28. break;
  29. }
  30. }
  31. $distance = distance($lat,$lon,$home_lat,$home_lon);
  32. echo '<li>';
  33. echo '<p>Alert Post ID: '.$id.' Author Name:'.$author.' Author ID: '.$author_id.' Email Address: '.$emailaddress.'</p>';
  34. echo '<p>Author location: '.$center_location.' Lat: '.$lat.' Long: '.$lon.' Distance: '.$distance.'Kms</p>';
  35. if ($distance <= $radius) {
  36. echo '<p style="color:green">Distance is within radius of '.$radius.' Kms. Send email to '.$emailaddress.'</p>';
  37. }
  38. else { echo '<p style="color:red">Distance is not within radius of '.$radius.' Kms.</p>';}
  39. echo '</li>';
  40. }
  41. echo '</ol>';
  42. wp_reset_postdata();
  43. }
Add Comment
Please, Sign In to add comment