You've already forked wc-licensed-product
Add inline editing for licenses and copy license key button
- Add inline editing for status, expiry date, and domain fields - Add copy-to-clipboard button for license keys - Add AJAX handlers for inline editing with nonce verification - Update LicenseManager with updateLicenseExpiry method - Add new translations for inline editing strings (de_CH) - Compile updated German translations to .mo file Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -424,6 +424,39 @@ class LicenseManager
|
||||
return $result !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update license expiry date
|
||||
*
|
||||
* @param int $licenseId License ID
|
||||
* @param \DateTimeImmutable $expiresAt New expiry date
|
||||
* @return bool Success
|
||||
*/
|
||||
public function updateLicenseExpiry(int $licenseId, \DateTimeImmutable $expiresAt): bool
|
||||
{
|
||||
global $wpdb;
|
||||
|
||||
$license = $this->getLicenseById($licenseId);
|
||||
if (!$license) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$tableName = Installer::getLicensesTable();
|
||||
$result = $wpdb->update(
|
||||
$tableName,
|
||||
['expires_at' => $expiresAt->format('Y-m-d H:i:s')],
|
||||
['id' => $licenseId],
|
||||
['%s'],
|
||||
['%d']
|
||||
);
|
||||
|
||||
// If license was expired and new date is in the future, reactivate it
|
||||
if ($result !== false && $license->getStatus() === License::STATUS_EXPIRED && $expiresAt > new \DateTimeImmutable()) {
|
||||
$this->updateLicenseStatus($licenseId, License::STATUS_ACTIVE);
|
||||
}
|
||||
|
||||
return $result !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update license domain
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user