Documentation

Application

Table of Contents

Interfaces

ICore
IFolder
This interface provides elementary getter and setter methods for folder objects. All folder types (Folder, Collection, Gallery, ...) have implemented this interface.
IFolderActions
This interface provides elementary action methods for folder objects. All folder types (Folder, Collection, Gallery, ...) have implemented this interface.
IFolderContent
This interface provides elementary action methods for folder content. All folder types (Folder, Collection, Gallery, ...) have implemented this interface.
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.
IStructure
Structure implementation for Real Media Library. It handles all SQL query which reads all folders from the database and "collects" it into one tree. You can modify the structure queries by RML/Tree* filters and extending the MatthiasWeb\RealMediaLibrary\attachment\Structure class (implements IStructure).
IUserSettings
Metadata content for the general user settings. The metadata can be changed in the cog icon in the folders sidebar toolbar. To handle metadata for general user settings you can use the default WordPress add_user_meta function.
IOverrideExImport
IOverrideWPML
IOverrideCreatable
IOverrideCRUD
IOverrideCore
IOverrideSortable
IOverrideFolder
IOverrideService
IOverrideDefaultFolder

Classes

Autoloader
Plugin autoloader for lite version.
Constants
Common constants.
AbstractInitiator
This is the main class. You need to create an own class extending from this one to initiate the client. The configuration is done by an abstract schema. That means, all configurations need to be implemented through methods.
Announcement
Represent an announcement model.
AnnouncementPool
Represent a set of announcements synced to the backend (for a given plugin update).
Assets
Assets handling.
Announcement
Handle Real Product Manager API calls.
ClientUtils
Handle Real Product Manager API calls (Utilities).
Feedback
Handle Real Product Manager API calls.
LicenseActivation
Handle Real Product Manager API calls.
TelemetryData
Handle Real Product Manager API calls.
Core
Core for real-product-manager-wp-client. It is only initialized once and holds all available initiators.
License
Handle license information for a given plugin and associated blog id.
LicenseActivation
Handle license activation.
PluginUpdateChecker
Enable external updates with the help of PUC. This should be only done in non-free plugins!
TelemetryData
Handle telemetry data.
Localization
Package localization for `real-product-manager-wp-client` package.
PluginUpdate
Plugin update and license handling. If the plugin is hosted on wordpress.org, this class never does anything. But notice, that wordpress.org plugins also needs to "Complete the setup" and get a "free license" from the RPM license server.
Announcement
Create announcement REST service.
Feedback
Create feedback REST service.
PluginUpdate
Create plugin update REST service.
Utils
Utils functionality.
AnnouncementView
Show announcement notices.
PluginUpdateView
Plugin update view handling. E. g. add links to the plugins row in plugins list.
AbstractInitiator
This is the main class. You need to create an own class extending from this one to initiate the ads system. The configuration is done by an abstract schema. That means, all configurations need to be implemented through methods.
Assets
Assets handling.
Core
Core for real-utils. It is only initialized once and holds all available initiators.
AbstractCrossSelling
An abstract cross-selling implementation which can be used for each pro product of devowl.io.
CrossRealCategoryLibrary
Cross-selling for Real Category Management.
CrossRealCookieBanner
Cross-selling for Real Cookie Banner.
CrossRealMediaLibrary
Cross-selling for Real Media Library.
CrossRealPhysicalMedia
Cross-selling for Real Physical Media.
CrossSellingHandler
Cross-selling handler.
Localization
Package localization for `real-utils` package.
RatingHandler
Allow to handle rating popups depending on usage time.
Service
Create an example REST Service.
TransientHandler
Handle site-wide transients for a specific plugin. It is static-only access and set.
Options
Add real-utils specific options to frontend.
WelcomePage
Handle welcome page for a specific plugin.
Constants
Common constants which cannot be hold in `trait`s as this is forbidden since PHP 8.1.
ExpireOption
WordPress itself has a so-called "Transient API" which allows you to save custom results of e. g. database queries in the database `wp_options` table. While developing the plugin Real Media Library we experienced a lot of issues with Transients as there are a lot of performance and optimization plugins which clears the transients.
FixInvalidJsonInDb
Migration tools can corrupt JSON in database by search & replace domains. For example, the data `["example.com"]` can be transformed to `['example.com']` with invalid single quotes.
KeyValueMapOption
Adds an option via `add_option` which represents a simple map / array of key value pairs.
PackageLocalization
Base i18n management for backend and frontend for a package.
RateLimitNotice
Show a notice about rate limit when contacting a devowl.io external service.
Service
Create a base REST Service needed for boilerplate development.
ServiceNoStore
Add `no-store` cache control directive to WP REST API requests.
Utils
Utility helpers.
Activator
The activator class handles the plugin relevant activation hooks: Uninstall, activation, deactivation and installation. The "installation" means installing needed database tables.
AdInitiator
Initiate real-utils functionality.
Assets
Asset management for frontend scripts and styles.
CountCache
This class handles the count cache for the folder structure.
CustomField
This class handles all hooks for the custom field in a attachments dialog.
Filter
This class handles all hooks for the general filters.
Permissions
Folders permission handling.
Shortcut
Handle the metadata and attached file for shortcuts.
Structure
This class handles all hooks and functions for the structure.
Upload
Handling uploader, so files can be uploaded directly to a folder.
Core
Base class for the applications Core class.
ComplexQuery
Define your complex SQL query. When implementing your complex query do not use global $wpdb; in your methods. Use ::getWpdb() instead.
ResetNames
Reset names so slugs combined to a correct absolute path.
ExImport
Import and export functionality.
HierarchicalFilenameResolver
Resolve filenames by a set of attachment ids.
ExportMediaLibrary
This class handles the compatibility for this plugin: https://wordpress.org/plugins/export-media-library/
PageBuilders
This class handles the compatibility for general page builders. If a page builder has more compatibility options, please see / create another compatibility class.
PolyLang
This class handles the compatibility for Poly Lang plugin.
WPML
This class handles the compatibility for WPML.
Core
Singleton core class which handles the main system for plugin. It includes registering of the autoload, all hooks (actions & filters) (see BaseCore class).
FolderAlreadyExistsException
When we want to set parent of a folder and the given name already exists in the parent folder.
OnlyInProVersionException
When a functionality is only available in PRO version throw an exception.
BaseFolder
Abstract base class for folders. It handles the available fields and getters / setters.
Creatable
Abstract class for a creatable folder item. It handles all general actions for a folder item. If you want to add an new folder type, have a look at the api function wp_rml_register_creatable();
CRUD
Static class to perform CRUD operations on folders. Please do not use this directly instead use the API functions.
Folder
This class creates a folder object. (Type 0) See parent classes / interfaces for better documentation.
QueryCount
Get the count of WP_Query resultset instead of all the rows.
Root
This class creates a root object. (Type 4) See parent classes / interfaces for better documentation.
Localization
i18n management for backend and frontend.
CoverImage
Implements a cover image for root folder, collections, galleries and normal folders.
Description
Implements a description field.
Meta
Create general functionality for the custom folder fields.
Sortable
Handles the sortable content in the folder. The methods of this class contains always the keyword "content".
Collection
This class creates a collection object. (Type 1) See parent classes / interfaces for better documentation.
Gallery
This class creates a gallery data folder object. (Type 2) See parent classes / interfaces for better documentation.
Attachment
Enables the /attachments REST.
Folder
Enables the /folders REST for all creatable items.
Reset
Enables the /reset, /import and /export REST for admins (manage_options).
Service
Create a REST Service.
RpmInitiator
Initiate real-product-manager-wp-client functionality.
AllFilesShortcuts
Add an option so the user can hide shortcuts in "All files" view.
DefaultFolder
Add an option so the user can set the default startup folder.
Demo
InfiniteScrolling
Add an option so the user can disable the WordPress infinite scrolling.
Util
Util functionality for Real Media Library.
FolderShortcode
Handles the shortcode for [folder-gallery].
Gutenberg
Create gutenberg blocks with Server side rendering.
Lang
LEGACY Language texts for the JavaScript frontend. Later when using TypeScript this class is no longer needed because the __() function is used and automatically extracted.
Options
This class handles all hooks for the options.
View
Handles the view for dropdowns and custom UI's for folders.

