New series: what assistive tech really hears on your checkout page. Start with part one →
Shipwright
Home
WordPress Jul 30, 2026 3 min read 268 views

WP-CLI Commands Every Theme Developer Should Alias

Tomás Herrera

Tomás Herrera

@tomasherrera_

Share

The handful of commands we type every day, and the aliases that shorten them. WordPress rewards developers who work with its APIs instead of around them. Almost every problem we have debugged in client projects started with a shortcut that bypassed a core function.

Cover illustration for the article WP-CLI Commands Every Theme Developer Should Alias
Figure 1. The handful of commands we type every day, and the aliases that shorten them.

The WordPress way

Register things on the right hook, pass complete arguments, and let core handle the rest. It is more typing up front, but the result survives updates and plays nicely with other plugins.

  • Check capabilities before doing anything.
  • Verify a nonce on every state-changing request.
  • Sanitise input and escape output, always.
  • Script test sites with WP-CLI.

Registering it properly

Every endpoint and form needs three things: a capability check, a nonce or equivalent, and sanitisation on the way in with escaping on the way out. Skipping any one of them is how sites get compromised.

Program testing can be used to show the presence of bugs, but never to show their absence!

Edsger W. Dijkstra, Notes on Structured Programming, 1970

Quick takeaway

Use the core API that already exists before writing your own.

Security checklist

🔌

Hooks

Attach code at the right moment in the request.

🔐

Capabilities

Check what the user may do, not who they are.

⌨️

WP-CLI

Script every repetitive admin task.

WP-CLI makes all of this faster to test. We script the setup of a fresh site for every experiment so nothing depends on the state of a long-lived development database.

None of this is new, and that is the point. The techniques that last are usually the boring ones that are documented well and supported by the platform itself.

As always, the examples are simplified to fit on a page. The production version has more error handling and logging, but the shape of the code is the same.

Questions, corrections, and war stories are welcome in the comments. Several of our best follow-up posts started as a reader pointing out something we had missed.

We will revisit this in six months with fresh numbers. If the results change, we will update the post and note what changed at the end.

If you try this on your own project, start with one page or one service rather than the whole codebase. A small experiment gives you real numbers to argue with, and it is easy to roll back if the idea does not fit.

We have been running this approach for several months now. The initial setup took about a day, and the ongoing cost is close to zero once the team knows where to look.

Wrapping up

We will revisit this in six months with fresh numbers. If the results change, we will update the post and note what changed at the end.

Tomás Herrera

Tomás Herrera

Author

PHP and WordPress developer for fifteen years. Tomás maintains a handful of open-source plugins and a strong opinion about hooks.

Related Posts

Comments 7

Diego Alvarez

The quote in the middle is doing a lot of work here, and it earns it.

Amara Nwosu

We have a follow-up on CI in the drafts, stay tuned.

Sam Whitfield Member

This is exactly the write-up I needed this week. We hit the same wall last sprint.

Diego Alvarez

Is there a repo with the full example? Happy to open a PR with a TypeScript version.

Chloe Martin

Would love a follow-up on how you test this in CI.

Yuki Tanaka

The quote in the middle is doing a lot of work here, and it earns it.

Mara Okafor Member

This is exactly the write-up I needed this week. We hit the same wall last sprint.

Leave a comment

Your email will not be published. Sign in for a faster experience.

Supports **bold**, *italic*, and `code`.