plugins/real-media-library/src/inc/apimeta.php

Functions

get_media_folder_meta()

get_media_folder_meta(integer  $folder_id,string  $key = '',boolean  $single = false): array<mixed,mixed>|mixed

Retrieve folder meta field for a folder.

Parameters

integer $folder_id

Folder ID.

string $key

The meta key to retrieve. By default, returns data for all keys.

boolean $single

Whether to return a single value. Default false.

Returns

array<mixed,mixed>|mixed —

Will be an array if $single is false. Will be value of meta data field if $single is true.

add_media_folder_meta()

add_media_folder_meta(integer  $folder_id,string  $meta_key,mixed  $meta_value,boolean  $unique = false): integer|false

Add meta data field to a folder.

Folder meta data is called "Custom Fields" on the Administration Screen.

Parameters

integer $folder_id

Folder ID.

string $meta_key

Metadata name.

mixed $meta_value

Metadata value. Must be serializable if non-scalar.

boolean $unique

Whether the same key should not be added.

Returns

integer|false

update_media_folder_meta()

update_media_folder_meta(integer  $folder_id,string  $meta_key,mixed  $meta_value,mixed  $prev_value = ''): integer|boolean

Update folder meta field based on folder ID.

Use the $prev_value parameter to differentiate between meta fields with the same key and folder ID.

If the meta field for the folder does not exist, it will be added.

Parameters

integer $folder_id

Folder ID.

string $meta_key

Metadata key.

mixed $meta_value

Metadata value. Must be serializable if non-scalar.

mixed $prev_value

Previous value to check before removing.

Returns

integer|boolean

delete_media_folder_meta()

delete_media_folder_meta(integer  $folder_id,string  $meta_key,mixed  $meta_value = ''): boolean

Remove metadata matching criteria from a folder.

You can match based on the key, or key and value. Removing based on key and value, will keep from removing duplicate metadata with the same key. It also allows removing all metadata matching key, if needed.

Parameters

integer $folder_id

Folder ID.

string $meta_key

Metadata name.

mixed $meta_value

Metadata value. Must be serializable if non-scalar.

Returns

boolean —

True on success, false on failure.

delete_media_folder_meta_by_key()

delete_media_folder_meta_by_key(string  $folder_meta_key): boolean

Delete everything from folder meta matching meta key.

Parameters

string $folder_meta_key

Key to search for when deleting.

Returns

boolean —

Whether the post meta key was deleted from the database.

truncate_media_folder_meta()

truncate_media_folder_meta(integer  $folder_id): integer

Remove all meta of a folder. Use this with caution!!

Parameters

integer $folder_id

Folder ID

Returns

integer

add_rml_user_settings_box()

add_rml_user_settings_box(string  $name,\MatthiasWeb\RealMediaLibrary\api\IUserSettings  $obj,boolean  $deprecated = false,integer  $priority = 10,string  $contentGroup = ''): boolean

Add a visible content to the general user settings dialog.

Example: Adding a new tab "Physical" group to user settings dialog (or RML/Folder/Meta/Groups for folder details)

add_filter("RML/User/Settings/Groups", function($groups) {
 $groups["physical"] = __("Physical");
 return $groups;
});

Parameters

string $name

Unique name for this meta box

\MatthiasWeb\RealMediaLibrary\api\IUserSettings $obj

The object which implements IUserSettings

boolean $deprecated

boolean Load the resources if exists (since 4.3.0 deprecated, scripts method is always called)

integer $priority

Priority for actions and filters

string $contentGroup

The tab group for the meta settings, see example for adding a new group

Returns

boolean

add_rml_meta_box()

add_rml_meta_box(string  $name,\MatthiasWeb\RealMediaLibrary\api\IMetadata  $obj,boolean  $hasScripts = false,integer  $priority = 10,string  $contentGroup = ''): boolean

Add a visible content to the folder details dialog.

Example: Adding a new tab "Physical" group to meta dialog (or RML/User/Settings/Groups for user settings)

add_filter("RML/Folder/Meta/Groups", function($groups) {
 $groups["physical"] = __("Physical");
 return $groups;
});

Parameters

string $name

Unique name for this meta box

\MatthiasWeb\RealMediaLibrary\api\IMetadata $obj

The object which implements IMetadata

boolean $hasScripts

boolean Load the resources if exists

integer $priority

Priority for actions and filters

string $contentGroup

The tab group for the meta settings, see example for adding a new group

Returns

boolean