Traits

Assets
CoreLite
CorePro
FreemiumProvider
Extends the UtilsProvider with freemium provider.
PluginUpdateLicensePool
Use this trait together in `PluginUpdate`.
UtilsProvider
Let our package act as own "plugin".
UtilsProvider
Let our package act as own "plugin".
Activator
The activator class handles the plugin relevant activation hooks: Uninstall, activation, deactivation and installation. The "installation" means installing needed database tables.
Assets
Base asset management class for frontend scripts and styles.
Base
Base trait for all available classes in your plugin. The trait itself should not be directly used, use the UtilsProvider trait instead in your plugin! But you can still use the methods defined there.
Core
Base class for the applications Core class.
Localization
Base i18n management for backend and frontend.
PluginReceiver
This trait is used via Base trait and allows to consume the prefix filled but the UtilsProvider in your plugin. That allows you to dynamically get plugin data within your composer package.
UtilsProvider
To make the composer package in packages/utils work we need to make the constant variables be passed to the High-Order class.
CommonFolderTrait
Trait common folder meta helper methods.
CommonTrait
Trait common folder meta and user settings helper methods.
ExImport
WPML
Core
Creatable
CRUD
Sortable
Folder
Service
DefaultFolder
ExImport
WPML
Core
Creatable
CRUD
Sortable
Folder
Service
DefaultFolder
CommonUserSettingsTrait
Trait common user settings helper methods.

Constants

REAL_UTILS_ROOT_SLUG  = 'devowl-wp'
REAL_UTILS_SLUG  = 'real-utils'
REAL_UTILS_SLUG_CAMELCASE  = lcfirst(str_replace('-', '', ucwords(REAL_UTILS_SLUG, '-')))
REAL_UTILS_TD  = REAL_UTILS_ROOT_SLUG . '-' . REAL_UTILS_SLUG
REAL_UTILS_VERSION  = filemtime(__FILE__)
RML_PRO_VERSION  = $translatedUrl
RML_TD  = $this->getPluginData('TextDomain')
RML_VERSION  = $this->getPluginData('Version')
RPM_WP_CLIENT_OPT_PREFIX  = 'rpm-wpc'
RPM_WP_CLIENT_ROOT_SLUG  = 'devowl-wp'
RPM_WP_CLIENT_SLUG  = 'real-product-manager-wp-client'
RPM_WP_CLIENT_SLUG_CAMELCASE  = lcfirst(str_replace('-', '', ucwords(RPM_WP_CLIENT_SLUG, '-')))
RPM_WP_CLIENT_TD  = RPM_WP_CLIENT_ROOT_SLUG . '-' . RPM_WP_CLIENT_SLUG
RPM_WP_CLIENT_VERSION  = filemtime(__FILE__)

Functions

wp_rml_get_attachments()  : null|array<string|int, int>
Reads content of a folder.
wp_attachment_folder()  : int|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.
wp_attachment_order_update()  : bool
(Pro only) Moves an attachment before another given attachment in the order table.
wp_rml_move()  : bool|array<string|int, string>
Move or create shortcuts of a set of attachments to a specific folder.
wp_rml_create_shortcuts()  : bool|array<string|int, 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.
wp_rml_created_shortcuts_last_ids()  : array<string|int, int>
If you create shortcuts you can get the ids for those shortcuts with this function.
wp_attachment_ensure_source_file()  : int|WP_Post
Checks if a given attachment has already a shortcut in a given folder id or has generally shortcuts.
wp_attachment_has_shortcuts()  : bool
Checks if a given attachment has already a shortcut in a given folder id or has generally shortcuts.
wp_attachment_get_shortcuts()  : mixed
Checks if a given attachment ID has shortcut and returns the shortcut IDs as array.
wp_attachment_is_shortcut()  : bool|int
Checks if a given attachment is a shortcut, use the $returnSourceId parameter to get the source attachment id.
_wp_rml_synchronize_attachment()  : bool
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.
wp_rml_debug()  : mixed
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.
is_rml_folder()  : bool
Checks, if a given variable is an implementation of the IFolder interface.
wp_rml_get_parent_id()  : int
Get the parent ID of a given folder id.
wp_rml_objects()  : array<string|int, IFolder>
Get all available folders, collections, galleries, .
wp_rml_root_childs()  : array<string|int, IFolder>
Gets the first level childs of the media library.
wp_rml_create()  : int|array<string|int, string>
Creates a folder. At first it checks if a folder in parent already exists.
wp_rml_create_p()  : int|array<string|int, string>
(Pro only) Creates multiple folders like "test/test2". At first it checks if a folder in parent already exists.
wp_rml_create_or_return_existing_id()  : int|array<string|int, string>
Wrapper function for wp_rml_create.
wp_rml_rename()  : bool|array<string|int, string>
Renames a folder and then checks, if there is no duplicate folder in the parent folder.
wp_rml_delete()  : bool|array<string|int, string>
Deletes a folder by ID.
wp_rml_update_count()  : string|null
Handle the count cache for the folders. This should avoid a lack SQL subquery which loads data from the postmeta table.
wp_rml_selector()  : 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.
wp_rml_dropdown()  : string
This functions returns a HTML formatted string which contains options-tag elements with all folders, collections and galleries.
wp_rml_dropdown_collection()  : string
This functions returns a HTML formatted string which contains `<options>` elements with all folders, collections and galleries.
wp_rml_dropdown_gallery()  : string
This functions returns a HTML formatted string which contains option-tag elements with all folders, collections and galleries.
wp_rml_dropdown_gallery_or_collection()  : string
This functions returns a HTML formatted string which contains option-tag elements with all folders, collections and galleries.
wp_rml_is_type()  : bool
Determines if a Folder is a special folder type.
wp_rml_get_object_by_id()  : 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.
wp_rml_get_by_id()  : 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.
wp_rml_get_by_absolute_path()  : IFolder
This functions checks if a specific folder exists by absolute path and is a given allowed RML Folder Type.
wp_rml_register_creatable()  : mixed
Register a new folder type for RML. It does not check if the creatable type is already registered.
_wp_rml_root()  : int
Get the parent root folder for a given blog id.
wp_rml_active()  : bool
Checks if RML is active for the current user.
_wp_rml_sanitize()  : 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.
_wp_rml_sanitize_filename()  : mixed
wp_rml_structure_reset()  : IFolder
Resets the structure. This function must be called when you create a new folder for example and to register it to the structure.
wp_rml_structure()  : IStructure
Get the main working structure.
wp_rml_create_all_parents_sql()  : string|bool
Returns a SQL query to get all parents for a folder id.
wp_rml_all_children_sql_supported()  : bool
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.
wp_rml_create_all_children_sql()  : string|bool
Returns a SQL query to get all children for a folder id.
wp_rml_last_queried_folder()  : int
Set or get the last queried folder.
get_media_folder_meta()  : array<string|int, mixed>|mixed
Retrieve folder meta field for a folder.
add_media_folder_meta()  : int|false
Add meta data field to a folder.
update_media_folder_meta()  : int|bool
Update folder meta field based on folder ID.
delete_media_folder_meta()  : bool
Remove metadata matching criteria from a folder.
delete_media_folder_meta_by_key()  : bool
Delete everything from folder meta matching meta key.
truncate_media_folder_meta()  : int
Remove all meta of a folder. Use this with caution!!
add_rml_user_settings_box()  : bool
Add a visible content to the general user settings dialog.
add_rml_meta_box()  : bool
Add a visible content to the folder details dialog.
rml_skip_already_admin_notice()  : mixed
Show an admin notice to administrators when the plugin is already active.
rml_skip_already_deactivate_lite()  : mixed
Automatically deactivate Lite version when we try to activate the PRO version.
rml_skip_php_admin_notice()  : mixed
Show an admin notice to administrators when the minimum PHP version could not be reached. The error message is only in english available.
rml_skip_rest_admin_notice()  : mixed
Show an admin notice to administrators when the minimum WP version could not be reached. The error message is only in english available.
rml_skip_wp_admin_notice()  : mixed
Show an admin notice to administrators when the minimum WP version could not be reached. The error message is only in english available.

Constants

REAL_UTILS_ROOT_SLUG

public mixed REAL_UTILS_ROOT_SLUG = 'devowl-wp'

REAL_UTILS_SLUG_CAMELCASE

public mixed REAL_UTILS_SLUG_CAMELCASE = lcfirst(str_replace('-', '', ucwords(REAL_UTILS_SLUG, '-')))

REAL_UTILS_TD

public mixed REAL_UTILS_TD = REAL_UTILS_ROOT_SLUG . '-' . REAL_UTILS_SLUG

REAL_UTILS_VERSION

public mixed REAL_UTILS_VERSION = filemtime(__FILE__)

RML_PRO_VERSION

public mixed RML_PRO_VERSION = $translatedUrl

RML_TD

public mixed RML_TD = $this->getPluginData('TextDomain')

RML_VERSION

public mixed RML_VERSION = $this->getPluginData('Version')

RPM_WP_CLIENT_OPT_PREFIX

public mixed RPM_WP_CLIENT_OPT_PREFIX = 'rpm-wpc'

RPM_WP_CLIENT_ROOT_SLUG

public mixed RPM_WP_CLIENT_ROOT_SLUG = 'devowl-wp'

RPM_WP_CLIENT_SLUG

public mixed RPM_WP_CLIENT_SLUG = 'real-product-manager-wp-client'

RPM_WP_CLIENT_SLUG_CAMELCASE

public mixed RPM_WP_CLIENT_SLUG_CAMELCASE = lcfirst(str_replace('-', '', ucwords(RPM_WP_CLIENT_SLUG, '-')))

RPM_WP_CLIENT_TD

public mixed RPM_WP_CLIENT_TD = RPM_WP_CLIENT_ROOT_SLUG . '-' . RPM_WP_CLIENT_SLUG

RPM_WP_CLIENT_VERSION

public mixed RPM_WP_CLIENT_VERSION = filemtime(__FILE__)

Functions

wp_rml_get_attachments()

Reads content of a folder.

wp_rml_get_attachments(int $fid[, string $order = null ][, string $orderby = null ]) : null|array<string|int, int>
Parameters
$fid : int

The folder id

$order : string = null

The order statement

$orderby : string = null

The order by statement

Return values
null|array<string|int, int>

Null if folder not exists or array of post ids

wp_attachment_folder()

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.

wp_attachment_folder(int $attachmentId[, int $default = null ]) : int|mixed
Parameters
$attachmentId : int

The attachment ID, if you pass an array you get an array of folder IDs

$default : int = null

If no folder was found for this, this value is returned for the attachment

Return values
int|mixed

Folder ID or $default or Array

wp_attachment_order_update()

(Pro only) Moves an attachment before another given attachment in the order table.

wp_attachment_order_update(int $folderId, int $attachmentId, int|false $nextId[, int $lastIdInView = false ]) : bool
Parameters
$folderId : int

The folder id where the attachment exists

$attachmentId : int

The attachment which should be moved

