Consolidate update count code into wp_get_update_data(). Props mitchoyoshitaka. fixes #17694
git-svn-id: http://svn.automattic.com/wordpress/trunk@18468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -323,39 +323,14 @@ function wp_admin_bar_appearance_menu( $wp_admin_bar ) {
|
||||
* @since 3.1.0
|
||||
*/
|
||||
function wp_admin_bar_updates_menu( $wp_admin_bar ) {
|
||||
if ( !current_user_can('install_plugins') )
|
||||
|
||||
$update_data = wp_get_update_data();
|
||||
|
||||
if ( !$update_data['counts']['total'] )
|
||||
return;
|
||||
|
||||
$plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
|
||||
$update_plugins = get_site_transient( 'update_plugins' );
|
||||
if ( !empty($update_plugins->response) )
|
||||
$plugin_update_count = count( $update_plugins->response );
|
||||
$update_themes = get_site_transient( 'update_themes' );
|
||||
if ( !empty($update_themes->response) )
|
||||
$theme_update_count = count( $update_themes->response );
|
||||
/* @todo get_core_updates() is only available on admin page loads
|
||||
$update_wordpress = get_core_updates( array('dismissed' => false) );
|
||||
if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) )
|
||||
$wordpress_update_count = 1;
|
||||
*/
|
||||
|
||||
$update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
|
||||
|
||||
if ( !$update_count )
|
||||
return;
|
||||
|
||||
$update_title = array();
|
||||
if ( $wordpress_update_count )
|
||||
$update_title[] = sprintf(__('%d WordPress Update'), $wordpress_update_count);
|
||||
if ( $plugin_update_count )
|
||||
$update_title[] = sprintf(_n('%d Plugin Update', '%d Plugin Updates', $plugin_update_count), $plugin_update_count);
|
||||
if ( $theme_update_count )
|
||||
$update_title[] = sprintf(_n('%d Theme Update', '%d Theme Updates', $theme_update_count), $theme_update_count);
|
||||
|
||||
$update_title = !empty($update_title) ? esc_attr(implode(', ', $update_title)) : '';
|
||||
|
||||
$update_title = "<span title='$update_title'>";
|
||||
$update_title .= sprintf( __('Updates %s'), "<span id='ab-updates' class='update-count'>" . number_format_i18n($update_count) . '</span>' );
|
||||
$update_title = "<span title='{$update_data['title']}'>";
|
||||
$update_title .= sprintf( __('Updates %s'), "<span id='ab-updates' class='update-count'>" . number_format_i18n($update_data['counts']['total']) . '</span>' );
|
||||
$update_title .= '</span>';
|
||||
|
||||
$wp_admin_bar->add_menu( array( 'id' => 'updates', 'title' => $update_title, 'href' => network_admin_url( 'update-core.php' ) ) );
|
||||
|
||||
Reference in New Issue
Block a user