This updater is great for auto updating of private plugins and also themes.

Library links

https://github.com/YahnisElsts/plugin-update-checker

These notes are based on the excellent guide included on GitHub

Should you use GitHub to host your plugin-update-checker releases?

plugin-update-checker lets you, you can create a release in GitHub and have that as where your files get hosted, nice and simple. But there’s a catch…

If you don’t mind your plugin being public then no problem. But if that is the case why not just release it to the official WordPress plugins system? So if you’re using this library, you probably want your GitHub repo to be private.

If you repo is private then you need to generate a personal access token in GitHub and store it in your plugin file, so that plugin-update-checker can use it to get the new file releases. The big issue here is that the personal access token you create in GitHub grants access rights to all of your private repositories. You can’t (at the time of writing anyway) create one that just grants access to just one specific repo on GitHub. So that means if you have someone else rooting around your wordpress install on a site for any reason and they grab that access token string, they can then access all of your private repo’s on GitHub! Big problem if you host other projects that must remain protected.

For us this is a no go, we instead choose to self host on a website of ours and use a directory name with a decent random string in it to create a similar level of security as a GitHub access token, but without needing to store the keys to the entire kingdom in our plugins :-)

Adding updater to your plugin or theme

Create repository for the update files somewhere

Create a file named “details.json” and store it on a publicly accessible server.

A minimum version of the file contents you can use for a plugin:

 {
 	"name" : "MY  PLUGIN OR THEME NAME",
 	"version" : "1.0",
 	"download_url" : "https://mydomain.com/downloads/my-plugin.zip",
 	"sections" : {
 		"description" : "This is my plugin"
 	}
 }

A minimum version of the file contents you can use for a theme:

 {
 	"version": "1.0",
 	"details_url": "https://mydomain.com/downloads/my-theme-details.html",
 	"download_url": "https://mydomain.com/downloads/my-theme.zip"
 }

(details_url is the page the user will see if they click the “View version 1.2.3 details” link in an update notification).

Add library to your plugin

Download latest version from https://github.com/YahnisElsts/plugin-update-checker/releases/latest

Remove the version number from the end and then copy the “plugin-update-checker” directory to your plugin or theme.

Add the following to your main plugin file, or functions.php for a theme:

//***************************************************
//***************************************************
//********** PLUGIN UPDATE CHECKER LIBRARY **********
//***************************************************
//***************************************************
require 'plugin-update-checker/plugin-update-checker.php';
$myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
	'https://mydomain.com/downloads/details.json',
	__FILE__,            //Full path to the main plugin file or functions.php.  If not this file then use:  __DIR__ . '/my-plugin-name.php'
	'MY-PLUGIN-NAME'     //The 'unique-plugin-or-theme-slug'
);

Releasing a new version of your plugin

In the top of your “my-plugin-name.php” or theme “style.css” file

Update the “version” field to the new version number

Create an install release of the plugin or theme

Zip up your plugin or theme into “my-plugin-theme-name.zip”.  The zip should contain a folder named “my-plugin-theme-name” which contains all of the plugin / theme files, all exactly as they will be installed on the wordpress site.

In your publicly hosted details.json file

Update the “version” field

Update the “download_url” if necessary

Upload the new “my-plugin-theme-name.zip” file to the download_url you specified in details.json.

That’s it. The new plugin or theme version will now be picked up by all wordpress installs using your plugin or theme, typically within the next 12 hours.

Updating your plugin or theme to use new version of plugin-update-checker

Download latest version from https://github.com/YahnisElsts/plugin-update-checker/releases/latest

Remove the version number from the end and then copy the “plugin-update-checker” directory to your plugin (or theme), overwriting the previous contents.

That should be it.

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *