Notice for updated plugins

Waiting for Plugin Directory…
I’ll like to notice users when a new version of a plugin is out.
For now I’m going to check this against the GitHub repository and display this:


What do you think about?

Is there any plan to add something in the header of plugins to get an url to check for updates?

Simone.

4 Likes

Good question. In the meantime, you can add an update process to your plugins to ensure your updates are found before the plugin directory is launched. Some of us are using the f(x) Updater and some are using the GitHub Updater.

5 Likes

Using a pre-existing update solution is the best way to handle this until v2 is available.

3 Likes

Ok, thank you for the suggestions.
I’ll share with you a little review:

f(x) Updater

This plugin installs on a server that acts like a repository.
On this server you have to configure the plugins you want to work with.
Then you have to include a class in every plugin/theme you want to work with.

Pros:

  • Full self-hosting solutions.
  • support themes and plugins.

Cons:

  • Setup will take some time (not too much perhaps).
  • You have to mantain your own repository (bandwidth usage, …) if you choose to host your plugin packages on your own site.

GitHub Updater

This plugin taked care of the update process for plugins that have a line
in their header. Just add
GitHub Plugin URI: user/repo
to your plugin and GitHub Updater will take care og keeping up-to-date it.
For this update to work, people that installs yout plugin must install even GitHub Updater.

Pros:

  • 10 seconds setup.
  • Support themes, plugins and language packs.
  • Works with GitHub, Bitbucket, GitLab, or Gitea.

Cons:

  • Must be installed by your plugin users.

Checking against latest GitHub release by yourself

This is a function I se to do a simple check.
It return false if you are up-to-date, otherwise true.
Works with releases.

function yourprefix_update_link( $gituser, $gitrepo ){
	$slug = dirname( plugin_basename( __FILE__ ) );
	$plugin_info = get_plugin_data( __FILE__ );
	$plugin_installed_version = $plugin_info['Version'];
	if ( false === ( $plugin_current_version = get_transient( $slug . 'lastversion' ) ) ) {
		$response = wp_remote_get( 
			'https://api.github.com/repos/' . $gituser . "/" . $gitrepo . '/releases/latest' ,
			 array( 'redirection' => 5 )
		);
		if ( 200 === $response['response']['code'] ){
			$git_data = json_decode ( $response['body'], true );
			$plugin_current_version = ltrim ( $git_data['tag_name'], 'v');
			// Keep the transient for one day
			set_transient( $slug . 'lastversion', $plugin_current_version, DAY_IN_SECONDS );
		} else
		{
			// Bad response fro GitHub
			return false;
		};
	};
	if ( version_compare( $plugin_current_version, $plugin_installed_version , '>' ) ){
		return true;
	} else {
		return false;
	}
};

Simone.

3 Likes

Re: f(x) Updater: this isn’t quite accurate.

If you are hosting your plugin packages on your own site (ie through the media library) then you will have bandwidth usage. If you use a remote URL for the update package, there’s zero bandwidth consumption. To clarify: it works with any remote URL; you’re not limited to GitHub and the others.

Also, thanks for the comparison.

2 Likes

Right! Thank you!
I’ll edit the post!

1 Like