Documentation

Meta
in package
implements IMetadata Uses UtilsProvider

Create general functionality for the custom folder fields.

For an example see the function-doc of this::content_general and this::save_general

Table of Contents

Interfaces

IMetadata
Metadata content of a folder. The metadata can be changed in the arrow-down icon in the folders sidebar toolbar. To handle metadata for folders you can use the add_media_folder_meta function.

Properties

$boxes  : mixed
$me  : mixed
$view  : mixed

Methods

add()  : bool
Add meta box.
content()  : string
Return modified content for the meta box.
exists()  : bool
Check if a meta box exists by name.
folder_deleted()  : mixed
When a folder gets deleted, also delete meta.
get()  : IMetadata|null
Get meta box instance.
getInstance()  : Meta
Get instance.
getPluginConstantPrefix()  : string
Get the prefix of this plugin so composer packages can dynamically build other constant values on it.
prepare_content()  : mixed
Prepare the whole content for a single meta box.
save()  : array<string|int, string>
Save the infos. Add an error to the array to show on the frontend dialog. Add an successful data to receive it in JavaScript.
scripts()  : mixed
Enqueue scripts and styles for this meta box.
__construct()  : mixed
C'tor.

Properties

$boxes

private mixed $boxes = []

$me

private static mixed $me = null

$view

private mixed $view = null

Methods

add()

Add meta box.

public add(string $name, IMetadata $instance) : bool
Parameters
$name : string
$instance : IMetadata
Return values
bool

content()

Return modified content for the meta box.

public content(mixed $content, mixed $folder) : string

Note: If you want to use a more complex content in a meta table use something like this:

<tr>
 <th scope="row">Medium size</th>
 <td><fieldset>
     <legend class="screen-reader-text"><span>Medium size</span></legend>
     <label for="medium_size_w">Max Width</label>
     <input name="medium_size_w" type="number" step="1" min="0" id="medium_size_w" value="300" class="small-text">
     <label for="medium_size_h">Max Height</label>
     <input name="medium_size_h" type="number" step="1" min="0" id="medium_size_h" value="300" class="small-text">
 </fieldset></td>
</tr>

If you want to "group" your meta boxes you can use this code to create a empty space: <tr class="rml-meta-margin"></tr>

Parameters
$content : mixed

the HTML formatted string for the dialog

$folder : mixed

The folder object

Return values
string

exists()

Check if a meta box exists by name.

public exists(string $name) : bool
Parameters
$name : string
Return values
bool

folder_deleted()

When a folder gets deleted, also delete meta.

public folder_deleted(int $fid, mixed $oldData) : mixed
Parameters
$fid : int
$oldData : mixed

get()

Get meta box instance.

public get(string $name) : IMetadata|null
Parameters
$name : string
Return values
IMetadata|null

getInstance()

Get instance.

public static getInstance() : Meta
Return values
Meta

getPluginConstantPrefix()

Get the prefix of this plugin so composer packages can dynamically build other constant values on it.

public getPluginConstantPrefix() : string
Tags
codeCoverageIgnore

It only returns a string with the constant prefix

Return values
string

prepare_content()

Prepare the whole content for a single meta box.

public prepare_content(int $fid) : mixed
Parameters
$fid : int

save()

Save the infos. Add an error to the array to show on the frontend dialog. Add an successful data to receive it in JavaScript.

public save(mixed $response, mixed $folder, mixed $request) : array<string|int, string>
$response["errors"][] = "Your error";
$response["data"]["myData"] = "Test";

Since v.4.0.8 the minimum PHP version is 4.0.8 and you can use traits in your meta implementation: metadata\CommonTrait, metadata\CommonFolderTrait or usersettings\CommonUserSettingsTrait.

Parameters
$response : mixed

Array of errors and successful data.

$folder : mixed

The folder object

$request : mixed

The server request

Return values
array<string|int, string>

scripts()

Enqueue scripts and styles for this meta box.

public scripts(mixed $assets) : mixed
Parameters
$assets : mixed

The assets instance so you can enqueue library scripts

__construct()

C'tor.

private __construct() : mixed

        
On this page

Search results