Software Licensing - Updater Implementation for WordPress Themes

With the  Software Licensing extension for Easy Digital Downloads you can set up automatic upgrades for themes.  This does not mean that your customer's theme will update itself but rather that your customer may update their theme using the traditional WordPress update tools, as if the theme were hosted on WordPress.org.

Setup

In your  Software Licensing extension is a directory called /samples/edd-sample-theme/updater/. This folder needs to be copied into your theme's main folder.

Then place the following code into your theme's functions.php:

/**
 * Load theme updater functions.
 * Action is used so that child themes can easily disable.
 */

function prefix_theme_updater() {
    require( get_template_directory() . '/updater/theme-updater.php' );
}
add_action( 'after_setup_theme', 'prefix_theme_updater' );

Please change the prefix to something that matches your theme. This code includes the updater code.

Configure Updater

Edit /updater/theme-updater.php and put in the proper values for these array elements:

$config = array(
    'remote_api_url' => 'https://easydigitaldownloads.com', // Site where EDD is hosted
    'item_name'      => 'Theme Name', // Name of theme
    'theme_slug'     => 'theme-slug', // Theme slug
    'version'        => '1.0.0', // The current version of this theme
    'author'         => 'Easy Digital Downloads', // The author of this theme
    'download_id'    => '', // Optional, used for generating a license renewal link
    'renew_url'      => '', // Optional, allows for a custom license renewal link,
    'beta'           => false, // Optional, set to true to opt into beta versions
),

Additionally, in the same file, change the edd-theme-updater text-domain to match that of your theme. Example:

    // Strings
    $strings = array(
        'theme-license'             => __( 'Theme License', 'edd-theme-updater' ),

Packaging and Sale

Your theme should be zipped just like any other theme, there's no difference. Then create a new Download in Easy Digital Downloads.

Complete everything as you would a normal product, uploading your theme and giving it a price etc.

Then be sure to check the box to enable licensing. This is key to the update process.

Most of the settings in the Licensing meta box can be set to whatever you like, but the version number is important. When you increment the version number it will alert your customer's sites that there's a new version. For your initial version pick something and then only make it larger when it's time for a new version. Example: start at 1.0 and then only go to 1.1 when you want everyone to get a new version.

Updating your theme

When you choose to release a new version, replace the old file with the new one. Then enter some text into the Changelog field in the Licensing meta box. Lastly, increment the version number and save the download. Then your customer's sites will be notified that there's a new version, and they will be able to click Update.

Beta versions

As of version 3.5 of Software Licensing, it is possible to release beta versions of your theme. See the  documentation on how to release beta versions.

In order for customers to receive beta version notifications, 'beta' => true must be supplied in the $config array shown above. If you wish for your customers to have a way to opt into beta version, you will need to supply an interface for that. We recommend adding a checkbox to your theme settings page that allows customers to opt into beta versions. You can then set the beta flag in the config array dynamically based on the checked state of that checkbox.