Refactor plugin hooks