PluginProbe
Boxzilla – WordPress Popup Builder / 3.2.13
Boxzilla – WordPress Popup Builder v3.2.13
3.4.11 3.4.10 3.4.9 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 trunk 3.0 3.0.1 3.0.2 3.0.3 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 All 72 releases
boxzilla / src / licensing / class-license.php

class-license.php in Boxzilla – WordPress Popup Builder 3.2.13, at src/licensing/class-license.php

126 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Boxzilla\Licensing;
4
5 /**
6 * Class License
7 *
8 *
9 * @property string $key
10 * @property string $site
11 * @property string $activation_key
12 * @property boolean $activated
13 * @property string $expires_at
14 *
15 * @package Boxzilla\Licensing
16 */
17 class License
18 {
19
20 /**
21 * @var string The name of the option that holds the License data
22 */
23 protected $option_key = '';
24
25 /**
26 * @var bool Loaded?
27 */
28 protected $loaded = false;
29
30 /**
31 * @var bool Any changes?
32 */
33 protected $dirty = false;
34
35 /**
36 * @var array
37 */
38 protected $data;
39
40 /**
41 * @param string $option_key
42 */
43 public function __construct($option_key)
44 {
45 $this->option_key = $option_key;
46 }
47
48 /**
49 * @param string $name
50 * @param mixed $value
51 */
52 public function __set($name, $value)
53 {
54 $this->load();
55 $this->data[ $name ] = $value;
56 $this->dirty = true;
57 }
58
59 /**
60 * @param string $name
61 *
62 * @return mixed
63 */
64 public function __get($name)
65 {
66 $this->load();
67 return $this->data[ $name ];
68 }
69
70 /**
71 * @param $name
72 *
73 * @return bool
74 */
75 public function __isset($name)
76 {
77 $this->load();
78 return isset($this->data[ $name ]);
79 }
80
81 /**
82 * Load the license data from the database
83 */
84 protected function load()
85 {
86 if ($this->loaded) {
87 return;
88 }
89
90 $defaults = array(
91 'key' => '',
92 'activation_key' => '',
93 'activated' => false,
94 'expires_at' => ''
95 );
96
97 $data = (array) get_option($this->option_key, array());
98 $this->data = array_replace($defaults, $data);
99 $this->loaded = true;
100 }
101
102 /**
103 * Reload the license data from DB
104 */
105 public function reload()
106 {
107 $this->loaded = false;
108 $this->load();
109 }
110
111 /**
112 * Save the license in the database
113 *
114 * @return License
115 */
116 public function save()
117 {
118 if (! $this->dirty) {
119 return;
120 }
121
122 update_option($this->option_key, $this->data);
123 $this->dirty = false;
124 }
125 }
126