vc-map.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*------------------------------------------------------*/
  3. /* taskereasy Map
  4. /*------------------------------------------------------*/
  5. vc_map(array(
  6. "name" => esc_html__("Map", 'taskereasy'),
  7. "base" => "taskereasy_map",
  8. 'icon' => get_template_directory_uri() . '/assets/images/favicon-icon/shortcode-icon.png',
  9. "class" => "",
  10. "description" => esc_html__("Add taskereasy map", 'taskereasy'),
  11. "category" => esc_html__('Taskereasy Shortcodes', 'taskereasy'),
  12. "params" => array(
  13. array(
  14. "type" => "textfield",
  15. "heading" => esc_html__("Latitude", 'taskereasy'),
  16. "param_name" => "latitude",
  17. ),
  18. array(
  19. "type" => "textfield",
  20. "heading" => esc_html__("Longitude", 'taskereasy'),
  21. "param_name" => "longitude",
  22. ),
  23. array(
  24. "type" => "textfield",
  25. "heading" => esc_html__("Zoom", 'taskereasy'),
  26. "param_name" => "zoom",
  27. ),
  28. array(
  29. 'type' => 'css_editor',
  30. 'heading' => esc_html__( 'CSS', 'taskereasy' ),
  31. 'param_name' => 'custom_design',
  32. 'group' => esc_html__( 'Design options', 'taskereasy' ),
  33. )
  34. )
  35. ));
  36. add_shortcode( 'taskereasy_map', function($atts, $content = null) {
  37. extract(shortcode_atts(array(
  38. 'latitude' => '',
  39. 'longitude' => '',
  40. 'zoom' => 14,
  41. 'custom_design' => '',
  42. ), $atts));
  43. $custom_design = vc_shortcode_custom_css_class( $custom_design, ' ' );
  44. $lat = !empty($latitude)?$latitude:'49.274059';
  45. $lon = !empty($longitude)?$longitude:'-123.1410967';
  46. $icon = ( !empty( taskereasy_get_config('map-icon')['url'] ) ) ? taskereasy_get_config('map-icon')['url'] : '';
  47. $output = '';
  48. $map_api = taskereasy_get_config('google-map-api');
  49. if($map_api != ''){
  50. $output .='
  51. <div class="office-location-map">
  52. <iframe src="https://www.google.com/maps/embed/v1/place?q=place_id:ChIJOwg_06VPwokRYv534QaPC8g&key='.$map_api.'" allowfullscreen></iframe>
  53. </div>';
  54. }else{
  55. $output.='You must add an API Key in Theme Options > Google Options first';
  56. }
  57. return $output;
  58. });