Getting started with WordPress plugin development

I got an email with the following question, and figured I may as well answer publicly. The question comes from someone who’s an experienced programmer, but has never worked with WordPress before.

[…] I wondered if you had some helpful advice on learning the basics of WP plugin development. I’m mostly hoping there are frameworks/libraries that the community is currently using.

I don’t know of a widely-used library of general WP plugin development tools. Partly this is because WP itself partially qualifies as a “library”, insofar as it provides ready-to-use functions for saving data to the database, URL routing, template loading, user management, etc. And partly it’s because the architecture of WP is so wide open that it’d be difficult to build a more generalized library that covered even a majority of the possible modifications you might make to stock WordPress.

That said, here are a few useful tools that I know of:

  • The official WP documentation on writing a plugin is good for learning about plugin manifests as well as a top-level overview of the aspects of plugin development.
  • The official Plugin API page is also a good starting point. It explains WP’s hook system, which is the foundation for plugin development.
  • Pippin Williamson has written a series called Plugin Development 101 that features a set of video tutorials on common plugin development techniques. Costs a couple bucks, but Pippin is a smart dude and I’m sure the videos are a really good way to get started.
  • There are a couple of tools that can be used to generate boilerplate and basic file setup for plugins. The ones I know of are https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate and the wp scaffold plugin command in WP-CLI.
  • The book Professional WordPress Plugin Development is very solid, and a good investment for those who like to learn this kinda stuff through books.

My #1 piece of advice to people getting started with WP plugin development is to find a plugin that does something sorta like what they are trying to do and to reverse engineer it. For me, this is far faster and more practical than any hello-world tutorial or sequential set of lessons. YMMV.

If anyone has other suggestions, please feel free to add them in the comments.

8 thoughts on “Getting started with WordPress plugin development

  1. Trip Kirkpatrick

    Not having done plugin dev, but wanting to do it, my expectation is to execute a slight variation of this suggestion. I’ll probably pull a small handful of plugins (3–5) with a range of complexities. First I plan to clone each and make small changes to see what happens and then to pursue full reverse engineering. Clone-and-tweak could be considered a phase of reverse engineering, but to me it merits a call-out on its own. Also, I think I’ll gain more from the comparison possibilities of working with a handful in rough parallel than from going soup-to-nuts on one at a time. The range matters, too, as Hello Dolly might be one of the very easiest and should give you the “Yes! I can do this!” feeling so important to sustaining interest and resilience, even if it’s leagues below (in complexity and sophistication) the plugin functionality you want to achieve.

    Reply
    1. Boone Gorges Post author

      Thanks for the thoughts, Trip. You’re right that “clone-and-tweak” is probably a less intimidating and more gratifying way of looking at it than “reverse engineering” (which sounds difficult). I will say that one difficult thing for the absolute beginner is to select a good plugin (or set of plugins) to serve as a starting point. Aside from sheer size, there’s no straightforward metric for knowing what constitutes a “complicated” plugin; and aside from author reputation and user feedback, it’s hard to know what constitutes good code. But I think there’s merit in looking at multiple options, because even the newcomer will be able to draw some conclusions when doing side-by-side comparisons.

      Reply
  2. Peter Knight (@peterrknight)

    I think looking back I would have loved to have been sent to the coding standards page so that the code one writes at the start also builds up the right muscle memory. I say that because I still sometimes fight old habits and have to correct myself while typing/refactoring. It’s little things like naming things, spacing between characters and so forth. A system of file organization is another thing to learn early that comes in handy, Tom McFarlin’s tutorials put a nice emphasis on that too.

    Another thing I wish I had started on doing earlier on is to simply study the WordPress code base directly much more often instead of relying solely on documentation and tutorials. It just seems like you learn a lot more that way.

    Reply
    1. Boone Gorges Post author

      Good call on the coding standards page. Though, to be blunt, getting fixated on coding standards can be frustrating in some cases, since so many WP plugins (and so many parts of WP itself) don’t conform to those standards. I agree wholeheartedly that it’s great to delve into WP itself, but I don’t think it’s the quickest way to get developing plugins. WP, being the parent platform, has to solve a lot of problems (and has a lot of leeway to solve those problems) that simply aren’t relevant or appropriate for plugin development. That said, at a certain point, it’s critical to have a good grasp on how certain sections of WordPress work if you expect to extend them in any meaningful way.

      Reply
    1. Boone Gorges Post author

      Nice, thanks for the pointer, Alan. I think I’ve already told you that the WP settings API is one of the most painful parts of working with WordPress, so I’m glad you found something that helped you not have to start from scratch.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *