pluginkollektiv / statify

Statify – statistics plugin for WordPress
https://wordpress.org/plugins/statify/
GNU General Public License v3.0
77 stars 23 forks source link

exclude sitemap calls from tracking (#185) #186

Closed stklcode closed 3 years ago

stklcode commented 4 years ago

resolves #185

The default tracking method does not detect core sitemap calls to wp-sitemap.xml, because there is no check. When WP core sitemaps are disabled, the redirect_template hook is too early, i.e. the sitemap does not yet know if it shall be generated or skipped, so we accidentally track 404 hits in this case.

JS tracking does not seem to be affected, because there either is no wo_footer() for the XML output or is_404() returns true at this point.

Solution: Add a check for the query variable sitemap as suggested in the WP Core discussion1 to the _is_internal() check, s.t. we never try to track anything for sitemap calls.


[1] https://make.wordpress.org/core/2020/07/22/new-xml-sitemaps-functionality-in-wordpress-5-5/#comment-39484

stklcode commented 4 years ago

Added another check for the query var sitemap-stylesheet which is set for the XSL call. Don't see any more elegant way at the moment, but it works for me.

stklcode commented 4 years ago

Rebased on top of the latest development and added test case for sitemaps.