Debug Pending WordPress Updates

If WordPress shows you one or more pending updates, but there is no update shown when viewing the updates panel, you can use the following code to debug the pending updates. Insert the code into a custom plugin (or your themes functions.php) and open your website with the URL parameter ?show_available_updates appended:

/** enable ?show_available_updates url parameter */
function debug_pending_updates()
{
    // Basic permission handling
    if (!is_user_logged_in() || !current_user_can('manage_options')) {
        return;
    }
    if (!isset($_GET['show_available_updates'])) {
        return;
    }

    $output = "";

    // Check for available plugin updates
    $plugin_updates = get_site_transient('update_plugins');
    if ($plugin_updates && !empty($plugin_updates->response)) {
        foreach ($plugin_updates->response as $plugin => $details) {
            $output .= "<p><strong>The plugin</strong> <u>$plugin</u> is reporting an available update.</p>";
        }
    }

    // Check for available theme updates
    wp_update_themes();
    $theme_updates = get_site_transient('update_themes');
    if ($theme_updates && !empty($theme_updates->response)) {
        foreach ($theme_updates->response as $theme => $details) {
            $output .= "<p><strong>The theme</strong> <u>$theme</u> is reporting an available update.</p>";
        }
    }

    if (empty($output)) {
        $output = "No pending updates found in database.";
    }

    wp_die($output);
}

add_action('init', 'debug_pending_updates');

Now, you should see a list of pending WordPress updates.

Caution: Remove the inserted code after debugging the pending updates. It is not safe to permanently use this code in an production environment!