The last few days I worked on the following scenario: a WordPress plugin or theme gets its update from a private GitLab repo and checks the Git tags for a new version. The result is a WordPress plugin, which also can be integrated into a plugin or theme directly.
You can find the plugin on GitHub. It is pretty much my first class orientated PHP code (perhaps even object orientated(?)), and I would be happy about feedback and suggestions to improve it — here in the comments or in the GitHub repo 🙂 I get inspiration for namespaces and tags in code comments from a repo by Alain Schlesser.
Access token is the GitLab access token, which needs the api and read_registry scope. It may be the safest way to create that token for a user with reporter capabilities, who has only access to that particular repo.
GitLab URL is the URL of the GitLab installation, for example, https://gitlab.com/.
Repo is the ID of the repo like shown in the URL if you open it in GitLab: username/project or group/project.
If you only want to use the feature for one theme or plugin in an installation, you can implement it directly (also possible with multiple usages per installation — for that you need to change the namespace to avoid a conflict with multiple classes of the same name).
* Include the file with the ThemeUpdater class.
* Init the theme updater.
The params are the same as above — the only additional one is the theme's slug.
* Include the file with the PluginUpdater class.
* Init the plugin updater with the plugin base name.
One more param here: plugin_base_name is the plugin directory and the name of the main file — for example, svg-social-menu/svg-social-menu.php.