| 1 |
<?php |
| 2 |
|
| 3 |
namespace Kibo\PhastPlugins\PhastPress; |
| 4 |
|
| 5 |
use Kibo\PhastPlugins\SDK\Configuration\KeyValueStore; |
| 6 |
|
| 7 |
class KeyValueStoreImplementation implements KeyValueStore { |
| 8 |
|
| 9 |
public function get($key) { |
| 10 |
if (($value = get_option($this->prefixKey($key))) !== false) { |
| 11 |
return $value; |
| 12 |
} |
| 13 |
if (($value = get_option($this->prefixLegacyKey($key))) !== false) { |
| 14 |
return json_encode($value); |
| 15 |
} |
| 16 |
} |
| 17 |
|
| 18 |
public function set($key, $value) { |
| 19 |
update_option($this->prefixKey($key), $value); |
| 20 |
delete_option($this->prefixLegacyKey($key)); |
| 21 |
} |
| 22 |
|
| 23 |
private function prefixKey($key) { |
| 24 |
return 'phastpress2-' . $key; |
| 25 |
} |
| 26 |
|
| 27 |
private function prefixLegacyKey($key) { |
| 28 |
return 'phastpress-' . $key; |
| 29 |
} |
| 30 |
|
| 31 |
} |
| 32 |
|