Site Health: Avoid "Undefined property" PHP notices in wp_dashboard_site_health()
when the status result transient does not exist yet.
Props dlh for initial patch. See #47606. git-svn-id: https://develop.svn.wordpress.org/trunk@47069 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5ee2e239dc
commit
92fc229ca0
@ -1772,21 +1772,21 @@ function dashboard_php_nag_class( $classes ) {
|
|||||||
function wp_dashboard_site_health() {
|
function wp_dashboard_site_health() {
|
||||||
$get_issues = get_transient( 'health-check-site-status-result' );
|
$get_issues = get_transient( 'health-check-site-status-result' );
|
||||||
|
|
||||||
$issue_counts = new stdClass();
|
$issue_counts = array();
|
||||||
|
|
||||||
if ( false !== $get_issues ) {
|
if ( false !== $get_issues ) {
|
||||||
$issue_counts = json_decode( $get_issues );
|
$issue_counts = json_decode( $get_issues, true );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! is_object( $issue_counts ) || empty( $issue_counts ) ) {
|
if ( ! is_array( $issue_counts ) || ! $issue_counts ) {
|
||||||
$issue_counts = (object) array(
|
$issue_counts = array(
|
||||||
'good' => 0,
|
'good' => 0,
|
||||||
'recommended' => 0,
|
'recommended' => 0,
|
||||||
'critical' => 0,
|
'critical' => 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$issues_total = $issue_counts->recommended + $issue_counts->critical;
|
$issues_total = $issue_counts['recommended'] + $issue_counts['critical'];
|
||||||
?>
|
?>
|
||||||
<div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js">
|
<div class="health-check-title-section site-health-progress-wrapper loading hide-if-no-js">
|
||||||
<div class="site-health-progress">
|
<div class="site-health-progress">
|
||||||
@ -1821,7 +1821,7 @@ function wp_dashboard_site_health() {
|
|||||||
|
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<p>
|
<p>
|
||||||
<?php if ( $issue_counts->critical > 0 ) : ?>
|
<?php if ( $issue_counts['critical'] > 0 ) : ?>
|
||||||
<?php _e( 'Your site has critical issues that should be addressed as soon as possible to improve the performance or security of your website.' ); ?>
|
<?php _e( 'Your site has critical issues that should be addressed as soon as possible to improve the performance or security of your website.' ); ?>
|
||||||
<?php elseif ( $issues_total <= 0 ) : ?>
|
<?php elseif ( $issues_total <= 0 ) : ?>
|
||||||
<?php _e( 'Great job! Your site currently passes all site health checks.' ); ?>
|
<?php _e( 'Great job! Your site currently passes all site health checks.' ); ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user