Daily Top 10 Posts Timezone Bug Fixed
by walter on Jan.08, 2010, under Blogging
Visited 1966 times, 1 so far today
The Daily Top 10 Posts plugin (v0.7) for WordPress has a bug in it where it ignores its timezone setting, thus it starts counting a new day at the wrong time. Its a simple fix that requires editing one line.
First, in order to set your timezone, you have to edit daily-top-10-posts.php and find the following two lines (lines 96 & 97).
#SET TIMEZONE OFFSET (UTC/GMT). To know your timezone, visit http://www.timeanddate.com/worldclock/ and click on the appropriate city. If you live in the Philippines, the offset is +8. $OFFSET = 0;
Change the 0 to whatever is correct for you. US Eastern would be $OFFSET = -5;
(High res timezone map at wikipedia)
Unfortunately, doing that won’t accomplish a thing because there’s a bug further into the file. Look for line 144, (its in the todays_date function), which says:
if ($offset) {
and change it to
if ($OFFSET) {
The case of variables in PHP makes a difference, so when you set $OFFSET earlier, and then check $offset later, you’re checking something completely different that in this case doesn’t exist. After making this change, the day changes will happen at the correct time, although this plug-in makes no adjustment for daylight savings time.
March 24th, 2010 on 9:12 am
Thanx! You save me!