Software Licensing - Minimum Requirements

Software Licensing 3.8 introduced the ability to set minimum platform requirements for products. If a customer doesn't meet those requirements, they won't be given automatic updates through the API.

API prerequisites

In order for this feature to work properly, the customer's platform versions need to be sent along with the API request that checks for an update.

If you're using our plugin updater, that means your product needs to be bundling version 1.9 or greater of the EDD_SL_Plugin_Updater class file.

If you're using our theme updater, your product needs to be bundling version 1.2 or greater.

If you've built a custom integration, you need to make sure to include "php_version" and "wp_version" in your API request. Consult our API documentation for more details.

If a customer's site does not include the platform version(s) in the API request then those requirements will not be checked and the user may still receive the update.

Configuring requirements for a product

To configure requirements for a product, edit the product via Downloads > Edit. On the right sidebar, search for a metabox called "Download Requirements". It looks like this:

Download requirements metabox

Simply enter your minimum required versions and save. Any versions left blank will not be checked or required.

Adding custom requirements

By default Software Licensing supports PHP and WordPress versions, though your own dependencies can be added with some custom code. Two steps are required:

1. Add your dependency to the metabox

Adding a new dependency is done with a simple filter like this, which needs to be added to your own site:

add_filter( 'edd_sl_platforms', function( $platforms ) {
	$platforms['your-platform-id'] = 'Your Platform Display Name';
	
	return $platforms;
} );

Replace your-platform-id with a unique, slug-friendly version of your dependency name, and replace Your Platform Display Name with the display-friendly version. Here's an example of adding Easy Digital Downloads as a requirement:

add_filter( 'edd_sl_platforms', function( $platforms ) {
	$platforms['easy-digital-downloads'] = 'Easy Digital Downloads';

	return $platforms;
} );

Once added, your platform will appear in the metabox:

Platform requirements, with Easy Digital Downloads as a custom option

2. Include the dependency version in your API request

When checking for a new update via the API (within your product), you need to send the dependency's current version number in the API request. To do that, you simply have to append a new argument: {your platform ID}_version.

A version check request normally looks like this:

https://YOURSITE.com/?edd_action=get_version&item_id=8&license=cc22c1ec86304b36883440e2e84cddff&url=http://licensedsite.com

But with our new argument, it would look like this:

https://YOURSITE.com/?edd_action=get_version&item_id=8&license=cc22c1ec86304b36883440e2e84cddff&url=http://licensedsite.com&easy-digital-downloads_version=1.0

Note the addition of &easy-digital-downloads_version=1.0 at the end.

If you're using a custom updater, you can add the new argument directly to the API parameters sent with the request:

$api_params = array(
	'edd_action'                     => 'get_version',
	'license'                        => ! empty( $data['license'] ) ? $data['license'] : '',
	'item_name'                      => isset( $data['item_name'] ) ? $data['item_name'] : false,
	'item_id'                        => isset( $data['item_id'] ) ? $data['item_id'] : false,
	'version'                        => $this->version,
	'slug'                           => $data['slug'],
	'author'                         => $data['author'],
	'url'                            => home_url(),
	'beta'                           => ! empty( $data['beta'] ),
	'php_version'                    => phpversion(),
	'wp_version'                     => get_bloginfo( 'version' ),
	'easy-digital-downloads_version' => defined( 'EDD_VERSION' ) ? EDD_VERSION : '', // current version number
);

If you're using our plugin updater class (version 1.9 or greater), then you can add this argument to the API request by using a filter. This filter needs to be part of your plugin, as it runs on your customers' sites:

add_filter( 'edd_sl_plugin_updater_api_params', function( $api_params, $api_data, $plugin_file ) {
	/*
	 * Make sure $plugin_file matches your plugin's file path. You should have a constant for this
	 * or can use __FILE__ if this code goes in your plugin's main file.
	 */
	if ( __FILE__ === $plugin_file ) {
		// Dynamically retrieve the current version number.
		$api_params['easy-digital-downloads_version'] = defined( 'EDD_VERSION' ) ? EDD_VERSION : '';
	}

	return $api_params;
}, 10, 3 );

Be sure to replace easy-digital-downloads with the unique ID you've chosen for your dependency, and defined( 'EDD_VERSION' ) ? EDD_VERSION : '' with the current version number. This value needs to be able to be dynamically retrieved by the customer site.