WordPress 7.2 adds a Secrets API for encrypting plugin credentials
WordPress 7.2's new Secrets API encrypts plugin credentials at rest instead of storing them as plaintext in wp_options, with key rotation and a storage drop-in hosts can override.
WordPress 7.2 adds a Secrets API that encrypts credentials at rest, instead of leaving them as plaintext in the wp_options table. Four new functions, wp_set_secret(), wp_get_secret(), wp_delete_secret() and wp_retire_secret_version(), let a plugin store and read secrets under a namespaced name such as my-plugin/api-key. wp_get_secret() returns a WP_Secret object whose value stays masked until you call reveal() on it, and the previous version of a secret is kept around so you can rotate a key without breaking code still reading the old one.
wp_set_secret( 'my-plugin/api-key', $value );
$secret = wp_get_secret( 'my-plugin/api-key' );
$value = $secret->reveal();
Encryption is tied to a new WP_SECRETS_KEY constant in wp-config.php, generated automatically on fresh installs; existing sites get a Site Health prompt to add one. Hosts can swap in their own storage backend with a secrets.php drop-in. There’s no admin screen for managing secrets yet, that’s planned for a later release. The feature ships as part of WordPress 7.2, due for general availability on 8 December.
Why it matters: plugin authors have long had nowhere good to put an API key or OAuth token short of wp_options in plain text, which is how a fair few of the plugin vulnerabilities covered here start. A first-party, encrypted, rotation-aware store gives them a proper place to put it.
The caveat: 7.2 is still in beta, so the API could still change before release, and without an admin screen, secrets.php is your only visibility into what’s actually stored for now.