alledia/edd-sl-plugin-updater

WordPress 插件 EDD 更新处理器

v1.6.23 2023-08-30 19:32 UTC

README

这个库应该在 EDD 上销售的外部应用或插件中使用。它处理 WordPress 网站上与 Easy Digital Downloads 集成的插件的更新。

要求

此类只能与 EDD v1.7 及更高版本一起使用。

如何使用

安装

使用 composer 添加为需求

$ composer require alledia/edd-sl-plugin-updater 

或手动添加到 composer.json 文件中

{
  "require": {
    "alledia/edd-sl-plugin-updater": "dev-master"
  }
} 

加载和初始化

<?php
add_action('admin_init', 'init_updater');

function init_updater()
{
    // The site for the EDD store.
    $apiUrl         = 'https://site-with-edd.com';
    
    $pluginFile     = 'your-plugin/your-plugin.php';
    // The version of your add-on/plugin.
    $currentVersion = '1.0.5';
    // ID for the add-on/plugin on EDD.
    $addonEddId     = '3252';
    
    $author         = 'Your Name';
    
    // Initialize the library.
    $updater = new Alledia\EDD_SL_Plugin_Updater(
        $apiUrl,
        $pluginFile,
        [
            'version' => $currentVersion,
            'license' => get_option('upstream_frontend_edit_license_key'),
            'item_id' => $addonEddId,
            'author'  => $author,
            'beta'    => false,
        ]
    );
}