WordPress License Management SDK #
Add a license key settings section to your WordPress plugin or theme.
Files #
sdk/php/wordpress/class-dmsi-wp-license.php
What It Does #
DMSI_WP_License provides:
- A settings section for customers to enter their license key
- Activate, deactivate, and validate buttons
- A status badge (active, grace, expired, invalid)
- Expiry date display
- Daily background validation via WordPress cron
Basic Integration #
require_once plugin_dir_path(__FILE__) . 'updater/class-dmsi-wp-license.php';
add_action('init', function() {
$client = new DMSI_Update_Client([
'api_url' => 'https://yoursite.com',
'product_id' => 42,
]);
$license = new DMSI_WP_License([
'client' => $client,
'slug' => 'your-plugin', // used as option name prefix
'name' => 'Your Plugin', // display name
]);
$license->init();
});
Rendering the License Section #
In your plugin's settings page:
$license->render_settings_section();
This renders the license key input, status badge, and action buttons.
Checking License Status in Your Code #
if ($license->is_valid()) {
// Enable premium features
}
$status = $license->get_status();
// Returns: active | grace | expired | invalid | inactive
$days_left = $license->get_days_until_expiry();
License Status Values #
| Status | Meaning |
|---|---|
| active | License is valid and not expiring soon |
| grace | License expired but within grace period (is_valid() returns true) |
| expired | License expired and past grace period |
| invalid | Key does not exist or was revoked |
| inactive | Key entered but not yet activated |
