Skip to content

Add wp secret commands for the WordPress 7.2 Secrets API #677

Not planned

Description

@ericmann

Feature Request

WordPress 7.2 adds the Secrets API (#66187, r64337). It stores credentials such as API keys encrypted at rest. Each secret keeps a previous version, so it can be rotated without breaking the code that reads it. Hosts can replace the storage with a wp-content/secrets.php drop-in. Docs: secretsapi.dev.

Core left the WP-CLI commands out, because commands ship as WP-CLI packages. For now they live in the feature plugin. On 7.2 the plugin registers them on core's implementation. I'd like to move them into WP-CLI and wanted to ask where they belong before opening a PR. I opened this here because wp option lives here, and because the Abilities API started the same way in #549.

Proposed commands

Site scope (wp secret):

Command What it does
wp secret set <name> [<value>] [--stdin] Stores a secret. --stdin is the documented way to pass the value, so it stays out of shell history and process listings.
wp secret get <name> [--slot=<current|previous>] [--reveal] Shows metadata and a fingerprint. The plaintext is shown only with --reveal.
wp secret delete <name> Deletes a secret.
wp secret list [<namespace>] Lists names, versions and fingerprints. Never values.
wp secret retire <name> Drops the previous version once a rotation is done.
wp secret import-option <option> Moves a plaintext option into the Secrets API (wp_import_option_as_secret()).
wp secret health Runs the three Site Health checks from the CLI.

Network scope: the same commands for network secrets. In the plugin they're wp network-secret. wp network secret, alongside wp network meta, probably fits WP-CLI's naming better.

Open questions

  1. Home. entity-command, next to wp option, or a new secret-command package, like ability-command?
  2. Key management. The plugin also has rotate (re-wrap the root key under a new WP_SECRETS_KEY), dropin (show the active provider, store and keyring) and generate-key. The first two need core internals (_wp_secrets_get_key_manager(), _wp_secrets_get_provider()), which are marked private. I'd suggest leaving those two out until core has a public path for re-wrapping, which is planned for 7.3. generate-key is probably better as part of wp config create, which Generate WP_SECRETS_KEY in wp config create for the WordPress 7.2 Secrets API config-command#234 covers.
  3. Version gate. Use before_invoke with Utils\wp_version_compare( '7.2-beta1', '<' ), like ability-command and the icons commands.

The plugin's migrate-legacy command stays in the plugin. It's for a prototype that is deprecated.

Once the home is settled, I'll open the PR with Behat tests: set, get, list, rotate versions, retire, import, and failing closed when WP_SECRETS_KEY is missing.

Activity

  1. added
    command:option
    help-wanted
    status:unconfirmed
    on Oct 30, 2026
  2. swissspidy commented on Nov 24, 2026

    @swissspidy
    Member

    Closing for now as this was pulled from the release. We can revisit again in the future if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    command:optionhelp-wantedstatus:unconfirmed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions