$prefix . _IS_PRO
$prefix . _IS_PRO =$isPro
_wp_rml_sanitize(string $name,boolean $database = false,integer $exclude = -1): string
Sanitize to a valid slug name for a given folder name. If the passed folder name contains only invalid characters, then it falls back to the base64 encode.
string | $name | The name of the folder |
boolean | $database | If true the name is generated unique from the database slugs |
integer | $exclude |
_wp_rml_synchronize_attachment(integer $postId,integer $fid,boolean $isShortcut = false): boolean
Synchronizes a result with the realmedialibrary_posts table so on this base there can be made the folder content. It also creates shortcuts, if the given $isShortcut parameter is true.
Do not use this directly, instead use the wp_rml_move function.
integer | $postId | The post ID |
integer | $fid | The folder ID |
boolean | $isShortcut | true = Is shortcut in the given folder, false = Is no shortcut, mainly in this folder |
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.
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. |
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;
});
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 |
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;
});
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 |
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.
integer | $folder_id | Folder ID. |
string | $meta_key | Metadata name. |
mixed | $meta_value | Metadata value. Must be serializable if non-scalar. |
True on success, false on failure.
get_media_folder_meta(integer $folder_id,string $key = '',boolean $single = false): array<mixed,mixed>|mixed
Retrieve folder meta field for a folder.
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. |
Will be an array if $single is false. Will be value of meta data field if $single is true.
is_rml_folder(integer|\MatthiasWeb\RealMediaLibrary\api\IFolder $obj): boolean
Checks, if a given variable is an implementation of the IFolder interface.
integer|\MatthiasWeb\RealMediaLibrary\api\IFolder | $obj | Object or int (ID) |
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.
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. |
wp_attachment_ensure_source_file(integer|\WP_Post $post): integer|\WP_Post
Checks if a given attachment has already a shortcut in a given folder id or has generally shortcuts.
integer|\WP_Post | $post | The attachment id or a WP_Post object |
wp_attachment_folder(integer $attachmentId,integer $default = null): integer|mixed
Returns the folder id of an given attachment or more than one attachment (array). If you pass an array as attachment ids, then the default value does not work, only for single queries. When you pass a shortcut attachment id, the folder id for the shortcut is returned.
integer | $attachmentId | The attachment ID, if you pass an array you get an array of folder IDs |
integer | $default | If no folder was found for this, this value is returned for the attachment |
Folder ID or $default or Array
wp_attachment_get_shortcuts(integer $postId,integer $fid = false,boolean $extended = false): mixed
Checks if a given attachment ID has shortcut and returns the shortcut IDs as array.
integer | $postId | The attachment id |
integer | $fid | The folder id, if false, it checks if there generally exists shortcuts |
boolean | $extended | If true the result is an array with all information about the associated folder |
wp_attachment_has_shortcuts(integer $postId,integer $fid = false): boolean
Checks if a given attachment has already a shortcut in a given folder id or has generally shortcuts.
integer | $postId | The attachment id |
integer | $fid | The folder id, if false, it checks if there generally exists shortcuts |
wp_attachment_is_shortcut(integer|\WP_Post $post,boolean $returnSourceId = false): boolean|integer
Checks if a given attachment is a shortcut, use the $returnSourceId parameter to get the source attachment id.
integer|\WP_Post | $post | The attachment id or a WP_Post object |
boolean | $returnSourceId | If true, the return will be the source attachment id or 0 if it is no shortcut |
wp_attachment_order_update(integer $folderId,integer $attachmentId,integer $nextId,integer $lastIdInView = false): boolean
(Pro only) Moves an attachment before another given attachment in the order table.
integer | $folderId | The folder id where the attachment exists |
integer | $attachmentId | The attachment which should be moved |
integer | $nextId | The attachment next to the currentId, if it is false the currentId should be moved to the end of table. |
integer | $lastIdInView | If you have pagination, you can pass the last id from this view |
True or array with error strings
wp_rml_all_children_sql_supported(boolean $force = false,string $type = 'legacy'): boolean
Checks if the wp_rml_create_all_children_sql() SQL is supported by the current used database system. The function itself creates a dummy table and performs the SQL and checks if the result is as expected. The "support" result is cached site-wide.
boolean | $force | If true the database check is performed again |
string | $type | The type which is minimum required. Possible values: 'function' (MySQL UDF) or 'legacy' (default, old variant) |
wp_rml_create(string $name,integer $parent,integer $type,array<mixed,string> $restrictions = array(),boolean $supress_validation = false,boolean $return_existing_id = false): integer|array<mixed,string>
Creates a folder. At first it checks if a folder in parent already exists.
Then it checks if the given type is allowed in the parent.
It is highly recommend, to use wp_rml_structure_reset after you created your folders.
string | $name | String Name of the folder |
integer | $parent | int ID of the parent (_wp_rml_root() for root) |
integer | $type | integer 0|1|2, Folder.inc |
array<mixed,string> | $restrictions | Restrictions for this folder |
boolean | $supress_validation | Supress the permission validation |
boolean | $return_existing_id | If true and the folder already exists, then return the ID of the existing folder |
int (ID) when successfully array with error strings
wp_rml_create_all_children_sql(\MatthiasWeb\RealMediaLibrary\api\IFolder|integer $folder,boolean $includeSelf = false,array $options = null): string|boolean
Returns a SQL query to get all children for a folder id.
The first result for this SQL statement is the first children and so on...
$options parameters:
"fields" => (string) SELECT fields (default: "rmldata.*"), "join" => (string) JOIN statement (default: ""), "where" => (string) Replace WHERE statement, it is preferred to use afterWhere (default: '1=1 ' . ($includeSelf === true ? "" : $wpdb->prepare(" AND rmldata.id != %d", $folderId))), "afterWhere" => (string) Additional WHERE statement to the above WHERE (default: ""), "orderby" => (string) ORDER BY statement (default: "rmldata.parent, rmldata.ord"), "limit" => (string) LIMIT statement (default: "")
Note: Not all database systems do support this kind of SQL query. You have to use the wp_rml_all_children_sql_supported() API function to check if it is supported.
\MatthiasWeb\RealMediaLibrary\api\IFolder|integer | $folder | The folder object or folder id |
boolean | $includeSelf | Set true to include self (passed $folder) |
array | $options | Additional options for the SQL query, see above |
SQL query or false if something went wrong
wp_rml_create_all_parents_sql(\MatthiasWeb\RealMediaLibrary\api\IFolder|integer $folder,boolean $includeSelf = false,integer $until = null,array $options = null): string|boolean
Returns a SQL query to get all parents for a folder id.
The first result for this SQL statement is the first parent and so on... Use rmltmp.lvl field for the depth number upwards. To avoid performance lacks you should figure out if there is already an action available to search for a meta_key in the action RML/$action/AnyParentHasMeta.
$options parameters:
"fields" => (string) SELECT fields (default: "rmldata.*, rmltmp.lvl AS lvlup") "join" => (string) JOIN statement (default: "") "where" => (string) Replace WHERE statement, it is preferred to use afterWhere (default: "rmltmp.lvl > " . ($includeSelf === true ? "-1" : "0")) "afterWhere"=> (string) Additional WHERE statement to the above WHERE (default: "") "orderby" => (string) ORDER BY statement (default: "rmltmp.lvl ASC") "limit" => (string) LIMIT statement (default: "")
Note: The created SQL is supported by all well-known MySQL systems.
\MatthiasWeb\RealMediaLibrary\api\IFolder|integer | $folder | The folder object or folder id |
boolean | $includeSelf | Set true to include self (passed $folder) |
integer | $until | Until this folder id |
array | $options | Additional options for the SQL query, see above |
SQL query or false if something went wrong
wp_rml_create_or_return_existing_id(string $name,integer $parent,integer $type,array<mixed,string> $restrictions = array(),boolean $supress_validation = false): integer|array<mixed,string>
Wrapper function for wp_rml_create.
string | $name | String Name of the folder |
integer | $parent | int ID of the parent (_wp_rml_root() for root) |
integer | $type | integer 0|1|2, Folder.inc |
array<mixed,string> | $restrictions | Restrictions for this folder |
boolean | $supress_validation | Supress the permission validation |
int (ID) when successfully array with error strings
wp_rml_create_p(string $name,integer $parent,integer $type,array<mixed,string> $restrictions = array(),boolean $supress_validation = false): integer|array<mixed,string>
(Pro only) Creates multiple folders like "test/test2". At first it checks if a folder in parent already exists.
Then it checks if the given type is allowed in the parent.
It is highly recommend, to use wp_rml_structure_reset after you created your folders.
string | $name | String Name of the folder |
integer | $parent | int ID of the parent (_wp_rml_root() for root) |
integer | $type | integer 0|1|2, Folder.inc |
array<mixed,string> | $restrictions | Restrictions for this folder, it is only applied to first folder |
boolean | $supress_validation | Supress the permission validation |
int (ID) when successfully array with error strings
wp_rml_create_shortcuts(integer $to,array<mixed,integer> $ids,boolean $supress_validation = false): boolean|array<mixed,string>
Link/Copy a set of attachments to a specific folder. When the folder has already a given shortcut, the movement for the given attachment will be skipped.
If you want to receive the last created shortcut ID's you can use the wp_rml_created_shortcuts_last_ids() function.
integer | $to | Folder ID, if folder not exists then root will be |
array<mixed,integer> | $ids | Array of attachment ids |
boolean | $supress_validation | Supress the permission validation |
True or Array with errors
wp_rml_debug(mixed|string $message,string $methodOrFunction = null)
This function is recommend for RML add-ons. You can use this function to generate log entries in the database when Settings > Media > Debug is enabled.
mixed|string | $message | The message |
string | $methodOrFunction | METHOD or FUNCTION |
wp_rml_delete(integer $id,boolean $supress_validation = false): boolean|array<mixed,string>
Deletes a folder by ID.
integer | $id | The ID of the folder |
boolean | $supress_validation | Supress the permission validation |
True or array with error string
wp_rml_dropdown(mixed $selected,array<mixed,integer> $disabled,boolean $useAll = true): string
This functions returns a HTML formatted string which contains options-tag elements with all folders, collections and galleries.
This function should only be used if you want to provide output. For a more UX friendly dropdown use wp_rml_selector()!
mixed | $selected | The selected item, "" => "All Files", _wp_rml_root() => "Root", int => Folder ID. Can also be an array for multiple select (since 3.1.2) |
array<mixed,integer> | $disabled | Which folder types are disabled. Default disabled is RML_TYPE_COLLECTION |
boolean | $useAll | boolean Defines, if "All Files" should be showed |
wp_rml_dropdown_collection(mixed $selected): string
This functions returns a HTML formatted string which contains `<options>` elements with all folders, collections and galleries.
Note: Only COLLECTIONS are SELECTABLE!
This function should only be used if you want to provide output. For a more UX friendly dropdown use wp_rml_selector()!
mixed | $selected | The selected item, "" => "All Files", _wp_rml_root() => "Root", int => Folder ID. Can also be an array for multiple select (since 3.1.2) |
wp_rml_dropdown_gallery(mixed $selected): string
This functions returns a HTML formatted string which contains option-tag elements with all folders, collections and galleries.
Note: Only GALLERIES are SELECTABLE!
This function should only be used if you want to provide output. For a more UX friendly dropdown use wp_rml_selector()!
mixed | $selected | The selected item, "" => "All Files", _wp_rml_root() => "Root", int => Folder ID. Can also be an array for multiple select (since 3.1.2) |
wp_rml_dropdown_gallery_or_collection(mixed $selected): string
This functions returns a HTML formatted string which contains option-tag elements with all folders, collections and galleries.
Note: Only GALLERIES AND COLLECTIONS are SELECTABLE!
mixed | $selected | The selected item, "" => "All Files", _wp_rml_root() => "Root", int => Folder ID. Can also be an array for multiple select (since 3.1.2) |
wp_rml_get_attachments(integer $fid,string $order = null,string $orderby = null): null|array<mixed,integer>
Reads content of a folder.
integer | $fid | The folder id |
string | $order | The order statement |
string | $orderby | The order by statement |
Null if folder not exists or array of post ids
wp_rml_get_by_absolute_path(string $path,array<mixed,integer> $allowed = null): \MatthiasWeb\RealMediaLibrary\api\IFolder
This functions checks if a specific folder exists by absolute path and is a given allowed RML Folder Type.
string | $path | Folder Absolute Path |
array<mixed,integer> | $allowed | Which folder types are allowed. If null all folder types are allowed. |
wp_rml_get_by_id(integer $id,array<mixed,integer> $allowed = null,boolean $mustBeFolderObject = false,boolean $nullForRoot = true): \MatthiasWeb\RealMediaLibrary\api\IFolder
This functions checks if a specific folder exists by ID and is a given allowed RML Folder Type. If the given folder is _wp_rml_root you will get the first level folders.
integer | $id | Folder ID |
array<mixed,integer> | $allowed | Which folder types are allowed. If null all folder types are allowed. |
boolean | $mustBeFolderObject | Defines if the function may return the wp_rml_root_childs result |
boolean | $nullForRoot | If set to false and $id == -1 then the Root instance is returned |
wp_rml_get_object_by_id(integer $id,array<mixed,integer> $allowed = null): \MatthiasWeb\RealMediaLibrary\api\IFolder
A shortcut function for the wp_rml_get_by_id function that ensures, that a IFolder object is returned. For -1 the root instance is returned.
integer | $id | |
array<mixed,integer> | $allowed |
wp_rml_is_type(\MatthiasWeb\RealMediaLibrary\api\IFolder|integer $folder,array<mixed,integer> $allowed): boolean
Determines if a Folder is a special folder type.
\MatthiasWeb\RealMediaLibrary\api\IFolder|integer | $folder | The folder object |
array<mixed,integer> | $allowed | Which folder types are allowed |
wp_rml_move(integer $to,array<mixed,integer> $ids,boolean $supress_validation = false,boolean $isShortcut = false): boolean|array<mixed,string>
Move or create shortcuts of a set of attachments to a specific folder.
If you copy attachments, the action called is also "RML/Item/Move"... but there is a paramter $isShortcut.
integer | $to | Folder ID |
array<mixed,integer> | $ids | Array of attachment ids |
boolean | $supress_validation | Supress the permission validation |
boolean | $isShortcut | Determines, if the ID's are copies |
True or Array with errors
wp_rml_objects(): array<mixed,\MatthiasWeb\RealMediaLibrary\api\IFolder>
Get all available folders, collections, galleries, .
..
wp_rml_register_creatable(string $qualified,integer $type,boolean $onRegister = false)
Register a new folder type for RML. It does not check if the creatable type is already registered.
string | $qualified | The qualified name of the class representing the creatable |
integer | $type | The type of the creatable. It must be the same as in yourClass::getType is returned |
boolean | $onRegister | Calls the yourClass::onRegister function |
wp_rml_rename(string $name,integer $id,boolean $supress_validation = false): boolean|array<mixed,string>
Renames a folder and then checks, if there is no duplicate folder in the parent folder.
string | $name | String New name of the folder |
integer | $id | The ID of the folder |
boolean | $supress_validation | Suppress the permission validation |
true or array with error strings
wp_rml_root_childs(): array<mixed,\MatthiasWeb\RealMediaLibrary\api\IFolder>
Gets the first level childs of the media library.
wp_rml_selector(array $options = array()): string
This function returns a HTML code (input[type="hidden"]) which gets nicely rendered via Javascript (FolderSelector). If you need a more complex implementation have a look at FolderSelector.js module.
$options:
array | $options |
wp_rml_structure_reset(integer $root = null,boolean $fetchData = true,integer $returnId = false): \MatthiasWeb\RealMediaLibrary\api\IFolder
Resets the structure. This function must be called when you create a new folder for example and to register it to the structure.
ATTENTION: This function will be declared as deprecated soon, because it is planned to automatically reset the structure data / reset folder data (lazy loading of Folder objects).
integer | $root | The root folder to read the structure |
boolean | $fetchData | Determine if the data should be re-fetched |
integer | $returnId | If set this folder is returned |
If $returnId is set
wp_rml_update_count(array<mixed,integer> $folders = null,array<mixed,integer> $attachments = null,boolean $onlyReturn = false): string|null
Handle the count cache for the folders. This should avoid a lack SQL subquery which loads data from the postmeta table.
array<mixed,integer> | $folders | Array of folders ID, if null then all folders with cnt NULL are updated |
array<mixed,integer> | $attachments | Array of attachments ID, is merged with $folders if given |
boolean | $onlyReturn | Set to true if you only want the SQL query |