Document

Document Controller

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

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_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_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_preview_button()  : string
Generate the Preview button HTML markup
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.
set_document_link()  : mixed
Sets the document link data
set_download_count()  : mixed
Set the download count meta
set_file_id()  : mixed
Set the file id meta
set_file_size()  : mixed
Set the file size meta
set_version_history()  : mixed
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_delete_attachment()  : mixed
purge_attachments()  : mixed

Properties

$post_object

public mixed $post_object
Tags

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, ]

Tags
Return values
mixed

get_author_list()

Gets the comma seperated author list

public get_author_list() : string
Tags
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
Tags
Return values
string

$category_list

get_custom_fields_list()

Gets the custom fields list.

public get_custom_fields_list() : string
Tags
Return values
string

$custom_fields_list

Gets the direct link URL

public get_direct_link() : string
Tags
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
Tags
Return values
string

get_download_count()

Gets the file size meta

public get_download_count() : string
Tags
Return values
string

get_download_url()

Gets the download URL

public get_download_url() : string
Tags
Return values
string

get_file_icon()

Retrieves the associated file type icon

public get_file_icon() : string
Tags
Return values
string

$file_icon

get_file_id()

Retrieves the attached file id

public get_file_id() : string
Tags
Return values
string

get_file_name()

Retrieves the attached file name

public get_file_name() : string
Tags
Return values
string

get_file_size()

Gets the file size meta

public get_file_size() : string
Tags
Return values
string

get_file_type()

Gets the associated file type

public get_file_type() : string
Tags
Return values
string

get_id()

Returns the document ID

public get_id() : int
Tags
Return values
int

Gets the link type

public get_link_type() : string
Tags
Return values
string

Gets the link version, if any

public get_link_version() : string
Tags
Return values
string

get_meta_data()

Retrieves meta data from the post

public get_meta_data(string $key) : string
Parameters
$key : string
Tags
Return values
string

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'
Tags
Return values
string

get_tag_list()

Gets the comma seperated tag list

public get_tag_list() : string
Tags
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
since
1.8.0
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
Tags
Return values
bool

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'

Tags
Return values
mixed

set_download_count()

Set the download count meta

public set_download_count(string $download_count) : mixed
Parameters
$download_count : string
Tags
Return values
mixed

set_file_id()

Set the file id meta

public set_file_id(string $file_id) : mixed
Parameters
$file_id : string
Tags
Return values
mixed

set_file_size()

Set the file size meta

public set_file_size(string $file_size) : mixed
Parameters
$file_size : string
Tags
Return values
mixed

set_version_history()

public set_version_history(mixed $version_history) : mixed
Parameters
$version_history : mixed
Tags
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.

Tags
Return values
mixed

create_document()

Creates a new document

protected create_document(array<string|int, mixed> $data) : mixed
Parameters
$data : array<string|int, mixed>
Tags
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
throws
Exception

Failed to create document.

Return values
int

$document_id

fetch_document()

Fetch and setup existing document

protected fetch_document(int $id) : mixed
Parameters
$id : int
Tags
throws
Exception

Document does not exist.

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
Tags
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
Tags
Return values
mixed

set_file_type()

Sets the file type taxonomy if there is associated file

protected set_file_type() : mixed
Tags
Return values
mixed

set_meta_data()

Sets meta data

protected set_meta_data(string $key, string $value) : mixed
Parameters
$key : string
$value : string
Tags
Return values
mixed

autocalculate_file_size()

Determines the attached file size.

private autocalculate_file_size(int $file_id) : mixed
Parameters
$file_id : int
Tags
Return values
mixed

Retrieves the download button text

private ensure_download_button_link_text(string $link_text) : string
Parameters
$link_text : string
Tags
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
Tags
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
Tags
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 = ', '
Tags
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 = ', '
Tags
Return values
false|string

maybe_delete_attachment()

private maybe_delete_attachment(mixed $new_id) : mixed
Parameters
$new_id : mixed
Tags
Return values
mixed

purge_attachments()

private purge_attachments(mixed $version_history) : mixed
Parameters
$version_history : mixed
Tags
Return values
mixed

Search results