Skip to content

Commit

Permalink
Fix #84: separate internal-rules from other skip_tracking rules (#86)
Browse files Browse the repository at this point in the history
Changed the rules for appending JS snippet to avoid caching problems.
  • Loading branch information
stklcode authored and patrickrobrecht committed May 19, 2018
1 parent df6f003 commit f52ac47
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ All notable changes to this project will be documented in this file. This projec

## unreleased
* Scaled datapoint size to number of records in dashboard widget to improve legibility
* Added JS source maps to avoid warnings with developer tools
* Added JS source maps to avoid warnings with developer tools
* Add JS snippet to output even if tracking is skipped to avoid caching problems

## 1.6.0
* Added hook statify__visit_saved which is fired after a visit was stored in the database.
Expand Down
19 changes: 15 additions & 4 deletions inc/statify_frontend.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,22 @@ private static function _skip_tracking() {
}

/** Skip tracking via Referrer check and Conditional_Tags. */
return ( self::check_referrer() || is_feed() || is_trackback() || is_robots()
|| is_preview() || is_user_logged_in() || is_404() || is_search()
return ( self::check_referrer() || is_trackback() || is_robots() || is_user_logged_in()
|| self::_is_internal()
);
}

/**
* Rules to detect internal calls to skip tracking and not print code snippet.
*
* @since 1.7.0
*
* @return boolean $skip_hook TRUE if NO tracking is desired
*/
private static function _is_internal() {
return is_feed() || is_preview() || is_404() || is_search();
}

/**
* Compare the referrer url to the blacklist data.
* De/activate this feature via settings in the Dashboard widget.
Expand Down Expand Up @@ -264,8 +275,8 @@ public static function wp_footer() {
return;
}

/* Skip by rules */
if ( self::_skip_tracking() ) {
/* Skip by internal rules (#84) */
if ( self::_is_internal() ) {
return;
}

Expand Down

0 comments on commit f52ac47

Please sign in to comment.