Files
WooNooW/includes/Modules/LicensingSettings.php
Dwindi Ramadhana a0b5f8496d feat: Implement OAuth license activation flow
- Add LicenseConnect.tsx focused OAuth confirmation page in customer SPA
- Add /licenses/oauth/validate and /licenses/oauth/confirm API endpoints
- Update App.tsx to render license-connect outside BaseLayout (no header/footer)
- Add license_activation_method field to product settings in Admin SPA
- Create LICENSING_MODULE.md with comprehensive OAuth flow documentation
- Update API_ROUTES.md with license module endpoints
2026-01-31 22:22:22 +07:00

116 lines
4.5 KiB
PHP

<?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,
],
'activation_method' => [
'type' => 'select',
'label' => __('Activation Method', 'woonoow'),
'description' => __('How licenses are activated. OAuth requires user login on your site (anti-piracy).', 'woonoow'),
'options' => [
'api' => __('Simple API (license key only)', 'woonoow'),
'oauth' => __('Secure OAuth (requires account login)', 'woonoow'),
],
'default' => 'api',
],
'allow_product_override' => [
'type' => 'toggle',
'label' => __('Allow Per-Product Override', 'woonoow'),
'description' => __('Show activation method field on each product for individual customization', 'woonoow'),
'default' => false,
],
];
return $schemas;
}
}