PHP code example of mkr / smartdesk-license-client
1. Go to this page and download the library: Download mkr/smartdesk-license-client library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mkr / smartdesk-license-client example snippets
define('SDLC_API_BASE', 'https://server.local/');
define('SDLC_API_VERIFY', SDLC_API_BASE . '/wp-json/smartdesk/v1/license/verify');
define('SDLC_API_PING', SDLC_API_BASE . '/wp-json/smartdesk/v1/license/ping');
define('SDLC_API_UPDATE', SDLC_API_BASE . '/wp-json/smartdesk/v1/update/plugin');
use SmartDesk\LicenseClient\Api;
// Gate features behind a license
if (!Api::is_valid('smartdesk-core')) {
add_action('admin_notices', function () {
echo '<div class="notice notice-error"><p>License invalid or expired.</p></div>';
});
return;
}
// Read plan/limits
$limits = Api::get_limits('smartdesk-core');
// Example: enforce seats
$maxMembers = (int)($limits['members.max'] ?? 0);
use SmartDesk\LicenseClient\Client;
// Verify with cache (12h TTL)
$res = Client::verify('smartdesk-core');
// Force verification (bypass cache)
$res = Client::verify('smartdesk-core', true);
use SmartDesk\LicenseClient\Helpers;
// Store (encrypted)
Helpers::set_secret('license_key', 'XXXX-XXXX-XXXX');
// Read (plaintext)
$key = Helpers::get_secret('license_key', '');
// In plugin bootstrap
\SmartDesk\LicenseClient\Updater::boot();
use SmartDesk\Utils\DebugLogger;
use SmartDesk\Utils\Support\LogLevel;
add_action('plugins_loaded', function () {
if (!defined('WP_DEBUG') || WP_DEBUG !== true) return;
$dir = WP_CONTENT_DIR . '/uploads/smartdesk-logs';
DebugLogger::setWriter(DebugLogger::makeRotatingWriter($dir, 'sdlc.log', 2_000_000, 4));
DebugLogger::setMinLevel(LogLevel::INFO);
});
composer
use SmartDesk\LicenseClient\Api;
add_action('admin_init', function () {
if (!Api::is_valid('smartdesk-core')) {
add_action('admin_notices', function () {
echo '<div class="notice notice-error"><p>SmartDesk: license invalid/expired.</p></div>';
});
}
});
$limits = Api::get_limits('smartdesk-core');
$maxMembers = (int)($limits['members.max'] ?? 0);
if ($maxMembers > 0 && $currentCount > $maxMembers) {
// Block or upsell
}
\SmartDesk\LicenseClient\Updater::boot();