If your WordPress site uses a newsletter plugin, an AI writing tool, or anything that talks to an outside service, that service’s API key is almost certainly sitting in your database as plain text. WordPress has never had a place to put credentials, so every plugin that needed one wrote it into the options table like any other setting. WordPress 7.2, whose first release candidate landed on 17 November and which ships on 8 December, finally adds an encrypted Secrets API. It migrates nothing, and on most existing sites it is switched off until you add one constant to wp-config.php.
The short version:
- Plugin API keys today live in
wp_optionsas plain text, so every database backup and every staging clone carries them. - 7.2 adds
wp_set_secret(),wp_get_secret(),wp_delete_secret()andwp_retire_secret_version(), encrypted at rest with a key that comes fromWP_SECRETS_KEY. - No
WP_SECRETS_KEY, no API. Calls returnsecret_key_unavailable, and upgraded sites do not get a key automatically. - Core does not call the Secrets API yet, so 8 December breaks nothing. The breakage comes later, when the plugins you already use move their keys and your site has no key to encrypt them with.
- Your work this month is small: find out which plugins hold keys, decide where the encryption key lives, and rotate anything that has been sitting in a backup for years.
Where your keys are sitting right now
Almost every settings page you have ever filled in on a WordPress site ends up as one row in wp_options. A plugin stores an array of its settings, and the API key is one string inside that array. There is no masking, no encryption, and no warning. If you have ever restored a site from a backup, sent a database dump to a developer, or cloned production to staging, those keys travelled with it.
You can see the shape of it with WP-CLI. Run this on a staging copy, not on production during the day, and keep the output to yourself:
wp db query "SELECT option_name, LENGTH(option_value) AS len
FROM wp_options
WHERE option_value REGEXP '(sk-|api[_-]?key|api[_-]?token|secret)'
ORDER BY len DESC LIMIT 40;"
That is a blunt search and it will miss keys stored under names that do not mention them, so treat the empty result as inconclusive. The reliable way is to list the plugins you pay for or connect, then open each one’s settings page in the admin and look for a field that holds a token: payment gateways, email providers, SEO tools, AI writing assistants, form-to-CRM connectors, backup services. Every one of those is a key in the database.
Two more places worth checking: wp-config.php for keys someone hardcoded by hand, and any custom code in the theme that calls an API. Hardcoding in wp-config.php is not encryption either, but at least the file lives outside the database and does not travel with a dump.
What 7.2 actually gives you
The API is deliberately plain. A secret has a name in the form plugin-slug/secret-name, and you get it back as a WP_Secret object that stays masked until you call reveal(). Saving, reading and deleting look like this:
$secret = wp_get_secret( 'my-plugin/api-key' );
if ( is_wp_error( $secret ) ) {
// The secret exists but cannot be read.
return '';
}
$key = $secret ? $secret->reveal() : '';
Three details matter more than the function names. First, secrets are encrypted at rest with a key kept in wp-config.php, not in the database, so a stolen dump is no longer a list of live credentials. Second, the API keeps a previous version of each secret, which makes rotation a two-step operation instead of an outage: write the new key, then retire the old one. Third, a host can swap the storage layer through a secrets.php drop-in, so a host that already runs a secrets manager can keep using it.
There is no admin screen for secrets in 7.2. That is planned for later, so for now this is a developer-facing change. If you are not writing plugin code, the only part you control is the key.
The missing key is the real story
Beta 5 removed the salt fallback. Without WP_SECRETS_KEY the API is simply unavailable. And only the browser installer writes the constant: new sites created through the WordPress installer get one, while upgraded sites get nothing. Neither does a site whose wp-config.php was written by wp config create, a one-click installer or a provisioning script that copies the sample file and fills in only the eight salts. If the placeholder stays in place, the API rejects it.
Core does not call the API in 7.2, and most plugin authors will wait a release or two before moving their keys, so an upgraded site without a key keeps working for now. What you have is a window: the months between now and the first plugin that moves its key are when you can fix this calmly instead of during a support ticket.
Check both answers on a staging site:
wp config has WP_SECRETS_KEY
wp eval 'var_dump( wp_is_secrets_api_available() );'
Who has to do what
| If you are | Do this before 8 December |
|---|---|
| A site owner | List the plugins that hold tokens, rotate the important ones, and ask your host whether new sites get a key. |
| A plugin author | Test the API against RC1, handle secret_key_unavailable, and keep your own option as a fallback until you are sure the key exists. |
| A host | Write a key in every provisioning path, never regenerate it on a rebuild, and check that secrets do not land in the object cache. |
Rules for the key itself
Treat WP_SECRETS_KEY like a salt with consequences. Generate it with openssl rand -base64 32, and be careful where the value comes from: a trailing newline from a file makes a different key, a copied salt is rejected, and the placeholder in the sample config is rejected too. Keep it in your password manager next to the database credentials, because if you lose it you lose the ability to decrypt every secret stored with it.
One key per environment. A key shared across environments means a production database cloned to staging can still read its secrets, which defeats part of the point. A different key means the clone cannot read them at all, and Site Health will show two critical items until you fix it. Either way, decide on purpose rather than by accident. If you rotate the constant itself, put the old value in WP_SECRETS_KEY_PREVIOUS so existing secrets can still be read while you re-save them.
This is the same class of work as a core update: boring, fifteen minutes, and much cheaper now than after an incident. If you already have a routine for updating WordPress core without opening an attack window, put the key check in the same runbook. If you let an AI agent touch your WordPress site, it matters twice as much, because an agent holding a database-level credential is holding every key in that database.
What I am doing this week
- List every plugin on the site that asks for a token, and write down which ones I would have to fix by hand if the key stopped working.
- Run the options query on a staging copy and match the option names to that list.
- Rotate the keys that touch money and email first, while the old ones still work and I can compare behaviour.
- Ask the host whether a new site gets
WP_SECRETS_KEY, and test the answer on a throwaway install rather than trusting the support page. - Try the RC1 on staging with WP-CLI, then check Site Health on both a fresh install and an upgraded one, because they will not behave the same.
The encryption only protects keys written after it is switched on. Nothing in 7.2 goes back and encrypts the strings already sitting in your options table, and no plugin can do that for you until it adopts the API. So the useful deadline is not 8 December. It is today, and the first command is the query above.









