The recent spat between Garmin and Strava reminded me that there was a time when I used to post GPX files on this blog for orienteering events and my more interesting runs. I then used the XML Google Maps plugin to render those GPX files. That plugin failed to survive a PHP upgrade many years ago, and the maps were gone. I sensed another opportunity for Copilot…
This time, I decided to try Copilot in agent mode using GPT-5 mini. This was my initial prompt:
Create a script that uses the WordPress API to find all the posts on a given blog that contain a link to a file with .gpx suffix. It should then edit those posts to add a shortcode for the OSM plugin that uses the linked file in the file_list. The file needs to use a relative path.
For example, if the post on the site http://david.currie.name contained the link:
<a href="http://david.currie.name/wp-content/uploads/2013/02/20130217-agglestone.gpx">20130217 Agglestone GPX</a>Then before this paragraph should be added the shortcode:
[osm_map_v3 map_center="autolat,autolon" zoom="autozoom" width="100%" height="450" file_list="../../../../wp-content/uploads/2013/02/20130217-agglestone.gpx" file_color_list="red" file_title="20130217 Agglestone GPX"]There should be an option to not make the updates, but instead output the updates that would be made (i.e. a dry run).
You may select the programming language to use for the script.
It decided to use Python, which seemed a reasonable choice. There were only two major issues with the script it generated:
- It added
/wpto the base URL twice. It then swallowed the error it got back, and just returned zero posts! - It was trying to update the rendered content rather than the raw content.
Both of these it fixed quickly. I also got it to add a preview mode to show the content before and after changes.
The last problem, and the one that took me the longest to resolve, was really of my own creation. The eagle-eyed may have spotted that, in the original prompt, I used http in the URL. That made no difference to the generated code, but it did end up in the README. I then cut and paste that when running the script. The site is set to redirect to https, but everything becomes a GET on the redirect. This meant I was seeing a 200 back on the update POST, but nothing was getting updated!
The final script can be found here. As the README states, I’ve not attempted to tidy anything up, but it did the job for me! 82 posts were updated and their maps resurrected. For example: Run some Pubs.