PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.6.9
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.6.9
4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / libs / license / helper.php
shopengine / libs / license Last commit date
helper.php 4 years ago license-route.php 3 years ago
helper.php
122 lines
1 <?php
2
3 namespace ShopEngine\Libs\License;
4
5 use ShopEngine\Traits\Singleton;
6
7 defined('ABSPATH') || exit;
8
9 /**
10 * Allows plugins to use their own update API.
11 *
12 * @version 1.1.4
13 */
14 class Helper {
15
16 use Singleton;
17
18 public function activate($key) {
19
20 $data = [
21 'key' => $key,
22 'id' => \ShopEngine_Pro::product_id(),
23 ];
24
25 $response = $this->check_license($data);
26
27 if(isset($response->validate) && $response->validate == 1) {
28
29 update_option('__shopengine_oppai__', $response->oppai);
30 update_option('__shopengine_license_key__', $response->key);
31
32 $response->is_activated = true;
33
34 return $response;
35 }
36
37 return $response;
38 }
39
40 public function deactivate() {
41
42 delete_option('__shopengine_oppai__');
43 update_option('__shopengine_license_key__', '');
44
45 return true;
46 }
47
48
49 public function check_license($data = []) {
50
51 if(strlen($data['key']) < 28) {
52 $data['error'] = 'yes';
53 $data['message'] = 'Invalid license key';
54
55 return (object)$data;
56 }
57
58 $data['oppai'] = get_option('__shopengine_oppai__');
59 $data['action'] = 'activate';
60 $data['marketplace'] = \ShopEngine_Pro::store_name();
61 $data['author_name'] = \ShopEngine_Pro::author_name();
62 $data['v'] = \ShopEngine_Pro::version();
63
64 $url = \ShopEngine_Pro::api_url() . 'license?' . http_build_query($data);
65
66 $args = [
67 'timeout' => 60,
68 'redirection' => 3,
69 'httpversion' => '1.0',
70 'blocking' => true,
71 'sslverify' => true,
72 ];
73
74
75 $res = wp_remote_get($url, $args);
76
77 return (object)json_decode((string)$res['body']);
78 }
79
80 public function status() {
81
82 $cached = wp_cache_get('shopengine_pro__license_status');
83
84 if(false !== $cached) {
85 return $cached;
86 }
87
88 $oppai = get_option('__shopengine_oppai__', '');
89 $key = get_option('__shopengine_license_key__', '');
90 $status = 'invalid';
91
92 if($oppai != '' && $key != '') {
93 $status = 'valid';
94 }
95
96 wp_cache_set('shopengine_pro__license_status', $status);
97
98 return $status;
99 }
100
101 public function get_license() {
102
103 $cached = wp_cache_get('shopengine_pro__license_key');
104
105 if(false !== $cached) {
106 return $cached;
107 }
108
109 $oppai = get_option('__shopengine_oppai__');
110 $key = get_option('__shopengine_license_key__');
111
112 $license = [
113 'checksum' => $oppai,
114 'key' => $key,
115 ];
116
117 wp_cache_set('shopengine_pro__license_key', $license);
118
119 return $license;
120 }
121 }
122