Compare commits

...

5 Commits

15 changed files with 4691 additions and 996 deletions

View File

@ -1,380 +1,389 @@
=== WP GPX Maps === # WP GPX Maps
Contributors: bastianonm, Stephan Klein, Michel Selerin, TosattoSimonePio, Kniebremser Contributors: bastianonm, Stephan Klein, Michel Selerin, TosattoSimonePio, Kniebremser
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8VHWLRW6JBTML Donate link: https://www.paypal.com/cgi-bin/webscr?cmd_s-xclick&hosted_button_id=8VHWLRW6JBTML
Tags: maps, gpx, gps, graph, chart, leaflet, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence Tags: maps, gpx, gps, graph, chart, leaflet, track, garmin, image, nextgen-gallery, nextgen, exif, OpenStreetMap, OpenCycleMap, Hike&Bike, heart rate, heartrate, cadence
Requires at least: 4.6.0 Requires at least: 4.6.0
Tested up to: 5.2.1 Tested up to: 5.2.2
Stable tag: 1.7.00 Requires PHP: 5.6.20
Stable tag: 1.7.00
Draws a GPX track with altitude graph. You can also display your nextgen gallery images in the map.
Draws a GPX track with altitude graph. You can also display your nextgen gallery images in the map.
== Description ==
## Description
This plugin has, as input, the GPX file with the track you've made and as output it shows the map of the track and an interactive altitude graph (where available).
This plugin has, as input, the GPX file with the track you've made and as output it shows the map of the track and an interactive altitude graph (where available).
Fully configurable:
Fully configurable:
- Custom colors
- Custom icons - Custom colors
- Multiple language support - Custom icons
- Multiple language support
Supported charts:
Supported charts:
- Altitude
- Speed - Altitude
- Heart rate - Speed
- Temperature - Heart rate
- Cadence - Temperature
- Grade - Cadence
- Grade
NextGen Gallery Integration:
NextGen Gallery Integration:
Display your NextGen Gallery images inside the map!
Even if you don't have a GPS camera, this plugin can retrive the image position starting from the image date and your GPX file. Display your NextGen Gallery images inside the map!
Even if you don't have a GPS camera, this plugin can retrive the image position starting from the image date and your GPX file.
Post Attachments Integration:
Post Attachments Integration:
This version is extended by: <a href="https://klein-gedruckt.de/2015/03/wordpress-plugin-wp-gpx-maps/" target="_blank" rel="noopener noreferrer">Stephan Klein</a> and supports displaying all images attached to a post without using NGG.
This version is extended by: <a href"https://klein-gedruckt.de/2015/03/wordpress-plugin-wp-gpx-maps/" target="_blank" rel="noopener noreferrer">Stephan Klein</a> and supports displaying all images attached to a post without using NGG.
Try this plugin: <a href="https://devfarm.it/wp-gpx-maps-demo/" target="_blank" rel="noopener noreferrer">https://devfarm.it/wp-gpx-maps-demo/</a>
Try this plugin: <a href"https://devfarm.it/wp-gpx-maps-demo/" target="_blank" rel="noopener noreferrer">https://devfarm.it/wp-gpx-maps-demo/</a>
Support:
Support:
If you need help, please use: <a href="http://www.devfarm.it/forums/forum/wp-gpx-maps/" target="_blank" rel="noopener noreferrer">www.devfarm.it Support Forum</a>
Would you like to help fix bugs or further develop the plugin? On <a href="https://github.com/devfarm-it/wp-gpx-maps" target="_blank" rel="noopener noreferrer">Github</a> you can contribuite easly with your code. If you need help, please use: <a href"http://www.devfarm.it/forums/forum/wp-gpx-maps/" target="_blank" rel="noopener noreferrer">www.devfarm.it Support Forum</a>
Translations: Would you like to help fix bugs or further develop the plugin? On <a href"https://github.com/devfarm-it/wp-gpx-maps" target="_blank" rel="noopener noreferrer">Github</a> you can contribuite easly with your code.
Translators are welcome to contribute to the plugin. Please use the <a href="https://translate.wordpress.org/projects/wp-plugins/wp-gpx-maps/)" target="_blank" rel="noopener noreferrer">WordPress translation website</a>. Translations:
The language files in the plugin contain 19 translatable texts for 14 languages: Translators are welcome to contribute to the plugin. Please use the <a href"https://translate.wordpress.org/projects/wp-plugins/wp-gpx-maps/)" target="_blank" rel="noopener noreferrer">WordPress translation website</a>.
- Catalan ca The language files in the plugin contain 18 translatable texts for 13 languages:
- Dutch nl_NL
- English (default) - Catalan ca
- French fr_FR - Dutch nl_NL
- German de_DE - English (default)
- Hungarian hu_HU - French fr_FR
- Italian it_IT - Hungarian hu_HU
- Norwegian nb_NO - Italian it_IT
- Polish pl_PL - Norwegian nb_NO
- Portuguese (Brazilian) pt_BR - Polish pl_PL
- Russian ru_RU - Portuguese (Brazilian) pt_BR
- Spanish es_ES - Russian ru_RU
- Swedish sv_SE - Spanish es_ES
- Turkish tr_TR - Swedish sv_SE
- Bulgarian bg_BG - Turkish tr_TR
- Slovak cs_CZ - Bulgarian bg_BG
- Norwegian nb_NO - Slovak cs_CZ
- Japanese ja_JP - Norwegian nb_NO
- Japanese ja_JP
(Many thanks to all guys who helped me with the translations)
(Many thanks to all guys who helped me with the translations)
Currently are 222 texts are translatable in the plugin.
Currently are 230 texts are translatable in the plugin.
With your help, the plugin can be translated into any language. For updating the language file you no longer need to wait for a new version of the plugin.
Are 95% WordPress generates a new language file for your language. With your help, the plugin can be translated into any language. For updating the language file you no longer need to wait for a new version of the plugin.
If the translation is available via WP Translate, the language file will be deleted in the next version of the plugin. Are 95% WordPress generates a new language file for your language.
Please also help with the translation of the readme. The more languages that are available, the wider the spread of the plugin will be. If the translation is available via WP Translate, the language file will be deleted in the next version of the plugin.
Please also help with the translation of the readme. The more languages that are available, the wider the spread of the plugin will be.
Supported GPX namespaces are:
Supported GPX namespaces are:
1. http://www.topografix.com/GPX/1/0
1. http://www.topografix.com/GPX/1/0
1. <a href="http://www.topografix.com/GPX/1/1" target="_blank" rel="noopener noreferrer">www.topografix.com/GPX/1/1</a>
1. <a href"http://www.topografix.com/GPX/1/1" target="_blank" rel="noopener noreferrer">www.topografix.com/GPX/1/1</a>
1. http://www.garmin.com/xmlschemas/GpxExtensions/v3
1. http://www.garmin.com/xmlschemas/GpxExtensions/v3
1. http://www.garmin.com/xmlschemas/TrackPointExtension/v1
1. http://www.garmin.com/xmlschemas/TrackPointExtension/v1
Thanks to: <a href="http://www.securcube.net/" target="_blank" rel="noopener noreferrer">www.securcube.net</a>, <a href="http://www.devfarm.it/" target="_blank" rel="noopener noreferrer">www.devfarm.it</a>
Thanks to: <a href"http://www.securcube.net/" target="_blank" rel="noopener noreferrer">www.securcube.net</a>, <a href="http://www.devfarm.it/" target="_blank" rel="noopener noreferrer">www.devfarm.it</a>
Icons made by <a href="https://www.freepik.com/" target="_blank" rel="noopener noreferrer">Freepik</a> from <a href="https://www.flaticon.com/" target="_blank" rel="noopener noreferrer">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener noreferrer">Creative Commons BY 3.0</a>
Icons made by <a href"https://www.freepik.com/" target="_blank" rel="noopener noreferrer">Freepik</a> from <a href="https://www.flaticon.com/" target="_blank" rel="noopener noreferrer">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener noreferrer">Creative Commons BY 3.0</a>
== Installation ==
## Installation
1. Use the classic wordpress plugin installer or copy the plugins folder to the `/wp-content/plugins/` directory
1. Use the classic wordpress plugin installer or copy the plugins folder to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Add the shortcode [sgpx gpx="&gt;relative path to your gpx&lt;"] or [sgpx gpx="&gt;http://somesite.com/files/yourfile.gpx&lt;"]
1. Add the shortcode [sgpx gpx"&gt;relative path to your gpx&lt;"] or [sgpx gpx="&gt;http://somesite.com/files/yourfile.gpx&lt;"]
== Frequently Asked Questions ==
## Frequently Asked Questions
= Which shortcode attributes are available? =
### Which shortcode attributes are available?
You can use the following shortcodes:
You can use the following shortcodes:
1. gpx: Relative path to the GPX file
1. width: Width in pixels 1. gpx: Relative path to the GPX file
1. mheight: Map height 1. width: Map width (value in percent)
1. gheight: Graph height 1. mheight: Map height (value in pixeln)
1. skipcache: Do not use cache. If TRUE might be very slow (default is false) 1. gheight: Graph height (value in pixeln)
1. download: Allow users to download your GPX file (default is false) 1. skipcache: Do not use cache. If TRUE might be very slow (default is false)
1. summary: Print summary details of your GPX track (default is false) 1. download: Allow users to download your GPX file (default is false)
1. summarytotlen: Print total distance in summary table (default is false) 1. summary: Print summary details of your GPX track (default is false)
1. summarymaxele: Print max elevation in summary table (default is false) 1. summarytotlen: Print total distance in summary table (default is false)
1. summaryminele: Print min Elevation in summary table (default is false) 1. summarymaxele: Print max elevation in summary table (default is false)
1. summaryeleup: Print total climbing in summary table (default is false) 1. summaryminele: Print min Elevation in summary table (default is false)
1. summaryeledown: Print total descent in summary table (default is false) 1. summaryeleup: Print total climbing in summary table (default is false)
1. summaryavgspeed: Print average Speed in summary table (default is false) 1. summaryeledown: Print total descent in summary table (default is false)
1. summarytotaltime: Print total time in summary table (default is false) 1. summaryavgspeed: Print average Speed in summary table (default is false)
1. mtype: Map available types are: HYBRID, ROADMAP, SATELLITE, TERRAIN, OSM1 (Open Street Map), OSM2 (Open Cycle Map), OSM4 (Open Cycle Map - Transport), OSM5 (Open Cycle Map - Landscape), OSM6 (MapToolKit - Terrain), OSM7 (Open Street Map - Humanitarian map style), OSM 9 (Hike & Bike), OSM10 (Open Sea Map) 1. summarytotaltime: Print total time in summary table (default is false)
1. mlinecolor: Map line color (default is #3366cc) 1. mtype: Map available types are: HYBRID, ROADMAP, SATELLITE, TERRAIN, OSM1 (Open Street Map), OSM2 (Open Cycle Map), OSM4 (Open Cycle Map - Transport), OSM5 (Open Cycle Map - Landscape), OSM6 (MapToolKit - Terrain), OSM7 (Open Street Map - Humanitarian map style), OSM 9 (Hike & Bike), OSM10 (Open Sea Map)
1. zoomonscrollwheel: Zoom on map when mouse scroll wheel (default is false) 1. mlinecolor: Map line color (default is #3366cc)
1. waypoints: Print the gpx waypoints inside the map (default is false) 1. zoomonscrollwheel: Zoom on map when mouse scroll wheel (default is false)
1. startIcon: Start track icon 1. waypoints: Print the gpx waypoints inside the map (default is false)
1. endIcon: End track icon 1. startIcon: Start track icon
1. currentIcon: Current position icon (when mouse hover) 1. endIcon: End track icon
1. waypointicon: Waypoint custom icon 1. currentIcon: Current position icon (when mouse hover)
1. showele: Show elevation data inside the chart (default is true) 1. waypointicon: Custom waypoint icon
1. uom: Distance/altitude possible unit of measure (0 = meters, 1 = feet/miles, 2 = meters/kilometers, 3 = meters/nautical miles, 4 = meters/miles, 5 = feet/nautical miles) 1. showele: Show elevation data inside the chart (default is true)
1. glinecolor: Altitude line color (default is #3366cc) 1. uom: Distance/altitude possible unit of measure (0 meters, 1 = feet/miles, 2 = meters/kilometers, 3 = meters/nautical miles, 4 = meters/miles, 5 = feet/nautical miles)
1. chartFrom1: Minimun value for altitude chart 1. glinecolor: Altitude line color (default is #3366cc)
1. chartTo1: Maxumin value for altitude chart 1. chartFrom1: Minimun value for altitude chart
1. showspeed: Show speed inside the chart (default is false) 1. chartTo1: Maxumin value for altitude chart
1. glinecolorspeed: Speed line color (default is #ff0000) 1. showspeed: Show speed inside the chart (default is false)
1. uomspeed: Unit of measure for speed (0 = m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles, 5 = Nautical Miles/Hour (Knots), 6 = min/100 meters) 1. glinecolorspeed: Speed line color (default is #ff0000)
1. chartFrom2: Minimun value for speed chart 1. uomspeed: Unit of measure for speed (0 m/s, 1 = km/h, 2 = miles/h, 3 = min/km, 4 = min/miles, 5 = Nautical Miles/Hour (Knots), 6 = min/100 meters)
1. chartTo2: Maxumin value for speed chart 1. chartFrom2: Minimun value for speed chart
1. showhr: Show heart rate inside the chart (default is false) 1. chartTo2: Maxumin value for speed chart
1. glinecolorhr: Heart rate line color (default is #ff77bd) 1. showhr: Show heart rate inside the chart (default is false)
1. showatemp: Show temperature inside the chart (default is false) 1. glinecolorhr: Heart rate line color (default is #ff77bd)
1. glinecoloratemp: Temperature line color (default is #ff77bd) 1. showatemp: Show temperature inside the chart (default is false)
1. showcad: Show cadence inside the chart (default is false) 1. glinecoloratemp: Temperature line color (default is #ff77bd)
1. glinecolorcad: Cadence line color (default is #beecff) 1. showcad: Show cadence inside the chart (default is false)
1. showgrade: Show grade inside the chart (default is false) 1. glinecolorcad: Cadence line color (default is #beecff)
1. glinecolorgrade: Grade line color (default is #beecff) 1. showgrade: Show grade inside the chart (default is false)
1. nggalleries: NextGen Gallery id or a list of Galleries id separated by a comma 1. glinecolorgrade: Grade line color (default is #beecff)
1. ngimages: NextGen Image id or a list of Images id separated by a comma 1. nggalleries: NextGen Gallery id or a list of Galleries id separated by a comma
1. attachments: Show all images that are attached to post (default is false) 1. ngimages: NextGen Image id or a list of Images id separated by a comma
1. dtoffset: The difference (in seconds) between your gpx tool date and your camera date 1. attachments: Show all images that are attached to post (default is false)
1. pointsoffset: Skip points closer than XX meters (default is 10) 1. dtoffset: The difference (in seconds) between your gpx tool date and your camera date
1. donotreducegpx: Print all the point without reduce it (default is false) 1. pointsoffset: Skip points closer than XX meters (default is 10)
1. donotreducegpx: Print all the point without reduce it (default is false)
= What happening if I've a very large GPX files? =
### What happening if I've a very large GPX files?
This plugin will print a small amout of points to speedup javascript and pageload.
This plugin will print a small amout of points to speedup javascript and pageload.
= Is it free? =
### Is it free?
Yes!
Yes!
== Screenshots ==
1. Simple Gpx ## Screenshots
1. Gpx with waypoints 1. Simple GPX
1. Admin area - List of tracks 1. GPX with waypoints
1. Admin area - Settings 1. Admin area - List of tracks
1. Altitude & Speed 1. Admin area - Settings
1. Altitude & Speed & Heart rate 1. Altitude & Speed
1. Altitude & Speed & Heart rate
== Changelog ==
## Changelog
= 1.7.00 =
* Added: Authors can upload GPX tracks in a folder called as *your user name*, inside [../wp-upload dir/gpx/[*your user name*] (thanks to wildcomputations) ### X.X.XX
* Added: Authors an Admins can see the current values for shortcodes in help tab * Added: PHP version notices, WordPress 5.3 requires PHP 5.6.20
* Added: Button to instant copy the shortcode of the selected GPX file in the tab track * Added: Missing entries for add and delete options
* Added: different size logos for the plugin store (icon.svg, icon128x128.png and icon256x256.png) [inside ../plugins/wp-gpx-maps/assets] * Changed: Style for output moved in a seperate file
* Changed: Settings tab is for non-Admin users is not more visible * Tweak: Small design optimizations in the admin area
* Tweak: Help tab is easier to read * Tweak: Small code adjustments (WPCS)
* Tweak: Plugin is now complete translatable (Backend + Frontend) * Upgrade: bootstrap-table to 1.13.2
* Tweak: WordPress coding standards * Removed: german language file (now over translate.wordpress.org)
* Upgrade: Leaflet to 1.5.1 ### 1.7.00
* Upgrade: leaflet.fullscreen to 1.4.5 * Added: Authors can upload GPX tracks in a folder called as *your user name*, inside [../wp-upload dir/gpx/[*your user name*] (thanks to wildcomputations)
* Upgrade: Chart.min.js to 2.8.0 * Added: Authors an Admins can see the current values for shortcodes in help tab
= 1.6.07 = * Added: Button to instant copy the shortcode of the selected GPX file in the tab track
* resolve admin error * Added: different size logos for the plugin store (icon.svg, icon128x128.png and icon256x256.png) [inside ../plugins/wp-gpx-maps/assets]
= 1.6.06 = * Changed: Settings tab is for non-Admin users is not more visible
* Added average values under the graph (thanks to cyclinggeorgian) * Tweak: Help tab is easier to read
= 1.6.04 = * Tweak: Plugin is now complete translatable (Backend + Frontend)
* NGG gallery is working * Tweak: WordPress coding standards
* Getting HR, Cad and Temp working again (thanks to cyclinggeorgian) * Upgrade: Leaflet to 1.5.1
* Fix javascript errors * Upgrade: leaflet.fullscreen to 1.4.5
* Fix multiple traks gpx * Upgrade: Chart.min.js to 2.8.0
= 1.6.03 = ### 1.6.07
* Fix syntax error causing graph not to display (thanks to nickstabler) * resolve admin error
= 1.6.02 = ### 1.6.06
* Resolved errors with start and end icons * Added average values under the graph (thanks to cyclinggeorgian)
= 1.6.01 = ### 1.6.04
* Removed Gogole maps. Leafletjs instead. * NGG gallery is working
* -- NextGen Gallery is not working, due next gen image format changed -- I'll fix soon * Getting HR, Cad and Temp working again (thanks to cyclinggeorgian)
= 1.5.05 = * Fix javascript errors
* renamed javascript functions to avoid collision with other plugins * Fix multiple traks gpx
* reduced chart line thickness ### 1.6.03
= 1.5.04 = * Fix syntax error causing graph not to display (thanks to nickstabler)
* fix uom ### 1.6.02
* fix file not found * Resolved errors with start and end icons
= 1.5.03 = ### 1.6.01
* fix random error * Removed Gogole maps. Leafletjs instead.
= 1.5.02 = * -- NextGen Gallery is not working, due next gen image format changed -- I'll fix soon
* Security improvements ### 1.5.05
= 1.5.01 = * renamed javascript functions to avoid collision with other plugins
* Improved security * reduced chart line thickness
* Included javascript ### 1.5.04
* Multiple file upload * fix uom
* Implemented sorting in file list * fix file not found
* Renamed internal function to improve wp compatibility ### 1.5.03
= 1.5.00 = * fix random error
* replaced highcharts with chartjs. This is a forced choice due highcharts license issue, view: https://devfarm.it/wordpress-plugin/wordpress-plugin-directory-notice-wp-gpx-maps-temporarily-disabled/ ### 1.5.02
= 1.3.16 = * Security improvements
* Added Norwegian nb_NO translation (thanks to thordivel) ### 1.5.01
* Added Japanese ja_JP translation (thanks to dentos) * Improved security
= 1.3.15 = * Included javascript
* Switched to HTTPS where possible (thanks to delitestudio) * Multiple file upload
= 1.3.14 = * Implemented sorting in file list
* Added Thunderforest Api Key on settings: for OpenCycleMap * Renamed internal function to improve wp compatibility
= 1.3.13 = ### 1.5.00
* Added google maps api key on settings * replaced highcharts with chartjs. This is a forced choice due highcharts license issue, view: https://devfarm.it/wordpress-plugin/wordpress-plugin-directory-notice-wp-gpx-maps-temporarily-disabled/
* Removed parameter 'sensor' on google maps js ### 1.3.16
* Added unit of measure of speed for swimmers: min/100 meters * Added Norwegian nb_NO translation (thanks to thordivel)
= 1.3.12 = * Added Japanese ja_JP translation (thanks to dentos)
* Fix incompatibility with Debian PHP7 (thanks to phbaer) https://github.com/devfarm-it/wp-gpx-maps/pull/5 ### 1.3.15
= 1.3.10 = * Switched to HTTPS where possible (thanks to delitestudio)
* Improved german translations (thanks to Konrad) http://tadesse.de/7882/2015-wanderung-ostrov-tisa-ii/ ### 1.3.14
= 1.3.9 = * Added Thunderforest Api Key on settings: for OpenCycleMap
* Retrieve waypoints in JSON, possibility to add a custom marker (Changed by Michel Selerin) ### 1.3.13
= 1.3.8 = * Added google maps api key on settings
* Improved Google Maps visualization * Removed parameter 'sensor' on google maps js
= 1.3.7 = * Added unit of measure of speed for swimmers: min/100 meters
* NextGen Gallery's Attachment support. Thanks to Stephan Klein (https://klein-gedruckt.de/2015/03/wordpress-plugin-wp-gpx-maps/) ### 1.3.12
= 1.3.6 = * Fix incompatibility with Debian PHP7 (thanks to phbaer) https://github.com/devfarm-it/wp-gpx-maps/pull/5
* Fix: remote file download issue ### 1.3.10
* Fix: download file link with WPML * Improved german translations (thanks to Konrad) http://tadesse.de/7882/2015-wanderung-ostrov-tisa-ii/
* Improved cache with filetime (thanks to David) ### 1.3.9
= 1.3.5 = * Retrieve waypoints in JSON, possibility to add a custom marker (Changed by Michel Selerin)
* Fix: Garmin cadence again ### 1.3.8
* Fix: WP Tabs * Improved Google Maps visualization
= 1.3.4 = ### 1.3.7
* Fix: Garmin cadence * NextGen Gallery's Attachment support. Thanks to Stephan Klein (https://klein-gedruckt.de/2015/03/wordpress-plugin-wp-gpx-maps/)
* Infowindows closing on mouseout ### 1.3.6
= 1.3.3 = * Fix: remote file download issue
* Add feet/Nautical Miles units (thanks to elperepat) * Fix: download file link with WPML
* Update OpenStreetMaps Credits * Improved cache with filetime (thanks to David)
* WP Tabs fix ### 1.3.5
= 1.3.2 = * Fix: Garmin cadence again
* fix: left axis not visible (downgrade highcharts to v3.0.10) * Fix: WP Tabs
* fix: fullscreen map js error ### 1.3.4
= 1.3.1 = * Fix: Garmin cadence
* fix: http/https javascript registration * Infowindows closing on mouseout
* fix: full screen map css issue ### 1.3.3
= 1.3.0 = * Add feet/Nautical Miles units (thanks to elperepat)
* Speed improvement * Update OpenStreetMaps Credits
* Rewritten js classes * WP Tabs fix
* Added Temperature chart ### 1.3.2
* Added HTML5 Gps position (you can now follow the gpx with your mobile phone/tablet/pc) * fix: left axis not visible (downgrade highcharts to v3.0.10)
= 1.2.6 = * fix: fullscreen map js error
* Speed improvement ### 1.3.1
= 1.2.5 = * fix: http/https javascript registration
* Added Catalan translation, thanks to Edgar * fix: full screen map css issue
* Updated Spanish translation, thanks to Dani ### 1.3.0
* Added different types of distance: Normal, Flat (don't consider altitude) and Climb distance * Speed improvement
= 1.2.4 = * Rewritten js classes
* Added Bulgarian translation, thanks to Svilen Savov * Added Temperature chart
* Added possibility to hide the elevation chart * Added HTML5 Gps position (you can now follow the gpx with your mobile phone/tablet/pc)
= 1.2.2 = ### 1.2.6
* Smaller map type selector * Speed improvement
* New map: MapToolKit - Terrain ### 1.2.5
* Fix: Google maps exception for NextGen Gallery * Added Catalan translation, thanks to Edgar
= 1.2.1 = * Updated Spanish translation, thanks to Dani
* Fix: NextGen Gallery 1.9 compatibility * Added different types of distance: Normal, Flat (don't consider altitude) and Climb distance
= 1.2.0 = ### 1.2.4
* NextGen Gallery 2 support * Added Bulgarian translation, thanks to Svilen Savov
* NextGen Gallery Pro support * Added possibility to hide the elevation chart
= 1.1.46 = ### 1.2.2
* Added meters/miles chart unit of measure * Smaller map type selector
* Added Russian translation, thanks to G.A.P * New map: MapToolKit - Terrain
= 1.1.45 = * Fix: Google maps exception for NextGen Gallery
* Added nautical miles as distance (Many thanks to Anders) ### 1.2.1
= 1.1.44 = * Fix: NextGen Gallery 1.9 compatibility
* Added Chart zoom feature ### 1.2.0
* Some small bug fixes * NextGen Gallery 2 support
= 1.1.43 = * NextGen Gallery Pro support
* Added Portuguese (Brazilian) translation, thanks to André Ramos ### 1.1.46
* new map: Open Cycle Map - Transport * Added meters/miles chart unit of measure
* new map: Open Cycle Map - Landscape * Added Russian translation, thanks to G.A.P
= 1.1.42 = ### 1.1.45
* qTranslate compatible * Added nautical miles as distance (Many thanks to Anders)
= 1.1.41 = ### 1.1.44
* Added Polish translation, thanks to Sebastian * Added Chart zoom feature
* Fix: Spanish translation * Some small bug fixes
* Minor javascript improvement ### 1.1.43
= 1.1.40 = * Added Portuguese (Brazilian) translation, thanks to André Ramos
* Improved italian translation * new map: Open Cycle Map - Transport
* Added grade chart (beta) * new map: Open Cycle Map - Landscape
= 1.1.39 = ### 1.1.42
* Added French translation, thanks to Hervé * qTranslate compatible
* Added Nautical Miles per Hour (Knots) unit of measure ### 1.1.41
= 1.1.38 = * Added Polish translation, thanks to Sebastian
* Fix: garmin gpx cadence and heart rate * Fix: Spanish translation
* Updated Turkish translation, thanks to Edip * Minor javascript improvement
* Added Hungarian translation, thanks to Tami ### 1.1.40
= 1.1.36 = * Improved italian translation
* Even Editor and Author users can upload their own gpx. Administrators can see all the administrators gpx. The other users can see only their uploads * Added grade chart (beta)
= 1.1.35 = ### 1.1.39
* Fix: In the post list, sometime, the maps was not displaying correctly ( the php rand() function was not working?? ) * Added French translation, thanks to Hervé
* Various improvements for multi track gpx. Thanks to GPSracks.tv * Added Nautical Miles per Hour (Knots) unit of measure
* Summary table is now avaiable even without chart. Thanks to David ### 1.1.38
= 1.1.34 = * Fix: garmin gpx cadence and heart rate
* 2 decimals for unit of measure min/km and min/mi * Updated Turkish translation, thanks to Edip
* translation file updated (a couple of phrases added) * Added Hungarian translation, thanks to Tami
* File list reverse order (from the newer to the older) ### 1.1.36
* nggallery integration: division by zero fixed * Even Editor and Author users can upload their own gpx. Administrators can see all the administrators gpx. The other users can see only their uploads
= 1.1.33 = ### 1.1.35
* Decimals reducted to 1 for unit of measure min/km and min/mi * Fix: In the post list, sometime, the maps was not displaying correctly ( the php rand() function was not working?? )
* map zoom and center position is working with waypoints only files * Various improvements for multi track gpx. Thanks to GPSracks.tv
* automatic scale works again (thanks to MArkus) * Summary table is now avaiable even without chart. Thanks to David
= 1.1.32 = ### 1.1.34
* You can exclude cache (slower and not recommended) * 2 decimals for unit of measure min/km and min/mi
* You can decide what show in the summary table * translation file updated (a couple of phrases added)
* German translation (thanks to Ali) * File list reverse order (from the newer to the older)
= 1.1.31 = * nggallery integration: division by zero fixed
* Fixed fullscreen map image slideshow ### 1.1.33
= 1.1.30 = * Decimals reducted to 1 for unit of measure min/km and min/mi
* Multi track gpx support * map zoom and center position is working with waypoints only files
* Next Gen Gallery images positions derived from date. You can adjust the date with the shortcode attribute dtoffset * automatic scale works again (thanks to MArkus)
* If you set Chart Height (shortcode gheight) = 0 means hide the graph ### 1.1.32
* Fix: All images should work, independent from browser cache * You can exclude cache (slower and not recommended)
= 1.1.29 = * You can decide what show in the summary table
* Decimal separator is working with all the browsers * German translation (thanks to Ali)
* minutes per mile and minutes per kilometer was wrong ### 1.1.31
= 1.1.28 = * Fixed fullscreen map image slideshow
* Decimal and thousand separator derived from browser language ### 1.1.30
* Added summary table (see settings): Total distance, Max elevation, Min elevation, Total climbing, Total descent, Average speed * Multi track gpx support
* Added 2 speed units of measure: minutes per mile and minutes per kilometer * Next Gen Gallery images positions derived from date. You can adjust the date with the shortcode attribute dtoffset
= 1.1.26 = * If you set Chart Height (shortcode gheight) 0 means hide the graph
* Multilanguage implementation (only front-end). I've implemented the italian one, I hope somebody will help me with other languages.. * Fix: All images should work, independent from browser cache
* Map Full screen mode (I'm sure it's not working in ie6. don't even ask!) ### 1.1.29
* Added waypoint custom icon * Decimal separator is working with all the browsers
= 1.1.25 = * minutes per mile and minutes per kilometer was wrong
* Added possibility to download your gpx ### 1.1.28
= 1.1.23 = * Decimal and thousand separator derived from browser language
* Security fix, please update! * Added summary table (see settings): Total distance, Max elevation, Min elevation, Total climbing, Total descent, Average speed
= 1.1.22 = * Added 2 speed units of measure: minutes per mile and minutes per kilometer
* enable map zoom on scroll wheel (check settings) ### 1.1.26
* test attributes in get params * Multilanguage implementation (only front-end). I've implemented the italian one, I hope somebody will help me with other languages..
= 1.1.21 = * Map Full screen mode (I'm sure it's not working in ie6. don't even ask!)
* google maps images fixed (templates with bad css) * Added waypoint custom icon
* upgrade to google maps 3.9 ### 1.1.25
= 1.1.20 = * Added possibility to download your gpx
* google maps images fixed in <a href="http://wordpress.org/extend/themes/yoko">Yoko theme</a> ### 1.1.23
= 1.1.19 = * Security fix, please update!
* include jQuery if needed ### 1.1.22
= 1.1.17 = * enable map zoom on scroll wheel (check settings)
* Remove zero values from cadence and heart rate charts * test attributes in get params
* nextgen gallery improvement ### 1.1.21
= 1.1.16 = * google maps images fixed (templates with bad css)
* Cadence chart (where available) * upgrade to google maps 3.9
* minor bug fixes ### 1.1.20
= 1.1.15 = * google maps images fixed in <a href"http://wordpress.org/extend/themes/yoko">Yoko theme</a>
* migration from google chart to highcharts. Highcharts are much better than google chart! This is the base for a new serie of improvements. Stay in touch for the next releases! ### 1.1.19
* heart rate chart (where available) * include jQuery if needed
= 1.1.14 = ### 1.1.17
* added css to avoid map bars display issue * Remove zero values from cadence and heart rate charts
= 1.1.13 = * nextgen gallery improvement
* added new types of maps: Open Street Map, Open Cycle Map, Hike & Bike. ### 1.1.16
* fixed nextgen gallery caching problem * Cadence chart (where available)
= 1.1.12 = * minor bug fixes
* nextgen gallery display bug fixes ### 1.1.15
* migration from google chart to highcharts. Highcharts are much better than google chart! This is the base for a new serie of improvements. Stay in touch for the next releases!
== Upgrade Notice == * heart rate chart (where available)
### 1.1.14
* added css to avoid map bars display issue
### 1.1.13
* added new types of maps: Open Street Map, Open Cycle Map, Hike & Bike.
* fixed nextgen gallery caching problem
### 1.1.12
* nextgen gallery display bug fixes
## Upgrade Notice

View File

@ -7,6 +7,7 @@
* 2. Tab: Tracks * 2. Tab: Tracks
* 3. Tab: Settings * 3. Tab: Settings
* 4. Tab: Help * 4. Tab: Help
*
*/ */
/** /**
@ -16,15 +17,31 @@
/** /**
* 2.0 Tab: Tracks * 2.0 Tab: Tracks
*/ */
#table tbody tr:hover {
background: #eee;
}
/** /**
* 3.0 Tab: Settings * 3.0 Tab: Settings
*/ */
.wpgpxmaps-container-tab-settings { .wpgpxmaps-container-tab-settings {
display: block; display: block;
padding: 5px 20px 1px 20px; padding: 5px 20px 1px 20px;
} }
.wpgpxmaps-container-tab-settings table.form-table input[type="checkbox"] {
margin-top: -4px;
margin-right: 4px;
}
.wpgpxmaps-container-tab-settings table.form-table input[type="radio"] {
margin-right: 4px;
}
.wpgpxmaps-container-tab-settings table.form-table input[type="text"] {
margin-right: 4px;
}
/** /**
* 4.0 Tab: Tracks * 4.0 Tab: Tracks
*/ */
@ -44,8 +61,12 @@
border-radius: 6px; border-radius: 6px;
} }
.wpgpxmaps-container-tab-faq table.widefat tbody tr:hover { .wpgpxmaps-container-tab-faq table.widefat thead th.title {
background:#eeeeee; font-weight: 650;
}
.wpgpxmaps-container-tab-faq table.widefat td {
width: 200px;
} }
.wpgpxmaps-container-tab-faq table.widefat th, .wpgpxmaps-container-tab-faq table.widefat th,
@ -53,10 +74,11 @@
padding: 4px 10px; padding: 4px 10px;
} }
.wpgpxmaps-container-tab-faq table.widefat thead tr th { .wpgpxmaps-container-tab-faq table.widefat tbody tr:hover {
font-size: 14px; background: #eee;
} }
.wpgpxmaps-container-tab-faq table.widefat td {
width: 200px; .wpgpxmaps-container-tab-faq table.widefat thead th {
font-size: 14px;
} }

337
css/bootstrap-table.css vendored Normal file
View File

@ -0,0 +1,337 @@
/**
* @author zhixin wen <wenzhixin2010@gmail.com>
* version: 1.13.2
* https://github.com/wenzhixin/bootstrap-table/
*/
.bootstrap-table .table {
margin-bottom: 0 !important;
border-bottom: 1px solid #dddddd;
border-collapse: collapse !important;
border-radius: 1px;
}
.bootstrap-table .table:not(.table-condensed),
.bootstrap-table .table:not(.table-condensed) > tbody > tr > th,
.bootstrap-table .table:not(.table-condensed) > tfoot > tr > th,
.bootstrap-table .table:not(.table-condensed) > thead > tr > td,
.bootstrap-table .table:not(.table-condensed) > tbody > tr > td,
.bootstrap-table .table:not(.table-condensed) > tfoot > tr > td {
padding: 8px;
}
.bootstrap-table .table.table-no-bordered > thead > tr > th {
border-top: none;
}
.bootstrap-table .table.table-no-bordered > thead > tr > th,
.bootstrap-table .table.table-no-bordered > tbody > tr > td {
border-right: 2px solid transparent;
}
.bootstrap-table .table.table-no-bordered > tbody > tr > td:last-child {
border-right: none;
}
.fixed-table-container {
position: relative;
clear: both;
border: 1px solid #dddddd;
border-radius: 4px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
}
.fixed-table-container.table-no-bordered {
border: 1px solid transparent;
}
.fixed-table-footer,
.fixed-table-header {
overflow: hidden;
}
.fixed-table-footer {
border-top: 1px solid #dddddd;
}
.fixed-table-body {
overflow-x: auto;
overflow-y: auto;
height: 100%;
}
.fixed-table-container table {
width: 100%;
}
.fixed-table-container thead th {
height: 0;
padding: 0;
margin: 0;
border-left: 1px solid #dddddd;
}
.fixed-table-container thead th:focus {
outline: 0 solid transparent;
}
.fixed-table-container thead th:first-child:not([data-not-first-th]) {
border-left: none;
border-top-left-radius: 4px;
-webkit-border-top-left-radius: 4px;
-moz-border-radius-topleft: 4px;
}
.fixed-table-container thead th .th-inner,
.fixed-table-container tbody td .th-inner {
padding: 8px;
line-height: 24px;
vertical-align: top;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.fixed-table-container thead th .sortable {
cursor: pointer;
background-position: right;
background-repeat: no-repeat;
padding-right: 30px;
}
.fixed-table-container thead th .both {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAQAAADYWf5HAAAAkElEQVQoz7X QMQ5AQBCF4dWQSJxC5wwax1Cq1e7BAdxD5SL+Tq/QCM1oNiJidwox0355mXnG/DrEtIQ6azioNZQxI0ykPhTQIwhCR+BmBYtlK7kLJYwWCcJA9M4qdrZrd8pPjZWPtOqdRQy320YSV17OatFC4euts6z39GYMKRPCTKY9UnPQ6P+GtMRfGtPnBCiqhAeJPmkqAAAAAElFTkSuQmCC');
}
.fixed-table-container thead th .asc {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZ0lEQVQ4y2NgGLKgquEuFxBPAGI2ahhWCsS/gDibUoO0gPgxEP8H4ttArEyuQYxAPBdqEAxPBImTY5gjEL9DM+wTENuQahAvEO9DMwiGdwAxOymGJQLxTyD+jgWDxCMZRsEoGAVoAADeemwtPcZI2wAAAABJRU5ErkJggg==');
}
.fixed-table-container thead th .desc {
background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAAAZUlEQVQ4y2NgGAWjYBSggaqGu5FA/BOIv2PBIPFEUgxjB+IdQPwfC94HxLykus4GiD+hGfQOiB3J8SojEE9EM2wuSJzcsFMG4ttQgx4DsRalkZENxL+AuJQaMcsGxBOAmGvopk8AVz1sLZgg0bsAAAAASUVORK5CYII= ');
}
.fixed-table-container th.detail {
width: 30px;
}
.fixed-table-container tbody td {
border-left: 1px solid #dddddd;
}
.fixed-table-container tbody tr:first-child td {
border-top: none;
}
.fixed-table-container tbody td:first-child {
border-left: none;
}
/* the same color with .active */
.fixed-table-container tbody .selected td {
background-color: #f5f5f5;
}
.fixed-table-container .bs-checkbox {
text-align: center;
}
.fixed-table-container input[type="radio"],
.fixed-table-container input[type="checkbox"] {
margin: 0 auto !important;
}
.fixed-table-container .no-records-found {
text-align: center;
}
.fixed-table-pagination div.pagination,
.fixed-table-pagination .pagination-detail {
margin-top: 10px;
margin-bottom: 10px;
}
.fixed-table-pagination div.pagination .pagination {
margin: 0;
}
.fixed-table-pagination .pagination a {
padding: 6px 12px;
line-height: 1.428571429;
}
.fixed-table-pagination ul.pagination li.page-intermediate a {
color:#c8c8c8;
}
.fixed-table-pagination ul.pagination li.page-intermediate a:before {
content: '\2B05';
}
.fixed-table-pagination ul.pagination li.page-intermediate a:after {
content: '\27A1';
}
.fixed-table-pagination .pagination-info {
line-height: 34px;
margin-right: 5px;
}
.fixed-table-pagination .btn-group {
position: relative;
display: inline-block;
vertical-align: middle;
}
.fixed-table-pagination .dropup .dropdown-menu {
margin-bottom: 0;
}
.fixed-table-pagination .page-list {
display: inline-block;
}
.fixed-table-toolbar .columns-left {
margin-right: 5px;
}
.fixed-table-toolbar .columns-right {
margin-left: 5px;
}
.fixed-table-toolbar .columns label {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.428571429;
}
.fixed-table-toolbar .bs-bars,
.fixed-table-toolbar .search,
.fixed-table-toolbar .columns {
position: relative;
margin-top: 10px;
margin-bottom: 10px;
}
.fixed-table-pagination li.disabled a {
pointer-events: none;
cursor: default;
}
.fixed-table-loading {
display: none;
position: absolute;
top: 42px;
right: 0;
bottom: 0;
left: 0;
z-index: 99;
background-color: #fff;
text-align: center;
}
.fixed-table-body .card-view .title {
font-weight: bold;
display: inline-block;
min-width: 30%;
text-align: left !important;
}
/* support bootstrap 2 */
.fixed-table-body thead th .th-inner {
box-sizing: border-box;
}
.table th, .table td {
vertical-align: middle;
box-sizing: border-box;
}
.fixed-table-toolbar .dropdown-menu {
text-align: left;
max-height: 300px;
overflow: auto;
}
.fixed-table-toolbar .btn-group > .btn-group {
display: inline-block;
margin-left: -1px !important;
}
.fixed-table-toolbar .btn-group > .btn-group > .btn {
border-radius: 0;
}
.fixed-table-toolbar .btn-group > .btn-group:first-child > .btn {
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.fixed-table-toolbar .btn-group > .btn-group:last-child > .btn {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.bootstrap-table .table > thead > tr > th {
vertical-align: bottom;
border-bottom: 1px solid #ddd;
}
.bootstrap-table .table > thead.thead-dark > tr > th {
border-bottom: 1px solid #212529;
}
/* support bootstrap 3 */
.bootstrap-table .table thead > tr > th {
padding: 0;
margin: 0;
}
.bootstrap-table .fixed-table-footer tbody > tr > td {
padding: 0 !important;
}
.bootstrap-table .fixed-table-footer .table {
border-bottom: none;
border-radius: 0;
padding: 0 !important;
}
.bootstrap-table .pull-right .dropdown-menu {
right: 0;
left: auto;
}
/* calculate scrollbar width */
p.fixed-table-scroll-inner {
width: 100%;
height: 200px;
}
div.fixed-table-scroll-outer {
top: 0;
left: 0;
visibility: hidden;
width: 200px;
height: 150px;
overflow: hidden;
}
/* for get correct heights */
.fixed-table-toolbar:after, .fixed-table-pagination:after {
content: "";
display: block;
clear: both;
}
.bootstrap-table.fullscreen {
position: fixed;
top: 0;
left: 0;
z-index: 1050;
width: 100%!important;
background: #FFF;
}

65
css/output-style.css Normal file
View File

@ -0,0 +1,65 @@
/**
* This file contains the style definitions for the output
*
*/
.wpgpxmaps img,
.entry-content .wpgpxmaps img,
#content .wpgpxmaps img {
width: none;
max-width: none;
margin: 0;
padding: 0;
border: none;
background: none;
}
.wpgpxmaps {
clear: both;
}
.wpgpxmaps .ngimages {
display: none;
}
.wpgpxmaps .myngimages {
position: absolute;
z-index :1;
margin:0;
border: 1px solid #fff;
cursor: pointer;
}
.wpgpxmaps_summary .summarylabel {
font-weight: 400;
}
.wpgpxmaps_summary .summaryvalue {
font-weight: 600;
}
.wpgpxmaps .report {
line-height :120;
}
.wpgpxmaps .gmnoprint div:first-child { }
.wpgpxmaps .wpgpxmaps_osm_footer {
position: absolute;
z-index: 999;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 13px;
margin: 0;
background: #fff;
font-size: 12px;
}
.wpgpxmaps .wpgpxmaps_osm_footer span {
position: absolute;
bottom: 0;
padding: 0 6px 6px 6px;
background: #fff;
vertical-align: baseline;
}

View File

@ -48,7 +48,7 @@ var WPGPXMAPS = {
MapEngines: { MapEngines: {
/* NOT WORKING AND TESTED! old code copy&pate */ /* NOT WORKING AND TESTED! old code copy&paste */
GoogleMaps: function() { GoogleMaps: function() {
this.map = null, this.map = null,
this.EventSelectChart = null, this.EventSelectChart = null,

3223
js/bootstrap-table.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

2
users.txt Normal file
View File

@ -0,0 +1,2 @@
bastianonm = bastianonm <bastianonm>
plugin-master = plugin-master <plugin-master>

View File

@ -3,11 +3,12 @@
* Plugin Name: WP-GPX-Maps * Plugin Name: WP-GPX-Maps
* Plugin URI: http://www.devfarm.it/ * Plugin URI: http://www.devfarm.it/
* Description: Draws a GPX track with altitude chart * Description: Draws a GPX track with altitude chart
* Version: 1.7.00 * Version: 1.7.00.1
* Author: Bastianon Massimo * Author: Bastianon Massimo
* Author URI: http://www.devfarm.it/ * Author URI: http://www.devfarm.it/
* Text Domain: wp-gpx-maps * Text Domain: wp-gpx-maps
* Domain Path: /languages * Domain Path: /languages
* Gitea Plugin URI: https://gitea.dyomedea.com/Dyomedea/wp-gpx-maps
* *
* @package WP-GPX-Maps * @package WP-GPX-Maps
*/ */
@ -22,7 +23,6 @@ add_shortcode( 'sgpxf', 'handle_WP_GPX_Maps_folder_Shortcodes' );
register_activation_hook( __FILE__, 'WP_GPX_Maps_install' ); register_activation_hook( __FILE__, 'WP_GPX_Maps_install' );
register_deactivation_hook( __FILE__, 'WP_GPX_Maps_remove' ); register_deactivation_hook( __FILE__, 'WP_GPX_Maps_remove' );
add_filter( 'plugin_action_links', 'WP_GPX_Maps_action_links', 10, 2 ); add_filter( 'plugin_action_links', 'WP_GPX_Maps_action_links', 10, 2 );
add_action( 'wp_print_styles', 'print_WP_GPX_Maps_styles' );
add_action( 'wp_enqueue_scripts', 'enqueue_WP_GPX_Maps_scripts' ); add_action( 'wp_enqueue_scripts', 'enqueue_WP_GPX_Maps_scripts' );
add_action( 'admin_enqueue_scripts', 'enqueue_WP_GPX_Maps_scripts_admin' ); add_action( 'admin_enqueue_scripts', 'enqueue_WP_GPX_Maps_scripts_admin' );
add_action( 'plugins_loaded', 'WP_GPX_Maps_lang_init' ); add_action( 'plugins_loaded', 'WP_GPX_Maps_lang_init' );
@ -64,29 +64,38 @@ function enqueue_WP_GPX_Maps_scripts_admin( $hook ) {
if ( strpos( $hook, 'WP-GPX-Maps' ) !== false ) { if ( strpos( $hook, 'WP-GPX-Maps' ) !== false ) {
/* Admin Style CSS */ /* Admin Style CSS */
wp_register_style( 'admin-stye', plugins_url( 'css/admin-style.css', __FILE__ ), array(), '1.0.0' ); wp_register_style( 'admin-style', plugins_url( 'css/admin-style.css', __FILE__ ), array(), '1.0.0' );
wp_enqueue_style( 'admin-stye' ); wp_enqueue_style( 'admin-style' );
/* mColorPicker */ /* mColorPicker */
wp_register_script( 'mColorPicker', plugins_url( '/js/mColorPicker_min.js', __FILE__ ), array(), '1.0 r39' ); wp_register_script( 'mColorPicker', plugins_url( '/js/mColorPicker_min.js', __FILE__ ), array(), '1.0 r39' );
wp_enqueue_script( 'mColorPicker' ); wp_enqueue_script( 'mColorPicker' );
/* bootstrap-table */ /* bootstrap-table */
wp_register_script( 'bootstrap-table', plugins_url( '/js/bootstrap-table.min.js', __FILE__ ), array(), '1.11.1' ); wp_register_script( 'bootstrap-table', plugins_url( '/js/bootstrap-table.js', __FILE__ ), array(), '1.13.2' );
wp_enqueue_script( 'bootstrap-table' ); wp_enqueue_script( 'bootstrap-table' );
wp_register_style( 'bootstrap-table', plugins_url( '/css/bootstrap-table.min.css', __FILE__ ), array(), '1.11.1' ); wp_register_style( 'bootstrap-table', plugins_url( '/css/bootstrap-table.css', __FILE__ ), array(), '1.13.2' );
wp_enqueue_style( 'bootstrap-table' ); wp_enqueue_style( 'bootstrap-table' );
} }
} }
function enqueue_WP_GPX_Maps_scripts() { function enqueue_WP_GPX_Maps_scripts() {
/* leaflet */ /* Output Style CSS */
wp_register_style( 'output-style', plugins_url( 'css/output-style.css', __FILE__ ), array(), '1.0.0' );
wp_enqueue_style( 'output-style' );
/* Leaflet */
wp_register_style( 'leaflet', plugins_url( '/ThirdParties/Leaflet_1.5.1/leaflet.css', __FILE__ ), array(), '1.5.1' ); wp_register_style( 'leaflet', plugins_url( '/ThirdParties/Leaflet_1.5.1/leaflet.css', __FILE__ ), array(), '1.5.1' );
wp_enqueue_style( 'leaflet' ); wp_enqueue_style( 'leaflet' );
/* Leaflet.markercluster */
wp_register_style( 'leaflet.markercluster', plugins_url( '/ThirdParties/Leaflet.markercluster-1.4.1/MarkerCluster.css', __FILE__ ), array(), '1.4.1,' ); wp_register_style( 'leaflet.markercluster', plugins_url( '/ThirdParties/Leaflet.markercluster-1.4.1/MarkerCluster.css', __FILE__ ), array(), '1.4.1,' );
wp_enqueue_style( 'leaflet.markercluster' ); wp_enqueue_style( 'leaflet.markercluster' );
/* Leaflet.Photo */
wp_register_style( 'leaflet.Photo', plugins_url( '/ThirdParties/Leaflet.Photo/Leaflet.Photo.css', __FILE__ ), array(), '0' ); wp_register_style( 'leaflet.Photo', plugins_url( '/ThirdParties/Leaflet.Photo/Leaflet.Photo.css', __FILE__ ), array(), '0' );
wp_enqueue_style( 'leaflet.Photo' ); wp_enqueue_style( 'leaflet.Photo' );
/* Leaflet.fullscreen */
wp_register_style( 'leaflet.fullscreen', plugins_url( '/ThirdParties/leaflet.fullscreen-1.4.5/Control.FullScreen.css', __FILE__ ), array(), '1.5.1' ); wp_register_style( 'leaflet.fullscreen', plugins_url( '/ThirdParties/leaflet.fullscreen-1.4.5/Control.FullScreen.css', __FILE__ ), array(), '1.5.1' );
wp_enqueue_style( 'leaflet.fullscreen' ); wp_enqueue_style( 'leaflet.fullscreen' );
@ -95,11 +104,12 @@ function enqueue_WP_GPX_Maps_scripts() {
wp_register_script( 'leaflet.Photo', plugins_url( '/ThirdParties/Leaflet.Photo/Leaflet.Photo.js', __FILE__ ), array( 'leaflet', 'leaflet.markercluster' ), '0' ); wp_register_script( 'leaflet.Photo', plugins_url( '/ThirdParties/Leaflet.Photo/Leaflet.Photo.js', __FILE__ ), array( 'leaflet', 'leaflet.markercluster' ), '0' );
wp_register_script( 'leaflet.fullscreen', plugins_url( '/ThirdParties/leaflet.fullscreen-1.4.5/Control.FullScreen.js', __FILE__ ), array( 'leaflet' ), '1.4.5' ); wp_register_script( 'leaflet.fullscreen', plugins_url( '/ThirdParties/leaflet.fullscreen-1.4.5/Control.FullScreen.js', __FILE__ ), array( 'leaflet' ), '1.4.5' );
/* chartjs */ /* Chartjs */
wp_register_script( 'chartjs', plugins_url( '/js/Chart.min.js', __FILE__ ), array(), '2.8.0' ); wp_register_script( 'chartjs', plugins_url( '/js/Chart.min.js', __FILE__ ), array(), '2.8.0' );
wp_register_script( 'WP-GPX-Maps', plugins_url( '/js/WP-GPX-Maps.js', __FILE__ ), array( 'jquery', 'leaflet', 'chartjs' ), '1.6.02' ); wp_register_script( 'WP-GPX-Maps', plugins_url( '/js/WP-GPX-Maps.js', __FILE__ ), array( 'jquery', 'leaflet', 'chartjs' ), '1.6.02' );
wp_enqueue_script( 'output-style' );
wp_enqueue_script( 'leaflet' ); wp_enqueue_script( 'leaflet' );
wp_enqueue_script( 'leaflet.markercluster' ); wp_enqueue_script( 'leaflet.markercluster' );
wp_enqueue_script( 'leaflet.Photo' ); wp_enqueue_script( 'leaflet.Photo' );
@ -109,72 +119,6 @@ function enqueue_WP_GPX_Maps_scripts() {
wp_enqueue_script( 'WP-GPX-Maps' ); wp_enqueue_script( 'WP-GPX-Maps' );
} }
function print_WP_GPX_Maps_styles() {
?>
<style type="text/css">
.wpgpxmaps {
clear: both;
}
#content .wpgpxmaps img,
.entry-content .wpgpxmaps img,
.wpgpxmaps img {
max-width: none;
width: none;
padding: 0;
background: none;
margin: 0;
border: none;
}
.wpgpxmaps .ngimages {
display: none;
}
.wpgpxmaps .myngimages {
border: 1px solid #fff;
position: absolute;
cursor: pointer;
margin:0;
z-index :1;
}
.wpgpxmaps_summary .summarylabel { }
.wpgpxmaps_summary .summaryvalue {
font-weight: bold;
}
.wpgpxmaps .report {
line-height :120%;
}
.wpgpxmaps .gmnoprint div:first-child { }
.wpgpxmaps .wpgpxmaps_osm_footer {
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 13px;
margin: 0;
z-index: 999;
background: WHITE;
font-size: 12px;
}
.wpgpxmaps .wpgpxmaps_osm_footer span {
background: WHITE;
padding: 0 6px 6px 6px;
vertical-align: baseline;
position: absolute;
bottom: 0;
}
</style>
<?php
}
function wpgpxmaps_findValue( $attr, $attributeName, $optionName, $defaultValue ) { function wpgpxmaps_findValue( $attr, $attributeName, $optionName, $defaultValue ) {
$val = ''; $val = '';
@ -216,20 +160,20 @@ function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
$gpx = $folder . DIRECTORY_SEPARATOR . $file; $gpx = $folder . DIRECTORY_SEPARATOR . $file;
$points = wpgpxmaps_getPoints( $gpx, $pointsoffset, $donotreducegpx, $distanceType ); $points = wpgpxmaps_getPoints( $gpx, $pointsoffset, $donotreducegpx, $distanceType );
$points_maps = ''; $points_maps = '';
$points_graph_dist = ''; $points_graph_dist = '';
$points_graph_ele = ''; $points_graph_ele = '';
if ( is_array ( $points_x_lat ) ) if ( is_array( $points_x_lat ) )
foreach ( array_keys( $points_x_lat ) as $i ) { foreach ( array_keys( $points_x_lat ) as $i ) {
$_lat = (float) $points_x_lat[$i]; $_lat = (float) $points_x_lat[$i];
$_lon = (float) $points_x_lon[$i]; $_lon = (float) $points_x_lon[$i];
if ( $_lat == 0 && $_lon == 0 ) { if ( $_lat == 0 && $_lon == 0 ) {
$points_maps .= 'null,'; $points_maps .= 'null,';
$points_graph_dist .= 'null,'; $points_graph_dist .= 'null,';
$points_graph_ele .= 'null,'; $points_graph_ele .= 'null,';
} else { } else {
$points_maps .= '[' . number_format( (float) $points_x_lat[$i], 7, '.', '' ) . ',' . number_format( (float) $points_x_lon[$i], 7, '.', '' ) . '],'; $points_maps .= '[' . number_format( (float) $points_x_lat[$i], 7, '.', '' ) . ',' . number_format( (float) $points_x_lon[$i], 7, '.', '' ) . '],';
@ -238,7 +182,7 @@ function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
$_dist = (float) $points->dist[$i]; $_dist = (float) $points->dist[$i];
if ( $uom == '1' ) { if ( $uom == '1' ) {
/* miles and feet */ /* feet / miles */
$_dist *= 0.000621371192; $_dist *= 0.000621371192;
$_ele *= 3.2808399; $_ele *= 3.2808399;
@ -247,7 +191,7 @@ function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
$_dist = (float) ( $_dist / 1000 ); $_dist = (float) ( $_dist / 1000 );
} elseif ( $uom == '3' ) { } elseif ( $uom == '3' ) {
/* meters / kilometers / nautical miles */ /* meters / nautical miles */
$_dist = (float) ( $_dist / 1000 / 1.852 ); $_dist = (float) ( $_dist / 1000 / 1.852 );
} elseif ( $uom == '4' ) { } elseif ( $uom == '4' ) {
@ -255,7 +199,7 @@ function handle_WP_GPX_Maps_folder_Shortcodes( $attr, $content = '' ) {
$_dist *= 0.000621371192; $_dist *= 0.000621371192;
} elseif ( $uom == '5' ) { } elseif ( $uom == '5' ) {
/* meters / kilometers / nautical miles and feet */ /* feet / nautical miles */
$_dist = (float) ( $_dist / 1000 / 1.852 ); $_dist = (float) ( $_dist / 1000 / 1.852 );
$_ele *= 3.2808399; $_ele *= 3.2808399;
} }
@ -283,7 +227,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$download = wpgpxmaps_findValue( $attr, 'download', 'wpgpxmaps_download', '' ); $download = wpgpxmaps_findValue( $attr, 'download', 'wpgpxmaps_download', '' );
$usegpsposition = wpgpxmaps_findValue( $attr, 'usegpsposition', 'wpgpxmaps_usegpsposition', false ); $usegpsposition = wpgpxmaps_findValue( $attr, 'usegpsposition', 'wpgpxmaps_usegpsposition', false );
/* Print Summary Table */ /* Print Summary Table */
$summary = wpgpxmaps_findValue( $attr, 'summary', 'wpgpxmaps_summary', '' ); $summary = wpgpxmaps_findValue( $attr, 'summary', 'wpgpxmaps_summary', false );
$p_tot_len = wpgpxmaps_findValue( $attr, 'summarytotlen', 'wpgpxmaps_summary_tot_len', false ); $p_tot_len = wpgpxmaps_findValue( $attr, 'summarytotlen', 'wpgpxmaps_summary_tot_len', false );
$p_max_ele = wpgpxmaps_findValue( $attr, 'summarymaxele', 'wpgpxmaps_summary_max_ele', false ); $p_max_ele = wpgpxmaps_findValue( $attr, 'summarymaxele', 'wpgpxmaps_summary_max_ele', false );
$p_min_ele = wpgpxmaps_findValue( $attr, 'summaryminele', 'wpgpxmaps_summary_min_ele', false ); $p_min_ele = wpgpxmaps_findValue( $attr, 'summaryminele', 'wpgpxmaps_summary_min_ele', false );
@ -305,7 +249,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$currentIcon = wpgpxmaps_findValue( $attr, 'currenticon', 'wpgpxmaps_map_current_icon', '' ); $currentIcon = wpgpxmaps_findValue( $attr, 'currenticon', 'wpgpxmaps_map_current_icon', '' );
$waypointIcon = wpgpxmaps_findValue( $attr, 'waypointicon', 'wpgpxmaps_map_waypoint_icon', '' ); $waypointIcon = wpgpxmaps_findValue( $attr, 'waypointicon', 'wpgpxmaps_map_waypoint_icon', '' );
/* Diagram - Elevation */ /* Diagram - Elevation */
$showEle = wpgpxmaps_findValue( $attr, 'showele', 'wpgpxmaps_show_elevation', 'true' ); $showEle = wpgpxmaps_findValue( $attr, 'showele', 'wpgpxmaps_show_elevation', true );
$color_graph = wpgpxmaps_findValue( $attr, 'glinecolor', 'wpgpxmaps_graph_line_color', '#3366cc' ); $color_graph = wpgpxmaps_findValue( $attr, 'glinecolor', 'wpgpxmaps_graph_line_color', '#3366cc' );
$uom = wpgpxmaps_findValue( $attr, 'uom', 'wpgpxmaps_unit_of_measure', '0' ); $uom = wpgpxmaps_findValue( $attr, 'uom', 'wpgpxmaps_unit_of_measure', '0' );
$chartFrom1 = wpgpxmaps_findValue( $attr, 'chartfrom1', 'wpgpxmaps_graph_offset_from1', '' ); $chartFrom1 = wpgpxmaps_findValue( $attr, 'chartfrom1', 'wpgpxmaps_graph_offset_from1', '' );
@ -323,8 +267,8 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$showAtemp = wpgpxmaps_findValue( $attr, 'showatemp', 'wpgpxmaps_show_atemp', false ); $showAtemp = wpgpxmaps_findValue( $attr, 'showatemp', 'wpgpxmaps_show_atemp', false );
$color_graph_atemp = wpgpxmaps_findValue( $attr, 'glinecoloratemp', 'wpgpxmaps_graph_line_color_atemp', '#ff77bd' ); $color_graph_atemp = wpgpxmaps_findValue( $attr, 'glinecoloratemp', 'wpgpxmaps_graph_line_color_atemp', '#ff77bd' );
/* Diagram - Cadence */ /* Diagram - Cadence */
$showCad = wpgpxmaps_findValue( $attr, 'showcad', 'wpgpxmaps_show_cadence', false ); $showCad = wpgpxmaps_findValue( $attr, 'showcad', 'wpgpxmaps_show_cadence', false );
$color_graph_cad = wpgpxmaps_findValue( $attr, 'glinecolorcad', 'wpgpxmaps_graph_line_color_cad', '#beecff' ); $color_graph_cad = wpgpxmaps_findValue( $attr, 'glinecolorcad', 'wpgpxmaps_graph_line_color_cad', '#beecff' );
/* Diagram - Grade */ /* Diagram - Grade */
$showGrade = wpgpxmaps_findValue( $attr, 'showgrade', 'wpgpxmaps_show_grade', false ); $showGrade = wpgpxmaps_findValue( $attr, 'showgrade', 'wpgpxmaps_show_grade', false );
$color_graph_grade = wpgpxmaps_findValue( $attr, 'glinecolorgrade', 'wpgpxmaps_graph_line_color_grade', '#beecff' ); $color_graph_grade = wpgpxmaps_findValue( $attr, 'glinecolorgrade', 'wpgpxmaps_graph_line_color_grade', '#beecff' );
@ -338,7 +282,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$donotreducegpx = wpgpxmaps_findValue( $attr, 'donotreducegpx', 'wpgpxmaps_donotreducegpx', false ); $donotreducegpx = wpgpxmaps_findValue( $attr, 'donotreducegpx', 'wpgpxmaps_donotreducegpx', false );
$allow_users_upload = wpgpxmaps_findValue( $attr, 'wpgpxmaps_allow_users_upload', 'wpgpxmaps_allow_users_view', false ); $allow_users_upload = wpgpxmaps_findValue( $attr, 'wpgpxmaps_allow_users_upload', 'wpgpxmaps_allow_users_view', false );
$colors_map = "\"" . implode( "\",\"", ( explode( " ", $color_map ) ) ) . "\""; $colors_map = "\"" . implode( "\",\"", ( explode( ' ', $color_map ) ) ) . "\"";
$gpxurl = $gpx; $gpxurl = $gpx;
@ -417,7 +361,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
} }
} }
$isGpxUrl = ( preg_match( '/^(http(s)?\:\/\/)/', trim( $gpx ) ) == 1); $isGpxUrl = ( preg_match( '/^(http(s)?\:\/\/)/', trim( $gpx ) ) == 1 );
if ( ( ! isset( $points_maps ) || $points_maps == '' ) && $gpx != '' ) { if ( ( ! isset( $points_maps ) || $points_maps == '' ) && $gpx != '' ) {
// if (true) { // if (true) {
@ -495,7 +439,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$_dist = (float) $points->dist[$i]; $_dist = (float) $points->dist[$i];
if ( $uom == '1') { if ( $uom == '1') {
/* miles and feet */ /* feet / miles */
$_dist *= 0.000621371192; $_dist *= 0.000621371192;
$_ele *= 3.2808399; $_ele *= 3.2808399;
@ -504,7 +448,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$_dist = (float) ( $_dist / 1000 ); $_dist = (float) ( $_dist / 1000 );
} elseif ( $uom == '3') { } elseif ( $uom == '3') {
/* meters / kilometers / nautical miles */ /* meters / nautical miles */
$_dist = (float) ( $_dist / 1000 / 1.852 ); $_dist = (float) ( $_dist / 1000 / 1.852 );
} elseif ( $uom == '4' ) { } elseif ( $uom == '4' ) {
@ -512,7 +456,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$_dist *= 0.000621371192; $_dist *= 0.000621371192;
} elseif ( $uom == '5' ) { } elseif ( $uom == '5' ) {
/* meters / kilometers / nautical miles and feet */ /* feet / nautical miles */
$_dist = (float) ( $_dist / 1000 / 1.852 ); $_dist = (float) ( $_dist / 1000 / 1.852 );
$_ele *= 3.2808399; $_ele *= 3.2808399;
} }
@ -526,25 +470,25 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
} }
if ( $showHr == true ) { if ( $showHr == true ) {
$points_graph_hr .= number_format( $points->hr[$i], 2, '.', '' ).','; $points_graph_hr .= number_format( $points->hr[$i], 2, '.', '' ) . ',';
} }
if ( $showAtemp == true ) { if ( $showAtemp == true ) {
$points_graph_atemp .= number_format( $points->atemp[$i], 1, '.', '' ).','; $points_graph_atemp .= number_format( $points->atemp[$i], 1, '.', '' ) . ',';
} }
if ( $showCad == true ) { if ( $showCad == true ) {
$points_graph_cad .= number_format( $points->cad[$i], 2, '.', '' ).','; $points_graph_cad .= number_format( $points->cad[$i], 2, '.', '' ) . ',';
} }
if ( $showGrade == true ) { if ( $showGrade == true ) {
$points_graph_grade .= number_format( $points->grade[$i], 2, '.', '' ).','; $points_graph_grade .= number_format( $points->grade[$i], 2, '.', '' ) . ',';
} }
} }
} }
if ( $uom == '1' ) { if ( $uom == '1' ) {
/* miles and feet */ /* feet / miles */
$tot_len = round( $tot_len * 0.000621371192, 2 ) . ' mi'; $tot_len = round( $tot_len * 0.000621371192, 2 ) . ' mi';
$max_ele = round( $max_ele * 3.2808399, 0 ) . ' ft'; $max_ele = round( $max_ele * 3.2808399, 0 ) . ' ft';
$min_ele = round( $min_ele * 3.2808399, 0 ) . ' ft'; $min_ele = round( $min_ele * 3.2808399, 0 ) . ' ft';
@ -560,15 +504,15 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$total_ele_down = round( $total_ele_down, 0 ) . ' m'; $total_ele_down = round( $total_ele_down, 0 ) . ' m';
} elseif ( $uom == '3' ) { } elseif ( $uom == '3' ) {
/* meters / kilometers / nautical miles */ /* meters / nautical miles */
$tot_len = round( $tot_len / 1000/1.852, 2 ) . ' NM'; $tot_len = round( $tot_len / 1000 / 1.852, 2 ) . ' NM';
$max_ele = round( $max_ele, 0 ) . ' m'; $max_ele = round( $max_ele, 0 ) . ' m';
$min_ele = round( $min_ele, 0 ) . ' m'; $min_ele = round( $min_ele, 0 ) . ' m';
$total_ele_up = round( $total_ele_up, 0 ) . ' m'; $total_ele_up = round( $total_ele_up, 0 ) . ' m';
$total_ele_down = round( $total_ele_down, 0 ) . ' m'; $total_ele_down = round( $total_ele_down, 0 ) . ' m';
} elseif ( $uom == '4' ) { } elseif ( $uom == '4' ) {
/* meters / kilometers / nautical miles */ /* meters / miles */
$tot_len = round( $tot_len * 0.000621371192, 2 ) . ' mi'; $tot_len = round( $tot_len * 0.000621371192, 2 ) . ' mi';
$max_ele = round( $max_ele, 0 ) . ' m'; $max_ele = round( $max_ele, 0 ) . ' m';
$min_ele = round( $min_ele, 0 ) . ' m'; $min_ele = round( $min_ele, 0 ) . ' m';
@ -576,8 +520,8 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$total_ele_down = round( $total_ele_down, 0 ) . ' m'; $total_ele_down = round( $total_ele_down, 0 ) . ' m';
} elseif ( $uom == '5' ) { } elseif ( $uom == '5' ) {
/* meters / kilometers / nautical miles and feet */ /* feet / nautical miles */
$tot_len = round( $tot_len / 1000/1.852, 2 ) . ' NM'; $tot_len = round( $tot_len / 1000 / 1.852, 2 ) . ' NM';
$max_ele = round( $max_ele * 3.2808399, 0 ) . ' ft'; $max_ele = round( $max_ele * 3.2808399, 0 ) . ' ft';
$min_ele = round( $min_ele * 3.2808399, 0 ) . ' ft'; $min_ele = round( $min_ele * 3.2808399, 0 ) . ' ft';
$total_ele_up = round( $total_ele_up * 3.2808399, 0 ) . ' ft'; $total_ele_up = round( $total_ele_up * 3.2808399, 0 ) . ' ft';
@ -599,11 +543,11 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$wpoints = wpgpxmaps_getWayPoints( $gpx ); $wpoints = wpgpxmaps_getWayPoints( $gpx );
$waypoints = wp_json_encode( $wpoints ); $waypoints = wp_json_encode( $wpoints );
} }
if ( $showEle == 'false' ) { if ( $showEle == false ) {
$points_graph_ele = ""; $points_graph_ele = '';
} }
$p = "/(,|,null,)$/"; $p = '/(,|,null,)$/';
$points_maps = preg_replace( $p, '', $points_maps ); $points_maps = preg_replace( $p, '', $points_maps );
@ -643,11 +587,11 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$ngimgs_data = ''; $ngimgs_data = '';
if ( $ngGalleries != '' || $ngImages != '' ) { if ( $ngGalleries != '' || $ngImages != '' ) {
$ngimgs = getNGGalleryImages( $ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error ); $ngimgs = getNGGalleryImages( $ngGalleries, $ngImages, $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error );
$ngimgs_data =''; $ngimgs_data = '';
foreach ( $ngimgs as $img ) { foreach ( $ngimgs as $img ) {
$data = $img['data']; $data = $img['data'];
$data = str_replace( "\n", "", $data ); $data = str_replace( '\n', '', $data );
$ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>'; $ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>';
} }
} }
@ -656,7 +600,7 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$attimgs = wpgpxmaps_getAttachedImages( $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error ); $attimgs = wpgpxmaps_getAttachedImages( $points_x_time, $points_x_lat, $points_x_lon, $dtoffset, $error );
foreach ( $attimgs as $img ) { foreach ( $attimgs as $img ) {
$data = $img['data']; $data = $img['data'];
$data = str_replace( "\n", "", $data ); $data = str_replace( '\n', '', $data );
$ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>'; $ngimgs_data .= '<span lat="' . $img['lat'] . '" lon="' . $img['lon'] . '">' . $data . '</span>';
} }
} }
@ -713,55 +657,56 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
jQuery(document).ready(function() { jQuery(document).ready(function() {
jQuery("#wpgpxmaps_' . $r . '").wpgpxmaps({ jQuery( "#wpgpxmaps_' . $r . '" ).wpgpxmaps( {
targetId : "' . $r . '", targetId : "' . $r . '",
mapType : "' . $mt . '", mapType : "' . $mt . '",
mapData : [' . $points_maps . '], mapData : [' . $points_maps . '],
graphDist : [' . ( $hideGraph ? '' : $points_graph_dist ) . '], graphDist : [' . ( $hideGraph ? '' : $points_graph_dist ) . '],
graphEle : [' . ( $hideGraph ? '' : $points_graph_ele ) . '], graphEle : [' . ( $hideGraph ? '' : $points_graph_ele ) . '],
graphSpeed : [' . ( $hideGraph ? '' : $points_graph_speed ) . '], graphSpeed : [' . ( $hideGraph ? '' : $points_graph_speed ) . '],
graphHr : [' . ( $hideGraph ? '' : $points_graph_hr ) . '], graphHr : [' . ( $hideGraph ? '' : $points_graph_hr ) . '],
graphAtemp : [' . ( $hideGraph ? '' : $points_graph_atemp ) . '], graphAtemp : [' . ( $hideGraph ? '' : $points_graph_atemp ) . '],
graphCad : [' . ( $hideGraph ? '' : $points_graph_cad ) . '], graphCad : [' . ( $hideGraph ? '' : $points_graph_cad ) . '],
graphGrade : [' . ( $hideGraph ? '' : $points_graph_grade ) . '], graphGrade : [' . ( $hideGraph ? '' : $points_graph_grade ) . '],
waypoints : ' . $waypoints . ', waypoints : ' . $waypoints . ',
unit : "' . $uom . '", unit : "' . $uom . '",
unitspeed : "' . $uomspeed . '", unitspeed : "' . $uomspeed . '",
color1 : [' . $colors_map . '], color1 : [' . $colors_map . '],
color2 : "' . $color_graph . '", color2 : "' . $color_graph . '",
color3 : "' . $color_graph_speed . '", color3 : "' . $color_graph_speed . '",
color4 : "' . $color_graph_hr . '", color4 : "' . $color_graph_hr . '",
color5 : "' . $color_graph_cad . '", color5 : "' . $color_graph_cad . '",
color6 : "' . $color_graph_grade . '", color6 : "' . $color_graph_grade . '",
color7 : "' . $color_graph_atemp . '", color7 : "' . $color_graph_atemp . '",
chartFrom1 : "' . $chartFrom1 . '", chartFrom1 : "' . $chartFrom1 . '",
chartTo1 : "' . $chartTo1 . '", chartTo1 : "' . $chartTo1 . '",
chartFrom2 : "' . $chartFrom2 . '", chartFrom2 : "' . $chartFrom2 . '",
chartTo2 : "' . $chartTo2 . '", chartTo2 : "' . $chartTo2 . '",
startIcon : "' . $startIcon . '", startIcon : "' . $startIcon . '",
endIcon : "' . $endIcon . '", endIcon : "' . $endIcon . '",
currentIcon : "' . $currentIcon . '", currentIcon : "' . $currentIcon . '",
waypointIcon : "' . $waypointIcon . '", waypointIcon : "' . $waypointIcon . '",
currentpositioncon : "' . $currentpositioncon . '", currentpositioncon : "' . $currentpositioncon . '",
usegpsposition : "' . $usegpsposition . '", usegpsposition : "' . $usegpsposition . '",
zoomOnScrollWheel : "' . $zoomOnScrollWheel . '", zoomOnScrollWheel : "' . $zoomOnScrollWheel . '",
ngGalleries : [' . $ngGalleries . '], ngGalleries : [' . $ngGalleries . '],
ngImages : [' . $ngImages . '], ngImages : [' . $ngImages . '],
pluginUrl : "' . plugins_url() . '", pluginUrl : "' . plugins_url() . '",
TFApiKey : "' . get_option( 'wpgpxmaps_openstreetmap_apikey' ) . '", TFApiKey : "' . get_option( 'wpgpxmaps_openstreetmap_apikey' ) . '",
langs : { altitude : "' . __( 'Altitude', 'wp-gpx-maps' ) . '", langs : {
currentPosition : "' . __( 'Current position', 'wp-gpx-maps' ) . '", altitude : "' . __( 'Altitude', 'wp-gpx-maps' ) . '",
speed : "' . __( 'Speed', 'wp-gpx-maps' ) . '", currentPosition : "' . __( 'Current position', 'wp-gpx-maps' ) . '",
grade : "' . __( 'Grade', 'wp-gpx-maps' ) . '", speed : "' . __( 'Speed', 'wp-gpx-maps' ) . '",
heartRate : "' . __( 'Heart rate', 'wp-gpx-maps' ) . '", grade : "' . __( 'Grade', 'wp-gpx-maps' ) . '",
atemp : "' . __( 'Temperature', 'wp-gpx-maps' ) . '", heartRate : "' . __( 'Heart rate', 'wp-gpx-maps' ) . '",
cadence : "' . __( 'Cadence', 'wp-gpx-maps' ) . '", atemp : "' . __( 'Temperature', 'wp-gpx-maps' ) . '",
goFullScreen : "' . __( 'Go full screen', 'wp-gpx-maps' ) . '", cadence : "' . __( 'Cadence', 'wp-gpx-maps' ) . '",
exitFullFcreen : "' . __( 'Exit full screen', 'wp-gpx-maps' ) . '", goFullScreen : "' . __( 'Go full screen', 'wp-gpx-maps' ) . '",
hideImages : "' . __( 'Hide images', 'wp-gpx-maps' ) . '", exitFullFcreen : "' . __( 'Exit full screen', 'wp-gpx-maps' ) . '",
showImages : "' . __( 'Show images', 'wp-gpx-maps' ) . '", hideImages : "' . __( 'Hide images', 'wp-gpx-maps' ) . '",
backToCenter : "' . __( 'Back to center', 'wp-gpx-maps' ) . '" showImages : "' . __( 'Show images', 'wp-gpx-maps' ) . '",
} backToCenter : "' . __( 'Back to center', 'wp-gpx-maps' ) . '"
}
}); });
}); });
@ -769,43 +714,43 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
</script>'; </script>';
/* Print summary */ /* Print summary */
if ( $summary == 'true' && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '') ) { if ( $summary == true && ( $points_graph_speed != '' || $points_graph_ele != '' || $points_graph_dist != '' ) ) {
$output .= "<div id='wpgpxmaps_summary_" . $r . "' class='wpgpxmaps_summary'>"; $output .= "<div id='wpgpxmaps_summary_" . $r . "' class='wpgpxmaps_summary'>";
if ( $points_graph_dist != '' && $p_tot_len == 'true' ) { if ( $points_graph_dist != '' && $p_tot_len == true ) {
$output .= "<span class='totlen'><span class='summarylabel'>" . __( 'Total distance', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $tot_len</span></span><br />"; $output .= "<span class='totlen'><span class='summarylabel'>" . __( 'Total distance:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $tot_len</span></span><br />";
} }
if ( $points_graph_ele != ' ' ) { if ( $points_graph_ele != ' ' ) {
if ( $p_max_ele == 'true' ) if ( $p_max_ele == true )
$output .= "<span class='maxele'><span class='summarylabel'>" . __( 'Max elevation', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $max_ele</span></span><br />"; $output .= "<span class='maxele'><span class='summarylabel'>" . __( 'Max elevation:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $max_ele</span></span><br />";
if ( $p_min_ele == 'true' ) if ( $p_min_ele == true )
$output .= "<span class='minele'><span class='summarylabel'>" . __( 'Min elevation', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $min_ele</span></span><br />"; $output .= "<span class='minele'><span class='summarylabel'>" . __( 'Min elevation:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $min_ele</span></span><br />";
if ( $p_total_ele_up == 'true' ) if ( $p_total_ele_up == true )
$output .= "<span class='totaleleup'><span class='summarylabel'>" . __( 'Total climbing', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $total_ele_up</span></span><br />"; $output .= "<span class='totaleleup'><span class='summarylabel'>" . __( 'Total climbing:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $total_ele_up</span></span><br />";
if ( $p_total_ele_down == 'true' ) if ( $p_total_ele_down == true )
$output .= "<span class='totaleledown'><span class='summarylabel'>" . __( 'Total descent', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $total_ele_down</span></span><br />"; $output .= "<span class='totaleledown'><span class='summarylabel'>" . __( 'Total descent:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $total_ele_down</span></span><br />";
} }
if ( $points_graph_speed != '' && $p_avg_speed == 'true' ) { if ( $points_graph_speed != '' && $p_avg_speed == true ) {
$output .= "<span class='avgspeed'><span class='summarylabel'>" . __( 'Average speed', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $avg_speed</span></span><br />"; $output .= "<span class='avgspeed'><span class='summarylabel'>" . __( 'Average speed:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_speed</span></span><br />";
} }
if ( $points_graph_cad != '' && $p_avg_cad == 'true' ) { if ( $points_graph_cad != '' && $p_avg_cad == true ) {
$output .= "<span class='avgcad'><span class='summarylabel'>" . __( 'Average cadence', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $avg_cad</span></span><br />"; $output .= "<span class='avgcad'><span class='summarylabel'>" . __( 'Average cadence:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_cad</span></span><br />";
} }
if ( $points_graph_hr != '' && $p_avg_hr == 'true' ) { if ( $points_graph_hr != '' && $p_avg_hr == true ) {
$output .= "<span class='avghr'><span class='summarylabel'>" . __( 'Average heart rate', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $avg_hr</span></span><br />"; $output .= "<span class='avghr'><span class='summarylabel'>" . __( 'Average heart rate:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_hr</span></span><br />";
} }
if ( $points_graph_atemp != '' && $p_avg_temp == 'true' ) { if ( $points_graph_atemp != '' && $p_avg_temp == true ) {
$output .= "<span class='avgtemp'><span class='summarylabel'>" . __( 'Average temperature', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $avg_temp</span></span><br />"; $output .= "<span class='avgtemp'><span class='summarylabel'>" . __( 'Average temperature:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $avg_temp</span></span><br />";
} }
if ( $p_total_time == 'true' && $max_time > 0 ) { if ( $p_total_time == true && $max_time > 0 ) {
$time_diff = date( "H:i:s", ( $max_time - $min_time ) ); $time_diff = date( 'H:i:s', ( $max_time - $min_time ) );
$output .= "<span class='totaltime'><span class='summarylabel'>" . __( 'Total time', 'wp-gpx-maps' ) . ":</span><span class='summaryvalue'> $time_diff</span></span><br />"; $output .= "<span class='totaltime'><span class='summarylabel'>" . __( 'Total time:', 'wp-gpx-maps' ) . "</span><span class='summaryvalue'> $time_diff</span></span><br />";
} }
$output .= "</div>"; $output .= '</div>';
} }
/* Print download link */ /* Print download link */
if ( $download == 'true' && $gpxurl != '' ) { if ( $download == true && $gpxurl != '' ) {
if ( $isGpxUrl == true ) { if ( $isGpxUrl == true ) {
} else { } else {
@ -813,25 +758,28 @@ function handle_WP_GPX_Maps_Shortcodes( $attr, $content = '' ) {
$dummy = ( defined( 'WP_SITEURL' ) ) ? WP_SITEURL : get_bloginfo( 'url' ); $dummy = ( defined( 'WP_SITEURL' ) ) ? WP_SITEURL : get_bloginfo( 'url' );
$gpxurl = $dummy . $gpxurl; $gpxurl = $dummy . $gpxurl;
} }
$output .= "<a href='$gpxurl' target='_new' download>" . __( 'Download', 'wp-gpx-maps' ) . "</a>"; $output .= "<a href='$gpxurl' target='_new' download>" . __( 'Download', 'wp-gpx-maps' ) . '</a>';
} }
return $output; return $output;
} }
function convertSeconds( $s ) { function convertSeconds( $s ) {
if ( $s == 0 ) if ( $s == 0 )
return 0; return 0;
$s = 1.0 / $s; $s = 1.0 / $s;
$_sSecT = $s * 60; // sec/km $_sSecT = $s * 60; // sec/km
$_sMin = floor ( $_sSecT / 60 ); $_sMin = floor( $_sSecT / 60 );
$_sSec = $_sSecT - $_sMin * 60; $_sSec = $_sSecT - $_sMin * 60;
return $_sMin + $_sSec / 100; return $_sMin + $_sSec / 100;
} }
function convertSpeed( $speed, $uomspeed, $addUom = false ) { function convertSpeed( $speed, $uomspeed, $addUom = false ) {
$uom = ''; $uom = '';
if ( $uomspeed == '6' ) {
if ( $uomspeed == '6' ) {
/* min/100 meters */ /* min/100 meters */
$speed = 1 / $speed * 100 / 60; $speed = 1 / $speed * 100 / 60;
$uom = ' min/100m'; $uom = ' min/100m';
@ -860,6 +808,7 @@ function convertSpeed( $speed, $uomspeed, $addUom = false ) {
/* km/h */ /* km/h */
$speed *= 3.6; $speed *= 3.6;
$uom = ' km/h'; $uom = ' km/h';
} else { } else {
/* dafault m/s */ /* dafault m/s */
$uom = ' m/s'; $uom = ' m/s';
@ -873,38 +822,31 @@ function convertSpeed( $speed, $uomspeed, $addUom = false ) {
} }
function downloadRemoteFile( $remoteFile ) { function downloadRemoteFile( $remoteFile ) {
try { try {
$newfname = tempnam( '/tmp', 'gpx' ); $newfname = tempnam( '/tmp', 'gpx' );
if ( function_exists ( 'file_put_contents' ) ) { if ( function_exists( 'file_put_contents' ) ) {
file_put_contents( $newfname, fopen( $remoteFile, 'r' ) ); file_put_contents( $newfname, fopen( $remoteFile, 'r' ) );
return $newfname; return $newfname;
} }
$file = fopen( $remoteFile, 'rb' );
$file = fopen ( $remoteFile, 'rb' );
if ( $file ) { if ( $file ) {
$newf = fopen ( $newfname, 'wb' ); $newf = fopen( $newfname, 'wb' );
if ( $newf ) if ( $newf )
while ( ! feof( $file ) ) { while ( ! feof( $file ) ) {
fwrite( $newf, fread( $file, 1024 * 8 ), 1024 * 8 ); fwrite( $newf, fread( $file, 1024 * 8 ), 1024 * 8 );
} }
} }
if ( $file ) { if ( $file ) {
fclose( $file ); fclose( $file );
} }
if ( $newf ) { if ( $newf ) {
fclose( $newf ); fclose( $newf );
} }
return $newfname; return $newfname;
} catch ( Exception $e ) { } catch ( Exception $e ) {
print_r( $e ); print_r( $e );
return ''; return '';
} }
} }
@ -912,7 +854,7 @@ function downloadRemoteFile( $remoteFile ) {
function unescape( $value ) { function unescape( $value ) {
$value = str_replace( "'", "\'", $value ); $value = str_replace( "'", "\'", $value );
$value = str_replace( array( "\n", "\r" ), "", $value ); $value = str_replace( array( '\n', '\r' ), '', $value );
return $value; return $value;
} }
@ -922,10 +864,22 @@ function WP_GPX_Maps_install() {
add_option( 'wpgpxmaps_width', '100%', '', 'yes' ); add_option( 'wpgpxmaps_width', '100%', '', 'yes' );
add_option( 'wpgpxmaps_height', '450px', '', 'yes' ); add_option( 'wpgpxmaps_height', '450px', '', 'yes' );
add_option( 'wpgpxmaps_graph_height', '200px', '', 'yes' ); add_option( 'wpgpxmaps_graph_height', '200px', '', 'yes' );
add_option( 'wpgpxmaps_distance_type', '0', '', 'yes' );
add_option( 'wpgpxmaps_skipcache', '', '', 'yes' ); add_option( 'wpgpxmaps_skipcache', '', '', 'yes' );
add_option( 'wpgpxmaps_download', '', '', 'yes' ); add_option( 'wpgpxmaps_download', '', '', 'yes' );
add_option( 'wpgpxmaps_usegpsposition', '', '', 'yes' );
/* Print Summary Table */ /* Print Summary Table */
add_option( 'wpgpxmaps_summary', '', '', 'yes' ); add_option( 'wpgpxmaps_summary', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_tot_len', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_max_ele', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_min_ele', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_total_ele_up', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_total_ele_down', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_avg_speed', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_avg_cad', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_avg_hr', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_avg_temp', '', '', 'yes' );
add_option( 'wpgpxmaps_summary_total_time', '', '', 'yes' );
/* Map */ /* Map */
add_option( 'wpgpxmaps_map_type', 'HYBRID', '', 'yes' ); add_option( 'wpgpxmaps_map_type', 'HYBRID', '', 'yes' );
add_option( 'wpgpxmaps_map_line_color', '#3366cc', '', 'yes' ); add_option( 'wpgpxmaps_map_line_color', '#3366cc', '', 'yes' );
@ -933,9 +887,11 @@ function WP_GPX_Maps_install() {
add_option( 'wpgpxmaps_show_waypoint', '', '', 'yes' ); add_option( 'wpgpxmaps_show_waypoint', '', '', 'yes' );
add_option( 'wpgpxmaps_map_start_icon', '', '', 'yes' ); add_option( 'wpgpxmaps_map_start_icon', '', '', 'yes' );
add_option( 'wpgpxmaps_map_end_icon', '', '', 'yes' ); add_option( 'wpgpxmaps_map_end_icon', '', '', 'yes' );
add_option( 'wpgpxmaps_currentpositioncon', '', '', 'yes' );
add_option( 'wpgpxmaps_map_current_icon', '', '', 'yes' ); add_option( 'wpgpxmaps_map_current_icon', '', '', 'yes' );
add_option( 'wpgpxmaps_map_waypoint_icon', '', '', 'yes' ); add_option( 'wpgpxmaps_map_waypoint_icon', '', '', 'yes' );
/* Diagram - Elevation */ /* Diagram - Elevation */
add_option( 'wpgpxmaps_show_elevation', 'true', '', 'yes' );
add_option( 'wpgpxmaps_graph_line_color', '#3366cc', '', 'yes' ); add_option( 'wpgpxmaps_graph_line_color', '#3366cc', '', 'yes' );
add_option( 'wpgpxmaps_unit_of_measure', '0', '', 'yes' ); add_option( 'wpgpxmaps_unit_of_measure', '0', '', 'yes' );
add_option( 'wpgpxmaps_graph_offset_from1', '', '', 'yes' ); add_option( 'wpgpxmaps_graph_offset_from1', '', '', 'yes' );
@ -956,7 +912,8 @@ function WP_GPX_Maps_install() {
add_option( 'wpgpxmaps_show_cadence', '', '', 'yes' ); add_option( 'wpgpxmaps_show_cadence', '', '', 'yes' );
add_option( 'wpgpxmaps_graph_line_color_cad', '#beecff', '', 'yes' ); add_option( 'wpgpxmaps_graph_line_color_cad', '#beecff', '', 'yes' );
/* Diagram - Grade */ /* Diagram - Grade */
add_option( 'wpgpxmaps_show_grade', '', '', 'yes' );
add_option( 'wpgpxmaps_graph_line_color_grade', '#beecff', '', 'yes' );
/* Pictures */ /* Pictures */
add_option( 'wpgpxmaps_map_nggallery', '', '', 'yes' ); add_option( 'wpgpxmaps_map_nggallery', '', '', 'yes' );
/* Advanced */ /* Advanced */
@ -970,10 +927,22 @@ function WP_GPX_Maps_remove() {
delete_option( 'wpgpxmaps_width' ); delete_option( 'wpgpxmaps_width' );
delete_option( 'wpgpxmaps_graph_height' ); delete_option( 'wpgpxmaps_graph_height' );
delete_option( 'wpgpxmaps_height' ); delete_option( 'wpgpxmaps_height' );
delete_option( 'wpgpxmaps_distance_type' );
delete_option( 'wpgpxmaps_skipcache' ); delete_option( 'wpgpxmaps_skipcache' );
delete_option( 'wpgpxmaps_download' ); delete_option( 'wpgpxmaps_download' );
delete_option( 'wpgpxmaps_usegpsposition' );
/* Print Summary Table */ /* Print Summary Table */
delete_option( 'wpgpxmaps_summary' ); delete_option( 'wpgpxmaps_summary' );
delete_option( 'wpgpxmaps_summary_tot_len' );
delete_option( 'wpgpxmaps_summary_max_ele' );
delete_option( 'wpgpxmaps_summary_min_ele' );
delete_option( 'wpgpxmaps_summary_total_ele_up' );
delete_option( 'wpgpxmaps_summary_total_ele_down' );
delete_option( 'wpgpxmaps_summary_avg_speed' );
delete_option( 'wpgpxmaps_summary_avg_cad' );
delete_option( 'wpgpxmaps_summary_avg_hr' );
delete_option( 'wpgpxmaps_summary_avg_temp' );
delete_option( 'wpgpxmaps_summary_total_time' );
/* Map */ /* Map */
delete_option( 'wpgpxmaps_map_type' ); delete_option( 'wpgpxmaps_map_type' );
delete_option( 'wpgpxmaps_map_line_color' ); delete_option( 'wpgpxmaps_map_line_color' );
@ -981,9 +950,11 @@ function WP_GPX_Maps_remove() {
delete_option( 'wpgpxmaps_show_waypoint' ); delete_option( 'wpgpxmaps_show_waypoint' );
delete_option( 'wpgpxmaps_map_start_icon' ); delete_option( 'wpgpxmaps_map_start_icon' );
delete_option( 'wpgpxmaps_map_end_icon' ); delete_option( 'wpgpxmaps_map_end_icon' );
delete_option( 'wpgpxmaps_currentpositioncon' );
delete_option( 'wpgpxmaps_map_current_icon' ); delete_option( 'wpgpxmaps_map_current_icon' );
delete_option( 'wpgpxmaps_map_waypoint_icon' ); delete_option( 'wpgpxmaps_map_waypoint_icon' );
/* Diagram - Elevation */ /* Diagram - Elevation */
delete_option( 'wpgpxmaps_show_elevation' );
delete_option( 'wpgpxmaps_graph_line_color' ); delete_option( 'wpgpxmaps_graph_line_color' );
delete_option( 'wpgpxmaps_unit_of_measure' ); delete_option( 'wpgpxmaps_unit_of_measure' );
delete_option( 'wpgpxmaps_graph_offset_from1' ); delete_option( 'wpgpxmaps_graph_offset_from1' );
@ -1004,12 +975,11 @@ function WP_GPX_Maps_remove() {
delete_option( 'wpgpxmaps_show_cadence' ); delete_option( 'wpgpxmaps_show_cadence' );
delete_option( 'wpgpxmaps_graph_line_color_cad' ); delete_option( 'wpgpxmaps_graph_line_color_cad' );
/* Diagram - Grade */ /* Diagram - Grade */
delete_option( 'wpgpxmaps_show_grade' );
delete_option( 'wpgpxmaps_graph_line_color_grade' );
/* Pictures */ /* Pictures */
delete_option( 'wpgpxmaps_map_nggallery' ); delete_option( 'wpgpxmaps_map_nggallery' );
/* Advanced */ /* Advanced */
delete_option( 'wpgpxmaps_pointsoffset' ); delete_option( 'wpgpxmaps_pointsoffset' );
delete_option( 'wpgpxmaps_donotreducegpx' ); delete_option( 'wpgpxmaps_donotreducegpx' );
} }
?>

View File

@ -1,57 +1,53 @@
<?php <?php
if ( is_admin() ) { if ( is_admin() ) {
add_action( 'admin_menu', 'wpgpxmaps_admin_menu' ); add_action( 'admin_menu', 'wpgpxmaps_admin_menu' );
} }
/**
* Roles and capabilities
*
* Capabilities for each user role that are relevant to this plugin:
*
* Super Admin: can manage settings; can publish, edit and delete all posts; can upload and delete all GPX files
* Admin: can manage settings; can publish, edit and delete all posts; can upload and delete all GPX files
* Editor: can not manage settings; can publish, edit and delete all posts; can upload and delete all GPX files
* Author: can not manage settings; can publish, edit and delete his own posts; can upload and delete his own files
* Contributor: can not manage settings; can edit and delete his own posts; can not manage GPX files
* Subscriber: can not manage settings; can not manage posts; can not manage GPX files (has read status everywhere)
*
* @see https://wordpress.org/support/article/roles-and-capabilities/
*/
function wpgpxmaps_admin_menu() { function wpgpxmaps_admin_menu() {
/*
All roles/capabilities:
https://wordpress.org/support/article/roles-and-capabilities/
*/
if ( current_user_can( 'manage_options' ) ) { if ( current_user_can( 'manage_options' ) ) {
/* Only Administrators and Super Administrators */ /* Access only for Super Administrators and Administrators */
add_options_page( 'WP GPX Maps', 'WP GPX Maps', 'manage_options', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page' ); add_options_page( 'WP GPX Maps', 'WP GPX Maps', 'manage_options', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page' );
} } elseif ( current_user_can( 'publish_posts' ) ) {
elseif ( current_user_can( 'publish_posts' ) ) { /* Access for Editors and Authors */
/* Contributor Authors and */ /* Contributor Authors and */
$allow_users_upload = get_option( 'wpgpxmaps_allow_users_view' ) === 'true';
$allow_users_upload = get_option( 'wpgpxmaps_allow_users_view' ) === "true"; if ( $allow_users_upload == 1 ) {
if ($allow_users_upload == 1)
{
add_menu_page( 'WP GPX Maps', 'WP GPX Maps', 'publish_posts', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page' ); add_menu_page( 'WP GPX Maps', 'WP GPX Maps', 'publish_posts', 'WP-GPX-Maps', 'WP_GPX_Maps_html_page' );
} }
} }
} }
function wpgpxmaps_ilc_admin_tabs( $current ) {
function wpgpxmaps_ilc_admin_tabs( $current ) {
if ( current_user_can( 'manage_options' ) ) { if ( current_user_can( 'manage_options' ) ) {
/* Access for Super Administrators and Administrators */
$tabs = array( $tabs = array(
'tracks' => __( 'Tracks', 'wp-gpx-maps' ), 'tracks' => __( 'Tracks', 'wp-gpx-maps' ),
'settings' => __( 'Settings', 'wp-gpx-maps' ), 'settings' => __( 'Settings', 'wp-gpx-maps' ),
'help' => __( 'Help', 'wp-gpx-maps' ), 'help' => __( 'Help', 'wp-gpx-maps' ),
); );
} elseif ( current_user_can( 'publish_posts' ) ) {
} elseif ( current_user_can( 'publish_posts' ) ) {
/* Access for Editors and Authors */
$tabs = array( $tabs = array(
'tracks' => __( 'Tracks', 'wp-gpx-maps' ), 'tracks' => __( 'Tracks', 'wp-gpx-maps' ),
'help' => __( 'Help', 'wp-gpx-maps' ), 'help' => __( 'Help', 'wp-gpx-maps' ),
@ -61,54 +57,40 @@ function wpgpxmaps_ilc_admin_tabs( $current ) {
echo '<h2 class="nav-tab-wrapper">'; echo '<h2 class="nav-tab-wrapper">';
foreach ( $tabs as $tab => $name ) { foreach ( $tabs as $tab => $name ) {
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
$class = ( $tab == $current ) ? ' nav-tab-active' : '';
echo "<a class='nav-tab$class' href='?page=WP-GPX-Maps&tab=$tab'>$name</a>"; echo "<a class='nav-tab$class' href='?page=WP-GPX-Maps&tab=$tab'>$name</a>";
} }
echo '</h2>'; echo '</h2>';
} }
function WP_GPX_Maps_html_page() { function WP_GPX_Maps_html_page() {
$realGpxPath = gpxFolderPath(); $realGpxPath = gpxFolderPath();
$cacheGpxPath = gpxCacheFolderPath();
$cacheGpxPath = gpxCacheFolderPath(); $relativeGpxPath = relativeGpxFolderPath();
$relativeGpxPath = str_replace( '\\', '/', $relativeGpxPath );
$relativeGpxPath = relativeGpxFolderPath();
$relativeGpxPath = str_replace( "\\","/", $relativeGpxPath );
$relativeGpxCachePath = relativeGpxCacheFolderPath(); $relativeGpxCachePath = relativeGpxCacheFolderPath();
$relativeGpxCachePath = str_replace( '\\', '/', $relativeGpxCachePath );
$relativeGpxCachePath = str_replace( "\\","/", $relativeGpxCachePath ); $tab = $_GET['tab'];
$tab = $_GET['tab'];
if ( $tab == '' ) if ( $tab == '' )
$tab = 'tracks'; $tab = 'tracks';
?> ?>
<div id="icon-themes" class="icon32"><br></div> <div id="icon-themes" class="icon32"><br></div>
<h2><?php _e( 'Settings', 'wp-gpx-maps' ); ?></h2> <h2>
<?php _e( 'Settings', 'wp-gpx-maps' ); ?>
</h2>
<?php <?php
if ( file_exists( $realGpxPath ) && is_dir( $realGpxPath ) ) { if ( file_exists( $realGpxPath ) && is_dir( $realGpxPath ) ) {
/* Directory exist! */ /* Directory exist! */
} else { } else {
if ( ! @mkdir( $realGpxPath, 0755, true ) ) { if ( ! @mkdir( $realGpxPath, 0755, true ) ) {
echo '<div class=" notice notice-error"><p>'; echo '<div class=" notice notice-error"><p>';
printf( printf(
@ -119,13 +101,11 @@ function WP_GPX_Maps_html_page() {
echo '</p></div>'; echo '</p></div>';
} }
} }
if ( file_exists( $cacheGpxPath ) && is_dir( $cacheGpxPath ) ) { if ( file_exists( $cacheGpxPath ) && is_dir( $cacheGpxPath ) ) {
/* Directory exist! */ /* Directory exist! */
} else { } else {
if ( ! @mkdir( $cacheGpxPath, 0755, true ) ) { if ( ! @mkdir( $cacheGpxPath, 0755, true ) ) {
echo '<div class=" notice notice-error"><p>'; echo '<div class=" notice notice-error"><p>';
printf( printf(

View File

@ -96,9 +96,15 @@
</th> </th>
<td> <td>
<select name='wpgpxmaps_distance_type'> <select name='wpgpxmaps_distance_type'>
<option value="0" <?php if ( $distanceType == '0' || $distanceType == '' ) echo 'selected'; ?>><?php _e( 'Normal (default)', 'wp-gpx-maps' ); ?></option> <option value="0" <?php if ( $distanceType == '0' || $distanceType == '' ) echo 'selected'; ?>>
<option value="1" <?php if ( $distanceType == '1' ) echo 'selected'; ?>><?php _e( 'Flat &#8594; (Only flat distance, don&#8217;t take care of altitude)', 'wp-gpx-maps' ); ?></option> <?php _e( 'Normal (default)', 'wp-gpx-maps' ); ?>
<option value="2" <?php if ( $distanceType == '2' ) echo 'selected'; ?>><?php _e( 'Climb &#8593; (Only climb distance)', 'wp-gpx-maps' ); ?></option> </option>
<option value="1" <?php if ( $distanceType == '1' ) echo 'selected'; ?>>
<?php _e( 'Flat &#8594; (Only flat distance, don&#8217;t take care of altitude)', 'wp-gpx-maps' ); ?>
</option>
<option value="2" <?php if ( $distanceType == '2' ) echo 'selected'; ?>>
<?php _e( 'Climb &#8593; (Only climb distance)', 'wp-gpx-maps' ); ?>
</option>
</select> </select>
</td> </td>
</tr> </tr>
@ -110,10 +116,7 @@
<td> <td>
<input name="wpgpxmaps_skipcache" type="checkbox" value="true" <?php if ( $skipcache == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_skipcache" type="checkbox" value="true" <?php if ( $skipcache == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Do not use cache', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Do not use cache', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -125,10 +128,7 @@
<td> <td>
<input name="wpgpxmaps_download" type="checkbox" value="true" <?php if ( $download == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_download" type="checkbox" value="true" <?php if ( $download == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Allow users to download your GPX file', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Allow users to download your GPX file', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -140,10 +140,7 @@
<td> <td>
<input name="wpgpxmaps_usegpsposition" type="checkbox" value="true" <?php if ( $usegpsposition == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_usegpsposition" type="checkbox" value="true" <?php if ( $usegpsposition == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Allow users to use browser GPS in order to display their current position on map', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Allow users to use browser GPS in order to display their current position on map', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -194,10 +191,7 @@
<td> <td>
<input name="wpgpxmaps_summary" type="checkbox" value="true" <?php if ( $summary == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary" type="checkbox" value="true" <?php if ( $summary == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print summary details of your GPX track', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print summary details of your GPX track', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -209,10 +203,7 @@
<td> <td>
<input name="wpgpxmaps_summary_tot_len" type="checkbox" value="true" <?php if ( $tot_len == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_tot_len" type="checkbox" value="true" <?php if ( $tot_len == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print total distance', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print total distance', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -224,10 +215,7 @@
<td> <td>
<input name="wpgpxmaps_summary_max_ele" type="checkbox" value="true" <?php if ( $max_ele == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_max_ele" type="checkbox" value="true" <?php if ( $max_ele == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print max elevation', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print max elevation', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -239,10 +227,7 @@
<td> <td>
<input name="wpgpxmaps_summary_min_ele" type="checkbox" value="true" <?php if ( $min_ele == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_min_ele" type="checkbox" value="true" <?php if ( $min_ele == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print min elevation', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print min elevation', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -254,10 +239,7 @@
<td> <td>
<input name="wpgpxmaps_summary_total_ele_up" type="checkbox" value="true" <?php if ( $total_ele_up == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_total_ele_up" type="checkbox" value="true" <?php if ( $total_ele_up == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print total climbing', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print total climbing', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -269,10 +251,7 @@
<td> <td>
<input name="wpgpxmaps_summary_total_ele_down" type="checkbox" value="true" <?php if ( $total_ele_down == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_total_ele_down" type="checkbox" value="true" <?php if ( $total_ele_down == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print total descent', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print total descent', 'wp-gpx-maps' );
?>
</i> </i>
</tr> </tr>
@ -283,10 +262,7 @@
<td> <td>
<input name="wpgpxmaps_summary_avg_speed" type="checkbox" value="true" <?php if ( $avg_speed == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_avg_speed" type="checkbox" value="true" <?php if ( $avg_speed == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print average speed', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print average speed', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -298,10 +274,7 @@
<td> <td>
<input name="wpgpxmaps_summary_avg_cad" type="checkbox" value="true" <?php if ( $avg_cad == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_avg_cad" type="checkbox" value="true" <?php if ( $avg_cad == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print average cadence', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print average cadence', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -313,10 +286,7 @@
<td> <td>
<input name="wpgpxmaps_summary_avg_hr" type="checkbox" value="true" <?php if ( $avg_hr == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_avg_hr" type="checkbox" value="true" <?php if ( $avg_hr == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print average heart rate', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print average heart rate', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -328,10 +298,7 @@
<td> <td>
<input name="wpgpxmaps_summary_avg_temp" type="checkbox" value="true" <?php if ( $avg_temp == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_avg_temp" type="checkbox" value="true" <?php if ( $avg_temp == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print average temperature', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print average temperature', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -343,10 +310,7 @@
<td> <td>
<input name="wpgpxmaps_summary_total_time" type="checkbox" value="true" <?php if ( $total_time == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_summary_total_time" type="checkbox" value="true" <?php if ( $total_time == true ) { echo ( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Print total time', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Print total time', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -379,49 +343,49 @@
<td> <td>
<input type="radio" name="wpgpxmaps_map_type" value="OSM1" <?php if ( $t == 'OSM1' ) echo 'checked'; ?>> <input type="radio" name="wpgpxmaps_map_type" value="OSM1" <?php if ( $t == 'OSM1' ) echo 'checked'; ?>>
<?php <?php
echo ' '; /* translators: map type */
_e( 'Open Street Map', 'wp-gpx-maps' ); _e( 'Open Street Map', 'wp-gpx-maps' );
?> ?>
<br /> <br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM2" <?php if ( $t == 'OSM2' ) echo 'checked'; ?>> <input type="radio" name="wpgpxmaps_map_type" value="OSM2" <?php if ( $t == 'OSM2' ) echo 'checked'; ?>>
<?php <?php
echo ' '; /* translators: map provider / map type */
_e( 'Open Cycle Map', 'wp-gpx-maps' ); _e( 'Open Cycle Map', 'wp-gpx-maps' );
?> ?>
<br /> <br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM4" <?php if ( $t == 'OSM4' ) echo 'checked'; ?>> <input type="radio" name="wpgpxmaps_map_type" value="OSM4" <?php if ( $t == 'OSM4' ) echo 'checked'; ?>>
<?php <?php
echo ' '; /* translators: map provider / map type */
_e( 'Open Cycle Map - Transport', 'wp-gpx-maps' ); _e( 'Open Cycle Map - Transport', 'wp-gpx-maps' );
?> ?>
<br /> <br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM5" <?php if ( $t == 'OSM5' ) echo 'checked'; ?>> <input type="radio" name="wpgpxmaps_map_type" value="OSM5" <?php if ( $t == 'OSM5' ) echo 'checked'; ?>>
<?php <?php
echo ' '; /* translators: map provider / map type */
_e( 'Open Cycle Map - Landscape', 'wp-gpx-maps' ); _e( 'Open Cycle Map - Landscape', 'wp-gpx-maps' );
?> ?>
<br /> <br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM6" <?php if ( $t == 'OSM6' ) echo 'checked'; ?>> <input type="radio" name="wpgpxmaps_map_type" value="OSM6" <?php if ( $t == 'OSM6' ) echo 'checked'; ?>>
<?php <?php
echo ' '; /* translators: map provider / map type */
_e( 'MapToolKit - Terrain', 'wp-gpx-maps' ); _e( 'MapToolKit - Terrain', 'wp-gpx-maps' );
?> ?>
<br /> <br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM7" <?php if ( $t == 'OSM7' ) echo 'checked'; ?>> <input type="radio" name="wpgpxmaps_map_type" value="OSM7" <?php if ( $t == 'OSM7' ) echo 'checked'; ?>>
<?php <?php
echo ' '; /* translators: map provider / map type */
_e( 'Open Street Map - Humanitarian map style', 'wp-gpx-maps' ); _e( 'Open Street Map - Humanitarian map style', 'wp-gpx-maps' );
?> ?>
<br /> <br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM9" <?php if ( $t == 'OSM9' ) echo 'checked'; ?>> <input type="radio" name="wpgpxmaps_map_type" value="OSM9" <?php if ( $t == 'OSM9' ) echo 'checked'; ?>>
<?php <?php
echo ' '; /* translators: map provider / map type */
_e( 'Hike & Bike', 'wp-gpx-maps' ); _e( 'Hike & Bike', 'wp-gpx-maps' );
?> ?>
<br /> <br />
<input type="radio" name="wpgpxmaps_map_type" value="OSM10" <?php if ( $t == 'OSM10' ) echo 'checked'; ?>> <input type="radio" name="wpgpxmaps_map_type" value="OSM10" <?php if ( $t == 'OSM10' ) echo 'checked'; ?>>
<?php <?php
echo ' '; /* translators: map provider / map type */
_e( 'Open Sea Map', 'wp-gpx-maps' ); _e( 'Open Sea Map', 'wp-gpx-maps' );
?> ?>
<br /> <br />
@ -444,10 +408,7 @@
<td> <td>
<input name="wpgpxmaps_zoomonscrollwheel" type="checkbox" value="true" <?php if ( $zoomonscrollwheel == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_zoomonscrollwheel" type="checkbox" value="true" <?php if ( $zoomonscrollwheel == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Enable zoom', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Enable zoom', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -459,10 +420,7 @@
<td> <td>
<input name="wpgpxmaps_show_waypoint" type="checkbox" value="true" <?php if ( $showW == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_show_waypoint" type="checkbox" value="true" <?php if ( $showW == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Show waypoints', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Show waypoints', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -472,7 +430,7 @@
<?php _e( 'Start track icon:', 'wp-gpx-maps' ); ?> <?php _e( 'Start track icon:', 'wp-gpx-maps' ); ?>
</th> </th>
<td> <td>
<input name="wpgpxmaps_map_start_icon" value="<?php echo get_option( 'wpgpxmaps_map_start_icon' ); ?>" style="width:400px" /> <input name="wpgpxmaps_map_start_icon" type="text" value="<?php echo get_option( 'wpgpxmaps_map_start_icon' ); ?>" style="width:400px" />
<em> <em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?> <?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em> </em>
@ -484,7 +442,7 @@
<?php _e( 'End track icon:', 'wp-gpx-maps' ); ?> <?php _e( 'End track icon:', 'wp-gpx-maps' ); ?>
</th> </th>
<td> <td>
<input name="wpgpxmaps_map_end_icon" value="<?php echo get_option( 'wpgpxmaps_map_end_icon' ); ?>" style="width:400px" /> <input name="wpgpxmaps_map_end_icon" type="text" value="<?php echo get_option( 'wpgpxmaps_map_end_icon' ); ?>" style="width:400px" />
<em> <em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?> <?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em> </em>
@ -496,7 +454,7 @@
<?php _e( 'Current position icon:', 'wp-gpx-maps' ); ?> <?php _e( 'Current position icon:', 'wp-gpx-maps' ); ?>
</th> </th>
<td> <td>
<input name="wpgpxmaps_map_current_icon" value="<?php echo get_option( 'wpgpxmaps_map_current_icon' ); ?>" style="width:400px" /> <input name="wpgpxmaps_map_current_icon" type="text" value="<?php echo get_option( 'wpgpxmaps_map_current_icon' ); ?>" style="width:400px" />
<em> <em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?> <?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em> </em>
@ -508,7 +466,7 @@
<?php _e( 'Current GPS position icon:', 'wp-gpx-maps' ); ?> <?php _e( 'Current GPS position icon:', 'wp-gpx-maps' ); ?>
</th> </th>
<td> <td>
<input name="wpgpxmaps_currentpositioncon" value="<?php echo get_option( 'wpgpxmaps_currentpositioncon' ); ?>" style="width:400px" /> <input name="wpgpxmaps_currentpositioncon" type="text" value="<?php echo get_option( 'wpgpxmaps_currentpositioncon' ); ?>" style="width:400px" />
<em> <em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?> <?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em> </em>
@ -520,7 +478,7 @@
<?php _e( 'Custom waypoint icon:', 'wp-gpx-maps' ); ?> <?php _e( 'Custom waypoint icon:', 'wp-gpx-maps' ); ?>
</th> </th>
<td> <td>
<input name="wpgpxmaps_map_waypoint_icon" value="<?php echo get_option( 'wpgpxmaps_map_waypoint_icon' ); ?>" style="width:400px" /> <input name="wpgpxmaps_map_waypoint_icon" type="text" value="<?php echo get_option( 'wpgpxmaps_map_waypoint_icon' ); ?>" style="width:400px" />
<em> <em>
<?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?> <?php _e( '(URL to image) Leave empty to hide.', 'wp-gpx-maps' ); ?>
</em> </em>
@ -553,12 +511,9 @@
<?php _e( 'Altitude:', 'wp-gpx-maps' ); ?> <?php _e( 'Altitude:', 'wp-gpx-maps' ); ?>
</th> </th>
<td> <td>
<input type="checkbox" <?php if ( $showEle == true ){ echo( 'checked' ); } ?> onchange="wpgpxmaps_show_elevation.value = this.checked" onload="wpgpxmaps_show_elevation.value = this.checked" /> <input type="checkbox" <?php if ( $showEle == true ) { echo( 'checked' ); } ?> onchange="wpgpxmaps_show_elevation.value = this.checked" onload="wpgpxmaps_show_elevation.value = this.checked" />
<i> <i>
<?php <?php _e( 'Show altitude', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Show altitude', 'wp-gpx-maps' );
?>
</i> </i>
<input name="wpgpxmaps_show_elevation" type="hidden" value="<?php echo $showEle; ?>"> <input name="wpgpxmaps_show_elevation" type="hidden" value="<?php echo $showEle; ?>">
</td> </td>
@ -579,12 +534,42 @@
</th> </th>
<td> <td>
<select name='wpgpxmaps_unit_of_measure'> <select name='wpgpxmaps_unit_of_measure'>
<option value="0" <?php if ( $uom == '0' ) echo 'selected'; ?>><?php _e( 'meters / meters', 'wp-gpx-maps' ); ?></option> <option value="0" <?php if ( $uom == '0' ) echo 'selected'; ?>>
<option value="1" <?php if ( $uom == '1' ) echo 'selected'; ?>><?php _e( 'feet / miles', 'wp-gpx-maps' ); ?></option> <?php
<option value="2" <?php if ( $uom == '2' ) echo 'selected'; ?>><?php _e( 'meters / kilometers', 'wp-gpx-maps' ); ?></option> /* translators: chart axis labels */
<option value="3" <?php if ( $uom == '3' ) echo 'selected'; ?>><?php _e( 'meters / nautical miles', 'wp-gpx-maps' ); ?></option> _e( 'meters / meters', 'wp-gpx-maps' );
<option value="4" <?php if ( $uom == '4' ) echo 'selected'; ?>><?php _e( 'meters / miles', 'wp-gpx-maps' ); ?></option> ?>
<option value="5" <?php if ( $uom == '5' ) echo 'selected'; ?>><?php _e( 'feet / nautical miles', 'wp-gpx-maps' ); ?></option> </option>
<option value="1" <?php if ( $uom == '1' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'feet / miles', 'wp-gpx-maps' );
?>
</option>
<option value="2" <?php if ( $uom == '2' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'meters / kilometers', 'wp-gpx-maps' );
?>
</option>
<option value="3" <?php if ( $uom == '3' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'meters / nautical miles', 'wp-gpx-maps' );
?>
</option>
<option value="4" <?php if ( $uom == '4' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'meters / miles', 'wp-gpx-maps' );
?>
</option>
<option value="5" <?php if ( $uom == '5' ) echo 'selected'; ?>>
<?php
/* translators: chart axis labels */
_e( 'feet / nautical miles', 'wp-gpx-maps' );
?>
</option>
</select> </select>
</td> </td>
</tr> </tr>
@ -595,10 +580,12 @@
</th> </th>
<td> <td>
<?php _e( 'From', 'wp-gpx-maps' ); ?> <?php _e( 'From', 'wp-gpx-maps' ); ?>
<input name="wpgpxmaps_graph_offset_from1" value="<?php echo get_option( 'wpgpxmaps_graph_offset_from1' ); ?>" style="width:50px;" /> <input name="wpgpxmaps_graph_offset_from1" type="text" value="<?php echo get_option( 'wpgpxmaps_graph_offset_from1' ); ?>" style="width:50px;" />
<?php _e( 'to', 'wp-gpx-maps' ); ?> <?php _e( 'to', 'wp-gpx-maps' ); ?>
<input name="wpgpxmaps_graph_offset_to1" value="<?php echo get_option( 'wpgpxmaps_graph_offset_to1' ); ?>" style="width:50px;" /> <input name="wpgpxmaps_graph_offset_to1" type="text" value="<?php echo get_option( 'wpgpxmaps_graph_offset_to1' ); ?>" style="width:50px;" />
<em><?php _e( '(leave empty for auto scale)', 'wp-gpx-maps' ); ?></em> <em>
<?php _e( '(leave empty for auto scale)', 'wp-gpx-maps' ); ?>
</em>
</td> </td>
</tr> </tr>
@ -607,7 +594,10 @@
<?php _e( 'Speed:', 'wp-gpx-maps' ); ?> <?php _e( 'Speed:', 'wp-gpx-maps' ); ?>
</th> </th>
<td> <td>
<input name="wpgpxmaps_show_speed" type="checkbox" value="true" <?php if ( $showSpeed == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /><i><?php echo ' ' ; _e( 'Show speed', 'wp-gpx-maps' ); ?></i> <input name="wpgpxmaps_show_speed" type="checkbox" value="true" <?php if ( $showSpeed == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i>
<?php _e( 'Show speed', 'wp-gpx-maps' ); ?>
</i>
</td> </td>
</tr> </tr>
@ -626,13 +616,48 @@
</th> </th>
<td> <td>
<select name='wpgpxmaps_unit_of_measure_speed'> <select name='wpgpxmaps_unit_of_measure_speed'>
<option value="0" <?php if ( $uomSpeed == '0' ) echo 'selected'; ?>><?php _e( 'm/s', 'wp-gpx-maps' ); ?></option> <option value="0" <?php if ( $uomSpeed == '0' ) echo 'selected'; ?>>
<option value="1" <?php if ( $uomSpeed == '1' ) echo 'selected'; ?>><?php _e( 'km/h', 'wp-gpx-maps' ); ?></option> <?php
<option value="2" <?php if ( $uomSpeed == '2' ) echo 'selected'; ?>><?php _e( 'miles/h', 'wp-gpx-maps' ); ?></option> /* translators: speed unit of measure */
<option value="3" <?php if ( $uomSpeed == '3' ) echo 'selected'; ?>><?php _e( 'min/km', 'wp-gpx-maps' ); ?></option> _e( 'm/s', 'wp-gpx-maps' );
<option value="4" <?php if ( $uomSpeed == '4' ) echo 'selected'; ?>><?php _e( 'min/miles', 'wp-gpx-maps' ); ?></option> ?>
<option value="5" <?php if ( $uomSpeed == '5' ) echo 'selected'; ?>><?php _e( 'Knots (nautical miles / hour)', 'wp-gpx-maps' ); ?></option> </option>
<option value="6" <?php if ( $uomSpeed == '6' ) echo 'selected'; ?>><?php _e( 'min/100 meters', 'wp-gpx-maps' ); ?></option> <option value="1" <?php if ( $uomSpeed == '1' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'km/h', 'wp-gpx-maps' );
?>
</option>
<option value="2" <?php if ( $uomSpeed == '2' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'miles/h', 'wp-gpx-maps' );
?>
</option>
<option value="3" <?php if ( $uomSpeed == '3' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'min/km', 'wp-gpx-maps' );
?>
</option>
<option value="4" <?php if ( $uomSpeed == '4' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'min/miles', 'wp-gpx-maps' );
?>
</option>
<option value="5" <?php if ( $uomSpeed == '5' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'Knots (nautical miles / hour)', 'wp-gpx-maps' );
?>
</option>
<option value="6" <?php if ( $uomSpeed == '6' ) echo 'selected'; ?>>
<?php
/* translators: speed unit of measure */
_e( 'min/100 meters', 'wp-gpx-maps' );
?>
</option>
</select> </select>
</td> </td>
</tr> </tr>
@ -643,10 +668,12 @@
</th> </th>
<td> <td>
<?php _e( 'From', 'wp-gpx-maps' ); ?> <?php _e( 'From', 'wp-gpx-maps' ); ?>
<input name="wpgpxmaps_graph_offset_from2" value="<?php echo get_option( 'wpgpxmaps_graph_offset_from2' ); ?>" style="width:50px;" /> <input name="wpgpxmaps_graph_offset_from2" type="text" value="<?php echo get_option( 'wpgpxmaps_graph_offset_from2' ); ?>" style="width:50px;" />
<?php _e( 'to', 'wp-gpx-maps' ); ?> <?php _e( 'to', 'wp-gpx-maps' ); ?>
<input name="wpgpxmaps_graph_offset_to2" value="<?php echo get_option( 'wpgpxmaps_graph_offset_to2' ); ?>" style="width:50px;" /> <input name="wpgpxmaps_graph_offset_to2" type="text" value="<?php echo get_option( 'wpgpxmaps_graph_offset_to2' ); ?>" style="width:50px;" />
<em><?php _e( '(leave empty for auto scale)', 'wp-gpx-maps' ); ?></em> <em>
<?php _e( '(leave empty for auto scale)', 'wp-gpx-maps' ); ?>
</em>
</td> </td>
</tr> </tr>
@ -657,10 +684,7 @@
<td> <td>
<input name="wpgpxmaps_show_hr" type="checkbox" value="true" <?php if ( $showHr == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_show_hr" type="checkbox" value="true" <?php if ( $showHr == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Show heart rate', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Show heart rate', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -681,10 +705,7 @@
<td> <td>
<input name="wpgpxmaps_show_atemp" type="checkbox" value="true" <?php if ( $showAtemp == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_show_atemp" type="checkbox" value="true" <?php if ( $showAtemp == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Show temperature', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Show temperature', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -705,10 +726,7 @@
<td> <td>
<input name="wpgpxmaps_show_cadence" type="checkbox" value="true" <?php if ( $showCad == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_show_cadence" type="checkbox" value="true" <?php if ( $showCad == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Show cadence', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Show cadence', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -729,10 +747,7 @@
<td> <td>
<input name="wpgpxmaps_show_grade" type="checkbox" value="true" <?php if ( $showGrade == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_show_grade" type="checkbox" value="true" <?php if ( $showGrade == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Show grade - BETA (Grade values depends on your GPS accuracy. If you have a poor GPS accuracy they might be totally wrong!)', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Show grade - BETA (Grade values depends on your GPS accuracy. If you have a poor GPS accuracy they might be totally wrong!)', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -777,10 +792,7 @@
<td> <td>
<input name="wpgpxmaps_pointsoffset" type="text" id="wpgpxmaps_pointsoffset" value="<?php echo $po ?>" style="width:50px;" /> <input name="wpgpxmaps_pointsoffset" type="text" id="wpgpxmaps_pointsoffset" value="<?php echo $po ?>" style="width:50px;" />
<i> <i>
<?php <?php _e( 'meters', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'meters', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -792,10 +804,7 @@
<td> <td>
<input name="wpgpxmaps_donotreducegpx" type="checkbox" value="true" <?php if ( $donotreducegpx == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" /> <input name="wpgpxmaps_donotreducegpx" type="checkbox" value="true" <?php if ( $donotreducegpx == true ) { echo( 'checked' ); } ?> onchange="this.value = (this.checked)" />
<i> <i>
<?php <?php _e( 'Do not reduce GPX', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Do not reduce GPX', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>
@ -805,12 +814,9 @@
<?php _e( 'User upload:', 'wp-gpx-maps' ); ?> <?php _e( 'User upload:', 'wp-gpx-maps' ); ?>
</th> </th>
<td> <td>
<input name="wpgpxmaps_allow_users_view" type="checkbox" value="true" onchange="this.value = (this.checked)" <?php if ( $allow_users_upload === "true" ) { echo( 'checked' ); } ?>> <input name="wpgpxmaps_allow_users_view" type="checkbox" value="true" onchange="this.value = (this.checked)" <?php if ( $allow_users_upload === "true" ) { echo( 'checked' ); } ?> />
<i> <i>
<?php <?php _e( 'Allow registered user to upload GPX files', 'wp-gpx-maps' ); ?>
echo ' ';
_e( 'Allow registered user to upload GPX files', 'wp-gpx-maps' );
?>
</i> </i>
</td> </td>
</tr> </tr>

View File

@ -8,47 +8,39 @@ $is_admin = current_user_can( 'publish_posts' );
if ( $is_admin != 1 ) if ( $is_admin != 1 )
return; return;
$allow_users_upload = get_option( 'wpgpxmaps_allow_users_view' ) === "true"; $allow_users_upload = get_option( 'wpgpxmaps_allow_users_view' ) === 'true';
$wpgpxmapsUrl = get_admin_url() . 'admin.php?page=WP-GPX-Maps';
$wpgpxmapsUrl = get_admin_url() . "admin.php?page=WP-GPX-Maps"; $gpxRegEx = '/.gpx$/i';
$gpxRegEx = '/.gpx$/i';
if ( current_user_can( 'manage_options' ) ) { if ( current_user_can( 'manage_options' ) ) {
$menu_root = 'options-general.php'; $menu_root = 'options-general.php';
} elseif ( current_user_can( 'publish_posts' ) ) { } elseif ( current_user_can( 'publish_posts' ) ) {
$menu_root = 'admin.php'; $menu_root = 'admin.php';
} }
if ( isset( $_POST['clearcache'] ) ) { if ( isset( $_POST['clearcache'] ) ) {
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_clearcache_nonce' . $entry ) ) {
if ( isset( $_GET['_wpnonce'] )
&&
wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_clearcache_nonce' . $entry )
) {
echo '<div class="notice notice-success"><p>'; echo '<div class="notice notice-success"><p>';
_e( 'Cache is now empty!', 'wp-gpx-maps' ); _e( 'Cache is now empty!', 'wp-gpx-maps' );
echo '</p></div>'; echo '</p></div>';
wpgpxmaps_recursive_remove_directory( $cacheGpxPath, true ); wpgpxmaps_recursive_remove_directory( $cacheGpxPath, true );
} }
} }
if ( is_writable( $realGpxPath ) ) { if ( is_writable( $realGpxPath ) ) {
?> ?>
<div class="tablenav top"> <div class="tablenav top">
<?php <?php
echo '<form enctype="multipart/form-data" method="POST" style="float:left; margin:5px 20px 0 0" action="' . get_bloginfo( 'wpurl' ) . '/wp-admin/' . $menu_root . '?page=WP-GPX-Maps">'; echo '<form enctype="multipart/form-data" method="POST" style="float:left; margin:5px 20px 0 0" action="' . get_bloginfo( 'wpurl' ) . '/wp-admin/' . $menu_root . '?page=WP-GPX-Maps">';
?> ?>
<?php _e( 'Choose a file to upload:', 'wp-gpx-maps' ); ?> <input name="uploadedfile[]" type="file" onchange="submitgpx(this);" multiple /> <?php _e( 'Choose a file to upload:', 'wp-gpx-maps' ); ?> <input name="uploadedfile[]" type="file" onchange="submitgpx(this);" multiple />
<?php <?php
if ( isset( $_FILES['uploadedfile'] ) ) { if ( isset( $_FILES['uploadedfile'] ) ) {
$total = count( $_FILES['uploadedfile']['name'] ); $total = count( $_FILES['uploadedfile']['name'] );
for ( $i = 0; $i < $total; $i++ ) { for ( $i = 0; $i < $total; $i++ ) {
$uploadingFileName = basename( $_FILES['uploadedfile']['name'][$i] ); $uploadingFileName = basename( $_FILES['uploadedfile']['name'][$i] );
$target_path = $realGpxPath . "/" . $uploadingFileName; $target_path = $realGpxPath . '/' . $uploadingFileName;
if ( preg_match( $gpxRegEx, $target_path ) ) { if ( preg_match( $gpxRegEx, $target_path ) ) {
if ( move_uploaded_file( $_FILES['uploadedfile']['tmp_name'][$i], $target_path ) ) { if ( move_uploaded_file( $_FILES['uploadedfile']['tmp_name'][$i], $target_path ) ) {
echo '<div class="notice notice-success"><p>'; echo '<div class="notice notice-success"><p>';
@ -57,19 +49,19 @@ if ( is_writable( $realGpxPath ) ) {
__( 'The file %1s has been successfully uploaded.', 'wp-gpx-maps' ), __( 'The file %1s has been successfully uploaded.', 'wp-gpx-maps' ),
'<span class="code"><strong>' . esc_html( $uploadingFileName ) . '</strong></span>' '<span class="code"><strong>' . esc_html( $uploadingFileName ) . '</strong></span>'
); );
echo '</p></div>'; echo '</p></div>';
} else {
echo '<div class=" notice notice-error"><p>';
_e( 'There was an error uploading the file, please try again!', 'wp-gpx-maps' );
echo '</p></div>';
}
} else { } else {
echo '<div class=" notice notice-error"><p>'; echo '<div class="notice notice-warning"><p>';
_e( 'There was an error uploading the file, please try again!', 'wp-gpx-maps' ); _e( 'The file type is not supported!', 'wp-gpx-maps' );
echo '</p></div>'; echo '</p></div>';
} }
} else {
echo '<div class="notice notice-warning"><p>';
_e( 'The file type is not supported!', 'wp-gpx-maps' );
echo '</p></div>';
} }
} }
}
?> ?>
</form> </form>
@ -105,21 +97,16 @@ if ( is_writable( $realGpxPath ) ) {
$myGpxFileNames = array(); $myGpxFileNames = array();
if ( is_readable ( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) { if ( is_readable ( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) {
while ( false !== ( $entry = readdir( $handle ) ) ) { while ( false !== ( $entry = readdir( $handle ) ) ) {
if ( preg_match( $gpxRegEx, $entry ) ) { if ( preg_match( $gpxRegEx, $entry ) ) {
if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_deletefile_nonce_' . $entry ) ) {
if ( isset($_GET['_wpnonce']) if ( file_exists( $realGpxPath . '/' . $entry ) ) {
&& unlink( $realGpxPath . '/' . $entry );
wp_verify_nonce( $_GET['_wpnonce'], 'wpgpx_deletefile_nonce_' . $entry )
) {
if ( file_exists( $realGpxPath . "/" . $entry ) ) {
unlink( $realGpxPath . "/" . $entry );
echo '<div class="notice notice-success"><p>'; echo '<div class="notice notice-success"><p>';
printf( printf(
/* translators: GPX file name */ /* translators: GPX file name */
__( 'The file %1s has been successfully deleted.', 'wp-gpx-maps' ), __( 'The file %1s has been successfully deleted.', 'wp-gpx-maps' ),
'<span class="code"><strong>' . esc_html ( $entry ) . '</strong></span>' '<span class="code"><strong>' . esc_html( $entry ) . '</strong></span>'
); );
echo '</p></div>'; echo '</p></div>';
} else { } else {
@ -127,13 +114,12 @@ if ( is_writable( $realGpxPath ) ) {
printf( printf(
/* translators: GPX file name */ /* translators: GPX file name */
__( 'The file %1s could not be deleted.', 'wp-gpx-maps' ), __( 'The file %1s could not be deleted.', 'wp-gpx-maps' ),
'<span class="code"><strong>' . esc_html ( $entry ) . '</strong></span>' '<span class="code"><strong>' . esc_html( $entry ) . '</strong></span>'
); );
echo '</p></div>'; echo '</p></div>';
} }
} else { } else {
$myFile = $realGpxPath . "/" . $entry; $myFile = $realGpxPath . '/' . $entry;
$myGpxFileNames[] = array( $myGpxFileNames[] = array(
'name' => $entry, 'name' => $entry,
'size' => filesize( $myFile ), 'size' => filesize( $myFile ),
@ -146,13 +132,13 @@ if ( is_writable( $realGpxPath ) ) {
closedir( $handle ); closedir( $handle );
} }
if ( is_readable ( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) { if ( is_readable( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) {
while ( false !== ($entry = readdir( $handle ) ) ) { while ( false !== ( $entry = readdir( $handle ) ) ) {
if ( preg_match( $gpxRegEx, $entry ) ) { if ( preg_match( $gpxRegEx, $entry ) ) {
$filenames[] = $realGpxPath . "/" . $entry; $filenames[] = $realGpxPath . '/' . $entry;
} }
} }
closedir( $handle ); closedir( $handle );
} }
?> ?>
@ -237,11 +223,4 @@ if ( is_readable ( $realGpxPath ) && $handle = opendir( $realGpxPath ) ) {
}); });
</script> </script>
<style>
#table tr:hover {
background:#eeeeee;
}
</style>

View File

@ -59,14 +59,15 @@
?> ?>
<code><strong>[sgpx gpx="<?php echo $relativeGpxPath; ?>yourgpxfile.gpx &lt; <?php _e( 'read below all the optional attributes', 'wp-gpx-maps' ); ?> &gt;"]</strong></code> <code><strong>[sgpx gpx="<?php echo $relativeGpxPath; ?>yourgpxfile.gpx &lt; <?php _e( 'read below all the optional attributes', 'wp-gpx-maps' ); ?> &gt;"]</strong></code>
</p> </p>
<strong><?php _e( 'Note: If no value is displayed in the "Current value" column, the value is "false".', 'wp-gpx-maps' ); ?></strong>
</div> </div>
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th colspan="4"> <th class="title" colspan="4">
<strong><?php _e( 'General', 'wp-gpx-maps' ); ?></strong> <?php _e( 'General', 'wp-gpx-maps' ); ?>
</th> </th>
</tr> </tr>
<tr> <tr>
@ -104,6 +105,12 @@
</td> </td>
<td> <td>
<?php _e( 'Value in percent', 'wp-gpx-maps' ); ?> <?php _e( 'Value in percent', 'wp-gpx-maps' ); ?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>100%</strong>
</td> </td>
<td> <td>
<?php echo get_option( 'wpgpxmaps_width' ); ?> <?php echo get_option( 'wpgpxmaps_width' ); ?>
@ -116,6 +123,12 @@
</td> </td>
<td> <td>
<?php _e( 'Value in pixels', 'wp-gpx-maps' ); ?> <?php _e( 'Value in pixels', 'wp-gpx-maps' ); ?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>450px</strong>
</td> </td>
<td> <td>
<?php echo get_option( 'wpgpxmaps_height' ); ?> <?php echo get_option( 'wpgpxmaps_height' ); ?>
@ -128,6 +141,12 @@
</td> </td>
<td> <td>
<?php _e( 'Value in pixels', 'wp-gpx-maps' ); ?> <?php _e( 'Value in pixels', 'wp-gpx-maps' ); ?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>200px</strong>
</td> </td>
<td> <td>
<?php echo get_option( 'wpgpxmaps_graph_height' ); ?> <?php echo get_option( 'wpgpxmaps_graph_height' ); ?>
@ -173,8 +192,8 @@
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th colspan="4"> <th class="title" colspan="4">
<strong><?php _e( 'Map', 'wp-gpx-maps' ); ?></strong> <?php _e( 'Map', 'wp-gpx-maps' ); ?>
</th> </th>
</tr> </tr>
<tr> <tr>
@ -199,23 +218,56 @@
<?php _e( 'Map type', 'wp-gpx-maps' ); ?> <?php _e( 'Map type', 'wp-gpx-maps' ); ?>
</td> </td>
<td> <td>
<strong>HYBRID, ROADMAP, SATELLITE, TERRAIN</strong> <?php
/* translators: map type */
_e( 'HYBRID, ROADMAP, SATELLITE, TERRAIN', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>OSM1</strong> = <?php _e( 'Open Street Map', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = map provider / map type */
_e( 'OSM1 = Open Street Map', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>OSM2</strong> = <?php _e( 'Open Cycle Map', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = map provider / map type */
_e( 'OSM2 = Open Cycle Map', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>OSM4</strong> = <?php _e( 'Open Cycle Map - Transport', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = map provider / map type */
_e( 'OSM4 = Open Cycle Map - Transport', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>OSM5</strong> = <?php _e( 'Open Cycle Map - Landscape', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = map provider / map type */
_e( 'OSM5 = Open Cycle Map - Landscape', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>OSM6</strong> = <?php _e( 'MapToolKit - Terrain', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = map provider / map type */
_e( 'OSM6 = MapToolKit - Terrain', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>OSM7</strong> = <?php _e( 'Open Street Map - Humanitarian map style', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = map provider / map type */
_e( 'OSM7 = Open Street Map - Humanitarian map style', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>OSM9</strong> = <?php _e( 'Hike & Bike', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = map provider / map type */
_e( 'OSM9 = Hike & Bike', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>OSM10</strong> = <?php _e( 'Open Sea Map', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = map provider / map type */
_e( 'OSM10 = Open Sea Map', 'wp-gpx-maps' );
?>
<br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>HYBRID</strong>
</td> </td>
<td> <td>
<?php echo get_option( 'wpgpxmaps_map_type' ); ?> <?php echo get_option( 'wpgpxmaps_map_type' ); ?>
@ -317,8 +369,8 @@
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th colspan="4"> <th class="title" colspan="4">
<strong><?php _e( 'Diagram', 'wp-gpx-maps' ); ?></strong> <?php _e( 'Diagram', 'wp-gpx-maps' ); ?>
</th> </th>
</tr> </tr>
<tr> <tr>
@ -375,18 +427,41 @@
<?php _e( 'Distance / Altitude unit of measure', 'wp-gpx-maps' ); ?> <?php _e( 'Distance / Altitude unit of measure', 'wp-gpx-maps' ); ?>
</td> </td>
<td> <td>
<strong>0</strong> = <?php _e( 'meters / meters', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = chart axis labels */
_e( '0 = meters / meters', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>1</strong> = <?php _e( 'feet / miles', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = chart axis labels */
_e( '1 = feet / miles', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>2</strong> = <?php _e( 'meters / kilometers', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = chart axis labels */
_e( '2 = meters / kilometers', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>3</strong> = <?php _e( 'meters / nautical miles', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = chart axis labels */
_e( '3 = meters / nautical miles', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>4</strong> = <?php _e( 'meters / miles', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = chart axis labels */
_e( '4 = meters / miles', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>5</strong> = <?php _e( 'feet / nautical miles', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = chart axis labels */
_e( '5 = feet / nautical miles', 'wp-gpx-maps' );
?>
<br /> <br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>0</strong>
</td> </td>
<td> <td>
<?php echo get_option( 'wpgpxmaps_unit_of_measure' ); ?> <?php echo get_option( 'wpgpxmaps_unit_of_measure' ); ?>
@ -450,20 +525,46 @@
<?php _e( 'Speed unit of measure', 'wp-gpx-maps' ); ?> <?php _e( 'Speed unit of measure', 'wp-gpx-maps' ); ?>
</td> </td>
<td> <td>
<strong>0</strong> = <?php _e( 'm/s', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = speed unit of measure */
_e( '0 = m/s', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>1</strong> = <?php _e( 'km/h', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = speed unit of measure */
_e( '1 = km/h', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>2</strong> = <?php _e( 'miles/h', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = speed unit of measure */
_e( '2 = miles/h', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>3</strong> = <?php _e( 'min/km', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = speed unit of measure */
_e( '3 = min/km', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>4</strong> = <?php _e( 'min/miles', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = speed unit of measure */
_e( '4 = min/miles', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>5</strong> = <?php _e( 'Knots (nautical miles / hour)', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = speed unit of measure */
_e( '5 = Knots (nautical miles / hour)', 'wp-gpx-maps' );
?>
<br /> <br />
<strong>6</strong> = <?php _e( 'min/100 meters', 'wp-gpx-maps' ); ?> <?php
/* translators: selection = speed unit of measure */
_e( '6 = min/100 meters', 'wp-gpx-maps' );
?>
<br /> <br />
<?php
_e( 'Default is:', 'wp-gpx-maps' );
echo ' ';
?>
<strong>0</strong>
</td> </td>
<td> <td>
<?php echo get_option( 'wpgpxmaps_unit_of_measure_speed' ); ?> <?php echo get_option( 'wpgpxmaps_unit_of_measure_speed' ); ?>
@ -624,8 +725,8 @@
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th colspan="3"> <th class="title" colspan="3">
<strong><?php _e( 'Pictures', 'wp-gpx-maps' ); ?></strong> <?php _e( 'Pictures', 'wp-gpx-maps' ); ?>
</th> </th>
</tr> </tr>
<tr> <tr>
@ -689,8 +790,8 @@
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th colspan="4"> <th class="title" colspan="4">
<strong><?php _e( 'Summary table', 'wp-gpx-maps' ); ?></strong> <?php _e( 'Summary table', 'wp-gpx-maps' ); ?>
</th> </th>
</tr> </tr>
<tr> <tr>
@ -893,8 +994,8 @@
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th colspan="4"> <th class="title" colspan="4">
<strong><?php _e( 'Advanced', 'wp-gpx-maps' ); ?></strong> <?php _e( 'Advanced', 'wp-gpx-maps' ); ?>
</th> </th>
</tr> </tr>
<tr> <tr>

View File

@ -18,7 +18,8 @@ function wpgpxmaps_getAttachedImages( $dt, $lat, $lon, $dtoffset, &$error ) {
'post_mime_type' => 'image', 'post_mime_type' => 'image',
'order' => 'ASC', 'order' => 'ASC',
'orderby' => 'menu_order ASC', 'orderby' => 'menu_order ASC',
)); )
);
foreach ( $attachments as $attachment_id => $attachment ) { foreach ( $attachments as $attachment_id => $attachment ) {
@ -27,27 +28,27 @@ function wpgpxmaps_getAttachedImages( $dt, $lat, $lon, $dtoffset, &$error ) {
$img_metadata = wp_get_attachment_metadata( $attachment_id ); $img_metadata = wp_get_attachment_metadata( $attachment_id );
$item = array(); $item = array();
$item["data"] = wp_get_attachment_link( $attachment_id, array( 105, 105 ) ); $item['data'] = wp_get_attachment_link( $attachment_id, array( 105, 105 ) );
if ( is_callable( 'exif_read_data' ) ) { if ( is_callable( 'exif_read_data' ) ) {
$exif = @exif_read_data( $img_src[0] ); $exif = @exif_read_data( $img_src[0] );
if ( $exif !== false ) { if ( $exif !== false ) {
$item["lon"] = getExifGps( $exif["GPSLongitude"], $exif['GPSLongitudeRef'] ); $item['lon'] = getExifGps( $exif['GPSLongitude'], $exif['GPSLongitudeRef'] );
$item["lat"] = getExifGps( $exif["GPSLatitude"], $exif['GPSLatitudeRef'] ); $item['lat'] = getExifGps( $exif['GPSLatitude'], $exif['GPSLatitudeRef'] );
if ( ( $item["lat"] != 0 ) || ( $item["lon"] != 0 ) ) { if ( ( $item['lat'] != 0 ) || ( $item['lon'] != 0 ) ) {
$result[] = $item; $result[] = $item;
} elseif ( isset( $p->imagedate ) ) { } elseif ( isset( $p->imagedate ) ) {
$_dt = strtotime( $p->imagedate ) + $dtoffset; $_dt = strtotime( $p->imagedate ) + $dtoffset;
$_item = findItemCoordinate( $_dt, $dt, $lat, $lon ); $_item = findItemCoordinate( $_dt, $dt, $lat, $lon );
if ( $_item != null ) { if ( $_item != null ) {
$item["lat"] = $_item["lat"]; $item['lat'] = $_item['lat'];
$item["lon"] = $_item["lon"]; $item['lon'] = $_item['lon'];
$result[] = $item; $result[] = $item;
} }
} }
} }
} else { } else {
$error .= "Sorry, <a href='http://php.net/manual/en/function.exif-read-data.php' target='_blank' >exif_read_data</a> function not found! check your hosting..<br />"; $error .= "Sorry, <a href='http://php.net/manual/en/function.exif-read-data.php' target='_blank' >exif_read_data</a> function not found! check your hosting.<br />";
} }
} }
} catch ( Exception $e ) { } catch ( Exception $e ) {
@ -106,8 +107,7 @@ function relativeGpxCacheFolderPath() {
function wpgpxmaps_recursive_remove_directory( $directory, $empty = false ) { function wpgpxmaps_recursive_remove_directory( $directory, $empty = false ) {
if ( substr( $directory, -1 ) == '/' ) if ( substr( $directory, -1 ) == '/' ) {
{
$directory = substr( $directory, 0, -1 ); $directory = substr( $directory, 0, -1 );
} }
if ( ! file_exists( $directory ) || ! is_dir( $directory ) ) { if ( ! file_exists( $directory ) || ! is_dir( $directory ) ) {
@ -262,31 +262,31 @@ function wpgpxmaps_parseXml( $filePath, $gpxOffset, $distancetype ) {
} }
} }
if ( $lastLat == 0 && $lastLon == 0 ) { if ( $lastLat == 0 && $lastLon == 0 ) {
/* Base Case */ /* Base Case */
array_push( $points->dt, strtotime( $time ) ); array_push( $points->dt, strtotime( $time ) );
array_push( $points->lat, (float) $lat ); array_push( $points->lat, (float) $lat );
array_push( $points->lon, (float) $lon ); array_push( $points->lon, (float) $lon );
array_push( $points->ele, (float) round( $ele, 2 ) ); array_push( $points->ele, (float) round( $ele, 2 ) );
array_push( $points->dist, (float) round( $dist, 2 ) ); array_push( $points->dist, (float) round( $dist, 2 ) );
array_push( $points->speed, 0 ); array_push( $points->speed, 0 );
array_push( $points->hr, (float) $hr ); array_push( $points->hr, (float) $hr );
array_push( $points->atemp, (float) $atemp ); array_push( $points->atemp, (float) $atemp );
array_push( $points->cad, (float) $cad ); array_push( $points->cad, (float) $cad );
array_push( $points->grade, $grade ); array_push( $points->grade, $grade );
$lastLat = $lat; $lastLat = $lat;
$lastLon = $lon; $lastLon = $lon;
$lastEle = $ele; $lastEle = $ele;
$lastTime = $time; $lastTime = $time;
} else { } else {
/* Normal Case */ /* Normal Case */
$offset = calculateDistance( (float) $lat, (float) $lon, (float) $ele, (float) $lastLat, (float) $lastLon, (float) $lastEle, $distancetype ); $offset = calculateDistance( (float) $lat, (float) $lon, (float) $ele, (float) $lastLat, (float) $lastLon, (float) $lastEle, $distancetype );
$dist = $dist + $offset; $dist = $dist + $offset;
$points->totalLength = $dist; $points->totalLength = $dist;
if ( $speed == 0 ) { if ( $speed == 0 ) {
$datediff = (float) my_date_diff( $lastTime, $time ); $datediff = (float) my_date_diff( $lastTime, $time );
@ -295,8 +295,8 @@ function wpgpxmaps_parseXml( $filePath, $gpxOffset, $distancetype ) {
} }
} }
if ( $ele != 0 && $lastEle != 0 ) { if ( $ele != 0 && $lastEle != 0 ) {
$deltaEle = (float) ( $ele - $lastEle ); $deltaEle = (float) ( $ele - $lastEle );
if ( (float) $ele > (float) $lastEle ) { if ( (float) $ele > (float) $lastEle ) {
$points->totalEleUp += $deltaEle; $points->totalEleUp += $deltaEle;
@ -306,98 +306,92 @@ function wpgpxmaps_parseXml( $filePath, $gpxOffset, $distancetype ) {
$grade = $deltaEle / $offset * 100; $grade = $deltaEle / $offset * 100;
} }
array_push( $speedBuffer, $speed ); array_push( $speedBuffer, $speed );
if ( ( (float) $offset + (float) $lastOffset ) > $gpxOffset ) { if ( ( (float) $offset + (float) $lastOffset ) > $gpxOffset ) {
/* Bigger Offset -> write coordinate */ /* Bigger Offset -> write coordinate */
$avgSpeed = 0; $avgSpeed = 0;
foreach ( $speedBuffer as $s ) { foreach ( $speedBuffer as $s ) {
$avgSpeed += $s; $avgSpeed += $s;
} }
$avgSpeed = $avgSpeed / count( $speedBuffer ); $avgSpeed = $avgSpeed / count( $speedBuffer );
$speedBuffer = array(); $speedBuffer = array();
$lastOffset = 0; $lastOffset = 0;
array_push( $points->dt, strtotime( $time ) );
array_push( $points->lat, (float) $lat );
array_push( $points->lon, (float) $lon );
array_push( $points->ele, (float) round( $ele, 2 ) );
array_push( $points->dist, (float) round( $dist, 2 ) );
array_push( $points->speed, (float) round( $avgSpeed, 1 ) );
array_push( $points->hr, $hr );
array_push( $points->atemp, $atemp );
array_push( $points->cad, $cad );
array_push( $points->grade, (float) round( $grade, 2 ) );
array_push( $points->dt, strtotime( $time ) );
array_push( $points->lat, (float) $lat );
array_push( $points->lon, (float) $lon );
array_push( $points->ele, (float) round( $ele, 2 ) );
array_push( $points->dist, (float) round( $dist, 2 ) );
array_push( $points->speed, (float) round( $avgSpeed, 1 ) );
array_push( $points->hr, $hr );
array_push( $points->atemp, $atemp );
array_push( $points->cad, $cad );
array_push( $points->grade, (float) round( $grade, 2 ) );
} else { } else {
/* Smoller Offset -> continue.. */ /* Smoller Offset -> continue.. */
$lastOffset = (float) $lastOffset + (float) $offset; $lastOffset = (float) $lastOffset + (float) $offset;
} }
} }
$lastLat = $lat; $lastLat = $lat;
$lastLon = $lon; $lastLon = $lon;
$lastEle = $ele; $lastEle = $ele;
$lastTime = $time; $lastTime = $time;
} }
array_push( $points->dt, null );
array_push( $points->lat, null );
array_push( $points->lon, null );
array_push( $points->ele, null );
array_push( $points->dist, null );
array_push( $points->speed, null );
array_push( $points->hr, null );
array_push( $points->atemp, null );
array_push( $points->cad, null );
array_push( $points->grade, null );
array_push( $points->dt, null ); unset( $trkpts );
array_push( $points->lat, null );
array_push( $points->lon, null );
array_push( $points->ele, null );
array_push( $points->dist, null );
array_push( $points->speed, null );
array_push( $points->hr, null );
array_push( $points->atemp, null );
array_push( $points->cad, null );
array_push( $points->grade, null );
unset( $trkpts );
} }
unset( $nodes );
unset( $nodes );
try { try {
array_pop( $points->dt, null );
array_pop( $points->lat, null );
array_pop( $points->lon, null );
array_pop( $points->ele, null );
array_pop( $points->dist, null );
array_pop( $points->speed, null );
array_pop( $points->hr, null );
array_pop( $points->atemp, null );
array_pop( $points->cad, null );
array_pop( $points->grade, null );
array_pop( $points->dt, null ); $_time = array_filter( $points->dt );
array_pop( $points->lat, null ); $_ele = array_filter( $points->ele );
array_pop( $points->lon, null ); $_dist = array_filter( $points->dist );
array_pop( $points->ele, null ); $points->maxEle = max( $_ele );
array_pop( $points->dist, null ); $points->minEle = min( $_ele );
array_pop( $points->speed, null ); $points->totalLength = max( $_dist );
array_pop( $points->hr, null ); $points->maxTime = max( $_time );
array_pop( $points->atemp, null ); $points->minTime = min( $_time );
array_pop( $points->cad, null );
array_pop( $points->grade, null );
$_time = array_filter( $points->dt ); /* Calculating Average Speed */
$_ele = array_filter( $points->ele ); $_speed = array_filter( $points->speed );
$_dist = array_filter( $points->dist ); $points->avgSpeed = array_sum( $_speed ) / count( $_speed );
$points->maxEle = max( $_ele );
$points->minEle = min( $_ele );
$points->totalLength = max( $_dist );
$points->maxTime = max( $_time );
$points->minTime = min( $_time );
/* Calculating Average Speed */ /* Calculating Average Cadence */
$_speed = array_filter( $points->speed ); $_cad = array_filter( $points->cad );
$points->avgSpeed = array_sum( $_speed ) / count( $_speed ); $points->avgCad = (float) round( array_sum( $_cad ) / count( $_cad ), 0 );
/* Calculating Average Cadence */ /* Calculating Average Heart Rate */
$_cad = array_filter( $points->cad ); $_hr = array_filter( $points->hr );
$points->avgCad = (float) round( array_sum( $_cad ) / count( $_cad ), 0 ); $points->avgHr = (float) round( array_sum( $_hr ) / count( $_hr ), 0 );
/* Calculating Average Heart Rate */ /* Calculating Average Temperature */
$_hr = array_filter( $points->hr ); $_temp = array_filter( $points->atemp );
$points->avgHr = (float) round( array_sum( $_hr ) / count( $_hr ), 0 ); $points->avgTemp = (float) round( array_sum( $_temp ) / count( $_temp ), 1 );
/* Calculating Average Temperature */
$_temp = array_filter( $points->atemp );
$points->avgTemp = (float) round( array_sum( $_temp ) / count( $_temp ), 1 );
} catch ( Exception $e ) { } catch ( Exception $e ) {
} }
@ -568,15 +562,15 @@ function wpgpxmaps_getWayPoints( $gpxPath ) {
} }
array_push($points, array( array_push($points, array(
"lat" => (float) $lat, 'lat' => (float) $lat,
"lon" => (float) $lon, 'lon' => (float) $lon,
"ele" => (float) $ele, 'ele' => (float) $ele,
"time" => $time, 'time' => $time,
"name" => $name, 'name' => $name,
"desc" => $desc, 'desc' => $desc,
"sym" => $sym, 'sym' => $sym,
"type" => $type, 'type' => $type,
"img" => $img, 'img' => $img,
)); ));
} }
} }
@ -638,4 +632,3 @@ function date_getDecimals( $date ) {
return 0; return 0;
} }
} }
?>

View File

@ -28,10 +28,14 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
try { try {
$pictures = array(); $pictures = array();
foreach ( $galids as $g ) { foreach ( $galids as $g ) {
if ($g != null ) {
$pictures = array_merge( $pictures, nggdb::get_gallery( $g ) ); $pictures = array_merge( $pictures, nggdb::get_gallery( $g ) );
}
} }
foreach ( $imgids as $i ) { foreach ( $imgids as $i ) {
if ($i != null) {
array_push( $pictures, nggdb::find_image( $i ) ); array_push( $pictures, nggdb::find_image( $i ) );
}
} }
foreach ( $pictures as $p ) { foreach ( $pictures as $p ) {
$item = array(); $item = array();
@ -39,8 +43,10 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
if ( is_callable( 'exif_read_data' ) ) { if ( is_callable( 'exif_read_data' ) ) {
$exif = @exif_read_data( $p->imagePath ); $exif = @exif_read_data( $p->imagePath );
if ( $exif !== false ) { if ( $exif !== false ) {
$item['lon'] = getExifGps( $exif['GPSLongitude'], $exif['GPSLongitudeRef'] ); $item['lon'] = (array_key_exists('GPSLongiture', $exif) and array_key_exists('GPSLongitudeRef', $exif)) ?
$item['lat'] = getExifGps( $exif['GPSLatitude'], $exif['GPSLatitudeRef'] ); getExifGps( $exif['GPSLongitude'], $exif['GPSLongitudeRef'] ) : 0;
$item['lat'] = (array_key_exists('GPSLatitude', $exif) and array_key_exists('GPSLatitudeRef', $exif)) ?
getExifGps( $exif['GPSLatitude'], $exif['GPSLatitudeRef'] ) : 0;
if ( ( $item['lat'] != 0 ) || ( $item['lon'] != 0 ) ) { if ( ( $item['lat'] != 0 ) || ( $item['lon'] != 0 ) ) {
$result[] = $item; $result[] = $item;
} elseif ( isset( $p->imagedate ) ) { } elseif ( isset( $p->imagedate ) ) {
@ -54,7 +60,7 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
} }
} }
} else { } else {
$error .= "Sorry, <a href='https://php.net/manual/en/function.exif-read-data.php' target='_blank' rel='noopener noreferrer'>exif_read_data</a> function not found! check your hosting..<br />"; $error .= "Sorry, <a href='https://php.net/manual/en/function.exif-read-data.php' target='_blank' rel='noopener noreferrer'>exif_read_data</a> function not found! check your hosting.<br />";
} }
} }
/* START FIX NEXT GEN GALLERY 2.x */ /* START FIX NEXT GEN GALLERY 2.x */
@ -72,7 +78,7 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
if ( preg_match( "/data-nplmodal-gallery-id=[\"'](.*?)[\"']/", $dummy, $m ) ) { if ( preg_match( "/data-nplmodal-gallery-id=[\"'](.*?)[\"']/", $dummy, $m ) ) {
$galid = $m[1]; $galid = $m[1];
if ( $galid ) { if ( $galid ) {
for( $i = 0; $i < count( $result ); ++$i ) { for ( $i = 0; $i < count( $result ); ++$i ) {
$result[$i]['data'] = str_replace( '%PRO_LIGHTBOX_GALLERY_ID%', $galid, $result[$i]['data'] ); $result[$i]['data'] = str_replace( '%PRO_LIGHTBOX_GALLERY_ID%', $galid, $result[$i]['data'] );
} }
} }
@ -90,9 +96,12 @@ function getNGGalleryImages( $ngGalleries, $ngImages, $dt, $lat, $lon, $dtoffset
function findItemCoordinate( $imgdt, $dt, $lat, $lon ) { function findItemCoordinate( $imgdt, $dt, $lat, $lon ) {
foreach ( array_keys( $dt ) as $i ) { foreach ( array_keys( $dt ) as $i ) {
if ( $i!=0 && $imgdt >= $dt[$i-1] && $imgdt <= $dt[$i] ) { if ( $i != 0 && $imgdt >= $dt[$i - 1] && $imgdt <= $dt[$i] ) {
if ( $lat[$i] != 0 && $lon[$i] != 0 ) if ( $lat[$i] != 0 && $lon[$i] != 0 )
return array( 'lat' => $lat[$i], 'lon' => $lon[$i] ); return array(
'lat' => $lat[$i],
'lon' => $lon[$i],
);
} }
} }
return null; return null;
@ -105,7 +114,7 @@ function getExifGps( $exifCoord, $hemi ) {
$seconds = count( $exifCoord ) > 2 ? gps2Num( $exifCoord[2] ) : 0; $seconds = count( $exifCoord ) > 2 ? gps2Num( $exifCoord[2] ) : 0;
$flip = ( $hemi == 'W' or $hemi == 'S' ) ? -1 : 1; $flip = ( $hemi == 'W' or $hemi == 'S' ) ? -1 : 1;
return $flip * ( $degrees + $minutes / 60 + $seconds / 3600); return $flip * ( $degrees + $minutes / 60 + $seconds / 3600 );
} }
function gps2Num( $coordPart ) { function gps2Num( $coordPart ) {
@ -121,8 +130,7 @@ function gps2Num( $coordPart ) {
$lat = floatval( $parts[0] ); $lat = floatval( $parts[0] );
$lon = floatval( $parts[1] ); $lon = floatval( $parts[1] );
if ($lon == 0 ) if ($lon == 0 )
return $lat; return $lat;
return $lat / $lon; return $lat / $lon;
} }
?>