Simple Google Map - Version 4.0

Version Description

  • Add support for Google Maps API Key
Download this release

Release Info

Developer gwelser
Plugin Icon wp plugin Simple Google Map
Version 4.0
Comparing to
See all releases

Code changes from version 3.3 to 4.0

README.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://clarknikdelpowell.com/pay
4
  Tags: google, google map, google maps, simple google map, no api key
5
  Requires at least: 3.2
6
  Tested up to: 4.5.3
7
- Stable tag: 3.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -12,7 +12,9 @@ This plugin will embed a google map using shortcode or as a widget.
12
 
13
  == Description ==
14
 
15
- With this plugin you can insert a google map into your posts, pages, or wigitized sidebar *without an API key*. Google recently released version 3 of their Maps API. They made it smaller and faster, but with less features. The biggest advantage is that it doesn’t require an API key. So all you have to do is install this plugin and set a few options! Lucky you.
 
 
16
 
17
  **FEATURES**
18
 
@@ -51,6 +53,9 @@ The shortcode name is SGM and here are the options..
51
 
52
  == Changelog ==
53
 
 
 
 
54
  = 3.3 =
55
  * Add custom map marker image with `icon` attribute
56
  * Add default custom map marker image via plugin settings page
4
  Tags: google, google map, google maps, simple google map, no api key
5
  Requires at least: 3.2
6
  Tested up to: 4.5.3
7
+ Stable tag: 4.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
12
 
13
  == Description ==
14
 
