10. Developer


In this section we will explain you how to integrate the WooCommerce License Manager Clien in your plugins.

10.1. Client Configuration


In this section we will explain the main settings of the WooCommerce License Manager client.

You can find the api_url & product_key in the Software tab of your product. Please the section 4.3 of the product documentation.

api_url
URL of the server Rest API.
product_key
Public product key of the product related to your plugin.
dir
Don’t change this unless you know what you’re doing.
rest_namespace
Enable Rest API endpoints to handle your license.
parent_menu_slug
Include the slug of your plugin’s main menu to attach the license page or include false to disable it completely.
license_url
Include a custom license URL. This is specially useful if you’ve disabled the parent_menu_slug.

10.2. Client Integration


In this section we will explain you how to integrate the WooCommerce License Manager Client in your plugins.

10.2.1. Composer


In this section we will explain you how to integrate the WooCommerce License Manager Client in your plugins with Composer.

1. Install the library using, you have to run command “composer require quadlayers/wp-license-client”.

2. Create a file called ql_license_client_integration.php.

3. Go to the main file of your plugin and include this code.
require_once 'ql_license_client_integration.php';

4. Include this code in the ql_license_client_integration.php

<?php

if ( ! function_exists( 'your_plugin_license_client_integration' ) ) {
    function your_plugin_license_client_integration() {
        global $your_plugin_license_client;
        if ( ! isset( $your_plugin_license_client ) ) {
            $your_plugin_license_client = ql_license_client(
                array(
                    'api_url'     => 'https://yoursite.com/wp-json/wc/wdd/',
                    'product_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                    'plugin_file' => __FILE__,
                // 'rest_namespace'   => 'your_plugin', /** Enable rest api */
                // 'parent_menu_slug' => 'your_plugin_menu_slug',
                // 'license_url'      => admin_url( 'admin.php?page=your_plugin_license_page' ) ),
                // 'support_url'      => 'your_plugin_support_url',
                )
            );
        }
        return $your_plugin_license_client;
    }
    your_plugin_license_client_integration();
}

10.2.2. Manual


In this section we will explain you how to integrate the WooCommerce License Manager Client in your plugins manually.

1. Download the license client repo from this link.

2. Include the licenseClient folder in your vendor/licenseClient folder of your plugin.

3. Create a file called ql_license_client_integration.php

4. Go to the main file of your plugin and include this code.
require_once 'ql_license_client_integration.php';

5. Include this code in the ql_license_client_integration.php

<?php

if ( ! function_exists( 'your_plugin_license_client_integration' ) ) {
    function your_plugin_license_client_integration() {
        global $your_plugin_license_client;
        if ( ! isset( $your_plugin_license_client ) ) {
            /**
             * Path to the license client folder.
             * This is not required if you're using Composer in your package.
             */
            require_once 'vendor/quadlayers/license-client/index.php';
            $your_plugin_license_client = ql_license_client(
                array(
                    'api_url'     => 'https://yoursite.com/wp-json/wc/wdd/',
                    'product_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
                    'plugin_file' => __FILE__,
                // 'rest_namespace'   => 'your_plugin', /** Enable rest api */
                // 'parent_menu_slug' => 'your_plugin_menu_slug',
                // 'license_url'      => admin_url( 'admin.php?page=your_plugin_license_page' ) ),
                // 'support_url'      => 'your_plugin_support_url',
                )
            );
        }
        return $your_plugin_license_client;
    }
    your_plugin_license_client_integration();
}