heymehedi / edd-sl-plugin-updater
WordPress插件EDD更新处理器
v1.0.1
2023-06-23 04:17 UTC
Requires
- php: >=5.6.20
- ext-json: *
This package is auto-updated.
Last update: 2024-09-23 06:53:02 UTC
README
此库应在EDD上销售的可添加组件或插件中使用。它处理与WordPress站点的Easy Digital Downloads集成的插件的更新。
要求
此类只能在EDD v1.7及更高版本中使用。
如何使用
安装
使用Composer添加要求
$ composer require heymehedi/edd-sl-plugin-updater
或手动将其添加到composer.json文件中
{ "require": { "heymehedi/edd-sl-plugin-updater": "dev-master" } }
加载和初始化
用法1
add_action('admin_init', 'init_updater'); function init_updater() { $api_url = 'https://loginmenow.com'; // The site for the EDD store. $plugin_file = 'your-plugin/your-plugin.php'; // The version of your add-on/plugin. $current_version = '1.0.5'; $product_id = '3252'; // ID for the add-on/plugin on EDD. $author = 'Your Name'; // Initialize the library. $updater = new HeyMehedi\EDD_SL_Plugin_Updater( $api_url, $plugin_file, [ 'version' => $current_version, 'license' => get_option( 'my_plugin_license' ), 'item_id' => $product_id, 'author' => $author, 'beta' => false, ] ); }
用法2
/** * 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();