| @@ -1,13 +1,13 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | * Google Maps Widget |
| 4 | 4 | * Widget definition, admin GUI and front-end functions |
| 5 | - * (c) Web factory Ltd, 2012 - 2014 | |
| 5 | + * (c) Web factory Ltd, 2012 - 2015 | |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | 8 | |
| 9 | -// include only file | |
| 9 | +// this is an include only file | |
| 10 | 10 | if (!defined('ABSPATH')) { |
| 11 | 11 | die(); |
| 12 | 12 | } |
| 13 | 13 | |
| @@ -20,9 +20,9 @@ | ||
| 20 | 20 | // constructor method |
| 21 | 21 | function GoogleMapsWidget() { |
| 22 | 22 | $widget_ops = array('classname' => 'google-maps-widget', 'description' => __('Displays a map image thumbnail with a larger map available in a lightbox.', 'google-maps-widget')); |
| 23 | 23 | $control_ops = array('width' => 450, 'height' => 350); |
| 24 | - $this->WP_Widget('GoogleMapsWidget', __('Google Maps Widget', 'google-maps-widget'), $widget_ops, $control_ops); | |
| 24 | + parent::__construct('GoogleMapsWidget', __('Google Maps Widget', 'google-maps-widget'), $widget_ops, $control_ops); | |
| 25 | 25 | } // GoogleMapsWidget |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | // widget edit form HTML |
| @@ -38,10 +38,10 @@ | ||
| 38 | 38 | 'thumb_height' => '250', |
| 39 | 39 | 'thumb_type' => 'roadmap', |
| 40 | 40 | 'thumb_zoom' => '13', |
| 41 | 41 | 'thumb_header' => '', |
| 42 | - 'thumb_footer' => '', | |
| 43 | - 'thumb_new_colors' => '1', | |
| 42 | + 'thumb_footer' => 'Powered by Google Maps Widget', | |
| 43 | + 'thumb_color_scheme' => '', | |
| 44 | 44 | 'thumb_link_type' => 'lightbox', |
| 45 | 45 | 'thumb_link' => '', |
| 46 | 46 | 'lightbox_width' => '550', |
| 47 | 47 | 'lightbox_height' => '550', |
| @@ -96,23 +96,39 @@ | ||
| 96 | 96 | for ($tmp = 1; $tmp <= 21; $tmp++) { |
| 97 | 97 | $zoom_levels[] = array('val' => $tmp, 'label' => $tmp); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $lightbox_skins[] = array('val' => 'light', 'label' => __('Light (default)', 'google-maps-widget')); | |
| 101 | - $lightbox_skins[] = array('val' => 'dark', 'label' => __('Dark', 'google-maps-widget')); | |
| 102 | - | |
| 103 | - $thumb_pin_types[] = array('val' => 'predefined', 'label' => __('Predefined (default)', 'google-maps-widget')); | |
| 104 | - $thumb_pin_types[] = array('val' => 'custom', 'label' => __('Custom', 'google-maps-widget')); | |
| 100 | + $lightbox_skins = array(array('val' => 'light', 'label' => __('Light (default)', 'google-maps-widget')), | |
| 101 | + array('val' => 'dark', 'label' => __('Dark', 'google-maps-widget'))); | |
| 105 | 102 | |
| 106 | - $thumb_link_types[] = array('val' => 'lightbox', 'label' => __('Lightbox (default)', 'google-maps-widget')); | |
| 107 | - $thumb_link_types[] = array('val' => 'custom', 'label' => __('Custom link', 'google-maps-widget')); | |
| 108 | - $thumb_link_types[] = array('val' => 'nolink', 'label' => __('Disable link', 'google-maps-widget')); | |
| 103 | + $lightbox_bubbles = array(array('val' => '0', 'label' => __('Hide', 'google-maps-widget')), | |
| 104 | + array('val' => '1', 'label' => __('Show (default)', 'google-maps-widget'))); | |
| 109 | 105 | |
| 106 | + $lightbox_titles = array(array('val' => '0', 'label' => __('Do not show map title on lightbox', 'google-maps-widget')), | |
| 107 | + array('val' => '1', 'label' => __('Show map title on lightbox (default)', 'google-maps-widget'))); | |
| 110 | 108 | |
| 109 | + $thumb_pin_types = array(array('val' => 'predefined', 'label' => __('Predefined (default)', 'google-maps-widget')), | |
| 110 | + array('val' => 'custom', 'label' => __('Custom', 'google-maps-widget'))); | |
| 111 | + | |
| 112 | + $thumb_link_types = array(array('val' => 'lightbox', 'label' => __('Lightbox (default)', 'google-maps-widget')), | |
| 113 | + array('val' => 'custom', 'label' => __('Custom URL', 'google-maps-widget')), | |
| 114 | + array('val' => 'nolink', 'label' => __('Disable link', 'google-maps-widget'))); | |
| 115 | + | |
| 116 | + $thumb_color_schemes = array(array('val' => 'default', 'label' => __('Default', 'gmw')), | |
| 117 | + array('val' => 'new', 'label' => __('Refreshed by Google', 'gmw'))); | |
| 118 | + | |
| 119 | + if (GMW::is_activated()) { | |
| 120 | + array_push($thumb_color_schemes, array('val' => 'apple', 'label' => __('Apple', 'google-maps-widget')), | |
| 121 | + array('val' => 'gray', 'label' => __('Gray', 'google-maps-widget')), | |
| 122 | + array('val' => 'paper', 'label' => __('Paper', 'google-maps-widget'))); | |
| 123 | + array_push($lightbox_skins, array('val' => 'noimage-blue', 'label' => __('Blue', 'google-maps-widget')), | |
| 124 | + array('val' => 'noimage-rounded', 'label' => __('Rounded', 'google-maps-widget'))); | |
| 125 | + } | |
| 126 | + | |
| 111 | 127 | echo '<p><label for="' . $this->get_field_id('title') . '">' . __('Title', 'google-maps-widget') . ':</label><input class="widefat" id="' . $this->get_field_id('title') . '" name="' . $this->get_field_name('title') . '" type="text" value="' . esc_attr($title) . '" /></p>'; |
| 112 | 128 | echo '<p><label for="' . $this->get_field_id('address') . '">' . __('Address', 'google-maps-widget') . ':</label><input class="widefat" id="' . $this->get_field_id('address') . '" name="' . $this->get_field_name('address') . '" type="text" value="' . esc_attr($address) . '" /></p>'; |
| 113 | 129 | |
| 114 | - echo '<div class="gmw-tabs" id="tab-' . $this->id . '"><ul><li><a href="#gmw-thumb">' . __('Thumbnail map', 'google-maps-widget') . '</a></li><li><a href="#gmw-lightbox">' . __('Lightbox map', 'google-maps-widget') . '</a></li></ul>'; | |
| 130 | + echo '<div class="gmw-tabs" id="tab-' . $this->id . '"><ul><li><a href="#gmw-thumb">' . __('Thumbnail map', 'google-maps-widget') . '</a></li><li><a href="#gmw-lightbox">' . __('Lightbox map', 'google-maps-widget') . '</a></li><li><a href="#gmw-shortcode">' . __('Shortcode', 'google-maps-widget') . '</a></li><li><a href="#gmw-info">' . __('Info & Support', 'google-maps-widget') . '</a></li></ul>'; | |
| 115 | 131 | echo '<div id="gmw-thumb">'; |
| 116 | 132 | |
| 117 | 133 | echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_width') . '">' . __('Map Size', 'google-maps-widget') . ':</label>'; |
| 118 | 134 | 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 '; |
| @@ -122,9 +138,9 @@ | ||
| 122 | 138 | echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_type') . '">' . __('Map Type', 'google-maps-widget') . ':</label>'; |
| 123 | 139 | echo '<select id="' . $this->get_field_id('thumb_type') . '" name="' . $this->get_field_name('thumb_type') . '">'; |
| 124 | 140 | GMW::create_select_options($map_types_thumb, $thumb_type); |
| 125 | 141 | echo '</select></p>'; |
| 126 | - | |
| 142 | + | |
| 127 | 143 | echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_pin_type') . '">' . __('Pin Type', 'google-maps-widget') . ':</label>'; |
| 128 | 144 | echo '<select class="gmw_thumb_pin_type" id="' . $this->get_field_id('thumb_pin_type') . '" name="' . $this->get_field_name('thumb_pin_type') . '">'; |
| 129 | 145 | GMW::create_select_options($thumb_pin_types, $thumb_pin_type); |
| 130 | 146 | echo '</select></p>'; |
| @@ -137,10 +153,10 @@ | ||
| 137 | 153 | echo '<p class="gmw_thumb_pin_type_predefined_section"><label class="gmw-label" for="' . $this->get_field_id('thumb_pin_size') . '">' . __('Pin Size', 'google-maps-widget') . ':</label>'; |
| 138 | 154 | echo '<select id="' . $this->get_field_id('thumb_pin_size') . '" name="' . $this->get_field_name('thumb_pin_size') . '">'; |
| 139 | 155 | GMW::create_select_options($pin_sizes, $thumb_pin_size); |
| 140 | 156 | echo '</select></p>'; |
| 141 | - | |
| 142 | - echo '<p class="gmw_thumb_pin_type_custom_section"><label class="gmw-label gmw-label-wide" for="' . $this->get_field_id('thumb_pin_img') . '">' . __('Custom Pin Image URL', 'google-maps-widget') . ':</label>'; | |
| 157 | + | |
| 158 | + echo '<p class="gmw_thumb_pin_type_custom_section"><label class="gmw-label" for="' . $this->get_field_id('thumb_pin_img') . '">' . __('Pin Image URL', 'google-maps-widget') . ':</label>'; | |
| 143 | 159 | echo '<input type="text" class="regular-text" id="' . $this->get_field_id('thumb_pin_img') . '" name="' . $this->get_field_name('thumb_pin_img') . '" value="' . esc_attr($thumb_pin_img) . '">'; |
| 144 | 160 | |
| 145 | 161 | echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_zoom') . '">' . __('Zoom Level', 'google-maps-widget') . ':</label>'; |
| 146 | 162 | echo '<select id="' . $this->get_field_id('thumb_zoom') . '" name="' . $this->get_field_name('thumb_zoom') . '">'; |
| @@ -151,20 +167,24 @@ | ||
| 151 | 167 | echo '<select class="gmw_thumb_link_type" id="' . $this->get_field_id('thumb_link_type') . '" name="' . $this->get_field_name('thumb_link_type') . '">'; |
| 152 | 168 | GMW::create_select_options($thumb_link_types, $thumb_link_type); |
| 153 | 169 | echo '</select></p>'; |
| 154 | 170 | |
| 155 | - echo '<p class="gmw_thumb_link_section"><label class="gmw-label" for="' . $this->get_field_id('thumb_link') . '">' . __('Custom Link', 'google-maps-widget') . ':</label>'; | |
| 171 | + echo '<p class="gmw_thumb_link_section"><label class="gmw-label" for="' . $this->get_field_id('thumb_link') . '">' . __('Custom URL', 'google-maps-widget') . ':</label>'; | |
| 156 | 172 | echo '<input class="regular-text" id="' . $this->get_field_id('thumb_link') . '" name="' . $this->get_field_name('thumb_link') . '" type="text" value="' . esc_attr($thumb_link) . '" /></p>'; |
| 157 | 173 | |
| 158 | - echo '<p><label for="' . $this->get_field_id('thumb_new_colors') . '">' . __('Use New Color Scheme', 'google-maps-widget') . ': </label>'; | |
| 159 | - echo '<input ' . checked('1', $thumb_new_colors, false) . ' value="1" type="checkbox" id="' . $this->get_field_id('thumb_new_colors') . '" name="' . $this->get_field_name('thumb_new_colors') . '">'; | |
| 160 | - echo '</p>'; | |
| 174 | + echo '<p><label class="gmw-label" for="' . $this->get_field_id('thumb_color_scheme') . '">' . __('Color Scheme', 'google-maps-widget') . ':</label>'; | |
| 175 | + echo '<select class="gmw_thumb_color_scheme" id="' . $this->get_field_id('thumb_color_scheme') . '" name="' . $this->get_field_name('thumb_color_scheme') . '">'; | |
| 176 | + GMW::create_select_options($thumb_color_schemes, $thumb_color_scheme); | |
| 177 | + if (!GMW::is_activated()) { | |
| 178 | + echo '<option class="promo" value="-1">' . __('Add more schemes for FREE', 'google-maps-widget') . '</option>'; | |
| 179 | + } | |
| 180 | + echo '</select></p>'; | |
| 161 | 181 | |
| 162 | 182 | echo '<p><label for="' . $this->get_field_id('thumb_header') . '">' . __('Text Above Map', 'google-maps-widget') . ':</label>'; |
| 163 | - echo '<textarea class="widefat" rows="3" cols="20" id="' . $this->get_field_id('thumb_header') . '" name="' . $this->get_field_name('thumb_header') . '">'. $thumb_header . '</textarea></p>'; | |
| 183 | + echo '<textarea class="widefat" rows="3" cols="20" id="' . $this->get_field_id('thumb_header') . '" name="' . $this->get_field_name('thumb_header') . '">'. esc_textarea($thumb_header) . '</textarea></p>'; | |
| 164 | 184 | |
| 165 | 185 | echo '<p><label for="' . $this->get_field_id('thumb_footer') . '">' . __('Text Below Map', 'google-maps-widget') . ':</label>'; |
| 166 | - echo '<textarea class="widefat" rows="3" cols="20" id="' . $this->get_field_id('thumb_footer') . '" name="' . $this->get_field_name('thumb_footer') . '">'. $thumb_footer . '</textarea></p>'; | |
| 186 | + echo '<textarea class="widefat" rows="3" cols="20" id="' . $this->get_field_id('thumb_footer') . '" name="' . $this->get_field_name('thumb_footer') . '">'. esc_textarea($thumb_footer) . '</textarea></p>'; | |
| 167 | 187 | |
| 168 | 188 | echo '</div>'; // thumbnail tab |
| 169 | 189 | echo '<div id="gmw-lightbox">'; |
| 170 | 190 | |
| @@ -182,30 +202,70 @@ | ||
| 182 | 202 | echo '<select id="' . $this->get_field_id('lightbox_zoom') . '" name="' . $this->get_field_name('lightbox_zoom') . '">'; |
| 183 | 203 | GMW::create_select_options($zoom_levels, $lightbox_zoom); |
| 184 | 204 | echo '</select></p>'; |
| 185 | 205 | |
| 186 | - echo '<p><label class="gmw-label" for="' . $this->get_field_id('lightbox_skin') . '">' . __('Skin', 'google-maps-widget') . ':</label>'; | |
| 187 | - echo '<select id="' . $this->get_field_id('lightbox_skin') . '" name="' . $this->get_field_name('lightbox_skin') . '">'; | |
| 206 | + echo '<p><label class="gmw-label" for="' . $this->get_field_id('lightbox_skin') . '">' . __('Lightbox Skin', 'google-maps-widget') . ':</label>'; | |
| 207 | + echo '<select class="gmw_lightbox_skin" id="' . $this->get_field_id('lightbox_skin') . '" name="' . $this->get_field_name('lightbox_skin') . '">'; | |
| 188 | 208 | GMW::create_select_options($lightbox_skins, $lightbox_skin); |
| 209 | + if (!GMW::is_activated()) { | |
| 210 | + echo '<option class="promo" value="-1">' . __('Add more skins for FREE', 'google-maps-widget') . '</option>'; | |
| 211 | + } | |
| 189 | 212 | echo '</select></p>'; |
| 190 | 213 | |
| 191 | - echo '<p><label for="' . $this->get_field_id('lightbox_bubble') . '">' . __('Show Address Bubble', 'google-maps-widget') . ': </label>'; | |
| 192 | - 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') . '">'; | |
| 193 | - echo '</p>'; | |
| 214 | + echo '<p><label class="gmw-label" for="' . $this->get_field_id('lightbox_bubble') . '">' . __('Address Bubble', 'google-maps-widget') . ':</label>'; | |
| 215 | + echo '<select id="' . $this->get_field_id('lightbox_bubble') . '" name="' . $this->get_field_name('lightbox_bubble') . '">'; | |
| 216 | + GMW::create_select_options($lightbox_bubbles, $lightbox_bubble); | |
| 217 | + echo '</select></p>'; | |
| 194 | 218 | |
| 195 | - echo '<p><label for="' . $this->get_field_id('lightbox_title') . '">' . __('Show Map Title Above Lightbox', 'google-maps-widget') . ': </label>'; | |
| 196 | - 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') . '">'; | |
| 197 | - echo '</p>'; | |
| 219 | + echo '<p><label class="gmw-label" for="' . $this->get_field_id('lightbox_title') . '">' . __('Map Title', 'google-maps-widget') . ': </label>'; | |
| 220 | + echo '<select id="' . $this->get_field_id('lightbox_title') . '" name="' . $this->get_field_name('lightbox_title') . '">'; | |
| 221 | + GMW::create_select_options($lightbox_titles, $lightbox_title); | |
| 222 | + echo '</select></p>'; | |
| 198 | 223 | |
| 199 | 224 | echo '<p><label for="' . $this->get_field_id('lightbox_header') . '">' . __('Header Text', 'google-maps-widget') . ':</label>'; |
| 200 | - 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>'; | |
| 225 | + echo '<textarea class="widefat" rows="3" cols="20" id="' . $this->get_field_id('lightbox_header') . '" name="' . $this->get_field_name('lightbox_header') . '">'. esc_textarea($lightbox_header) . '</textarea></p>'; | |
| 201 | 226 | |
| 202 | 227 | echo '<p><label for="' . $this->get_field_id('lightbox_footer') . '">' . __('Footer Text', 'google-maps-widget') . ':</label>'; |
| 203 | - 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>'; | |
| 228 | + echo '<textarea class="widefat" rows="3" cols="20" id="' . $this->get_field_id('lightbox_footer') . '" name="' . $this->get_field_name('lightbox_footer') . '">'. esc_textarea($lightbox_footer) . '</textarea></p>'; | |
| 204 | 229 | |
| 205 | 230 | echo '</div>'; // lightbox tab |
| 206 | - echo '</div>'; // tabs | |
| 207 | - echo '<p><i>' . __('If you like the plugin give us a shout. Thanks!', 'google-maps-widget') . ' <a title="WebFactory on Twitter" target="_blank" href="http://twitter.com/WebFactoryLtd">@WebFactoryLtd</a></i></p>'; | |
| 231 | + | |
| 232 | + // shortcode tab | |
| 233 | + echo '<div id="gmw-shortcode">'; | |
| 234 | + if (GMW::is_activated()) { | |
| 235 | + $id = str_replace('googlemapswidget-', '', $this->id); | |
| 236 | + | |
| 237 | + if (!$id || !is_numeric($id)) { | |
| 238 | + echo '<p>' . __('Please save the widget so that the shortcode can be generated.', 'google-maps-widget') . '</p>'; | |
| 239 | + } else { | |
| 240 | + echo '<p><code>[gmw id="' . $id . '"]</code><br></p>'; | |
| 241 | + echo '<p>' . __('Use the above shortcode to display this Google Maps Widget instance in any page or post. <br>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 <code>span.gmw-shortcode-widget</code> class to target the shortcode and make necessary changes via CSS.', 'google-maps-widget') . '</p>'; | |
| 242 | + } | |
| 243 | + } else { | |
| 244 | + echo '<p>Shortcode support is an extra feature. You can activate it <b>for free</b> and get more features & options for free as well.<br><br><a class="button open_promo_dialog" href="#">Activate extra features</a></p>'; | |
| 245 | + } | |
| 246 | + echo '</div>'; // shortcode tab | |
| 247 | + | |
| 248 | + echo '<div id="gmw-info">'; | |
| 249 | + echo '<h4>' . __('Support', 'google-maps-widget') . '</h4>'; | |
| 250 | + echo '<p>If you have any problems, questions or would like a new feature added post it on the <a href="https://wordpress.org/support/plugin/google-maps-widget" target="_blank">official support forum</a>. It\'s the only place to get support. Since it\'s free and community powered please be patient. <a target="_blank" href="https://www.paypal.com/cgi-bin/[email protected]&cmd=_xclick¤cy_code=USD&amount=19&item_name=Premium%20support%20for%20Google%20Maps%20Widget">Premium support</a> is available for $19.</p>'; | |
| 251 | + echo '<h4>' . __('Activate extra features & options', 'google-maps-widget') . '</h4>'; | |
| 252 | + echo '<p>' . __('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 <i>activate by subscribing</i> features will be available soon!', 'google-maps-widget') . '<br>'; | |
| 253 | + if (GMW::is_activated()) { | |
| 254 | + echo __('You\'ve already subscribed and activated extra features. Thank you!', 'google-maps-widget'); | |
| 255 | + } else { | |
| 256 | + echo __('Subscribe and <a class="open_promo_dialog" href="#">activate extra features</a>.', 'google-maps-widget'); | |
| 257 | + } | |
| 258 | + echo '</p>'; | |
| 259 | + echo '<h4>' . __('Rate the plugin & spread the word', 'google-maps-widget') . '</h4>'; | |
| 260 | + echo '<p>It won\'t take you more than a minute but it will help us immensely. So please - <a href="https://wordpress.org/support/view/plugin-reviews/google-maps-widget" target="_blank">rate the plugin</a>. Or spread the word by <a href="https://twitter.com/intent/tweet?via=WebFactoryLtd&text=' . urlencode('I\'m using the #free Google Maps Widget for #wordpress. You can grab it too at http://goo.gl/2qcbbf') . '" target="_blank">tweeting about it</a>. Thank you!</p>'; | |
| 261 | + echo '</div>'; // info tab | |
| 262 | + | |
| 263 | + echo '</div><p></p>'; // tabs | |
| 264 | + | |
| 265 | + if (!GMW::is_activated()) { | |
| 266 | + echo '<p>' . __('Click to <a href="#" class="open_promo_dialog">get extra premium features</a> for Google Maps Widget! For <b><span style="color: #d54e21;">FREE</span></b>.', 'google-maps-widget') . '</p>'; | |
| 267 | + } | |
| 208 | 268 | } // form |
| 209 | 269 | |
| 210 | 270 | |
| 211 | 271 | // update/save widget options |
| @@ -225,18 +285,19 @@ | ||
| 225 | 285 | $instance['thumb_link_type'] = $new_instance['thumb_link_type']; |
| 226 | 286 | $instance['thumb_link'] = trim($new_instance['thumb_link']); |
| 227 | 287 | $instance['thumb_header'] = trim($new_instance['thumb_header']); |
| 228 | 288 | $instance['thumb_footer'] = trim($new_instance['thumb_footer']); |
| 229 | - $instance['thumb_new_colors'] = isset($new_instance['thumb_new_colors']); | |
| 289 | + $instance['thumb_color_scheme'] = $new_instance['thumb_color_scheme']; | |
| 230 | 290 | $instance['lightbox_width'] = (int) $new_instance['lightbox_width']; |
| 231 | 291 | $instance['lightbox_height'] = (int) $new_instance['lightbox_height']; |
| 232 | 292 | $instance['lightbox_type'] = $new_instance['lightbox_type']; |
| 233 | 293 | $instance['lightbox_zoom'] = $new_instance['lightbox_zoom']; |
| 234 | - $instance['lightbox_bubble'] = isset($new_instance['lightbox_bubble']); | |
| 235 | - $instance['lightbox_title'] = isset($new_instance['lightbox_title']); | |
| 294 | + $instance['lightbox_bubble'] = $new_instance['lightbox_bubble']; | |
| 295 | + $instance['lightbox_title'] = $new_instance['lightbox_title']; | |
| 236 | 296 | $instance['lightbox_header'] = trim($new_instance['lightbox_header']); |
| 237 | 297 | $instance['lightbox_footer'] = trim($new_instance['lightbox_footer']); |
| 238 | 298 | $instance['lightbox_skin'] = $new_instance['lightbox_skin']; |
| 299 | + $instance['core_ver'] = GMW::$version; | |
| 239 | 300 | |
| 240 | 301 | return $instance; |
| 241 | 302 | } // update |
| 242 | 303 | |
| @@ -244,8 +305,13 @@ | ||
| 244 | 305 | // echo widget |
| 245 | 306 | function widget($args, $instance) { |
| 246 | 307 | $out = $tmp = ''; |
| 247 | 308 | |
| 309 | + $thumb_styles = array( | |
| 310 | + '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|', | |
| 311 | + '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|', | |
| 312 | + '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|'); | |
| 313 | + | |
| 248 | 314 | extract($args, EXTR_SKIP); |
| 249 | 315 | |
| 250 | 316 | $ll = ''; |
| 251 | 317 | if ($instance['lightbox_zoom'] > 14) { |
| @@ -258,9 +324,9 @@ | ||
| 258 | 324 | $lang = substr(@$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); |
| 259 | 325 | if (!$lang) { |
| 260 | 326 | $lang = 'en'; |
| 261 | 327 | } |
| 262 | - | |
| 328 | + | |
| 263 | 329 | // legacy fix for older versions; it's auto-fixed on first widget save but has to be here |
| 264 | 330 | if(!$instance['lightbox_skin']) { |
| 265 | 331 | $instance['lightbox_skin'] = 'light'; |
| 266 | 332 | } |
| @@ -282,19 +348,13 @@ | ||
| 282 | 348 | |
| 283 | 349 | if (!isset($instance['thumb_pin_type']) || empty($instance['thumb_pin_type'])) { |
| 284 | 350 | $instance['thumb_pin_type'] = 'predefined'; |
| 285 | 351 | } |
| 286 | - | |
| 352 | + | |
| 287 | 353 | if (!isset($instance['thumb_link_type']) || empty($instance['thumb_link_type'])) { |
| 288 | 354 | $instance['thumb_link_type'] = 'lightbox'; |
| 289 | 355 | } |
| 290 | 356 | |
| 291 | - if (isset($instance['thumb_new_colors']) && $instance['thumb_new_colors']) { | |
| 292 | - $instance['thumb_new_colors'] = 'true'; | |
| 293 | - } else { | |
| 294 | - $instance['thumb_new_colors'] = 'false'; | |
| 295 | - } | |
| 296 | - | |
| 297 | 357 | $title = empty($instance['title'])? ' ' : apply_filters('widget_title', $instance['title']); |
| 298 | 358 | if (!empty($title)) { |
| 299 | 359 | $out .= $before_title . $title . $after_title; |
| 300 | 360 | } |
| @@ -302,15 +362,15 @@ | ||
| 302 | 362 | if (isset($instance['thumb_header']) && $instance['thumb_header']) { |
| 303 | 363 | $tmp .= wpautop(do_shortcode($instance['thumb_header'])); |
| 304 | 364 | } |
| 305 | 365 | $tmp .= '<p>'; |
| 306 | - | |
| 366 | + | |
| 307 | 367 | if ($instance['thumb_link_type'] == 'lightbox') { |
| 308 | 368 | $alt = __('Click to open larger map', 'google-maps-widget'); |
| 309 | 369 | } else { |
| 310 | 370 | $alt = esc_attr($instance['address']); |
| 311 | 371 | } |
| 312 | - | |
| 372 | + | |
| 313 | 373 | if ($instance['thumb_link_type'] == 'lightbox') { |
| 314 | 374 | $tmp .= '<a class="gmw-thumbnail-map gmw-lightbox-enabled" href="#gmw-dialog-' . $widget_id . '" title="' . __('Click to open larger map', 'google-maps-widget') . '">'; |
| 315 | 375 | } elseif ($instance['thumb_link_type'] == 'custom') { |
| 316 | 376 | $tmp .= '<a class="gmw-thumbnail-map" title="' . esc_attr($instance['address']) . '" href="' . $instance['thumb_link'] . '">'; |
| @@ -323,15 +383,27 @@ | ||
| 323 | 383 | $tmp .= 'markers=size:' . $instance['thumb_pin_size'] . '%7Ccolor:' . $instance['thumb_pin_color']; |
| 324 | 384 | } else { |
| 325 | 385 | $tmp .= 'markers=icon:' . urlencode($instance['thumb_pin_img']); |
| 326 | 386 | } |
| 327 | - $tmp .= '%7Clabel:A%7C' . urlencode($instance['address']) . '&language=' . $lang . '&visual_refresh=' . $instance['thumb_new_colors'] .'">'; | |
| 387 | + $tmp .= '%7Clabel:A%7C' . urlencode($instance['address']) . '&language=' . $lang; | |
| 388 | + if (!isset($instance['thumb_color_scheme']) || $instance['thumb_color_scheme'] == 'default') { | |
| 389 | + $tmp .= '&visual_refresh=false'; | |
| 390 | + } elseif ($instance['thumb_color_scheme'] == 'new') { | |
| 391 | + $tmp .= '&visual_refresh=true'; | |
| 392 | + } elseif (GMW::is_activated()) { | |
| 393 | + $tmp .= '&' . str_replace('&', '&', $thumb_styles[$instance['thumb_color_scheme']]); | |
| 394 | + } | |
| 395 | + $tmp .= '">'; | |
| 328 | 396 | if ($instance['thumb_link_type'] == 'lightbox' || $instance['thumb_link_type'] == 'custom') { |
| 329 | 397 | $tmp .= '</a>'; |
| 330 | 398 | } |
| 331 | 399 | $tmp .= '</p>'; |
| 332 | 400 | if (isset($instance['thumb_footer']) && $instance['thumb_footer']) { |
| 333 | - $tmp .= wpautop(do_shortcode($instance['thumb_footer'])); | |
| 401 | + if ($instance['thumb_footer'] == 'Powered by Google Maps Widget') { | |
| 402 | + $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>'; | |
| 403 | + } else { | |
| 404 | + $tmp .= wpautop(do_shortcode($instance['thumb_footer'])); | |
| 405 | + } | |
| 334 | 406 | } |
| 335 | 407 | $out .= apply_filters('google_maps_widget_content', $tmp); |
| 336 | 408 | |
| 337 | 409 | $out .= $after_widget; |