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.
- WooCommerce product configuration
- 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.
- Copy and include the client update library into your plugins directory.
- Initialize the software license class in your MAIN plugin file.
require_once plugin_dir_path( __FILE__ ) . 'path/to/class-wc-software-license-client.php';
return WC_Software_License_Client::get_instance( 'http://yourshopurl.here.com', 1.0.0, 'your-text-domain', __FILE__, 'My Cool Plugin' );
} // wcslc_instance()
|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|
|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:
- Edit the WooCommerce Product.
- Provide an updated plugin zip file.
- Adjust the version to the new version
- Update last updated field
- Update the changelog.
- Save your product and the new version will show up as an available update.
- 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.