Similarly, For themes the configuration are similar as for plugin. The sample theme folder named – sparkle-edd-sample-theme are included in samples folder already. Please checkout the following for code implementation
Please keep the following function and actions to your theme’s function.php file.
function sparkle_edd_theme_updater() {
require( get_template_directory() . '/theme-updater/sparkle-theme-updater.php' );
}
add_action( 'after_setup_theme', 'sparkle_edd_theme_updater' );
Add the folder theme-updater to your themes root folder. The folder contains 3 files.
sparkle-theme-updater.php
seddl-theme-updater-admin.php
seddl-theme-updater-class.php
Inside the sparkle-theme-updater.php class please configure the plugin settings as per your need.
$updater = new SparkleEDDThemeUpdaterAdmin(
// Config settings
$config = array(
'remote_api_url' => 'http://youshopurl.com/', // Site where Our Sparkle EDD Licensing is hosted
'item_name' => 'Theme Name', // Name of theme
'theme_slug' => 'sparkle-edd-sample-theme', // Theme slug
'version' => '1.0.0', // The current version of this theme
'author' => 'Sparkle Themes', // 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
'product_id' => '358', // set the product id here *important
)
);
Please configure remote_api_url, theme_slug, version, product_id properly as it may affect the working of theme updates available for download.
After configure those variables you need to create a page for license validation.
inside seddl-theme-updater-admin.php file there you will find a action for adding a menu
add_action( 'admin_menu', array( $this, 'sparkle_sample_theme_license_menu' ) );
This will include a method – ‘sedd_license_page’ for display of license activation page. You can just copy the function and can use it. You can change the options name as per your need.
In this page at first the user need to save the license key first so that the license key will be stored in options table then only they will be able to activate the license key.
Now when user click on activate button the response will be returned based on license key saved.
Thanks