wp_admin_bar_updates_menu() WordPress Function

The wp_admin_bar_updates_menu() function allows a user to see if there are any updates available for their WordPress site. The function will display a notification in the admin bar if there are any updates available. This is a useful function for keeping your WordPress site up-to-date.

wp_admin_bar_updates_menu( WP_Admin_Bar $wp_admin_bar ) #

Provides an update link if theme/plugin/core updates are available.


Parameters

$wp_admin_bar

(WP_Admin_Bar)(Required)The WP_Admin_Bar instance.


Top ↑

Source

File: wp-includes/admin-bar.php

function wp_admin_bar_updates_menu( $wp_admin_bar ) {

	$update_data = wp_get_update_data();

	if ( ! $update_data['counts']['total'] ) {
		return;
	}

	$updates_text = sprintf(
		/* translators: %s: Total number of updates available. */
		_n( '%s update available', '%s updates available', $update_data['counts']['total'] ),
		number_format_i18n( $update_data['counts']['total'] )
	);

	$icon   = '<span class="ab-icon" aria-hidden="true"></span>';
	$title  = '<span class="ab-label" aria-hidden="true">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>';
	$title .= '<span class="screen-reader-text updates-available-text">' . $updates_text . '</span>';

	$wp_admin_bar->add_node(
		array(
			'id'    => 'updates',
			'title' => $icon . $title,
			'href'  => network_admin_url( 'update-core.php' ),
		)
	);
}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.