PluginProbe
Boxzilla – WordPress Popup Builder / 3.1.4
Boxzilla – WordPress Popup Builder v3.1.4
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
← All changes | src/licensing/class-license.php +85 -95 3.4.63.1.4 View file →
@@ -13,112 +13,102 @@
13 13 * @property string $expires_at
14 14 *
15 15 * @package Boxzilla\Licensing
16 16 */
17 -class License
18 -{
19 - /**
20 - * @var string The name of the option that holds the License data
21 - */
22 - protected $option_key = '';
17 +class License {
23 18
24 - /**
25 - * @var bool Loaded?
26 - */
27 - protected $loaded = false;
19 + /**
20 + * @var string The name of the option that holds the License data
21 + */
22 + protected $option_key = '';
28 23
29 - /**
30 - * @var bool Any changes?
31 - */
32 - protected $dirty = false;
24 + /**
25 + * @var bool Loaded?
26 + */
27 + protected $loaded = false;
33 28
34 - /**
35 - * @var array
36 - */
37 - protected $data;
29 + /**
30 + * @var bool Any changes?
31 + */
32 + protected $dirty = false;
38 33
39 - /**
40 - * @param string $option_key
41 - */
42 - public function __construct($option_key)
43 - {
44 - $this->option_key = $option_key;
45 - }
34 + /**
35 + * @var array
36 + */
37 + protected $data;
46 38
47 - /**
48 - * @param string $name
49 - * @param mixed $value
50 - */
51 - public function __set($name, $value)
52 - {
53 - $this->load();
54 - $this->data[ $name ] = $value;
55 - $this->dirty = true;
56 - }
39 + /**
40 + * @param string $option_key
41 + */
42 + public function __construct( $option_key ) {
43 + $this->option_key = $option_key;
44 + }
57 45
58 - /**
59 - * @param string $name
60 - *
61 - * @return mixed
62 - */
63 - public function __get($name)
64 - {
65 - $this->load();
66 - return $this->data[ $name ];
67 - }
46 + /**
47 + * @param string $name
48 + * @param mixed $value
49 + */
50 + public function __set($name, $value) {
51 + $this->load();
52 + $this->data[ $name ] = $value;
53 + $this->dirty = true;
54 + }
68 55
69 - /**
70 - * @param $name
71 - *
72 - * @return bool
73 - */
74 - public function __isset($name)
75 - {
76 - $this->load();
77 - return isset($this->data[ $name ]);
78 - }
56 + /**
57 + * @param string $name
58 + *
59 + * @return mixed
60 + */
61 + public function __get($name) {
62 + $this->load();
63 + return $this->data[ $name ];
64 + }
79 65
80 - /**
81 - * Load the license data from the database
82 - */
83 - protected function load()
84 - {
85 - if ($this->loaded) {
86 - return;
87 - }
66 + /**
67 + * @param $name
68 + *
69 + * @return bool
70 + */
71 + public function __isset( $name ) {
72 + $this->load();
73 + return isset( $this->data[ $name ] );
74 + }
88 75
89 - $defaults = [
90 - 'key' => '',
91 - 'activation_key' => '',
92 - 'activated' => false,
93 - 'expires_at' => '',
94 - ];
76 + /**
77 + * Load the license data from the database
78 + */
79 + protected function load() {
80 + static $defaults = array(
81 + 'key' => '',
82 + 'activation_key' => '',
83 + 'activated' => false,
84 + 'expires_at' => ''
85 + );
95 86
96 - $data = (array) get_option($this->option_key, []);
97 - $this->data = array_replace($defaults, $data);
98 - $this->loaded = true;
99 - }
87 + if( ! $this->loaded ) {
88 + $data = (array) get_option( $this->option_key, array() );
89 + $this->data = array_replace( $defaults, $data );
90 + $this->loaded = true;
91 + }
92 + }
100 93
101 - /**
102 - * Reload the license data from DB
103 - */
104 - public function reload()
105 - {
106 - $this->loaded = false;
107 - $this->load();
108 - }
94 + /**
95 + * Reload the license data from DB
96 + */
97 + public function reload() {
98 + $this->loaded = false;
99 + $this->load();
100 + }
109 101
110 - /**
111 - * Save the license in the database
112 - *
113 - * @return License
114 - */
115 - public function save()
116 - {
117 - if (! $this->dirty) {
118 - return;
119 - }
102 + /**
103 + * Save the license in the database
104 + *
105 + * @return License
106 + */
107 + public function save() {
108 + if( $this->dirty ) {
109 + update_option( $this->option_key, $this->data );
110 + $this->dirty = false;
111 + }
112 + }
120 113
121 - update_option($this->option_key, $this->data, true);
122 - $this->dirty = false;
123 - }
124 -}
114 +}