Make WordPress Core

Changeset 54165


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

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/admin/site-health.js

    r54089 r54165  
    1616        isDebugTab = $( '.health-check-body.health-check-debug-tab' ).length,
    1717        pathsSizesSection = $( '#health-check-accordion-block-wp-paths-sizes' ),
     18        menuCounterWrapper = $( '#adminmenu .site-health-counter' ),
     19        menuCounter = $( '#adminmenu .site-health-counter .count' ),
    1820        successTimeout;
    1921
     
    165167        }
    166168
     169        menuCounter.text( SiteHealth.site_status.issues.critical );
     170
    167171        if ( 0 < parseInt( SiteHealth.site_status.issues.critical, 0 ) ) {
    168172            $( '#health-check-issues-critical' ).removeClass( 'hidden' );
     173
     174            menuCounterWrapper.removeClass( 'count-0' );
     175        } else {
     176            menuCounterWrapper.addClass( 'count-0' );
    169177        }
    170178        if ( 0 < parseInt( SiteHealth.site_status.issues.recommended, 0 ) ) {
  • trunk/src/wp-admin/css/admin-menu.css

    r53731 r54165  
    428428
    429429/* @todo: consider to use a single rule for these counters and the list table comments counters. */
     430#adminmenu .menu-counter,
    430431#adminmenu .awaiting-mod,
    431432#adminmenu .update-plugins {
  • trunk/src/wp-admin/css/colors/_admin.scss

    r53383 r54165  
    351351/* Admin Menu: bubble */
    352352
     353#adminmenu .menu-counter,
    353354#adminmenu .awaiting-mod,
    354355#adminmenu .update-plugins {
  • 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.