A lightweight and developer-friendly class to enable automatic plugin updates in WordPress directly from a GitHub repository.
- Checks GitHub Releases for new plugin versions
- Compares current plugin version with the latest GitHub tag
- Downloads and installs ZIP directly from GitHub
- Automatically renames the plugin folder after download
- Displays changelog from the GitHub release body
- Supports GitHub Personal Access Tokens (for private repos)
-
Clone or download this repository:
git clone https://github.com/therakib7/wordpress-plugin-update-from-github.git
-
Include the
AutoUpdate
class in your plugin. -
Initialize the updater with your plugin configuration:
use SoftTent\AutoUpdate; new AutoUpdate([ 'plugin_file' => 'my-plugin-folder', // Plugin directory name 'plugin_slug' => 'my-plugin-main-file', // Main plugin file (without .php) 'github_author' => 'your-github-username', 'github_repository' => 'your-plugin-repo', 'access_token' => 'your-github-token' // Optional ]);
π If your repository is private, a GitHub Personal Access Token (PAT) is required.
-
Checks for Updates: Hooks into
pre_set_site_transient_update_plugins
to fetch the latest release using the GitHub API. -
Version Comparison: Uses
version_compare()
to determine if an update is available based on GitHub release tags. -
Authenticated Download: Adds an authorization header using
http_request_args
to download the ZIP file from GitHub, including private repos. -
Folder Rename: Uses
upgrader_source_selection
to rename GitHubβs auto-generated folder (e.g.,author-repo-hash
) to your correct plugin directory name. -
Changelog Display: Hooks into
plugins_api
to display release notes or changelog from the GitHub release body in the WordPress plugin update screen.
- WordPress 5.0+
- PHP 7.4+
- Do not expose your access token publicly.
- All input is internally validated and sanitized.
- Or Create a access token only for specific repository with read only permission
This project is open-sourced under the MIT License.
Developed by @therakib7 If this helped you, consider giving the repository a βοΈ!