, ,

Writing WordPress plugins with Standards

[Note: I wrote this in bits and pieces over the past week or so which has caused it to be a bit all over the place 😁 ]

On May 31st I will be speaking at WordCamp Miami about the WordPress coding standards, documentation standards, and showing how to apply those when writing your own plugins.

Although it isn’t an overly flashy or seemingly exciting topic, it gels nicely with my obsession with project organization so *I* am excited to talk about it. I have not completely nailed down my slides yet so I’m going to write things out and use this post as an organizational/focusing exercise.

Lets start with the big one: WordPress Coding Standards for contributing to core.

No, plugins are not core but in an effort to follow best practices we can use the standards when writing our own plugins. If you are new to writing code this should be easy for you. Coming from outside of the WordPress bubble is a bit harder.

This will be immediately after an intro to writing plugins so I need to keep that in mind. Still though, the easiest part of following the standards is making sure your code editor of choice is using the rules for css/php/js. I’ll mark that as “definitely tell people to do that”.

This is something I want to make sure to highlight as well: https://make.wordpress.org/core/handbook/coding-standards/php/#clever-code

Clever is great and all, but at least explain it with a nice big comment 😑

Since the handbook covers so much I don’t want to re-re-re-re-repeat things that everyone will be able to go digest later on. Moving on…

Plugins, with standards! Plugins as a whole topic are really all over the place. If you go off of the codex entry for “Writing a Plugin” there is no telling what you might end up with. [As an aside, that page needs to be updated. Ouch. Maybe I can help 😕 ]

Since the codex is kind of eh in this case, where should you go? These are both good: Plugin Resources – Reference, Plugin Resources – Special Topics . Still though, we are just touching the surface and spitting out a bunch of links. Since I happen to be leading a pretty fancy pants plugin boilerplate which strives to follow best practices and standards I’ll jump into that. Yea, code all up in there.

I’m tempted to go up an add this into my previous thought but that is rather disingenuous. I totally forgot the best place to look at best practices for WordPress….is WordPress. Thankfully there was this exchange to remind me core typically is #doingitright: