plebster
Forum Replies Created
-
Fixes/ Workaround here
https://gitlab.com/cooperativeit/event-manager-map-fix-block-themes
The issue is about badly formed JSON data that cannot be parsed. (The data is the data that will be sent to the google API)
The template file that generates the JSON is: templates/map-global.php
This template is called when a shortcode is used and is defined in em-shortcode.php
I believe that the arguments passed to the template file, and the construction of the JSON string are all working fine.
The problem occurs when the string is rendered by the site into an HTML page.When I view the source of the page I see the JSON string like:
{“0″:””,”em_ajax”:true,”query”:”GlobalMapData”,”width”:”400px”,”height”:”300px”,”id”:1016433076}My console shows:
{“0″:””,”em_ajax”:true,”query”:”GlobalMapData”,”width”:”400px”,”height”:”300px”,”id”:1328304383}The maps.js (although I worked in events-manager.js) picks that string from the HTML, tries to parse it and fails because of the badly formed string. i.e. it has curly quotes in it.
We managed to clean up the JSON string with a find a replace script in the javascript, and then the map loads fine.
I’ve no idea if there’s a better way to fix this before the javascript file tries to read the data from the page.
We tried and failed with
1) Adding flags to json_decode in templates/map-global.php – see: https://www.php.net/manual/en/function.json-encode.php
2) Trying to sanatize the json with PHP before it is rendered in HTML
3) Trying to turn off wptexturize site wide – see: https://developer.ww.wp.xz.cn/reference/functions/wptexturize/#more-informationI can now see this error too, Hopefully we’ll have a fix fairly soon
I have done some more testing with this, I can get this to work on the older ‘classic’ themes but this fails every time I use newer block theme.
I’m assuming that mawf.org is not using a block theme.
I hope there is a work around.
that’s really interesting, I might explore the firewall issue, although I can’t under stand why that would be. I see you’re on 6.3.1, what theme are you using and I’ll try and recreate that here.
Thanks again
Thanks for that Jory, that is the conclusion that I had come to…
How do we go about enquing this? do I have to enque every css file into the pods template, are there any examples or documentation that you can show for this.
Thanks again