Make WordPress Core


Ignore:
Timestamp:
09/14/2022 09:12:12 PM (21 months ago)
Author:
azaozz
Message:

Site health: Add a menu bubble with the critical issues count to the Tools -> Site Health submenu.

Props: Clorith
See: #56199

File:
1 edited

Legend:

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

    r52415 r54165  
    343343}
    344344
     345$site_health_count = '';
     346if ( ! is_multisite() && current_user_can( 'view_site_health_checks' ) ) {
     347    $get_issues = get_transient( 'health-check-site-status-result' );
     348
     349    $issue_counts = array();
     350
     351    if ( false !== $get_issues ) {
     352        $issue_counts = json_decode( $get_issues, true );
     353    }
     354
     355    if ( ! is_array( $issue_counts ) || ! $issue_counts ) {
     356        $issue_counts = array(
     357            'good'        => 0,
     358            'recommended' => 0,
     359            'critical'    => 0,
     360        );
     361    }
     362
     363    $site_health_count = sprintf(
     364        '<span class="menu-counter site-health-counter count-%s"><span class="count">%s</span></span>',
     365        $issue_counts['critical'],
     366        number_format_i18n( $issue_counts['critical'] )
     367    );
     368}
     369
    345370$menu[75]                     = array( __( 'Tools' ), 'edit_posts', 'tools.php', '', 'menu-top menu-icon-tools', 'menu-tools', 'dashicons-admin-tools' );
    346371    $submenu['tools.php'][5]  = array( __( 'Available Tools' ), 'edit_posts', 'tools.php' );
    347372    $submenu['tools.php'][10] = array( __( 'Import' ), 'import', 'import.php' );
    348373    $submenu['tools.php'][15] = array( __( 'Export' ), 'export', 'export.php' );
    349     $submenu['tools.php'][20] = array( __( 'Site Health' ), 'view_site_health_checks', 'site-health.php' );
     374    /* translators: %s: Number of critical Site Health checks. */
     375    $submenu['tools.php'][20] = array( sprintf( __( 'Site Health %s' ), $site_health_count ), 'view_site_health_checks', 'site-health.php' );
    350376    $submenu['tools.php'][25] = array( __( 'Export Personal Data' ), 'export_others_personal_data', 'export-personal-data.php' );
    351377    $submenu['tools.php'][30] = array( __( 'Erase Personal Data' ), 'erase_others_personal_data', 'erase-personal-data.php' );
Note: See TracChangeset for help on using the changeset viewer.