This library allows you to distribute WordPress plugins with automatic updates from your own Hizzle Licenses licensing server.
- Flexible Configuration: Works with any custom licensing server in addition to Hizzle Licenses
- License Management: Built-in license activation/deactivation system
- Automatic Updates: Integrates seamlessly with WordPress's update system
- REST API: Optional REST endpoints for license management
- Secure: Follows WordPress best practices and security standards
Install via Composer:
composer require hizzle/wp-plugin-updatesIn your main plugin file, initialize the library with your server configuration:
<?php
/**
* Plugin Name: My Plugin
* Plugin URI: https://myplugin.com
* Description: Example plugin using Hizzle Licenses updater library
* Version: 1.0.0
* Author: Your Name
* Author URI: https://yourwebsite.com
* Text Domain: my-plugin
* Domain Path: /languages/
* Requires at least: 5.5
* Requires PHP: 7.0
* Update URI: your-licensing-server.com/your-plugin-slug
*/
// Update URI above is required for WordPress to recognize this plugin as updateable from your server. It should match the hostname of your licensing server.
defined( 'ABSPATH' ) || exit;
// Include the auto loader.
require 'vendor/autoload.php';
// Initialize with your server configuration
$updater = \Hizzle\WP_Plugin_Updates\Main::instance(
'your-licensing-server.com', // Hostname of your licensing server.
array(
'prefix' => 'my_prefix', // Optional prefix for options and transients (default: 'your_licensing_server_com').
)
);
// Register your plugin.
$updater->add( __FILE__, 'github-org/your-plugin-slug', admin_url( 'admin.php?page=my-plugin-license' ) );Your licensing server needs to implement the following endpoints:
GET your-licensing-server.com/wp-json/hizzle/v1/licenses/{license_key}/?website={site_url}&downloads={plugins}
Where downloads is a comma-separated list of plugin identifiers (e.g. github-org/your-plugin-slug,github-org/another-plugin).
Response should include:
{
"license": {
"is_active_on_site": true,
// ... other license details
}
}POST your-licensing-server.com/wp-json/hizzle/v1/licenses/{license_key}/activate
Body:
{
"website": "https://example.com",
"downloads": "github-org/your-plugin-slug,github-org/another-plugin"
}As usual, downloads is a comma-separated list of plugin identifiers that the license should be activated for.
POST your-licensing-server.com/wp-json/hizzle/v1/licenses/{license_key}/deactivate
Body:
{
"website": "https://example.com",
"downloads": "github-org/your-plugin-slug,github-org/another-plugin"
}GET your-licensing-server.com/wp-json/hizzle_download/v1/versions?hizzle_license={key}&hizzle_license_url={home_url}&downloads={plugins}
Where downloads is a comma-separated list of plugin identifiers (e.g. github-org/your-plugin-slug,github-org/another-plugin).
Response should include version info for each plugin:
{
"plugin-identifier": {
"version": "1.2.0",
"download_link": "https://...",
"requires_php": "5.6",
"name": "Plugin Name",
"description": "...",
// ... other plugin info
}
}- Leave download_link empty if the license is not valid or does not have access to updates.
- If you have both the Hizzle Downloads and Hizzle Licenses plugins installed, it will automatically handle the version check and license validation for you.
The library sends the plugin identifiers you provide (e.g. github-org/your-plugin-slug) to the licensing server for license validation and version checks. This is useful if you sell multiple plugins and want to manage them under the same license server.
- All API requests include proper authentication headers
- License keys are sanitized before storage
- Transient caching prevents excessive API calls
- Follows WordPress coding standards and security best practices
- PHP 5.6 or higher
- WordPress 5.0 or higher
GPL-3.0-or-later
For issues and feature requests, please use the GitHub issue tracker.