Skip to main content
Easy Digital Downloads Documentation
Documentation, Reference Materials, and Tutorials for Easy Digital Downloads

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
    'item_id'        => '', // The ID of the download on the storefront site
),

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.

Important notes

  • The code shown on this page is purely for demonstrative purposes and is not meant to be used as is. Do not copy and paste it into your plugin and expect it to work as is.
  • All function names added to your plugin need to get a unique prefix. We have used edd_sample_ throughout this example. Do not keep edd_sample_ in your own plugin, replace it with your own unique prefix.
  • The names of the constants must be changed. Do not keep them as EDD_SL_ITEM_ID and EDD_SL_STORE_URL. Use your own unique constants.
  • If you have issues with SSL verification when requesting updates, you can use the `edd_sl_api_request_verify_ssl` filter to disable the SSL Verification flag.

Updating Child Themes

When using automatic updating with EDD’s Software Licensing you must have an /updater/ folder in your theme folder, and it must contain a theme-updater-class.php file.

For child themes that theme-updater-class.php file needs a minor adjustment. On line 24 you’ll find 'theme_slug' => get_template(),

get_template() must be changed to get_stylesheet() for Child Themes, so that it looks like this:

Inside your child theme functions.php file you will also have to make a change:

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

Change get_template_directory to get_stylesheet_directory

Read our latest blog post:
How to Make a WordPress eCommerce Website