admin管理员组

文章数量:1122846

There are specific plugins that I want to use my own repo for for updating my sites. How can I identify the plugin to target and what server they should be looking at?

There are specific plugins that I want to use my own repo for for updating my sites. How can I identify the plugin to target and what server they should be looking at?

Share Improve this question edited Aug 4, 2018 at 17:09 Mark Kaplun 23.7k7 gold badges43 silver badges65 bronze badges asked Aug 4, 2018 at 15:48 TannerTanner 275 bronze badges 1
  • since this question was asked, WP 5.8 added an official method of doing this via filters and the plugins header – Tom J Nowell Commented Aug 2, 2021 at 21:41
Add a comment  | 

2 Answers 2

Reset to default 1

this can be done with the filter plugins_api :
https://developer.wordpress.org/reference/hooks/plugins_api/

try this code :

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);

There is also this solution, which is a bit more work to set up, but allows you to get updates from your own GitHub or private repository. I use it for my own private plugin that contains my personal settings for all web sites I develop.

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

本文标签: How can I change the plugin update server for specific plugins