utilities
1 year ago
ehssl-config.php
1 year ago
ehssl-cronjob.php
1 year ago
ehssl-custom-post-types.php
1 year ago
ehssl-debug-logger.php
1 year ago
ehssl-email-handler.php
1 year ago
ehssl-init-time-tasks.php
1 year ago
ehssl-rules-helper.php
1 year ago
ehssl-ssl-certificate.php
1 year ago
index.php
1 year ago
ehssl-config.php
66 lines
| 1 | <?php |
| 2 | class EHSSL_Config |
| 3 | { |
| 4 | public $configs; |
| 5 | public $message_stack; |
| 6 | static $_this; |
| 7 | |
| 8 | public function __construct() |
| 9 | { |
| 10 | $this->message_stack = new stdClass(); |
| 11 | } |
| 12 | |
| 13 | public function load_config() |
| 14 | { |
| 15 | $this->configs = get_option('ehssl_configs'); |
| 16 | } |
| 17 | |
| 18 | public function get_value($key) |
| 19 | { |
| 20 | return isset($this->configs[$key]) ? $this->configs[$key] : ''; |
| 21 | } |
| 22 | |
| 23 | public function set_value($key, $value) |
| 24 | { |
| 25 | $this->configs[$key] = $value; |
| 26 | } |
| 27 | |
| 28 | public function add_value($key, $value) |
| 29 | { |
| 30 | if (array_key_exists($key, $this->configs)) { |
| 31 | //Don't update the value for this key |
| 32 | } else { //It is safe to update the value for this key |
| 33 | $this->configs[$key] = $value; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | public function save_config() |
| 38 | { |
| 39 | update_option('ehssl_configs', $this->configs); |
| 40 | } |
| 41 | |
| 42 | public function get_stacked_message($key) |
| 43 | { |
| 44 | if (isset($this->message_stack->{$key})) { |
| 45 | return $this->message_stack->{$key}; |
| 46 | } |
| 47 | |
| 48 | return ""; |
| 49 | } |
| 50 | |
| 51 | public function set_stacked_message($key, $value) |
| 52 | { |
| 53 | $this->message_stack->{$key} = $value; |
| 54 | } |
| 55 | |
| 56 | public static function get_instance() |
| 57 | { |
| 58 | if (empty(self::$_this)) { |
| 59 | self::$_this = new EHSSL_Config(); |
| 60 | self::$_this->load_config(); |
| 61 | return self::$_this; |
| 62 | } |
| 63 | return self::$_this; |
| 64 | } |
| 65 | } |
| 66 |