Reusable GitHub updater helper for WordPress plugins, built on top of yahnis-elsts/plugin-update-checker.
- Automatic plugin updates from GitHub.
- Release-asset filtering using regex.
- Branch selection (default:
main). - Canonical static API (
GitHubUpdater::init) plus backward-compatible wrapper (GitHub_Plugin_Updater). - Error handling with
WP_DEBUGlogging.
- WordPress plugin context (
ABSPATHmust be defined). - Composer dependency:
yahnis-elsts/plugin-update-checker(v5+). - A public GitHub repository with releases or branch updates.
Install dependency:
composer require yahnis-elsts/plugin-update-checkerCopy class-github-plugin-updater.php into your plugin and initialize like this:
if ( ! class_exists( \Soderlind\WordPress\GitHubUpdater::class ) ) {
require_once __DIR__ . '/class-github-plugin-updater.php';
}
\Soderlind\WordPress\GitHubUpdater::init(
github_url: 'https://github.com/username/plugin-name',
plugin_file: __FILE__,
plugin_slug: 'plugin-name',
name_regex: '/plugin-name\.zip/',
branch: 'main',
);Positional equivalent:
\Soderlind\WordPress\GitHubUpdater::init(
'https://github.com/username/plugin-name',
__FILE__,
'plugin-name',
'/plugin-name\.zip/',
'main'
);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'
);
\Soderlind\WordPress\GitHub_Plugin_Updater::create_with_assets(
'https://github.com/username/plugin-name',
__FILE__,
'plugin-name',
'/plugin-name\.zip/',
'main'
);| 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 |
Notes:
- When
name_regexis empty, release-asset filtering is disabled. initregistration is deferred to WordPressinitto be safe regardless of load timing.
From your main plugin file, mirror the vmfa pattern:
if ( ! class_exists( \Soderlind\WordPress\GitHubUpdater::class ) ) {
require_once __DIR__ . '/class-github-plugin-updater.php';
}
\Soderlind\WordPress\GitHubUpdater::init(
github_url: 'https://github.com/owner/repo',
plugin_file: MY_PLUGIN_FILE,
plugin_slug: 'my-plugin',
name_regex: '/my-plugin\.zip/',
branch: 'main',
);This repository includes two workflow templates:
on-release-add.zip.yml(release-triggered build + upload)manually-build-zip.yml(manual build/upload for a provided tag)
Copy them into your plugin repository at .github/workflows/.
- Set
PLUGIN_ZIPto your plugin zip file (example:my-plugin.zip). - Keep
composer install --no-dev --optimize-autoloaderso the updater dependency is 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.
- 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).
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...
Unauthenticated GitHub requests are rate-limited. Keep failed lookup caching enabled in your updater flow and avoid frequent forced checks in production.
This wrapper is designed for public GitHub releases. For private repositories, instantiate plugin-update-checker directly and configure authentication with that library.
WordPress plugins at https://github.com/soderlind
GPL-2.0-or-later.