Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Do not redirect while DOING_AJAX #121

@dboune

Description

@dboune

I found it necessary in one circumstance to hook mlp_redirect_url and prevent redirects during an XHR.

Specifically this occurs with plugins that do not use wp-admin/admin-ajax.php to provide data to the front end. The case here was the use of the Infinite Scroll plugin, part of Jetpack.

You can see the code I am referring to here:
https://github.com/Automattic/jetpack/blob/3.5.3/modules/infinite-scroll/infinity.php#L596-L614

In any case, I believe the definitive determination of whether or not we are in an ajax call should be when DOING_AJAX is true, not is_admin(). It's possible to handle XHR outside of wp-admin/admin-ajax.php, and at the very least DOING_AJAX should be set if you care for other code to be able cope with it.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions