Automattic\WooCommerce\Internal\Admin

SiteHealth::get_uploads_file_access_status │ private │ WC 1.0

Check whether the web server serves files from the WooCommerce uploads directory directly.

The directory request alone can't tell: the empty index.html WooCommerce installs there returns a blank 200 even when every file is downloadable. So this requests a temporary file instead.

Method of the class: SiteHealth{}

No Hooks.

Returns

string. 'protected', 'unprotected', or 'unverified'.

Usage

// private - for code of main (parent) class only
$result = $this->get_uploads_file_access_status(): string;

SiteHealth::get_uploads_file_access_status() code WC 11.3.0

private function get_uploads_file_access_status(): string {
	$is_served = $this->is_uploads_test_file_served( 'woocommerce_uploads/' );

	if ( null === $is_served ) {
		return 'unverified';
	}

	if ( $is_served ) {
		return 'unprotected';
	}

	// A blocked file only shows protection if an ordinary upload is served. Offloaded uploads, a site-wide
	// login, or a server rule for the file type would block both.
	return $this->is_uploads_test_file_served( '' ) ? 'protected' : 'unverified';
}