From 7ec2c1dec875a7cdb1aa0ca7f3f70f29cc906b03 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 26 May 2021 01:16:51 +0000 Subject: [PATCH] Themes: Display the number of available theme updates in the admin menu. This brings some consistency with the similar update counter for plugins. Props mukesh27, zodiac1978, pixolin, Boniu91, francina, sannevndrmeulen, joyously, SergeyBiryukov. Fixes #43697. git-svn-id: https://develop.svn.wordpress.org/trunk@51022 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/menu.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/menu.php b/src/wp-admin/menu.php index 9b479da344..20a0a2f477 100644 --- a/src/wp-admin/menu.php +++ b/src/wp-admin/menu.php @@ -185,8 +185,22 @@ $menu[59] = array( '', 'read', 'separator2', '', 'wp-menu-separator' ); $appearance_cap = current_user_can( 'switch_themes' ) ? 'switch_themes' : 'edit_theme_options'; -$menu[60] = array( __( 'Appearance' ), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' ); - $submenu['themes.php'][5] = array( __( 'Themes' ), $appearance_cap, 'themes.php' ); +$menu[60] = array( __( 'Appearance' ), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' ); + +$count = ''; +if ( ! is_multisite() && current_user_can( 'update_themes' ) ) { + if ( ! isset( $update_data ) ) { + $update_data = wp_get_update_data(); + } + $count = sprintf( + '%s', + $update_data['counts']['themes'], + number_format_i18n( $update_data['counts']['themes'] ) + ); +} + + /* translators: %s: Number of available theme updates. */ + $submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_cap, 'themes.php' ); $customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' ); $submenu['themes.php'][6] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' ); @@ -236,7 +250,7 @@ if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) { ); } -/* translators: %s: Number of pending plugin updates. */ +/* translators: %s: Number of available plugin updates. */ $menu[65] = array( sprintf( __( 'Plugins %s' ), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'dashicons-admin-plugins' ); $submenu['plugins.php'][5] = array( __( 'Installed Plugins' ), 'activate_plugins', 'plugins.php' );