AJAX mode

You are here:

Ajax mode was conceived in order to make the Geotargeting plugin compatible with all cache plugins around. Once enabled, the shortcodes and geotargeted posts or products will be updated after the page is loaded by doing an AJAX request with Javascript. Thanks to this we are able to bypass the page cache generated by plugins.

This functionality is complex so please test it carefully after activating it.

Important:

  • Geotargeted widgets are not supported by ajax.
  • Posts / products needs to be compliant with WordPress coding standards. This mean that each posts needs to have an ID attribute such as post-12 (where 12 is post ID ) or class attribute with same value. Also when content is replaced with a message the posts needs to have class attribute of “entry-content” in order to know where to place the message.
  • A request is made for every page even is not geotargeting data is set *

Geo Redirects

The difference between this mode and regular mode is that the user sees the page for a second or less. Then, a full screen overlay it's presented to inform that he is being redirected to the right page.

Geo Blocker

The difference between this mode and regular mode is that the user sees the page for a second or less.Then, a full screen overlay it's presented to inform that the page it's not available to the user.

* About the extra requests

When ajax mode it's enabled the plugin will get a list of all posts of the site where you added geolocation even if not the queried page. This happens in case the given pages has widgets or similar where those pages are listed. If you want to save requests because you know this functionality it's not needed you could add the following filter:


add_filter( 'geot/get_geotargeted_posts_pass_id', function( $pid, $ajax_data ) {
        // will save requests in all single pages and posts
        if( $ajax_data['is_singular'] ) {
           return $ajax_data['pid'];
        }
});