dev-master
9999999-dev http://www.waga.itAn helper component for managing licenses
GPL-2.0+
The Requires
by Waga Team
An helper component for managing licenses
A license manager for themes and plugins., (*1)
You first need to create a license class by extending WBF\components\license\License and implementing WBF\components\license\License_Interface, then you can register this license with the License Manager:, (*2)
$l = new YourLicense(); \WBF\components\license\License_Manager::register_theme_license($l);
And that's it! WBF will detect your new license and allows user to enter their license code through the dashboard., (*3)
If you are using WBF as plugin the admin interface will be automatically created for you. If this is not the case you have to do it yourself., (*4)
You can look at the WBF implementation in License_Manager class:, (*5)
perform_page_actions()
=> saves input data, (*6)
admin_license_menu_item()
=> adds the menu item, (*7)
license_page()
=> display the admin page., (*8)
If you use the WBF Custom Updater, you can use an hook or two to lock the updates once your license is registered., (*9)
In your License constructor:, (*10)
add_filter("wbf/custom_theme_updater/can_update", [$this, "allow_updates"], 10, 2); add_action("wbf/custom_theme_updater/after_update_inject", [$this, "show_update_notice"], 10, 2);
Then, in your License class:, (*11)
public function allow_updates($can_update, Theme_Update_Checker $checker){ if(!$this->is_valid()){ $can_update = false; } return $can_update; } public function show_update_notice(Theme_Update_Checker $checker, $can_update){ if(!$can_update){ $message = sprintf(__( 'A new version of %s is available! <a href="%s" title="Enter a valid license">Enter a valid license</a> to get latest updates.', 'wbf' ),"my-theme","admin.php?page=wbf_licenses"); //Show notice whatever you like //... } }
For now WBF alone does not automatically binds plugins licenses to update mechanism. On the other hand Plugins Framework does it within the set_update_server()
method., (*12)
[...], (*13)
An helper component for managing licenses
GPL-2.0+