If you’ve ever created a plugin for WordPress and wanted to sell it you’ve likely run in to the problem of delivering updates to your customers. Agencies and internal developers run in to this problem as well. You can’t upload your plugin to the WordPress.org repository because then it will be free for everyone, but you still really want integrated update functionality.
Kernl.us is a SaaS product that helps solve this problem (and so many others!). Kernl allows you to distribute updates to your premium plugin automatically using the built-in WordPress update functionality. So how does it work?
- Sign up for Kernl
- Create an entry for your plugin in Kernl
- Add 2 lines of code to your plugin.
- Upload your plugin to Kernl and then distribute it to your customers
Lets dive in an see how this works!
Creating a Plugin in Kernl
After you’ve signed up for Kernl, the first step to configure seamless automatic updates is to create a plugin entry in Kernl. To do so, click the “Plugins” button in the left-hand menu.
Next, click the “Add Plugin” button.
The next step is easy. Just enter the name, slug, and description of your plugin then press “Save”.
Adding Kernl Update Code
Now that you have a plugin entry in Kernl, you can add the Kernl update code to your plugin. Download the Kernl plugin update code from https://kernl.us/static/php/plugin_update_check.php. and place it in the root directory of your plugin. Next, take note of the UUID of the plugin that you just created.
In your plugin’s main file, add the following code:
require 'plugin_update_check.php'; $MyUpdateChecker = new PluginUpdateChecker_2_0 ( 'https://kernl.us/api/v1/updates/MyUuidFromKernl/', __FILE__, 'kernl-example-plugin', 1 );
Replace “MyUuidFromKernl” with the UUID of the plugin you just created.
Uploading Your Plugin to Kernl
Now that you have Kernl inside of your plugin you need to zip it up. At the folder level, go ahead and zip the plugin using the zip tool of your choice.
If you were to extract your plugin, it should look like:
/my-plugin-slug plugin_update_check.php functions.php someOtherFile.php
If it looked like this (notice there is no nesting), Kernl will not work:
plugin_update_check.php functions.php someOtherFile.php
Take your plugin and click “Add Version” inside Kernl.
Next enter the version number (of the format MAJOR.MINOR.PATCH, ex 1.4.14), select the zip file you just created, and press “Save”.
Distribute Your Plugin
Now that Kernl has this version of your plugin, feel free to distribute this ZIP file to your customers. If you ever need to release an update, just make your code changes, zip them up, and upload the new version to Kernl. Within 30 seconds the update will be visible to your customers at which point they can download it!