Hook system to modify simple things.
- See:
-
- Events for hook events
Example
Accessing the hook system
window.rml.hooks.register("yourAction", function() {
// Do something
});
Methods
(inner) call(name, args, context) → {module:util/hooks}
Call an event.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event name |
args |
Array.<mixed> | Pass arguments to the callbacks |
context |
object | Pass context to the callbacks |
Returns:
- Type
- module:util/hooks
(inner) exists(name) → {boolean}
Checks if a event name is registered.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event name |
Returns:
- Type
- boolean
(inner) register(names, callback) → {module:util/hooks}
Registers a callback to a given event name.
Parameters:
Name | Type | Description |
---|---|---|
names |
string | The event name, you can also pass multiple names when splitted with " " |
callback |
function | The callback function with the arguments |
Returns:
- Type
- module:util/hooks
(inner) register(name, callback) → {module:util/hooks}
Deregister a callback to a given event name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The event name |
callback |
function | The callback function with the arguments |
Returns:
- Type
- module:util/hooks
Events
attachment/move/finished
Attachment items got moved.
This:
Parameters:
Name | Type | Description |
---|---|---|
ids |
Array.<int> | The attachment ids |
to |
int | string | The destination folder |
isCopy |
boolean | If true the files were copied (shortcut) |
- Since:
- 4.0.7
attachment/relocate
(Pro only) An attachment is relocated and should be saved to the server.
This:
- Sortable
Parameters:
Name | Type | Description |
---|---|---|
folder |
module:store/TreeNode~TreeNode | The tree node |
attachmentId |
int | The attachment id |
nextId |
int | The next id |
lastIdInView |
int | |
next |
jQuery |
attachmentsBrowser/collection/change
Fired when the collection of attachments browser changes.
This:
- wp.media.view.AttachmentsBrowser
Parameters:
Name | Type | Description |
---|---|---|
appTree |
object | The app tree instance |
attachmentsBrowser/item/removed
Fired when an attachments browser item gets removed.
This:
- wp.media.view.AttachmentsBrowser
Parameters:
Name | Type | Description |
---|---|---|
args... |
mixed | The event arguments |
attachmentsBrowser/item/rendered
Fired when an attachments browser item is rendered.
This:
- wp.media.view.Attachment.Library
Parameters:
Name | Type | Description |
---|---|---|
$el |
jQuery | The element |
model |
object | The backbone model |
appTree |
object | The app tree instance |
attachmentsBrowser/modal
Fired, when a new modal window is created.
This:
- wp.media.view.AttachmentsBrowser
attachmentsBrowser/modal/dom/ready
A modal attachments browser is created and the view for the
React element is ready.
This:
- wp.media.view.AttachmentsBrowser
Parameters:
Name | Type | Description |
---|---|---|
container |
object | The backbone view |
folder/children/order/$id
(Pro only) This action is called when subfolders of a folder are successfully
ordered by a criterium. You have to implement the .setter() for the new
children's order.
This:
Parameters:
Name | Type | Description |
---|---|---|
children |
Array.<TreeNode> | The children of this folder, you have to apply .compare() because it is not reloaded from server |
setChildren |
function | A function where you pass one argument: childNodes with new sorting |
- Since:
- 4.4.0
folder/meta
The MetaBox ref element is ready and created.
This:
- MetaBox
Parameters:
Name | Type | Description |
---|---|---|
ref |
HTMLElement | The reference |
id |
string | id | The folder id or 'usersettings' |
store |
module:store~Store | The store |
folder/meta/saved
The MetaBox is saved successfully.
This:
- MetaBox
Parameters:
Name | Type | Description |
---|---|---|
id |
string | id | The folder id or 'usersettings' |
response |
object | The server response |
data |
object | The data sent to the server |
folder/meta/serialize
The MetaBox is serialized and ready to send.
This:
- MetaBox
Parameters:
Name | Type | Description |
---|---|---|
id |
string | id | The folder id or 'usersettings' |
store |
module:store~Store | The store |
data |
object | The data prepared for the server so you can perhaps modify it |
form |
HTMLElement | The form container |
folder/moved
This action is called when a folder was moved in the folder tree.
That means the parent and order was changed.
This:
Parameters:
Name | Type | Description |
---|---|---|
props |
object | The move properties |
- Since:
- 4.0.7
folder/relocated
This action is called when a folder was relocated in the
folder tree. That means the parent was not changed, only
the order was changed.
This:
Parameters:
Name | Type | Description |
---|---|---|
props |
object | The move properties |
- Since:
- 4.0.7
folder/renamed
Folder successfully renamed.
This:
Parameters:
Name | Type | Description |
---|---|---|
node |
module:store/TreeNode~TreeNode | The node |
- Since:
- 4.0.7
general
General event when script for RML is ready to load.
options/ready
Fired when the options screen tables are rendered successfully.
ready
General event when DOM is ready and a list table / grid mode
is available in media library page.
rest/button/error/$url
Fired when a button with class .rml-rest-button is successfully saved.
This:
- jQuery
Parameters:
Name | Type | Description |
---|---|---|
args... |
mixed | The $.ajax success arguments |
method |
string | The method |
data |
object | The data |
rest/button/prepare/$url
Fired when a button with class .rml-rest-button gets clicked and
the POST data is prepared so you can modify it. The $url is the
data-url attribute of the button. You also have to define a
data-method attribute.
This:
- jQuery
Parameters:
Name | Type | Description |
---|---|---|
data |
object | The data |
rest/button/success/$url
Fired when a button with class .rml-rest-button is successfully saved.
This:
- jQuery
Parameters:
Name | Type | Description |
---|---|---|
args... |
mixed | The $.ajax success arguments |
method |
string | The method |
data |
object | The data |
shortcode/dialog/insert
The shortcode gets generated. You are able to modify the shortcut
depending on the modal data.
Parameters:
Name | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
shortcodeData |
object |
Properties
|
||||||
data |
object | The data from the dialog |
shortcode/dialog/open
The shortcode dialog gets opened. You can modify the fields.
Parameters:
Name | Type | Description |
---|---|---|
options |
object | The options |
editor |
object | The editor instance |
tree/destroy
The React AppTree instance gets unmounted.
This:
Parameters:
Name | Type | Description |
---|---|---|
state |
object | |
props |
object |
tree/init
The React AppTree instance gets constructed and you can modify it here.
This:
Parameters:
Name | Type | Description |
---|---|---|
state |
object | |
props |
object |
tree/node
A tree node is fetched from the server and should be prepared
for the module:store/TreeNode~TreeNode class.
Parameters:
Name | Type | Description |
---|---|---|
node |
object | The node object |
tree/node/icon
Set the tree node icon by string.
Parameters:
Name | Type | Description |
---|---|---|
result |
object | Set "icon" to the React element |
icon |
string | The icon string |
- Since:
- 4.6.0
tree/select
The user is selecting a node in the app tree.
This:
Parameters:
Name | Type | Description |
---|---|---|
id |
int | string | |
select |
object | The MST node |
attachmentsBrowser |
object |
- Since:
- 4.0.5
tree/select
A folder has been deleted.
This:
Parameters:
Name | Type | Description |
---|---|---|
node |
module:store/TreeNode~TreeNode | The node |
attachmentsBrowser |
object |
- Since:
- 4.0.7
uploader/add
A new file is added.
This:
- object
Parameters:
Name | Type | Description |
---|---|---|
file |
object | The file |
folder |
module:store/TreeNode~TreeNode | The folder node |
store |
module:store~Store | The store |
uploader/init
The uploader gets initialized.
This:
- wp.Uploader
wprfc/$function
A RML WP RFC is called and should be handled.
Parameters:
Name | Type | Description |
---|---|---|
data |
object | The element data |
$el |
jQuery | The element |