Check if WordPress Updates Are Available

In order to check if new update for your WordPress installation is available you need to know two things:

  1. Which version are you currently running.
  2. Which version is available from

After that it's just a matter of comparing two numbers but some issues will occur. How often do you check for new updates? Checking this on every page refresh is out of the question so it should be every 12 or 24 hours. Luckily, we can take a function that WordPress itself uses when checking for new updates and that's get_preferred_from_update_core(). This way you don't have to worry about timing or caching the request towards

$current_version = get_preferred_from_update_core();

if( !isset($current_version->response) || $current_version->response != 'upgrade' ){
    $update_status = __('No updates available');
} else {
    $update_status = __('Update is available');

As simple as that, you can set your own booleans instead of strings as shown above that you can check later in the code.