Changeset 2401199 for leaflet-map
- Timestamp:
- 10/17/2020 12:39:43 AM (5 years ago)
- Location:
- leaflet-map
- Files:
-
- 16 edited
- 1 copied
-
tags/2.20.0 (copied) (copied from leaflet-map/trunk)
-
tags/2.20.0/README.md (modified) (1 diff)
-
tags/2.20.0/class.admin.php (modified) (1 diff)
-
tags/2.20.0/class.leaflet-map.php (modified) (1 diff)
-
tags/2.20.0/leaflet-map.php (modified) (2 diffs)
-
tags/2.20.0/readme.txt (modified) (2 diffs)
-
tags/2.20.0/shortcodes/class.image-shortcode.php (modified) (1 diff)
-
tags/2.20.0/shortcodes/class.map-shortcode.php (modified) (3 diffs)
-
tags/2.20.0/shortcodes/class.shortcode.php (modified) (2 diffs)
-
trunk/README.md (modified) (1 diff)
-
trunk/class.admin.php (modified) (1 diff)
-
trunk/class.leaflet-map.php (modified) (1 diff)
-
trunk/leaflet-map.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/shortcodes/class.image-shortcode.php (modified) (1 diff)
-
trunk/shortcodes/class.map-shortcode.php (modified) (3 diffs)
-
trunk/shortcodes/class.shortcode.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
leaflet-map/tags/2.20.0/README.md
r2400542 r2401199 132 132 | `tileurl` | 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' | 133 133 | `subdomains` | 'abc' | 134 | `tap` | true | 134 135 135 136 --- -
leaflet-map/tags/2.20.0/class.admin.php
r2267880 r2401199 104 104 { 105 105 wp_enqueue_style('leaflet_admin_stylesheet'); 106 wp_enqueue_script('custom_plugin_js', plugins_url('scripts/shortcode-helper.min.js', LEAFLET_MAP__PLUGIN_FILE), Array('leaflet_js'), false); 106 107 if (defined('WP_DEBUG') && WP_DEBUG) { 108 $minified = ''; 109 } else { 110 $minified = '.min'; 111 } 112 113 wp_enqueue_script('custom_plugin_js', plugins_url(sprintf('scripts/shortcode-helper%s.js', $minified), LEAFLET_MAP__PLUGIN_FILE), Array('leaflet_js'), false); 107 114 108 115 include 'templates/shortcode-helper.php'; -
leaflet-map/tags/2.20.0/class.leaflet-map.php
r2400542 r2401199 348 348 return Leaflet_Map_Plugin_Settings::init(); 349 349 } 350 351 /** 352 * Parses liquid tags from a string 353 * 354 * @param string $str 355 * 356 * @return array|null 357 */ 358 public function liquid ($str) { 359 if (!is_string($str)) { 360 return null; 361 } 362 $templateRegex = "/\{ *(.*?) *\}/"; 363 preg_match_all($templateRegex, $str, $matches); 364 365 if (!$matches[1]) { 366 return null; 367 } 368 369 $str = $matches[1][0]; 370 371 $tags = explode(' | ', $str); 372 373 $original = array_shift($tags); 374 375 if (!$tags) { 376 return null; 377 } 378 379 $output = array(); 380 381 foreach ($tags as $tag) { 382 $tagParts = explode(': ', $tag); 383 $tagName = array_shift($tagParts); 384 $tagValue = implode(': ', $tagParts) || true; 385 386 $output[$tagName] = $tagValue; 387 } 388 389 // preserve the original 390 $output['original'] = $original; 391 392 return $output; 393 } 394 395 /** 396 * Renders a json-like string, removing quotes for values 397 * 398 * allows JavaScript variables to be added directly 399 * 400 * @return string 401 */ 402 public function rawDict ($arr) { 403 $obj = '{'; 404 405 foreach ($arr as $key=>$val) { 406 $obj .= "\"$key\": $val,"; 407 } 408 409 $obj .= '}'; 410 411 return $obj; 412 } 350 413 } -
leaflet-map/tags/2.20.0/leaflet-map.php
r2400542 r2401199 9 9 * Text Domain: leaflet-map 10 10 * Domain Path: /languages/ 11 * Version: 2. 19.111 * Version: 2.20.0 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', '2. 19.1');32 define('LEAFLET_MAP__PLUGIN_VERSION', '2.20.0'); 33 33 define('LEAFLET_MAP__PLUGIN_FILE', __FILE__); 34 34 define('LEAFLET_MAP__PLUGIN_DIR', plugin_dir_path(__FILE__)); -
leaflet-map/tags/2.20.0/readme.txt
r2400542 r2401199 8 8 Requires at least: 4.6 9 9 Tested up to: 5.5.1 10 Version: 2. 19.111 Stable tag: 2. 19.110 Version: 2.20.0 11 Stable tag: 2.20.0 12 12 License: GPLv2 13 13 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 142 142 == Changelog == 143 143 144 = 2.20.0 = 145 * Adds tap and !tap option to [leaflet-map] 146 * Adds (advanced) raw filter syntax for map options: [leaflet-map dragging="{!L.Browser.mobile | raw}"] 147 144 148 = 2.19.1 = 145 149 * Bumps leaflet version to 1.7.1 -
leaflet-map/tags/2.20.0/shortcodes/class.image-shortcode.php
r2340086 r2401199 60 60 doubleClickZoom: <?php echo $doubleclickzoom; ?>, 61 61 attributionControl: false 62 }, <?php echo $m ore_options; ?>, {62 }, <?php echo $map_options; ?>, { 63 63 crs: L.CRS.Simple 64 64 }); -
leaflet-map/tags/2.20.0/shortcodes/class.map-shortcode.php
r2400542 r2401199 72 72 $settings->get('default_height') : $height; 73 73 $atts['width'] = empty($width) ? $settings->get('default_width') : $width; 74 $atts['zoomcontrol'] = array_key_exists('zoomcontrol', $atts) ? 75 $zoomcontrol : $settings->get('show_zoom_controls'); 74 $atts['zoomcontrol'] = isset($zoomControl) 75 ? $zoomControl 76 : (array_key_exists('zoomcontrol', $atts) 77 ? $zoomcontrol 78 : $settings->get('show_zoom_controls')); 76 79 $atts['min_zoom'] = array_key_exists('min_zoom', $atts) ? 77 80 $min_zoom : $settings->get('default_min_zoom'); 78 81 $atts['max_zoom'] = empty($max_zoom) ? 79 82 $settings->get('default_max_zoom') : $max_zoom; 80 $atts['scrollwheel'] = array_key_exists('scrollwheel', $atts) 81 ? $scrollwheel 82 : $settings->get('scroll_wheel_zoom'); 83 $atts['scrollwheel'] = isset($scrollWheelZoom) 84 ? $scrollWheelZoom 85 : (array_key_exists('scrollwheel', $atts) 86 ? $scrollwheel 87 : $settings->get('scroll_wheel_zoom')); 83 88 $atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ? 84 89 $doubleclickzoom : $settings->get('double_click_zoom'); … … 123 128 } 124 129 125 /* allow a bunch of other options */130 /* allow a bunch of other (boolean) options */ 126 131 // http://leafletjs.com/reference.html#map 127 $more_options = array( 128 'closePopupOnClick' => isset($closepopuponclick) ? 129 $closepopuponclick : null, 130 'trackResize' => isset($trackresize) ? $trackresize : null, 131 'boxZoom' => (isset($boxzoom) 132 $map_options = array( 133 'closePopupOnClick' => isset($closePopupOnClick) 134 ? $closePopupOnClick 135 : (isset($closepopuponclick) 136 ? $closepopuponclick 137 : null), 138 'trackResize' => isset($trackResize) 139 ? $trackResize 140 : (isset($trackresize) 141 ? $trackresize 142 : null), 143 'boxZoom' => isset($boxzoom) 132 144 ? $boxzoom 133 : isset($boxZoom))145 : (isset($boxZoom) 134 146 ? $boxZoom 135 : null ,147 : null), 136 148 'touchZoom' => isset($touchZoom) ? $touchZoom : null, 137 149 'dragging' => isset($dragging) ? $dragging : null, 138 150 'keyboard' => isset($keyboard) ? $keyboard : null, 151 'zoomAnimation' => isset($zoomAnimation) ? $zoomAnimation : null, 152 'fadeAnimation' => isset($fadeAnimation) ? $fadeAnimation : null, 153 'markerZoomAnimation' => isset($markerZoomAnimation) ? $markerZoomAnimation : null, 154 'inertia' => isset($inertia) ? $inertia : null, 155 'worldCopyJump' => isset($worldCopyJump) ? $worldCopyJump : null, 156 'tap' => isset($tap) ? $tap : null, 157 'bounceAtZoomLimits' => isset($bounceAtZoomLimits) ? $bounceAtZoomLimits : null, 139 158 ); 140 159 141 160 // filter out nulls 142 $m ore_options = $this->LM->filter_null($more_options);161 $map_options = $this->LM->filter_null($map_options); 143 162 144 163 // custom field for moving to JavaScript 145 $m ore_options['fitBounds'] = $atts['fitbounds'];164 $map_options['fitBounds'] = $atts['fitbounds']; 146 165 147 166 // change string booleans to booleans 148 $m ore_options = filter_var_array($more_options, FILTER_VALIDATE_BOOLEAN);167 $map_options = filter_var_array($map_options, FILTER_VALIDATE_BOOLEAN); 149 168 150 169 if ($maxBounds) { 151 $m ore_options['maxBounds'] = $maxBounds;170 $map_options['maxBounds'] = $maxBounds; 152 171 } 153 172 154 173 // custom field for moving to javascript 155 $m ore_options['attribution'] = $atts['attribution'];174 $map_options['attribution'] = $atts['attribution']; 156 175 157 176 // wrap as JSON 158 $atts['more_options'] = json_encode($more_options); 177 $atts['map_options'] = json_encode($map_options); 178 179 // get raw variables, allowing for JavaScript variables in values 180 $raw_map_options = array(); 181 foreach($map_options as $key=>$val) { 182 $original_value = isset($atts[$key]) ? $atts[$key] : null; 183 184 $liquid = $this->LM->liquid($original_value); 185 186 if ($liquid && isset($liquid['raw']) && $liquid['raw']) { 187 // raw leaves original value un-quoted 188 $raw_map_options[$key] = $liquid['original']; 189 } 190 } 191 192 $atts['raw_map_options'] = $this->LM->rawDict($raw_map_options); 159 193 160 194 return $atts; … … 231 265 doubleClickZoom: <?php echo $doubleclickzoom; ?>, 232 266 attributionControl: false 233 }, <?php echo $more_options; ?>); 267 }, <?php echo $map_options; ?>, 268 <?php echo $raw_map_options; ?>); 234 269 window.WPLeafletMapPlugin.createMap(options) 235 270 .setView(<?php -
leaflet-map/tags/2.20.0/shortcodes/class.shortcode.php
r2267880 r2401199 17 17 abstract class Leaflet_Shortcode 18 18 { 19 /** 20 * @var Leaflet_Map 21 */ 19 22 protected $LM; 20 23 … … 40 43 * Instantiate class and get HTML for shortcode 41 44 * 42 * @param array $atts string|array43 * @param string $content Optional45 * @param array|string|null $atts string|array 46 * @param string|null $content Optional 44 47 * 45 * @return string (see above)48 * @return string HTML 46 49 */ 47 50 public static function shortcode($atts = '', $content = null) -
leaflet-map/trunk/README.md
r2400542 r2401199 132 132 | `tileurl` | 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' | 133 133 | `subdomains` | 'abc' | 134 | `tap` | true | 134 135 135 136 --- -
leaflet-map/trunk/class.admin.php
r2267880 r2401199 104 104 { 105 105 wp_enqueue_style('leaflet_admin_stylesheet'); 106 wp_enqueue_script('custom_plugin_js', plugins_url('scripts/shortcode-helper.min.js', LEAFLET_MAP__PLUGIN_FILE), Array('leaflet_js'), false); 106 107 if (defined('WP_DEBUG') && WP_DEBUG) { 108 $minified = ''; 109 } else { 110 $minified = '.min'; 111 } 112 113 wp_enqueue_script('custom_plugin_js', plugins_url(sprintf('scripts/shortcode-helper%s.js', $minified), LEAFLET_MAP__PLUGIN_FILE), Array('leaflet_js'), false); 107 114 108 115 include 'templates/shortcode-helper.php'; -
leaflet-map/trunk/class.leaflet-map.php
r2400542 r2401199 348 348 return Leaflet_Map_Plugin_Settings::init(); 349 349 } 350 351 /** 352 * Parses liquid tags from a string 353 * 354 * @param string $str 355 * 356 * @return array|null 357 */ 358 public function liquid ($str) { 359 if (!is_string($str)) { 360 return null; 361 } 362 $templateRegex = "/\{ *(.*?) *\}/"; 363 preg_match_all($templateRegex, $str, $matches); 364 365 if (!$matches[1]) { 366 return null; 367 } 368 369 $str = $matches[1][0]; 370 371 $tags = explode(' | ', $str); 372 373 $original = array_shift($tags); 374 375 if (!$tags) { 376 return null; 377 } 378 379 $output = array(); 380 381 foreach ($tags as $tag) { 382 $tagParts = explode(': ', $tag); 383 $tagName = array_shift($tagParts); 384 $tagValue = implode(': ', $tagParts) || true; 385 386 $output[$tagName] = $tagValue; 387 } 388 389 // preserve the original 390 $output['original'] = $original; 391 392 return $output; 393 } 394 395 /** 396 * Renders a json-like string, removing quotes for values 397 * 398 * allows JavaScript variables to be added directly 399 * 400 * @return string 401 */ 402 public function rawDict ($arr) { 403 $obj = '{'; 404 405 foreach ($arr as $key=>$val) { 406 $obj .= "\"$key\": $val,"; 407 } 408 409 $obj .= '}'; 410 411 return $obj; 412 } 350 413 } -
leaflet-map/trunk/leaflet-map.php
r2400542 r2401199 9 9 * Text Domain: leaflet-map 10 10 * Domain Path: /languages/ 11 * Version: 2. 19.111 * Version: 2.20.0 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', '2. 19.1');32 define('LEAFLET_MAP__PLUGIN_VERSION', '2.20.0'); 33 33 define('LEAFLET_MAP__PLUGIN_FILE', __FILE__); 34 34 define('LEAFLET_MAP__PLUGIN_DIR', plugin_dir_path(__FILE__)); -
leaflet-map/trunk/readme.txt
r2400542 r2401199 8 8 Requires at least: 4.6 9 9 Tested up to: 5.5.1 10 Version: 2. 19.111 Stable tag: 2. 19.110 Version: 2.20.0 11 Stable tag: 2.20.0 12 12 License: GPLv2 13 13 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 142 142 == Changelog == 143 143 144 = 2.20.0 = 145 * Adds tap and !tap option to [leaflet-map] 146 * Adds (advanced) raw filter syntax for map options: [leaflet-map dragging="{!L.Browser.mobile | raw}"] 147 144 148 = 2.19.1 = 145 149 * Bumps leaflet version to 1.7.1 -
leaflet-map/trunk/shortcodes/class.image-shortcode.php
r2340086 r2401199 60 60 doubleClickZoom: <?php echo $doubleclickzoom; ?>, 61 61 attributionControl: false 62 }, <?php echo $m ore_options; ?>, {62 }, <?php echo $map_options; ?>, { 63 63 crs: L.CRS.Simple 64 64 }); -
leaflet-map/trunk/shortcodes/class.map-shortcode.php
r2400542 r2401199 72 72 $settings->get('default_height') : $height; 73 73 $atts['width'] = empty($width) ? $settings->get('default_width') : $width; 74 $atts['zoomcontrol'] = array_key_exists('zoomcontrol', $atts) ? 75 $zoomcontrol : $settings->get('show_zoom_controls'); 74 $atts['zoomcontrol'] = isset($zoomControl) 75 ? $zoomControl 76 : (array_key_exists('zoomcontrol', $atts) 77 ? $zoomcontrol 78 : $settings->get('show_zoom_controls')); 76 79 $atts['min_zoom'] = array_key_exists('min_zoom', $atts) ? 77 80 $min_zoom : $settings->get('default_min_zoom'); 78 81 $atts['max_zoom'] = empty($max_zoom) ? 79 82 $settings->get('default_max_zoom') : $max_zoom; 80 $atts['scrollwheel'] = array_key_exists('scrollwheel', $atts) 81 ? $scrollwheel 82 : $settings->get('scroll_wheel_zoom'); 83 $atts['scrollwheel'] = isset($scrollWheelZoom) 84 ? $scrollWheelZoom 85 : (array_key_exists('scrollwheel', $atts) 86 ? $scrollwheel 87 : $settings->get('scroll_wheel_zoom')); 83 88 $atts['doubleclickzoom'] = array_key_exists('doubleclickzoom', $atts) ? 84 89 $doubleclickzoom : $settings->get('double_click_zoom'); … … 123 128 } 124 129 125 /* allow a bunch of other options */130 /* allow a bunch of other (boolean) options */ 126 131 // http://leafletjs.com/reference.html#map 127 $more_options = array( 128 'closePopupOnClick' => isset($closepopuponclick) ? 129 $closepopuponclick : null, 130 'trackResize' => isset($trackresize) ? $trackresize : null, 131 'boxZoom' => (isset($boxzoom) 132 $map_options = array( 133 'closePopupOnClick' => isset($closePopupOnClick) 134 ? $closePopupOnClick 135 : (isset($closepopuponclick) 136 ? $closepopuponclick 137 : null), 138 'trackResize' => isset($trackResize) 139 ? $trackResize 140 : (isset($trackresize) 141 ? $trackresize 142 : null), 143 'boxZoom' => isset($boxzoom) 132 144 ? $boxzoom 133 : isset($boxZoom))145 : (isset($boxZoom) 134 146 ? $boxZoom 135 : null ,147 : null), 136 148 'touchZoom' => isset($touchZoom) ? $touchZoom : null, 137 149 'dragging' => isset($dragging) ? $dragging : null, 138 150 'keyboard' => isset($keyboard) ? $keyboard : null, 151 'zoomAnimation' => isset($zoomAnimation) ? $zoomAnimation : null, 152 'fadeAnimation' => isset($fadeAnimation) ? $fadeAnimation : null, 153 'markerZoomAnimation' => isset($markerZoomAnimation) ? $markerZoomAnimation : null, 154 'inertia' => isset($inertia) ? $inertia : null, 155 'worldCopyJump' => isset($worldCopyJump) ? $worldCopyJump : null, 156 'tap' => isset($tap) ? $tap : null, 157 'bounceAtZoomLimits' => isset($bounceAtZoomLimits) ? $bounceAtZoomLimits : null, 139 158 ); 140 159 141 160 // filter out nulls 142 $m ore_options = $this->LM->filter_null($more_options);161 $map_options = $this->LM->filter_null($map_options); 143 162 144 163 // custom field for moving to JavaScript 145 $m ore_options['fitBounds'] = $atts['fitbounds'];164 $map_options['fitBounds'] = $atts['fitbounds']; 146 165 147 166 // change string booleans to booleans 148 $m ore_options = filter_var_array($more_options, FILTER_VALIDATE_BOOLEAN);167 $map_options = filter_var_array($map_options, FILTER_VALIDATE_BOOLEAN); 149 168 150 169 if ($maxBounds) { 151 $m ore_options['maxBounds'] = $maxBounds;170 $map_options['maxBounds'] = $maxBounds; 152 171 } 153 172 154 173 // custom field for moving to javascript 155 $m ore_options['attribution'] = $atts['attribution'];174 $map_options['attribution'] = $atts['attribution']; 156 175 157 176 // wrap as JSON 158 $atts['more_options'] = json_encode($more_options); 177 $atts['map_options'] = json_encode($map_options); 178 179 // get raw variables, allowing for JavaScript variables in values 180 $raw_map_options = array(); 181 foreach($map_options as $key=>$val) { 182 $original_value = isset($atts[$key]) ? $atts[$key] : null; 183 184 $liquid = $this->LM->liquid($original_value); 185 186 if ($liquid && isset($liquid['raw']) && $liquid['raw']) { 187 // raw leaves original value un-quoted 188 $raw_map_options[$key] = $liquid['original']; 189 } 190 } 191 192 $atts['raw_map_options'] = $this->LM->rawDict($raw_map_options); 159 193 160 194 return $atts; … … 231 265 doubleClickZoom: <?php echo $doubleclickzoom; ?>, 232 266 attributionControl: false 233 }, <?php echo $more_options; ?>); 267 }, <?php echo $map_options; ?>, 268 <?php echo $raw_map_options; ?>); 234 269 window.WPLeafletMapPlugin.createMap(options) 235 270 .setView(<?php -
leaflet-map/trunk/shortcodes/class.shortcode.php
r2267880 r2401199 17 17 abstract class Leaflet_Shortcode 18 18 { 19 /** 20 * @var Leaflet_Map 21 */ 19 22 protected $LM; 20 23 … … 40 43 * Instantiate class and get HTML for shortcode 41 44 * 42 * @param array $atts string|array43 * @param string $content Optional45 * @param array|string|null $atts string|array 46 * @param string|null $content Optional 44 47 * 45 * @return string (see above)48 * @return string HTML 46 49 */ 47 50 public static function shortcode($atts = '', $content = null)
Note: See TracChangeset
for help on using the changeset viewer.