feat: Add licensing module backend
- LicensingSettings.php with key format, activation limits, expiry settings - LicenseManager.php with key generation, activation/deactivation, validation - LicensingModule.php with WooCommerce product meta integration - LicensesController.php with admin, customer, and public API endpoints - Database tables: woonoow_licenses, woonoow_license_activations - has_settings enabled in ModuleRegistry
This commit is contained in:
95
includes/Modules/LicensingSettings.php
Normal file
95
includes/Modules/LicensingSettings.php
Normal file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* Licensing Module Settings
|
||||
*
|
||||
* @package WooNooW\Modules
|
||||
*/
|
||||
|
||||
namespace WooNooW\Modules;
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
class LicensingSettings {
|
||||
|
||||
/**
|
||||
* Initialize the settings
|
||||
*/
|
||||
public static function init() {
|
||||
add_filter('woonoow/module_settings_schema', [__CLASS__, 'register_schema']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register licensing settings schema
|
||||
*/
|
||||
public static function register_schema($schemas) {
|
||||
$schemas['licensing'] = [
|
||||
'license_key_format' => [
|
||||
'type' => 'select',
|
||||
'label' => __('License Key Format', 'woonoow'),
|
||||
'description' => __('Format for generated license keys', 'woonoow'),
|
||||
'options' => [
|
||||
'uuid' => 'UUID (e.g., a1b2c3d4-e5f6-7890-abcd-ef1234567890)',
|
||||
'serial' => 'Serial (e.g., XXXX-XXXX-XXXX-XXXX)',
|
||||
'alphanumeric' => 'Alphanumeric (e.g., ABC123DEF456)',
|
||||
],
|
||||
'default' => 'serial',
|
||||
],
|
||||
'license_key_prefix' => [
|
||||
'type' => 'text',
|
||||
'label' => __('License Key Prefix', 'woonoow'),
|
||||
'description' => __('Optional prefix for license keys (e.g., PRO-, ENT-)', 'woonoow'),
|
||||
'placeholder' => 'e.g., PRO-',
|
||||
'default' => '',
|
||||
],
|
||||
'default_activation_limit' => [
|
||||
'type' => 'number',
|
||||
'label' => __('Default Activation Limit', 'woonoow'),
|
||||
'description' => __('Default max activations per license (0 = unlimited). Can be overridden per product.', 'woonoow'),
|
||||
'default' => 1,
|
||||
'min' => 0,
|
||||
'max' => 100,
|
||||
],
|
||||
'allow_deactivation' => [
|
||||
'type' => 'toggle',
|
||||
'label' => __('Allow Deactivation', 'woonoow'),
|
||||
'description' => __('Allow customers to deactivate their licenses to free up activation slots', 'woonoow'),
|
||||
'default' => true,
|
||||
],
|
||||
'license_expiry_enabled' => [
|
||||
'type' => 'toggle',
|
||||
'label' => __('Enable License Expiry', 'woonoow'),
|
||||
'description' => __('Licenses expire after a set period (for subscription-based products)', 'woonoow'),
|
||||
'default' => false,
|
||||
],
|
||||
'default_expiry_days' => [
|
||||
'type' => 'number',
|
||||
'label' => __('Default Expiry (Days)', 'woonoow'),
|
||||
'description' => __('Default license validity period in days (0 = never expires)', 'woonoow'),
|
||||
'default' => 365,
|
||||
'min' => 0,
|
||||
],
|
||||
'block_expired_activations' => [
|
||||
'type' => 'toggle',
|
||||
'label' => __('Block Expired Activations', 'woonoow'),
|
||||
'description' => __('Prevent new activations for expired licenses (deactivations still allowed)', 'woonoow'),
|
||||
'default' => true,
|
||||
],
|
||||
'send_expiry_reminder' => [
|
||||
'type' => 'toggle',
|
||||
'label' => __('Send Expiry Reminders', 'woonoow'),
|
||||
'description' => __('Send email reminders before license expires', 'woonoow'),
|
||||
'default' => true,
|
||||
],
|
||||
'expiry_reminder_days' => [
|
||||
'type' => 'number',
|
||||
'label' => __('Reminder Days Before Expiry', 'woonoow'),
|
||||
'description' => __('Send reminder this many days before expiry', 'woonoow'),
|
||||
'default' => 7,
|
||||
'min' => 1,
|
||||
'max' => 30,
|
||||
],
|
||||
];
|
||||
|
||||
return $schemas;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user