Skip to content
Kirby 5 is here! Learn more

Plugin licenses

Plugin licenses are now shown in the plugins table with an additional column to indicate their status. Licenses can link to their license document, a custom license shop or open a custom dialog to activate the license. #6738

Defining a plugin license as simple array

This is great if you want to point to your own license document.

Kirby::plugin(
  name: 'my/plugin',
  extends: [...],
  license: [
    'name'   => 'Custom license',
    'link'   => 'https://mylicenseshop.com',
    'status' => 'active',
  ]
);

Setting a custom status

Kirby::plugin(
  name: 'my/plugin',
  extends: [...],
  license: [
    'name' => 'Custom license',
    'status' => [
      'value' => 'missing',
      'theme' => 'negative',
      'label' => 'Get a license please',
      'icon'  => 'alert'
      'link'  => 'https://mylicenseshop.com',
    ]
  ]
);

A custom license for your plugin

You can also pass a license object. Extend our Kirby\Plugin\License class to return a custom status, theme, icon and label, depending on the state of your plugin’s license. You can also set a link or your custom dialog's/drawer's endpoint. This is great if you are working with a proprietary license for your plugin, which might still need to purchased/activated by the user.

use Kirby\Plugin\License;
use Kirby\Plugin\LicenseStatus;
use Kirby\Plugin\Plugin;

class MyCustomLicense extends License
{
  public function __construct(
    protected Plugin $plugin
  ) {
    $this->name = 'My Custom License';
    $this->link = '<https://mylicenseshop.com>';
    $this->status = new LicenseStatus(
      value: 'missing',
      theme: 'negative',
      label: 'Get a license please',
      icon: 'alert',
      dialog: 'my/dialog/endpoint'
    )
  }
}

Kirby::plugin(
  name: 'my/plugin',
  extends: [...],
  license: fn (Plugin $plugin) => new MyCustomLicense($plugin)
);