plugin-update-checker icon indicating copy to clipboard operation
plugin-update-checker copied to clipboard

how I find out when The download and replacement process is complete ?

Open Alireza-Ghavabesh opened this issue 4 years ago • 1 comments

i want to do something like this:

if (check_lisense() == true) { $result = $myUpdateChecker->checkForUpdates(); //=====> only once if($result == true){ $prosess_is_compelet = $myUpdateChecker->download_replace(); if($prosess_is_compelet == true){ do_important_work(); } } }

i want to more control on process can you guide me how i can implement code above according to this library.

Thanks again for all the guidance and time you spend.

Alireza-Ghavabesh avatar Jun 19 '21 14:06 Alireza-Ghavabesh

checkForUpdates returns an update object or null, so if you want to check if an update is available, I would recommend a slight modification:

$result = $myUpdateChecker->checkForUpdates();
if ( $result !== null ) {
    // An update is available.
}

However, this library doesn't have a download_replace() function or anything similar. This is because it doesn't actually download or install updates. It just retrieves updates and then gives them to WordPress. Update notifications and installation are handled by WordPress core.

There probably is a way to force WordPress to install an update, but I don't know it off the top of my head. You might need to take a look at WordPress core source code, or maybe see how other tools like WP-CLI install plugin updates.

YahnisElsts avatar Jun 19 '21 18:06 YahnisElsts