コード例 #1
0
 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;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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;
 }