WC_Product_Download::set_file
Set file.
Method of the class: WC_Product_Download{}
No Hooks.
Returns
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() WC Product Download::set file code WC 10.8.1
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;
}
}