DEV Community


Discussion on: Simplifying WordPress's functions.php with OOP

mathiu profile image

Action hooks fail silently, and I can't tell you how many times I've typed after_theme_setup instead of after_setup_theme.

I have created a simple theme generator years ago, its purpose was mostly to prefix some functions and create all the standard files. I gave it to one of my newly hired colleagues once and as he was finishing his first project, translations were not working exactly because of this. It was fun looking for misspelling.

tylerlwsmith profile image
Tyler Smith Author

That's the worst! To some extent these kinds of mistakes are unavoidable, and probably a good a good argument for test driven development. I've got methods wrapping this functionality in this theme class because I'm using the same hooks over and over, but in most cases this approach is less than practical because of the sheer volume of hooks available.

Building a theme generator like the one you built sounds super cool. That's something I should definitely focus on learning soon.