WP-CLI

The OOPSpam WordPress plugin ships with a set of WP-CLI commands that let you manage its settings from the command line. This is useful for automating configuration, rolling out the plugin across many sites, or managing settings on servers where you don’t have access to the WordPress dashboard.

All commands live under the oopspam namespace and require WP-CLI to be installed:

wp oopspam <command>

The available commands are:

CommandPurpose
wp oopspam statusShow the plugin status and configuration overview
wp oopspam getRead one or all plugin settings
wp oopspam setUpdate a single setting
wp oopspam set-manyUpdate multiple settings from JSON
wp oopspam exportExport settings to a JSON file or stdout
wp oopspam importImport settings from a JSON file
wp oopspam resetReset all settings to their defaults

Status

Show an overview of the plugin configuration, including the plugin version, whether an API key is configured, and the rate limiting state:

wp oopspam status

Example output:

+----------------+----------------------+
| field          | value                |
+----------------+----------------------+
| plugin_version | 1.2.78               |
| configured     | yes                  |
| api_key        | 1234************5678 |
| api_key_source | dashboard            |
| rate_limiting  | yes                  |
| site_url       | https://example.com   |
| multisite      | no                   |
+----------------+----------------------+

The API key is masked for security, so it’s safe to include this output in logs or support requests.

Get settings

Read the current plugin settings. Without arguments, prints the whole settings collection as a table:

wp oopspam get

Pass a setting name to read a single value. Dotted paths are supported, so you can read a nested value inside an option:

wp oopspam get oopspamantispam_settings.oopspam_api_key

Use the --format flag to control the output. The available formats are table (default), json, and plain:

wp oopspam get --format=json
wp oopspam get oopspamantispam_settings.oopspam_api_key --format=plain

Set a setting

Update a single setting. Dotted paths are supported, and JSON values are decoded automatically, so you can set structured data:

wp oopspam set oopspamantispam_settings.oopspam_api_key "abcdef123456"
wp oopspam set oopspamantispam_ratelimit_settings '{"oopspam_is_rt_enabled":"1","oopspamantispam_ratelimit_ip_limit":50}'
wp oopspam set oopspam_countryblocklist '["CN","RU"]'

Set multiple settings

Update several settings at once from a JSON object. You can pass either a map of option keys to full values, or a map of dotted paths to values:

wp oopspam set-many '{"oopspamantispam_settings.oopspam_spam_message":"Blocked","oopspamantispam_settings.oopspam_api_key":"abc123"}'

On a multisite network, add --all-sites to apply the changes to every site:

wp oopspam set-many '{"oopspam_countryblocklist":["CN"]}' --all-sites

Export settings

Export all plugin settings to a JSON file. The exported file can be restored on the same site, moved to another site, or imported through the plugin’s Tools tab in the WordPress dashboard:

wp oopspam export /tmp/oopspam-settings.json

If you omit the file path, the JSON is printed to stdout, so you can redirect it:

wp oopspam export > oopspam-settings.json

Import settings

Import settings from a JSON file produced by wp oopspam export or by the plugin’s Tools tab:

wp oopspam import /tmp/oopspam-settings.json

By default, existing settings are preserved and imported values override them (a merge). Pass --replace to replace each imported option entirely:

wp oopspam import /tmp/oopspam-settings.json --replace

On a multisite network, add --all-sites to import the settings into every site:

wp oopspam import /tmp/oopspam-settings.json --all-sites
ℹ️
The export format is shared between WP-CLI and the plugin’s Tools tab in the WordPress dashboard. A file exported from one can be imported with the other.

Reset settings

Reset every plugin setting back to its default state. A confirmation prompt is shown first, which you can skip with --yes:

wp oopspam reset
wp oopspam reset --yes

On a multisite network, add --all-sites to reset the settings on every site:

wp oopspam reset --yes --all-sites

Multisite networks

The commands that change settings accept an --all-sites flag: set-many, import, and reset. On a multisite network, this applies the command to every site in the network. On a single site, the flag is ignored and the command runs for the current site only, with a warning.