WC_Download_Handler::get_download_content_type
Get content type of a download.
Method of the class: WC_Download_Handler{}
No Hooks.
Returns
String.
Usage
$result = WC_Download_Handler::get_download_content_type( $file_path );
- $file_path(string) (required)
- File path.
WC_Download_Handler::get_download_content_type() WC Download Handler::get download content type code WC 10.5.0
private static function get_download_content_type( $file_path ) {
$file_extension = strtolower( substr( strrchr( $file_path, '.' ), 1 ) );
$ctype = 'application/force-download';
foreach ( get_allowed_mime_types() as $mime => $type ) {
$mimes = explode( '|', $mime );
if ( in_array( $file_extension, $mimes, true ) ) {
$ctype = $type;
break;
}
}
return $ctype;
}