option_key = $option_key; } /** * @param string $name * @param mixed $value */ public function __set($name, $value) { $this->load(); $this->data[ $name ] = $value; $this->dirty = true; } /** * @param string $name * * @return mixed */ public function __get($name) { $this->load(); return $this->data[ $name ]; } /** * @param $name * * @return bool */ public function __isset($name) { $this->load(); return isset($this->data[ $name ]); } /** * Load the license data from the database */ protected function load() { if ($this->loaded) { return; } $defaults = [ 'key' => '', 'activation_key' => '', 'activated' => false, 'expires_at' => '', ]; $data = (array) get_option($this->option_key, []); $this->data = array_replace($defaults, $data); $this->loaded = true; } /** * Reload the license data from DB */ public function reload() { $this->loaded = false; $this->load(); } /** * Save the license in the database */ public function save() { if (! $this->dirty) { return; } update_option($this->option_key, $this->data, true); $this->dirty = false; } }