Skip to content

Commit cf2f962

Browse files
committed
1.3 release
Added support for purchase time and license expiration time. Plus split to two fields on 'license_type' to 'license' and 'license_type'.
1 parent 6a5bfbd commit cf2f962

File tree

5 files changed

+51
-29
lines changed

5 files changed

+51
-29
lines changed

Libraries/EnvatoEdgeAPI.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,22 @@ public function normalizeLicense(array $paramPurchase, $paramPurchaseCode)
148148
'envato_item_id' => $paramPurchase['item_id'],
149149
'envato_item_name' => (!empty($paramPurchase['item_name']) ? $paramPurchase['item_name'] : ''),
150150
// The 'misspell' of 'licence' instead of 'license' here is left by Envato and applies only for Edge API
151-
'license_type' => (!empty($paramPurchase['licence']) ? $paramPurchase['licence'] : ''),
151+
'license' => (!empty($paramPurchase['licence']) ? $paramPurchase['licence'] : ''),
152152
'license_sold' => (!empty($paramPurchase['created_at']) ? $paramPurchase['created_at'] : ''),
153153
'license_supported' => (!empty($paramPurchase['supported_until']) ? $paramPurchase['supported_until'] : ''),
154154
'purchase_code' => sanitize_text_field($paramPurchaseCode),
155155
);
156+
157+
$licenseType = "";
158+
if($normalizedLicense['license'] == "Regular License")
159+
{
160+
$licenseType = "REGULAR";
161+
} else if($normalizedLicense['license'] == "Extended License")
162+
{
163+
$licenseType = "EXTENDED";
164+
}
165+
166+
$normalizedLicense['license_type'] = $licenseType;
156167
$normalizedLicense['license_purchase_date'] = (new \DateTime($normalizedLicense['license_sold']))->format('Y-m-d');
157168
$normalizedLicense['license_purchase_time'] = (new \DateTime($normalizedLicense['license_sold']))->format('H:i:s');
158169
$normalizedLicense['support_expiration_date'] = (new \DateTime($normalizedLicense['license_supported']))->format('Y-m-d');

