Brady Vercher wrote an insightful post…

Brady Vercher wrote an insightful post about how he’s been structuring his WordPress plugins. His methods are interesting and his closing advice is good:

It’s not meant to be dogmatic, but if you’re struggling with structure or spending too much time scaffolding new plugins,Β give it a shot and see what you think.

No matter your approach, here are some things I do recommend:

  • Define the main plugin class in its own file (not the in the main plugin file).
  • Don’t register hooks in constructors.
  • Don’t execute code in the same file where functions or classes are defined.