Encoder
3 months ago
EncoderFactory
3 months ago
Repository
3 months ago
Table
3 months ago
Encoder.php
3 months ago
EncoderFactory.php
3 months ago
KeyValue.php
3 months ago
Option.php
3 months ago
OptionData.php
3 months ago
OptionDataFactory.php
3 months ago
OptionFactory.php
3 months ago
SiteOption.php
3 months ago
SiteOptionFactory.php
3 months ago
Table.php
3 months ago
Timestamp.php
3 months ago
Transaction.php
3 months ago
UserData.php
3 months ago
UserMeta.php
3 months ago
UserOption.php
3 months ago
Option.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace AC\Storage; |
| 6 | |
| 7 | class Option implements OptionData |
| 8 | { |
| 9 | |
| 10 | protected string $key; |
| 11 | |
| 12 | public function __construct(string $key) |
| 13 | { |
| 14 | $this->key = $key; |
| 15 | } |
| 16 | |
| 17 | public function get() |
| 18 | { |
| 19 | wp_cache_delete($this->key, 'options'); |
| 20 | |
| 21 | return get_option($this->key, false); |
| 22 | } |
| 23 | |
| 24 | public function save($value): void |
| 25 | { |
| 26 | update_option($this->key, $value, false); |
| 27 | } |
| 28 | |
| 29 | public function delete(): void |
| 30 | { |
| 31 | delete_option($this->key); |
| 32 | } |
| 33 | |
| 34 | } |