$nextId : int|false

The attachment next to the currentId, if it is false the currentId should be moved to the end of table.

$lastIdInView : int = false

If you have pagination, you can pass the last id from this view

Return values
bool

True or array with error strings

wp_rml_move()

Move or create shortcuts of a set of attachments to a specific folder.

wp_rml_move(int $to, array<string|int, int> $ids[, bool $supress_validation = false ][, bool $isShortcut = false ]) : bool|array<string|int, string>

If you copy attachments, the action called is also "RML/Item/Move"... but there is a paramter $isShortcut.

Parameters
$to : int

Folder ID

$ids : array<string|int, int>

Array of attachment ids

$supress_validation : bool = false

Supress the permission validation

$isShortcut : bool = false

Determines, if the ID's are copies

Return values
bool|array<string|int, string>

True or Array with errors

wp_rml_create_shortcuts()

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.

wp_rml_create_shortcuts(int $to, array<string|int, int> $ids[, bool $supress_validation = false ]) : bool|array<string|int, string>

If you want to receive the last created shortcut ID's you can use the wp_rml_created_shortcuts_last_ids() function.

Parameters
$to : int

Folder ID, if folder not exists then root will be

$ids : array<string|int, int>

Array of attachment ids

$supress_validation : bool = false

Supress the permission validation

Return values
bool|array<string|int, string>

True or Array with errors

wp_rml_created_shortcuts_last_ids()

If you create shortcuts you can get the ids for those shortcuts with this function.

wp_rml_created_shortcuts_last_ids() : array<string|int, int>
Return values
array<string|int, int>

wp_attachment_ensure_source_file()

Checks if a given attachment has already a shortcut in a given folder id or has generally shortcuts.

wp_attachment_ensure_source_file(int|WP_Post $post) : int|WP_Post
Parameters
$post : int|WP_Post

The attachment id or a WP_Post object

Return values
int|WP_Post

wp_attachment_has_shortcuts()

Checks if a given attachment has already a shortcut in a given folder id or has generally shortcuts.

wp_attachment_has_shortcuts(int $postId[, int $fid = false ]) : bool
Parameters
$postId : int

The attachment id

$fid : int = false

The folder id, if false, it checks if there generally exists shortcuts

Return values
bool

wp_attachment_get_shortcuts()

Checks if a given attachment ID has shortcut and returns the shortcut IDs as array.

wp_attachment_get_shortcuts(int $postId[, int $fid = false ][, bool $extended = false ]) : mixed
Parameters
$postId : int

The attachment id

$fid : int = false

The folder id, if false, it checks if there generally exists shortcuts

$extended : bool = false

If true the result is an array with all information about the associated folder

wp_attachment_is_shortcut()

Checks if a given attachment is a shortcut, use the $returnSourceId parameter to get the source attachment id.

wp_attachment_is_shortcut(int|WP_Post $post[, bool $returnSourceId = false ]) : bool|int
Parameters
$post : int|WP_Post

The attachment id or a WP_Post object

$returnSourceId : bool = false

If true, the return will be the source attachment id or 0 if it is no shortcut

Return values
bool|int

_wp_rml_synchronize_attachment()

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.

_wp_rml_synchronize_attachment(int $postId, int $fid[, bool $isShortcut = false ]) : bool

Do not use this directly, instead use the wp_rml_move function.

Parameters
$postId : int

The post ID

$fid : int

The folder ID

$isShortcut : bool = false

true = Is shortcut in the given folder, false = Is no shortcut, mainly in this folder

Return values
bool

wp_rml_debug()

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.

wp_rml_debug(mixed|string $message[, string $methodOrFunction = null ]) : mixed
Parameters
$message : mixed|string

The message

$methodOrFunction : string = null

METHOD or FUNCTION

Tags
since
4.0.2

is_rml_folder()

Checks, if a given variable is an implementation of the IFolder interface.

is_rml_folder(int|IFolder $obj) : bool
Parameters
$obj : int|IFolder

Object or int (ID)

Return values
bool

wp_rml_get_parent_id()

Get the parent ID of a given folder id.

wp_rml_get_parent_id(int $id) : int
Parameters
$id : int

The id of the folder, collection, ...

Return values
int

or null

wp_rml_objects()

Get all available folders, collections, galleries, .

wp_rml_objects() : array<string|int, IFolder>

..

Return values
array<string|int, IFolder>

wp_rml_root_childs()

Gets the first level childs of the media library.

wp_rml_root_childs() : array<string|int, IFolder>
Return values
array<string|int, IFolder>

wp_rml_create()

Creates a folder. At first it checks if a folder in parent already exists.

wp_rml_create(string $name, int $parent, int $type[, array<string|int, string> $restrictions = [] ][, bool $supress_validation = false ][, bool $return_existing_id = false ]) : int|array<string|int, string>

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.

Parameters
$name : string

String Name of the folder

$parent : int

