WC_Download_Handler::download()public staticWC 1.0

Download a file - hook into init function.

Метод класса: WC_Download_Handler{}

Возвращает

null. Ничего (null).

Использование

$result = WC_Download_Handler::download( $file_path, $product_id );
$file_path(строка) (обязательный)
URL to file.
$product_id(int) (обязательный)
Product ID of the product being downloaded.

Код WC_Download_Handler::download() WC 8.7.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 );
}