This is a lite version of the main Freemius SDK, specifically developed for use in Duck Dev WordPress plugins. This library focuses exclusively on managing plugin license activation, deactivation, and updates. It does not provide any user interface, so your plugin will need to create its own UI and use this library to handle the logic.
- PHP version 7.4 or higher.
- WordPress 5.0+
This library should be installed and included in your WordPress plugin using Composer.
composer require duckdev/freemius-plugin-licensingInitialize the Freemius SDK by calling the static DuckDev\Freemius\Freemius::get_instance() method with your plugin's
details.
// Assuming Composer's autoload.php has been included.
$freemius = DuckDev\Freemius\Freemius::get_instance(
12345, // Your Freemius product ID.
array(
'slug' => 'loggedin', // Your plugin's unique Freemius slug.
'main_file' => LOGGEDIN_FILE, // The path to your plugin's main file.
'public_key' => 'pk_XXXXXXXXXXXXXXXXX', // Your plugin's public key.
)
);To activate a license, call the activate() method on the license() object with the user's license key.
$freemius->license()->activate( 'XXXX-XXXX-XXXX' );To deactivate a license, simply call the deactivate() method.
$freemius->license()->deactivate();The library will automatically handle plugin updates as long as a valid license is active. No additional code is required to check for and apply updates.