Make WordPress Core

Changeset 51022

Timestamp:
05/26/2021 01:16:51 AM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/menu.php

    r49837 r51022  
    186186$appearance_cap = current_user_can( 'switch_themes' ) ? 'switch_themes' : 'edit_theme_options';
    187187
    188 $menu[60]                     = array( __( 'Appearance' ), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' );
    189     $submenu['themes.php'][5] = array( __( 'Themes' ), $appearance_cap, 'themes.php' );
     188$menu[60] = array( __( 'Appearance' ), $appearance_cap, 'themes.php', '', 'menu-top menu-icon-appearance', 'menu-appearance', 'dashicons-admin-appearance' );
     189
     190$count = '';
     191if ( ! is_multisite() && current_user_can( 'update_themes' ) ) {
     192    if ( ! isset( $update_data ) ) {
     193        $update_data = wp_get_update_data();
     194    }
     195    $count = sprintf(
     196        '<span class="update-plugins count-%s"><span class="theme-count">%s</span></span>',
     197        $update_data['counts']['themes'],
     198        number_format_i18n( $update_data['counts']['themes'] )
     199    );
     200}
     201
     202    /* translators: %s: Number of available theme updates. */
     203    $submenu['themes.php'][5] = array( sprintf( __( 'Themes %s' ), $count ), $appearance_cap, 'themes.php' );
    190204
    191205    $customize_url            = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );
     
    237251}
    238252
    239 /* translators: %s: Number of pending plugin updates. */
     253/* translators: %s: Number of plugin updates. */
    240254$menu[65] = array( sprintf( __( 'Plugins %s' ), $count ), 'activate_plugins', 'plugins.php', '', 'menu-top menu-icon-plugins', 'menu-plugins', 'dashicons-admin-plugins' );
    241255
Note: See TracChangeset for help on using the changeset viewer.