List of plugin updates in admin bar

Here’s the code that extracts update plugin information with get_plugin_updates and wrestles some info from the returned objects, which sadly do not contain changelog information. A node is created in the admin bar for every available update.

I suppose I could expand this to a plugin that also lists core, theme and translation updates if anyone is interested.

add_action( 'admin_bar_menu', 'wpse_228026_toolbar_show_updates', 999 );

function wpse_228026_toolbar_show_updates ($wp_admin_bar) {
    if (!function_exists('get_plugin_updates')) require_once ABSPATH . 'wp-admin/includes/update.php';
    $plugin_updates = get_plugin_updates();
    foreach ($plugin_updates as $update) {
        $args = array(
            'id'            => $update->update->slug,
            'title'         => 'Plugin update: ' . $update->Name,
            'parent'        => 'updates',
            'meta'          => array( 
                                'class' => 'update-available ' . $update->update->slug,
                                'title' => 'Current version: ' . $update->Version . ' | ' . 'New version: ' . $update->update->new_version)
            );
        $wp_admin_bar->add_node( $args );
        }
    }