| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 4 |
|
| 5 |
$css = ''; |
| 6 |
|
| 7 |
extract(shortcode_atts(array( |
| 8 |
'map_link_type' => '_blank', |
| 9 |
"css" => "", |
| 10 |
"font_container" => "", |
| 11 |
), $atts)); |
| 12 |
|
| 13 |
global $property; |
| 14 |
|
| 15 |
if ( !isset($property->id) ) { |
| 16 |
return; |
| 17 |
} |
| 18 |
|
| 19 |
if ( $property->latitude == '' || $property->longitude == '' || $property->latitude == '0' || $property->longitude == '0' ) |
| 20 |
{ |
| 21 |
return; |
| 22 |
} |
| 23 |
|
| 24 |
$css_class = apply_filters( VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, vc_shortcode_custom_css_class( $css, ' ' ), $this->settings['base'], $atts ); |
| 25 |
|
| 26 |
$style = ''; |
| 27 |
if ( ! empty( $atts['font_container'] ) && isset($atts['font_container']) ) |
| 28 |
{ |
| 29 |
$style = ph_extract_font_style_from_salient_font_container( $font_container ); |
| 30 |
} |
| 31 |
|
| 32 |
echo '<div class="' . esc_attr( $css_class ) . '" ' . $style . '>'; |
| 33 |
|
| 34 |
$link_type = ( isset($atts['map_link_type']) && !empty($atts['map_link_type']) ) ? $atts['map_link_type'] : '_blank'; |
| 35 |
|
| 36 |
switch ($link_type) |
| 37 |
{ |
| 38 |
case "_blank": |
| 39 |
{ |
| 40 |
echo '<a href="https://www.google.com/maps/?q=' . (float)$property->latitude . ',' . (float)$property->longitude . '&ll=' . (float)$property->latitude . ',' . (float)$property->longitude . '" target="_blank">' . esc_html(__( 'View Map', 'propertyhive' )) . '</a>'; |
| 41 |
break; |
| 42 |
} |
| 43 |
case "embedded": |
| 44 |
{ |
| 45 |
echo '<a href="#map_lightbox" data-fancybox>' . __( 'View Map', 'propertyhive' ) . '</a>'; |
| 46 |
|
| 47 |
echo '<div id="map_lightbox" style="display:none; width:90%; max-width:800px;">'; |
| 48 |
echo do_shortcode('[property_map]'); |
| 49 |
echo '</div>'; |
| 50 |
break; |
| 51 |
} |
| 52 |
case "iframe": |
| 53 |
{ |
| 54 |
echo '<a |
| 55 |
href="#" |
| 56 |
data-fancybox |
| 57 |
data-type="iframe" |
| 58 |
data-src="https://maps.google.com/?output=embed&f=q&q=' . (float)$property->latitude . ',' . (float)$property->longitude . '&ll=' . (float)$property->latitude . ',' . (float)$property->longitude . '&layer=t&hq=&t=m&z=15" |
| 59 |
>' . esc_html(__( 'View Map', 'propertyhive' )) . '</a>'; |
| 60 |
break; |
| 61 |
} |
| 62 |
} |
| 63 |
|
| 64 |
echo '</div>'; |