I tried the hook update_plugins_{$hostname}
following the fresher informations I found in the link quoted by Tom J Nowell :
https://make.wordpress.org/core/2021/06/29/introducing-update-uri-plugin-header-in-wordpress-5-8/
here is a example of plugin with self managed update. it's a base for update by the Updates page and the Plugins page and this example can be complete to manage more details, e.g. in the plugin information page. then don't hesitate to edit to complete.
<?php
/*
Plugin Name: MY_PLUGIN
Version: 128
Plugin URI: https://my_domain.com/my_plugin
Update URI: https://my_domain.com/my_plugin
*/
if (!function_exists("add_action")) {
echo "plugin";
exit();
}
add_filter("update_plugins_my_domain.com", function ($update, $plugin_data, $plugin_file, $locales) {
// if you manage more plugins on the same domain,
// test here if it's the current plugin
if (TRUE) { // if there is a new version for this plugin
$update = [
"slug" => "MY_PLUGIN",
"version" => 137, // new version
"package" => "https://my_domain.com/plugins-updates/my_plugin-v137.zip",
];
}
return $update;
}, 10, 4);
// filter to manage the information page of the plugin
add_filter("plugins_api", function ($res, $action, $args) {
if ( ("plugin_information" === $action)
&& ("MY_PLUGIN" === $args->slug)
) {
$res = (object) [
"slug" => $args->slug,
"name" => "Name of the plugin",
"sections" => [
"description" => "<strong>plugin information</strong>",
"changelog" => "<ul><li>details of the change log</li></ul>",
],
"banners" => [
"low" => "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d5/8_Poultry.jpg/1024px-8_Poultry.jpg",
],
"download_link" => ".", // just any single character is enough
// to enable update button on information page
];
}
return $res;
}, 10, 3);