Forums › Forums › Search & Filter Pro › Passing WP_Query to another plugin
- This topic has 17 replies, 3 voices, and was last updated 7 years, 11 months ago by
Ross.
-
Anonymous(Private) December 6, 2018 at 5:46 pm #195530
I have discovered a workaround. Stripping the sf_data parameter from the URL, for the purpose if displaying the map within the iframe only, prevents the issue from happening. I’d still be curious to know the reason.
$map = GeoMashup::map([ 'map_content' => $query, 'show_future' => True, ]); $map = str_replace('sf_data=results', '', $map); echo $map;Ross Moderator(Private) December 6, 2018 at 9:23 pm #195546Hi Nathaniel
I’m trying to follow this ticket, but as I literally have no experience on integrating the two, I’m finding it hard to follow.
The sf_data attribute in the URL, tells S&F whether to load the search form object, the results object, or both… This is essential for improving speed when users only require some of the data, not all (ie when only updating results with ajax, but not the search form, then there is no need to add the overhead of generating a search form)…
Regarding the infinite loop you mentioned earlier, when I click both links, I see the same (no infinite loop) –
{"results":"No Results Found"}So, to get my head around your setup, can you explain (with links) which page you have this setup on, and how it is currently working? I’m sure when I get up to speed I’ll be able to better advise.
Thanks
Anonymous(Private) December 9, 2018 at 12:21 pm #195646Hi Ross,
Thank you for following up.
The link I have this set up on is the landing page at http://www.fantutti.com. Geomashup will accept a WP_Query object as a parameter (https://github.com/cyberhobo/wordpress-geo-mashup/wiki/Tag-Reference). I am currently passing a query from SFP, though not on initial load. In order that the map initially display all posts, the query only gets passed when search filters are active.
The issue only happens when the map is reloaded via AJAX, and only when a query object is passed. Remove either one of these factors and the map displays normally.
To clarify, the workaround I’m using is not to remove the
sf_dataattribute altogether from the page URL, only from the URL inside the<iframe>that generates the map. Whensf_data=resultsis added to the<frame>URL, that JSON “No Results” response is displayed. When the<iframe>is inside SFP results, it causes an endless loop of iframes inside of iframes. When I inspect the generated HTML, I see that somehow HTML from the calling page is being regenerated inside the first iFrame, ad infinitum.So there are really two separate behaviors here: 1) the “No Results” JSON text instead of a map, and 2) the endless looping of #1. The link I sent earlier was just an isolated example of the former, out of context of a SFP results page.
Ross Moderator(Private) December 10, 2018 at 7:43 pm #195792Hi Nathaniel
So, after some digging I may have some answers 🙂
1) Ok I see whats happening here. When we do an ajax request (using the shortcode display method), we send a request to
admin-ajax.phpwith some URL params, that signal to S&F that a JSON object should be returned.sf_action=get_data&sf_data=allThe mapping plugin (to better integrate with third party plugins) automatically takes these URL variables, and appends it to its own
<iframe>url… withsf_actionandsf_datain the URL, S&F jumps in, takes over, and shows its json response.So, naturally the thing to do, as you have been, is to remove those params from the URL (note, all the search params could get added, like
_sf_sfor the search field, so remove all the URL vars that are represented by the filters in your search form).2) I think this is related to (1). If the results are coming back in a json object (because S&F takes over it), then there is the
<iframe>markup embedded in there somewhee. This iframe gets loaded, inside it (because of thesf_dataandsf_actionbeing replicated in the URL) will be another json response, with the iframe html… and so on…So it seems like possibly, your technique of removing the
sf_dataandsf_actionfrom the URL is not being applied everywhere? Is this a filter you have been using provided by that plugin, to manipulate the URL? If so, it might not be firing because its not active inwp-admin/admin-ajax.php, where our ajax requests are performed.Make sure your code for filtering the URL is also active in wp-admin, ajax requests are treated as admin, and return true for
is_admin(), which is a common pitfall in these kinds of scenarios.—
I hope the above makes sense? Let me know if you have any questions.
Thanks
Anonymous(Private) December 14, 2018 at 5:15 pm #196421Ross,
Many thanks ; this makes sense and resolved the issue entirely.
I had meanwhile submitted an issue on Github to the Geomashups plugin developer, and it turns out that plugin has a parameter to optionally ignore the sending URL for exactly this scenario. I would not have known to apply it without asking, but it results in essentially the same solution. The thread for that, if it’s useful to you, is here:
https://github.com/cyberhobo/wordpress-geo-mashup/issues/828#issuecomment-446237764
Ross Moderator(Private) December 17, 2018 at 11:39 am #196551Hi Nathaniel
Great stuff, glad they have an option to disable it too.
Happy holidays 🙂
-
AuthorPosts