1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155:
<?php
$shortcodes_config['gmap'] = array(
'no_preview' => true,
'options' => array(
'type' => array(
'name' => __('Map Type', 'inbound-pro' ),
'desc' => __('Select a map type', 'inbound-pro' ),
'type' => 'select',
'options' => array('HYBRID' => 'Hybrid', 'ROADMAP' => 'Road Map', 'SATELLITE' => 'Satellite', 'TERRAIN' => 'Terrain'),
'std' => ''
),
'width' => array(
'name' => __('Map Width', 'inbound-pro' ),
'desc' => '',
'type' => 'text',
'std' => ''
),
'height' => array(
'name' => __('Map Height', 'inbound-pro' ),
'desc' => '',
'type' => 'text',
'std' => ''
),
'address' => array(
'name' => __('Address', 'inbound-pro' ),
'desc' => __('Enter your address here. ex: "New York" or "New York, USA" If you want a accurate position please fill the Latitude and Longitude fields', 'inbound-pro' ),
'type' => 'text',
'std' => ''
),
'latitude' => array(
'name' => __('Latitude', 'inbound-pro' ),
'desc' => __('Latitude is specified in degrees within the range [-90, 90]', 'inbound-pro' ),
'type' => 'text',
'std' => ''
),
'longitude' => array(
'name' => __('Longitude', 'inbound-pro' ),
'desc' => __('Longitude is specified in degrees within the range [-180, 180]', 'inbound-pro' ),
'type' => 'text',
'std' => ''
),
'zoom' => array(
'name' => __('Zoom', 'inbound-pro' ),
'desc' => __('Set the zoom level, numeric value from 1 to 19', 'inbound-pro' ),
'type' => 'text',
'std' => '8'
),
'pancontrol' => array(
'name' => __('Pan Control', 'inbound-pro' ),
'desc' => __('Enable pan control?', 'inbound-pro' ),
'type' => 'select',
'options' => array('true' => 'Enable', 'false' => 'Disable'),
'std' => ''
),
'zoomcontrol' => array(
'name' => __('Zoom Control', 'inbound-pro' ),
'desc' => __('Enable zoom control?', 'inbound-pro' ),
'type' => 'select',
'options' => array('true' => 'Enable', 'false' => 'Disable'),
'std' => ''
),
'maptypecontrol' => array(
'name' => __('Map Type Control', 'inbound-pro' ),
'desc' => __('Enable map type control?', 'inbound-pro' ),
'type' => 'select',
'options' => array('true' => 'Enable', 'false' => 'Disable'),
'std' => ''
),
'content' => array(
'name' => __('Popup Content', 'inbound-pro' ),
'desc' => __('A descriptive text for the Google Map marker popup, ex: "My Office"', 'inbound-pro' ),
'type' => 'textarea',
'std' => ''
)
),
'shortcode' => '[gmap type="{{type}}" address="{{address}}" lat="{{latitude}}" lng="{{longitude}}" zoom="{{zoom}}" pancontrol="{{pancontrol}}" zoomcontrol="{{zoomcontrol}}" maptypecontrol="{{maptypecontrol}}" width="{{width}}" height="{{height}}"]{{content}}[/gmap]',
'popup_title' => 'Insert Google Map Shortcode'
);
add_shortcode('gmap', 'inbound_shortcode_gmap');
function inbound_shortcode_gmap( $atts, $content = null ) {
extract(shortcode_atts(array(
'type' => 'ROADMAP',
'address' => '',
'lat' => '',
'lng' => '',
'width' => '',
'height' => 400,
'zoom' => 8,
'scroll' => 'true',
'pancontrol' => 'true',
'zoomcontrol' => 'true',
'maptypecontrol' => 'true'
), $atts));
$out = '';
if ( !$lat == '' && !$lng == '') :
$out .= '<div id="google_map_'.preg_replace('![^a-z0-9]+!i', '', $lat) . preg_replace('![^a-z0-9]+!i', '', $lng) . $type .'" class="google_map" style="width:'.$width.'px;height:'.$height.'px"></div>' . "\n";
$out .= '
<script type="text/javascript">
(function($) {
$("#google_map_'.preg_replace('![^a-z0-9]+!i', '', $lat) . preg_replace('![^a-z0-9]+!i', '', $lng) . $type .'").gMap({
latitude:'.$lat.',
longitude:'.$lng.',
maptype:"'.$type.'",
scrollwheel: '.$scroll.',
zoom:'.$zoom.',
controls: {
panControl:'.$pancontrol.',
zoomControl:'.$zoomcontrol.',
mapTypeControl:'.$maptypecontrol.'
},
markers: [{
latitude:'.$lat.',
longitude:'.$lng.',
html: "'.$content.'"
}]
});
})(jQuery);
</script>';
else :
$out .= '<div id="google_map_'.preg_replace('![^a-z0-9]+!i', '',$address) . $type .'" class="google_map" style="width:'.$width.'px;height:'.$height.'px"></div>' . "\n";
$out .= '
<script type="text/javascript">
(function($) {
$("#google_map_'.preg_replace('![^a-z0-9]+!i', '',$address) . $type .'").gMap({
address:"'.$address.'",
maptype:"'.$type.'",
scrollwheel: '.$scroll.',
zoom:'.$zoom.',
controls: {
panControl:'.$pancontrol.',
zoomControl:'.$zoomcontrol.',
mapTypeControl:'.$maptypecontrol.'
},
markers: [{
address:"'.$address.'",
html: "'.$content.'"
}]
});
})(jQuery);
</script>';
endif;
return $out;
}