Passing WP_Query to another plugin

Forums › Forums › Search & Filter Pro › Passing WP_Query to another plugin

Viewing 8 posts – 11 through 18 (of 18 total)
  • Anonymous
    #195407
    This reply has been marked as private.
    Anonymous
    #195457
    This reply has been marked as private.
    Anonymous
    #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
    #195546

    Hi 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
    #195646

    Hi 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_data attribute altogether from the page URL, only from the URL inside the <iframe> that generates the map. When sf_data=results is 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
    #195792

    Hi 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.php with some URL params, that signal to S&F that a JSON object should be returned.

    sf_action=get_data&sf_data=all

    The mapping plugin (to better integrate with third party plugins) automatically takes these URL variables, and appends it to its own <iframe> url… with sf_action and sf_data in 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_s for 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 the sf_data and sf_action being 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_data and sf_action from 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 in wp-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
    #196421

    Ross,

    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
    #196551

    Hi Nathaniel

    Great stuff, glad they have an option to disable it too.

    Happy holidays 🙂

Viewing 8 posts – 11 through 18 (of 18 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.