webnestors / wp-packager
1.0.2
2022-06-24 19:58 UTC
README
警告:该项目当前不稳定。新版本可能会破坏兼容性
为您的WordPress插件提供插件信息,并将其附加到WordPress更新API上,以便插件可以无缝或自动更新,就像它们托管在wordpress.org上一样。
可与您自己的服务器或姐妹项目WP-Packager Server一起使用。
特性
- 与WordPress核心更新API集成,具有原生功能。
- 显示插件信息,如标题、描述、更新日志、最后更新等。
- 可以连接到任何提供有效JSON架构的服务器。
- 支持使用许可证密钥的付费(受限)下载,在下载包时使用自定义HTTP头。
- 目前仅支持插件。
用法
将其用作您插件的库
<?php
$remote_url = "https://my.domain.com/plugin/myplugin";
$slug = "myplugin";
$basename = "myplugin/myplugin.php";
$current_version = "1.0.0";
$updater = Webnestors\WPPackager\Updater::get_plugin_updater($remote_url, $slug, $basename, $current_version);
$updater->init();
您可以在下载请求中附加自定义许可证密钥头
<?php
// ...
$updater
// Placing '##WP-Packager-License##' as the license key will automatically
// replace that value with the actual key when using the wp-packager/server
// 'plugin/id/download' endpoint when downloading the package
->set_license_key('##WP-Packager-License##')
// Default
->set_license_header('WP-License')
->init();
// ...
如果服务器位于基本HTTP身份验证之后
<?php
// ...
$allow_unsecure = false;
$updater
->set_basic_auth('username', 'password', $allow_unsecure)
->init();
// ...
如果您不想在下载期间拒绝不安全的URL(不安全的http)
<?php
// ...
$updater
->set_reject_unsafe(false)
->init();
// ...