WordPress 7.2 is scheduled for December 8, and it ships a Secrets API that encrypts plugin API keys at rest. It's overdue. Before you upgrade an existing site, though, give it a dedicated WP_SECRETS_KEY in wp-config.php. The fallback it uses without one will bite somebody.
Where API keys live today
Open the options table on a typical small-business WordPress site and you'll find the shop's payment key and the newsletter plugin's API key sitting in wp_options as plain text.
That table gets copied constantly. Every backup and staging clone gets its own copy, and so does the database export you send another developer to chase a bug. Each copy is one more place a live key can leak, and a SQL injection that can read wp_options gets all of them at once.
What 7.2 adds
Plugins save a value with wp_set_secret() and read it with wp_get_secret(). The value is encrypted with libsodium before it goes into the options table. Reading it back gives you a WP_Secret object that stays masked in logs and debug output until your code calls reveal(). Names follow a plugin-slug/secret-name pattern.
wp_set_secret( 'my-plugin/api-key', $key_from_form );
$secret = wp_get_secret( 'my-plugin/api-key' );
if ( is_wp_error( $secret ) ) {
// Stored, but it can't be decrypted. The key changed.
} elseif ( null === $secret ) {
// Nothing stored yet. Show the connect screen.
} else {
$client = new API_Client( $secret->reveal() );
}
That three-way return is my favorite part of the design. "Never saved" and "saved but unreadable" are different problems with different fixes, and the API makes you handle them separately instead of treating both as an empty string.
Hosts get a secrets.php drop-in that loads the same way object-cache.php does, so storage or the key can move out to a real secrets manager. There's no admin screen in 7.2. That's planned for 7.3.
Give it its own key
The encryption key comes from a WP_SECRETS_KEY constant in wp-config.php. New installs get one automatically. Existing sites don't, and when the constant is missing, WordPress derives a key from the site's salts.
That fallback is where I expect trouble. Changing the salts is a standard step when you clean up a hacked site. Do that on a site running on the fallback and every stored secret comes back as a WP_Error. Nothing gets corrupted, but every connected plugin needs its key entered again, on what is already a bad day.
So after upgrading an existing site, open Site Health. It flags the missing constant and tells you how to add it. Then keep a copy of that key somewhere other than the site's own backups. If one backup archive holds both the database and wp-config.php, whoever gets the archive gets the ciphertext and the key that opens it.
What it doesn't protect
The proposal spells out the limits. Encryption at rest covers the database being copied or read without permission, which includes backups and SQL injection against the options table. It does nothing about code running inside WordPress. Any plugin can call wp_get_secret() with any name, because nothing checks the slug prefix. It's only a naming convention. A malicious or compromised plugin still reads everything, and so does anyone who can read wp-config.php.
Plugins still have to move
None of this helps until the plugin holding a key switches to the new functions. Until then it keeps writing plain options like it always has. Even core's own Connectors screen is still waiting on that change, tracked in ticket #64789.
If you maintain client sites, ask the vendor behind each plugin that stores a key when they plan to adopt it. If you write plugins, the switch is a few lines, and your users get encrypted keys without doing anything.
Sources
- What's new for developers? (November 2026) (WordPress Developer Blog)
- Proposal: A Secrets API for WordPress 7.2 (Make WordPress Core)
- Changeset 64337: Introduce the Secrets API (WordPress Trac)
- Ticket #64789: Security audit for API key storage on the Connectors screen (WordPress Trac)
Want the next post as soon as it's up?
On iPhone and iPad, notifications work once the blog is on your Home Screen.
- Tap the Share button in Safari.
- Choose Add to Home Screen, then Add.
- Open Off by One from your Home Screen and tap Get notified of new posts.