WP_Site_Health::get_test_available_updates_disk_space(): array

In this article

Tests available disk space for updates.

Return

array The test results.

Source

public function get_test_available_updates_disk_space() {
	$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false;

	$result = array(
		'label'       => __( 'Disk space available to safely perform updates' ),
		'status'      => 'good',
		'badge'       => array(
			'label' => __( 'Security' ),
			'color' => 'blue',
		),
		'description' => sprintf(
			/* translators: %s: Available disk space in MB or GB. */
			'<p>' . __( '%s available disk space was detected, update routines can be performed safely.' ) . '</p>',
			size_format( $available_space )
		),
		'actions'     => '',
		'test'        => 'available_updates_disk_space',
	);

	if ( false === $available_space ) {
		$result['description'] = __( 'Could not determine available disk space for updates.' );
		$result['status']      = 'recommended';
	} elseif ( $available_space < 20 * MB_IN_BYTES ) {
		$result['description'] = __( 'Available disk space is critically low, less than 20 MB available. Proceed with caution, updates may fail.' );
		$result['status']      = 'critical';
	} elseif ( $available_space < 100 * MB_IN_BYTES ) {
		$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
		$result['status']      = 'recommended';
	}

	return $result;
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.