Filter
uncanny-automator
automator_ignore_tokenify_meta
Filters which meta keys should be ignored when tokenifying, allowing for custom exclusions.
add_filter( 'automator_ignore_tokenify_meta', $callback, 10, 1 );
Description
Filters the meta keys that should be ignored when tokenizing for recipe parts. Developers can use this hook to prevent specific meta data from being converted into tokens, ensuring only relevant information is available for automation. This is particularly useful for avoiding duplicate or internal data from appearing in token lists.
Usage
add_filter( 'automator_ignore_tokenify_meta', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
add_filter( 'automator_ignore_tokenify_meta', 'my_custom_automator_ignore_tokens', 10, 1 );
/**
* Example function to modify the list of meta keys that should be ignored when generating tokens.
*
* In this example, we're adding a custom meta key 'my_plugin_custom_data'
* that we don't want to be converted into tokens by the automator.
*
* @param array $ignored_metas The array of meta keys to ignore.
*
* @return array The modified array of meta keys to ignore.
*/
function my_custom_automator_ignore_tokens( $ignored_metas ) {
// Add a custom meta key from our plugin that we don't want to be tokenized.
$ignored_metas[] = 'my_plugin_custom_data';
// You might also want to conditionally remove existing ignored metas if needed.
// For instance, if you want to allow 'sentence' to be tokenized under specific conditions.
// if ( ! current_user_can( 'manage_options' ) ) {
// $ignored_metas = array_diff( $ignored_metas, array( 'sentence' ) );
// }
return $ignored_metas;
}
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/recipe-parts/tokens/class-automator-tokens.php:121
return $tokens;
}
//Add custom tokens regardless of integration / trigger code
$filters = array();
$trigger_integration = '';
$trigger_meta = '';
$trigger_value = '';
$ignore_metas_for_tokens = apply_filters(
'automator_ignore_tokenify_meta',
array(
'INTEGRATION_NAME',
'NUMBERCOND',
'uap_trigger_version',
'sentence',
'sentence_human_readable',