Download the PHP package duckdev/freemius-plugin-licensing without Composer
On this page you can find all versions of the php package duckdev/freemius-plugin-licensing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download duckdev/freemius-plugin-licensing
More information about duckdev/freemius-plugin-licensing
Files in duckdev/freemius-plugin-licensing
Package freemius-plugin-licensing
Short Description Lite version of the Freemius SDK for managing plugin licensing and updates using Freemius APIs, specifically developed for use with Foxe Labs plugins.
License GPL-2.0+
Homepage https://github.com/foxelabs/wp-freemius-client
Informations about the package freemius-plugin-licensing
Freemius Plugin Licensing
A lite, UI-free Freemius SDK for Duck Dev WordPress plugins. The library handles license activation, deactivation, update delivery, and addon listing by talking to the Freemius API directly. It deliberately ships no admin screens — host plugins build their own UI and call into this library for the underlying logic.
📖 Full documentation: docs.duckdev.com/wp-libraries/freemius-plugin-licensing/overview
Requirements
- PHP 7.4 or higher
- WordPress 5.0+
- Composer
Installation
The library autoloads under the DuckDev\Freemius\ namespace via PSR-4.
Architecture
The library is organised as a small dependency-injection container wired up by the entry class
DuckDev\Freemius\Freemius. The folder layout mirrors the namespace:
Each service receives its collaborators by constructor injection, so they can be unit-tested without WordPress in the
loop. Hook registration happens inside boot() (called once by the container), so simply instantiating the container
has no side effects.
Usage
Initialization
Initialise the container by calling Freemius::get_instance() with your Freemius product ID and an arguments array:
The supported arguments are:
| Key | Type | Description |
|---|---|---|
slug |
string |
Unique Freemius slug for the plugin. |
main_file |
string |
Absolute path to the plugin's main file (used for plugin_basename() and get_plugin_data()). |
public_key |
string |
Freemius public key (pk_…). Required for plugin-scoped endpoints (addons, info). |
is_premium |
bool |
Whether this build is the premium edition. Update hooks only register when true. Default false. |
has_addons |
bool |
Whether the product has addons to list. Default false. |
The first call to get_instance() creates the container and registers WordPress hooks. Subsequent calls for the same
plugin ID return the existing instance (the second argument is ignored after the first call).
License Activation
activate() returns true / false from the option update on success, or a WP_Error when the key is empty, the
plugin is not the premium build, the API call fails, or the response does not include an install ID.
License Deactivation
deactivate() refuses to proceed when the stored UID does not match the current site — that means the activation was
moved to another host, and we let the new host appear unlicensed rather than silently freeing the original seat.
Reading the Current Activation
get_activation() always returns an Activation value object — use is_empty() to detect the no-activation case.
Updates
Update hooks are registered automatically during boot() for premium builds. There is no manual integration needed —
WordPress will check for, display, and apply updates through its standard pipeline.
To force a refresh from the host plugin's UI:
Addons
Each entry is enriched with a link field (Freemius checkout URL) and an is_premium boolean. Use the
duckdev_freemius_format_addon_data filter to add or rewrite fields per addon.
Hooks
Actions
| Hook | Arguments | When |
|---|---|---|
duckdev_freemius_license_activated |
array $activation, bool $success |
After a successful activation. |
duckdev_freemius_license_deactivated |
array $activation, bool $success |
After a successful deactivation. |
Filters
| Hook | Arguments | Use |
|---|---|---|
duckdev_freemius_api_request_args |
array $args, string $method, string $url, array $data, array $headers |
Tweak the request arguments before they reach wp_remote_request(). |
duckdev_freemius_api_request_verify_ssl |
bool $verify, Client $client |
Disable SSL verification (typically only in local dev). |
duckdev_freemius_format_addon_data |
array $addon, Addon $service |
Rewrite or augment each addon entry before it is returned. |
Security Notes
- The library does not verify nonces or capabilities. Host plugins MUST do that before forwarding form input to
License::activate()/License::deactivate(). - The license key is stored in the
duckdev_freemius_activation_dataoption (an autoload-safe option keyed by plugin ID). It is blanked from storage on deactivation.
License
GPL-2.0+