rewritten to enable Drupal-like hooks in WordPress