You've already forked wc-licensed-product
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2ec3f42b1f | |||
| 4817175f99 | |||
| a4561057fa | |||
| d15c59b7c3 |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [0.4.0] - 2026-01-24
|
||||
|
||||
### Added
|
||||
|
||||
- Self-licensing prevention: Plugin automatically bypasses license validation when the configured license server URL points to the same WordPress installation
|
||||
- New `isSelfLicensing()` method in `PluginLicenseChecker` to detect circular licensing scenarios
|
||||
- New `normalizeDomain()` helper method for domain comparison (strips www prefix, lowercases)
|
||||
|
||||
### Changed
|
||||
|
||||
- `isLicenseValid()` and `validateLicense()` now check for self-licensing before attempting validation
|
||||
- Cache clearing now also clears the self-licensing check cache
|
||||
|
||||
### Technical Details
|
||||
|
||||
- Self-licensing detection compares normalized domains of license server URL and current site URL
|
||||
- Prevents circular dependency where plugin would try to validate against itself
|
||||
- Plugins can only be validated against the original store from which they were obtained
|
||||
|
||||
## [0.3.9] - 2026-01-24
|
||||
|
||||
### Added
|
||||
|
||||
44
CLAUDE.md
44
CLAUDE.md
@@ -36,13 +36,9 @@ This project is proudly **"vibe-coded"** using Claude.AI - the entire codebase w
|
||||
|
||||
No known bugs at the moment.
|
||||
|
||||
### Version 0.3.9
|
||||
|
||||
No changes at the moment.
|
||||
|
||||
### Version 0.4.0
|
||||
|
||||
No changes at the moment.
|
||||
- Self-licensing prevention: Plugin automatically bypasses license validation when the configured license server URL points to the same WordPress installation (prevents circular dependency)
|
||||
|
||||
## Technical Stack
|
||||
|
||||
@@ -1125,3 +1121,41 @@ Fixed a critical translation bug that caused the settings page to crash with an
|
||||
- Created release package: `releases/wc-licensed-product-0.3.8.zip` (829 KB)
|
||||
- SHA256: `50ad6966c5ab8db2257572084d2d8a820448df62615678e1576696f2c0cb383d`
|
||||
- Tagged as `v0.3.8` and pushed to `main` branch
|
||||
|
||||
### 2026-01-24 - Version 0.3.9 - Admin Order License Generation Fix
|
||||
|
||||
**Overview:**
|
||||
|
||||
Fixed a critical bug where licenses were not generated for orders created manually in the WordPress admin area.
|
||||
|
||||
**Bug Fix:**
|
||||
|
||||
- **Critical:** Licenses are now generated for orders created manually in admin area
|
||||
- Previously, licenses were only generated via checkout hooks (`woocommerce_order_status_completed`, `woocommerce_order_status_processing`, `woocommerce_payment_complete`)
|
||||
- Admin-created orders bypassed checkout, so the `_licensed_product_domain` meta was never set and licenses were never generated
|
||||
|
||||
**Implemented:**
|
||||
|
||||
- "Generate Licenses" button in order meta box for admin-created orders
|
||||
- "Generate Missing Licenses" button when some products in an order already have licenses
|
||||
- Warning message when order domain is not set before generating licenses
|
||||
- AJAX handler `ajaxGenerateOrderLicenses()` for manual license generation
|
||||
|
||||
**Modified files:**
|
||||
|
||||
- `src/Admin/OrderLicenseController.php` - Added Generate button, AJAX handler, CSS styles
|
||||
- `assets/js/order-licenses.js` - Added `generateLicenses()` function with page reload on success
|
||||
|
||||
**Technical notes:**
|
||||
|
||||
- Button only appears when order is paid and domain is set
|
||||
- Uses existing `LicenseManager::generateLicense()` which handles duplicate prevention
|
||||
- Page reloads after successful generation to show new licenses in table
|
||||
- Tracks generated vs skipped licenses for accurate feedback messages
|
||||
- Updated translations (365 strings)
|
||||
|
||||
**Release v0.3.9:**
|
||||
|
||||
- Created release package: `releases/wc-licensed-product-0.3.9.zip` (851 KB)
|
||||
- SHA256: `fdb65200c368da380df0cabb3c6ac6419d5b4731cd528f630f9b432a3ba5c586`
|
||||
- Tagged as `v0.3.9` and pushed to `main` branch
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
BIN
releases/wc-licensed-product-0.3.9.zip
Normal file
BIN
releases/wc-licensed-product-0.3.9.zip
Normal file
Binary file not shown.
1
releases/wc-licensed-product-0.3.9.zip.sha256
Normal file
1
releases/wc-licensed-product-0.3.9.zip.sha256
Normal file
@@ -0,0 +1 @@
|
||||
fdb65200c368da380df0cabb3c6ac6419d5b4731cd528f630f9b432a3ba5c586 releases/wc-licensed-product-0.3.9.zip
|
||||
@@ -52,6 +52,11 @@ final class PluginLicenseChecker
|
||||
*/
|
||||
private ?bool $isLocalhostCached = null;
|
||||
|
||||
/**
|
||||
* Cached self-licensing check result
|
||||
*/
|
||||
private ?bool $isSelfLicensingCached = null;
|
||||
|
||||
/**
|
||||
* Get singleton instance
|
||||
*/
|
||||
@@ -84,6 +89,11 @@ final class PluginLicenseChecker
|
||||
return true;
|
||||
}
|
||||
|
||||
// Always valid when self-licensing (server URL points to this installation)
|
||||
if ($this->isSelfLicensing()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check cache first
|
||||
$cached = get_transient(self::CACHE_KEY);
|
||||
if ($cached !== false) {
|
||||
@@ -107,6 +117,11 @@ final class PluginLicenseChecker
|
||||
return true;
|
||||
}
|
||||
|
||||
// Always valid when self-licensing (server URL points to this installation)
|
||||
if ($this->isSelfLicensing()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check settings are configured
|
||||
$serverUrl = $this->getLicenseServerUrl();
|
||||
$licenseKey = $this->getLicenseKey();
|
||||
@@ -176,6 +191,7 @@ final class PluginLicenseChecker
|
||||
delete_transient(self::CACHE_KEY);
|
||||
delete_transient(self::ERROR_CACHE_KEY);
|
||||
$this->isLocalhostCached = null;
|
||||
$this->isSelfLicensingCached = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,6 +231,60 @@ final class PluginLicenseChecker
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if self-licensing (license server URL points to this installation)
|
||||
*
|
||||
* Prevents circular dependency where plugin tries to validate against itself.
|
||||
* Plugins can only be validated against the original store from which they were obtained.
|
||||
*/
|
||||
public function isSelfLicensing(): bool
|
||||
{
|
||||
if ($this->isSelfLicensingCached !== null) {
|
||||
return $this->isSelfLicensingCached;
|
||||
}
|
||||
|
||||
$serverUrl = $this->getLicenseServerUrl();
|
||||
|
||||
// No server URL configured - not self-licensing
|
||||
if (empty($serverUrl)) {
|
||||
$this->isSelfLicensingCached = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parse both URLs to compare domains
|
||||
$serverParsed = parse_url($serverUrl);
|
||||
$siteUrl = get_site_url();
|
||||
$siteParsed = parse_url($siteUrl);
|
||||
|
||||
// Get normalized domains (lowercase, no www prefix)
|
||||
$serverDomain = $this->normalizeDomain($serverParsed['host'] ?? '');
|
||||
$siteDomain = $this->normalizeDomain($siteParsed['host'] ?? '');
|
||||
|
||||
// If domains match, this is self-licensing
|
||||
if ($serverDomain === $siteDomain) {
|
||||
$this->isSelfLicensingCached = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->isSelfLicensingCached = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize a domain for comparison (lowercase, strip www)
|
||||
*/
|
||||
private function normalizeDomain(string $domain): string
|
||||
{
|
||||
$domain = strtolower(trim($domain));
|
||||
|
||||
// Strip www. prefix
|
||||
if (str_starts_with($domain, 'www.')) {
|
||||
$domain = substr($domain, 4);
|
||||
}
|
||||
|
||||
return $domain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current domain from the site URL
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: WooCommerce Licensed Product
|
||||
* Plugin URI: https://src.bundespruefstelle.ch/magdev/wc-licensed-product
|
||||
* Description: WooCommerce plugin to sell software products using license keys with domain-based validation.
|
||||
* Version: 0.3.9
|
||||
* Version: 0.4.0
|
||||
* Author: Marco Graetsch
|
||||
* Author URI: https://src.bundespruefstelle.ch/magdev
|
||||
* License: GPL-2.0-or-later
|
||||
@@ -28,7 +28,7 @@ if (!defined('ABSPATH')) {
|
||||
}
|
||||
|
||||
// Plugin constants
|
||||
define('WC_LICENSED_PRODUCT_VERSION', '0.3.9');
|
||||
define('WC_LICENSED_PRODUCT_VERSION', '0.4.0');
|
||||
define('WC_LICENSED_PRODUCT_PLUGIN_FILE', __FILE__);
|
||||
define('WC_LICENSED_PRODUCT_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||
define('WC_LICENSED_PRODUCT_PLUGIN_URL', plugin_dir_url(__FILE__));
|
||||
|
||||
Reference in New Issue
Block a user