[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/secrets/ -> class-wp-secrets-key-manager.php (summary)

Secrets API: WP_Secrets_Key_Manager class

File Size: 382 lines (11 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 7 functions

  __construct()
  get_keyring()
  get_master_key()
  get_root_key()
  rotate_site_key()
  get_wrapped_root_key()
  generate_root_key()

Functions
Functions that are not part of a class:

__construct( ?WP_Secrets_Keyring $keyring = null )   X-Ref
Constructor.

param: WP_Secrets_Keyring|null $keyring Keyring to use. Defaults to the

get_keyring()   X-Ref
Returns the keyring in use.

Used by Site Health and by `wp secret dropin` and `wp secret health`, which all
need to describe the active keyring without duplicating the logic that resolves
it.

return: WP_Secrets_Keyring

get_master_key( string $scope, ?int $site_id = null )   X-Ref
Derives a scope's master key from the root key.

return: string|WP_Error 32-byte master key on success. WP_Error on failure,
param: string   $scope   'site' or 'network'.
param: int|null $site_id Blog id for site scope. Defaults to the current blog.

get_root_key()   X-Ref
Returns the root key, generating and persisting one on first use.

return: string|WP_Error 32 raw bytes on success. WP_Error on failure.

rotate_site_key( WP_Secrets_Keyring $old_keyring, WP_Secrets_Keyring $new_keyring )   X-Ref
Re-wraps the root key under a new keyring, without touching any stored secret.

Every derived master key is unchanged by this: they come from the root key's
raw bytes, which rotation never alters, only its wrapping. No secret value is
ever re-encrypted as a result of a site-key rotation.

return: true|WP_Error
param: WP_Secrets_Keyring $old_keyring Unwraps the current wrapped root key.
param: WP_Secrets_Keyring $new_keyring Wraps it again for storage.

get_wrapped_root_key()   X-Ref
Returns the wrapped root key, adopting a pre-conversion copy if needed.

A single site converted to multisite keeps its wrapped root key in its own
(now main site's) options row: `update_site_option()` only starts writing to
sitemeta once `is_multisite()` is true, and the conversion process does not
move existing option rows. Without this, a network's first read would find no
sitemeta row and mint a brand new root key, stranding every secret written
before conversion.

return: mixed The wrapped root key, or false if none exists anywhere. Anything

generate_root_key()   X-Ref
Generates a new root key and persists it.

Handles the race where two requests both find no root key at the same time.

return: string|WP_Error



Generated : Wed Oct 14 08:20:33 2026 Cross-referenced by PHPXref