Skip to content

Run WP-CLI commands

Run allowlisted WP-CLI commands on an environment from the dashboard, and learn why a command is refused.

WP-CLI is the command line for WordPress. Avaloi runs it for you on the environment you pick, from the Tools tab. Open the site, then Tools, then WP-CLI.

Open it

  1. Open a site and pick the environment in the top bar.
  2. Choose Tools, then WP-CLI.

Run a command

  1. Type the command without the wp prefix, for example cache flush.
  2. Press Run.

The command runs as a job. The output appears when it finishes.

How Avaloi checks commands

Avaloi checks each command twice, once in your browser and again on the server. The browser check is advice only: it warns you early, but the server decides. On the server the allowlist applies at the API and again at the agent that runs the command.

A refused command shows the plain reason and a link to the docs. Through the API, a command that is not allowed returns 422 with that link.

On a WordPress network

On a WordPress Multisite network, Avaloi adds --url with the network address to every command, because WordPress needs it to load the right site. A --url you add yourself wins, so option get home --url=address/blog reads one site. Network commands are allowed: site list, site create --slug=blog, site archive, site unarchive, site activate, site deactivate, super-admin list, super-admin add, super-admin remove, plugin activate --network, theme enable --network, and theme disable --network.

Code changes in Git mode

On a live environment, commands that change code are refused, such as plugin install and eval, and so are plugin activate and plugin toggle. Code on live is deployed from Git, and nothing may write code there. On a staging or multidev environment in Git mode, which is the default for new ones, the same code writes are refused, but plugin activate and plugin toggle still run because they change the database only.

Put the change in your repository and deploy it instead. See How Git deploys work. If a plugin needs writable code and cannot work from Git, switch staging to SFTP mode with the SFTP | Git switch on the Code card on Info.

Quick answers

The browser warned me, but the command ran. The browser check is advice only. The server made the final call.

plugin install was refused on live. The environment is in Git mode. Add the plugin to your repository, push, and deploy. On staging or a multidev, you can switch to SFTP mode instead.

Can I run a command on staging? Yes. Pick staging in the top bar, then run it. Commands that write code work only in SFTP mode.

Where do I find the allowlist? A refused command links to the docs page that lists what is allowed.

API

  • POST /v1/environments/{id}/tools/wp-cli

Still stuck?

Email [email protected] with your site name and what you tried, or send us a message.