More fixes for PHP warnings.

Had to revert 'Constants should be set by init action' as the init hook is too late for the rest of the script.