'google-maps-widget', 'description' => __('Displays a map image thumbnail with a larger map available in a lightbox.', 'google-maps-widget')); $control_ops = array('width' => 450, 'height' => 350); parent::__construct('GoogleMapsWidget', __('Google Maps Widget', 'google-maps-widget'), $widget_ops, $control_ops); } // GoogleMapsWidget // widget edit form HTML function form($instance) { $instance = wp_parse_args((array) $instance, array('title' => __('Map', 'google-maps-widget'), 'address' => __('New York, USA', 'google-maps-widget'), 'thumb_pin_color' => 'red', 'thumb_pin_type' => 'predefined', 'thumb_pin_size' => 'default', 'thumb_pin_img' => '', 'thumb_width' => '250', 'thumb_height' => '250', 'thumb_type' => 'roadmap', 'thumb_zoom' => '13', 'thumb_header' => '', 'thumb_footer' => 'Powered by Google Maps Widget', 'thumb_color_scheme' => '', 'thumb_link_type' => 'lightbox', 'thumb_link' => '', 'lightbox_width' => '550', 'lightbox_height' => '550', 'lightbox_type' => 'roadmap', 'lightbox_zoom' => '14', 'lightbox_bubble' => '1', 'lightbox_skin' => 'light', 'lightbox_title' => '1', 'lightbox_header' => '', 'lightbox_footer' => '')); extract($instance, EXTR_SKIP); // legacy fixes for older versions; it's auto-fixed on first widget save but has to be here if(!$thumb_pin_type) { $thumb_pin_type = 'predefined'; } if(!$thumb_link_type) { $thumb_link_type = 'lightbox'; } if(!$lightbox_skin) { $lightbox_skin = 'light'; } $map_types_thumb = array(array('val' => 'roadmap', 'label' => __('Road (default)', 'google-maps-widget')), array('val' => 'satellite', 'label' => __('Satellite', 'google-maps-widget')), array('val' => 'terrain', 'label' => __('Terrain', 'google-maps-widget')), array('val' => 'hybrid', 'label' => __('Hybrid', 'google-maps-widget'))); $map_types_lightbox = array(array('val' => 'm', 'label' => __('Road (default)', 'google-maps-widget')), array('val' => 'k', 'label' => __('Satellite', 'google-maps-widget')), array('val' => 'p', 'label' => __('Terrain', 'google-maps-widget')), array('val' => 'h', 'label' => __('Hybrid', 'google-maps-widget'))); $pin_colors = array(array('val' => 'black', 'label' => __('Black', 'google-maps-widget')), array('val' => 'brown', 'label' => __('Brown', 'google-maps-widget')), array('val' => 'green', 'label' => __('Green', 'google-maps-widget')), array('val' => 'purple', 'label' => __('Purple', 'google-maps-widget')), array('val' => 'yellow', 'label' => __('Yellow', 'google-maps-widget')), array('val' => 'blue', 'label' => __('Blue', 'google-maps-widget')), array('val' => 'gray', 'label' => __('Gray', 'google-maps-widget')), array('val' => 'orange', 'label' => __('Orange', 'google-maps-widget')), array('val' => 'red', 'label' => __('Red (default)', 'google-maps-widget')), array('val' => 'white', 'label' => __('White', 'google-maps-widget'))); $pin_sizes = array(array('val' => 'tiny', 'label' => __('Tiny', 'google-maps-widget')), array('val' => 'small', 'label' => __('Small', 'google-maps-widget')), array('val' => 'mid', 'label' => __('Medium', 'google-maps-widget')), array('val' => 'default', 'label' => __('Large (default)', 'google-maps-widget'))); $zoom_levels = array(array('val' => '0', 'label' => __('0 - entire world', 'google-maps-widget'))); for ($tmp = 1; $tmp <= 21; $tmp++) { $zoom_levels[] = array('val' => $tmp, 'label' => $tmp); } $lightbox_skins = array(array('val' => 'light', 'label' => __('Light (default)', 'google-maps-widget')), array('val' => 'dark', 'label' => __('Dark', 'google-maps-widget'))); $lightbox_bubbles = array(array('val' => '0', 'label' => __('Hide', 'google-maps-widget')), array('val' => '1', 'label' => __('Show (default)', 'google-maps-widget'))); $lightbox_titles = array(array('val' => '0', 'label' => __('Do not show map title on lightbox', 'google-maps-widget')), array('val' => '1', 'label' => __('Show map title on lightbox (default)', 'google-maps-widget'))); $thumb_pin_types = array(array('val' => 'predefined', 'label' => __('Predefined (default)', 'google-maps-widget')), array('val' => 'custom', 'label' => __('Custom', 'google-maps-widget'))); $thumb_link_types = array(array('val' => 'lightbox', 'label' => __('Lightbox (default)', 'google-maps-widget')), array('val' => 'custom', 'label' => __('Custom URL', 'google-maps-widget')), array('val' => 'nolink', 'label' => __('Disable link', 'google-maps-widget'))); $thumb_color_schemes = array(array('val' => 'default', 'label' => __('Default', 'gmw')), array('val' => 'new', 'label' => __('Refreshed by Google', 'gmw'))); if (GMW::is_activated()) { array_push($thumb_color_schemes, array('val' => 'apple', 'label' => __('Apple', 'google-maps-widget')), array('val' => 'gray', 'label' => __('Gray', 'google-maps-widget')), array('val' => 'paper', 'label' => __('Paper', 'google-maps-widget'))); array_push($lightbox_skins, array('val' => 'noimage-blue', 'label' => __('Blue', 'google-maps-widget')), array('val' => 'noimage-rounded', 'label' => __('Rounded', 'google-maps-widget'))); } echo '
'; echo ''; echo ''; echo ' x '; echo ''; echo ' px
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo ' x '; echo ''; echo ' px
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo '' . __('Please save the widget so that the shortcode can be generated.', 'google-maps-widget') . '
'; } else { echo '[gmw id="' . $id . '"]
' . __('Use the above shortcode to display this Google Maps Widget instance in any page or post.
Please note that your theme might style the widget in the post as if it is placed in a sidebar. In that case use the span.gmw-shortcode-widget class to target the shortcode and make necessary changes via CSS.', 'google-maps-widget') . '
Shortcode support is an extra feature. You can activate it for free and get more features & options for free as well.
Activate extra features
If you have any problems, questions or would like a new feature added post it on the official support forum. It\'s the only place to get support. Since it\'s free and community powered please be patient. Premium support is available for $19.
'; echo '' . __('If you subscribe to our mailing list we\'ll instantly activate additional features in the plugin! At the moment those features are: shortcode support, 3 additional thumbnail map skins and 2 additional lightbox skins. More activate by subscribing features will be available soon!', 'google-maps-widget') . '
';
if (GMW::is_activated()) {
echo __('You\'ve already subscribed and activated extra features. Thank you!', 'google-maps-widget');
} else {
echo __('Subscribe and activate extra features.', 'google-maps-widget');
}
echo '
It won\'t take you more than a minute but it will help us immensely. So please - rate the plugin. Or spread the word by tweeting about it. Thank you!
'; echo '' . __('Click to get extra premium features for Google Maps Widget! For FREE.', 'google-maps-widget') . '
'; } } // form // update/save widget options function update($new_instance, $old_instance) { $instance = $old_instance; $instance['title'] = $new_instance['title']; $instance['address'] = $new_instance['address']; $instance['thumb_pin_type'] = $new_instance['thumb_pin_type']; $instance['thumb_pin_color'] = $new_instance['thumb_pin_color']; $instance['thumb_pin_size'] = $new_instance['thumb_pin_size']; $instance['thumb_pin_img'] = trim($new_instance['thumb_pin_img']); $instance['thumb_width'] = (int) $new_instance['thumb_width']; $instance['thumb_height'] = (int) $new_instance['thumb_height']; $instance['thumb_zoom'] = $new_instance['thumb_zoom']; $instance['thumb_type'] = $new_instance['thumb_type']; $instance['thumb_link_type'] = $new_instance['thumb_link_type']; $instance['thumb_link'] = trim($new_instance['thumb_link']); $instance['thumb_header'] = trim($new_instance['thumb_header']); $instance['thumb_footer'] = trim($new_instance['thumb_footer']); $instance['thumb_color_scheme'] = $new_instance['thumb_color_scheme']; $instance['lightbox_width'] = (int) $new_instance['lightbox_width']; $instance['lightbox_height'] = (int) $new_instance['lightbox_height']; $instance['lightbox_type'] = $new_instance['lightbox_type']; $instance['lightbox_zoom'] = $new_instance['lightbox_zoom']; $instance['lightbox_bubble'] = $new_instance['lightbox_bubble']; $instance['lightbox_title'] = $new_instance['lightbox_title']; $instance['lightbox_header'] = trim($new_instance['lightbox_header']); $instance['lightbox_footer'] = trim($new_instance['lightbox_footer']); $instance['lightbox_skin'] = $new_instance['lightbox_skin']; $instance['core_ver'] = GMW::$version; return $instance; } // update // echo widget function widget($args, $instance) { $out = $tmp = ''; $thumb_styles = array( 'apple' => 'style=feature:water|element:geometry|color:0xa2daf2|&style=feature:landscape.man_made|element:geometry|color:0xf7f1df|&style=feature:landscape.natural|element:geometry|color:0xd0e3b4|&style=feature:landscape.natural.terrain|element:geometry|visibility:off|&style=feature:poi.park|element:geometry|color:0xbde6ab|&style=feature:poi|element:labels|visibility:off|&style=feature:poi.medical|element:geometry|color:0xfbd3da|&style=feature:poi.business|element:all|visibility:off|&style=feature:road|element:geometry.stroke|visibility:off|&style=feature:road|element:labels|visibility:off|&style=feature:road.highway|element:geometry.fill|color:0xffe15f|&style=feature:road.highway|element:geometry.stroke|color:0xefd151|&style=feature:road.arterial|element:geometry.fill|color:0xffffff|&style=feature:road.local|element:geometry.fill|color:black|&style=feature:transit.station.airport|element:geometry.fill|color:0xcfb2db|', 'gray' => 'style=feature:landscape|element:all|saturation:-100|lightness:65|visibility:on|&style=feature:poi|element:all|saturation:-100|lightness:51|visibility:simplified|&style=feature:road.highway|element:all|saturation:-100|visibility:simplified|&style=feature:road.arterial|element:all|saturation:-100|lightness:30|visibility:on|&style=feature:road.local|element:all|saturation:-100|lightness:40|visibility:on|&style=feature:transit|element:all|saturation:-100|visibility:simplified|&style=feature:administrative.province|element:all|visibility:off|&style=feature:water|element:labels|visibility:on|lightness:-25|saturation:-100|&style=feature:water|element:geometry|hue:0xffff00|lightness:-25|saturation:-97|', 'paper' => 'style=feature:landscape|element:all|hue:0xF1FF00|saturation:-27.4|lightness:9.4|gamma:1|&style=feature:road.highway|element:all|hue:0x0099FF|saturation:-20|lightness:36.4|gamma:1|&style=feature:road.arterial|element:all|hue:0x00FF4F|saturation:0|lightness:0|gamma:1|&style=feature:road.local|element:all|hue:0xFFB300|saturation:-38|lightness:11.2|gamma:1|&style=feature:water|element:all|hue:0x00B6FF|saturation:4.2|lightness:-63.4|gamma:1|&style=feature:poi|element:all|hue:0x9FFF00|saturation:0|lightness:0|gamma:1|'); extract($args, EXTR_SKIP); $ll = ''; if ($instance['lightbox_zoom'] > 14) { $coordinates = GMW::get_coordinates($instance['address']); if ($coordinates) { $ll = $coordinates['lat'] . ',' . $coordinates['lng']; } } $lang = substr(@$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); if (!$lang) { $lang = 'en'; } // legacy fix for older versions; it's auto-fixed on first widget save but has to be here if(!$instance['lightbox_skin']) { $instance['lightbox_skin'] = 'light'; } self::$widgets[] = array('title' => ($instance['lightbox_title']? $instance['title']: ''), 'width' => $instance['lightbox_width'], 'height' => $instance['lightbox_height'], 'footer' => $instance['lightbox_footer'], 'header' => $instance['lightbox_header'], 'address' => $instance['address'], 'zoom' => $instance['lightbox_zoom'], 'type' => $instance['lightbox_type'], 'skin' => $instance['lightbox_skin'], 'bubble' => $instance['lightbox_bubble'], 'll' => $ll, 'id' => $widget_id); $out .= $before_widget; if (!isset($instance['thumb_pin_type']) || empty($instance['thumb_pin_type'])) { $instance['thumb_pin_type'] = 'predefined'; } if (!isset($instance['thumb_link_type']) || empty($instance['thumb_link_type'])) { $instance['thumb_link_type'] = 'lightbox'; } $title = empty($instance['title'])? ' ' : apply_filters('widget_title', $instance['title']); if (!empty($title)) { $out .= $before_title . $title . $after_title; } if (isset($instance['thumb_header']) && $instance['thumb_header']) { $tmp .= wpautop(do_shortcode($instance['thumb_header'])); } $tmp .= '';
if ($instance['thumb_link_type'] == 'lightbox') {
$alt = __('Click to open larger map', 'google-maps-widget');
} else {
$alt = esc_attr($instance['address']);
}
if ($instance['thumb_link_type'] == 'lightbox') {
$tmp .= '';
} elseif ($instance['thumb_link_type'] == 'custom') {
$tmp .= '';
}
$tmp .= '';
if ($instance['thumb_link_type'] == 'lightbox' || $instance['thumb_link_type'] == 'custom') {
$tmp .= '';
}
$tmp .= '