| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Secrets API: WP_Secrets_Provider interface
| File Size: | 227 lines (9 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
WP_Secrets_Provider:: (8 methods):
get()
set()
delete()
retire_previous()
list_secrets()
get_label()
get_protection_boundary()
is_writable()
Interface: WP_Secrets_Provider - X-Ref
Interface for a secrets provider.| get( string $name, string $version, bool $network = false ) X-Ref |
| Retrieves a secret. Returning null means "I am not responsible for this name" as well as "this name does not exist". The two are the same answer from a caller's point of view, and keeping them distinct would require a provider to enumerate names it has never heard of. return: WP_Secret|null|WP_Error param: string $name The secret's name. param: string $version A WP_Secret_Version constant. A provider with no param: bool $network Whether this is a network-scope secret. |
| set( string $name, $value, bool $network = false, bool $needs_rotation = false, ?string $action = null ) X-Ref |
| Stores a secret. A provider whose credentials are managed elsewhere, by a control panel, host tooling, or a KMS with its own access policy, returns WP_Error here with code WP_SECRETS_ERROR_PROVIDER_READ_ONLY, and reports false from is_writable() so that callers can find that out without attempting the write first. Implementations are responsible for firing the `wp_secret_changed` action once the write has succeeded, with `$network` as its last argument. The API does not fire it on the provider's behalf, because only the provider knows the prior fingerprint without paying for an additional read. An audit hook that stopped firing once a host installed a provider would be unreliable in exactly the situation it matters most, so WP_Secrets_Provider_Conformance checks it. A write that fails fires nothing. return: true|WP_Error param: string $name The secret's name. param: string $value The plaintext value. param: bool $network Whether this is a network-scope secret. param: bool $needs_rotation Mark the stored secret as needing rotation. param: string|null $action Overrides the action reported to |
| delete( string $name, bool $network = false ) X-Ref |
| Deletes a secret. Deleting a secret that does not exist is a success. Fires `wp_secret_changed` with the 'deleted' action once a secret has been deleted, for the reason given on set(). A provider that can tell nothing was there to delete fires nothing. return: true|WP_Error param: string $name The secret's name. param: bool $network Whether this is a network-scope secret. |
| retire_previous( string $name, bool $network = false ) X-Ref |
| Clears a secret's previous version, if this provider keeps one. A provider with no version history treats this as a successful no-op: there is nothing to retire, which is the state the caller asked for. Fires `wp_secret_changed` with the 'retired' action once a previous version has been cleared, for the reason given on set(). Nothing fires when there was no previous version to clear. return: true|WP_Error param: string $name The secret's name. param: bool $network Whether this is a network-scope secret. |
| list_secrets( string $name_prefix = '', bool $network = false ) X-Ref |
| Lists secrets by name and metadata. Never values. return: array|WP_Error List of arrays with keys 'name', 'fingerprint', param: string $name_prefix Restrict to names beginning with this prefix, or param: bool $network Whether to list network-scope secrets. |
| get_label() X-Ref |
| A short human-readable name for this provider, for Site Health. Describes the protection, not the vendor's marketing: "AWS KMS (alias/wp-secrets)" tells an operator something, "SuperSecure Pro" does not. Never key material, never a credential, never a value. return: string |
| get_protection_boundary() X-Ref |
| Where secrets this provider holds are actually protected. One of the BOUNDARY_* constants. This is what lets Site Health and a future admin screen tell an operator whether their credentials are protected by WordPress's own libsodium envelope or by something outside it, a question they currently have no way to answer, and the one hosts asked to be able to answer honestly. return: string |
| is_writable() X-Ref |
| Whether wp_set_secret() can succeed against this provider. False for a provider whose credentials are managed by host tooling or a control panel. Declared rather than discovered so a settings screen can disable its save control before an operator types a credential into a field that will only reject it. return: bool |
| Generated : Wed Oct 14 08:20:33 2026 | Cross-referenced by PHPXref |