Version Description
- Add directions form to info bubble when directionsto is provided.
- Enqueue Google Maps script the proper way with conditional loading.
Download this release
Release Info
Developer | gwelser |
Plugin | Simple Google Map |
Version | 3.1 |
Comparing to | |
See all releases |
Code changes from version 3.0.1 to 3.1
readme.txt → README.txt
RENAMED
@@ -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.0.1
|
6 |
Tested up to: 4.4
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -48,6 +48,10 @@ The shortcode name is SGM and here are the options..
|
|
48 |
|
49 |
== Changelog ==
|
50 |
|
|
|
|
|
|
|
|
|
51 |
= 3.0 =
|
52 |
* Refactored to use [WordPress Plugin Boilerplate](https://github.com/DevinVinson/WordPress-Plugin-Boilerplate).
|
53 |
* Removed protocol from Google Maps js call so as not to cause errors on pages secured via SSL.
|
4 |
Tags: google, google map, google maps, simple google map, no api key
|
5 |
Requires at least: 3.0.1
|
6 |
Tested up to: 4.4
|
7 |
+
Stable tag: 3.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
48 |
|
49 |
== Changelog ==
|
50 |
|
51 |
+
= 3.1 =
|
52 |
+
* Add directions form to info bubble when directionsto is provided.
|
53 |
+
* Enqueue Google Maps script the proper way with conditional loading.
|
54 |
+
|
55 |
= 3.0 =
|
56 |
* Refactored to use [WordPress Plugin Boilerplate](https://github.com/DevinVinson/WordPress-Plugin-Boilerplate).
|
57 |
* Removed protocol from Google Maps js call so as not to cause errors on pages secured via SSL.
|
includes/class-simple-google-map.php
CHANGED
@@ -195,6 +195,7 @@ class Simple_Google_Map {
|
|
195 |
|
196 |
$plugin_public = new Simple_Google_Map_Public( $this->get_plugin_name(), $this->get_version() );
|
197 |
|
|
|
198 |
$this->loader->add_action( 'wp_head', $plugin_public, 'output_css' );
|
199 |
|
200 |
$this->loader->add_shortcode( 'SGM', $plugin_public, 'map' );
|
195 |
|
196 |
$plugin_public = new Simple_Google_Map_Public( $this->get_plugin_name(), $this->get_version() );
|
197 |
|
198 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
|
199 |
$this->loader->add_action( 'wp_head', $plugin_public, 'output_css' );
|
200 |
|
201 |
$this->loader->add_shortcode( 'SGM', $plugin_public, 'map' );
|
public/class-simple-google-map-public.php
CHANGED
@@ -27,7 +27,7 @@ class Simple_Google_Map_Public {
|
|
27 |
*
|
28 |
* @since 3.0.0
|
29 |
* @access private
|
30 |
-
* @var string
|
31 |
*/
|
32 |
private $plugin_name;
|
33 |
|
@@ -36,7 +36,7 @@ class Simple_Google_Map_Public {
|
|
36 |
*
|
37 |
* @since 3.0.0
|
38 |
* @access protected
|
39 |
-
* @var string
|
40 |
*/
|
41 |
protected $plugin_path;
|
42 |
|
@@ -45,7 +45,7 @@ class Simple_Google_Map_Public {
|
|
45 |
*
|
46 |
* @since 3.0.0
|
47 |
* @access private
|
48 |
-
* @var string
|
49 |
*/
|
50 |
private $version;
|
51 |
|
@@ -53,49 +53,72 @@ class Simple_Google_Map_Public {
|
|
53 |
* Initialize the class and set its properties.
|
54 |
*
|
55 |
* @since 3.0.0
|
56 |
-
*
|
57 |
-
* @param string
|
|
|
58 |
*/
|
59 |
public function __construct( $plugin_name, $version ) {
|
60 |
|
61 |
$this->plugin_name = $plugin_name;
|
62 |
-
$this->version
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
* Output CSS into header
|
68 |
-
*
|
69 |
* @since 3.0.0
|
70 |
*/
|
71 |
public function output_css() {
|
72 |
|
73 |
$SGMoptions = get_option( 'SGMoptions' );
|
74 |
-
if ( isset($SGMoptions['nostyle']) )
|
|
|
|
|
75 |
|
76 |
echo "<!-- styles for Simple Google Map -->\n<style type='text/css'>\n";
|
77 |
-
echo get_option('SGMcss');
|
78 |
echo "\n</style>\n<!-- end styles for Simple Google Map -->\n";
|
79 |
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
* Output CSS into header
|
84 |
-
*
|
85 |
* @since 3.0.0
|
86 |
*/
|
87 |
public function map( $atts ) {
|
88 |
|
89 |
-
$SGMoptions = get_option('SGMoptions'); // get options defined in admin page
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
-
$
|
92 |
-
$
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
$directionsto = isset($atts['directionsto']) ? $atts['directionsto'] : '';
|
97 |
|
98 |
-
require_once plugin_dir_path( dirname(__FILE__) ).'public/partials/simple-google-map-public-display.php';
|
99 |
|
100 |
}
|
101 |
|
27 |
*
|
28 |
* @since 3.0.0
|
29 |
* @access private
|
30 |
+
* @var string $plugin_name The ID of this plugin.
|
31 |
*/
|
32 |
private $plugin_name;
|
33 |
|
36 |
*
|
37 |
* @since 3.0.0
|
38 |
* @access protected
|
39 |
+
* @var string $plugin_path The string path of this plugin.
|
40 |
*/
|
41 |
protected $plugin_path;
|
42 |
|
45 |
*
|
46 |
* @since 3.0.0
|
47 |
* @access private
|
48 |
+
* @var string $version The current version of this plugin.
|
49 |
*/
|
50 |
private $version;
|
51 |
|
53 |
* Initialize the class and set its properties.
|
54 |
*
|
55 |
* @since 3.0.0
|
56 |
+
*
|
57 |
+
* @param string $plugin_name The name of the plugin.
|
58 |
+
* @param string $version The version of this plugin.
|
59 |
*/
|
60 |
public function __construct( $plugin_name, $version ) {
|
61 |
|
62 |
$this->plugin_name = $plugin_name;
|
63 |
+
$this->version = $version;
|
64 |
+
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Enqueue scripts
|
69 |
+
*
|
70 |
+
* @since 3.1.0
|
71 |
+
*/
|
72 |
+
public function enqueue_scripts() {
|
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 |
}
|
80 |
|
81 |
/**
|
82 |
* Output CSS into header
|
83 |
+
*
|
84 |
* @since 3.0.0
|
85 |
*/
|
86 |
public function output_css() {
|
87 |
|
88 |
$SGMoptions = get_option( 'SGMoptions' );
|
89 |
+
if ( isset( $SGMoptions['nostyle'] ) ) {
|
90 |
+
return;
|
91 |
+
}
|
92 |
|
93 |
echo "<!-- styles for Simple Google Map -->\n<style type='text/css'>\n";
|
94 |
+
echo get_option( 'SGMcss' );
|
95 |
echo "\n</style>\n<!-- end styles for Simple Google Map -->\n";
|
96 |
|
97 |
}
|
98 |
|
99 |
/**
|
100 |
* Output CSS into header
|
101 |
+
*
|
102 |
* @since 3.0.0
|
103 |
*/
|
104 |
public function map( $atts ) {
|
105 |
|
106 |
+
$SGMoptions = get_option( 'SGMoptions' ); // get options defined in admin page
|
107 |
+
|
108 |
+
$lat = isset( $atts['lat'] ) ? $atts['lat'] : '0';
|
109 |
+
$lng = isset( $atts['lng'] ) ? $atts['lng'] : '0';
|
110 |
+
$zoom = isset( $atts['zoom'] ) ? $atts['zoom'] : $SGMoptions['zoom'];
|
111 |
+
$type = isset( $atts['type'] ) ? strtoupper( $atts['type'] ) : $SGMoptions['type'];
|
112 |
+
$content = isset( $atts['content'] ) ? $atts['content'] : $SGMoptions['content'];
|
113 |
+
$directionsto = isset( $atts['directionsto'] ) ? $atts['directionsto'] : '';
|
114 |
|
115 |
+
$content = htmlspecialchars_decode( $content );
|
116 |
+
$directionsForm = '';
|
117 |
+
if ( $directionsto ) {
|
118 |
+
$directionsForm = "<form method=\"get\" action=\"//maps.google.com/maps\"><input type=\"hidden\" name=\"daddr\" value=\"" . $directionsto . "\" /><input type=\"text\" class=\"text\" name=\"saddr\" /><input type=\"submit\" class=\"submit\" value=\"Directions\" /></form>";
|
119 |
+
}
|
|
|
120 |
|
121 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/partials/simple-google-map-public-display.php';
|
122 |
|
123 |
}
|
124 |
|
public/partials/simple-google-map-public-display.php
CHANGED
@@ -13,7 +13,6 @@
|
|
13 |
*/
|
14 |
?>
|
15 |
|
16 |
-
<script type='text/javascript' src='//maps.google.com/maps/api/js?sensor=false'></script>
|
17 |
<script type='text/javascript'>
|
18 |
function makeMap() {
|
19 |
var latlng = new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng; ?>)
|
@@ -29,7 +28,7 @@
|
|
29 |
};
|
30 |
var map = new google.maps.Map(document.getElementById('SGM'), myOptions);
|
31 |
|
32 |
-
var contentString = '<div class=\"infoWindow\"><?php echo $content.$directionsto ?></div>';
|
33 |
var infowindow = new google.maps.InfoWindow({
|
34 |
content: contentString
|
35 |
});
|
13 |
*/
|
14 |
?>
|
15 |
|
|
|
16 |
<script type='text/javascript'>
|
17 |
function makeMap() {
|
18 |
var latlng = new google.maps.LatLng(<?php echo $lat; ?>, <?php echo $lng; ?>)
|
28 |
};
|
29 |
var map = new google.maps.Map(document.getElementById('SGM'), myOptions);
|
30 |
|
31 |
+
var contentString = '<div class=\"infoWindow\"><?php echo $content.$directionsto.$directionsForm; ?></div>';
|
32 |
var infowindow = new google.maps.InfoWindow({
|
33 |
content: contentString
|
34 |
});
|
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.
|
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: 3.1
|
20 |
* Author: Taylor Gorman, Glenn Welser
|
21 |
* Author URI: http://clarknikdelpowell.com
|
22 |
* License: GPL-2.0+
|