wp-forge/wp-update-handler
Composer 安装命令:
composer require wp-forge/wp-update-handler
包简介
A WordPress package for updating custom plugins and themes based on an API response from a custom update server.
README 文档
README
A WordPress package for updating custom plugins and themes based on an JSON REST API response from a custom update server.
Check out the WordPress GitHub Release API repository to learn how to quickly launch a custom update server that fetches releases from GitHub using Cloudflare Workers.
Plugins
This package expects your custom plugin info API to respond with the same shape as the WordPress plugin info API. However, if your API response has a different shape, you can map fields to those returned by your API.
Usage
Basic example:
<?php /** * Plugin Name: My Plugin */ require __DIR__ . '/vendor/autoload.php'; use WP_Forge\WPUpdateHandler\PluginUpdater; $url = 'https://my-update-api.com/plugins/plugin-name'; // Custom API GET endpoint new PluginUpdater( __FILE__, $url );
Advanced example with data mapping and data overrides:
<?php /** * Plugin Name: My Plugin */ require __DIR__ . '/vendor/autoload.php'; use WP_Forge\WPUpdateHandler\PluginUpdater; $file = __FILE__; // Can be absolute path to main plugin file, or the plugin basename. $url = 'https://my-update-api.com/plugins/plugin-name'; // Custom API GET endpoint $pluginUpdater = new PluginUpdater( $file, $url ); /* * Keys are the fields that WordPress is expecting (look at the WP Plugin Info API response). * Values are the keys returned by your custom API. * * Use dot notation to map nested keys. */ $pluginUpdater->setDataMap( [ 'requires' => 'requires.wp', 'requires' => 'requires.php', 'banners.2x' => 'banners.retina', ] ); /* * Explicitly set specific values that will be provided to WordPress. */ $pluginUpdater->setDataOverrides( [ 'banners' => [ '2x' => 'https://my.cdn.com/banner-123-retina.jpg', '1x' => 'https://my.cdn.com/banner-123.jpg', ], 'icons' => [ '2x' => 'https://my.cdn.com/icon-123-retina.jpg', '1x' => 'https://my.cdn.com/icon-123.jpg', ], ] );
Themes
This package expects your custom theme info API to respond with the same shape as the WordPress theme info API. However, if your API response has a different shape, you can map fields to those returned by your API.
Usage
Basic example:
<?php /** * Theme Name: My Theme */ require __DIR__ . '/vendor/autoload.php'; use WP_Forge\WPUpdateHandler\ThemeUpdater; $url = 'https://my-update-api.com/theme/theme-name'; // Custom API GET endpoint new ThemeUpdater( wp_get_theme('my-theme'), $url );
Advanced example with data mapping and data overrides:
<?php /** * Theme Name: My Theme */ require __DIR__ . '/vendor/autoload.php'; use WP_Forge\WPUpdateHandler\ThemeUpdater; $theme = wp_get_theme('my-theme'); // Get the theme's WP_Theme instance. $url = 'https://my-update-api.com/themes/theme-name'; // Custom API GET endpoint $themeUpdater = new ThemeUpdater( $file, $url ); /* * Keys are the fields that WordPress is expecting (look at the WP Theme Info API response). * Values are the keys returned by your custom API. * * Use dot notation to map nested keys. */ $themeUpdater->setDataMap( [ 'requires' => 'requires.wp', 'requires' => 'requires.php', 'banners.2x' => 'banners.retina', ] ); /* * Explicitly set specific values that will be provided to WordPress. */ $themeUpdater->setDataOverrides( [ 'banners' => [ '2x' => 'https://my.cdn.com/banner-123-retina.jpg', '1x' => 'https://my.cdn.com/banner-123.jpg', ], 'icons' => [ '2x' => 'https://my.cdn.com/icon-123-retina.jpg', '1x' => 'https://my.cdn.com/icon-123.jpg', ], ] );
wp-forge/wp-update-handler 适用场景与选型建议
wp-forge/wp-update-handler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 157.38k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2021 年 09 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 wp-forge/wp-update-handler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wp-forge/wp-update-handler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 157.38k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2021-09-29