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 .= '<p>';
     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 .= '<a class="gmw-thumbnail-map gmw-lightbox-enabled" href="#gmw-dialog-' . $widget_id . '" title="' . __('Click to open larger map', 'google-maps-widget') . '">';
     } elseif ($instance['thumb_link_type'] == 'custom') {
         $tmp .= '<a class="gmw-thumbnail-map" title="' . esc_attr($instance['address']) . '" href="' . $instance['thumb_link'] . '">';
     }
     $tmp .= '<img alt="' . $alt . '" title="' . $alt . '" src="//maps.googleapis.com/maps/api/staticmap?center=' . urlencode($instance['address']) . '&amp;zoom=' . $instance['thumb_zoom'] . '&amp;size=' . $instance['thumb_width'] . 'x' . $instance['thumb_height'] . '&amp;maptype=' . $instance['thumb_type'] . '&amp;scale=1&amp;';
     if ($instance['thumb_pin_type'] != 'custom') {
         $tmp .= 'markers=size:' . $instance['thumb_pin_size'] . '%7Ccolor:' . $instance['thumb_pin_color'];
     } else {
         $tmp .= 'markers=icon:' . urlencode($instance['thumb_pin_img']);
     }
     $tmp .= '%7Clabel:A%7C' . urlencode($instance['address']) . '&amp;language=' . $lang;
     if (!isset($instance['thumb_color_scheme']) || $instance['thumb_color_scheme'] == 'default') {
         $tmp .= '&amp;visual_refresh=false';
     } elseif ($instance['thumb_color_scheme'] == 'new') {
         $tmp .= '&amp;visual_refresh=true';
     } elseif (GMW::is_activated()) {
         $tmp .= '&amp;' . str_replace('&', '&amp;', $thumb_styles[$instance['thumb_color_scheme']]);
     }
     $tmp .= '">';
     if ($instance['thumb_link_type'] == 'lightbox' || $instance['thumb_link_type'] == 'custom') {
         $tmp .= '</a>';
     }
     $tmp .= '</p>';
     if (isset($instance['thumb_footer']) && $instance['thumb_footer']) {
         if ($instance['thumb_footer'] == 'Powered by Google Maps Widget') {
             $tmp .= '<span class="gmw-powered-by">Powered by <a title="Powered by free Google Maps Widget plugin for WordPress" href="http://www.googlemapswidget.com" target="_blank">Google Maps Widget</a></span>';
         } else {
             $tmp .= wpautop(do_shortcode($instance['thumb_footer']));
         }
     }
     $out .= apply_filters('google_maps_widget_content', $tmp);
     $out .= $after_widget;
     echo $out;
 }
