Skip to content

Home / Guides / WordPress development

WordPress development

How to write a WordPress plugin people can trust

A practical route from a local WordPress fix to a portable plugin: define its job, package the release, test upgrades and make maintenance possible.

By Shane Rounce · 5 min read

A plugin often starts as a fix for one site. That is a good starting point, but “works on my site” is a very different claim from “someone else can install, understand, update and trust this”. I have been preparing some of my WordPress plugins for public release, and the useful work has been less about adding features than removing hidden assumptions.

Here is the route I now use when turning a local solution into a plugin worth sharing. It also applies to a private plugin handed to another developer or client.

Start with one job and one user

Write down the problem before opening the editor. Who needs the plugin? What will they see or do differently? What happens when the plugin is disabled? A good first version solves one recognisable problem and leaves unrelated site policy outside the package.

For example, a crawler and SEO plugin can own its metadata and sitemap behaviour. A particular site's analytics choice, branding or private integration belongs in a separate adapter or a documented hook. That boundary makes the plugin easier to test and makes updates less likely to break somebody else's setup.

Before adding a setting, ask whether WordPress already has a useful default. Every extra toggle needs an explanation, a saved value, an upgrade path and a test.

Build for an unfamiliar installation

Use WordPress hooks and public APIs rather than editing Core. Prefix or namespace functions, classes, options and database keys. Check capabilities and nonces before writes, validate and sanitise incoming data, and escape values when displaying them. The Plugin Handbook is a better guide than copying an old snippet without its context.

Make setup quiet and reversible. Activation should work twice without corrupting data. Deactivation should stop scheduled work and leave the site usable. Uninstall should have a clear, documented data policy. If the plugin calls a remote service, say what is sent, when it is sent, and what happens when the service is unavailable. Do not make a dashboard page wait for an external API simply to load.

Test with a clean WordPress install and a normal administrator account, then try a lower-privilege account. A plugin that only works because my own server has a specific constant, cache, folder or companion plugin is not yet portable.

Make the release package match the source

This is the part I have spent a lot of time on recently. A public repository can look tidy while the ZIP contains local files, stale builds or a different version. I want one repeatable build command and a list of exactly which runtime files belong in the package. I compare the built ZIP with what I intend to submit or deploy, then install that ZIP on a disposable site.

Keep the main plugin header, package version and readme in agreement. The WordPress.org readme guide explains the directory format, while the plugin's main PHP file supplies compatibility requirements. Say what the plugin actually does in the first few lines; do not bury limitations in a changelog.

In my own release preparation, a reproducible package for Ace Crawl Enhancer has been useful evidence. It does not by itself mean a directory review has finished or that every upgrade path has been tested. I keep those states separate so I know what is still left to prove.

Test the behaviour that matters to users

  • Install: activate the actual release ZIP on a clean site and check for PHP errors, notices and unexpected network requests.
  • Upgrade: install a previous version with realistic settings and data, then upgrade to the candidate. Confirm that stored values and public output still make sense.
  • Permissions: try each write as an authorised user and an unauthorised one. Check REST routes, AJAX actions and admin forms, not just menu visibility.
  • Failure: disconnect an external service, return an empty result, and make a cache unavailable. The site should still explain what happened and recover.
  • Removal: deactivate and uninstall on a test site. Confirm that scheduled jobs stop and the documented data policy is followed.

Run PHP syntax checks, focused tests and Plugin Check as part of the release. Plugin Check catches many common problems, but WordPress.org says it does not replace manual review. Nor does a mocked API response prove that a real provider behaves the same way. I record exactly which tests ran against the package and which still need a live integration check.

Make maintenance part of the design

Someone will report a bug with a different PHP version, a different theme or a cache you did not use. Give them a useful way to report it: plugin version, WordPress and PHP versions, steps to reproduce, expected and actual behaviour, and relevant logs with private data removed. Keep a changelog that tells people what changed and whether they need to take action.

Use hooks for extension points you can support, and avoid turning every internal function into a promise of compatibility. When a fix is reported, add a regression test for the underlying behaviour. This is also where contributing to WordPress itself helps: Core tickets and code reviews teach the same discipline of reproducing a fault, making a narrow change and giving another person evidence to check it.

If you want to publish on WordPress.org

Read the current directory guidelines before submitting. Pay particular attention to licensing, consent for tracking or external services, readable code, admin behaviour and versioning. Prepare the complete plugin, not a placeholder that needs a paid service just to do its advertised job. Directory approval is a review outcome, not an automatic result of a clean scan.

Start with a small plugin you can support. Build the ZIP from the same source you review, install it from scratch, upgrade it, break its dependencies on purpose, and write down what users should expect. That is how a useful local fix becomes a dependable piece of open source.

Need a hand with your next project?

I help with WordPress development, with practical advice and hands-on work. Tell me what you are trying to improve.

Email Shane