15
+ With this plugin you can insert a google map into your posts, pages, or wigitized sidebar *without an API key*. Google recently released version 3 of their Maps API. They made it smaller and faster, but with less features.
16
+
17
+ **If your site was not using the Google Maps API key as of June 22, 2016, Google now requires the use of an API key. [More information in this Google Developers post](http://googlegeodevelopers.blogspot.com.au/2016/06/building-for-scale-updates-to-google.html). You can get a Google Maps Javascript API Key from the [Google Developers API Console](https://console.developers.google.com).**
18
 
19
  **FEATURES**
20
 
53
 
54
  == Changelog ==
55
 
56
+ = 4.0 =
57
+ * Add support for Google Maps API Key
58
+
59
  = 3.3 =
60
  * Add custom map marker image with `icon` attribute
61
  * Add default custom map marker image via plugin settings page
admin/class-simple-google-map-admin.php CHANGED
@@ -106,6 +106,7 @@ class Simple_Google_Map_Admin {
106
 
107
  if ( isset( $_POST['submit'] ) ) {
108
 
 
109
  $new_options['zoom'] = is_numeric( $_POST['zoom'] ) ? sanitize_text_field( $_POST['zoom'] ) : '';
110
  $new_options['type'] = strtoupper( sanitize_text_field( $_POST['type'] ) );
111
  $new_options['icon'] = esc_url_raw( $_POST['icon'], array( 'http', 'https' ) );
@@ -129,7 +130,7 @@ class Simple_Google_Map_Admin {
129
  $sgm_options = get_option( 'SGMoptions' );
130
  $sgm_options = wp_parse_args( array_filter( $sgm_options ), $this->default_options );
131
 
132
- $sgm_css = get_option( 'SGMcss' );
133
  }
134
 
135
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/simple-google-map-admin-display.php';
106
 
107
  if ( isset( $_POST['submit'] ) ) {
108
 
109
+ $new_options['api_key'] = sanitize_text_field( $_POST['api_key'] );
110
  $new_options['zoom'] = is_numeric( $_POST['zoom'] ) ? sanitize_text_field( $_POST['zoom'] ) : '';
111
  $new_options['type'] = strtoupper( sanitize_text_field( $_POST['type'] ) );
112
  $new_options['icon'] = esc_url_raw( $_POST['icon'], array( 'http', 'https' ) );
130
  $sgm_options = get_option( 'SGMoptions' );
131
  $sgm_options = wp_parse_args( array_filter( $sgm_options ), $this->default_options );
132
 
133
+ $sgm_css = get_option( 'SGMcss' );
134
  }
135
 
136
  require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/partials/simple-google-map-admin-display.php';
admin/partials/simple-google-map-admin-display.php CHANGED
@@ -13,6 +13,7 @@
13
  */
14
 
15
  $message_value = isset( $message ) ? $message : '';
 
16
  $zoom_value = isset( $sgm_options['zoom'] ) ? $sgm_options['zoom'] : '';
17
  $type_value = isset( $sgm_options['type'] ) ? $sgm_options['type'] : '';
18
  $icon_value = isset( $sgm_options['icon'] ) ? $sgm_options['icon'] : '';
@@ -36,6 +37,18 @@ $nostyle_value = isset( $sgm_options['nostyle'] ) ? 'checked="checked"' : '';
36
 
37
  <table class="form-table">
38
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  <tr valign="top">
40
  <th><label for="zoom">Zoom Level</label></th>
41
  <td>
13
  */
14
 
15
  $message_value = isset( $message ) ? $message : '';
16
+ $api_key_value = isset( $sgm_options['api_key'] ) ? $sgm_options['api_key'] : '';
17
  $zoom_value = isset( $sgm_options['zoom'] ) ? $sgm_options['zoom'] : '';
18
  $type_value = isset( $sgm_options['type'] ) ? $sgm_options['type'] : '';
19
  $icon_value = isset( $sgm_options['icon'] ) ? $sgm_options['icon'] : '';
37
 
38
  <table class="form-table">
39
 
40
+ <tr valign="top">
41
+ <th><label for="key">API Key</label></th>
42
+ <td>
43
+ <input name="api_key" type="text" value="<?php echo $api_key_value ?>"/><br/>
44
+ <span class="description">You may need an API Key. See this <a
45
+ href="http://googlegeodevelopers.blogspot.com.au/2016/06/building-for-scale-updates-to-google.html"
46
+ target="_blank">Google Developers post</a> for more info.<br/>
47
+ Go to the <a href="https://console.developers.google.com"
48
+ target="_blank">Google Maps API Console</a> and create a Google Maps JavaScript API key.</span>
49
+ </td>
50
+ </tr>
51
+
52
  <tr valign="top">
53
  <th><label for="zoom">Zoom Level</label></th>
54
  <td>
includes/class-simple-google-map.php CHANGED
@@ -81,6 +81,7 @@ class Simple_Google_Map {
81
  * @var array
82
  */
83
  static $default_options = array(
 
84
  'zoom' => '12',
85
  'type' => 'ROADMAP',
86
  'icon' => '',
81
  * @var array
82
  */
83
  static $default_options = array(
84
+ 'api_key' => '',
85
  'zoom' => '12',
86
  'type' => 'ROADMAP',
87
  'icon' => '',
public/class-simple-google-map-public.php CHANGED
@@ -73,7 +73,14 @@ class Simple_Google_Map_Public {
73
 
74
  global $post;
75
  if ( has_shortcode( $post->post_content, 'SGM' ) || is_active_widget( false, false, 'simple-google-map-widget', true ) ) {
76
- wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js' );
 
 
 
 
 
 
 
77
  }
78
 
79
  }
@@ -174,4 +181,18 @@ class Simple_Google_Map_Public {
174
 
175
  return $map;
176
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
177
  }
73
 
74
  global $post;
75
  if ( has_shortcode( $post->post_content, 'SGM' ) || is_active_widget( false, false, 'simple-google-map-widget', true ) ) {
76
+ $source = 'https://maps.googleapis.com/maps/api/js';
77
+
78
+ $api_key = $this->get_api_key();
79
+ if ( $api_key ) {
80
+ $source .= '?key=' . $api_key;
81
+ }
82
+
83
+ wp_enqueue_script( 'google-maps', $source );
84
  }
85
 
86
  }
181
 
182
  return $map;
183
  }
184
+
185
+ /**
186
+ * Get the Google Maps API Key
187
+ *
188
+ * @since 4.0.0
189
+ */
190
+ public function get_api_key() {
191
+
192
+ $sgm_options = get_option( 'SGMoptions' );
193
+ $sgm_options = wp_parse_args( $sgm_options, Simple_Google_Map::$default_options );
194
+ $api_key = $sgm_options['api_key'];
195
+
196
+ return $api_key;
197
+ }
198
  }
simple-google-map.php CHANGED
@@ -16,7 +16,7 @@
16
  * Plugin Name: Simple Google Map
17
  * Plugin URI: http://clarknikdelpowell.com/wordpress/simple-google-map
18
  * Description: Embed a google map using shortcode or as a widget.
19
- * Version: 3.3
20
  * Author: Taylor Gorman, Glenn Welser
21
  * Author URI: http://clarknikdelpowell.com
22
  * License: GPL-2.0+
16
  * Plugin Name: Simple Google Map
17
  * Plugin URI: http://clarknikdelpowell.com/wordpress/simple-google-map
18
  * Description: Embed a google map using shortcode or as a widget.
19
+ * Version: 4.0
20
  * Author: Taylor Gorman, Glenn Welser
21
  * Author URI: http://clarknikdelpowell.com
22
  * License: GPL-2.0+