shazzad/plugin-updater
Composer 安装命令:
composer require shazzad/plugin-updater
包简介
A comprehensive WordPress plugin updater library that enables automatic updates, license verification, and remote plugin management for custom WordPress plugins.
README 文档
README
A comprehensive WordPress plugin updater library that enables automatic updates, license verification, and remote plugin management for custom WordPress plugins.
Features
- Automatic Plugin Updates: Seamlessly check for and install plugin updates from your remote server
- License Management: Built-in license key verification and validation system
- Admin Interface: Clean WordPress admin interface for license management
- Plugin Tracking: Track plugin activation, deactivation, and usage statistics
- WordPress Integration: Hooks into WordPress core update system
- Flexible Configuration: Customizable API endpoints, menu placement, and licensing options
Requirements
- WordPress 5.0 or higher
- PHP 7.4 or higher
- Valid API server endpoint for plugin updates and license verification
Installation
composer require shazzad/plugin-updater
Quick Start
<?php // Initialize the updater (autoloaded via Composer) new \Shazzad\PluginUpdater\Integration( 'https://your-api-server.com/api', // API URL plugin_basename( __FILE__ ), // Plugin file path 'your-product-id', // Product ID true, // Enable licensing true, // Display admin menu 'My Plugin License', // Menu label 'plugins.php', // Parent menu 10 // Menu priority );
File Structure
/src/
├── Integration.php # Core state, license helpers, and subsystem wiring
├── Client.php # API client with typed methods (ping, check_license, updates, details)
├── Updater.php # Update checks and WordPress integration
├── Admin.php # WordPress admin interface
└── Tracker.php # Plugin tracking and license sync
Configuration Options
Constructor Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
$api_url |
string | - | Required. Your API server URL |
$product_file |
string | - | Required. Plugin file path (e.g., "my-plugin/my-plugin.php") |
$product_id |
string | - | Required. Unique product identifier |
$license_enabled |
bool | false |
Enable license verification features |
$display_menu |
bool | true |
Show license settings in WordPress admin |
$menu_label |
string | '' |
Custom label for admin menu item |
$menu_parent |
string | '' |
Parent menu slug (defaults to 'plugins.php') |
$menu_priority |
int | 9999 |
Menu display priority |
Example Configurations
Basic Update Checking (No Licensing)
new \Shazzad\PluginUpdater\Integration( 'https://api.example.com', plugin_basename( __FILE__ ), 'my-plugin-id' );
Full Featured with Licensing and Metadata
( new \Shazzad\PluginUpdater\Integration( 'https://api.example.com', plugin_basename( __FILE__ ), 'my-plugin-id', true, // Enable licensing true, // Show admin menu 'My Plugin Updates', // Menu label 'tools.php', // Under Tools menu 20 // Menu priority ) )->setMeta( [ 'php_version' => function () { return phpversion(); }, 'theme' => function () { return get_stylesheet(); }, ] );
API Server Requirements
Your API server should provide the following endpoints:
Update Check Endpoint
GET /products/{product_id}/updates
Response:
{
"updates": {
"new_version": "2.1.0",
"package": "https://download-url.com/plugin.zip",
"url": "https://plugin-info-url.com",
"tested": "6.4",
"requires": "5.0",
"changelog": "Bug fixes and improvements"
}
}
Plugin Details Endpoint
GET /products/{product_id}/details
Response:
{
"details": {
"name": "My Plugin",
"version": "2.1.0",
"author": "Developer Name",
"homepage": "https://plugin-website.com",
"sections": {
"description": "Plugin description",
"changelog": "Version history",
"installation": "Installation instructions"
},
"download_link": "https://download-url.com/plugin.zip"
}
}
License Verification Endpoint
GET /products/{product_id}/check_license?license=LICENSE_KEY
Response:
{
"license": {
"status": "active",
"expires": "2024-12-31",
"customer_name": "John Doe",
"customer_email": "john@example.com",
"renewal_url": "https://example.com/renew?license={license_code}&email={email}"
}
}
The renewal_url field is optional in the license verification response. When present and the license status is expired, a renewal link is displayed on the admin license page. The URL supports two placeholders that are replaced automatically:
{license_code}— replaced with the stored license key{email}— replaced with thebuyer_emailfrom the license data
A static URL without placeholders (e.g., https://example.com/renew) is also supported.
Ping Endpoint
POST /products/{product_id}/ping
Used for tracking plugin installations and status. Sends site environment data and optional custom metadata.
Request body:
product_version: Current plugin versionproduct_status: Plugin status (active/inactive)wp_url: WordPress site URLwp_locale: WordPress localewp_version: WordPress versionadmin_email: Site admin emailadmin_name: First admin user's display namemeta: Optional key-value pairs of custom metadata
Custom Metadata
You can attach custom metadata to pings using setMeta(). Values can be static or closures — closures are resolved at ping time so data is always fresh.
( new \Shazzad\PluginUpdater\Integration( 'https://api.example.com', plugin_basename( __FILE__ ), 'my-plugin-id' ) )->setMeta( [ 'php_version' => function () { return phpversion(); }, 'theme' => function () { return get_stylesheet(); }, 'memory_limit' => ini_get( 'memory_limit' ), 'active_plugins_count' => function () { return count( get_option( 'active_plugins' ) ); }, ] );
- Static values (strings, numbers) are sent as-is
- Closures are called at each ping and the return value is sent (only
Closureinstances, not arbitrary callable strings) - Metadata is synced on every ping — keys removed from
setMeta()are deleted from the server
Request Parameters
API requests to updates, details, and check_license include these query parameters:
license: License key (if licensing enabled)
WordPress Integration
Hooks and Filters
The updater integrates with WordPress using these hooks:
pre_set_site_transient_update_plugins: Inject update informationplugins_api: Provide plugin details for update screenupgrader_package_options: Configure upgrade processupgrader_process_complete: Handle post-update cleanup- Plugin activation/deactivation hooks for tracking
Scheduled Tasks
- License Sync: Hourly cron job to verify license status
- Update Checks: Integrated with WordPress core update system
Admin Interface
When licensing is enabled, the updater adds an admin page with:
- License key input field
- License status display
- Update availability notifications
- Direct upgrade buttons
- Changelog and upgrade notices
Menu Placement
By default, the license page appears under Plugins menu. You can customize this:
// Under Tools menu 'menu_parent' => 'tools.php' // Under Settings menu 'menu_parent' => 'options-general.php' // Top-level menu 'menu_parent' => null
Security Features
- Input Sanitization: All user inputs are properly sanitized
- Nonce Verification: WordPress nonces protect admin forms
- Capability Checks: Requires
delete_userscapability for license management - XSS Protection: Output is escaped using WordPress functions
Error Handling
The updater includes comprehensive error handling:
- API connection failures
- Invalid license keys
- Update server timeouts
- Malformed responses
Errors are logged and displayed appropriately in the WordPress admin.
Changelog
Version 1.1
- Send ping as POST request with admin_email and admin_name
- Add
setMeta()for custom install metadata (static values and callables) - Skip update transient injection when plugin is inactive
- Send ping on hourly cron for licensed plugins
Version 1.0
- Refactored into modular structure
- Improved error handling
- Enhanced security measures
- Better WordPress integration
- Comprehensive documentation
Support
For support and bug reports, please contact your plugin developer or visit the plugin's official support channels.
License
This updater package is typically licensed under the same terms as your main plugin. Check your plugin's license file for specific terms.
shazzad/plugin-updater 适用场景与选型建议
shazzad/plugin-updater 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 42 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「wordpress」 「license」 「updater」 「wp-plugin」 「plugin-management」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shazzad/plugin-updater 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shazzad/plugin-updater 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shazzad/plugin-updater 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
HiDev plugin for license generation
Cpanel Licensing Class
Fantastico Licensing Class
Cloudlinux Licensing Class
LiteSpeed Licensing Class
统计信息
- 总下载量: 42
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2025-07-14