If you're a plugin developer, here are two ways to improve distribution + updates - what do you think?

I’ve seen these two resources discussed and mentioned elsewhere, I’d love to see opinions on them.

  • pluginstxt - plugins.txt aims to decentralize plugin hosting by allowing developers to self-host and provide necessary metadata for discovery, verification, and secure communication.
  • Git Updater - A simple plugin to enable automatic updates to your GitHub hosted WordPress plugins, themes, and language packs. Additional API plugins available for Bitbucket, GitLab, Gitea, and Gist.

Also relevant:

1 Like

Many plugins by CP developers used a version of GitUpdater. Sure, it works, but it provides no visibility.

Since we built the CP Directory to run on an instance of CP itself, pretty much everyone has instead chosen to have their plugin listed there and to use the updating function that provides.

Speaking purely for myself, I’d view a plugin that still uses its own Git Updater as taking a step backwards and wouldn’t use it.

2 Likes

I agree, I can see multiple issues depending on what route current WP devs/users choose. I am thinking if you submit your plugin to CP’s directory, your audience is here unless you decide to also support + maintain versions for other forks or WP.

It’s my understanding the ClassicPress plugins directory also relies on the ClassicPress Directory Integration - correct ?

1 Like

Yes, that’s right.

1 Like

I’m all for our directory, but now if you need to self host your updates the Update URI header and the relative hooks are the best way to do this without extra libraries and with extreme flexibility.

3 Likes

I didn’t know about this. I coded my own updater, which is one file only and really tiny. Has been working perfectly for 3+ years now.

What would go in the Update URI header? A zip file link?

1 Like

This is done using the header and the update_plugins_{$hostname} filter.
This is a PoC plugin that get update information from a simple endpoint (can also use a static json file).

/**
 * Plugin Name: Update URI test
 * Version: 1.0.0
 * Update URI: https://educatorecinofilo.dog/myplugins.php
 */

namespace XXSimoXX\UURI;

class U_URI {

	const UPDATE_URI = 'https://educatorecinofilo.dog/myplugins.php';

	public function __construct() {
		$update_plugins_hook = 'update_plugins_'.wp_parse_url(self::UPDATE_URI, PHP_URL_HOST);
		add_filter($update_plugins_hook, [$this, 'update_uri_filter'], 10, 4);
	}

	public function update_uri_filter($update, $plugin_data, $plugin_file, $locales) {
		$response = wp_remote_get(self::UPDATE_URI);
		$remote_data = json_decode(wp_remote_retrieve_body($response), true);
		$plugin_remote_data = $remote_data[dirname($plugin_file)];

		if (version_compare($plugin_data['Version'], $plugin_remote_data['Version']) >= 0) {
			// No updates available
			return false;
		}

		return [
			'slug'         => $plugin_file,
			'version'      => $plugin_remote_data['Version'],
			'package'      => $plugin_remote_data['Download'],
		];
	}

}

new U_URI();

On the remote side:

<?php

$plugins = [
	'u-uri' => [
		'Version'  => '1.1.0',
		'Download' => 'https://not.existing.domain/u-uri.zip',
	]
];

echo json_encode($plugins);
2 Likes

I thought it was something native.

I am using this code - fx-builder/includes/updater.php at af2f1eea07a5a26f17b6932955f50220d0566b1d · wolffe/fx-builder · GitHub - and I have statistics server side.

I want to turn this into a self-managed plugin, so you can manage the files, the JSON code and the releases from your own WordPress/ClassicPress installation. I started a thread a while ago, here - Selling plugins and themes

2 Likes

It’s the same way Update Manager handles updates, filtering pre_set_site_transient_update_plugins.
ClassicPress Directory Integration plugin uses the new hook update_plugins_{$hostname} that was created to achieve this result.

2 Likes

I will definitely check out your code and see if it’s more efficient than mine :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.