WooCommerce Code Reference

WC_Product_Download
in package
implements ArrayAccess

Product download class.

Interfaces, Classes and Traits

ArrayAccess

Table of Contents

$data  : array<string|int, mixed>
Data array.
file_exists()  : bool
Validate file exists.
get_allowed_mime_types()  : array<string|int, mixed>
Get allowed mime types.
get_data()  : array<string|int, mixed>
Returns all data for this object.
get_enabled()  : bool
Get status of the download.
get_file()  : string
Get file.
get_file_extension()  : string
Get file extension.
get_file_type()  : string
Get file type.
get_id()  : string
Get id.
get_name()  : string
Get name.
get_previous_hash()  : string
Get previous_hash.
get_type_of_file_path()  : string
Get type of file path set.
is_allowed_filetype()  : bool
Check if file is allowed.
offsetExists()  : bool
OffsetExists.
offsetGet()  : mixed
OffsetGet.
offsetSet()  : mixed
OffsetSet.
offsetUnset()  : mixed
OffsetUnset.
set_enabled()  : mixed
Sets the status of the download to enabled (true) or disabled (false).
set_file()  : mixed
Set file.
set_id()  : mixed
Set ID.
set_name()  : mixed
Set name.
set_previous_hash()  : mixed
Set previous_hash.
approved_directory_checks()  : mixed
Confirms that the download exists within an approved directory.
raise_invalid_file_exception()  : void
Convenience method, allows us to re-use the same exception messaging from different areas.

Properties

Methods

get_allowed_mime_types()

Get allowed mime types.

public get_allowed_mime_types() : array<string|int, mixed>
Return values
array<string|int, mixed>

get_previous_hash()

Get previous_hash.

public get_previous_hash() : string
Tags
deprecated
3.3.0

No longer using filename based hashing to keep track of files.

Return values
string

get_type_of_file_path()

Get type of file path set.

public get_type_of_file_path([string $file_path = '' ]) : string
Parameters
$file_path : string = ''

optional.

Return values
stringabsolute, relative, or shortcode.

offsetSet()

OffsetSet.

public offsetSet(string $offset, mixed $value) : mixed
Parameters
$offset : string

Offset.

$value : mixed

Offset value.

Return values
mixed

set_enabled()

Sets the status of the download to enabled (true) or disabled (false).

public set_enabled([bool $enabled = true ]) : mixed
Parameters
$enabled : bool = true

True indicates the downloadable file is enabled, false indicates it is disabled.

Return values
mixed

set_previous_hash()

Set previous_hash.

public set_previous_hash(string $value) : mixed
Parameters
$value : string

Previous hash.

Tags
deprecated
3.3.0

No longer using filename based hashing to keep track of files.

Return values
mixed

approved_directory_checks()

Confirms that the download exists within an approved directory.

private approved_directory_checks([bool $auto_add_to_approved_directory_list = true ]) : mixed

If it is not within an approved directory but the current user has sufficient capabilities, then the method will try to add the download's directory to the approved directory list.

Parameters
$auto_add_to_approved_directory_list : bool = true

If the download is not already in the approved directory list, automatically add it if possible.

Tags
throws
Exception

If the download is not in an approved directory.

Return values
mixed

raise_invalid_file_exception()

Convenience method, allows us to re-use the same exception messaging from different areas.

private raise_invalid_file_exception(string $download_file) : void
Parameters
$download_file : string
Tags
throws
Exception
Return values
void