18 days ago I’ve installed the Wp-Dstats2-Plugin for Worpress. This plugin generates some statistics, e.g. ‘last 10 comments’, ‘visitors’ or – to me most interesting – ‘referrers’.
The data that gets accumulated by that script is quite interesting. I just recently noticed that it does not store the page that was referred (i.e. a single post on my weblog).
Searching for the cause of that behavior I noticed that Wp-Dstats2 will only work correctly in that regard without using rewriting rules (see Options -> Permalinks in your admin-interface). At least that’s my conclusion.
So I fiddled about a bit and came up with a hack that at least does the job for me. I’d guess it will be helpful to other users of Wordpress, too. So here it goes:
- Open
wp-content/plugins/wp-dstats-advanced.php– or whereever you placed yourwp-dstats-advanced.php– in an editor. - Search for the lines that say
if ($page == NULL) { $page = $id; if ($page < 1) { $page = 0; } - Change this to
if ($page == NULL) { $page = $id; if ($page < 1) { $page = dstats2_idFromRewriting(); } - Put the line
include 'wp-dstats-rewrite.php';at the beginning of that file Download wp-dstats-rewrite.php.txt. Cut the ‘.txt’ and put the file in the directory ofDownload wp-dstats-rewrite.txt. Change the ‘.txt’ to ‘.php’ and put the file in the directory ofwp-dstats-advanced.php.wp-dstats-advanced.php.
My solution uses the name, year, month and dayofmonth parameters that are given (invisibly) to the Wordpress-script via the URL. But it can be adapted quite easily. Have a look at ./wp-blog-header.php and compare this with wp-dstats-rewrite.php to get an idea.
{ 3 } Comments
I would REALLY like to use your hack in my installation of WP, but it seems that your file wp-dstats-rewrite.php.txt does not exist!Sigh…
Hello Aliosha,Sorry, the file-extension ‘.php.txt’ caused the script to be executed.
So it WAS there, just not downloadable. I renamed it by leaving out the ‘.php’. Now it does work.
Thanks for letting me know!
Awesome! Nice work.Post a Comment