refactor wordpress plugin a bit for templates