Action
uncanny-automator
automator_actionify_triggers_after
Fires after triggers are actionified, providing access to the modified triggers for further processing.
add_action( 'automator_actionify_triggers_after', $callback, 10, 1 );
Description
Fires after all defined actionified triggers have been registered and added to their respective hooks. Developers can use this hook to access and potentially modify the array of registered triggers (`$actionified_triggers`) before they are fully processed, allowing for dynamic adjustments or logging of trigger registration.
Usage
add_action( 'automator_actionify_triggers_after', 'your_function_name', 10, 1 );
Parameters
-
$actionified_triggers(mixed) - This parameter contains an array of actionified triggers that have been processed and are ready for further use.
Examples
<?php
/**
* Example of how to hook into the automator_actionify_triggers_after action.
* This example processes the actionified triggers to potentially modify them
* or log information about them.
*/
function my_automator_process_actionified_triggers( $actionified_triggers ) {
// Check if $actionified_triggers is an array and not empty.
if ( ! is_array( $actionified_triggers ) || empty( $actionified_triggers ) ) {
// Optionally log this to help with debugging if it's unexpected.
error_log( 'automator_actionify_triggers_after: $actionified_triggers is empty or not an array.' );
return;
}
// Example: Log the number of triggers that were actionified.
$trigger_count = count( $actionified_triggers );
error_log( "automator_actionify_triggers_after: Successfully actionified {$trigger_count} triggers." );
// Example: If you wanted to conditionally remove or alter triggers, you could do it here.
// For instance, let's say we want to prevent a specific trigger from running based on some condition.
// Note: This is a hypothetical example. Modifying $actionified_triggers directly
// after it has been passed to do_action() might not have the intended effect
// as the original add_action calls have already occurred.
// A more common use case would be logging or external system integration.
// For demonstration, let's iterate and log details of each trigger.
foreach ( $actionified_triggers as $trigger_key => $trigger_details ) {
if ( isset( $trigger_details['action_hook'] ) && isset( $trigger_details['callback'] ) ) {
error_log( sprintf(
'Actionified Trigger: Key="%s", Hook="%s", Callback="%s"',
$trigger_key,
$trigger_details['action_hook'],
is_array( $trigger_details['callback'] ) ? implode( '::', $trigger_details['callback'] ) : $trigger_details['callback']
) );
}
}
}
add_action( 'automator_actionify_triggers_after', 'my_automator_process_actionified_triggers', 10, 1 );
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/core/classes/class-actionify-triggers.php:93
public function actionify_triggers() {
if ( empty( self::$actionified_triggers ) ) {
self::$actionified_triggers = $this->get_active_integration_triggers();
}
// If not, bail.
if ( empty( self::$actionified_triggers ) ) {
return;
}
foreach ( self::$actionified_triggers as $trigger ) {
$trigger_actions = $trigger->trigger_actions;
$trigger_validation_function = $trigger->trigger_validation_function;
$trigger_priority = $trigger->trigger_priority;
$trigger_accepted_args = $trigger->trigger_accepted_args;
// Initialize trigger
if ( empty( $trigger_validation_function ) ) {
continue;
}
if ( is_array( $trigger_actions ) ) {
foreach ( $trigger_actions as $trigger_action ) {
add_action( $trigger_action, $trigger_validation_function, $trigger_priority, $trigger_accepted_args );
}
continue;
}
add_action( $trigger_actions, $trigger_validation_function, $trigger_priority, $trigger_accepted_args );
}
do_action( 'automator_actionify_triggers_after', self::$actionified_triggers );
}