Skip to content

Commit

Permalink
always register private AJAX action to prevent error 400 if logged-in (
Browse files Browse the repository at this point in the history
…#159)

If logged-in users are excluded from tracking (default), we did not
register the private AJAX action, which raises an error 400 with JS
tracking enabled.
Does not affect the visit count, but the erroneous request should not
mess up the server logs.
  • Loading branch information
stklcode committed Jun 7, 2020
1 parent b61aff6 commit 579a97e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).

## unreleased
* Prevent JavaScript tracking from raising 400 for logged-in users, if tracking is disabled (#159)

## 1.7.1
* Fix refresh of the dashboard widget when settings have been changed through the settings page (#147)
* Fix _Cachify_ cache not being flushed after changing JavaScript settings (#152)
Expand Down
4 changes: 1 addition & 3 deletions inc/class-statify.php
Expand Up @@ -79,9 +79,7 @@ public static function init() {

if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
add_action( 'wp_ajax_nopriv_statify_track', array( 'Statify_Frontend', 'track_visit_ajax' ) );
if ( 0 === self::$_options['skip']['logged_in'] ) {
add_action( 'wp_ajax_statify_track', array( 'Statify_Frontend', 'track_visit_ajax' ) );
}
add_action( 'wp_ajax_statify_track', array( 'Statify_Frontend', 'track_visit_ajax' ) );
} elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { // XMLRPC.
add_filter( 'xmlrpc_methods', array( 'Statify_XMLRPC', 'xmlrpc_methods' ) );
} elseif ( defined( 'DOING_CRON' ) && DOING_CRON ) { // Cron.
Expand Down

0 comments on commit 579a97e

Please sign in to comment.