OK, I finally figured what was happening.
The call to wp_localize_script in geodirectory/geodirectory-functions/map-functions/map_functions.php would fail and I think it is because I had more than one map displayed on any page.
The line where it would fail i.e. where it would not correctly output the CDATA javascript line in the source code is : wp_localize_script( ‘geodir-map-widget’, $canvas_jason_args, $map_canvas_jason_args);
Initially I thought the wp_enqueue_script was not performed at the right time. But I added a second enqueue_script just before the wp_localize_script and that did not fix the problem.
Then I bumped into the following thread http://wordpress.stackexchange.com/questions/135821/creating-multiple-wp-localize-script-for-shortcode and got the idea to change the name of the handle.
I think the reason for the error is that the same handle might be used more than once.
So the way I fixed it is (for every wp_localise_script occurrence) by :
– creating a unique handle
– enqueueing the map.js script a second time using the unique handle
– wp_localize_script using the unique handle.
I know that map.js is now enqueued twice but I am trying to stick to the original code so I can easily upgrade my site.
Cheers.