Client Library Overview

The SLSWC Client library enables WordPress plugins and themes to check for updates, manage licenses, and enforce DRM against an SLSWC-powered license server.

Location

libraries/slswc/client/src/

Class Reference

ClassDescription
PluginPlugin updater. Hooks into pre_set_site_transient_update_plugins and plugins_api. Extends GenericSoftwareUpdater.
ThemeTheme updater. Hooks into pre_set_site_transient_update_themes. Extends GenericSoftwareUpdater.
GenericSoftwareUpdaterAbstract base class. Manages license details, creates ApiClient and LicenseDetails instances.
ApiClientHTTP client. Sends requests to the license server's REST API (/wp-json/slswc/v1/).
LicenseDetailsLicense state manager. Reads/writes license details from WordPress options. Tracks activation status, expiry, and environment.
DRMGrace-period enforcer. Escalating admin notices and full-page interstitial lock for unlicensed products.
HelperStatic utilities. File header parsing, environment detection, logging, data formatting.
SoftwareUpdaterInterfaceInterface that Plugin and Theme implement.

Architecture

Plugin / Theme
    |
    +-- GenericSoftwareUpdater (base)
    |       |
    |       +-- ApiClient         (HTTP requests to license server)
    |       +-- LicenseDetails    (license state persistence)
    |
    +-- DRM (optional, admin-only enforcement)

Namespace

All client classes live in the SLSWC\Client namespace:

use SLSWC\Client\Plugin;
use SLSWC\Client\Theme;
use SLSWC\Client\DRM;

Quick Start

For Plugins

use SLSWC\Client\Plugin;

$client = Plugin::get_instance(
    'https://your-license-server.com/',
    __FILE__,
    array(
        'license_key' => get_option( 'my_plugin_license_key', '' ),
        'slug'        => 'my-plugin-slug',
    )
);
$client->init_hooks();

For Themes

use SLSWC\Client\Theme;

Theme::get_instance(
    'https://your-license-server.com/',
    WP_CONTENT_DIR . '/themes/my-theme',
    array(
        'license_key' => get_option( 'my_theme_license_key', '' ),
        'domain'      => site_url(),
    )
);

See Plugin Integration and Theme Integration for full guides.

Which Class Do I Need?

ScenarioClassGuide
WordPress plugin with licensing and auto-updatesPluginPlugin Integration
WordPress theme with licensing and auto-updatesThemeTheme Integration
Custom API integration (non-WordPress or headless)ApiClientREST API Overview
Copy protection with grace periods and admin lockDRM (via Plugin)DRM
Checking license state from your own codeLicenseDetailsAuto-Updates

Tip: You almost never instantiate ApiClient, LicenseDetails, or DRM directly. The Plugin and Theme classes create them internally. Use DRM configuration via the drm key in the args array passed to Plugin::get_instance().

Was this article helpful?