这可以通过过滤器完成plugins_api
:
https://developer.wordpress.org/reference/hooks/plugins_api/
请尝试以下代码:
add_filter("plugins_api", function ($plugins_api, $action, $args) {
if ("plugin_information" !== $action) {
return $plugins_api;
}
$pluginSlug = $args->slug;
if (... update available ...) {
$plugins_api = new \\stdClass();
$plugins_api->name = $pluginSlug;
$plugins_api->version = "5"; // new version
$plugins_api->download_link = "https://server/directory/newVersion.zip";
$plugins_api->slug = $pluginSlug;
$plugins_api->sections = []; // sections of "view details" of update page when update is available
}
return $plugins_api;
}, 10, 3);