WordPress Actions
WordPress actions are functions attached to specific events that occur, allowing you to add or modify functionality.
With the add_action function, you can easily link your own function to these events. Furthermore, you can make use of the has_action function to verify whether an action has already been added.
motionpage/action/iframe
This action is triggered when iframe content is loaded.
/*Example usage*/
add_action('motionpage/action/iframe', function() {
// Your code here
});
motionpage/action/front
This action is triggered when one or more timelines are loaded on the user-facing page.
/*Example usage*/
add_action('motionpage/action/front', function() {
// Your code here
});
To check if these actions have been added, you can use the has_action
function in WordPress:
// Check if 'motionpage/action/iframe' action has been added
if (has_action('motionpage/action/iframe')) {
// The action has been added, proceed with your code here
}
// Check if 'motionpage/action/front' action has been added
if (has_action('motionpage/action/front')) {
// The action has been added, proceed with your code here
}
motionpage/action/builder
This action is triggered before any builder processes have started.
/*Example usage*/
add_action('motionpage/action/builder', function() {
// Your code here
});
motionpage/action/builder/end
This action is triggered after all builder processes have completed.
/*Example usage*/
add_action('motionpage/action/builder/end', function() {
// Your code here
});
motionpage/action/loaded
This action is triggered when the Motion.page plugin has been loaded.
/*Example usage*/
add_action('motionpage/action/loaded', function() {
// Your code here
});
The has_action
function checks if a function has been attached to the specified action. If a function has been attached, has_action
will return the priority of the function. If no function has been attached, it will return false. This allows you to conditionally execute code depending on whether an action has been added or not.
CRUD operations
These actions are designed to fire only after successful operations, ensuring that any hooked functions or procedures are executed in the right context.
motionpage/action/api/create
: This action is triggered specifically when a new timeline has been successfully created. It provides developers with an opportunity to introduce additional behaviors or integrations right after a new timeline comes into existence.
motionpage/action/api/update
: Activated in the event a timeline is successfully updated. Whether it's a minor change or a major overhaul, this action ensures that developers can respond to updates in real-time.
motionpage/action/api/delete
: This action takes center stage when a timeline is successfully removed. It offers a hook for developers to execute cleanup operations, data archiving, or any other tasks that should follow a timeline's deletion.