WP_Site_Health_Auto_Updates::test_if_failed_update
Checks if automatic updates have tried to run, but failed, previously.
Method of the class: WP_Site_Health_Auto_Updates{}
No Hooks.
Returns
Array|false. The test results if auto-updates previously failed, false otherwise.
Usage
$WP_Site_Health_Auto_Updates = new WP_Site_Health_Auto_Updates(); $WP_Site_Health_Auto_Updates->test_if_failed_update();
Changelog
| Since 5.2.0 | Introduced. |
WP_Site_Health_Auto_Updates::test_if_failed_update() WP Site Health Auto Updates::test if failed update code WP 6.9.1
public function test_if_failed_update() {
$failed = get_site_option( 'auto_core_update_failed' );
if ( ! $failed ) {
return false;
}
if ( ! empty( $failed['critical'] ) ) {
$description = __( 'A previous automatic background update ended with a critical failure, so updates are now disabled.' );
$description .= ' ' . __( 'You would have received an email because of this.' );
$description .= ' ' . __( "When you've been able to update using the \"Update now\" button on Dashboard > Updates, this error will be cleared for future update attempts." );
$description .= ' ' . sprintf(
/* translators: %s: Code of error shown. */
__( 'The error code was %s.' ),
'<code>' . $failed['error_code'] . '</code>'
);
return array(
'description' => $description,
'severity' => 'warning',
);
}
$description = __( 'A previous automatic background update could not occur.' );
if ( empty( $failed['retry'] ) ) {
$description .= ' ' . __( 'You would have received an email because of this.' );
}
$description .= ' ' . __( 'Another attempt will be made with the next release.' );
$description .= ' ' . sprintf(
/* translators: %s: Code of error shown. */
__( 'The error code was %s.' ),
'<code>' . $failed['error_code'] . '</code>'
);
return array(
'description' => $description,
'severity' => 'warning',
);
}