1. Home
  2. WP Software License Server
  3. Developer Documentation
  4. Integrate License Into Your Plugin
  1. Home
  2. WP Software License Server
  3. Integrate License Into Your Plugin

Integrate License Into Your Plugin

The following article will outline the steps required to integrate the software license system into your plugin. This software has been developed to work with WooCommerce based plugins at this point.

There are two components to enabling your plugin to work with the software license server.

  1. WooCommerce product configuration
  2. Plugin license client integration

WooCommerce Product Configuration 

To enable a product to be sold and have license automatically generated when orders are placed you need to create the following.

Create WooCommerce product with standard information such as title, description, images and price. The following MUST BE SET.

Simple Product and be Virtual & Downloadable

Include your plugin Installation zip file and download expiry ( 365 days as licenses last for 1 year )

License information configuration 

This is the most important settings that must be set for the update service to work correctly. The fields that correspond to your software information is as follows:

  • Software Slug – This is the unique software slug used to identify the product on the server.
  • Software Version – The current software version number. This is what the client library uses to check for updates.
  • Software Author – The author of the software, this is shown on the plugins details.
  • Requires WP Version – The minimum WordPress version required
  • Compatible Up to – The WordPress version tested up to.
  • Last updated – When the plugin was last updated
  • Changelog – This is the plugins changelog shown on the changelog panel for plugin details.

Plugin Client License Integration

To include the license and update system to your plugin. You need to only do the following TWO steps.

  1. Copy and include the client update library into your plugins directory.
  2. Initialize the software license class in your MAIN plugin file.

Parameter Explanation

Required Parameters

Parameter Name  Type Description
1 $license_server_url string The base url to your woocommerce shop
2 $version string  The software version currently running.
3 $text_domain string The text domain of the plugin
4 $plugin_file string Path to the plugin file or directory, relative to the plugins directory
5 $plugin_nice_name string A nice name for the plugin for use in messages

Optional Parameters

Parameter Name Type Description
6 $slug string The plugin slug if your class file name is different to the specified slug on the WooCommerce Product.
7 $update_interval integer Time in hours between update checks.
8 $debug bool Enable debugging of the client library.  Not used in current version.

Release New Version

To release a new version all you have to do is the following:

  1. Edit the WooCommerce Product.
  2. Provide an updated plugin zip file.
  3. Adjust the version to the new version
  4. Update last updated field
  5. Update the changelog.
  6. Save your product and the new version will show up as an available update.

Notes: 

  • The client initialization should only be done in your main class file. This cannot be included in any subclasses.
  • The software version is what is used to check if there is a new version on the server. If the server software version is new then an update is available.
  • If you don’t like using a variable for your text-domain you can do a search and replace on the $text_domain
  • The library file is called class-wc-software-license-client.php ships with the license server or a copy can be provided by your marketplace owner (if used in conjunction with wc-vendors).
  • The plugin slug is auto generated from the plugins mail class filename if not specified. This should match the plugin-slug on the WooCommerce Product license information. eg. main plugin file name my-cool-plugin.php slug is my-cool-plugin
  • You should leave the update interval as default unless you have a reason to increase or decrease the update checking.

 

Updated on May 3, 2017

Was this article helpful?