|
1 | | -# Plugin Licensing |
2 | | -A premium licensing module developed exclusively for Duck Dev plugins. |
| 1 | +# Freemius Plugin Licensing |
| 2 | + |
| 3 | +This is a lite version of the main Freemius SDK, specifically developed for use in Duck Dev WordPress plugins. This |
| 4 | +library focuses exclusively on managing plugin license activation, deactivation, and updates. It does not provide any |
| 5 | +user interface, so your plugin will need to create its own UI and use this library to handle the logic. |
| 6 | + |
| 7 | +## Requirements |
| 8 | + |
| 9 | +* PHP version 7.4 or higher. |
| 10 | +* WordPress 5.0+ |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +This library should be installed and included in your WordPress plugin using Composer. |
| 15 | + |
| 16 | +```console |
| 17 | +composer require duckdev/freemius-licensing-sdk |
| 18 | +``` |
| 19 | + |
| 20 | +## Usage |
| 21 | + |
| 22 | +### Initialization |
| 23 | + |
| 24 | +Initialize the Freemius SDK by calling the static `DuckDev\Freemius\Freemius::get_instance()` method with your plugin's |
| 25 | +details. |
| 26 | + |
| 27 | +```php |
| 28 | +// Assuming Composer's autoload.php has been included. |
| 29 | +$freemius = DuckDev\Freemius\Freemius::get_instance( |
| 30 | + 12345, // Your Freemius product ID. |
| 31 | + array( |
| 32 | + 'slug' => 'loggedin', // Your plugin's unique Freemius slug. |
| 33 | + 'main_file' => LOGGEDIN_FILE, // The path to your plugin's main file. |
| 34 | + 'public_key' => 'pk_XXXXXXXXXXXXXXXXX', // Your plugin's public key. |
| 35 | + ) |
| 36 | +); |
| 37 | +``` |
| 38 | + |
| 39 | +### License Activation |
| 40 | + |
| 41 | +To activate a license, call the `activate()` method on the `license()` object with the user's license key. |
| 42 | + |
| 43 | +```php |
| 44 | +$freemius->license()->activate( 'XXXX-XXXX-XXXX' ); |
| 45 | +``` |
| 46 | + |
| 47 | +### License Deactivation |
| 48 | + |
| 49 | +To deactivate a license, simply call the `deactivate()` method. |
| 50 | + |
| 51 | +```php |
| 52 | +$freemius->license()->deactivate(); |
| 53 | +``` |
| 54 | + |
| 55 | +### Updates |
| 56 | + |
| 57 | +The library will automatically handle plugin updates as long as a valid license is active. No additional code is |
| 58 | +required to check for and apply updates. |
0 commit comments