WooCommerce Code Reference

Search results

WC_Download_Handler

Download handler class.

Table of Contents

init() Hook in methods. mixed
download_product() Check if we need to download a file and check validity. mixed
check_order_is_valid() Check if an order is valid for downloading from. mixed
check_downloads_remaining() Check if there are downloads remaining. mixed
check_download_expiry() Check if the download has expired. mixed
check_download_login_required() Check if a download requires the user to login first. mixed
count_download() Count download. mixed
download() Download a file - hook into init function. mixed
download_file_redirect() Redirect to a file to start the download. mixed
parse_file_path() Parse file path and see if its remote or local. array
download_file_xsendfile() Download a file using X-Sendfile, X-Lighttpd-Sendfile, or X-Accel-Redirect if available. mixed
get_download_range() Parse the HTTP_RANGE request from iOS devices. array
download_file_force() Force download - this is the default method. mixed
get_download_content_type() Get content type of a download. string
download_headers() Set headers for the download. mixed
check_server_config() Check and set certain server config variables to ensure downloads work as intended. mixed
clean_buffers() Clean all output buffers. mixed
readfile_chunked() Read file chunked. bool
ie_nocache_headers_fix() Filter headers for IE to fix issues over SSL. array
download_error() Die with an error message if the download fails. mixed

Methods

download_product()

Check if we need to download a file and check validity.

public static download_product( ) : mixed
Return values
mixed

count_download()

Count download.

public static count_download( $download_data : array ) : mixed
Parameters
$download_data : array

Download data.

Tags
deprecated
Return values
mixed

download()

Download a file - hook into init function.

public static download( $file_path : string , $product_id : int ) : mixed
Parameters
$file_path : string

URL to file.

$product_id : int

Product ID of the product being downloaded.

Return values
mixed

download_file_redirect()

Redirect to a file to start the download.

public static download_file_redirect( $file_path : string [, $filename : string = '' ] ) : mixed
Parameters
$file_path : string

File path.

$filename : string = ''

File name.

Return values
mixed

parse_file_path()

Parse file path and see if its remote or local.

public static parse_file_path( $file_path : string ) : array
Parameters
$file_path : string

File path.

Return values
array

download_file_xsendfile()

Download a file using X-Sendfile, X-Lighttpd-Sendfile, or X-Accel-Redirect if available.

public static download_file_xsendfile( $file_path : string , $filename : string ) : mixed
Parameters
$file_path : string

File path.

$filename : string

File name.

Return values
mixed

get_download_range()

Parse the HTTP_RANGE request from iOS devices.

protected static get_download_range( $file_size : int ) : array

Does not support multi-range requests.

Parameters
$file_size : int

Size of file in bytes.

Return values
array

{ Information about range download request: beginning and length of file chunk, whether the range is valid/supported and whether the request is a range request.

@type int  $start            Byte offset of the beginning of the range. Default 0.
@type int  $length           Length of the requested file chunk in bytes. Optional.
@type bool $is_range_valid   Whether the requested range is a valid and supported range.
@type bool $is_range_request Whether the request is a range request.

}

download_file_force()

Force download - this is the default method.

public static download_file_force( $file_path : string , $filename : string ) : mixed
Parameters
$file_path : string

File path.

$filename : string

File name.

Return values
mixed

get_download_content_type()

Get content type of a download.

private static get_download_content_type( $file_path : string ) : string
Parameters
$file_path : string

File path.

Return values
string

download_headers()

Set headers for the download.

private static download_headers( $file_path : string , $filename : string [, $download_range : array = array() ] ) : mixed
Parameters
$file_path : string

File path.

$filename : string

File name.

$download_range : array = array()

Array containing info about range download request (see {@see \get_download_range} for structure).

Return values
mixed

check_server_config()

Check and set certain server config variables to ensure downloads work as intended.

private static check_server_config( ) : mixed
Return values
mixed

clean_buffers()

Clean all output buffers.

private static clean_buffers( ) : mixed

Can prevent errors, for example: transfer closed with 3 bytes remaining to read.

Return values
mixed

readfile_chunked()

Read file chunked.

public static readfile_chunked( $file : string , $start : int , $length : int ) : bool

Reads file in chunks so big downloads are possible without changing PHP.INI - http://codeigniter.com/wiki/Download_helper_for_large_files/.

Parameters
$file : string

File.

$start : int

Byte offset/position of the beginning from which to read from the file.

$length : int

Length of the chunk to be read from the file in bytes, 0 means full file.

Return values
bool

Success or fail

ie_nocache_headers_fix()

Filter headers for IE to fix issues over SSL.

public static ie_nocache_headers_fix( $headers : array ) : array

IE bug prevents download via SSL when Cache Control and Pragma no-cache headers set.

Parameters
$headers : array

HTTP headers.

Return values
array

download_error()

Die with an error message if the download fails.

private static download_error( $message : string [, $title : string = '' ] [, $status : int = 404 ] ) : mixed
Parameters
$message : string

Error message.

$title : string = ''

Error title.

$status : int = 404

Error status.

Return values
mixed
Back to the top