int ID of the parent (_wp_rml_root() for root)

$type : int

integer 0|1|2, Folder.inc

$restrictions : array<string|int, string> = []

Restrictions for this folder

$supress_validation : bool = false

Supress the permission validation

$return_existing_id : bool = false

If true and the folder already exists, then return the ID of the existing folder

Tags
throws
OnlyInProVersionException
since
4.12.1

This function ignores the $parent parameter in Lite version as creating subfolders is no longer supported

Return values
int|array<string|int, string>

int (ID) when successfully array with error strings

wp_rml_create_p()

(Pro only) Creates multiple folders like "test/test2". At first it checks if a folder in parent already exists.

wp_rml_create_p(string $name, int $parent, int $type[, array<string|int, string> $restrictions = [] ][, bool $supress_validation = false ]) : int|array<string|int, string>

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.

Parameters
$name : string

String Name of the folder

$parent : int

int ID of the parent (_wp_rml_root() for root)

$type : int

integer 0|1|2, Folder.inc

$restrictions : array<string|int, string> = []

Restrictions for this folder, it is only applied to first folder

$supress_validation : bool = false

Supress the permission validation

Tags
throws
OnlyInProVersionException
since
4.12.0
since
4.12.1

This function is no longer available in PRO version

Return values
int|array<string|int, string>

int (ID) when successfully array with error strings

wp_rml_create_or_return_existing_id()

Wrapper function for wp_rml_create.

wp_rml_create_or_return_existing_id(string $name, int $parent, int $type[, array<string|int, string> $restrictions = [] ][, bool $supress_validation = false ]) : int|array<string|int, string>
Parameters
$name : string

String Name of the folder

$parent : int

int ID of the parent (_wp_rml_root() for root)

$type : int

integer 0|1|2, Folder.inc

$restrictions : array<string|int, string> = []

Restrictions for this folder

$supress_validation : bool = false

Supress the permission validation

Tags
since
4.12.1

This function ignores the $parent parameter in Lite version as creating subfolders is no longer supported

Return values
int|array<string|int, string>

int (ID) when successfully array with error strings

wp_rml_rename()

Renames a folder and then checks, if there is no duplicate folder in the parent folder.

wp_rml_rename(string $name, int $id[, bool $supress_validation = false ]) : bool|array<string|int, string>
Parameters
$name : string

String New name of the folder

$id : int

The ID of the folder

$supress_validation : bool = false

Suppress the permission validation

Return values
bool|array<string|int, string>

true or array with error strings

wp_rml_delete()

Deletes a folder by ID.

wp_rml_delete(int $id[, bool $supress_validation = false ]) : bool|array<string|int, string>
Parameters
$id : int

The ID of the folder

$supress_validation : bool = false

Supress the permission validation

Return values
bool|array<string|int, string>

True or array with error string

wp_rml_update_count()

Handle the count cache for the folders. This should avoid a lack SQL subquery which loads data from the postmeta table.

wp_rml_update_count([array<string|int, int> $folders = null ][, array<string|int, int> $attachments = null ][, bool $onlyReturn = false ]) : string|null
Parameters
$folders : array<string|int, int> = null

Array of folders ID, if null then all folders with cnt NULL are updated

$attachments : array<string|int, int> = null

Array of attachments ID, is merged with $folders if given

$onlyReturn : bool = false

Set to true if you only want the SQL query

Return values
string|null

wp_rml_selector()

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.

wp_rml_selector([array<string|int, mixed> $options = [] ]) : string

$options:

  • mixed selected=Root The selected item, "" => "None", _wp_rml_root() => "Root", int => Folder ID
  • int[] disabled Which folder types are disabled
  • boolean nullable=false Defines if null ('') is allowed as value
  • boolean editable=true Define if the selector is editable
  • string name Name for the input
  • string title Title in the modal dialog
Parameters
$options : array<string|int, mixed> = []
Tags
since
4.3
Return values
string

wp_rml_dropdown()

This functions returns a HTML formatted string which contains options-tag elements with all folders, collections and galleries.

wp_rml_dropdown(mixed $selected, array<string|int, int> $disabled[, bool $useAll = true ]) : string

This function should only be used if you want to provide

Parameters
$selected : mixed

The selected item, "" => "All Files", _wp_rml_root() => "Root", int => Folder ID. Can also be an array for multiple select (since 3.1.2)

$disabled : array<string|int, int>

Which folder types are disabled. Default disabled is RML_TYPE_COLLECTION

$useAll : bool = true

boolean Defines, if "All Files" should be showed

Return values
string

wp_rml_dropdown_collection()

This functions returns a HTML formatted string which contains `<options>` elements with all folders, collections and galleries.

wp_rml_dropdown_collection(mixed $selected) : string

Note: Only COLLECTIONS are SELECTABLE!

This function should only be used if you want to provide

Parameters
$selected : mixed

