WC_Product_Download::set_file()publicWC 1.0

Set file.

Method of the class: WC_Product_Download{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Product_Download = new WC_Product_Download();
$WC_Product_Download->set_file( $value );
$value(string) (required)
File URL/Path.

WC_Product_Download::set_file() code WC 8.7.0

public function set_file( $value ) {
	// A `///` is recognized as an "absolute", but on the filesystem, so it bypasses the mime check in `self::is_allowed_filetype`.
	// This will strip extra prepending / to the maximum of 2.
	if ( preg_match( '#^//+(/[^/].+)$#i', $value, $matches ) ) {
		$value = $matches[1];
	}
	switch ( $this->get_type_of_file_path( $value ) ) {
		case 'absolute':
			$this->data['file'] = esc_url_raw( $value );
			break;
		default:
			$this->data['file'] = wc_clean( $value );
			break;
	}
}