0

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?

0

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);
  • Is specifying a version necessary and the "slug" is that the plugin's handle that needs to be updated? And do you have an example of specifying if the update is available? – Tanner Aug 9 '18 at 2:52
  • Maybe I should specify - I'm trying to change the location of the update for an already existing plugin. I think the code and below's answer are for my own plugins. – Tanner Aug 9 '18 at 5:47
0

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

  • Is there a way to use this outside of a plugin or theme's folder? I tried this in functions.php but it crashes require '../../plugins/plugin-update-checker/plugin-update-checker.php'; – Tanner Aug 9 '18 at 2:54
  • 1
    You have to adjust that require for the location of the functions.php. The process is built for a theme/plugin to look for updates in a non-WP repository; perhaps your own Github repository, or a spot on your domain. And the zip has to contain a folder that is the same name as the theme/plugin, then the plugin/theme files are in that subfolder. Carefully read/follow the instructions; it can be a bit tricky. – Rick Hellewell Aug 9 '18 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.