The selected item, "" => "All Files", _wp_rml_root() => "Root", int => Folder ID. Can also be an array for multiple select (since 3.1.2)

Return values
string

This functions returns a HTML formatted string which contains option-tag elements with all folders, collections and galleries.

wp_rml_dropdown_gallery(mixed $selected) : string

Note: Only GALLERIES are SELECTABLE!

This function should only be used if you want to provide

Parameters
$selected : mixed

The selected item, "" => "All Files", _wp_rml_root() => "Root", int => Folder ID. Can also be an array for multiple select (since 3.1.2)

Return values
string

This functions returns a HTML formatted string which contains option-tag elements with all folders, collections and galleries.

wp_rml_dropdown_gallery_or_collection(mixed $selected) : string

Note: Only GALLERIES AND COLLECTIONS are SELECTABLE!

Parameters
$selected : mixed

The selected item, "" => "All Files", _wp_rml_root() => "Root", int => Folder ID. Can also be an array for multiple select (since 3.1.2)

Return values
string

wp_rml_is_type()

Determines if a Folder is a special folder type.

wp_rml_is_type(IFolder|int $folder, array<string|int, int> $allowed) : bool
Parameters
$folder : IFolder|int

The folder object

$allowed : array<string|int, int>

Which folder types are allowed

Return values
bool

wp_rml_get_object_by_id()

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.

wp_rml_get_object_by_id(int $id[, array<string|int, int> $allowed = null ]) : IFolder
Parameters
$id : int
$allowed : array<string|int, int> = null
Return values
IFolder

wp_rml_get_by_id()

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.

wp_rml_get_by_id(int $id[, array<string|int, int> $allowed = null ][, bool $mustBeFolderObject = false ][, bool $nullForRoot = true ]) : IFolder
Parameters
$id : int

Folder ID

$allowed : array<string|int, int> = null

Which folder types are allowed. If null all folder types are allowed.

$mustBeFolderObject : bool = false

Defines if the function may return the wp_rml_root_childs result

$nullForRoot : bool = true

If set to false and $id == -1 then the Root instance is returned

Return values
IFolder

wp_rml_get_by_absolute_path()

This functions checks if a specific folder exists by absolute path and is a given allowed RML Folder Type.

wp_rml_get_by_absolute_path(string $path[, array<string|int, int> $allowed = null ]) : IFolder
Parameters
$path : string

Folder Absolute Path

$allowed : array<string|int, int> = null

Which folder types are allowed. If null all folder types are allowed.

Return values
IFolder

wp_rml_register_creatable()

Register a new folder type for RML. It does not check if the creatable type is already registered.

wp_rml_register_creatable(string $qualified, int $type[, bool $onRegister = false ]) : mixed
Parameters
$qualified : string

The qualified name of the class representing the creatable

$type : int

The type of the creatable. It must be the same as in yourClass::getType is returned

$onRegister : bool = false

Calls the yourClass::onRegister function

_wp_rml_root()

Get the parent root folder for a given blog id.

_wp_rml_root() : int
Return values
int

Folder id

wp_rml_active()

Checks if RML is active for the current user.

wp_rml_active() : bool
Tags
since
4.0.2
Return values
bool

_wp_rml_sanitize()

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.

_wp_rml_sanitize(string $name[, bool $database = false ][, int $exclude = -1 ]) : string
Parameters
$name : string

The name of the folder

$database : bool = false

If true the name is generated unique from the database slugs

$exclude : int = -1
Return values
string

_wp_rml_sanitize_filename()

_wp_rml_sanitize_filename(mixed $name) : mixed
Parameters
$name : mixed

wp_rml_structure_reset()

Resets the structure. This function must be called when you create a new folder for example and to register it to the structure.

wp_rml_structure_reset([int $root = null ][, bool $fetchData = true ][, int $returnId = false ]) : IFolder

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).

Parameters
$root : int = null

The root folder to read the structure

$fetchData : bool = true

Determine if the data should be re-fetched

$returnId : int = false

If set this folder is returned

Return values
IFolder

If $returnId is set

wp_rml_structure()

Get the main working structure.

wp_rml_structure() : IStructure
Tags
since
3.3.1
Return values
IStructure

wp_rml_create_all_parents_sql()

Returns a SQL query to get all parents for a folder id.

wp_rml_create_all_parents_sql(IFolder|int $folder[, bool $includeSelf = false ][, int $until = null ][, array<string|int, mixed> $options = null ]) : string|bool

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.

Parameters
$folder : IFolder|int

The folder object or folder id

$includeSelf : bool = false

Set true to include self (passed $folder)

$until : int = null

Until this folder id

$options : array<string|int, mixed> = null

Additional options for the SQL query, see above

Return values
string|bool

SQL query or false if something went wrong

wp_rml_all_children_sql_supported()

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.

wp_rml_all_children_sql_supported([bool $force = false ][, string $type = 'legacy' ]) : bool
Parameters
$force : bool = false

