diff --git a/readme.txt b/readme.txt index 062d9fe..2c9c628 100644 --- a/readme.txt +++ b/readme.txt @@ -66,7 +66,7 @@ Add a line to the map by adding `[leaflet-line]`. You can specify the postions w Add a circle to the map by adding `[leaflet-circle]`. You can specify the position using `lat` and `lng` and the radius in meters using `radius`. You can also customize the style using [Leaflet's Path options](https://leafletjs.com/reference.html#path-option). Example: `[leaflet-circle message="max distance" lng=5.117909610271454 lat=52.097914814706094 radius=17500 color="#0DC143" fillOpacity=0.1]`. -Or you can add a geojson shape via a url (make sure you are allowed to access it if it's not hosted on your own server): `[leaflet-geojson src="https://example.com/path/to.geojson"]`. Add custom popups with field names; try out the default src file and fields like so: +Or you can add a geojson shape via a url (make sure you are allowed to access it if it's not hosted on your own server): `[leaflet-geojson src="https://example.com/path/to.geojson"]`. Add custom popups with field names; try out the default src file and fields like so: ` [leaflet-map fitbounds] @@ -177,7 +177,7 @@ For more FAQs, please visit the [FAQ section on GitHub here](https://github.com/ * actual bugfix to multiple or missing enqueue map scripts = 2.23.1 = -* possible bugfix to failing to enqueue map when shortcode rendered +* possible bugfix to failing to enqueue map when shortcode rendered = 2.23.0 = * Added iconUrl to leaflet-geojson shortcode. @@ -294,7 +294,7 @@ For more FAQs, please visit the [FAQ section on GitHub here](https://github.com/ * Added string interpolation for GeoJSON popups to use feature properties (thanks to [@geraldo](https://github.com/geraldo)) = 2.9.1 = -* Fixes for PHP 7.2: made all method arguments identical +* Fixes for PHP 7.2: made all method arguments identical * Added minified JavaScript files for site speed = 2.8.6 = @@ -355,13 +355,13 @@ For more FAQs, please visit the [FAQ section on GitHub here](https://github.com/ * Added basic marker icon support (with attributes "iconUrl", "iconAnchor", etc.); = 2.6.0 = -* Changes to map creation which may solve an occasional marker creation JavaScript error +* Changes to map creation which may solve an occasional marker creation JavaScript error * Added more attributes to marker shortcode (draggable, title, alt, opacity) * Added doubleClickZoom global, database option to globally disable double click zooming (by default), because it's more inline with disabling scroll zooming by default. Box zooming on the other hand is more intentional = 2.5.0 = -* Some improvements to the codebase; -* added the same styling options for lines as there are for geojson; +* Some improvements to the codebase; +* added the same styling options for lines as there are for geojson; * added popups to lines, as there are for markers; * added an example to the shortcode admin page for the style attributes on lines; * added code and another example for disabling all map interactions (all zooms, keyboard, etc); @@ -553,7 +553,7 @@ Fixed array_filter on some older PHP versions Fixed possible JavaScript error "Unexpected token <"; fix was to remove spaces = 2.6.0 = -Changes to map creation which may solve an occasional marker creation JavaScript error +Changes to map creation which may solve an occasional marker creation JavaScript error = 2.0.2 = OpenStreetMap.org has an SSL certificate (osm.org didn't) diff --git a/shortcodes/class.map-shortcode.php b/shortcodes/class.map-shortcode.php index bd2e748..d4fd90d 100644 --- a/shortcodes/class.map-shortcode.php +++ b/shortcodes/class.map-shortcode.php @@ -2,10 +2,10 @@ /** * Map Shortcode * - * Displays map with [leaflet-map ...atts] + * Displays map with [leaflet-map ...atts] * * JavaScript equivalent : L.map("id"); - * + * * @category Shortcode * @author Benjamin J DeLong */ @@ -13,7 +13,7 @@ // Exit if accessed directly if (!defined('ABSPATH')) { exit; -} +} require_once LEAFLET_MAP__PLUGIN_DIR . 'shortcodes/class.shortcode.php'; @@ -33,8 +33,8 @@ public function __construct() } /** - * Enqueue Scripts and Styles for Leaflet - * + * Enqueue Scripts and Styles for Leaflet + * * @return null */ protected function enqueue() @@ -47,7 +47,7 @@ protected function enqueue() wp_enqueue_script('leaflet_mapquest_plugin'); } - // enqueue user-defined scripts + // enqueue user-defined scripts // ! will fire for each map do_action('leaflet_map_enqueue'); } @@ -55,8 +55,8 @@ protected function enqueue() /** * Merge shortcode options with default options * - * @param array|string $atts key value pairs from shortcode - * + * @param array|string $atts key value pairs from shortcode + * * @return array new atts, which is actually an array */ protected function getAtts($atts='') @@ -66,42 +66,42 @@ protected function getAtts($atts='') $settings = Leaflet_Map_Plugin_Settings::init(); - $atts['zoom'] = array_key_exists('zoom', $atts) ? + $atts['zoom'] = array_key_exists('zoom', $atts) ? $zoom : $settings->get('default_zoom'); - $atts['height'] = empty($height) ? + $atts['height'] = empty($height) ? $settings->get('default_height') : $height; $atts['width'] = empty($width) ? $settings->get('default_width') : $width; - $atts['zoomcontrol'] = isset($zoomControl) + $atts['zoomcontrol'] = isset($zoomControl) ? $zoomControl - : (array_key_exists('zoomcontrol', $atts) - ? $zoomcontrol + : (array_key_exists('zoomcontrol', $atts) + ? $zoomcontrol : $settings->get('show_zoom_controls')); - $atts['min_zoom'] = array_key_exists('min_zoom', $atts) ? + $atts['min_zoom'] = array_key_exists('min_zoom', $atts) ? $min_zoom : $settings->get('default_min_zoom'); - $atts['max_zoom'] = empty($max_zoom) ? + $atts['max_zoom'] = empty($max_zoom) ? $settings->get('default_max_zoom') : $max_zoom; $atts['scrollwheel'] = isset($scrollWheelZoom) ? $scrollWheelZoom - : (array_key_exists('scrollwheel', $atts) - ? $scrollwheel + : (array_key_exists('scrollwheel', $atts) + ? $scrollwheel : $settings->get('scroll_wheel_zoom')); - $atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ? + $atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ? $doubleclickzoom : $settings->get('double_click_zoom'); - + // @deprecated backwards-compatible fit_markers - $atts['fit_markers'] = array_key_exists('fit_markers', $atts) ? + $atts['fit_markers'] = array_key_exists('fit_markers', $atts) ? $fit_markers : $settings->get('fit_markers'); // fitbounds is what it should be called @since v2.12.0 - $atts['fitbounds'] = array_key_exists('fitbounds', $atts) ? + $atts['fitbounds'] = array_key_exists('fitbounds', $atts) ? $fitbounds : $atts['fit_markers']; /* allow percent, but add px for ints */ $atts['height'] .= is_numeric($atts['height']) ? 'px' : ''; - $atts['width'] .= is_numeric($atts['width']) ? 'px' : ''; + $atts['width'] .= is_numeric($atts['width']) ? 'px' : ''; - /* - need to allow 0 or empty for removal of attribution + /* + need to allow 0 or empty for removal of attribution */ if (!array_key_exists('attribution', $atts)) { $atts['attribution'] = $settings->get('default_attribution'); @@ -113,15 +113,15 @@ protected function getAtts($atts='') 'closePopupOnClick' => isset($closePopupOnClick) ? $closePopupOnClick : (isset($closepopuponclick) - ? $closepopuponclick + ? $closepopuponclick : null), - 'trackResize' => isset($trackResize) + 'trackResize' => isset($trackResize) ? $trackResize - : (isset($trackresize) - ? $trackresize + : (isset($trackresize) + ? $trackresize : null), - 'boxZoom' => isset($boxzoom) - ? $boxzoom + 'boxZoom' => isset($boxzoom) + ? $boxzoom : (isset($boxZoom) ? $boxZoom : null), @@ -143,7 +143,7 @@ protected function getAtts($atts='') // filter out nulls $map_options = $this->LM->filter_null($map_options); - + // custom field for moving to JavaScript $map_options['fitBounds'] = $atts['fitbounds']; @@ -171,7 +171,7 @@ protected function getAtts($atts='') // custom field for moving to javascript // filter out any unwanted HTML tags (including img) $map_options['attribution'] = wp_kses_post($atts['attribution']); - + // wrap as JSON $atts['map_options'] = json_encode($map_options); @@ -179,7 +179,7 @@ protected function getAtts($atts='') $raw_map_options = array(); foreach($map_options as $key=>$val) { $original_value = isset($atts[$key]) ? $atts[$key] : null; - + $liquid = $this->LM->liquid($original_value); if ($liquid && isset($liquid['raw']) && $liquid['raw']) { @@ -198,7 +198,7 @@ protected function getAtts($atts='') 'zoomOffset' => empty($zoomoffset) ? $settings->get('zoomoffset') : $zoomoffset, 'noWrap' => filter_var(empty($nowrap) ? $settings->get('tile_no_wrap') : $nowrap, FILTER_VALIDATE_BOOLEAN) ); - + $tile_layer_options = $this->LM->filter_empty_string($tile_layer_options); $tile_layer_options = $this->LM->filter_null($tile_layer_options); @@ -217,25 +217,25 @@ protected function getAtts($atts='') ); $atts = $this->LM->sanitize_inclusive($atts, $validations); - + return $atts; } /** * Get the div tag for the map to instantiate - * + * * @param string $height * @param string $width - * + * * @return string HTML div element */ protected function getDiv($height, $width) { // div does not get wrapped in script tags ob_start(); ?> -
get('default_lat'); $lng = isset($lng) ? $lng : $settings->get('default_lng'); - + // validate lat/lng $lat = $this->LM->filter_float($lat); $lng = $this->LM->filter_float($lng); @@ -279,14 +279,14 @@ protected function getHTML($atts='', $content=null) } else { $tileurl = empty($tileurl) ? $settings->get('map_tile_url') : $tileurl; } - + $detect_retina = empty($detect_retina) ? $settings->get('detect_retina') : $detect_retina; $detect_retina = filter_var($detect_retina, FILTER_VALIDATE_BOOLEAN); $tile_min_zoom = $minZoom; $tile_max_zoom = $maxZoom; - + // fix #114 tilelayer zoom with detect_retina if ($detect_retina && $minZoom == $maxZoom) { $tile_min_zoom = 'undefined'; @@ -294,28 +294,28 @@ protected function getHTML($atts='', $content=null) } /* should be iterated for multiple maps */ - ob_start(); + ob_start(); ?>/*