Updater with License Code (Theme)

First read the below guide to add license & update feature in your theme. We have attached a demo theme for you to play around, which you can download it from here.

Use this license key for reference Z580Y99DDJ1TUBUN3FBWRZSCO

 

Step 1: Click here to download this zip file which contains the licensing and updater code.

Step 2: Unzip this file to get “licenses” folder.

Step 3: Open “licenses” folder and then open wpdigipro-adapter.php file in your text editor as shown below and change three variables:

i) WPDIGIPRO_REMOTE_URL: As shown below, if your website URL is yourwebsitedomain.com then you need to place it in this variable.

ii) WPDIGIPROTHEME_DIRECTORY_NAME: If your theme’s folder name is themefoldername, then you need to place it here as shown below.

iii) WPDIGIPROTHEME_REFERENCE: This is the product ID of your product. If it’s 21, place it as shown below.

 

How do you find product ID?
It’s simple.
1. Click on all products.
2. Mouse hover on the EDIT link of the product whose product ID you want. Then click on EDIT link. You will find the product ID in the URL of your browser. So, if the URL comes as:
https://yourwebsite.com/wp-admin/post.php?post=122&action=edit
then 122 is the product ID.

Step 4: Now after making the above 3 changes in your wpdigipro-adapter.php file,  Copy this “licenses” folder and paste it as it is inside your theme’s root directory as shown below:

Step 5: Now open your theme’s functions.php file and add following lines at the top of it. You just need to replace yourtextdomain with your theme’s text domain.

require get_template_directory() . '/licenses/wpdigipro-adp.php';
$theme_license = new WPDigiPro_Theme_License_Adapter('themes.php', 'yourtextdomain');
$license_data = $theme_license->WPDigiPro_Theme_Get_Code();

Just to give you a visual idea, we’re using this in our theme whose text domain is “icoach” and our theme’s functions.php file looks like:

 

Step 6: Conditional statements will use following functions:

if (isset($wpdigipro_license_data->license_status) && 
($wpdigipro_license_data->license_status == 'active')) {
	// code which will run if license is active
} else {
	// code which will run if license is not active
}

You can use these statements to lock particular functionality which you want to run only when license is successfully activated by your buyers.

Was this article helpful to you? Yes No

How can we help?