-
Notifications
You must be signed in to change notification settings - Fork 1
Theme Integration
Ashley Gibson edited this page Jul 13, 2021
·
2 revisions
A bare bones theme might start out like this:
sample-theme/
style.css
index.php
functions.php
Download a zip file of the SDK and extract it. You'll have a folder called edd-sl-sdk-main
with the contents inside. Move this file into your theme folder, so your theme will look something like this:
sample-theme/
style.css
index.php
functions.php
edd-sl-sdk-main/
src/
assets/
composer.json
You may rename the edd-sl-sdk-main
directory to whatever you like, but do not modify the contents inside that directory.
Include the SDK by adding this in your theme's functions.php file:
require_once dirname( __FILE__ ) . '/edd-sl-sdk-main/src/Loader.php';
For a theme, here are the bare minimum settings:
add_action( 'edd_sl_sdk_loaded', function ( \EDD_SL_SDK\SDK $sdk ) {
try {
$sdk->registerStore( [
// API URL: Replace `yoursite.com` with the domain of the site that has Software Licensing installed.
'api_url' => 'https://yoursite.com/wp-json/edd-sl/v2',
// Author: Your company's name.
'author' => 'Sandhills Development, LLC',
'products' => [
[
'type' => 'theme',
// Product ID: ID of the Software Licensing product this plugin corresponds to.
'product_id' => 9,
// License menu
'menu' => true
],
],
] );
} catch ( \Exception $e ) {
}
} );
This will automatically add a new license page to Appearance > Theme License, which handles license key activation and deactivation.
For a full list of arguments, see here: https://github.com/easydigitaldownloads/edd-sl-sdk#store-arguments