PluginProbe
Leaflet Map / 3.4.5
Leaflet Map v3.4.5
3.4.7 3.4.6 trunk 2.10.0 2.10.1 2.11.0 2.11.1 2.11.2 2.11.3 2.11.4 2.11.5 2.12.0 2.13.0 2.14.0 2.15.0 2.16.0 2.16.1 2.16.2 2.17.0 2.17.1 2.17.2 2.17.3 2.18.0 2.19.0 2.19.1 All 49 releases
← All changes | shortcodes/class.circle-shortcode.php +34 -36 2.16.23.4.5 View file →
@@ -3,10 +3,8 @@
3 3 * Circle Shortcode
4 4 *
5 5 * Use with [leaflet-circle ...]
6 6 *
7 - * PHP Version 5.5
8 - *
9 7 * @category Shortcode
10 8 * @author Peter Uithoven <peter@peteruithoven.nl>
11 9 */
12 10
@@ -32,14 +30,15 @@
32 30 */
33 31 protected function getHTML($atts='', $content=null)
34 32 {
35 33 if (!empty($atts)) {
36 - extract($atts);
34 + extract($atts, EXTR_SKIP);
37 35 }
38 36
39 37 $style_json = $this->LM->get_style_json($atts);
40 38
41 39 $fitbounds = empty($fitbounds) ? 0 : $fitbounds;
40 + $fitbounds = filter_var($fitbounds, FILTER_VALIDATE_BOOLEAN);
42 41
43 42 if (!empty($address)) {
44 43 include_once LEAFLET_MAP__PLUGIN_DIR . 'class.geocoder.php';
45 44 $location = new Leaflet_Geocoder( $address );
@@ -48,44 +47,43 @@
48 47 }
49 48
50 49 $lat = empty($lat) ? ( empty($y) ? '0' : $y ) : $lat;
51 50 $lng = empty($lng) ? ( empty($x) ? '0' : $x ) : $lng;
51 +
52 + // validate lat/lng
53 + $lat = $this->LM->filter_float($lat);
54 + $lng = $this->LM->filter_float($lng);
55 +
52 56 $radius = empty($radius) ? '1000' : $radius;
53 57
58 + $radius = $this->LM->filter_float($radius);
59 +
54 60 ob_start();
55 - ?>
56 - <script>
57 - window.WPLeafletMapPlugin = window.WPLeafletMapPlugin || [];
58 - window.WPLeafletMapPlugin.push(function () {
59 - var previous_map = window.WPLeafletMapPlugin.getCurrentMap(),
60 - fitbounds = <?php echo $fitbounds; ?>,
61 - is_image = previous_map.is_image_map,
62 - lat = <?php echo $lat; ?>,
63 - lng = <?php echo $lng; ?>,
64 - radius = <?php echo $radius; ?>,
65 - group = window.WPLeafletMapPlugin.getCurrentGroup();
61 + ?>/*<script>*/
62 +var previous_map = window.WPLeafletMapPlugin.getCurrentMap();
63 +var group = window.WPLeafletMapPlugin.getCurrentGroup();
64 +var fitbounds = <?php echo $fitbounds ? '1' : '0'; ?>;
65 +var is_image = previous_map.is_image_map;
66 +var lat = <?php echo $lat; ?>;
67 +var lng = <?php echo $lng; ?>;
68 +var radius = <?php echo $radius; ?>;
69 +// update lat lng to previous map's center
70 +if (!lat && !lng && !is_image) {
71 + var map_center = previous_map.getCenter();
72 + lat = map_center.lat;
73 + lng = map_center.lng;
74 +}
75 +var circle = L.circle([lat, lng], {radius: radius});
76 +circle.setStyle(<?php echo $style_json; ?>);
77 +circle.addTo( group );
78 +window.WPLeafletMapPlugin.circles.push( circle );
79 +if (fitbounds) {
80 + // zoom the map to the polyline
81 + previous_map.fitBounds( circle.getBounds() );
82 +}<?php
83 + $this->LM->add_popup_to_shape($atts, $content, 'circle');
66 84
67 - // update lat lng to previous map's center
68 - if (!lat && !lng && !is_image) {
69 - var map_center = previous_map.getCenter();
70 - lat = map_center.lat;
71 - lng = map_center.lng;
72 - }
73 - var circle = L.circle([lat, lng], {radius: radius});
74 - circle.setStyle(<?php echo $style_json; ?>);
75 - circle.addTo( group );
85 + $script = ob_get_clean();
76 86
77 - window.WPLeafletMapPlugin.circles.push( circle );
78 -
79 - if (fitbounds) {
80 - // zoom the map to the polyline
81 - previous_map.fitBounds( circle.getBounds() );
82 - }
83 - <?php
84 - $this->LM->add_popup_to_shape($atts, $content, 'circle');
85 - ?>
86 - });
87 - </script>
88 - <?php
89 - return ob_get_clean();
87 + return $this->wrap_script($script, 'WPLeafletCircleShortcode');
90 88 }
91 89 }