Changeset 2968965 for leaflet-map
- Timestamp:
- 09/20/2023 02:39:32 AM (19 months ago)
- Location:
- leaflet-map
- Files:
-
- 14 edited
- 1 copied
-
tags/3.3.1 (copied) (copied from leaflet-map/trunk)
-
tags/3.3.1/class.leaflet-map.php (modified) (1 diff)
-
tags/3.3.1/leaflet-map.php (modified) (2 diffs)
-
tags/3.3.1/readme.txt (modified) (3 diffs)
-
tags/3.3.1/scripts/construct-leaflet-map.min.js (modified) (1 diff)
-
tags/3.3.1/shortcodes/class.geojson-shortcode.php (modified) (1 diff)
-
tags/3.3.1/shortcodes/class.map-shortcode.php (modified) (19 diffs)
-
tags/3.3.1/shortcodes/class.marker-shortcode.php (modified) (5 diffs)
-
trunk/class.leaflet-map.php (modified) (1 diff)
-
trunk/leaflet-map.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/scripts/construct-leaflet-map.min.js (modified) (1 diff)
-
trunk/shortcodes/class.geojson-shortcode.php (modified) (1 diff)
-
trunk/shortcodes/class.map-shortcode.php (modified) (19 diffs)
-
trunk/shortcodes/class.marker-shortcode.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
leaflet-map/tags/3.3.1/class.leaflet-map.php
r2871359 r2968965 23 23 * @var string major minor patch version 24 24 */ 25 public static $leaflet_version = '1.9. 3';25 public static $leaflet_version = '1.9.4'; 26 26 27 27 /** -
leaflet-map/tags/3.3.1/leaflet-map.php
r2871359 r2968965 9 9 * Text Domain: leaflet-map 10 10 * Domain Path: /languages/ 11 * Version: 3.3. 011 * Version: 3.3.1 12 12 * License: GPL2 13 13 * Leaflet Map is free software: you can redistribute it and/or modify … … 30 30 } 31 31 32 define('LEAFLET_MAP__PLUGIN_VERSION', '3.3. 0');32 define('LEAFLET_MAP__PLUGIN_VERSION', '3.3.1'); 33 33 define('LEAFLET_MAP__PLUGIN_FILE', __FILE__); 34 34 define('LEAFLET_MAP__PLUGIN_DIR', plugin_dir_path(__FILE__)); -
leaflet-map/tags/3.3.1/readme.txt
r2871359 r2968965 7 7 Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive 8 8 Requires at least: 4.6 9 Tested up to: 6. 1.110 Version: 3.3. 011 Stable tag: 3.3. 09 Tested up to: 6.3.1 10 Version: 3.3.1 11 Stable tag: 3.3.1 12 12 License: GPLv2 13 13 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 149 149 150 150 == Changelog == 151 152 = 3.3.1 = 153 * [Update] Default Leaflet map set at v1.9.4 154 * [Security] Escapes geojson popup properties to prevent XSS attacks 155 * [Bug] Updates "!attribution" or "attribution=0" attributes to actually remove attribution 156 * [Bug] Switches SANITIZE_FULL with SANITIZE to to allow "German umlauts" 157 * [Bug] Fixes some issues when a map's max zoom differs from a tile layer's max zoom 151 158 152 159 = 3.3.0 = … … 461 468 == Upgrade Notice == 462 469 470 = 3.3.1 = 471 * Escapes geojson popup properties to prevent XSS attacks 472 463 473 = 3.2.0 = 464 474 * Fixes error if geocoder fails to get a lat/lng -
leaflet-map/tags/3.3.1/scripts/construct-leaflet-map.min.js
r2871359 r2968965 1 !function(){var t=window.WPLeafletMapPlugin;if(window.WPLeafletMapPlugin=new function(){function t(t){try{t()}catch(t){console.log("-- version --","v3.3. 0"),console.error(t)}}this.VERSION="v3.3.0";var n=!1,i=[];this.push=function(r){n?t(r):i.push(r)},this.unshift=function(r){n?t(r):i.unshift(r)},this.init=function(){n=!0;for(var r=0,e=i.length;r<e;r++)t(i[r])},this.createMap=function(t){var n=document.getElementsByClassName("WPLeafletMap")[this.maps.length],i=L.map(n,t);return t.fitBounds&&(i._shouldFitBounds=!0),t.attribution&&function(t,n){if(!t)return;for(var i=t.split(";"),r=L.control.attribution({prefix:!1}).addTo(n),e=0,o=i.length;e<o;e++){var a=(s=i[e]).trim?s.trim():s.replace(/^\s+|\s+$/gm,"");r.addAttribution(a)}var s}(t.attribution,i),this.maps.push(i),i},this.createImageMap=function(t){var n=this.createMap(t);return n.is_image_map=!0,this.images.push(n),n},this.getCurrentMap=function(){return this.maps[this.maps.length-1]},this.getCurrentGroup=function(){var t=this.maps.length;return this.markergroups[t]||(this.markergroups[t]=this.newMarkerGroup(this.maps[t-1])),this.markergroups[t]},this.getCurrentMarkerGroup=this.getCurrentGroup,this.getGroup=function(t){return(new L.FeatureGroup).addTo(t)},this.newMarkerGroup=function(t){var n=this.getGroup(t);return n.timeout=null,t._shouldFitBounds&&n.on("layeradd",(function(i){i.layer instanceof L.FeatureGroup&&i.layer.on("ready",(function(){t.fitBounds(n.getBounds())})),window.clearTimeout(this.timeout),this.timeout=window.setTimeout((function(){try{t.fitBounds(n.getBounds())}catch(t){}}),100)}),n),n},this.propsToTable=function(t){var n,i=[];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.push(n);for(var r="<table>",e=0,o=(i=i.sort()).length;e<o;e++){var a=i[e];r+="<tr><td>"+a+"</td>",r+="<td>"+t[a]+"</td></tr>"}return r+="</table>"};var r=this.unescape=function(t){var n=document.createElement("div");return n.innerHTML=t,n.innerText||t},e=/\{ *(.*?) *\}/g;this.template=function(t,n){return null==n?t:t.replace(e,(function(t,i){var e=function(t){for(var n=t.split(" | "),i={},r=n.shift(),e=0,o=n.length;e<o;e++){var a=n[e].split(": "),s=a.shift(),u=a.join(": ")||!0;i[s]=u}return i.key=r,i}(i),a=function(t,n){for(var i=function(t){if(null==t)return[];for(var n=t.split(o),i=[],r=0,e=n.length;r<e;r++)""!==n[r]&&i.push(n[r]);return i}(r(n)),e=t,a=0,s=i.length;a<s;a++)if(!(e=e[i[a]]))return;return e}(n,e.key);return null==a?e.default||t:a}))};var o=/[.‘’'“”"\[\]]+/g;function a(t,n){"undefined"!=typeof L&&void 0!==L[t]?n():setTimeout((function(){a(t,n)}),100)}this.waitForSVG=function(t){a("SVGIcon",t)},this.waitForAjax=function(t){a("AjaxGeoJSON",t)},this.createScale=function(t){L.control.scale(t).addTo(this.getCurrentMap())},this.getIconOptions=function(t){for(var n,i=t||{},r=["iconSize","iconAnchor","shadowSize","shadowAnchor","popupAnchor","tooltipAnchor"],e=L.Icon.Default.prototype.options,o=0,a=r.length;o<a;o++){var s=r[o],u=i[s];if(u){for(var h=u.split(","),c=0,l=h.length;c<l;c++)h[c]=Number(h[c]);i[s]=h}}return i.popupAnchor||(i.popupAnchor=((n=(n=i.iconSize||e.iconSize).slice())[0]=0,n[1]*=-1,n[1]-=3,n)),i.iconUrl&&(i.icon=new L.Icon(i)),i},this.maps=[],this.images=[],this.markergroups={},this.markers=[],this.lines=[],this.polygons=[],this.circles=[],this.geojsons=[],this.overlays=[]},t){for(var n=0,i=t.length;n<i;n++)window.WPLeafletMapPlugin.push(t[n]);for(var r in t.splice(0),t)t.hasOwnProperty(r)&&(window.WPLeafletMapPlugin[r]=t[r])}window.addEventListener?window.addEventListener("load",window.WPLeafletMapPlugin.init,!1):window.attachEvent&&window.attachEvent("onload",window.WPLeafletMapPlugin.init)}();1 !function(){var t=window.WPLeafletMapPlugin;if(window.WPLeafletMapPlugin=new function(){function t(t){try{t()}catch(t){console.log("-- version --","v3.3.1"),console.error(t)}}this.VERSION="v3.3.1";var n=!1,i=[];this.push=function(r){n?t(r):i.push(r)},this.unshift=function(r){n?t(r):i.unshift(r)},this.init=function(){n=!0;for(var r=0,e=i.length;r<e;r++)t(i[r])},this.createMap=function(t){var n=document.getElementsByClassName("WPLeafletMap")[this.maps.length],i=L.map(n,t);return t.fitBounds&&(i._shouldFitBounds=!0),t.attribution&&function(t,n){if(!t)return;for(var i=t.split(";"),r=L.control.attribution({prefix:!1}).addTo(n),e=0,o=i.length;e<o;e++){var a=(s=i[e]).trim?s.trim():s.replace(/^\s+|\s+$/gm,"");r.addAttribution(a)}var s}(t.attribution,i),this.maps.push(i),i},this.createImageMap=function(t){var n=this.createMap(t);return n.is_image_map=!0,this.images.push(n),n},this.getCurrentMap=function(){return this.maps[this.maps.length-1]},this.getCurrentGroup=function(){var t=this.maps.length;return this.markergroups[t]||(this.markergroups[t]=this.newMarkerGroup(this.maps[t-1])),this.markergroups[t]},this.getCurrentMarkerGroup=this.getCurrentGroup,this.getGroup=function(t){return(new L.FeatureGroup).addTo(t)},this.newMarkerGroup=function(t){var n=this.getGroup(t);return n.timeout=null,t._shouldFitBounds&&n.on("layeradd",(function(i){i.layer instanceof L.FeatureGroup&&i.layer.on("ready",(function(){t.fitBounds(n.getBounds())})),window.clearTimeout(this.timeout),this.timeout=window.setTimeout((function(){try{t.fitBounds(n.getBounds())}catch(t){}}),100)}),n),n},this.propsToTable=function(t){var n,i=[];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.push(n);for(var r="<table>",e=0,o=(i=i.sort()).length;e<o;e++){var a=i[e];r+="<tr><td>"+a+"</td>",r+="<td>"+t[a]+"</td></tr>"}return r+="</table>"};var r=this.unescape=function(t){var n=document.createElement("div");return n.innerHTML=t,n.innerText||t},e=/\{ *(.*?) *\}/g;this.template=function(t,n){return null==n?t:t.replace(e,(function(t,i){var e=function(t){for(var n=t.split(" | "),i={},r=n.shift(),e=0,o=n.length;e<o;e++){var a=n[e].split(": "),s=a.shift(),u=a.join(": ")||!0;i[s]=u}return i.key=r,i}(i),a=function(t,n){for(var i=function(t){if(null==t)return[];for(var n=t.split(o),i=[],r=0,e=n.length;r<e;r++)""!==n[r]&&i.push(n[r]);return i}(r(n)),e=t,a=0,s=i.length;a<s;a++)if(!(e=e[i[a]]))return;return e}(n,e.key);return null==a?e.default||t:a}))};var o=/[.‘’'“”"\[\]]+/g;function a(t,n){"undefined"!=typeof L&&void 0!==L[t]?n():setTimeout((function(){a(t,n)}),100)}this.waitForSVG=function(t){a("SVGIcon",t)},this.waitForAjax=function(t){a("AjaxGeoJSON",t)},this.createScale=function(t){L.control.scale(t).addTo(this.getCurrentMap())},this.getIconOptions=function(t){for(var n,i=t||{},r=["iconSize","iconAnchor","shadowSize","shadowAnchor","popupAnchor","tooltipAnchor"],e=L.Icon.Default.prototype.options,o=0,a=r.length;o<a;o++){var s=r[o],u=i[s];if(u){for(var h=u.split(","),c=0,l=h.length;c<l;c++)h[c]=Number(h[c]);i[s]=h}}return i.popupAnchor||(i.popupAnchor=((n=(n=i.iconSize||e.iconSize).slice())[0]=0,n[1]*=-1,n[1]-=3,n)),i.iconUrl&&(i.icon=new L.Icon(i)),i},this.maps=[],this.images=[],this.markergroups={},this.markers=[],this.lines=[],this.polygons=[],this.circles=[],this.geojsons=[],this.overlays=[]},t){for(var n=0,i=t.length;n<i;n++)window.WPLeafletMapPlugin.push(t[n]);for(var r in t.splice(0),t)t.hasOwnProperty(r)&&(window.WPLeafletMapPlugin[r]=t[r])}window.addEventListener?window.addEventListener("load",window.WPLeafletMapPlugin.init,!1):window.attachEvent&&window.attachEvent("onload",window.WPLeafletMapPlugin.init)}(); -
leaflet-map/tags/3.3.1/shortcodes/class.geojson-shortcode.php
r2863840 r2968965 121 121 var fitbounds = <?php echo $fitbounds ? '1' : '0'; ?>; 122 122 var circleMarker = <?php echo $circleMarker ? '1' : '0'; ?>; 123 var popup_text = window.WPLeafletMapPlugin.unescape("<?php echo $popup_text; ?>"); 124 var popup_property = "<?php echo $popup_property; ?>"; 123 var popup_text = window.WPLeafletMapPlugin.unescape("<?php echo esc_js( 124 $popup_text 125 ); ?>"); 126 var popup_property = "<?php echo esc_js($popup_property); ?>"; 125 127 var group = window.WPLeafletMapPlugin.getCurrentGroup(); 126 128 var markerOptions = window.WPLeafletMapPlugin.getIconOptions(<?php echo $options; ?>); -
leaflet-map/tags/3.3.1/shortcodes/class.map-shortcode.php
r2863840 r2968965 3 3 * Map Shortcode 4 4 * 5 * Displays map with [leaflet-map ...atts] 5 * Displays map with [leaflet-map ...atts] 6 6 * 7 7 * JavaScript equivalent : L.map("id"); 8 * 8 * 9 9 * @category Shortcode 10 10 * @author Benjamin J DeLong <ben@bozdoz.com> … … 14 14 if (!defined('ABSPATH')) { 15 15 exit; 16 } 16 } 17 17 18 18 require_once LEAFLET_MAP__PLUGIN_DIR . 'shortcodes/class.shortcode.php'; … … 34 34 35 35 /** 36 * Enqueue Scripts and Styles for Leaflet 37 * 36 * Enqueue Scripts and Styles for Leaflet 37 * 38 38 * @return null 39 39 */ … … 48 48 } 49 49 50 // enqueue user-defined scripts 50 // enqueue user-defined scripts 51 51 // ! will fire for each map 52 52 do_action('leaflet_map_enqueue'); … … 56 56 * Merge shortcode options with default options 57 57 * 58 * @param array|string $atts key value pairs from shortcode 59 * 58 * @param array|string $atts key value pairs from shortcode 59 * 60 60 * @return array new atts, which is actually an array 61 61 */ … … 67 67 $settings = Leaflet_Map_Plugin_Settings::init(); 68 68 69 $atts['zoom'] = array_key_exists('zoom', $atts) ? 69 $atts['zoom'] = array_key_exists('zoom', $atts) ? 70 70 $zoom : $settings->get('default_zoom'); 71 $atts['height'] = empty($height) ? 71 $atts['height'] = empty($height) ? 72 72 $settings->get('default_height') : $height; 73 73 $atts['width'] = empty($width) ? $settings->get('default_width') : $width; 74 $atts['zoomcontrol'] = isset($zoomControl) 74 $atts['zoomcontrol'] = isset($zoomControl) 75 75 ? $zoomControl 76 : (array_key_exists('zoomcontrol', $atts) 77 ? $zoomcontrol 76 : (array_key_exists('zoomcontrol', $atts) 77 ? $zoomcontrol 78 78 : $settings->get('show_zoom_controls')); 79 $atts['min_zoom'] = array_key_exists('min_zoom', $atts) ? 79 $atts['min_zoom'] = array_key_exists('min_zoom', $atts) ? 80 80 $min_zoom : $settings->get('default_min_zoom'); 81 $atts['max_zoom'] = empty($max_zoom) ? 81 $atts['max_zoom'] = empty($max_zoom) ? 82 82 $settings->get('default_max_zoom') : $max_zoom; 83 83 $atts['scrollwheel'] = isset($scrollWheelZoom) 84 84 ? $scrollWheelZoom 85 : (array_key_exists('scrollwheel', $atts) 86 ? $scrollwheel 85 : (array_key_exists('scrollwheel', $atts) 86 ? $scrollwheel 87 87 : $settings->get('scroll_wheel_zoom')); 88 $atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ? 88 $atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ? 89 89 $doubleclickzoom : $settings->get('double_click_zoom'); 90 90 91 91 // @deprecated backwards-compatible fit_markers 92 $atts['fit_markers'] = array_key_exists('fit_markers', $atts) ? 92 $atts['fit_markers'] = array_key_exists('fit_markers', $atts) ? 93 93 $fit_markers : $settings->get('fit_markers'); 94 94 95 95 // fitbounds is what it should be called @since v2.12.0 96 $atts['fitbounds'] = array_key_exists('fitbounds', $atts) ? 96 $atts['fitbounds'] = array_key_exists('fitbounds', $atts) ? 97 97 $fitbounds : $atts['fit_markers']; 98 98 99 99 /* allow percent, but add px for ints */ 100 100 $atts['height'] .= is_numeric($atts['height']) ? 'px' : ''; 101 $atts['width'] .= is_numeric($atts['width']) ? 'px' : ''; 102 103 /* 104 need to allow 0 or empty for removal of attribution 101 $atts['width'] .= is_numeric($atts['width']) ? 'px' : ''; 102 103 /* 104 need to allow 0 or empty for removal of attribution 105 105 */ 106 106 if (!array_key_exists('attribution', $atts)) { … … 114 114 ? $closePopupOnClick 115 115 : (isset($closepopuponclick) 116 ? $closepopuponclick 116 ? $closepopuponclick 117 117 : null), 118 'trackResize' => isset($trackResize) 118 'trackResize' => isset($trackResize) 119 119 ? $trackResize 120 : (isset($trackresize) 121 ? $trackresize 120 : (isset($trackresize) 121 ? $trackresize 122 122 : null), 123 'boxZoom' => isset($boxzoom) 124 ? $boxzoom 123 'boxZoom' => isset($boxzoom) 124 ? $boxzoom 125 125 : (isset($boxZoom) 126 126 ? $boxZoom … … 144 144 // filter out nulls 145 145 $map_options = $this->LM->filter_null($map_options); 146 146 147 147 // custom field for moving to JavaScript 148 148 $map_options['fitBounds'] = $atts['fitbounds']; … … 171 171 // custom field for moving to javascript 172 172 // filter out any unwanted HTML tags (including img) 173 $map_options['attribution'] = wp_kses_post($atts['attribution']); 174 173 if ($atts['attribution'] !== 0) { 174 $map_options['attribution'] = wp_kses_post($atts['attribution']); 175 } 176 175 177 // wrap as JSON 176 178 $atts['map_options'] = json_encode($map_options); … … 180 182 foreach($map_options as $key=>$val) { 181 183 $original_value = isset($atts[$key]) ? $atts[$key] : null; 182 184 183 185 $liquid = $this->LM->liquid($original_value); 184 186 … … 197 199 'accessToken' => empty($accesstoken) ? $settings->get('accesstoken') : $accesstoken, 198 200 'zoomOffset' => empty($zoomoffset) ? $settings->get('zoomoffset') : $zoomoffset, 199 'noWrap' => filter_var(empty($nowrap) ? $settings->get('tile_no_wrap') : $nowrap, FILTER_VALIDATE_BOOLEAN) 200 ); 201 201 'noWrap' => filter_var(empty($nowrap) ? $settings->get('tile_no_wrap') : $nowrap, FILTER_VALIDATE_BOOLEAN), 202 'maxZoom' => $atts['maxZoom'] 203 ); 204 205 202 206 $tile_layer_options = $this->LM->filter_empty_string($tile_layer_options); 203 207 $tile_layer_options = $this->LM->filter_null($tile_layer_options); … … 218 222 219 223 $atts = $this->LM->sanitize_inclusive($atts, $validations); 220 224 221 225 return $atts; 222 226 } … … 224 228 /** 225 229 * Get the div tag for the map to instantiate 226 * 230 * 227 231 * @param string $height 228 232 * @param string $width 229 * 233 * 230 234 * @return string HTML div element 231 235 */ … … 234 238 ob_start(); 235 239 ?> 236 <div class="leaflet-map WPLeafletMap" style="height:<?php 240 <div class="leaflet-map WPLeafletMap" style="height:<?php 237 241 echo htmlspecialchars($height); 238 ?>; width:<?php 242 ?>; width:<?php 239 243 echo htmlspecialchars($width); 240 244 ?>;"></div><?php … … 244 248 /** 245 249 * Get script for shortcode 246 * 250 * 247 251 * @param array $atts sometimes this is null 248 252 * @param string $content anything within a shortcode 249 * 253 * 250 254 * @return string HTML 251 255 */ … … 267 271 $lat = isset($lat) ? $lat : $settings->get('default_lat'); 268 272 $lng = isset($lng) ? $lng : $settings->get('default_lng'); 269 273 270 274 // validate lat/lng 271 275 $lat = $this->LM->filter_float($lat); … … 280 284 $tileurl = empty($tileurl) ? $settings->get('map_tile_url') : $tileurl; 281 285 } 282 286 283 287 $detect_retina = empty($detect_retina) ? $settings->get('detect_retina') : $detect_retina; 284 288 … … 286 290 287 291 /* should be iterated for multiple maps */ 288 ob_start(); 292 ob_start(); 289 293 ?>/*<script>*/ 290 294 var baseUrl = atob('<?php echo base64_encode(filter_var($tileurl, FILTER_SANITIZE_URL)); ?>'); 291 var base = (!baseUrl && window.MQ) ? 292 window.MQ.mapLayer() : L.tileLayer(baseUrl, 295 var base = (!baseUrl && window.MQ) ? 296 window.MQ.mapLayer() : L.tileLayer(baseUrl, 293 297 L.Util.extend({}, { 294 298 detectRetina: <?php echo $detect_retina ? '1' : '0'; ?>, 295 }, 299 }, 296 300 <?php echo $tile_layer_options; ?> 297 301 ) … … 300 304 layers: [base], 301 305 attributionControl: false 302 }, 303 <?php echo $map_options; ?>, 306 }, 307 <?php echo $map_options; ?>, 304 308 <?php echo $raw_map_options; ?> 305 309 ); 306 window.WPLeafletMapPlugin.createMap(options).setView(<?php 307 echo '[' . $lat . ',' . $lng . '],' . $zoom; 310 window.WPLeafletMapPlugin.createMap(options).setView(<?php 311 echo '[' . $lat . ',' . $lng . '],' . $zoom; 308 312 ?>);<?php 309 313 -
leaflet-map/tags/3.3.1/shortcodes/class.marker-shortcode.php
r2863840 r2968965 4 4 * 5 5 * Use with [leaflet-marker ...] 6 * 6 * 7 7 * @category Shortcode 8 8 * @author Benjamin J DeLong <ben@bozdoz.com> … … 23 23 /** 24 24 * Get Script for Shortcode 25 * 25 * 26 26 * @param string $atts could be an array 27 27 * @param string $content optional 28 * 28 * 29 29 * @return null 30 30 */ … … 87 87 $args = array( 88 88 'draggable' => FILTER_VALIDATE_BOOLEAN, 89 'title' => FILTER_SANITIZE_ FULL_SPECIAL_CHARS,89 'title' => FILTER_SANITIZE_SPECIAL_CHARS, 90 90 'alt' => FILTER_SANITIZE_FULL_SPECIAL_CHARS, 91 91 'zIndexOffset' => FILTER_VALIDATE_INT, … … 113 113 var marker_options = window.WPLeafletMapPlugin.getIconOptions(<?php echo $options; ?>); 114 114 var marker = <?php echo $default_marker; ?>( 115 [<?php echo $lat . ',' . $lng; ?>], 115 [<?php echo $lat . ',' . $lng; ?>], 116 116 marker_options 117 117 ); … … 143 143 window.WPLeafletMapPlugin.markers.push( marker ); 144 144 <?php 145 145 146 146 $script = ob_get_clean(); 147 147 -
leaflet-map/trunk/class.leaflet-map.php
r2871359 r2968965 23 23 * @var string major minor patch version 24 24 */ 25 public static $leaflet_version = '1.9. 3';25 public static $leaflet_version = '1.9.4'; 26 26 27 27 /** -
leaflet-map/trunk/leaflet-map.php
r2871359 r2968965 9 9 * Text Domain: leaflet-map 10 10 * Domain Path: /languages/ 11 * Version: 3.3. 011 * Version: 3.3.1 12 12 * License: GPL2 13 13 * Leaflet Map is free software: you can redistribute it and/or modify … … 30 30 } 31 31 32 define('LEAFLET_MAP__PLUGIN_VERSION', '3.3. 0');32 define('LEAFLET_MAP__PLUGIN_VERSION', '3.3.1'); 33 33 define('LEAFLET_MAP__PLUGIN_FILE', __FILE__); 34 34 define('LEAFLET_MAP__PLUGIN_DIR', plugin_dir_path(__FILE__)); -
leaflet-map/trunk/readme.txt
r2871359 r2968965 7 7 Tags: leaflet, map, mobile, javascript, openstreetmap, mapquest, interactive 8 8 Requires at least: 4.6 9 Tested up to: 6. 1.110 Version: 3.3. 011 Stable tag: 3.3. 09 Tested up to: 6.3.1 10 Version: 3.3.1 11 Stable tag: 3.3.1 12 12 License: GPLv2 13 13 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 149 149 150 150 == Changelog == 151 152 = 3.3.1 = 153 * [Update] Default Leaflet map set at v1.9.4 154 * [Security] Escapes geojson popup properties to prevent XSS attacks 155 * [Bug] Updates "!attribution" or "attribution=0" attributes to actually remove attribution 156 * [Bug] Switches SANITIZE_FULL with SANITIZE to to allow "German umlauts" 157 * [Bug] Fixes some issues when a map's max zoom differs from a tile layer's max zoom 151 158 152 159 = 3.3.0 = … … 461 468 == Upgrade Notice == 462 469 470 = 3.3.1 = 471 * Escapes geojson popup properties to prevent XSS attacks 472 463 473 = 3.2.0 = 464 474 * Fixes error if geocoder fails to get a lat/lng -
leaflet-map/trunk/scripts/construct-leaflet-map.min.js
r2871359 r2968965 1 !function(){var t=window.WPLeafletMapPlugin;if(window.WPLeafletMapPlugin=new function(){function t(t){try{t()}catch(t){console.log("-- version --","v3.3. 0"),console.error(t)}}this.VERSION="v3.3.0";var n=!1,i=[];this.push=function(r){n?t(r):i.push(r)},this.unshift=function(r){n?t(r):i.unshift(r)},this.init=function(){n=!0;for(var r=0,e=i.length;r<e;r++)t(i[r])},this.createMap=function(t){var n=document.getElementsByClassName("WPLeafletMap")[this.maps.length],i=L.map(n,t);return t.fitBounds&&(i._shouldFitBounds=!0),t.attribution&&function(t,n){if(!t)return;for(var i=t.split(";"),r=L.control.attribution({prefix:!1}).addTo(n),e=0,o=i.length;e<o;e++){var a=(s=i[e]).trim?s.trim():s.replace(/^\s+|\s+$/gm,"");r.addAttribution(a)}var s}(t.attribution,i),this.maps.push(i),i},this.createImageMap=function(t){var n=this.createMap(t);return n.is_image_map=!0,this.images.push(n),n},this.getCurrentMap=function(){return this.maps[this.maps.length-1]},this.getCurrentGroup=function(){var t=this.maps.length;return this.markergroups[t]||(this.markergroups[t]=this.newMarkerGroup(this.maps[t-1])),this.markergroups[t]},this.getCurrentMarkerGroup=this.getCurrentGroup,this.getGroup=function(t){return(new L.FeatureGroup).addTo(t)},this.newMarkerGroup=function(t){var n=this.getGroup(t);return n.timeout=null,t._shouldFitBounds&&n.on("layeradd",(function(i){i.layer instanceof L.FeatureGroup&&i.layer.on("ready",(function(){t.fitBounds(n.getBounds())})),window.clearTimeout(this.timeout),this.timeout=window.setTimeout((function(){try{t.fitBounds(n.getBounds())}catch(t){}}),100)}),n),n},this.propsToTable=function(t){var n,i=[];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.push(n);for(var r="<table>",e=0,o=(i=i.sort()).length;e<o;e++){var a=i[e];r+="<tr><td>"+a+"</td>",r+="<td>"+t[a]+"</td></tr>"}return r+="</table>"};var r=this.unescape=function(t){var n=document.createElement("div");return n.innerHTML=t,n.innerText||t},e=/\{ *(.*?) *\}/g;this.template=function(t,n){return null==n?t:t.replace(e,(function(t,i){var e=function(t){for(var n=t.split(" | "),i={},r=n.shift(),e=0,o=n.length;e<o;e++){var a=n[e].split(": "),s=a.shift(),u=a.join(": ")||!0;i[s]=u}return i.key=r,i}(i),a=function(t,n){for(var i=function(t){if(null==t)return[];for(var n=t.split(o),i=[],r=0,e=n.length;r<e;r++)""!==n[r]&&i.push(n[r]);return i}(r(n)),e=t,a=0,s=i.length;a<s;a++)if(!(e=e[i[a]]))return;return e}(n,e.key);return null==a?e.default||t:a}))};var o=/[.‘’'“”"\[\]]+/g;function a(t,n){"undefined"!=typeof L&&void 0!==L[t]?n():setTimeout((function(){a(t,n)}),100)}this.waitForSVG=function(t){a("SVGIcon",t)},this.waitForAjax=function(t){a("AjaxGeoJSON",t)},this.createScale=function(t){L.control.scale(t).addTo(this.getCurrentMap())},this.getIconOptions=function(t){for(var n,i=t||{},r=["iconSize","iconAnchor","shadowSize","shadowAnchor","popupAnchor","tooltipAnchor"],e=L.Icon.Default.prototype.options,o=0,a=r.length;o<a;o++){var s=r[o],u=i[s];if(u){for(var h=u.split(","),c=0,l=h.length;c<l;c++)h[c]=Number(h[c]);i[s]=h}}return i.popupAnchor||(i.popupAnchor=((n=(n=i.iconSize||e.iconSize).slice())[0]=0,n[1]*=-1,n[1]-=3,n)),i.iconUrl&&(i.icon=new L.Icon(i)),i},this.maps=[],this.images=[],this.markergroups={},this.markers=[],this.lines=[],this.polygons=[],this.circles=[],this.geojsons=[],this.overlays=[]},t){for(var n=0,i=t.length;n<i;n++)window.WPLeafletMapPlugin.push(t[n]);for(var r in t.splice(0),t)t.hasOwnProperty(r)&&(window.WPLeafletMapPlugin[r]=t[r])}window.addEventListener?window.addEventListener("load",window.WPLeafletMapPlugin.init,!1):window.attachEvent&&window.attachEvent("onload",window.WPLeafletMapPlugin.init)}();1 !function(){var t=window.WPLeafletMapPlugin;if(window.WPLeafletMapPlugin=new function(){function t(t){try{t()}catch(t){console.log("-- version --","v3.3.1"),console.error(t)}}this.VERSION="v3.3.1";var n=!1,i=[];this.push=function(r){n?t(r):i.push(r)},this.unshift=function(r){n?t(r):i.unshift(r)},this.init=function(){n=!0;for(var r=0,e=i.length;r<e;r++)t(i[r])},this.createMap=function(t){var n=document.getElementsByClassName("WPLeafletMap")[this.maps.length],i=L.map(n,t);return t.fitBounds&&(i._shouldFitBounds=!0),t.attribution&&function(t,n){if(!t)return;for(var i=t.split(";"),r=L.control.attribution({prefix:!1}).addTo(n),e=0,o=i.length;e<o;e++){var a=(s=i[e]).trim?s.trim():s.replace(/^\s+|\s+$/gm,"");r.addAttribution(a)}var s}(t.attribution,i),this.maps.push(i),i},this.createImageMap=function(t){var n=this.createMap(t);return n.is_image_map=!0,this.images.push(n),n},this.getCurrentMap=function(){return this.maps[this.maps.length-1]},this.getCurrentGroup=function(){var t=this.maps.length;return this.markergroups[t]||(this.markergroups[t]=this.newMarkerGroup(this.maps[t-1])),this.markergroups[t]},this.getCurrentMarkerGroup=this.getCurrentGroup,this.getGroup=function(t){return(new L.FeatureGroup).addTo(t)},this.newMarkerGroup=function(t){var n=this.getGroup(t);return n.timeout=null,t._shouldFitBounds&&n.on("layeradd",(function(i){i.layer instanceof L.FeatureGroup&&i.layer.on("ready",(function(){t.fitBounds(n.getBounds())})),window.clearTimeout(this.timeout),this.timeout=window.setTimeout((function(){try{t.fitBounds(n.getBounds())}catch(t){}}),100)}),n),n},this.propsToTable=function(t){var n,i=[];for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&i.push(n);for(var r="<table>",e=0,o=(i=i.sort()).length;e<o;e++){var a=i[e];r+="<tr><td>"+a+"</td>",r+="<td>"+t[a]+"</td></tr>"}return r+="</table>"};var r=this.unescape=function(t){var n=document.createElement("div");return n.innerHTML=t,n.innerText||t},e=/\{ *(.*?) *\}/g;this.template=function(t,n){return null==n?t:t.replace(e,(function(t,i){var e=function(t){for(var n=t.split(" | "),i={},r=n.shift(),e=0,o=n.length;e<o;e++){var a=n[e].split(": "),s=a.shift(),u=a.join(": ")||!0;i[s]=u}return i.key=r,i}(i),a=function(t,n){for(var i=function(t){if(null==t)return[];for(var n=t.split(o),i=[],r=0,e=n.length;r<e;r++)""!==n[r]&&i.push(n[r]);return i}(r(n)),e=t,a=0,s=i.length;a<s;a++)if(!(e=e[i[a]]))return;return e}(n,e.key);return null==a?e.default||t:a}))};var o=/[.‘’'“”"\[\]]+/g;function a(t,n){"undefined"!=typeof L&&void 0!==L[t]?n():setTimeout((function(){a(t,n)}),100)}this.waitForSVG=function(t){a("SVGIcon",t)},this.waitForAjax=function(t){a("AjaxGeoJSON",t)},this.createScale=function(t){L.control.scale(t).addTo(this.getCurrentMap())},this.getIconOptions=function(t){for(var n,i=t||{},r=["iconSize","iconAnchor","shadowSize","shadowAnchor","popupAnchor","tooltipAnchor"],e=L.Icon.Default.prototype.options,o=0,a=r.length;o<a;o++){var s=r[o],u=i[s];if(u){for(var h=u.split(","),c=0,l=h.length;c<l;c++)h[c]=Number(h[c]);i[s]=h}}return i.popupAnchor||(i.popupAnchor=((n=(n=i.iconSize||e.iconSize).slice())[0]=0,n[1]*=-1,n[1]-=3,n)),i.iconUrl&&(i.icon=new L.Icon(i)),i},this.maps=[],this.images=[],this.markergroups={},this.markers=[],this.lines=[],this.polygons=[],this.circles=[],this.geojsons=[],this.overlays=[]},t){for(var n=0,i=t.length;n<i;n++)window.WPLeafletMapPlugin.push(t[n]);for(var r in t.splice(0),t)t.hasOwnProperty(r)&&(window.WPLeafletMapPlugin[r]=t[r])}window.addEventListener?window.addEventListener("load",window.WPLeafletMapPlugin.init,!1):window.attachEvent&&window.attachEvent("onload",window.WPLeafletMapPlugin.init)}(); -
leaflet-map/trunk/shortcodes/class.geojson-shortcode.php
r2863840 r2968965 121 121 var fitbounds = <?php echo $fitbounds ? '1' : '0'; ?>; 122 122 var circleMarker = <?php echo $circleMarker ? '1' : '0'; ?>; 123 var popup_text = window.WPLeafletMapPlugin.unescape("<?php echo $popup_text; ?>"); 124 var popup_property = "<?php echo $popup_property; ?>"; 123 var popup_text = window.WPLeafletMapPlugin.unescape("<?php echo esc_js( 124 $popup_text 125 ); ?>"); 126 var popup_property = "<?php echo esc_js($popup_property); ?>"; 125 127 var group = window.WPLeafletMapPlugin.getCurrentGroup(); 126 128 var markerOptions = window.WPLeafletMapPlugin.getIconOptions(<?php echo $options; ?>); -
leaflet-map/trunk/shortcodes/class.map-shortcode.php
r2863840 r2968965 3 3 * Map Shortcode 4 4 * 5 * Displays map with [leaflet-map ...atts] 5 * Displays map with [leaflet-map ...atts] 6 6 * 7 7 * JavaScript equivalent : L.map("id"); 8 * 8 * 9 9 * @category Shortcode 10 10 * @author Benjamin J DeLong <ben@bozdoz.com> … … 14 14 if (!defined('ABSPATH')) { 15 15 exit; 16 } 16 } 17 17 18 18 require_once LEAFLET_MAP__PLUGIN_DIR . 'shortcodes/class.shortcode.php'; … … 34 34 35 35 /** 36 * Enqueue Scripts and Styles for Leaflet 37 * 36 * Enqueue Scripts and Styles for Leaflet 37 * 38 38 * @return null 39 39 */ … … 48 48 } 49 49 50 // enqueue user-defined scripts 50 // enqueue user-defined scripts 51 51 // ! will fire for each map 52 52 do_action('leaflet_map_enqueue'); … … 56 56 * Merge shortcode options with default options 57 57 * 58 * @param array|string $atts key value pairs from shortcode 59 * 58 * @param array|string $atts key value pairs from shortcode 59 * 60 60 * @return array new atts, which is actually an array 61 61 */ … … 67 67 $settings = Leaflet_Map_Plugin_Settings::init(); 68 68 69 $atts['zoom'] = array_key_exists('zoom', $atts) ? 69 $atts['zoom'] = array_key_exists('zoom', $atts) ? 70 70 $zoom : $settings->get('default_zoom'); 71 $atts['height'] = empty($height) ? 71 $atts['height'] = empty($height) ? 72 72 $settings->get('default_height') : $height; 73 73 $atts['width'] = empty($width) ? $settings->get('default_width') : $width; 74 $atts['zoomcontrol'] = isset($zoomControl) 74 $atts['zoomcontrol'] = isset($zoomControl) 75 75 ? $zoomControl 76 : (array_key_exists('zoomcontrol', $atts) 77 ? $zoomcontrol 76 : (array_key_exists('zoomcontrol', $atts) 77 ? $zoomcontrol 78 78 : $settings->get('show_zoom_controls')); 79 $atts['min_zoom'] = array_key_exists('min_zoom', $atts) ? 79 $atts['min_zoom'] = array_key_exists('min_zoom', $atts) ? 80 80 $min_zoom : $settings->get('default_min_zoom'); 81 $atts['max_zoom'] = empty($max_zoom) ? 81 $atts['max_zoom'] = empty($max_zoom) ? 82 82 $settings->get('default_max_zoom') : $max_zoom; 83 83 $atts['scrollwheel'] = isset($scrollWheelZoom) 84 84 ? $scrollWheelZoom 85 : (array_key_exists('scrollwheel', $atts) 86 ? $scrollwheel 85 : (array_key_exists('scrollwheel', $atts) 86 ? $scrollwheel 87 87 : $settings->get('scroll_wheel_zoom')); 88 $atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ? 88 $atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ? 89 89 $doubleclickzoom : $settings->get('double_click_zoom'); 90 90 91 91 // @deprecated backwards-compatible fit_markers 92 $atts['fit_markers'] = array_key_exists('fit_markers', $atts) ? 92 $atts['fit_markers'] = array_key_exists('fit_markers', $atts) ? 93 93 $fit_markers : $settings->get('fit_markers'); 94 94 95 95 // fitbounds is what it should be called @since v2.12.0 96 $atts['fitbounds'] = array_key_exists('fitbounds', $atts) ? 96 $atts['fitbounds'] = array_key_exists('fitbounds', $atts) ? 97 97 $fitbounds : $atts['fit_markers']; 98 98 99 99 /* allow percent, but add px for ints */ 100 100 $atts['height'] .= is_numeric($atts['height']) ? 'px' : ''; 101 $atts['width'] .= is_numeric($atts['width']) ? 'px' : ''; 102 103 /* 104 need to allow 0 or empty for removal of attribution 101 $atts['width'] .= is_numeric($atts['width']) ? 'px' : ''; 102 103 /* 104 need to allow 0 or empty for removal of attribution 105 105 */ 106 106 if (!array_key_exists('attribution', $atts)) { … … 114 114 ? $closePopupOnClick 115 115 : (isset($closepopuponclick) 116 ? $closepopuponclick 116 ? $closepopuponclick 117 117 : null), 118 'trackResize' => isset($trackResize) 118 'trackResize' => isset($trackResize) 119 119 ? $trackResize 120 : (isset($trackresize) 121 ? $trackresize 120 : (isset($trackresize) 121 ? $trackresize 122 122 : null), 123 'boxZoom' => isset($boxzoom) 124 ? $boxzoom 123 'boxZoom' => isset($boxzoom) 124 ? $boxzoom 125 125 : (isset($boxZoom) 126 126 ? $boxZoom … … 144 144 // filter out nulls 145 145 $map_options = $this->LM->filter_null($map_options); 146 146 147 147 // custom field for moving to JavaScript 148 148 $map_options['fitBounds'] = $atts['fitbounds']; … … 171 171 // custom field for moving to javascript 172 172 // filter out any unwanted HTML tags (including img) 173 $map_options['attribution'] = wp_kses_post($atts['attribution']); 174 173 if ($atts['attribution'] !== 0) { 174 $map_options['attribution'] = wp_kses_post($atts['attribution']); 175 } 176 175 177 // wrap as JSON 176 178 $atts['map_options'] = json_encode($map_options); … … 180 182 foreach($map_options as $key=>$val) { 181 183 $original_value = isset($atts[$key]) ? $atts[$key] : null; 182 184 183 185 $liquid = $this->LM->liquid($original_value); 184 186 … … 197 199 'accessToken' => empty($accesstoken) ? $settings->get('accesstoken') : $accesstoken, 198 200 'zoomOffset' => empty($zoomoffset) ? $settings->get('zoomoffset') : $zoomoffset, 199 'noWrap' => filter_var(empty($nowrap) ? $settings->get('tile_no_wrap') : $nowrap, FILTER_VALIDATE_BOOLEAN) 200 ); 201 201 'noWrap' => filter_var(empty($nowrap) ? $settings->get('tile_no_wrap') : $nowrap, FILTER_VALIDATE_BOOLEAN), 202 'maxZoom' => $atts['maxZoom'] 203 ); 204 205 202 206 $tile_layer_options = $this->LM->filter_empty_string($tile_layer_options); 203 207 $tile_layer_options = $this->LM->filter_null($tile_layer_options); … … 218 222 219 223 $atts = $this->LM->sanitize_inclusive($atts, $validations); 220 224 221 225 return $atts; 222 226 } … … 224 228 /** 225 229 * Get the div tag for the map to instantiate 226 * 230 * 227 231 * @param string $height 228 232 * @param string $width 229 * 233 * 230 234 * @return string HTML div element 231 235 */ … … 234 238 ob_start(); 235 239 ?> 236 <div class="leaflet-map WPLeafletMap" style="height:<?php 240 <div class="leaflet-map WPLeafletMap" style="height:<?php 237 241 echo htmlspecialchars($height); 238 ?>; width:<?php 242 ?>; width:<?php 239 243 echo htmlspecialchars($width); 240 244 ?>;"></div><?php … … 244 248 /** 245 249 * Get script for shortcode 246 * 250 * 247 251 * @param array $atts sometimes this is null 248 252 * @param string $content anything within a shortcode 249 * 253 * 250 254 * @return string HTML 251 255 */ … … 267 271 $lat = isset($lat) ? $lat : $settings->get('default_lat'); 268 272 $lng = isset($lng) ? $lng : $settings->get('default_lng'); 269 273 270 274 // validate lat/lng 271 275 $lat = $this->LM->filter_float($lat); … … 280 284 $tileurl = empty($tileurl) ? $settings->get('map_tile_url') : $tileurl; 281 285 } 282 286 283 287 $detect_retina = empty($detect_retina) ? $settings->get('detect_retina') : $detect_retina; 284 288 … … 286 290 287 291 /* should be iterated for multiple maps */ 288 ob_start(); 292 ob_start(); 289 293 ?>/*<script>*/ 290 294 var baseUrl = atob('<?php echo base64_encode(filter_var($tileurl, FILTER_SANITIZE_URL)); ?>'); 291 var base = (!baseUrl && window.MQ) ? 292 window.MQ.mapLayer() : L.tileLayer(baseUrl, 295 var base = (!baseUrl && window.MQ) ? 296 window.MQ.mapLayer() : L.tileLayer(baseUrl, 293 297 L.Util.extend({}, { 294 298 detectRetina: <?php echo $detect_retina ? '1' : '0'; ?>, 295 }, 299 }, 296 300 <?php echo $tile_layer_options; ?> 297 301 ) … … 300 304 layers: [base], 301 305 attributionControl: false 302 }, 303 <?php echo $map_options; ?>, 306 }, 307 <?php echo $map_options; ?>, 304 308 <?php echo $raw_map_options; ?> 305 309 ); 306 window.WPLeafletMapPlugin.createMap(options).setView(<?php 307 echo '[' . $lat . ',' . $lng . '],' . $zoom; 310 window.WPLeafletMapPlugin.createMap(options).setView(<?php 311 echo '[' . $lat . ',' . $lng . '],' . $zoom; 308 312 ?>);<?php 309 313 -
leaflet-map/trunk/shortcodes/class.marker-shortcode.php
r2863840 r2968965 4 4 * 5 5 * Use with [leaflet-marker ...] 6 * 6 * 7 7 * @category Shortcode 8 8 * @author Benjamin J DeLong <ben@bozdoz.com> … … 23 23 /** 24 24 * Get Script for Shortcode 25 * 25 * 26 26 * @param string $atts could be an array 27 27 * @param string $content optional 28 * 28 * 29 29 * @return null 30 30 */ … … 87 87 $args = array( 88 88 'draggable' => FILTER_VALIDATE_BOOLEAN, 89 'title' => FILTER_SANITIZE_ FULL_SPECIAL_CHARS,89 'title' => FILTER_SANITIZE_SPECIAL_CHARS, 90 90 'alt' => FILTER_SANITIZE_FULL_SPECIAL_CHARS, 91 91 'zIndexOffset' => FILTER_VALIDATE_INT, … … 113 113 var marker_options = window.WPLeafletMapPlugin.getIconOptions(<?php echo $options; ?>); 114 114 var marker = <?php echo $default_marker; ?>( 115 [<?php echo $lat . ',' . $lng; ?>], 115 [<?php echo $lat . ',' . $lng; ?>], 116 116 marker_options 117 117 ); … … 143 143 window.WPLeafletMapPlugin.markers.push( marker ); 144 144 <?php 145 145 146 146 $script = ob_get_clean(); 147 147
Note: See TracChangeset
for help on using the changeset viewer.