Countdown Timer v3.0.6

Sometime in June of 2012 I released version 3.0 of Countdown Timer. Before that, the last major release was version 2.4 in April of 2010.

I’ve just been busy with other things1. The other reason was that the program had grown from it’s modest roots as a single 321 sloc2 program to a multiple files (80% PHP / 20% JS) with 1,450 sloc. Managing all the files, testing, and integration is — well — hard and not fun. And no one pays me to do it.

It’s taken some time, but I’ve more or less completely redesigned how I develop PHP. I’ve switched to using Aptana, Git Hub, and FirePHP — a PHP integration into FireBug. This was a multimonth project to slowly learn a new way of developing, but it’s been fun! I just spent most of May 2012 essentially rewriting how Countdown Timer works. All the logic is ultimately the same, much of it was converting function and variables into appropriate classes. I’m somewhat particularly happy about being able to extend the DateTime class and use that, although the lastest bug fix release (v3.0.6) was released because of my new found hatred for the DateTime class.

Another big change from 2.4 was taking advantage of some of WordPress’ core i18n3 updates which make handling date and time information a bit easier. Version 3 (and the subsequent dot fix updates) haven’t been a big flashy update, things are more or less where you left them, but you should hopefully see some little things that make you smile and make your life easier. It’s always a challenge to keep making something truly better, but I still have a couple of things I want to implement. However, Countdown Timer is on GitHub and WordPress TRAC, I don’t want this to be code that’s hidden in a cave, so please fork, patch, push and pull away.

Anyway, version 3.0.6 is now out. It fixes some crazy bug with that developed sometime after PHP 5.2 was released that caused the “white screen of death.” There were three issues that I found:

  • WordPress is calling the sanitize callback twice…not sure if this is new behavior or not, but it was breaking things because the second time it was being called it was trying to sanitize a different type of input. I’ll probably need to rewrite the sanitize function in the future.
  • The DateTime class has been expanded and some of the new functions clashed with stuff I had written. PHP can’t overload functions, so instead it just barfs.
  • For some reason, if certain, presumably optional, methods of the new PHP DateTime class are missing, PHP will also barf. In particular, date4, timezone_type5, and timezone.

Anyway, several hours were spent backtracing the errors and providing suitable fixes. So, enjoy!

As per tradition:

Read more or download version 3.0.6!

Also, please consider that I spend several dozens hours making updates for each release…have you donated recently?


  1. which is to say that Countdown Timer has been pushed lower down my priority list 

  2. source lines of code 

  3. internationalization 

  4. which was never supposed to be exposed 

  5. also maybe a bug? 

Calculating Downloads

I recently hit 70,000 downloads on Countdown Plugin, a small plugin I wrote for WordPress about five years ago. Actually, the timer is older than that. I’ve only been using WordPress since my freshman year of college (spring semester circa 2005), before that I had this crazy home brew content management system. Part of that system included the original source of Countdown Timer. When I made the move to WordPress, I forked the code and made it into a WordPress plugin. The basic and display of the timer has remained relatively similar, although the code has pretty much been rewritten.

Download stats with 10- and 40-day moving averages

I digress. Having 70,000 is a great accomplishment. However, it’s not a very telling metric. What I really want to know is how many people are using the plugin currently?

In order to get an idea of how many active users there are, I looked at two pieces of data:

  • Temporal downloads prior to my last release
  • Temporal downloads subsequent to my last release

The theory is that when a new update is released, an upgrade notice goes out to all users of the plugin. This is the cause of the massive spike in downloads. By eliminating the background noise downloads (i.e. people just trying it out), I can calculate the area under the curve and get a rough estimate of the number of users.

I fit a power regression line to the subsequent downloads with an R2 value of 0.83, which is a little lower than I would have liked, but still usable, described by the equation:615.16x^{-0.481}

The average downloads for the 24 days prior to the release were 81.375 downloads/day. Using WolframAlpha, I solved for the intersection of the two lines:
x = \frac{308915776 \cdot 26^{114/481}}{5405625 \cdot 5^{76/481} \cdot 93^{38/481}}\approx 67.0498

The bounds of my function are now 0 (the day that the plugin was released) and 67 (the day the plugin will again be at ~81 downloads). It’s just a mater of integrating the function and subtracting out the base downloads:

\left (\int_{0}^{67}615.16x^{-0.481}  \right ) - \left (81.375\cdot67  \right ) = 5056.675

5,000 seems to be about the base number of users at this point. It will be interesting to see how this number changes over time. Especially since I have the historical data and could analyze how long it takes downloads to return to normal.

5/11/2010: Here’s the data I used: downloads.csv

Countdown Timer v2.4

