YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.25k stars 410 forks source link

Update failed: The theme is at the latest version. #446

Open manobalas opened 3 years ago

manobalas commented 3 years ago

When I'm updating, I'm getting this error, can you please check it..

YahnisElsts commented 3 years ago

It sounds like the update information is not filtered correctly when you try to install the update. There are multiple things that could cause that, but there's not enough information to guess what exactly is going on.

Can you post the code that you use to initialize the update checker? If it contains private information, feel free to edit it out. Also, if you're doing anything advanced such as trying to load the update checker only if certain conditions are met, please post that code too.

manobalas commented 3 years ago

Here is the code

if(is_admin() && strpos($_SERVER['PHP_SELF'], 'themes.php') !== false)
{
    require get_template_directory() . '/plugin-update-checker/plugin-update-checker.php';

    $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
        'https://github.com/username/repo-name',
        __FILE__,
        get_template()
    );
    $myUpdateChecker->setAuthentication('ghp_xxxxxxxxxxxxxxxxxxxxxxxx');
    $myUpdateChecker->setBranch('main');
    $myUpdateChecker->checkForUpdates();
}
YahnisElsts commented 3 years ago

I'm guessing that you might need to remove that themes.php condition. At least some (or maybe most) ways of installing updates will run a different PHP file.

On an related note, these conditions you're using will prevent periodic update checks because the update checker won't be loaded in Cron jobs. They may also prevent users from installing updates with third-party tools such as WP-CLI, ManageWP, and so on.