PluginProbe ʕ •ᴥ•ʔ
Backup Migration / 2.1.7
Backup Migration v2.1.7
2.1.7 2.1.6 2.1.5.2 trunk 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.6.1 1.4.7 1.4.8 1.4.9 1.4.9.1 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.5.1
backup-backup / analyst / src / Storage / DatabaseStorage.php
backup-backup / analyst / src / Storage Last commit date
DatabaseStorage.php 2 weeks ago FileStorage.php 2 weeks ago
DatabaseStorage.php
47 lines
1 <?php
2
3 namespace Analyst\Storage;
4
5 use Analyst\Contracts\StorageContract;
6
7 if ( ! defined( 'ABSPATH' ) ) exit;
8
9 /**
10 * Class DatabaseStorage
11 *
12 * Persists key-value data using the WordPress wp_options table.
13 */
14 class DatabaseStorage implements StorageContract
15 {
16 /**
17 * @param string $key The wp_options option name.
18 * @param mixed $default
19 * @return mixed
20 */
21 public function get($key, $default = null)
22 {
23 $value = get_option($key, null);
24
25 return $value !== null ? $value : $default;
26 }
27
28 /**
29 * @param string $key The wp_options option name.
30 * @param mixed $value
31 * @return bool
32 */
33 public function put($key, $value)
34 {
35 return update_option($key, $value);
36 }
37
38 /**
39 * @param string $key The wp_options option name.
40 * @return bool
41 */
42 public function delete($key)
43 {
44 return delete_option($key);
45 }
46 }
47