If true the database check is performed again

$type : string = 'legacy'

The type which is minimum required. Possible values: 'function' (MySQL UDF) or 'legacy' (default, old variant)

Tags
since
4.0.9
Return values
bool

wp_rml_create_all_children_sql()

Returns a SQL query to get all children for a folder id.

wp_rml_create_all_children_sql(IFolder|int $folder[, bool $includeSelf = false ][, array<string|int, mixed> $options = null ]) : string|bool

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.

Parameters
$folder : IFolder|int

The folder object or folder id

$includeSelf : bool = false

Set true to include self (passed $folder)

$options : array<string|int, mixed> = null

Additional options for the SQL query, see above

Return values
string|bool

SQL query or false if something went wrong

wp_rml_last_queried_folder()

Set or get the last queried folder.

wp_rml_last_queried_folder([int $folder = null ]) : int
Parameters
$folder : int = null

The folder id (0 is handled as "All files" folder)

Tags
since
4.0.5
Return values
int

get_media_folder_meta()

Retrieve folder meta field for a folder.

get_media_folder_meta(int $folder_id[, string $key = '' ][, bool $single = false ]) : array<string|int, mixed>|mixed
Parameters
$folder_id : int

Folder ID.

$key : string = ''

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

$single : bool = false

Whether to return a single value. Default false.

Return values
array<string|int, 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 meta data field to a folder.

add_media_folder_meta(int $folder_id, string $meta_key, mixed $meta_value[, bool $unique = false ]) : int|false

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

Parameters
$folder_id : int

Folder ID.

$meta_key : string

Metadata name.

$meta_value : mixed

Metadata value. Must be serializable if non-scalar.

$unique : bool = false

Whether the same key should not be added.

Return values
int|false

update_media_folder_meta()

Update folder meta field based on folder ID.

update_media_folder_meta(int $folder_id, string $meta_key, mixed $meta_value[, mixed $prev_value = '' ]) : int|bool

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
$folder_id : int

Folder ID.

$meta_key : string

Metadata key.

$meta_value : mixed

Metadata value. Must be serializable if non-scalar.

$prev_value : mixed = ''

Previous value to check before removing.

Return values
int|bool

delete_media_folder_meta()

Remove metadata matching criteria from a folder.

delete_media_folder_meta(int $folder_id, string $meta_key[, mixed $meta_value = '' ]) : bool

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
$folder_id : int

Folder ID.

$meta_key : string

Metadata name.

$meta_value : mixed = ''

Metadata value. Must be serializable if non-scalar.

Return values
bool

True on success, false on failure.

delete_media_folder_meta_by_key()

Delete everything from folder meta matching meta key.

delete_media_folder_meta_by_key(string $folder_meta_key) : bool
Parameters
$folder_meta_key : string

Key to search for when deleting.

Return values
bool

Whether the post meta key was deleted from the database.

truncate_media_folder_meta()

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

truncate_media_folder_meta(int $folder_id) : int
Parameters
$folder_id : int

Folder ID

Return values
int

add_rml_user_settings_box()

Add a visible content to the general user settings dialog.

add_rml_user_settings_box(string $name, IUserSettings $obj[, bool $deprecated = false ][, int $priority = 10 ][, string $contentGroup = '' ]) : bool

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
$name : string

Unique name for this meta box

$obj : IUserSettings

The object which implements IUserSettings

$deprecated : bool = false

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

$priority : int = 10

Priority for actions and filters

$contentGroup : string = ''

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

Return values
bool

add_rml_meta_box()

Add a visible content to the folder details dialog.

add_rml_meta_box(string $name, IMetadata $obj[, bool $hasScripts = false ][, int $priority = 10 ][, string $contentGroup = '' ]) : bool

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
$name : string

Unique name for this meta box

$obj : IMetadata

The object which implements IMetadata

$hasScripts : bool = false

boolean Load the resources if exists

$priority : int = 10

Priority for actions and filters

$contentGroup : string = ''

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

Return values
bool

rml_skip_already_admin_notice()

Show an admin notice to administrators when the plugin is already active.

rml_skip_already_admin_notice() : mixed

rml_skip_already_deactivate_lite()

Automatically deactivate Lite version when we try to activate the PRO version.

rml_skip_already_deactivate_lite() : mixed

rml_skip_php_admin_notice()

Show an admin notice to administrators when the minimum PHP version could not be reached. The error message is only in english available.

rml_skip_php_admin_notice() : mixed

rml_skip_rest_admin_notice()

Show an admin notice to administrators when the minimum WP version could not be reached. The error message is only in english available.

rml_skip_rest_admin_notice() : mixed

rml_skip_wp_admin_notice()

Show an admin notice to administrators when the minimum WP version could not be reached. The error message is only in english available.

rml_skip_wp_admin_notice() : mixed

        
On this page

Search results