php: handle hook scripts better