ideologix/dlm-wp-updater

PHP WordPress 更新器,用于更新您的插件和主题,利用 Digital License Manager PRO REST API

1.3.2 2024-07-20 17:41 UTC

This package is auto-updated.

Last update: 2024-09-21 06:18:16 UTC


README

WordPress 的更新器包,利用 Digital License Manager PRO REST API 进行更新检查和更新下载。它可以集成到您想通过 Digital License Manager PRO 提供更新的任何插件中。

要求

  1. WordPress 4.0+
  2. 数字许可管理器 PRO (在您的插件更新服务器站点上)

配置

  1. 登录到您的数字许可管理器商店。
  2. 转到 "许可管理器" > "软件" > "添加新软件" 并创建软件项。
  3. 获取软件 ID,然后进行下一步 安装

安装

PHP 包可以通过 Composer 导入,也可以通过包含 autoload.php 文件手动导入

composer install ideologix/dlm-wp-updater

或手动导入,首先下载包并将其保存到您的插件中,然后按照以下方式包含它

require_once 'path/to/dlm-wordpress-updater/autoload.php';

集成

以下示例说明如何在您的 PRO/Premium 插件中使用此库。

use \IdeoLogix\DigitalLicenseManagerUpdaterWP\Main;

try {
    $instance = new Main( array(
        'id'              => 'The software ID',
        'name'            => 'The software Name',
        'file'            => '/path/to/wp-content/plugins/your-plugin/your-plugin.php', // Tip: use __FILE__ to define it in your-plugin.php
        'basename'        => 'your-plugin/your-plugin.php', // Tip: use plugin_basename( __FILE__ ) in your-plugin.php
        'version'         => YOUR_PLUGIN_VERSION, // Tip: Define this in your-plugin.php file and increment with every release.
        'url_settings'    => 'https://url-to-your-plugin/settings-page',
        'url_purchase'    => 'https://url-to-your-website/purchase-page',
        'consumer_key'    => 'ck_XXXXXXXXXXXXXXXXX',
        'consumer_secret' => 'cs_XXXXXXXXXXXXXXXXX',
        'api_url'         => 'https://yourwoocommercesite.com/wp-json/dlm/v1/',
        'prefix'          => 'dlm',
    ) );
} catch (\Exception $e) {
    error_log('Error: ' . $e->getMessage());
}

// Important: To display the activation form in your settings page (url_settings), use the renderActivationForm() method like bellow.
// Note: If you want to override the activation form, you can extend the Activator class with your own class and override the renderActivationForm() method.
$instance->getActivator()->renderActivationForm();