Update 2026-11-13: Corrected the beta Beta A pre-release of software that is given out to a large group of users to trial under real conditions. Beta versions have gone through alpha testing in-house and are generally fairly close in look, feel and function to the final product; however, design changes often occur as part of the process. migration Migration Moving the code, database and media files for a website site from one server to another. Most typically done when changing hosting companies. steps for installs with more than one network network (versus site, blog) : each network’s root key has to be re-encrypted, not only the current network’s.
WordPress 7.2 adds the Secrets API API An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and data in limited, clearly defined ways. , which stores credentials such as API keys and OAuth client secrets encrypted, with one version kept for rotation. The original design is in the proposal and the history is on Trac Trac An open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress. #66187 .
If you tested an earlier WordPress 7.2 beta or created a secrets.php drop-in, review the breaking changes since Beta 1 and beta migration instructions before upgrading.
Storing and reading a secret
wp_get_secret() returns null only when the secret was never stored. When it exists but can’t be read, because the key or the database is unavailable, it returns a WP_Error . Keep the two apart: asking for a new credential on an error can replace one that still works.
Names take the form plugin-slug/secret-name , in lowercase letters, digits, hyphens and underscores. A name without a slash works but triggers _doing_it_wrong() . The prefix stops plugins from overwriting each other’s secrets. It isn’t access control, since any code running on the site can read any secret.
A name also cannot start or end with a hyphen or an underscore and only one slash is allowed.
WP_Secret shows [secret:my-plugin/api-key] when it is printed, logged, JSON JSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. -encoded, or passed to var_dump() or var_export() . Serializing or cloning it throws an exception. Only reveal() returns the value, so call it where you use the value, and don’t cache the object.
Writing a new value moves the current one to WP_Secret_Version:: , so you can fall back to it while a rotated credential rolls out. Saving the same value again, as a settings form does, keeps the version. wp_retire_secret_version() deletes it when you’re done.
wp_list_secrets() returns names and metadata, never values.
wp_import_option_as_secret() copies an existing option into a secret. It leaves the option for you to delete and flags the secret for rotation, since the old value has already been through your backups.
wp_set_network_secret() and the other *_network_secret() functions store secrets for a whole network on multisite multisite Used to describe a WordPress installation with a network of multiple blogs, grouped by sites. This installation type has shared users tables, and creates separate database tables for each blog (wp_posts becomes wp_0_posts). See also network , blog , site . The site and network functions never fall back to each other.
The functions don’t check capabilities capability A capability is permission to perform one or more types of task. Checking if a user has a capability is performed by the current_user_can function. Each user of a WordPress site might have some permissions but not others, depending on their role. For example, users who have the Author role usually have permission to edit their own posts (the “edit_posts” capability), but not permission to edit other users’ posts (the “edit_others_posts” capability). , because they have to work from cron and REST. Check them wherever a user enters or manages a value. The wp_secret_changed action fires when a secret is created, updated, imported, deleted, or retired. It passes fingerprints, never values.
Checking that the API is available
The API needs WP_SECRETS_KEY , covered in the section. Before moving an existing credential into it, check:
This returns false in three cases:
the secrets.php drop-in failed to load;
WP_SECRETS_KEY is missing or not usable;
the key can’t decrypt the root key that is already stored, which happens when someone changes the key after secrets are stored.
A keyring or provider from a working drop-in counts as available. If its backend fails on a request, that call returns a WP_Error .
Some hosts provide secrets through a read-only provider, where values are managed in the host’s dashboard or CLI CLI Command Line Interface. Terminal (Bash) in Mac, Command Prompt in Windows, or WP-CLI for WordPress. rather than in WordPress. On those sites wp_secrets_provider_is_writable() returns false and wp_set_secret() returns a WP_Error .
Reads work the same on every provider, so wp_get_secret() needs no special handling.
Setting WP_SECRETS_KEY
Secrets are encrypted with libsodium (XChaCha20-Poly1305) and stored in the options tables. Their keys are derived from a random root key, which is stored encrypted with WP_SECRETS_KEY from wp-config.php .
Without a usable WP_SECRETS_KEY , the API stores nothing, and every write, and every read of a stored secret, returns a secret_key_unavailable error. An empty key, the wp-config-sample.php placeholder, or a value copied from one of the authentication keys or salts doesn’t count.
New installs get a key: the installer fills it in along with the salts. Existing sites need one added. Site Health generates a line to copy into wp-config.php , below the salts:
You can also make one with php -r 'echo base64_encode( random_bytes( 32 ) ), "\n";' . Hosts and tools that write wp-config.php should add the key when they add the salts. WP-CLI WP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is ’s wp config create is being updated to do the same.
Don’t treat the key like the salts. Once secrets are stored, changing or removing it makes all of them unreadable until the old value comes back. To replace it, follow the steps in the last section.
Replacing the keyring, store or provider
A host can replace part of the API with a wp-content/secrets.php drop-in, which loads like db.php :
WP_Secrets_Keyring : keep the key that encrypts the root key in a KMS or HSM.
WP_Secrets_Store : keep the encrypted records outside the options tables.
WP_Secrets_Provider : hand the whole API to an external secret manager.
The drop-in sets $wp_secrets_keyring , $wp_secrets_store or $wp_secrets_provider . If it fails to load, or sets one to the wrong type, every call returns an error and Site Health reports it. The API never falls back to the defaults, because a misconfigured backend shouldn’t look like an empty one.
PHP PHP The web scripting language in which WordPress is primarily architected. WordPress requires PHP 7.4 or higher doesn’t inherit attributes, so add #[\SensitiveParameter] yourself to any parameter that receives a key or a value. Conformance tests for keyrings and providers are in wordpress-develop under tests/phpunit/includes/secrets/ .
Three tests appear under Security:
Secrets API key source is recommended when the key is missing or not usable, and critical when it can’t decrypt the stored root key.
Secrets API: undecryptable secrets is critical when any stored secret can’t be decrypted.
Secrets API: credentials pending rotation is recommended when secrets are flagged, as imported ones are.
The Info tab has a Secrets API section with the provider, keyring, key source and the number of secrets.
In code, the tests are methods of WP_Site_Health , and the Info section is WP_Debug_Data::get_wp_secrets_api() , under the key wp-secrets-api ( r65394 ). The wp_secrets_site_health_*() functions and the secrets-api key from the betas are gone.
Breaking changes since Beta 1
The following changes affect developers who tested earlier WordPress 7.2 betas or implemented custom drop-ins.
WP_SECRETS_KEY is required ( r65385 , r65389 ). In earlier betas, a site without it used a key derived from LOGGED_IN_KEY and LOGGED_IN_SALT , so rotating the salts made every secret unreadable. That fallback is gone. Secrets stored under it can be kept; see the section .
The keyring, store and provider are abstract classes ( r65390 ). They were interfaces, and an interface can’t gain a method without breaking every class that implements it. The method signatures are unchanged. Change implements to extends in your drop-in, and deploy Deploy Launching code from a local development environment to the production web server, so that it's available to visitors. it together with 7.2. A drop-in that still says implements is a fatal error on every request, and the API can’t catch it.
Smaller changes during the beta:
Drop-ins can set the overrides as plain variables, not only through $GLOBALS ( r65378 ).
secrets.php is listed with the other drop-ins on the Plugins screen and in Site Health ( r65374 ).
Names with a trailing newline are rejected ( r65375 ).
A failed database read no longer replaces the root key ( r65373 ).
If you stored secrets during the beta
Secrets stored on a beta without WP_SECRETS_KEY are encrypted under the old fallback. After updating, Site Health reports that they can’t be decrypted. They’re still there. Leave the salts alone until you’ve finished these steps, because the old key comes from them.
Generate a key with php -r 'echo base64_encode( random_bytes( 32 ) ), "\n";' . Add it and the old key to wp-config.php , below the salts: define( 'WP_SECRETS_KEY', '...your new key...' ); define( 'WP_SECRETS_KEY_PREVIOUS', LOGGED_IN_KEY . LOGGED_IN_SALT );
Re-encrypt the root key with the new key: wp eval '$r = ( new WP_Secrets_Key_Manager() )->rotate_site_key( new WP_Secrets_Config_Key_Provider( true ), new WP_Secrets_Config_Key_Provider() ); echo is_wp_error( $r ) ? $r->get_error_message() : "Done.";'
Remove the WP_SECRETS_KEY_PREVIOUS line.
No stored secret is rewritten. On multisite, one run covers the current network. An install with more than one network has a root key for each, and each one needs re-encrypting before you remove WP_SECRETS_KEY_PREVIOUS . If you already added WP_SECRETS_KEY , keep it and add only the second line. The same steps replace any key: put the old value in WP_SECRETS_KEY_PREVIOUS .
Props to @ whyisjake for technical review and @ jeffpaul for copy review.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
