soderlind / wordpress-github-updater
Reusable GitHub updater helper for WordPress plugins, built on top of yahnis-elsts/plugin-update-checker
Package info
github.com/soderlind/wordpress-plugin-gitHub-updater
pkg:composer/soderlind/wordpress-github-updater
Requires
- php: >=7.4
- yahnis-elsts/plugin-update-checker: ^5.5
README
Composer library for handling WordPress plugin updates from GitHub repositories. Built on yahnis-elsts/plugin-update-checker with built-in rate-limit mitigation.
Features
- Automatic updates from GitHub releases or branch commits.
- Rate-limit mitigation: Configurable check intervals (default 6h) and throttling (72h when update already known).
- GitHub token support for private repos and higher API limits (60 → 5000 requests/hour).
- Release-asset filtering using regex.
- Branch selection (default:
main). - Canonical static API (
GitHubUpdater::init) plus backward-compatible wrapper. - Error handling with
WP_DEBUGlogging.
Installation
composer require soderlind/wordpress-github-updater
This automatically includes yahnis-elsts/plugin-update-checker as a dependency.
Requirements
- PHP 7.4+
- WordPress plugin context (
ABSPATHmust be defined). - A GitHub repository with releases or branch updates.
Quick Start
use Soderlind\WordPress\GitHubUpdater; GitHubUpdater::init( github_url: 'https://github.com/username/plugin-name', plugin_file: __FILE__, plugin_slug: 'plugin-name', name_regex: '/plugin-name\.zip/', branch: 'main', check_period: 6, // Hours between checks (default: 6) auth_token: '', // Optional GitHub token );
Positional equivalent:
\Soderlind\WordPress\GitHubUpdater::init( 'https://github.com/username/plugin-name', __FILE__, 'plugin-name', '/plugin-name\.zip/', 'main', 6, // check_period '' // auth_token );
With GitHub Token (for private repos or higher rate limits)
GitHubUpdater::init( github_url: 'https://github.com/username/private-plugin', plugin_file: __FILE__, plugin_slug: 'private-plugin', auth_token: defined('MY_PLUGIN_GITHUB_TOKEN') ? MY_PLUGIN_GITHUB_TOKEN : '', );
Backward Compatibility API
GitHub_Plugin_Updater is still available for existing integrations.
\Soderlind\WordPress\GitHub_Plugin_Updater::create( 'https://github.com/username/plugin-name', __FILE__, 'plugin-name', 'main', 6, // check_period '' // auth_token ); \Soderlind\WordPress\GitHub_Plugin_Updater::create_with_assets( 'https://github.com/username/plugin-name', __FILE__, 'plugin-name', '/plugin-name\.zip/', 'main', 6, // check_period '' // auth_token );
Configuration
GitHubUpdater::init(...)
| Parameter | Required | Default | Description |
|---|---|---|---|
github_url |
Yes | - | Full repository URL (https://github.com/owner/repo) |
plugin_file |
Yes | - | Absolute path to the main plugin file |
plugin_slug |
Yes | - | Plugin slug used by WordPress |
name_regex |
No | '' |
Regex to match release asset zip filename |
branch |
No | 'main' |
Branch to track |
check_period |
No | 6 |
Hours between update checks. Set to 0 to disable automatic checks. |
auth_token |
No | '' |
GitHub personal access token for private repos or higher rate limits |
Rate-Limit Mitigation
This library includes built-in protection against GitHub API timeouts/overload:
- Configurable check interval: Default is 6 hours (vs. upstream default of 12h). Adjust via
check_period. - Throttled checks: When an update is already known, checks are reduced to every 72 hours.
- Token authentication: Provide a GitHub token to increase rate limits from 60 to 5000 requests/hour.
- Error logging: API errors are logged when
WP_DEBUGis enabled.
Recommended Integration Pattern
From your main plugin file:
// Autoloaded via Composer use Soderlind\WordPress\GitHubUpdater; GitHubUpdater::init( github_url: 'https://github.com/owner/repo', plugin_file: __FILE__, plugin_slug: 'my-plugin', name_regex: '/my-plugin\.zip/', branch: 'main', check_period: 6, );
Workflow Templates
This repository includes two workflow templates in .github/workflows/:
on-release-add.zip.yml— Release-triggered build + uploadmanually-build-zip.yml— Manual build/upload for a provided tag
Copy them into your plugin repository at .github/workflows/.
Workflow Checklist
- Set
PLUGIN_ZIPto your plugin zip file (example:my-plugin.zip). - Keep
composer install --no-dev --optimize-autoloaderso dependencies are packaged. - Keep the verification step that checks
vendor/yahnis-elsts/plugin-update-checkerexists in the zip. - Ensure
name_regexin PHP matches your zip filename convention.
Troubleshooting
Updates do not appear
- Confirm your plugin file, slug, repo URL, and branch are correct.
- Publish a release with an attached zip that matches
name_regex. - Trigger a manual update check in WordPress Admin (or wait for scheduled checks).
Dependency is missing in release zip
If plugin-update-checker is not in vendor/, updater setup fails. In WP_DEBUG, you will see:
GitHubUpdater (your-plugin-slug): Missing dependency yahnis-elsts/plugin-update-checker...
GitHub API rate limits
The library includes built-in rate-limit mitigation:
- Check interval: By default, checks only every 6 hours.
- Throttling: When an update is already available, checks reduce to every 72 hours.
- Token auth: Pass a GitHub token via
auth_tokento increase limits from 60 to 5000 requests/hour.
If you still hit rate limits, increase check_period or add a GitHub token.
Private repositories
Pass your GitHub personal access token via the auth_token parameter:
GitHubUpdater::init( github_url: 'https://github.com/username/private-repo', plugin_file: __FILE__, plugin_slug: 'private-plugin', auth_token: MY_GITHUB_TOKEN, );
Real-World Reference
WordPress plugins at https://github.com/soderlind
License
GPL-2.0-or-later.