Document
Document Controller
Tags
Table of Contents
- $post_object : mixed
- $id : int
- ID
- __construct() : mixed
- Constructor
- get_author_list() : string
- Gets the comma seperated author list
- get_category_list() : string
- Gets the comma seperated category list.
- get_custom_fields_list() : string
- Gets the custom fields list.
- get_direct_link() : string
- Gets the direct link URL
- get_download_button() : string
- Generate the download button HTML markup.
- get_download_count() : string
- Gets the file size meta
- get_download_url() : string
- Gets the download URL
- get_expiry_status() : string
- Retrieves the document expiry status
- get_expiry_timestamp() : string
- Retrieves the document expiry timestamp
- get_file_icon() : string
- Retrieves the associated file type icon
- get_file_id() : string
- Retrieves the attached file id
- get_file_name() : string
- Retrieves the attached file name
- get_file_size() : string
- Gets the file size meta
- get_file_type() : string
- Gets the associated file type
- get_filename() : mixed
- Get the filename
- get_id() : int
- Returns the document ID
- get_link_type() : string
- Gets the link type
- get_link_version() : string
- Gets the link version, if any
- get_meta_data() : string
- Retrieves meta data from the post
- get_mime_type() : string|null
- Retrieves the mime type of the file.
- get_preview_button() : string
- Generate the Preview button HTML markup
- get_preview_url() : mixed
- Get's the preview URL.
- get_tag_list() : string
- Gets the comma seperated tag list
- get_version_history() : bool|array<string|int, mixed>
- Retrieves a list of files and urls attached to this document.
- is_allowed_preview_mime_type() : bool
- Determine if the file mime type can have a preview.
- maybe_clean_up_attached_file() : mixed
- Clean up attached file (used for switching/updating document link)
- maybe_set_file_as_featured_image() : mixed
- Check if we have a valid file and if so, set it as the featured image
- set_document_link() : mixed
- Sets the document link data
- set_download_count() : mixed
- Set the download count meta
- set_expiry_timestamp() : mixed
- Sets the expiry timestamp
- set_file_id() : mixed
- Set the file id meta
- set_file_size() : mixed
- Set the file size meta
- set_version_history() : mixed
- Set the version history meta
- attach_file_from_url() : mixed
- Downloads a file from a URL and attaches it to the document
- create_document() : mixed
- Creates a new document
- create_wp_post() : int
- Creates the WP_Post and associates taxonomies
- fetch_document() : mixed
- Fetch and setup existing document
- set_acf_data() : mixed
- Sets Advanced Custom Fields data
- set_ept_data() : mixed
- Sets Easy Post Types data
- set_file_type() : mixed
- Sets the file type taxonomy if there is associated file
- set_meta_data() : mixed
- Sets meta data
- autocalculate_file_size() : mixed
- Determines the attached file size.
- ensure_download_button_link_text() : string
- Retrieves the download button text
- get_download_button_attributes() : string
- Retrieves the 'download' attribute.
- get_download_button_href() : string|false
- Retrieve the download button 'href' attribute.
- get_the_linked_term_names() : false|string
- Retrieves a linked list of term names.
- get_the_term_names() : false|string
- Retrieves a list of term names.
- maybe_check_office_file_exceeds_size_limit() : bool
- Checks if the document is an MS Office document and exceeds the preview limit.
- maybe_delete_attachment() : mixed
- Delete version control attachment.
- purge_attachments() : mixed
- Purge attachments that are no longer in the version history.
Properties
$post_object
public
mixed
$post_object
$id
ID
protected
int
$id
= 0
Methods
__construct()
Constructor
public
__construct(int $id[, array<string|int, mixed> $data = [] ]) : mixed
Parameters
- $id : int
- $data : array<string|int, mixed> = []
-
[ name, excerpt, file_size, ]
Return values
mixed —get_author_list()
Gets the comma seperated author list
public
get_author_list() : string
Return values
string —$author_list
get_category_list()
Gets the comma seperated category list.
public
get_category_list([bool $link = false ]) : string
Parameters
- $link : bool = false
Return values
string —$category_list
get_custom_fields_list()
Gets the custom fields list.
public
get_custom_fields_list() : string
Return values
string —$custom_fields_list
get_direct_link()
Gets the direct link URL
public
get_direct_link() : string
Return values
string —get_download_button()
Generate the download button HTML markup.
public
get_download_button(string $link_text[, string $link_style = 'button' ][, string $link_destination = 'direct' ][, bool $link_target = false ]) : string
Parameters
- $link_text : string
- $link_style : string = 'button'
- $link_destination : string = 'direct'
- $link_target : bool = false
Return values
string —get_download_count()
Gets the file size meta
public
get_download_count() : string
Return values
string —get_download_url()
Gets the download URL
public
get_download_url() : string
Return values
string —get_expiry_status()
Retrieves the document expiry status
public
get_expiry_status() : string
Return values
string —get_expiry_timestamp()
Retrieves the document expiry timestamp
public
get_expiry_timestamp() : string
Return values
string —get_file_icon()
Retrieves the associated file type icon
public
get_file_icon() : string
Return values
string —$file_icon
get_file_id()
Retrieves the attached file id
public
get_file_id() : string
Return values
string —get_file_name()
Retrieves the attached file name
public
get_file_name() : string
Return values
string —get_file_size()
Gets the file size meta
public
get_file_size() : string
Return values
string —get_file_type()
Gets the associated file type
public
get_file_type() : string
Return values
string —get_filename()
Get the filename
public
get_filename() : mixed
Return values
mixed —get_id()
Returns the document ID
public
get_id() : int
Return values
int —get_link_type()
Gets the link type
public
get_link_type() : string
Return values
string —get_link_version()
Gets the link version, if any
public
get_link_version() : string
Return values
string —get_meta_data()
Retrieves meta data from the post
public
get_meta_data(string $key) : string
Parameters
- $key : string
Return values
string —get_mime_type()
Retrieves the mime type of the file.
public
get_mime_type() : string|null
Return values
string|null —get_preview_button()
Generate the Preview button HTML markup
public
get_preview_button(string $link_text[, string $link_style = 'button_icon' ][, string $view = 'table' ]) : string
The preview scripts should still be enqueued if this is used outside of the core DLP preview areas.
Parameters
- $link_text : string
- $link_style : string = 'button_icon'
- $view : string = 'table'
Return values
string —get_preview_url()
Get's the preview URL.
public
get_preview_url() : mixed
Mainly used to format Dropbox URLs for the preview.
Return values
mixed —get_tag_list()
Gets the comma seperated tag list
public
get_tag_list() : string
Return values
string —$tag_list
get_version_history()
Retrieves a list of files and urls attached to this document.
public
get_version_history() : bool|array<string|int, mixed>
This method can be passed an option $type parameter. If no parameter is passed, $type will default to the result of get_link_type(). If any truthy value other than 'url' or 'file' is passed, the version history for both link types will be returned.
Tags
Return values
bool|array<string|int, mixed> —A list of file versions or false if version history is disabled
is_allowed_preview_mime_type()
Determine if the file mime type can have a preview.
public
is_allowed_preview_mime_type() : bool
Return values
bool —maybe_clean_up_attached_file()
Clean up attached file (used for switching/updating document link)
public
maybe_clean_up_attached_file() : mixed
Return values
mixed —maybe_set_file_as_featured_image()
Check if we have a valid file and if so, set it as the featured image
public
maybe_set_file_as_featured_image() : mixed
Return values
mixed —set_document_link()
Sets the document link data
public
set_document_link(string $type[, array<string|int, mixed> $data = [] ]) : mixed
Parameters
- $type : string
-
'url' | 'file' | 'none
- $data : array<string|int, mixed> = []
-
Should contain 'direct_url' for 'url' or 'file_id' for 'file'
Return values
mixed —set_download_count()
Set the download count meta
public
set_download_count(string $download_count) : mixed
Parameters
- $download_count : string
Return values
mixed —set_expiry_timestamp()
Sets the expiry timestamp
public
set_expiry_timestamp(mixed $timestamp) : mixed
Parameters
- $timestamp : mixed
Return values
mixed —set_file_id()
Set the file id meta
public
set_file_id(string $file_id) : mixed
Parameters
- $file_id : string
Return values
mixed —set_file_size()
Set the file size meta
public
set_file_size(string $file_size) : mixed
Parameters
- $file_size : string
Return values
mixed —set_version_history()
Set the version history meta
public
set_version_history(array<string|int, mixed> $version_history) : mixed
Parameters
- $version_history : array<string|int, mixed>
Return values
mixed —attach_file_from_url()
Downloads a file from a URL and attaches it to the document
protected
attach_file_from_url(string $url) : mixed
Parameters
- $url : string
-
Attachment URL.
Return values
mixed —create_document()
Creates a new document
protected
create_document(array<string|int, mixed> $data) : mixed
Parameters
- $data : array<string|int, mixed>
Return values
mixed —create_wp_post()
Creates the WP_Post and associates taxonomies
protected
create_wp_post(array<string|int, mixed> $data) : int
Parameters
- $data : array<string|int, mixed>
Tags
Return values
int —$document_id
fetch_document()
Fetch and setup existing document
protected
fetch_document(int $id) : mixed
Parameters
- $id : int
Tags
Return values
mixed —set_acf_data()
Sets Advanced Custom Fields data
protected
set_acf_data(string $key, string $value) : mixed
Parameters
- $key : string
- $value : string
Return values
mixed —set_ept_data()
Sets Easy Post Types data
protected
set_ept_data(string $key, string $value) : mixed
Parameters
- $key : string
- $value : string
Return values
mixed —set_file_type()
Sets the file type taxonomy if there is associated file
protected
set_file_type() : mixed
Return values
mixed —set_meta_data()
Sets meta data
protected
set_meta_data(string $key, string $value) : mixed
Parameters
- $key : string
- $value : string
Return values
mixed —autocalculate_file_size()
Determines the attached file size.
private
autocalculate_file_size(int $file_id) : mixed
Parameters
- $file_id : int
Return values
mixed —ensure_download_button_link_text()
Retrieves the download button text
private
ensure_download_button_link_text(string $link_text) : string
Parameters
- $link_text : string
Return values
string —get_download_button_attributes()
Retrieves the 'download' attribute.
private
get_download_button_attributes([bool $link_target = false ]) : string
Parameters
- $link_target : bool = false
Return values
string —get_download_button_href()
Retrieve the download button 'href' attribute.
private
get_download_button_href(string $link_destination) : string|false
Parameters
- $link_destination : string
Return values
string|false —get_the_linked_term_names()
Retrieves a linked list of term names.
private
get_the_linked_term_names(WP_Post $post, string $taxonomy[, string $sep = ', ' ]) : false|string
Parameters
- $post : WP_Post
- $taxonomy : string
- $sep : string = ', '
Return values
false|string —get_the_term_names()
Retrieves a list of term names.
private
get_the_term_names(WP_Post $post, string $taxonomy[, string $sep = ', ' ]) : false|string
Parameters
- $post : WP_Post
- $taxonomy : string
- $sep : string = ', '
Return values
false|string —maybe_check_office_file_exceeds_size_limit()
Checks if the document is an MS Office document and exceeds the preview limit.
private
maybe_check_office_file_exceeds_size_limit() : bool
Return values
bool —maybe_delete_attachment()
Delete version control attachment.
private
maybe_delete_attachment(int|string $new_id) : mixed
Parameters
- $new_id : int|string
Return values
mixed —purge_attachments()
Purge attachments that are no longer in the version history.
private
purge_attachments(array<string|int, mixed> $version_history) : mixed
Parameters
- $version_history : array<string|int, mixed>