Libraries/EnvatoMarketAPI.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,22 @@ public function normalizeLicense(array $paramPurchase, $paramBuyerUsername)
356356
'buyer_username' => sanitize_text_field($paramBuyerUsername),
357357
'envato_item_id' => (!empty($paramPurchase['item']['id']) ? $paramPurchase['item']['id'] : ''),
358358
'envato_item_name' => (!empty($paramPurchase['item']['name']) ? $paramPurchase['item']['name'] : ''),
359-
'license_type' => (!empty($paramPurchase['license']) ? $paramPurchase['license'] : ''),
359+
'license' => (!empty($paramPurchase['license']) ? $paramPurchase['license'] : ''),
360360
'license_sold' => (!empty($paramPurchase['sold_at']) ? $paramPurchase['sold_at'] : ''),
361361
'license_supported' => (!empty($paramPurchase['supported_until']) ? $paramPurchase['supported_until'] : ''),
362362
'purchase_code' => (!empty($paramPurchase['code']) ? $paramPurchase['code'] : ''),
363363
);
364+
365+
$licenseType = "";
366+
if($normalizedLicense['license'] == "Regular License")
367+
{
368+
$licenseType = "REGULAR";
369+
} else if($normalizedLicense['license'] == "Extended License")
370+
{
371+
$licenseType = "EXTENDED";
372+
}
373+
374+
$normalizedLicense['license_type'] = $licenseType;
364375
$normalizedLicense['license_purchase_date'] = (new \DateTime($normalizedLicense['license_sold']))->format('Y-m-d');
365376
$normalizedLicense['license_purchase_time'] = (new \DateTime($normalizedLicense['license_sold']))->format('H:i:s');
366377
$normalizedLicense['support_expiration_date'] = (new \DateTime($normalizedLicense['license_supported']))->format('Y-m-d');

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,9 @@ List of all different plugins you bought:
186186
<?='Plugin Id: '.$pluginId.', Name: '.$plugin['name'];?>, Licenses:
187187
<?php foreach($plugin['licenses'] AS $license): ?>
188188
Code: <?=$license['purchase_code'];?>,
189-
Type: <?=$license['license_type'];?>,
190-
Purchased: <?=$license['license_purchase_date'];?>,
191-
Expires: <?=$license['support_expiration_date'];?>
189+
License: <?=$license['license'];?>,
190+
Purchased: <?=$license['license_purchase_date'];?> <?=$license['license_purchase_time'];?>,
191+
Expires: <?=$license['support_expiration_date'];?> <?=$license['support_expiration_time'];?>,
192192
Support Status: <?=$license['support_active'];?>
193193
<?php endforeach; ?>
194194
<?php endforeach; ?>
@@ -198,9 +198,9 @@ List of all different themes you bought:
198198
<?='Theme Id: '.$themeId.', Name: '.$theme['name'];?>, Licenses:
199199
<?php foreach($theme['licenses'] AS $license): ?>
200200
Code: <?=$license['purchase_code'];?>,
201-
Type: <?=$license['license_type'];?>,
202-
Purchased: <?=$license['license_purchase_date'];?>,
203-
Expires: <?=$license['support_expiration_date'];?>,
201+
License: <?=$license['license'];?>,
202+
Purchased: <?=$license['license_purchase_date'];?> <?=$license['license_purchase_time'];?>,
203+
Expires: <?=$license['support_expiration_date'];?> <?=$license['support_expiration_time'];?>,
204204
Status: <?=$license['support_active'] == 1 ? "Supported" : "Support Expired";?>
205205
<?php endforeach; ?>
206206
<?php endforeach; ?>
@@ -215,8 +215,8 @@ Purchase Code: <?=$targetPurchaseCode;?>
215215
Is Valid License: <?=$isValidTargetLicense ? 'Yes' : 'No';?>
216216
Buyer Username: <?=$targetLicenseBuyer;?>
217217
License Type: <?=$targetLicenseType;?>
218-
Purchased At: <?=$targetLicensePurchaseDate;?>
219-
Supported Until: <?=$targetLicenseSupportExpiration;?>
218+
Purchased At: <?=$targetLicensePurchasedAt;?>
219+
Supported Until: <?=$targetLicenseSupportedUntil;?>
220220
Support Status: <?=$targetLicenseSupportActive == 1 ? "Supported" : "Support Expired";?>
221221
222222
2. Details About Target Envato User - <?=$targetUsername;?>
@@ -301,9 +301,9 @@ $targetLicenseDetails = $objToolkit->getLicenseDetails($sanitizedTargetPurchaseC
301301
$view->targetPurchaseCode = esc_html($sanitizedTargetPurchaseCode); // Ready for print
302302
$view->isValidTargetLicense = $objToolkit->isValidLicense($sanitizedTargetPurchaseCode);
303303
$view->targetLicenseBuyer = $targetLicenseDetails['buyer_username'];
304-
$view->targetLicenseType = $targetLicenseDetails['license_type'];
305-
$view->targetLicensePurchaseDate = $targetLicenseDetails['license_purchase_date'].' '.$targetLicenseDetails['license_purchase_time'];
306-
$view->targetLicenseSupportExpiration = $targetLicenseDetails['support_expiration_date'].' '.$targetLicenseDetails['support_expiration_time'];
304+
$view->targetLicense = $targetLicenseDetails['license'];
305+
$view->targetLicensePurchasedAt = $targetLicenseDetails['license_purchase_date'].' '.$targetLicenseDetails['license_purchase_time'];
306+
$view->targetLicenseSupportedUntil = $targetLicenseDetails['support_expiration_date'].' '.$targetLicenseDetails['support_expiration_time'];
307307
$view->targetLicenseSupportActive = $targetLicenseDetails['support_active'];
308308
309309
// 2. Details About Target Envato User
@@ -370,7 +370,7 @@ So there is no need to save your head revision number or last version on your se
370370
## Changelog ##
371371

372372
### 1.3 ###
373-
* Added support for purchase time and license expiration time.
373+
* Added support for purchase time and license expiration time. Plus split to two fields on 'license_type' to 'license' and 'license_type'.
374374

375375
### 1.2 ###
376376
* Added support for the situations if Envato API is down, plus added detailed error message handler.

Test/EnvatoAPIManagerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@
9999
if($targetLicenseDetails != FALSE)
100100
{
101101
$targetLicenseBuyer = $targetLicenseDetails['buyer_username'];
102-
$targetLicenseType = $targetLicenseDetails['license_type'];
103-
$targetLicensePurchaseDate = $targetLicenseDetails['license_purchase_date'].' '.$targetLicenseDetails['license_purchase_time'];
104-
$targetLicenseSupportExpiration = $targetLicenseDetails['support_expiration_date'].' '.$targetLicenseDetails['support_expiration_time'];
102+
$targetLicense = $targetLicenseDetails['license'];
103+
$targetLicensePurchasedAt = $targetLicenseDetails['license_purchase_date'].' '.$targetLicenseDetails['license_purchase_time'];
104+
$targetLicenseSupportedUntil = $targetLicenseDetails['support_expiration_date'].' '.$targetLicenseDetails['support_expiration_time'];
105105
$targetLicenseSupportActive = $targetLicenseDetails['support_active'];
106106
} else
107107
{
108108
$targetLicenseBuyer = '';
109-
$targetLicenseType = '';
110-
$targetLicensePurchaseDate = '';
111-
$targetLicenseSupportExpiration = '';
109+
$targetLicense = '';
110+
$targetLicensePurchasedAt = '';
111+
$targetLicenseSupportedUntil = '';
112112
$targetLicenseSupportActive = 0;
113113
}
114114

Test/template.TestResults.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@
8989
<?php foreach($plugin['licenses'] AS $license): ?>
9090
<em>
9191
Code: <?=$license['purchase_code'];?>,
92-
Type: <?=$license['license_type'];?>,
93-
Purchased: <?=$license['license_purchase_date'];?>,
94-
Expires: <?=$license['support_expiration_date'];?>,
92+
License: <?=$license['license'];?>,
93+
Purchased: <?=$license['license_purchase_date'];?> <?=$license['license_purchase_time'];?>,
94+
Expires: <?=$license['support_expiration_date'];?> <?=$license['support_expiration_time'];?>,
9595
Status: <?=$license['support_active'] == 1 ? "Supported" : "Support Expired";?>
9696
</em>
9797
<br />
@@ -106,9 +106,9 @@
106106
<?php foreach($theme['licenses'] AS $license): ?>
107107
<em>
108108
Code: <?=$license['purchase_code'];?>,
109-
Type: <?=$license['license_type'];?>,
110-
Purchased: <?=$license['license_purchase_date'];?>,
111-
Expires: <?=$license['support_expiration_date'];?>,
109+
License: <?=$license['license'];?>,
110+
Purchased: <?=$license['license_purchase_date'];?> <?=$license['license_purchase_time'];?>,
111+
Expires: <?=$license['support_expiration_date'];?> <?=$license['support_expiration_time'];?>,
112112
Status: <?=$license['support_active'] == 1 ? "Supported" : "Support Expired";?>
113113
</em>
114114
<br />
@@ -132,9 +132,9 @@
132132
<li>Purchase Code: <?=$targetPurchaseCode;?></li>
133133
<li>Is Valid License: <?=$isValidTargetLicense ? 'Yes' : 'No';?></li>
134134
<li>Buyer Username: <?=$targetLicenseBuyer;?></li>
135-
<li>License Type: <?=$targetLicenseType;?></li>
136-
<li>Purchased At: <?=$targetLicensePurchaseDate;?></li>
137-
<li>Supported Until: <?=$targetLicenseSupportExpiration;?></li>
135+
<li>License: <?=$targetLicense;?></li>
136+
<li>Purchased At: <?=$targetLicensePurchasedAt;?></li>
137+
<li>Supported Until: <?=$targetLicenseSupportedUntil;?></li>
138138
<li>Status: <?=$targetLicenseSupportActive == 1 ? "Supported" : "Support Expired";?></li>
139139
</ul>
140140
<?php endif; ?>

0 commit comments

Comments
 (0)