PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.5
YayMail – WooCommerce Email Customizer v4.4.5
4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 All 57 releases
← All changes | vendor-prefixed/src/License/License.php +23 -23 4.4.1 → 4.4.5 View file →
@@ -2,9 +2,9 @@
2 2
3 3 namespace YayMailScoped\YayCommerce\AdminShell\License;
4 4
5 5 use YayMailScoped\YayCommerce\AdminShell\License\Contracts\LicenseConfigAdapter;
6 -\defined('ABSPATH') || exit;
6 +defined('ABSPATH') || exit;
7 7 /**
8 8 * License state model.
9 9 *
10 10 * Option keys are derived from the adapter slug — NEVER hardcoded.
@@ -22,41 +22,41 @@
22 22 $this->adapter = $adapter;
23 23 $this->license_key = $this->get_license_key();
24 24 $this->license_info = $this->get_license_info();
25 25 }
26 - public function update_license_info(array $license_info) : void
26 + public function update_license_info(array $license_info): void
27 27 {
28 28 unset($license_info['success']);
29 - \update_option($this->adapter->get_plugin_slug() . '_license_info', $license_info, \false);
29 + update_option($this->adapter->get_plugin_slug() . '_license_info', $license_info, \false);
30 30 $this->license_info = $license_info;
31 31 }
32 - public function update_license_key(string $license_key) : void
32 + public function update_license_key(string $license_key): void
33 33 {
34 - \update_option($this->adapter->get_plugin_slug() . '_license_key', $license_key);
34 + update_option($this->adapter->get_plugin_slug() . '_license_key', $license_key);
35 35 $this->license_key = $license_key;
36 36 }
37 37 public function get_license_key()
38 38 {
39 - return \get_option($this->adapter->get_plugin_slug() . '_license_key');
39 + return get_option($this->adapter->get_plugin_slug() . '_license_key');
40 40 }
41 - public function get_license_info() : array
41 + public function get_license_info(): array
42 42 {
43 43 $default = ['expires' => 'Not updated'];
44 - $info = \get_option($this->adapter->get_plugin_slug() . '_license_info');
45 - $info = \is_string($info) ? \json_decode($info, \true) : $info;
44 + $info = get_option($this->adapter->get_plugin_slug() . '_license_info');
45 + $info = is_string($info) ? json_decode($info, \true) : $info;
46 46 return $info ?: $default;
47 47 }
48 - public function remove_license_key() : void
48 + public function remove_license_key(): void
49 49 {
50 - \delete_option($this->adapter->get_plugin_slug() . '_license_key');
50 + delete_option($this->adapter->get_plugin_slug() . '_license_key');
51 51 $this->license_key = null;
52 52 }
53 - public function remove_license_info() : void
53 + public function remove_license_info(): void
54 54 {
55 - \delete_option($this->adapter->get_plugin_slug() . '_license_info');
55 + delete_option($this->adapter->get_plugin_slug() . '_license_info');
56 56 $this->license_info = ['expires' => 'Not updated'];
57 57 }
58 - public function activate(string $license_key) : array
58 + public function activate(string $license_key): array
59 59 {
60 60 $activate_response = LicenseAPI::activate_license($this->adapter->get_store_url(), $this->adapter->get_item_id(), $license_key);
61 61 if ($activate_response['success']) {
62 62 $this->update_license_key($license_key);
@@ -64,9 +64,9 @@
64 64 }
65 65 LicenseHandler::remove_site_plugin_check($this->adapter);
66 66 return $activate_response;
67 67 }
68 - public function update() : array
68 + public function update(): array
69 69 {
70 70 $license_key = $this->get_license_key();
71 71 $response = LicenseAPI::check_license($this->adapter->get_store_url(), $this->adapter->get_item_id(), $license_key);
72 72 if ($response['success']) {
@@ -76,9 +76,9 @@
76 76 }
77 77 LicenseHandler::remove_site_plugin_check($this->adapter);
78 78 return $response;
79 79 }
80 - public function remove() : void
80 + public function remove(): void
81 81 {
82 82 // Deactivate on EDD side to free the activation slot
83 83 $license_key = $this->get_license_key();
84 84 if (!empty($license_key)) {
@@ -87,27 +87,27 @@
87 87 LicenseHandler::remove_site_plugin_check($this->adapter);
88 88 $this->remove_license_key();
89 89 $this->remove_license_info();
90 90 }
91 - public function is_active() : bool
91 + public function is_active(): bool
92 92 {
93 93 return (bool) $this->license_key;
94 94 }
95 - public function is_expired() : bool
95 + public function is_expired(): bool
96 96 {
97 97 if ($this->is_active()) {
98 98 $license_info = $this->get_license_info();
99 99 $expires = $license_info['expires'] ?? null;
100 100 if ($expires && 'lifetime' !== $expires && 'Not updated' !== $expires) {
101 - return \strtotime($expires) < \time();
101 + return strtotime($expires) < time();
102 102 }
103 103 }
104 104 return \false;
105 105 }
106 - public function format_license_key(int $group = 8, string $separator = '-', int $hidden = 20) : string
106 + public function format_license_key(int $group = 8, string $separator = '-', int $hidden = 20): string
107 107 {
108 108 $key = (string) $this->license_key;
109 - $len = \strlen($key);
109 + $len = strlen($key);
110 110 if ($len <= $hidden) {
111 111 return $key;
112 112 }
113 113 for ($i = $len - $hidden; $i < $len; $i++) {
@@ -121,13 +121,13 @@
121 121 }
122 122 }
123 123 return $formatted;
124 124 }
125 - public function get_renewal_url() : string
125 + public function get_renewal_url(): string
126 126 {
127 127 return $this->adapter->get_store_url() . 'checkout/?edd_license_key=' . $this->license_key . '&download_id=' . $this->adapter->get_item_id();
128 128 }
129 - public function get_upgrade_url() : string
129 + public function get_upgrade_url(): string
130 130 {
131 131 $payment_id = $this->license_info['payment_id'] ?? '';
132 132 return $this->adapter->get_store_url() . 'checkout/purchase-history/?view=upgrades&action=manage_licenses&payment_id=' . $payment_id;
133 133 }