SDK for WordPress Usage
Access the SDK via the integration snippet you created:
$bridge = my_license();
$slug = plugin_basename(__FILE__);
Or call your helper function directly:
my_license()->purchase_link(plugin_basename(__FILE__));
Get a unique landing page URL for your product
$link = $bridge->purchase_link($slug);
// https://licensebridge.com/market/my-first-product?callback_url=...
Use in a button:
echo '<a href="' . esc_url($link) . '">Buy Premium</a>';
The SDK builds and URL-encodes the callback URL automatically — you do not need to construct it manually.
Check if the user has a license key
if ($bridge->license_exists($slug)) {
// License credentials stored locally
}
Check if the license is active
if ($bridge->is_license_active($slug)) {
// Active license on License Bridge
}
Get license details
$response = $bridge->license($slug);
Returns false if no license exists. Otherwise returns an array with license details:
array (size=13)
'first_name' => string 'John' (length=11)
'last_name' => string 'Doe' (length=10)
'full_name' => string 'John Doe' (length=22)
'email' => string '[email protected]' (length=20)
'plan_type' => string 'month' (length=5)
'plan_name' => string 'plan' (length=4)
'charge_type' => string 'subscription' (length=12)
'gateway' => string 'stripe' (length=6)
'active' => boolean true
'created_at' => string '01/27/2022 18:07:48' (length=19)
'subscribed' => boolean true
'cancelled' => boolean true
'subscription' =>
array (size=4)
'stripe_id' => string 'sub_0KMcNuxCqoZozrbaG75rgcZs' (length=28)
'stripe_customer_id' => string 'cus_L2hnYEuIw2p3pE' (length=18)
'ends_at_formated' => string 'February 27, 2022' (length=17)
'is_ended' => boolean false
Cancel the user license request
When a user is subscribed to your plugin, you can let them cancel from your plugin UI:
if ($bridge->cancel_license($slug)) {
// Subscription cancelled on License Bridge
}
Post-purchase redirect
After checkout, License Bridge redirects the customer to your WordPress admin. The SDK:
- Verifies the nonce
- Stores
lk,client_id, andclient_secret - Runs premium plugin upgrade (if a newer package is available)
- Redirects to the Plugins screen with one of these query args:
wp-admin/plugins.php?license_upgraded=1— premium upgrade ranwp-admin/plugins.php?license_saved=1— license saved, no newer version to install
Show admin feedback after redirect:
add_action('admin_notices', function () {
if (isset($_GET['license_upgraded'])) {
echo '<div class="notice notice-success"><p>Premium activated.</p></div>';
}
if (isset($_GET['license_saved'])) {
echo '<div class="notice notice-success"><p>License saved.</p></div>';
}
});
The premium version on License Bridge must be higher than the installed free version for auto-upgrade to run after purchase.
Hooks
Run custom logic before or after the post-purchase upgrade:
apply_filters('before_upgrade_plugin_' . $plugin_slug, '');
apply_filters('after_upgrade_plugin_' . $plugin_slug, '');
Replace $plugin_slug with your plugin-slug value from Loader::register().