Exemple #2
0
 function form($instance)
 {
     $instance = wp_parse_args((array) $instance, array('title' => 'Map', 'address' => 'New York, USA', 'thumb_pin_color' => 'red', 'thumb_pin_size' => 'default', 'thumb_width' => 250, 'thumb_height' => 250, 'thumb_type' => 'roadmap', 'thumb_zoom' => '13', 'lightbox_width' => 550, 'lightbox_height' => 550, 'lightbox_type' => 'roadmap', 'lightbox_zoom' => '14', 'lightbox_bubble' => '1', 'lightbox_skin' => '', 'lightbox_title' => '1', 'lightbox_header' => '', 'lightbox_footer' => ''));
     $title = $instance['title'];
     $lightbox_footer = $instance['lightbox_footer'];
     $lightbox_header = $instance['lightbox_header'];
     $address = $instance['address'];
     $thumb_pin_color = $instance['thumb_pin_color'];
     $thumb_pin_size = $instance['thumb_pin_size'];
     $thumb_width = $instance['thumb_width'];
     $thumb_height = $instance['thumb_height'];
     $thumb_type = $instance['thumb_type'];
     $thumb_zoom = $instance['thumb_zoom'];
     $lightbox_width = $instance['lightbox_width'];
     $lightbox_height = $instance['lightbox_height'];
     $lightbox_type = $instance['lightbox_type'];
     $lightbox_zoom = $instance['lightbox_zoom'];
     $lightbox_bubble = $instance['lightbox_bubble'];
     $lightbox_title = $instance['lightbox_title'];
     $lightbox_skin = $instance['lightbox_skin'];
     $map_types_thumb = array(array('val' => 'roadmap', 'label' => 'Road'), array('val' => 'satellite', 'label' => 'Satellite'), array('val' => 'terrain', 'label' => 'Terrain'), array('val' => 'hybrid', 'label' => 'Hybrid'));
     $map_types_lightbox = array(array('val' => 'm', 'label' => 'Road'), array('val' => 'k', 'label' => 'Satellite'), array('val' => 'p', 'label' => 'Terrain'), array('val' => 'h', 'label' => 'Hybrid'));
     $pin_colors = array(array('val' => 'black', 'label' => 'Black'), array('val' => 'brown', 'label' => 'Brown'), array('val' => 'green', 'label' => 'Green'), array('val' => 'purple', 'label' => 'Purple'), array('val' => 'yellow', 'label' => 'Yellow'), array('val' => 'blue', 'label' => 'Blue'), array('val' => 'gray', 'label' => 'Gray'), array('val' => 'orange', 'label' => 'Orange'), array('val' => 'red', 'label' => 'Red'), array('val' => 'white', 'label' => 'White'));
     $pin_sizes = array(array('val' => 'tiny', 'label' => 'Tiny'), array('val' => 'small', 'label' => 'Small'), array('val' => 'mid', 'label' => 'Medium'), array('val' => 'default', 'label' => 'Large (default)'));
     $zoom_levels = array(array('val' => '0', 'label' => '0 - entire world'));
     for ($tmp = 1; $tmp <= 20; $tmp++) {
         $zoom_levels[] = array('val' => $tmp, 'label' => $tmp);
     }
     $zoom_levels[] = array('val' => '21', 'label' => '21 - street view');
     $lightbox_skins[] = array('val' => '', 'label' => 'White with rounded corners (default)');
     $lightbox_skins[] = array('val' => 'black-rounded', 'label' => 'Black with rounded corners');
     $lightbox_skins[] = array('val' => 'white-square', 'label' => 'White with square corners');
     $lightbox_skins[] = array('val' => 'black-square', 'label' => 'Black with square corners');
     echo '<p><label for="' . $this->get_field_id('title') . '">Title:</label><input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . esc_attr($title) . '" /></p>';
     echo '<p><label for="' . $this->get_field_id('address') . '">Address:</label><input class="widefat" id="' . $this->get_field_id('address') . '" name="' . $this->get_field_name('address') . '" type="text" value="' . esc_attr($address) . '" /></p>';
     echo '<div class="gmw-tabs" id="tab-' . $this->id . '"><ul><li><a href="#gmw-thumb">Thumbnail map</a></li><li><a href="#gmw-lightbox">Lightbox map</a></li></ul>';
     echo '<div id="gmw-thumb">';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_width') . '">Map Size: </label>';
     echo '<input class="small-text" id="' . $this->get_field_id('thumb_width') . '" name="' . $this->get_field_name('thumb_width') . '" type="text" value="' . esc_attr($thumb_width) . '" /> x ';
     echo '<input class="small-text" id="' . $this->get_field_id('thumb_height') . '" name="' . $this->get_field_name('thumb_height') . '" type="text" value="' . esc_attr($thumb_height) . '" />';
     echo ' px</p>';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_type') . '">Map Type: </label>';
     echo '<select id="' . $this->get_field_id('thumb_type') . '" name="' . $this->get_field_name('thumb_type') . '">';
     GMW::create_select_options($map_types_thumb, $thumb_type);
     echo '</select></p>';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_pin_color') . '">Pin Color: </label>';
     echo '<select id="' . $this->get_field_id('thumb_pin_color') . '" name="' . $this->get_field_name('thumb_pin_color') . '">';
     GMW::create_select_options($pin_colors, $thumb_pin_color);
     echo '</select></p>';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_pin_size') . '">Pin Size: </label>';
     echo '<select id="' . $this->get_field_id('thumb_pin_size') . '" name="' . $this->get_field_name('thumb_pin_size') . '">';
     GMW::create_select_options($pin_sizes, $thumb_pin_size);
     echo '</select></p>';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_zoom') . '">Zoom Level: </label>';
     echo '<select id="' . $this->get_field_id('thumb_zoom') . '" name="' . $this->get_field_name('thumb_zoom') . '">';
     GMW::create_select_options($zoom_levels, $thumb_zoom);
     echo '</select></p>';
     echo '</div>';
     // thumbnail tab
     echo '<div id="gmw-lightbox">';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('lightbox_width') . '">Map Size: </label>';
     echo '<input class="small-text" id="' . $this->get_field_id('lightbox_width') . '" name="' . $this->get_field_name('lightbox_width') . '" type="text" value="' . esc_attr($lightbox_width) . '" /> x ';
     echo '<input class="small-text" id="' . $this->get_field_id('lightbox_height') . '" name="' . $this->get_field_name('lightbox_height') . '" type="text" value="' . esc_attr($lightbox_height) . '" />';
     echo ' px</p>';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('lightbox_type') . '">Map Type: </label>';
     echo '<select id="' . $this->get_field_id('lightbox_type') . '" name="' . $this->get_field_name('lightbox_type') . '">';
     GMW::create_select_options($map_types_lightbox, $lightbox_type);
     echo '</select></p>';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('lightbox_zoom') . '">Zoom Level: </label>';
     echo '<select id="' . $this->get_field_id('lightbox_zoom') . '" name="' . $this->get_field_name('lightbox_zoom') . '">';
     GMW::create_select_options($zoom_levels, $lightbox_zoom);
     echo '</select></p>';
     echo '<p><label class="gmw-label" for="' . $this->get_field_id('lightbox_skin') . '">Skin: </label>';
     echo '<select id="' . $this->get_field_id('lightbox_skin') . '" name="' . $this->get_field_name('lightbox_skin') . '">';
     GMW::create_select_options($lightbox_skins, $lightbox_skin);
     echo '</select></p>';
     echo '<p><label for="' . $this->get_field_id('lightbox_bubble') . '">Show Address Bubble: &nbsp;</label>';
     echo '<input ' . checked('1', $lightbox_bubble, false) . ' value="1" type="checkbox" id="' . $this->get_field_id('lightbox_bubble') . '" name="' . $this->get_field_name('lightbox_bubble') . '">';
     echo '</p>';
     echo '<p><label for="' . $this->get_field_id('lightbox_title') . '">Show Title Below Lightbox: &nbsp;</label>';
     echo '<input ' . checked('1', $lightbox_title, false) . ' value="1" type="checkbox" id="' . $this->get_field_id('lightbox_title') . '" name="' . $this->get_field_name('lightbox_title') . '">';
     echo '</p>';
     echo '<p><label for="' . $this->get_field_id('lightbox_header') . '">Header Text:</label>';
     echo '<textarea class="widefat" rows="3" cols="20" id="' . $this->get_field_id('lightbox_header') . '" name="' . $this->get_field_name('lightbox_header') . '">' . $lightbox_header . '</textarea></p>';
     echo '<p><label for="' . $this->get_field_id('lightbox_footer') . '">Footer Text:</label>';
     echo '<textarea class="widefat" rows="3" cols="20" id="' . $this->get_field_id('lightbox_footer') . '" name="' . $this->get_field_name('lightbox_footer') . '">' . $lightbox_footer . '</textarea></p>';
     echo '</div>';
     // lightbox tab
     echo '</div>';
     // tabs
     echo '<p><i>If you like the plugin give us a shout <a title="WebFactory on Twitter" target="_blank" href="http://twitter.com/WebFactoryLtd">@WebFactoryLtd</a>. Thanks!</i></p>';
 }
 function widget($args, $instance)
 {
     $out = $tmp = '';
     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';
     }
     if (isset($instance['thumb_new_colors']) && $instance['thumb_new_colors']) {
         $instance['thumb_new_colors'] = 'true';
     } else {
         $instance['thumb_new_colors'] = 'false';
     }
     $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 .= '<p>';
     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 .= '<a class="gmw-thumbnail-map gmw-lightbox-enabled" href="#gmw-dialog-' . $widget_id . '" title="' . __('Click to open larger map', 'google-maps-widget') . '">';
     } elseif ($instance['thumb_link_type'] == 'custom') {
         $tmp .= '<a class="gmw-thumbnail-map" title="' . esc_attr($instance['address']) . '" href="' . $instance['thumb_link'] . '">';
     }
     $tmp .= '<img alt="' . $alt . '" title="' . $alt . '" src="//maps.googleapis.com/maps/api/staticmap?center=' . urlencode($instance['address']) . '&amp;zoom=' . $instance['thumb_zoom'] . '&amp;size=' . $instance['thumb_width'] . 'x' . $instance['thumb_height'] . '&amp;maptype=' . $instance['thumb_type'] . '&amp;sensor=false&amp;scale=1&amp;';
     if ($instance['thumb_pin_type'] != 'custom') {
         $tmp .= 'markers=size:' . $instance['thumb_pin_size'] . '%7Ccolor:' . $instance['thumb_pin_color'];
     } else {
         $tmp .= 'markers=icon:' . urlencode($instance['thumb_pin_img']);
     }
     $tmp .= '%7Clabel:A%7C' . urlencode($instance['address']) . '&amp;language=' . $lang . '&amp;visual_refresh=' . $instance['thumb_new_colors'] . '">';
     if ($instance['thumb_link_type'] == 'lightbox' || $instance['thumb_link_type'] == 'custom') {
         $tmp .= '</a>';
     }
     $tmp .= '</p>';
     if (isset($instance['thumb_footer']) && $instance['thumb_footer']) {
         $tmp .= wpautop(do_shortcode($instance['thumb_footer']));
     }
     $out .= apply_filters('google_maps_widget_content', $tmp);
     $out .= $after_widget;
     echo $out;
 }
 static function prepare_data()
 {
     $options = get_option(GMW_OPTIONS);
     $data = array();
     $current_user = wp_get_current_user();
     $data['url'] = home_url();
     if ($current_user && isset($current_user->user_email) && !empty($current_user->user_email)) {
         $data['admin_email'] = $current_user->user_email;
     } else {
         $data['admin_email'] = get_bloginfo('admin_email');
     }
     $data['wp_version'] = get_bloginfo('version');
     $data['gmw_version'] = GMW::$version;
     $data['gmw_first_version'] = $options['first_version'];
     $data['gmw_first_install'] = $options['first_install'];
     $data['gmw_activated'] = GMW::is_activated();
     $data['ioncube'] = extension_loaded('IonCube Loader');
     $data['gmw_count'] = self::count_active_widgets();
     if (get_bloginfo('version') < '3.4') {
         $theme = get_theme_data(get_stylesheet_directory() . '/style.css');
         $data['theme_name'] = $theme['Name'];
         $data['theme_version'] = $theme['Version'];
     } else {
         $theme = wp_get_theme();
         $data['theme_name'] = $theme->Name;
         $data['theme_version'] = $theme->Version;
     }
     // get current plugin information
     if (!function_exists('get_plugins')) {
         include ABSPATH . '/wp-admin/includes/plugin.php';
     }
     $plugins = get_plugins();
     $active_plugins = get_option('active_plugins', array());
     foreach ($active_plugins as $plugin) {
         $data['plugins'][$plugin] = @$plugins[$plugin];
     }
     return $data;
 }
 function widget($args, $instance)
 {
     $out = $tmp = '';
     extract($args, EXTR_SKIP);
     $ll = '';
     if ($instance['lightbox_zoom'] > 14) {
         $coordinates = GMW::get_coordinates($instance['address']);
         if ($coordinates) {
             $ll = $coordinates['lat'] . ',' . $coordinates['lng'];
         }
     }
     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;
     $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']);
     if (!empty($title)) {
         $out .= $before_title . $title . $after_title;
     }
     if ($instance['thumb_header']) {
         $tmp .= wpautop($instance['thumb_header']);
     }
     $tmp .= '<p><a class="gmw-thumbnail-map" href="#dialog-' . $widget_id . '" title="Click to open larger map">';
     $tmp .= '<img title="Click to open larger map" alt="Click to open larger map" src="https://maps.googleapis.com/maps/api/staticmap?center=' . urlencode($instance['address']) . '&amp;zoom=' . $instance['thumb_zoom'] . '&amp;size=' . $instance['thumb_width'] . 'x' . $instance['thumb_height'] . '&amp;maptype=' . $instance['thumb_type'] . '&amp;sensor=false&amp;scale=1&amp;markers=size:' . $instance['thumb_pin_size'] . '%7Ccolor:' . $instance['thumb_pin_color'] . '%7Clabel:A%7C' . urlencode($instance['address']) . '"></a>';
     $tmp .= '</p>';
     if ($instance['thumb_footer']) {
         $tmp .= wpautop($instance['thumb_footer']);
     }
     $out .= apply_filters('google_maps_widget_content', $tmp);
     $out .= $after_widget;
     echo $out;
 }