We're gearing up for this year's WordCamp 2013, and in anticipation of the event, we'll share a few cool (and helpful!) things about WordPress plugin development that make our keyboards glow with glee.
There are so many ways to tackle developing a new WordPress plugin that it's easy to lose your way, especially when it doesn't work as expected. So to shine a little light on it, we've put together a short guide to the best practices that can help make your plugins more effective all around.
1. Know your plan and purpose
It's not uncommon to start on a project of passion only to see it morph and change directions right before your eyes. Sometimes this can be helpful: it lets you know if, perhaps, your original idea wasn't right on the money. But the issue with changing your mind halfway through and adapting the plugin to new ideas is that it quickly opens the door to messy code and update and support issues which can all accumulate to a terribly ineffective plugin.
In short, know what you've set out to do and make it as specific as possible--and stick to it. As other ideas pop up while you're working (and they surely will), jot them down for your next plugin project. While you don't necessarily need to start from scratch each time, of course, the key is to work directly to a single goal. And, as always, to finish what you start.
2. Code up to standard
Quite possibly the most important thing you can do while developing a WordPress plugin: don't get lazy. It might work, but if it isn't up to par, problems will ensue sooner or later. Refer to the WordPress Coding Standards and make it a habit to code well.
3. Know your users
If there is any chance that your plugin will be used by people across the planet, take this into account from the beginning. International users will face a different set of language requirements, and how well your plugin translates can play an important role in its success. WordPress has a good article to help you along here.
4. Be lean and mean
And to the point. Don't load everything, load only the scripts that are necessary and no more. Simple.
5. Plan for security
Don't make security an afterthought. Plan for sanitation, plan for verification. Consider any potential ways malicious code can be injected in your plugin. WordPress, unsurprisingly, has a good guide on this.
6. Document it!
It's hard enough remembering what you've done months or years later, especially if you're experimenting. Don't leave others to figure out your process, especially if you work as a team. Assuming your code is neat and clean, it can still take some legwork to troubleshoot another developer's plugin. Keep good documentation that will help make everything easier come updates. And for goodness' sake, don't just leave your plugin hanging out on the web--deactivate it and delete it if it's out of date or ineffective and you don't plan on updating it.
So there you have it: six key things to help make developing WordPress plugins better. Do you have any practices to add? Let us know in the comments below!