Updater with License Code (Plugin)

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

Use this license key for reference JGGJ450VID9C6P89DGTB066Q9

 

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: Copy this “licenses” folder and paste it as it is inside your plugin’s root directory as shown below:

Step 4: If your plugin name is XYZ then you should have xyz.php file in your plugin folder. Now, open your plugin’s xyz.php file and add following code at the top of it.

add_action('init', 'wpdigipro_plugin_license_checker');
 function wpdigipro_plugin_license_checker(){
   if(!class_exists('WPDigiPro_Plugin_License_Adapter')):
     require_once('licenses/wpdigipro-adp.php');
   endif;
   $request_args = array(
     'menu_slug' => 'menu_slug',
     'plugin_slug'=>'plugin_slug',
     'textdomain'=>'textdomain',
     'plugin_path'=> plugin_dir_path (absolute), // plugin_dir_path(__FILE__).basename(__FILE__)
     'remote_url'=>'REMOTE URL', 
     'item_reference'=>'REFRENCE ID',
 );
 $license_data = new WPDigiPro_Plugin_License_Adapter($request_args);
 $wpdigipro_license_data = $license_data->WPDigiPro_Plguin_Get_License_Code();
 
 if (isset($wpdigipro_license_data->license_status) && ($wpdigipro_license_data->license_status == 'active')) {
 // license active
 } else {
 // license not active
 }
}

Once added, as shown below in your text editor change following five variables.

i) menu_slug : In the xyz.php file search for add_menu_page. In the string the fourth variable will be menu slug.

ii) plugin_slug : If your plugin’s folder name is pluginfoldername, then you need to place it here as shown below.

iii) textdomain : In your xyz.php in the comment area you’ll find textdomain.

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

v) item_reference : This is the product ID of your product. If it’s 122, place it as 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 5: Once all the variables are added, save the file and now your plugin will be license protected.

Was this article helpful to you? Yes No

How can we help?