Filter
uncanny-automator
automator_use_legacy_token_parser
Filters whether the legacy token parser is used for automations, allowing for backward compatibility with older versions.
add_filter( 'automator_use_legacy_token_parser', $callback, 10, 1 );
Description
This filter allows developers to force the use of the legacy token parsing mechanism, overriding the default behavior. By returning `true`, you can opt into the older parsing logic, which might be necessary for compatibility with older recipes or custom integrations. Use with caution, as the legacy parser has been superseded for performance and feature enhancements.
Usage
add_filter( 'automator_use_legacy_token_parser', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Force the use of the legacy token parser for compatibility with older versions
* or specific scenarios.
*
* @param bool $use_legacy_parser Default value: false.
* @return bool Whether to use the legacy token parser.
*/
add_filter( 'automator_use_legacy_token_parser', 'my_automator_force_legacy_parser', 10, 1 );
function my_automator_force_legacy_parser( $use_legacy_parser ) {
// This example forces the legacy parser to be used for demonstration purposes.
// In a real-world scenario, you might conditionally return true based on
// plugin options, user roles, or specific recipe IDs.
return true;
}
?>
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/lib/class-automator-functions.php:300
require_once __DIR__ . '/recipe-parts/tokens/class-automator-tokens.php';
$this->tokens = Automator_Tokens::get_instance();
// Load plugin status checks
require_once __DIR__ . '/utilities/class-automator-input-parser.php';
$this->parse = Automator_Input_Parser::get_instance();
$use_legacy_parser = apply_filters( 'automator_use_legacy_token_parser', false );
if ( true === $use_legacy_parser ) {
$this->parse = Legacy_Token_Parser::get_instance();
}
// Load plugin translated strings
require_once __DIR__ . '/utilities/class-automator-translations.php';
$this->i18n = Automator_Translations::get_instance();