wp_back/wp-content/plugins/smart-slider-3/Nextend/SmartSlider3/Settings.php

41 lines
1.1 KiB
PHP
Raw Normal View History

2024-05-20 15:37:46 +03:00
<?php
namespace Nextend\SmartSlider3;
use Nextend\Framework\Model\StorageSectionManager;
class Settings {
static $settings = null;
private static $_type = "settings";
static function getAll() {
if (self::$settings === null) {
self::$settings = json_decode(StorageSectionManager::getStorage('smartslider')
->get(self::$_type), true);
if (self::$settings === null || !is_array(self::$settings)) self::$settings = array();
}
return self::$settings;
}
static function get($key, $default = null) {
if (self::$settings === null) self::getAll();
if (!array_key_exists($key, self::$settings)) return $default;
return self::$settings[$key];
}
static function set($key, $value) {
self::getAll();
self::$settings[$key] = $value;
self::store(self::$_type, json_encode(self::$settings));
}
static function store($key, $value) {
StorageSectionManager::getStorage('smartslider')
->set($key, '', $value);
}
}