Action
uncanny-automator
automator_action_tokens_parser_loaded
Fires after the automator tokens parser is loaded, allowing modifications before token parsing.
add_action( 'automator_action_tokens_parser_loaded', $callback, 10, 1 );
Description
Fires after action token parsers have been registered. Developers can use this hook to add custom token parsing logic or modify existing parser behavior, ensuring dynamic content is correctly processed before recipe execution.
Usage
add_action( 'automator_action_tokens_parser_loaded', 'your_function_name', 10, 1 );
Examples
<?php
/**
* Example function to demonstrate the automator_action_tokens_parser_loaded hook.
* This function might be used to register custom token parsers or perform
* actions after the default token parsers have been loaded.
*
* @param array $loaded_parsers An array of currently loaded token parsers (if any are passed).
*/
function my_custom_token_parser_handler( $loaded_parsers = [] ) {
// In a real-world scenario, you might check if a specific parser is loaded
// or if you need to add your own custom parsing logic.
// For this example, we'll just log a message to the debug log.
error_log( 'automator_action_tokens_parser_loaded hook fired! Token parsers are ready.' );
// If you were registering a new parser, you would do it here using add_filter.
// For example:
// add_filter( 'automator_action_token_input_parser_text_field_text', [ new MyCustomParser(), 'parse_custom_tokens' ], 20, 3 );
}
// Add the action with a priority and specify the number of arguments it accepts.
// In this case, the hook itself doesn't explicitly pass arguments in the provided source,
// so we'll assume it might pass an array and set accepted args to 1, though 0 is also common if no args are expected.
add_action( 'automator_action_tokens_parser_loaded', 'my_custom_token_parser_handler', 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/services/recipe/action/token/registry.php:45
public function register_hooks() {
// Automatically register the action hooks once an action has set a token.
if ( did_action( 'automator_action_tokens_parser_loaded' ) ) {
return false;
}
// Register the parser.
add_filter( 'automator_action_token_input_parser_text_field_text', array( new Parser(), 'replace_key_value_pairs' ), 10, 3 );
// Invoke an action hook.
do_action( 'automator_action_tokens_parser_loaded' );
return true;
}