Tag Archives: Autoloader

Organizing your files in an object-oriented WordPress plugin

So you’ve made the plunge to the world of PHP object-oriented programming. You want to use that knowledge to build a plugin or convert your plugin to using objects. That’s great!

We’re going to talk about one of the first hurdles you might face when trying to work with PHP objects. That’s organizing your files. It’s an important topic with no general consensus in the WordPress community.

So why is file organization important? Well, let’s look at the code samples on this site to give you an idea. In general, each code sample tends to have a couple of classes and/or interfaces. They’re also small and only cover one specific WordPress problem.

But once you start building a real plugin, you’ll have to solve a lot of problems. That means that you’ll end up with a lot more classes. It can leave you feeling frustrated and looking for answers to questions like:

  • What do you do with them?
  • How do you structure my files and folders to accommodate them?
  • How do you load all the files containing them?

These are all questions that you’ll get an answer to in this article. So let’s get to it!

Continue reading Organizing your files in an object-oriented WordPress plugin