WC_Download_Handler::download_file_force
Force download - this is the default method.
Метод класса: WC_Download_Handler{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$result = WC_Download_Handler::download_file_force( $file_path, $filename );
- $file_path(строка) (обязательный)
- File path.
- $filename(строка) (обязательный)
- File name.
Код WC_Download_Handler::download_file_force() WC Download Handler::download file force WC 10.7.0
public static function download_file_force( $file_path, $filename ) {
$parsed_file_path = self::parse_file_path( $file_path );
$download_range = self::get_download_range( @filesize( $parsed_file_path['file_path'] ) ); // @codingStandardsIgnoreLine.
self::download_headers( $parsed_file_path['file_path'], $filename, $download_range );
$start = isset( $download_range['start'] ) ? $download_range['start'] : 0;
$length = isset( $download_range['length'] ) ? $download_range['length'] : 0;
if ( ! self::readfile_chunked( $parsed_file_path['file_path'], $start, $length ) ) {
if ( $parsed_file_path['remote_file'] && 'yes' === get_option( 'woocommerce_downloads_redirect_fallback_allowed' ) ) {
wc_get_logger()->warning(
sprintf(
/* translators: %1$s contains the filepath of the digital asset. */
__( '%1$s could not be served using the Force Download method. A redirect will be used instead.', 'woocommerce' ),
$file_path
)
);
self::download_file_redirect( $file_path );
} else {
self::download_error( __( 'File not found', 'woocommerce' ) );
}
}
exit;
}