Attachment extends Component

Handles file attachments.

Table of Contents

__construct()  : mixed
Class constructor.
delete_attachment()  : mixed
Deletes attachment.
delete_attachments()  : mixed
Deletes attachments.
filter_attachments()  : array<string|int, mixed>
Filters attachments.
filter_shortcode_attachments()  : mixed
Filters shortcode attachments.
generate_filename()  : string
Generates a unique filename.
get_parent_statuses()  : array<string|int, mixed>
Gets allowed parent statuses.
is_editable_parent()  : bool
Checks if the parent object is editable.
is_valid_file()  : bool
Checks if the file is valid.
move_attachments()  : mixed
Moves attachments.
restrict_attachment_embed()  : int
Restricts attachment embed.
restrict_attachment_page()  : array<string|int, mixed>
Restricts attachment page.
restrict_attachment_shortcode()  : array<string|int, mixed>
Restricts attachment shortcode.
restrict_rest_attachment()  : object
Restricts REST attachment.
set_parent_id()  : array<string|int, mixed>
Sets the attachment parent ID.
boot()  : mixed
Bootstraps component properties.
is_restricted_attachment()  : bool
Checks if the attachment is restricted.
set_callbacks()  : mixed
Sets the action and filter callbacks.
set_property()  : mixed
Sets a property value.

Methods

__construct()

Class constructor.

public __construct([array<string|int, mixed> $args = [] ]) : mixed
Parameters
$args : array<string|int, mixed> = []

Component arguments.

Return values
mixed —

delete_attachment()

Deletes attachment.

public delete_attachment(int $attachment_id, object $attachment) : mixed
Parameters
$attachment_id : int

Attachment ID.

$attachment : object

Attachment object.

Return values
mixed —

delete_attachments()

Deletes attachments.

public delete_attachments(int $parent_id, string $parent_alias) : mixed
Parameters
$parent_id : int

Parent ID.

$parent_alias : string

Parent alias.

Return values
mixed —

filter_attachments()

Filters attachments.

public filter_attachments(array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed>

Query arguments.

Return values
array<string|int, mixed> —

filter_shortcode_attachments()

Filters shortcode attachments.

public filter_shortcode_attachments(object $query) : mixed
Parameters
$query : object

Query object.

Return values
mixed —

generate_filename()

Generates a unique filename.

public generate_filename(string $filename, string $ext, string $dir) : string
Parameters
$filename : string

Filename.

$ext : string

Extension.

$dir : string

Directory.

Return values
string —

is_editable_parent()

Checks if the parent object is editable.

public is_editable_parent(object $object) : bool
Parameters
$object : object

Parent object.

Return values
bool —

is_valid_file()

Checks if the file is valid.

public is_valid_file(string $path, string $name, array<string|int, mixed> $exts) : bool
Parameters
$path : string

File path.

$name : string

File name.

$exts : array<string|int, mixed>

Allowed extensions.

Return values
bool —

move_attachments()

Moves attachments.

public move_attachments(object $from, object $to, string $field) : mixed
Parameters
$from : object

Source object.

$to : object

Target object.

$field : string

Field name.

Return values
mixed —

restrict_attachment_embed()

Restricts attachment embed.

public restrict_attachment_embed(int $post_id) : int
Parameters
$post_id : int

Post ID.

Return values
int —

restrict_attachment_page()

Restricts attachment page.

public restrict_attachment_page(array<string|int, mixed> $posts, object $query) : array<string|int, mixed>
Parameters
$posts : array<string|int, mixed>

Post objects.

$query : object

Query object.

Return values
array<string|int, mixed> —

restrict_attachment_shortcode()

Restricts attachment shortcode.

public restrict_attachment_shortcode(array<string|int, mixed> $atts) : array<string|int, mixed>
Parameters
$atts : array<string|int, mixed>

Shortcode attributes.

Return values
array<string|int, mixed> —

restrict_rest_attachment()

Restricts REST attachment.

public restrict_rest_attachment(object $response, object $attachment) : object
Parameters
$response : object

REST response.

$attachment : object

Attachment object.

Return values
object —

set_parent_id()

Sets the attachment parent ID.

public set_parent_id(array<string|int, mixed> $attachment, array<string|int, mixed> $args) : array<string|int, mixed>
Parameters
$attachment : array<string|int, mixed>

Attachment arguments.

$args : array<string|int, mixed>

Query arguments.

Return values
array<string|int, mixed> —

is_restricted_attachment()

Checks if the attachment is restricted.

protected is_restricted_attachment(int $attachment_id) : bool
Parameters
$attachment_id : int

Attachment ID.

Return values
bool —

set_callbacks()

Sets the action and filter callbacks.

protected final set_callbacks(array<string|int, mixed> $callbacks) : mixed
Parameters
$callbacks : array<string|int, mixed>

Callback arguments.

Return values
mixed —

set_property()

Sets a property value.

protected final set_property(string $name, mixed $value[, string $prefix = '' ]) : mixed
Parameters
$name : string

Property name.

$value : mixed

Property value.

$prefix : string = ''

Method prefix.

Return values
mixed —