WordPress 7.2 (final release scheduled for 8 December) adds a Secrets API. Credentials such as API keys are stored encrypted, with one previous version kept for rotation. The Make Core dev note is the reference; these are the points that matter when you move an existing key out of a plain option.
1. Check availability first.
if ( ! wp_is_secrets_api_available ( ) ) { return ; // Keep the existing storage. }
Enter fullscreen mode
Exit fullscreen mode
It returns false when the secrets.php drop-in failed to load, when WP_SECRETS_KEY is missing or unusable, or when the key can't decrypt the root key already stored.
2. Respect host-managed secrets. On a read-only provider, wp_secrets_provider_is_writable() returns false and wp_set_secret() returns a WP_Error . Show a notice instead of an input field, and don't fall back to an option.
3. Import, then clean up. wp_import_option_as_secret() copies the option into a secret.…