2021-07-14 14:55:41 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Sakura\Models;
|
|
|
|
|
|
|
|
class OptionModel extends BaseModel
|
|
|
|
{
|
|
|
|
public static $namespace = 'sakura_options';
|
|
|
|
|
|
|
|
public static function the_key(string $key)
|
|
|
|
{
|
|
|
|
return self::$namespace . "_{$key}";
|
|
|
|
}
|
|
|
|
|
2021-07-14 16:54:49 +08:00
|
|
|
public static function create(string $key, $value)
|
2021-07-14 14:55:41 +08:00
|
|
|
{
|
|
|
|
return add_option(self::the_key($key), $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function get(string $key)
|
|
|
|
{
|
|
|
|
return get_option(self::the_key($key));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function update(string $key, $value)
|
|
|
|
{
|
|
|
|
return update_option(self::the_key($key), $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function delete(string $key)
|
|
|
|
{
|
|
|
|
return delete_option(self::the_key($key));
|
|
|
|
}
|
|
|
|
}
|