WC_Download_Handler::download() public WC 1.0
Download a file - hook into init function.
{} Это метод класса: WC_Download_Handler{}
Хуки из метода
Возвращает
Null. Ничего.
Использование
$result = WC_Download_Handler::download( $file_path, $product_id );
- $file_path(строка) (обязательный)
- URL to file.
- $product_id(числоeger) (обязательный)
- Product ID of the product being downloaded.
Код WC_Download_Handler::download() WC Download Handler::download WC 5.0.0
public static function download( $file_path, $product_id ) {
if ( ! $file_path ) {
self::download_error( __( 'No file defined', 'woocommerce' ) );
}
$filename = basename( $file_path );
if ( strstr( $filename, '?' ) ) {
$filename = current( explode( '?', $filename ) );
}
$filename = apply_filters( 'woocommerce_file_download_filename', $filename, $product_id );
/**
* Filter download method.
*
* @since 4.5.0
* @param string $method Download method.
* @param int $product_id Product ID.
* @param string $file_path URL to file.
*/
$file_download_method = apply_filters( 'woocommerce_file_download_method', get_option( 'woocommerce_file_download_method', 'force' ), $product_id, $file_path );
// Add action to prevent issues in IE.
add_action( 'nocache_headers', array( __CLASS__, 'ie_nocache_headers_fix' ) );
// Trigger download via one of the methods.
do_action( 'woocommerce_download_file_' . $file_download_method, $file_path, $filename );
}