Just over a year ago I released Countdown Timer v2.3.5. I’ve had the fortunate opportunity to participate many great things over the last year, which is probably why there hasn’t been an release since.

Anyway, I’ve been slaving away at this release for the last three weeks:

Weeks of 2010 - Blue = Internet Applications (i.e. Chrome, Firefox, IE); Red = Development Applications (i.e. Dreamweaver); Tan = Utilities (i.e. PuTTY, FileZilla, etc)
Weeks of 2010 - Blue = Internet Applications (i.e. Chrome, Firefox, IE); Red = Development Applications (i.e. Dreamweaver); Tan = Utilities (i.e. PuTTY, FileZilla, etc)

I probably spent close to twenty hours, committed over 50 revisions, and had 865 lines changes in the core code1. For all this change behind the scenes, you expect to see some changes in the actual interface. Amazingly not.

Most of the work had to do with bringing the code up to WordPress 2.9/3.0 standards. This will ensure that this plugin continues to work well in to the future. As well as trying to keep up with best practices for WordPress Plugin coding.

The other major update dealt with adding CSS hooks to the html elements so that they can be customized better/more fully. In doing this, I also rewrote part of fergcorp_countdownTimer_format to make it less repetitive. This, unfortunately, caused a minor issue with using the [fergcorp_cdt_single date="ENTER_DATE_HERE"] shortcode that has the li-element included; I’ll fix that in a dot-dot release (i.e. 2.4.1).

The settings for Countdown Timer moved the WordPress Tools to Settings in the Admin Menu and you only need to be an Options Manager instead of Administrator to update the options. I think the only other change worth mentioning is that there is now an option to parse shortcodes in the_excerpt. Note that enabling this functionality will parse all shortcodes, not just ones related to Countdown Timer.

As per tradition:

Read more or download version 2.4!


  1. There’s only 1000 source lines of code [SLOC] to begin with, so this is sort of substantial 

Countdown Timer Update is in the Works

It’s been over a year since I’ve had the chance to update Countdown Timer. However, a couple of weeks ago the stars aligned just so and I started working on a slew of updates. Nothing huge, mostly just updating code in the back end to do things properly and rewriting some sections of code to take advantage of new methods WordPress has implemented in the last few releases.

So far I have almost 100 diffs involving a shit ton of source code1

It’s not quite ready yet, but I am working on it; as is hopefully evident by this freakishly late night/early morning post.

Please consider yourselves informed that a new version is on its way.


  1. yes, that’s a technical unit of measurement, similar to the Hella- prefix [See: The Official Petition to Establish ‘Hella-‘ as the SI Prefix for 10^27] 

Countdown Timer v2.3.5

Hot off the press, Countdown Timer 2.3.5 is now available for consumption.

This is a small update that resolves a few issues, including:

  • Updated calculation routine to ensure that dates are accurately when “Months” are not displayed.
  • Updated readme.txt file to make some things more clear
  • Fixed small display issue in the administration menu

Also included are six new languages:
Latvian, Romanian, Russian, Danish, Lithuanian, and Serbian.

Read more or download version 2.3.5!

Countdown Timer v2.2

I wanted to release this earlier, but between finals, being sick, and field session, I haven’t had a lot of time. This version of Countdown Timer (almost) updates the UI to 2.5 look and feel. As it turns out, there’s actually some function calls I can use to better create the UI and I’ll be using those in the future. There’s a couple of bug updates and added some new functionality.

Also, Countdown Timer v2.2 requires WordPress 2.5 or higher!

The run down:

  • Updated some phrases that missed being i18n.
  • Updated i18n to use use sprintf’s to assist in proper translation.
  • Update the admin page to WordPress 2.5 Look and Feel.
  • Users are now able to define the data (text/HTML) that comes after the title and before the actual countdown.
  • Implemented a new function, fergcorp_countdownTimer_single($date), that allows users to create a one-off event outside of The Loop. $date should be PHP strtotime parseable string.
  • Plugin output is now XHTML 1.0 Strict compliant.

Read more or download version 2.2!

Call for Translations: Pending Release of Countdown Timer v2.2

The release of Countdown Timer v2.2 is just around the corner (May 15th at 18:00 GMT). In preparation, I released the PO files for translation last night and sent out an email to all the wonderful participants who’ve translated in the past. Here’s the basic jist of what’s going on:

I’ve updated the PO files and uploaded them to my website. All you should need to do is find the language that’d you like to translate and click on the link below. The page will load with the existing data filled in that has not changed. The blank fields represent data that has changed and needs to be updated.

Also, there are a couple of special fields you should be aware of: “translator_name” is for your name as you’d like it to appear in the credits within the plugin (if you want it displayed). “translator_url” is for the URL link that will be associated with you name (again, if you would like it included).

There are a handful of fields that go something like: %d years,
The %d is a place holder for an integer (such as 5 days,) and can be moved around if needed depending on the localization requirements.

Similarly, there is a %s ago and in %s. Where %s represents a string (in this case, the countdown). This allows the translation of “in” and “ago” to be put in its proper place depending on the localization.

I really hope all that makes sense. If it doesn’t, I’d be more then happy to answer any questions you have. If you’re unsure of the context of certain strings, you can also download the trunk version version at http://downloads.wordpress.org/plugin/countdown-timer.zip

Languages already (mostly) completed:

  • Czech (cs_CS)
  • German (de_DE)
  • Spanish (es_ES)
  • French (fr_FR)
  • Dutch/Holland (nl_NL)
  • Portuguese/Brazil (pt_BR)
  • Swedish/Sweden (sv_SE)
  • Turkish (tr_TR)

As always, if you’d like to add a new translation, you can start here: http://fergcorp.com/project/phPo/phPo.php?poFileName=afdn_countdownTimer.po

And stay tuned for the pending release on Thursday!

phPo Translator – Online PO Translator

One of the great things about being a programmer is that when I have a problem, it’s pretty easy to solve it myself1.

I recently began to seriously support i18n (internationalization) in the Countdown Timer. It’s actually a pretty slick system. Everywhere I have some text that’s output in the plugin, I wrap it in a WordPress defined function that handles the translation. Then I generate a PO file using poEdit and make a MO (which is just a binary/machine object file of the PO file, which is human readable).

The issue is, if someone wanted to translate the PO file, they’d have to download poEdit, figure out how to use it, grab the PO file, translate it, make the MO file, and then send the MO file to me. This works pretty well if the users is a computer guru. But that’s not often the case.

I was hoping there would be an online PO translator, but I couldn’t find one. So I decided to make my own. Thus I present, in the form of clever titles that mash two words together, phPo Translator (or just phPo for short).

I basically wrote the code over lunch today and then decided that I should version control it. So I threw it up on Google Code, which I knew about but had never, up until this point, actually used.

Google Code is simply amazing. It took less then a minute to register and it uses SVN, which I already have installed on my computer. So I upload the code, create the tag, and away we go!

In any event, you can:

See it in action: Translate afdn_countdownTimer.po
Download phPo Translator v0.1.1
View phPo Translator Google Code page


  1. Granted, most of my problems are probably caused because I am a programmer 

Countdown Timer v2.1.1

After dilly dallying around for a couple months, I finally got serious about pushing the 2.1 version out the door. A couple of reasons for this actually.

First, the WordPress 2.5 is coming out end of March/beginning of April and I wanted to get out one more release (this one) before the next version of WordPress hits the streets.

Second, it’s fits with my development flow; releasing every few months when I can.

Here are the list of updates in Countdown Timer v2.1.1:

  • Fixed i18n translation issues where mo file would sometimes not be loaded
  • Updated UI (note: Based on UI code from Google XML Sitemaps)
  • Removed code dealing with recurring events (which has not been included for a few versions now)
  • Added js countdown ability to admin example (which doesn’t have wp_footer hook?)
  • Updated the link to the JS file to make it dynamic in case a folder gets renamed
  • Fixed a bug in the JS file that caused dates to be calculated incorrectly
  • Append a letter to the beginning of the unique id (as per XHTML requirement)…who knew?
  • Added two language files: Swedish (thanks to Mattias Tengblad) and Spanish (thanks to Google Translator)

The biggest change user will notice is the new UI. It’s based off the code from Google XML Sitemaps which I’m assuming is based off the code from WordPress itself. The great thing about the new design is that you can collapse, expand and move around the boxes to fit your work flow.

All the other changes are ‘under the hood’ and deal with code changes to make things work better in a larger variety of situations.

The Countdown Timer plugin is about three months shy of its third anniversary of public release! I’ve basically been maintaining it since the end of freshman year in college, which is when I switched to WordPress.

The first public version was v0.6. It had about 50 lines of code and used a text file to store the data. There was also no UI at all.

Version 2.1 is about 950 lines of code. Storing data in a text file is gone, instead using the WPDB. There are also several support files, including the javascript port of the countdown mechanism which is another 150 LoC.

Since the beginning of last March, there have been over 8700 downloads, which would almost pay for a semester of college if everyone gave a $1 (wink wink)!

Read more or download version 2.1.1!

Update: Had to increment the plugin to version 2.1.1 because of the way that WordPress does version numbers. In short, v2.01 is the same as v2.1. So I had to release this as 2.1.1.