1 | <?php |
||
16 | class Options { |
||
17 | |||
18 | /** |
||
19 | * Plugin options key. |
||
20 | */ |
||
21 | const KEY = 'wp_cas_server'; |
||
22 | |||
23 | /** |
||
24 | * Default plugin options. |
||
25 | * @var array |
||
26 | */ |
||
27 | private static $defaults = array( |
||
28 | /** |
||
29 | * CAS server endpoint path fragment (e.g. `<scheme>://<host>/wp-cas/login`). |
||
30 | */ |
||
31 | 'endpoint_slug' => Plugin::ENDPOINT_SLUG, |
||
32 | |||
33 | /** |
||
34 | * Service ticket expiration, in seconds [0..300]. |
||
35 | */ |
||
36 | 'expiration' => 30, |
||
37 | |||
38 | /** |
||
39 | * `allow_ticket_reuse` exists as a workaround for potential issues with |
||
40 | * WordPress's Transients API. |
||
41 | */ |
||
42 | 'allow_ticket_reuse' => false, |
||
43 | |||
44 | /** |
||
45 | * @todo Allow requests from these service URIs only. |
||
46 | */ |
||
47 | 'allowed_services' => array(), |
||
48 | |||
49 | /** |
||
50 | * User attributes to return on a successful `/serviceValidate` response. |
||
51 | */ |
||
52 | 'attributes' => array(), |
||
53 | ); |
||
54 | |||
55 | /** |
||
56 | * Gets all options. |
||
57 | * |
||
58 | * @return array All plugin options. |
||
59 | */ |
||
60 | public static function getAll() { |
||
63 | |||
64 | /** |
||
65 | * Get plugin option by key. |
||
66 | * |
||
67 | * @param string $key Plugin option key to return. |
||
68 | * @param mixed $default Option value to return if `$key` is not found. |
||
69 | * |
||
70 | * @return mixed Plugin option value. |
||
71 | * |
||
72 | * @uses \get_option() |
||
73 | */ |
||
74 | public static function get( $key = '', $default = null ) { |
||
78 | |||
79 | /** |
||
80 | * Set plugin option by key. |
||
81 | * |
||
82 | * @param string $key Plugin option key to set. |
||
83 | * @param mixed $value Plugin option value to set. |
||
84 | * |
||
85 | * @uses \get_option() |
||
86 | * @uses \update_option() |
||
87 | */ |
||
88 | public static function set( $key, $value ) { |
||
103 | |||
104 | /** |
||
105 | * Set the default plugin options in the database. |
||
106 | * |
||
107 | * @uses \get_option() |
||
108 | * @uses \update_option() |
||
109 | */ |
||
110 | public static function setDefaults() { |
||
114 | |||
115 | } |
||
116 |