\um\commonFilesystem

Class Filesystem

Summary

Methods
Properties
Constants
__construct()
init_paths()
files_age()
image_mimes()
clear_temp_dir()
get_upload_dir()
get_upload_url()
format_bytes()
maybe_init_wp_filesystem()
remove_dir()
$upload_dir
$upload_url
$temp_upload_dir
$temp_upload_url
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$upload_dir

$upload_dir : array

Type

normal

$upload_url

$upload_url : array

Type

normal

$temp_upload_dir

$temp_upload_dir : string

Type

normal

$temp_upload_url

$temp_upload_url : string

Type

normal

Methods

__construct()

__construct() : mixed

Filesystem constructor.

Returns

mixed

init_paths()

init_paths() : mixed

Init uploading URL and directory

Returns

mixed

files_age()

files_age() : int

Files Age in the temp folder. By default, it's 24 hours.

Returns

int —

Temp file age in seconds.

image_mimes()

image_mimes(string  $context = 'list') : array

Image MIME Types

Retrieves a list of image MIME types based on the context.

Parameters

string $context

The context in which the MIME types are needed ('list' or 'allowed').

Returns

array —

List of image MIME types based on the context.

clear_temp_dir()

clear_temp_dir() : mixed

Remove all files, which are older than 24 hours

Can duplicate this function functionality remove_old_files

Returns

mixed

get_upload_dir()

get_upload_dir(string  $dir = '', int|null  $blog_id = null) : string

Get upload dir of plugin

Parameters

string $dir
int|null $blog_id

Returns

string

get_upload_url()

get_upload_url(string  $url = '', int|null  $blog_id = null) : string

Get upload url of plugin

Parameters

string $url
int|null $blog_id

Returns

string

format_bytes()

format_bytes(int  $size, int  $precision = 1) : string

Format Bytes

Parameters

int $size
int $precision

Returns

string

maybe_init_wp_filesystem()

maybe_init_wp_filesystem() : void

Probably define global $wp_filesystem.

remove_dir()

remove_dir(string  $dir) : bool

Remove a directory using WP Filesystem.

Parameters

string $dir

The directory path to be removed. Should end with DIRECTORY_SEPARATOR.

Returns

bool —

True on success, false on failure or if directory doesn't exist.