SDK Integration
/
SDK Installation

SDK Installation

Installation

With Composer

To install SDK for WordPress, we recommend composer.

composer require license-bridge/wordpress-sdk
Manual Download

Another way is to grab a zipped download from a GitHub and extract it into your plugin/theme.

Create SDK Integration Snippet

To get access to global SDK object, you need to create integration snippet with unique function name to avoid collisions with another WordPress plugins and themes that also use License Bridge.

  • Replace my_license function name with your own unique function name.
  • Replace global variable $my_license with your own unique variable name.
  • Replace my-first-product with a real product slug from the License Bridge.
if (!function_exists('my_license')) {
    // Create a helper function for easy SDK access.
    function my_license() // Change the name of the function to avoid collisions
    {
        global $my_license; // Change the name of this global variable too.
        if ($my_license) {
            return $my_license;
        }

        // In case you manually download the SDK change the path to match your location
        include __DIR__ . '/vendor/license-bridge/wordpress-sdk/src/Boot/bootstrap.php';
        
        $my_license = Loader::register(__FILE__, [
            'plugin-slug'                   => plugin_basename(__FILE__),
            // Change the product slug to match the slug from License Bridge
            'license-product-slug'          => 'my-first-product', 
        ]);

        return $my_license;
    }
    my_license();
}

Where to store the snippet?

Store the snippet into main plugin file for plugins, and into functions.php for themes.

How to use it?

Once you set up the snippet, you can access to the main SDK object via function name, which is my_license() in our case. Another way to access the main SDK object is via a global variable you created with the snippet.

with function call
my_license()->license('my_plugin_file');
with global variable
$my_license->license('my_plugin_file');

Pick the way you prefer. Both ways will return singleton instance of the SDK object.