WP_Site_Health::get_test_available_updates_disk_space(): array

Tests available disk space for updates.


Return

array The test results.


Top ↑

Source

File: wp-admin/includes/class-wp-site-health.php. View all references

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

	$available_space = false !== $available_space
		? (int) $available_space
		: 0;

	$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 ( $available_space < 100 * MB_IN_BYTES ) {
		$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
		$result['status']      = 'recommended';
	}

	if ( $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';
	}

	if ( ! $available_space ) {
		$result['description'] = __( 'Could not determine available disk space for updates.' );
		$result['status']      = 'recommended';
	}

	return $result;
}


Top ↑

Changelog

Changelog
Version Description
6.3.0 Introduced.

Top ↑

User Contributed Notes

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