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/LicenseAPI.php +20 -20 4.4.1 → 4.4.5 View file →
@@ -1,9 +1,9 @@
1 1 <?php
2 2
3 3 namespace YayMailScoped\YayCommerce\AdminShell\License;
4 4
5 -\defined('ABSPATH') || exit;
5 +defined('ABSPATH') || exit;
6 6 /**
7 7 * EDD HTTP client — all calls go through wp_remote_get.
8 8 *
9 9 * Ported from YayMail Pro LicenseAPI.php — YAYCOMMERCE_SELLER_SITE_URL constant
@@ -10,17 +10,17 @@
10 10 * replaced with $store_url parameter sourced from LicenseConfigAdapter::get_store_url().
11 11 */
12 12 class LicenseAPI
13 13 {
14 - public static function activate_license(string $store_url, int $item_id, string $license_key) : array
14 + public static function activate_license(string $store_url, int $item_id, string $license_key): array
15 15 {
16 16 try {
17 - $url = $store_url . '?edd_action=activate_license&item_id=' . $item_id . '&license=' . \rawurlencode($license_key) . '&url=' . \home_url();
18 - $raw = \wp_remote_get($url);
19 - if (\is_wp_error($raw)) {
17 + $url = $store_url . '?edd_action=activate_license&item_id=' . $item_id . '&license=' . rawurlencode($license_key) . '&url=' . home_url();
18 + $raw = wp_remote_get($url);
19 + if (is_wp_error($raw)) {
20 20 throw new \Error('WP HTTP error', 1);
21 21 }
22 - $response = \json_decode(\wp_remote_retrieve_body($raw));
22 + $response = json_decode(wp_remote_retrieve_body($raw));
23 23 if (isset($response->success) && $response->success) {
24 24 return ['success' => \true, 'license' => $response->license ?? 'valid', 'expires' => $response->expires ?? null, 'license_limit' => $response->license_limit ?? 0, 'payment_id' => $response->payment_id ?? '', 'customer_name' => $response->customer_name ?? ''];
25 25 }
26 26 return ['success' => \false, 'message' => $response->error ?? 'unknown_error'];
@@ -27,31 +27,31 @@
27 27 } catch (\Error $error) {
28 28 return ['success' => \false, 'message' => 'server_error', 'is_server_error' => \true];
29 29 }
30 30 }
31 - public static function deactivate_license(string $store_url, int $item_id, string $license_key) : array
31 + public static function deactivate_license(string $store_url, int $item_id, string $license_key): array
32 32 {
33 33 try {
34 - $url = $store_url . '?edd_action=deactivate_license&item_id=' . $item_id . '&license=' . \rawurlencode($license_key) . '&url=' . \home_url();
35 - $raw = \wp_remote_get($url);
36 - if (\is_wp_error($raw)) {
34 + $url = $store_url . '?edd_action=deactivate_license&item_id=' . $item_id . '&license=' . rawurlencode($license_key) . '&url=' . home_url();
35 + $raw = wp_remote_get($url);
36 + if (is_wp_error($raw)) {
37 37 return ['success' => \false, 'is_server_error' => \true];
38 38 }
39 - $response = \json_decode(\wp_remote_retrieve_body($raw));
39 + $response = json_decode(wp_remote_retrieve_body($raw));
40 40 return ['success' => isset($response->success) && $response->success, 'license' => $response->license ?? 'deactivated'];
41 41 } catch (\Error $error) {
42 42 return ['success' => \false, 'is_server_error' => \true];
43 43 }
44 44 }
45 - public static function check_license(string $store_url, int $item_id, $license_key) : array
45 + public static function check_license(string $store_url, int $item_id, $license_key): array
46 46 {
47 47 try {
48 - $url = $store_url . '?edd_action=check_license&item_id=' . $item_id . '&license=' . \rawurlencode((string) $license_key) . '&url=' . \home_url();
49 - $raw = \wp_remote_get($url);
50 - if (\is_wp_error($raw)) {
48 + $url = $store_url . '?edd_action=check_license&item_id=' . $item_id . '&license=' . rawurlencode((string) $license_key) . '&url=' . home_url();
49 + $raw = wp_remote_get($url);
50 + if (is_wp_error($raw)) {
51 51 throw new \Error('WP HTTP error', 1);
52 52 }
53 - $response = \json_decode(\wp_remote_retrieve_body($raw));
53 + $response = json_decode(wp_remote_retrieve_body($raw));
54 54 if (isset($response->success) && \true === $response->success) {
55 55 if ('valid' === $response->license || 'expired' === $response->license) {
56 56 return ['success' => \true, 'license' => $response->license, 'expires' => $response->expires ?? null, 'license_limit' => $response->license_limit ?? 0, 'payment_id' => $response->payment_id ?? '', 'customer_name' => $response->customer_name ?? ''];
57 57 }
@@ -65,12 +65,12 @@
65 65 {
66 66 try {
67 67 $url = $store_url . '?edd_action=get_version&item_id=' . $item_id;
68 68 if (!empty($license_key)) {
69 - $url .= '&license=' . \rawurlencode($license_key);
69 + $url .= '&license=' . rawurlencode($license_key);
70 70 }
71 - $raw = \wp_remote_get($url);
72 - $response = \json_decode(\wp_remote_retrieve_body($raw));
71 + $raw = wp_remote_get($url);
72 + $response = json_decode(wp_remote_retrieve_body($raw));
73 73 if (isset($response->new_version)) {
74 74 return (array) $response;
75 75 }
76 76 return \false;
@@ -77,9 +77,9 @@
77 77 } catch (\Error $error) {
78 78 return \false;
79 79 }
80 80 }
81 - public static function get_error_message(string $message) : string
81 + public static function get_error_message(string $message): string
82 82 {
83 83 $messages = ['missing' => "License doesn't exist", 'license_not_activable' => "Attempting to activate a bundle's parent license", 'disabled' => 'License key revoked', 'no_activations_left' => 'No activations left', 'expired' => 'License has expired', 'key_mismatch' => 'License is not valid for this product', 'item_name_mismatch' => 'License is not valid for this product', 'server_error' => 'Your license could not be activated because of server error.'];
84 84 return $messages[$message] ?? 'Your license could not be activated.';
85 85 }