2017 © Pedro Peláez
 

library license

An helper component for managing licenses

image

wbf/license

An helper component for managing licenses

  • Thursday, January 19, 2017
  • by Waga Dev
  • Repository
  • 3 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

License

A license manager for themes and plugins., (*1)

Simple usage

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)

Creating dashboard interface

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)

Lock theme updates with license

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
        //...
    }
}

Lock plugins updates with

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)

The Versions

19/01 2017

dev-master

9999999-dev http://www.waga.it

An helper component for managing licenses

  Sources   Download

GPL-2.0+

The Requires