SDK Installation
Current SDK version: 2.0.0
Requirements
- PHP 7.2 or higher
- WordPress 6.4 or higher (tested up to 6.7+)
- Composer (recommended)
Installation
Install the SDK with Composer:
composer require license-bridge/wordpress-sdk
Commit composer.json and composer.lock to your repository. Do not edit files inside vendor/ directly.
Use Composer to install the SDK into vendor/. Do not copy a local bridge/ folder into your plugin or theme, and do not define LB_URL or other constants manually — pass configuration to Loader::register() instead.
Create SDK Integration Snippet
Create a helper function in your main plugin file (or functions.php for themes). Rename my_license and $my_license to something unique so they do not collide with other plugins or themes that use License Bridge.
Replace my-first-product with your product slug from License Bridge.
if (!function_exists('my_license')) {
function my_license()
{
global $my_license;
if ($my_license) {
return $my_license;
}
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
return null;
}
require_once __DIR__ . '/vendor/autoload.php';
include __DIR__ . '/vendor/license-bridge/wordpress-sdk/src/Boot/bootstrap.php';
$my_license = \LicenseBridge\WordPressSDK\Boot\Loader::register(__FILE__, [
'plugin-slug' => plugin_basename(__FILE__),
'license-product-slug' => 'my-first-product',
]);
return $my_license;
}
my_license();
}
Loader::register() automatically wires:
- Hidden admin callback page (post-purchase license storage)
- Premium plugin upgrade after purchase
- WordPress update API integration
You do not need to manually instantiate internal SDK classes or build callback URLs yourself.
Where to store the snippet?
Store the snippet in your main plugin file for plugins, and in functions.php for themes.
How to use it?
Once the snippet is in place, access the SDK via your helper function or global variable:
with function call
my_license()->license(plugin_basename(__FILE__));
with global variable
$my_license->license(plugin_basename(__FILE__));
Both return the same singleton SDK instance.
Upgrade from an earlier SDK version
If you already use the SDK, update with Composer:
composer update license-bridge/wordpress-sdk
SDK 2.0.0 ships checkout assets under vendor/license-bridge/wordpress-sdk/assets/. No extra install step is required. When using inline checkout, pass plugin-file to checkout_button() (or rely on the value stored from Loader::register(__FILE__, …) — see SDK Usage).
Configuration
Pass these keys to Loader::register() (merged with SDK defaults):
| Key | Required | Default | Description |
|---|---|---|---|
plugin-slug | Yes | — | plugin_basename(__FILE__) |
license-product-slug | Yes | — | Product slug on License Bridge |
license-bridge-url | No | https://licensebridge.com | Market / checkout base URL |
license-bridge-api-url | No | https://app.licensebridge.com | API base URL (OAuth, license, updates) |
license-bridge-oauth-token-uri | No | /oauth/token | OAuth token path |
plugin-transient-cache-expire | No | 43200 (12h) | Plugin details cache (seconds) |
cache-expire | No | 3600 (1h) | General cache (seconds) |
Local / staging example
$my_license = \LicenseBridge\WordPressSDK\Boot\Loader::register(__FILE__, [
'plugin-slug' => plugin_basename(__FILE__),
'license-product-slug' => 'my-first-product',
'license-bridge-url' => 'http://market.lb.test',
'license-bridge-api-url' => 'https://your-tunnel.ngrok-free.app',
]);
See SDK Usage for license checks, purchase links, inline checkout, and post-purchase redirects.