Pending Updates Summary Widget
Adds a dashboard widget showing how many WordPress, plugin, theme and translation updates are waiting, with the names of the plugins and a link to install them.
Opens WPIDE on
Code
add_action( 'wp_dashboard_setup', function () {
if ( ! current_user_can( 'update_plugins' ) ) {
return;
}
wp_add_dashboard_widget( 'wpide_pending_updates', 'Pending updates', function () {
$plugins = get_site_transient( 'update_plugins' );
$themes = get_site_transient( 'update_themes' );
$core = get_site_transient( 'update_core' );
$plugin_list = ! empty( $plugins->response ) ? $plugins->response : array();
$theme_count = ! empty( $themes->response ) ? count( $themes->response ) : 0;
$core_update = ! empty( $core->updates[0] ) && 'upgrade' === $core->updates[0]->response;
$translations = count( wp_get_translation_updates() );
if ( ! $plugin_list && ! $theme_count && ! $core_update && ! $translations ) {
echo '<p><span class="dashicons dashicons-yes-alt" style="color:#00a32a" aria-hidden="true"></span> Everything is up to date.</p>';
return;
}
echo '<ul>';
if ( $core_update ) {
printf( '<li><strong>WordPress %s</strong> is available.</li>', esc_html( $core->updates[0]->version ) );
}
if ( $plugin_list ) {
if ( ! function_exists( 'get_plugins' ) ) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$all = get_plugins();
$names = array();
foreach ( $plugin_list as $file => $update ) {
$names[] = ( $all[ $file ]['Name'] ?? $file ) . ' ' . $update->new_version;
}
printf( '<li><strong>%d plugin updates:</strong> %s</li>', count( $plugin_list ), esc_html( implode( ', ', $names ) ) );
}
if ( $theme_count ) {
printf( '<li><strong>%d theme updates</strong></li>', (int) $theme_count );
}
if ( $translations ) {
printf( '<li><strong>%d translation updates</strong></li>', (int) $translations );
}
echo '</ul>';
printf( '<p><a class="button button-primary" href="%s">Go to updates</a></p>', esc_url( admin_url( 'update-core.php' ) ) );
} );
} );
Notes
Uses the update data WordPress already checks twice a day, so it adds no remote requests.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.