From a8cb11641e320b0bd23634d16873899db157ef71 Mon Sep 17 00:00:00 2001 From: bozdoz Date: Mon, 12 Sep 2022 23:32:05 -0300 Subject: [PATCH] let subdomains be comma-separated; resolves #147 --- class.plugin-settings.php | 2 +- shortcodes/class.map-shortcode.php | 5 +++++ templates/shortcode-helper.php | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/class.plugin-settings.php b/class.plugin-settings.php index aa5f0bb..ad40165 100644 --- a/class.plugin-settings.php +++ b/class.plugin-settings.php @@ -231,7 +231,7 @@ private function __construct() 'type' => 'text', 'helptext' => sprintf( '%1$s %2$s
[leaflet-map subdomains="1234"]', - __('Some maps get tiles from multiple servers with subdomains such as a,b,c,d or 1,2,3,4', 'leaflet-map'), + __('Some maps get tiles from multiple servers with subdomains such as a,b,c or 1,2,3 or cache1,cache2; pass a string where each char is its own subdomain, or pass comma-separated string', 'leaflet-map'), $foreachmap ) ), diff --git a/shortcodes/class.map-shortcode.php b/shortcodes/class.map-shortcode.php index a55171c..32b7428 100644 --- a/shortcodes/class.map-shortcode.php +++ b/shortcodes/class.map-shortcode.php @@ -202,6 +202,11 @@ protected function getAtts($atts='') $tile_layer_options = $this->LM->filter_empty_string($tile_layer_options); $tile_layer_options = $this->LM->filter_null($tile_layer_options); + if (strpos($tile_layer_options['subdomains'], ',') !== false) { + // subdomains can be comma-separated + $tile_layer_options['subdomains'] = explode(',', $tile_layer_options['subdomains']); + } + $atts['tile_layer_options'] = json_encode($tile_layer_options, JSON_NUMERIC_CHECK | JSON_UNESCAPED_SLASHES); // TODO: find a better way to do this diff --git a/templates/shortcode-helper.php b/templates/shortcode-helper.php index 5fd7761..fd30548 100644 --- a/templates/shortcode-helper.php +++ b/templates/shortcode-helper.php @@ -72,7 +72,7 @@ '[leaflet-map zoom=10 lat=48.855 lng=2.35 zoomcontrol !detect-retina]', ), __("Alternate Map Tiles w/scrollwheel", 'leaflet-map') => array( - '[leaflet-map zoom=2 scrollwheel lat=-2.507 lng=32.902 tileurl=https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg subdomains=abcd attribution="Map tiles by Stamen Design, under CC BY 3.0."]', + '[leaflet-map zoom=2 scrollwheel lat=-2.507 lng=32.902 tileurl=https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg subdomains=a,b,c,d attribution="Map tiles by Stamen Design, under CC BY 3.0."]', ), __("Marker Popup Messages (on click)", 'leaflet-map') => array( '[leaflet-map lat=59.913 lng=10.739 zoom=12]',