The EDD_SL_Plugin_Updater
package provides a convenient way to connect your plugin with a licensing server and handle updates seamlessly. It allows you to define the necessary parameters, such as API URL, plugin file path, version, license key, product ID, and author information, which are used for communication with the licensing server.
Add as a requirement using composer:
composer require heymehedi/edd-sl-plugin-updater
Or add it manually to the composer.json file:
{
"require": {
"heymehedi/edd-sl-plugin-updater": "dev-master"
}
}
Loading and initializing
This code block represents the updater functionality for the Login Me Now Pro plugin. It ensures that the plugin stays up-to-date by integrating with the EDD_SL_Plugin_Updater class. The code is contained within the Updater
class, which defines the necessary properties such as the API URL, plugin file path, version, product ID, author, and license key.
/**
* Login Me Now Pro Updater.
*
* @package Login Me Now
* @since 1.0.0
* @version 1.0.0
*/
namespace Login_Me_Now_Pro;
use HeyMehedi\EDD_SL_Plugin_Updater;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
defined( 'ABSPATH' ) || exit;
/**
* Class Updater
*
* @since 1.0.0
*/
class Updater {
public $api_url;
public $plugin_file;
public $version;
public $product_id;
public $author;
public $lic_key;
public function __construct() {
$this->api_url = 'https://loginmenow.com';
$this->plugin_file = LOGIN_ME_NOW_PRO_BASE_FILE;
$this->version = LOGIN_ME_NOW_PRO_VERSION;
$this->product_id = '1212';
$this->author = 'Login Me Now';
$this->lic_key = get_option( 'my_plugin_license' );
add_action( 'admin_init', array( $this, 'init_updater' ) );
}
public function init_updater() {
$updater = new EDD_SL_Plugin_Updater(
$this->api_url,
$this->plugin_file,
array(
'version' => $this->version,
'license' => $this->lic_key,
'item_id' => $this->product_id,
'author' => $this->author,
'beta' => false,
)
);
}
}
new Updater();