I’ve been building WordPress plugins for more than a decade: from small utilities to integrations with external APIs, including plugins that manage business data. Over time, what taught me the most wasn’t the core functions but the mistakes that repeat in almost every project. This is a look at what I would do the same and what I’d do differently if I started today.
A plugin is not a theme with another name
It’s tempting to treat a plugin as a bigger functions.php. That works until the plugin has to coexist with forty others, with themes you don’t control, and with PHP and WordPress versions that change under your feet.
A well-made plugin is a polite guest: it doesn’t pollute the global space, assumes nothing about the environment, and leaves no residue when uninstalled. In practice that means very concrete things: prefixes or namespaces for everything, no global variables of your own, and a small bootstrap class that registers hooks and delegates the work.
Security is not a final phase
Security flaws in plugins are rarely sophisticated. Almost always they come from one of these four omissions:
- Not validating or sanitizing input. Everything arriving in
$_POST,$_GETor through the REST API is hostile until proven otherwise. - Not escaping output. You escape when printing, not when saving, and with the function that fits the context.
- Forgetting nonces on actions that modify data.
- Not checking capabilities. A nonce validates intent, but not that the user has permission.
The rule I follow is simple: sanitize on the way in, escape on the way out, and check permissions and nonce before touching anything.
if (!current_user_can('manage_options')) {
wp_die(esc_html__('You do not have permission to do this.', 'my-plugin'));
}
check_admin_referer('my_plugin_save');
$value = sanitize_text_field(wp_unslash($_POST['value'] ?? ''));
update_option('my_plugin_value', $value);
And for your own database queries, always $wpdb->prepare(), no exceptions.
Data and performance send the bill
A plugin that runs fine with ten records can drag down an entire site with ten thousand. The performance problems I’ve seen most are always the same:
- Huge options with autoload enabled, loaded on every request even when not needed.
- Queries inside loops, turning one page into hundreds of queries.
- Heavy code on every load that could run only on the screen where it’s needed, or be cached with transients.
- Meta and taxonomies without thinking about volume, when a custom table would have been more honest.
Before writing a feature I ask myself how much the data it handles will grow and where it will be read. That question prevents almost every problem.
Think about updates from day one
Installing a plugin is easy. Updating it without breaking the data of someone who’s used it for years is the hard part. That’s why I always store the plugin’s database version and run migrations explicitly when it changes, instead of assuming everyone starts from the same state.
And backward compatibility is a decision, not an accident: renaming a hook, a shortcode or an option can break other people’s sites that depend on it. If it has to change, the old one stays, marked as deprecated, for a reasonable time.
Ready to be translated and to be cleaned up
Two details that separate a careful plugin from an improvised one:
- Internationalization from the start. Wrapping strings in translation functions costs almost nothing at the beginning and a great deal at the end.
- Clean uninstall. An
uninstall.phpthat removes options, custom tables and scheduled tasks. Whoever uninstalls a plugin expects it to really disappear.
Less code, fewer dependencies
Over the years I’ve moved in a clear direction: use what WordPress already offers before bringing in a library. The Settings API, the REST API, transients or WP_Query have flaws, but they’re tested, documented and maintained for you. Every external dependency is something to update, audit, and which can clash with another plugin’s.
The same goes for features: the best code is the code you don’t need to write. Many requests are solved with a setting or a twenty-line hook, not with a new module.
The ecosystem has more nuance than it seems
WordPress gets talked about as if it were one thing, but there’s a gulf between a site with a carefully written plugin and another with a pile of plugins chosen without judgement. The platform allows both, which is why judgement matters so much.
I’ve also learned not to fight it. WordPress has its quirks, some awkward because of historical compatibility, and the solution is rarely to avoid them but to know them well and work with them.
What I take away
If I had to sum up ten years in one sentence: a good plugin is one you don’t notice. It breaks nothing, slows nothing down, updates without surprises and does exactly what it promises. It takes more effort than it looks, but it’s what separates a plugin you install and forget from one that causes problems every six months.
If you need to build or rescue a WordPress plugin, get in touch and let’s talk.