Version Description
[2012-07-12] = * fixed: Norwegian translation had incorrect file name * fixed: Malaysian translation had incorrect index (was overwriting Macedonian translation) * added: filters so that theme and plugin developers can modify the behaviour of this plugin * added: width and height can be any valid CSS units, not just pixels
Download this release
Release Info
Developer | webaware |
Plugin | Flexible Map |
Version | 1.3.0 |
Comparing to | |
See all releases |
Code changes from version 1.2.0 to 1.3.0
- class.FlxMapPlugin.php +55 -8
- flexible-map.php +1 -1
- i18n/ms.js +1 -1
- i18n/{no.js → nb.js} +1 -1
- readme.txt +22 -3
class.FlxMapPlugin.php
CHANGED
@@ -44,7 +44,7 @@ class FlxMapPlugin {
|
|
44 |
|
45 |
// non-admin actions and filters for this plugin
|
46 |
add_action('wp_footer', array($this, 'actionFooter'));
|
47 |
-
add_action('
|
48 |
|
49 |
// custom actions and filters for this plugin
|
50 |
add_filter('flexmap_getmap', array($this, 'shortcodeMap'), 10, 1);
|
@@ -79,11 +79,13 @@ class FlxMapPlugin {
|
|
79 |
$url = parse_url($this->urlBase, PHP_URL_PATH);
|
80 |
$version = 9;
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
|
|
85 |
|
86 |
-
|
87 |
|
88 |
// see if we need to load i18n messages
|
89 |
foreach (array_keys($this->locales) as $locale) {
|
@@ -111,12 +113,30 @@ HTML;
|
|
111 |
public function shortcodeMap($attrs) {
|
112 |
$html = '';
|
113 |
|
|
|
|
|
|
|
114 |
if (!empty($attrs['src']) || !empty($attrs['center']) || !empty($attrs['address'])) {
|
115 |
$this->loadScripts = TRUE;
|
116 |
$divID = uniqid('flxmap-');
|
117 |
-
$width = isset($attrs['width']) ? preg_replace('/\D/', '', $attrs['width']) : 400;
|
118 |
-
$height = isset($attrs['height']) ? preg_replace('/\D/', '', $attrs['height']) : 400;
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
$directions = FALSE;
|
121 |
$divDirections = '';
|
122 |
if (isset($attrs['directions']) && !self::isNo($attrs['directions'])) {
|
@@ -131,7 +151,7 @@ HTML;
|
|
131 |
}
|
132 |
|
133 |
$html = <<<HTML
|
134 |
-
<div id="$divID" class='flxmap-container'
|
135 |
<script>
|
136 |
//<![CDATA[
|
137 |
(function(w, fn) {
|
@@ -271,9 +291,36 @@ HTML;
|
|
271 |
$html .= "});\n//]]>\n</script>\n";
|
272 |
}
|
273 |
|
|
|
|
|
|
|
274 |
return $html;
|
275 |
}
|
276 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
277 |
/**
|
278 |
* test string to see if contents equate to yes/true
|
279 |
* @param string $text
|
44 |
|
45 |
// non-admin actions and filters for this plugin
|
46 |
add_action('wp_footer', array($this, 'actionFooter'));
|
47 |
+
add_action('wp_enqueue_scripts', array($this, 'actionEnqueueStyles'));
|
48 |
|
49 |
// custom actions and filters for this plugin
|
50 |
add_filter('flexmap_getmap', array($this, 'shortcodeMap'), 10, 1);
|
79 |
$url = parse_url($this->urlBase, PHP_URL_PATH);
|
80 |
$version = 9;
|
81 |
|
82 |
+
// allow others to override the Google Maps API URL
|
83 |
+
$apiURL = apply_filters('flexmap_google_maps_api_url', '//maps.google.com/maps/api/js?v=3.8&sensor=false');
|
84 |
+
if (!empty($apiURL)) {
|
85 |
+
echo "<script src=\"$apiURL\"></script>\n";
|
86 |
+
}
|
87 |
|
88 |
+
echo "<script src=\"{$url}flexible-map.min.js?v=$version\"></script>\n";
|
89 |
|
90 |
// see if we need to load i18n messages
|
91 |
foreach (array_keys($this->locales) as $locale) {
|
113 |
public function shortcodeMap($attrs) {
|
114 |
$html = '';
|
115 |
|
116 |
+
// allow others to change the shortcode attributes used
|
117 |
+
$attrs = apply_filters('flexmap_shortcode_attrs', $attrs);
|
118 |
+
|
119 |
if (!empty($attrs['src']) || !empty($attrs['center']) || !empty($attrs['address'])) {
|
120 |
$this->loadScripts = TRUE;
|
121 |
$divID = uniqid('flxmap-');
|
|
|
|
|
122 |
|
123 |
+
// build the inline styles for the div
|
124 |
+
$styles = array();
|
125 |
+
$styles['width'] = isset($attrs['width']) ? self::getUnits($attrs['width']) : '400px';
|
126 |
+
$styles['height'] = isset($attrs['height']) ? self::getUnits($attrs['height']) : '400px';
|
127 |
+
$styles = apply_filters('flexmap_shortcode_styles', $styles, $attrs);
|
128 |
+
if (empty($styles)) {
|
129 |
+
$inlinestyles = '';
|
130 |
+
}
|
131 |
+
else {
|
132 |
+
$inlinestyles = 'style="';
|
133 |
+
foreach ($styles as $style => $value) {
|
134 |
+
$inlinestyles .= $style . ':' . $value . ';';
|
135 |
+
}
|
136 |
+
$inlinestyles .= '"';
|
137 |
+
}
|
138 |
+
|
139 |
+
// build the directions div, if required
|
140 |
$directions = FALSE;
|
141 |
$divDirections = '';
|
142 |
if (isset($attrs['directions']) && !self::isNo($attrs['directions'])) {
|
151 |
}
|
152 |
|
153 |
$html = <<<HTML
|
154 |
+
<div id="$divID" class='flxmap-container' $inlinestyles></div>$divDirections
|
155 |
<script>
|
156 |
//<![CDATA[
|
157 |
(function(w, fn) {
|
291 |
$html .= "});\n//]]>\n</script>\n";
|
292 |
}
|
293 |
|
294 |
+
// allow others to change the generated html
|
295 |
+
$html = apply_filters('flexmap_shortcode_html', $html, $attrs);
|
296 |
+
|
297 |
return $html;
|
298 |
}
|
299 |
|
300 |
+
/**
|
301 |
+
* get valid CSS units from string, or default to 400px if invalid
|
302 |
+
* @param string $units
|
303 |
+
* @return string
|
304 |
+
*/
|
305 |
+
private static function getUnits($units) {
|
306 |
+
$units = trim($units);
|
307 |
+
|
308 |
+
// check for valid CSS units
|
309 |
+
if (!preg_match('/^auto$|^[+-]?[0-9]+\\.?(?:[0-9]+)?(?:px|em|ex|%|in|cm|mm|pt|pc)?$/', $units)) {
|
310 |
+
// not valid, so check to see if it's only digits
|
311 |
+
if (preg_match('/\D/', $units)) {
|
312 |
+
// not digits, so set to default
|
313 |
+
$units = '400px';
|
314 |
+
}
|
315 |
+
else {
|
316 |
+
// found only digits, so append px
|
317 |
+
$units .= 'px';
|
318 |
+
}
|
319 |
+
}
|
320 |
+
|
321 |
+
return $units;
|
322 |
+
}
|
323 |
+
|
324 |
/**
|
325 |
* test string to see if contents equate to yes/true
|
326 |
* @param string $text
|
flexible-map.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Flexible Map
|
4 |
Plugin URI: http://snippets.webaware.com.au/wordpress-plugins/wp-flexible-map/
|
5 |
Description: Embed Google Maps in pages and posts, either by centre coodinates or street address, or by URL to a Google Earth KML file.
|
6 |
-
Version: 1.
|
7 |
Author: WebAware
|
8 |
Author URI: http://www.webaware.com.au/
|
9 |
*/
|
3 |
Plugin Name: Flexible Map
|
4 |
Plugin URI: http://snippets.webaware.com.au/wordpress-plugins/wp-flexible-map/
|
5 |
Description: Embed Google Maps in pages and posts, either by centre coodinates or street address, or by URL to a Google Earth KML file.
|
6 |
+
Version: 1.3.0
|
7 |
Author: WebAware
|
8 |
Author URI: http://www.webaware.com.au/
|
9 |
*/
|
i18n/ms.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
|
4 |
if (typeof FlexibleMap != "undefined") {
|
5 |
|
6 |
-
FlexibleMap.prototype.i18n["
|
7 |
"Click for details" : "Klik untuk maklumat lanjut",
|
8 |
"Directions" : "arahan",
|
9 |
"From" : "Tempat berlepas",
|
3 |
|
4 |
if (typeof FlexibleMap != "undefined") {
|
5 |
|
6 |
+
FlexibleMap.prototype.i18n["ms"] = {
|
7 |
"Click for details" : "Klik untuk maklumat lanjut",
|
8 |
"Directions" : "arahan",
|
9 |
"From" : "Tempat berlepas",
|
i18n/{no.js → nb.js}
RENAMED
@@ -3,7 +3,7 @@
|
|
3 |
|
4 |
if (typeof FlexibleMap != "undefined") {
|
5 |
|
6 |
-
FlexibleMap.prototype.i18n["
|
7 |
"Click for details" : "Klikk for detaljer",
|
8 |
"Directions" : "kartanvisninger",
|
9 |
"From" : "Avgangssted",
|
3 |
|
4 |
if (typeof FlexibleMap != "undefined") {
|
5 |
|
6 |
+
FlexibleMap.prototype.i18n["nb"] = {
|
7 |
"Click for details" : "Klikk for detaljer",
|
8 |
"Directions" : "kartanvisninger",
|
9 |
"From" : "Avgangssted",
|
readme.txt
CHANGED
@@ -7,7 +7,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
7 |
Tags: google, maps, google maps, shortcode, kml
|
8 |
Requires at least: 3.0.1
|
9 |
Tested up to: 3.4.1
|
10 |
-
Stable tag: 1.
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
@@ -49,8 +49,8 @@ To add a Flexible Map to a post or a page, add a shortcode [flexiblemap] and giv
|
|
49 |
|
50 |
= Parameters for all maps =
|
51 |
|
52 |
-
* **width**: width in pixels, e.g. *width="500"*
|
53 |
-
* **height**: height in pixels, e.g. *height="400"*
|
54 |
* **zoom**: zoom level as an integer, larger is closer, e.g. *zoom="16"*
|
55 |
* **maptype**: type of map to show, from [roadmap, satellite], e.g. *maptype="roadmap"*; default=roadmap
|
56 |
* **hidemaptype**: hide the map type controls, from [true, false], e.g. *hidemaptype="true"*; default=false
|
@@ -111,6 +111,15 @@ There is a PHP function `flexmap_show_map()` for theme and plugin developers. Al
|
|
111 |
'maptype' => 'satellite',
|
112 |
));`
|
113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
== Frequently Asked Questions ==
|
115 |
|
116 |
= Can I add multiple markers to a map? =
|
@@ -133,8 +142,18 @@ When you use just centre coordinates for your map, the directions may send peopl
|
|
133 |
|
134 |
Since version 1.1.0, this plugin now uses localised messages for things like the Directions link and the default message on links in info windows. If you have your [WordPress installation set to use your language](http://codex.wordpress.org/WordPress_in_Your_Language), the plugin should automatically pick it up. If you need to force it to pick up your language (or want to offer a different language), use the `locale` parameter, e.g. `locale="ru"` or `locale="zh-TW"`. Google Maps will use the locale information from your web browser to help display maps in your language (see your browser's language settings).
|
135 |
|
|
|
|
|
|
|
|
|
136 |
== Changelog ==
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
= 1.2.0 [2012-06-29] =
|
139 |
* added: option showdirections, to show the directions search when the map loads
|
140 |
* added: option directionsfrom, to set the default from: location, and immediately search for directions when showdirections is set
|
7 |
Tags: google, maps, google maps, shortcode, kml
|
8 |
Requires at least: 3.0.1
|
9 |
Tested up to: 3.4.1
|
10 |
+
Stable tag: 1.3.0
|
11 |
License: GPLv2 or later
|
12 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
13 |
|
49 |
|
50 |
= Parameters for all maps =
|
51 |
|
52 |
+
* **width**: width in pixels or valid CSS units, e.g. *width="500"*
|
53 |
+
* **height**: height in pixels or valid CSS units, e.g. *height="400"*
|
54 |
* **zoom**: zoom level as an integer, larger is closer, e.g. *zoom="16"*
|
55 |
* **maptype**: type of map to show, from [roadmap, satellite], e.g. *maptype="roadmap"*; default=roadmap
|
56 |
* **hidemaptype**: hide the map type controls, from [true, false], e.g. *hidemaptype="true"*; default=false
|
111 |
'maptype' => 'satellite',
|
112 |
));`
|
113 |
|
114 |
+
There are also some filter hooks that allow you to change the behaviour of the plugin.
|
115 |
+
|
116 |
+
* **flexmap_google_maps_api_url**: allows you to replace the Google Maps API URL, e.g. if you need a different API version (NB: this plugin's scripts are coded for a specific API major version!)
|
117 |
+
* **flexmap_shortcode_attrs**: allows you to change the shortcode attributes, e.g. change the width and height
|
118 |
+
* **flexmap_shortcode_styles**: allows you to change the inline styles applied to the div wrapping the map, e.g. remove width and height so that it can be specified in the theme's stylesheets
|
119 |
+
* **flexmap_shortcode_html**: allows you to change the generated html, e.g. wrap in another div, add a link to Google Maps, etc.
|
120 |
+
|
121 |
+
For more information and examples, see [the website](http://snippets.webaware.com.au/wordpress-plugins/wp-flexible-map/).
|
122 |
+
|
123 |
== Frequently Asked Questions ==
|
124 |
|
125 |
= Can I add multiple markers to a map? =
|
142 |
|
143 |
Since version 1.1.0, this plugin now uses localised messages for things like the Directions link and the default message on links in info windows. If you have your [WordPress installation set to use your language](http://codex.wordpress.org/WordPress_in_Your_Language), the plugin should automatically pick it up. If you need to force it to pick up your language (or want to offer a different language), use the `locale` parameter, e.g. `locale="ru"` or `locale="zh-TW"`. Google Maps will use the locale information from your web browser to help display maps in your language (see your browser's language settings).
|
144 |
|
145 |
+
= You've translated my language badly / it's missing =
|
146 |
+
|
147 |
+
The initial translations were made using Google Translate, so it's likely that some will be truly awful! Please help by editing the .js file for your language in the i18n folder, and tell me about it in the support forum.
|
148 |
+
|
149 |
== Changelog ==
|
150 |
|
151 |
+
= 1.3.0 [2012-07-12] =
|
152 |
+
* fixed: Norwegian translation had incorrect file name
|
153 |
+
* fixed: Malaysian translation had incorrect index (was overwriting Macedonian translation)
|
154 |
+
* added: filters so that theme and plugin developers can modify the behaviour of this plugin
|
155 |
+
* added: width and height can be any valid CSS units, not just pixels
|
156 |
+
|
157 |
= 1.2.0 [2012-06-29] =
|
158 |
* added: option showdirections, to show the directions search when the map loads
|
159 |
* added: option directionsfrom, to set the default from: location, and immediately search for directions when showdirections is set
|