forked from bozdoz/wp-plugin-leaflet-map
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:bozdoz/wp-plugin-leaflet-map
- Loading branch information
Showing
7 changed files
with
195 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,6 +405,7 @@ | |
this.polygons = []; | ||
this.circles = []; | ||
this.geojsons = []; | ||
this.overlays = []; | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
/** | ||
* Image Overlay Shortcode | ||
* | ||
* Use with [leaflet-image-overlay ...] | ||
* | ||
* @category Shortcode | ||
* @author Luca Cireddu <[email protected]> | ||
*/ | ||
|
||
// Exit if accessed directly | ||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
|
||
require_once LEAFLET_MAP__PLUGIN_DIR . 'shortcodes/class.shortcode.php'; | ||
|
||
class Leaflet_Image_Overlay_Shortcode extends Leaflet_Shortcode | ||
{ | ||
protected $type = 'L.imageOverlay'; | ||
protected $default_src = 'https://maps.lib.utexas.edu/maps/historical/newark_nj_1922.jpg'; | ||
protected $default_bounds = "40.712216,-74.22655;40.773941,-74.12544"; | ||
|
||
/** | ||
* Get Script for Shortcode | ||
* | ||
* @param string $atts could be an array | ||
* @param string $content optional | ||
* | ||
* @return string HTML script | ||
*/ | ||
protected function getHTML($atts = '', $content = null) | ||
{ | ||
if (!empty($atts)) { | ||
extract($atts, EXTR_SKIP); | ||
} | ||
|
||
/* acquire image boundaries */ | ||
$url = empty($url) ? $this->default_src : $url; | ||
/* prefer src */ | ||
$url = empty($src) ? $url : $src; | ||
|
||
$bounds = isset($bounds) ? $bounds : $this->default_bounds; | ||
$bounds = $this->LM->convert_bounds_str_to_arr($bounds); | ||
|
||
$options = array( | ||
'interactive' => isset($interactive) ? $interactive : null, | ||
'opacity' => isset($opacity) ? $opacity : null, | ||
'alt' => isset($alt) ? $alt : null, | ||
'crossOrigin' => isset($crossorigin) ? $crossorigin : null, | ||
'errorOverlayUrl' => isset($erroroverlayurl) ? $erroroverlayurl : null, | ||
'zIndex' => isset($zindex) ? $zindex : null, | ||
'className' => isset($classname) ? $classname : null, | ||
// filter out any unwanted HTML tags (including img) | ||
'attribution' => isset($attribution) ? wp_kses_post($attribution) : null, | ||
'keepAspectRatio' => isset($keepAspectRatio) ? $keepAspectRatio : true, | ||
); | ||
|
||
$args = array( | ||
'interactive' => FILTER_VALIDATE_BOOLEAN, | ||
'opacity' => FILTER_VALIDATE_FLOAT, | ||
'alt' => FILTER_SANITIZE_STRING, | ||
'crossOrigin' => FILTER_SANITIZE_STRING, | ||
'errorOverlayUrl' => FILTER_SANITIZE_STRING, | ||
'zIndex' => FILTER_VALIDATE_INT, | ||
'className' => FILTER_SANITIZE_STRING, | ||
'attribution' => FILTER_SANITIZE_STRING, | ||
'keepAspectRatio' => FILTER_VALIDATE_BOOLEAN | ||
); | ||
|
||
$options = $this->LM->json_sanitize($options, $args); | ||
|
||
ob_start(); | ||
?>/*<script>*/ | ||
var group = window.WPLeafletMapPlugin.getCurrentGroup(); | ||
var src = '<?php echo htmlspecialchars($url, ENT_QUOTES); ?>'; | ||
var options = <?php echo $options; ?>; | ||
var bounds = <?php echo json_encode($bounds); ?>; | ||
var layer = <?php echo $this->type; ?>(src, bounds, options); | ||
layer.addTo(group); | ||
window.WPLeafletMapPlugin.overlays.push( layer ); | ||
<?php | ||
$script = ob_get_clean(); | ||
|
||
return $this->wrap_script($script, 'WPLeafletOverlayShortcode'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/** | ||
* Video Overlay Shortcode | ||
* | ||
* Use with [leaflet-video-overlay ...] | ||
* | ||
* @category Shortcode | ||
* @author Benjamin J DeLong <[email protected]> | ||
*/ | ||
|
||
// Exit if accessed directly | ||
if (!defined('ABSPATH')) { | ||
exit; | ||
} | ||
|
||
require_once LEAFLET_MAP__PLUGIN_DIR . 'shortcodes/class.image-overlay-shortcode.php'; | ||
|
||
class Leaflet_Video_Overlay_Shortcode extends Leaflet_Image_Overlay_Shortcode | ||
{ | ||
protected $type = 'L.videoOverlay'; | ||
protected $default_src = 'https://labs.mapbox.com/bites/00188/patricia_nasa.webm'; | ||
protected $default_bounds = "32,-130;13,-100"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters