Fixed PHP 5.2 and WP 3.1.0 compatibility

Tested the new code on an outdated WP blog and PHP 5.2 host:

1. Studied WP changelogs, had to update WP core to at least 3.1.0.
1. Only one change was required for PHP 5.2 compatibility.
1. Testing on this host revealed that the database table is apparently not installed upon first activation of the plugin; reverted the activation hook to point to `__FILE__` again and wrapped the constant definitions into conditions instead.