Closed nbeversl closed 5 years ago
I think the search plugin query arguments could be causing this. Try this tag with a direction to ignore those:
echo GeoMashup::map([
'map_content' => $map_query,
'show_future' => true,
'ignore_url' => true,
]);
Thank you for the reply. I've just tried that and the issue persists.
Since posting the issue, I did discover a workaround that also points to the search plugin as the cause. Stripping out one of its URL attributes (within the Geomashup iframe URL only of course) prevents the issue:
$map = GeoMashup::map([
'map_content' => $map_query,
'show_future' => True,
]);
$map = str_replace('sf_data=results', '', $map);
echo $map;
I've got a support ticket out to the search plugin's developed to try to isolate why this is happening. Glad to try any other fixes you suggest.
One more adjustment to try - Geo Mashup sometimes requires a string instead of a boolean:
echo GeoMashup::map([
'map_content' => $map_query,
'show_future' => true,
'ignore_url' => 'true',
]);
Yes, that resolves it. Thank you. Do you suppose this is an anomalous interaction of using these two plugins together, or could this be called an expected behavior? In other words, is there some sort of bug/error in one of the two, or does 'ignore_url' parameter exist exactly to prevent potential conflicts like this?
This is essentially the purpose of the ignore_url
parameter. It's a legacy feature of Geo Mashup to pass query parameters from the page URL on to global maps on that page. It should really filter these against a whitelist, that would have prevented this issue.
I'm using GeoMashup to make a map of search results from a WordPress query. I don't think it matters for this issue I'm posting, but the website utilizes Search and Filter Pro to get the search results. Search and Filter Pro will return a WP query object for cases like this when passing search results to another plugin. I was getting an error (this same one) using that feature, so I eliminated possible interaction between the two plugins by directly accessing the search data and manually building a WordPress query to pass to GeoMashup. My code looks like this:
// Get search parameters from other plugin
$categories = $sf_current_query->get_field_string("_sft_category");
$categories = str_replace('Categories: ', '', $categories);
$search_terms = $sf_current_query->get_search_term();
// Make new query
$map_args = array(
's' => $search_terms,
'cat' => $categories)
$map_query = new WP_Query ($map_args);
// Show Geomashup Map
echo GeoMashup::map([
'map_content' => $map_query,
'show_future' => True,
]);
Most of the time, though not all of the time, instead of getting a map I get this:
Inspecting the HTML, it appears that characters are being escaped with backward slashes like so:
<iframe name="\"gm-map-1\"" src="\"https:\/\/website.com\/?geo_mashup_content=render-map&map_data_key=6669c66d9609d8f9a1821e6928f3c584&map_content=global&show_future=1&name=gm-map-1&object_ids=174371529565047,174371529565046,174371529663274,174371529663195,174371529609792,174371529596380,174371529596379,174371529609791,174371529596378,174371529538729,174371529610349,174371529538728,174371529610348,174371529538726,174371529538724,174371529610352,174371529561088,174371529561087,174371529561086,174371529633478&sfid=174371529654519&sf_action=get_data&sf_data=results&_sf_s=some_keyword&post_date=12022018\\\\\\\\\\\\\\\\"\\\\"\"" style="\"position:" absolute;="" top:="" 0;="" left:="" width:="" 100%;="" height:="" border:="" none;="" overflow:="" hidden;\"=""><\/iframe><\/div><\/div>"}</iframe>
... and so on... This is evidently some kind of loop wherein an HTML container gets repeatedly written inside of itself, but I cannot figure out where this is occurring and how to prevent it.
I should also mention I'm putting GeoMashup::map() in an AJAX call ; this is working as expected in every case except when passing a WP_query object to GeoMashup.