always register private AJAX action to prevent error 400 if logged-in #159
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes an issue that has been reported in WP support forums (switches to German at comment 4):
https://wordpress.org/support/topic/statify-causes-400-error-admin-ajax-php/
Steps to reproduce:
Behavior:
The Statify JS snippet calls the
admin-ajax.php
endpoint for logged-in users. This request results in error code 400 (invalid request, because the action does not exist).Impact:
In most cases, the visit counts are not affected. If tracking is disabled for logged-in users, the visit is not counted anyway. However the log gets messed up with unnecessary errors.
If custom logic has been used to track logged-in users (necessary before 1.7 because there was no option for that), this does not work anymore!
Solution:
Always register the private AJAX action and rely on
_skip_tracking()
to not count the visits.