PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.6
YayMail – WooCommerce Email Customizer v4.4.6
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 +17 -18 4.4.2 → 4.4.6 View file →
@@ -2,15 +2,14 @@
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.
11 11 * Ported from YayMail Pro License.php — YAYMAIL_* constants replaced with adapter.
12 - * @internal
13 12 */
14 13 class License
15 14 {
16 15 protected LicenseConfigAdapter $adapter;
@@ -23,15 +22,15 @@
23 22 $this->adapter = $adapter;
24 23 $this->license_key = $this->get_license_key();
25 24 $this->license_info = $this->get_license_info();
26 25 }
27 - public function update_license_info(array $license_info) : void
26 + public function update_license_info(array $license_info): void
28 27 {
29 28 unset($license_info['success']);
30 29 update_option($this->adapter->get_plugin_slug() . '_license_info', $license_info, \false);
31 30 $this->license_info = $license_info;
32 31 }
33 - public function update_license_key(string $license_key) : void
32 + public function update_license_key(string $license_key): void
34 33 {
35 34 update_option($this->adapter->get_plugin_slug() . '_license_key', $license_key);
36 35 $this->license_key = $license_key;
37 36 }
@@ -38,26 +37,26 @@
38 37 public function get_license_key()
39 38 {
40 39 return get_option($this->adapter->get_plugin_slug() . '_license_key');
41 40 }
42 - public function get_license_info() : array
41 + public function get_license_info(): array
43 42 {
44 43 $default = ['expires' => 'Not updated'];
45 44 $info = get_option($this->adapter->get_plugin_slug() . '_license_info');
46 - $info = \is_string($info) ? \json_decode($info, \true) : $info;
45 + $info = is_string($info) ? json_decode($info, \true) : $info;
47 46 return $info ?: $default;
48 47 }
49 - public function remove_license_key() : void
48 + public function remove_license_key(): void
50 49 {
51 50 delete_option($this->adapter->get_plugin_slug() . '_license_key');
52 51 $this->license_key = null;
53 52 }
54 - public function remove_license_info() : void
53 + public function remove_license_info(): void
55 54 {
56 55 delete_option($this->adapter->get_plugin_slug() . '_license_info');
57 56 $this->license_info = ['expires' => 'Not updated'];
58 57 }
59 - public function activate(string $license_key) : array
58 + public function activate(string $license_key): array
60 59 {
61 60 $activate_response = LicenseAPI::activate_license($this->adapter->get_store_url(), $this->adapter->get_item_id(), $license_key);
62 61 if ($activate_response['success']) {
63 62 $this->update_license_key($license_key);
@@ -65,9 +64,9 @@
65 64 }
66 65 LicenseHandler::remove_site_plugin_check($this->adapter);
67 66 return $activate_response;
68 67 }
69 - public function update() : array
68 + public function update(): array
70 69 {
71 70 $license_key = $this->get_license_key();
72 71 $response = LicenseAPI::check_license($this->adapter->get_store_url(), $this->adapter->get_item_id(), $license_key);
73 72 if ($response['success']) {
@@ -77,9 +76,9 @@
77 76 }
78 77 LicenseHandler::remove_site_plugin_check($this->adapter);
79 78 return $response;
80 79 }
81 - public function remove() : void
80 + public function remove(): void
82 81 {
83 82 // Deactivate on EDD side to free the activation slot
84 83 $license_key = $this->get_license_key();
85 84 if (!empty($license_key)) {
@@ -88,27 +87,27 @@
88 87 LicenseHandler::remove_site_plugin_check($this->adapter);
89 88 $this->remove_license_key();
90 89 $this->remove_license_info();
91 90 }
92 - public function is_active() : bool
91 + public function is_active(): bool
93 92 {
94 93 return (bool) $this->license_key;
95 94 }
96 - public function is_expired() : bool
95 + public function is_expired(): bool
97 96 {
98 97 if ($this->is_active()) {
99 98 $license_info = $this->get_license_info();
100 99 $expires = $license_info['expires'] ?? null;
101 100 if ($expires && 'lifetime' !== $expires && 'Not updated' !== $expires) {
102 - return \strtotime($expires) < \time();
101 + return strtotime($expires) < time();
103 102 }
104 103 }
105 104 return \false;
106 105 }
107 - 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
108 107 {
109 108 $key = (string) $this->license_key;
110 - $len = \strlen($key);
109 + $len = strlen($key);
111 110 if ($len <= $hidden) {
112 111 return $key;
113 112 }
114 113 for ($i = $len - $hidden; $i < $len; $i++) {
@@ -122,13 +121,13 @@
122 121 }
123 122 }
124 123 return $formatted;
125 124 }
126 - public function get_renewal_url() : string
125 + public function get_renewal_url(): string
127 126 {
128 127 return $this->adapter->get_store_url() . 'checkout/?edd_license_key=' . $this->license_key . '&download_id=' . $this->adapter->get_item_id();
129 128 }
130 - public function get_upgrade_url() : string
129 + public function get_upgrade_url(): string
131 130 {
132 131 $payment_id = $this->license_info['payment_id'] ?? '';
133 132 return $this->adapter->get_store_url() . 'checkout/purchase-history/?view=upgrades&action=manage_licenses&payment_id=' . $payment_id;
134 133 }