onstage2426 / wp-hub-updater
WordPress plugin and theme updater powered by GitHub releases.
Requires
- php: >=8.3
Requires (Dev)
- php-stubs/wordpress-stubs: ^7.0
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^13.0
- rector/rector: ^2.0
Suggests
- wp-cli/wp-cli-bundle: Enables `wp pu <slug> check|status|clear|enable-auto-updates|disable-auto-updates` commands for each configured updater
README
Delivers WordPress plugin and theme updates from a GitHub repository. Hooks into the standard WordPress update system so your entity appears in the Updates screen and can be installed with a single click.
Installation
composer require onstage2426/wp-hub-updater
Requirements: PHP 8.3+, WordPress 6.6+
Bundling in a plugin? If your plugin ships with this library, prefix the namespace so it can coexist with other plugins that bundle it too. Your release workflow handles this automatically — see Distribution → Namespace isolation.
Quick start
Plugin — call this at the top level of your main plugin file:
use WpHubUpdater\Plugin\PluginUpdater; $repo = 'https://github.com/your-org/your-plugin'; PluginUpdater::build($repo, __FILE__) ->setAccessToken('ghp_xxxx'); // omit for public repos
Theme — call this in functions.php:
use WpHubUpdater\Theme\ThemeUpdater; $repo = 'https://github.com/your-org/your-theme'; ThemeUpdater::build($repo, 'your-theme') ->setAccessToken('ghp_xxxx'); // omit for public repos
That's it. The updater registers its WordPress hooks and handles everything else automatically.
PluginUpdater::build()
PluginUpdater::build(
string $repositoryUrl,
string $pluginFile,
string $slug = "", // defaults to filename without .php
int $checkPeriod = 12, // hours between checks; 0 disables automatic checks
string $optionName = "", // defaults to external_updates-{slug}
): static
Pass __FILE__ as $pluginFile from your plugin's main PHP file.
ThemeUpdater::build()
ThemeUpdater::build(
string $repositoryUrl,
string $themeSlug, // theme directory name, e.g. "my-theme"
int $checkPeriod = 12,
string $optionName = "",
): static
Documentation
- Configuration — all chainable methods, access token, branch, cooldown, release filters, reading state
- WordPress filters — filters and actions for info, update, detection strategies, error handling
- Data classes —
Update,PluginInfo,ThemeInfoproperties - Distribution — namespace isolation, release pipeline, draft-first workflow, version stamping, ZIP
plugin.json/theme.json— metadata schema, changelog, local assets- Advanced — MU-plugins, debugging, WP-CLI, reliability features
License
MIT — see LICENSE.