wp_dashboard_site_health()
Displays the Site Health Status widget.
No Hooks.
Return
null
. Nothing (null).
Usage
wp_dashboard_site_health();
Changelog
Since 5.4.0 | Introduced. |
wp_dashboard_site_health() wp dashboard site health code WP 6.6.2
<?php function wp_dashboard_site_health() { $get_issues = get_transient( 'health-check-site-status-result' ); $issue_counts = array(); if ( false !== $get_issues ) { $issue_counts = json_decode( $get_issues, true ); } if ( ! is_array( $issue_counts ) || ! $issue_counts ) { $issue_counts = array( 'good' => 0, 'recommended' => 0, 'critical' => 0, ); } $issues_total = $issue_counts['recommended'] + $issue_counts['critical']; ?> <div class="health-check-widget"> <div class="health-check-widget-title-section site-health-progress-wrapper loading hide-if-no-js"> <div class="site-health-progress"> <svg aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg"> <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0"></circle> </svg> </div> <div class="site-health-progress-label"> <?php if ( false === $get_issues ) : ?> <?php _e( 'No information yet…' ); ?> <?php else : ?> <?php _e( 'Results are still loading…' ); ?> <?php endif; ?> </div> </div> <div class="site-health-details"> <?php if ( false === $get_issues ) : ?> <p> <?php printf( /* translators: %s: URL to Site Health screen. */ __( 'Site health checks will automatically run periodically to gather information about your site. You can also <a href="%s">visit the Site Health screen</a> to gather information about your site now.' ), esc_url( admin_url( 'site-health.php' ) ) ); ?> </p> <?php else : ?> <p> <?php if ( $issues_total <= 0 ) : ?> <?php _e( 'Great job! Your site currently passes all site health checks.' ); ?> <?php elseif ( 1 === (int) $issue_counts['critical'] ) : ?> <?php _e( 'Your site has a critical issue that should be addressed as soon as possible to improve its performance and security.' ); ?> <?php elseif ( $issue_counts['critical'] > 1 ) : ?> <?php _e( 'Your site has critical issues that should be addressed as soon as possible to improve its performance and security.' ); ?> <?php elseif ( 1 === (int) $issue_counts['recommended'] ) : ?> <?php _e( 'Your site’s health is looking good, but there is still one thing you can do to improve its performance and security.' ); ?> <?php else : ?> <?php _e( 'Your site’s health is looking good, but there are still some things you can do to improve its performance and security.' ); ?> <?php endif; ?> </p> <?php endif; ?> <?php if ( $issues_total > 0 && false !== $get_issues ) : ?> <p> <?php printf( /* translators: 1: Number of issues. 2: URL to Site Health screen. */ _n( 'Take a look at the <strong>%1$d item</strong> on the <a href="%2$s">Site Health screen</a>.', 'Take a look at the <strong>%1$d items</strong> on the <a href="%2$s">Site Health screen</a>.', $issues_total ), $issues_total, esc_url( admin_url( 'site-health.php' ) ) ); ?> </p> <?php endif; ?> </div> </div> <?php }