Repository navigation
Expand file tree
/
Copy pathclass-wp-secrets-store.php
More file actions
77 lines (72 loc) · 2.57 KB
/
Copy pathclass-wp-secrets-store.php
File metadata and controls
77 lines (72 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
* Secrets API: WP_Secrets_Store class
*
* @package WordPress
* @subpackage Secrets
* @since 7.2.0
*/
/**
* Where a secret's encrypted record lives.
*
* An implementation is never handed a plaintext secret, only the record array
* produced by WP_Secrets_Cipher and assembled by the functions in secrets.php, and
* cannot turn encryption off; there is no method here that accepts or returns
* anything but ciphertext-bearing structures.
*
* A platform store that is read-only from the application, with credentials managed
* by a separate CLI or dashboard, returns WP_Error from set() rather than pretending
* the write succeeded. Providers declare writability up front through
* WP_Secrets_Provider::is_writable().
*
* Implementations extend this class. It is abstract rather than an interface so
* that a later release can add a method with a default implementation, and every
* existing subclass keeps working.
*
* @since 7.2.0
*/
abstract class WP_Secrets_Store {
/**
* Reads a secret's stored record.
*
* @since 7.2.0
*
* @param string $name The secret's namespaced name.
* @param bool $network Whether this is a network-scope secret.
* @return array<mixed>|null|WP_Error The record array if it exists. Null if it does not.
* WP_Error if it could not be determined which.
*/
abstract public function get( string $name, bool $network = false );
/**
* Writes a secret's record.
*
* @since 7.2.0
*
* @param string $name The secret's namespaced name.
* @param array<mixed> $record The record to store.
* @param bool $network Whether this is a network-scope secret.
* @return bool|WP_Error True on success. WP_Error on failure, including when the
* store does not accept writes.
*/
abstract public function set( string $name, array $record, bool $network = false );
/**
* Deletes a secret's record.
*
* @since 7.2.0
*
* @param string $name The secret's namespaced name.
* @param bool $network Whether this is a network-scope secret.
* @return bool|WP_Error True on success (including if it did not exist).
* WP_Error on failure.
*/
abstract public function delete( string $name, bool $network = false );
/**
* Lists the names of every secret in this store, for this scope. Never a value.
*
* @since 7.2.0
*
* @param bool $network Whether to list network-scope secrets.
* @return string[]|WP_Error Array of secret names on success. WP_Error on failure.
*/
abstract public function list_names( bool $network = false );
}