← All writing
Technical decisions

When WordPress business logic needs a plugin of its own

A request arrives to change a post-payment email. Before editing it, the developer has to discover whether the rule lives in the theme, a snippets tool, a page-builder element or an existing extension. The difficulty is understanding which piece owns the behaviour and what else depends on it.

When I joined the OVZA work, the starting point included basic payment pages with code distributed across functions.php, a snippets plugin and Elementor HTML elements. I created the custom plugins discussed in my case study and developed the connected service workflows. That does not mean every earlier snippet was removed, or that a plugin automatically made the system reliable.

The architectural question is more useful: where should a business rule live so that the team can find, change and verify it?

Give a capability a clear home

Suppose a hypothetical service business needs to request documents after payment and notify an employee when the customer responds. Those actions belong to the service workflow, even if customers reach them through a particular page design.

I would usually give that capability an explicit plugin boundary. A future visual redesign should not require rediscovering the rules for accepting documents. The plugin can expose a shortcode, block or other interface appropriate to the site while keeping the rules discoverable behind it.

A small, documented presentation adjustment may still fit a theme or a managed snippet. The decision depends on responsibility and lifetime. “Can somebody identify and safely change this capability?” is a better test than counting plugins or forbidding every snippet.

Organize for the next question

A plugin folder can become just as difficult to understand as scattered code. I would separate the parts a future developer will ask about: input handling, workflow rules, notifications and the administrative interface. Names should reflect those responsibilities.

WordPress’s own guidance recommends avoiding naming collisions and keeping related files together. It also notes that architecture should match the plugin’s size; a small, focused plugin does not automatically need elaborate classes. WordPress plugin best practices.

For a bilingual Saudi or Egyptian service website, I would keep customer-facing wording separate from the underlying decision. Changing an Arabic email should not accidentally change who receives it. A reviewer should be able to distinguish a copy edit from a workflow change.

Move one complete behaviour at a time

Migration needs more than copying code into a new directory. First map the current entry points: which event calls the rule, where its configuration is stored, and whether another snippet performs a similar action.

For our hypothetical document request, write down the existing behaviour and test it with safe sample data. Then move that behaviour behind the new boundary and disable the former entry point as part of the same controlled change. Leaving both active could cause duplicate messages.

Keep a record of what moved and what remains. A gradual migration is reasonable when the site must continue operating, provided the temporary arrangement is visible and someone owns finishing it.

Review permissions where the action happens

An administrative screen does not by itself establish that a user may perform every action reachable from it. If the plugin lets employees approve a submission, review the request handler as well as the button.

WordPress provides capability checks to determine whether the current user may perform an action. Its nonce documentation also makes clear that a nonce is not a substitute for authorization.

I would test an allowed employee, an account without that permission and a customer trying to act on somebody else’s request. The specific access model must follow the service, not an assumption that every logged-in account is trusted.

Leave an ownership note with the code

A useful handover explains what the plugin owns, where its settings live, which outside services it calls and how to exercise its main workflow in a test environment. It should identify the consequences of disabling it and which customer or operational actions would stop.

That note does not need to be long. It needs to answer the questions that otherwise send the next developer searching through page-builder content during an urgent change. A clear boundary, a reversible migration and understandable evidence of behaviour make a custom plugin valuable beyond its file structure.

Read the OVZA case study for my confirmed plugin and workflow contribution.

Frequently asked questions

When is a custom WordPress plugin appropriate?

When a business capability needs a clear owner and should remain understandable through theme or page-layout changes. Match the architecture to the size of the capability.

Should every snippet become a plugin?

No. Consider its responsibility, dependencies and lifetime. A small presentation change can stay simple; a connected operational workflow needs a more explicit boundary.