Filter
uncanny-automator
automator_direct_recipe_child_types
Filters the available direct recipe child post types that can be created.
add_filter( 'automator_direct_recipe_child_types', $callback, 10, 1 );
Description
Filters the array of direct recipe child post types. Developers can use this hook to add or remove supported child types for direct recipe creation, enabling custom post types to function as triggers, actions, or closures within automations. The hook fires when determining available child types.
Usage
add_filter( 'automator_direct_recipe_child_types', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Example: Add a custom post type to the list of direct recipe child types.
*
* This function demonstrates how to hook into the 'automator_direct_recipe_child_types'
* filter to include a custom post type as a valid child type for automator recipes.
*
* @param array $child_types The array of allowed child post types.
* @return array The modified array of allowed child post types.
*/
add_filter( 'automator_direct_recipe_child_types', 'my_custom_automator_recipe_child_types', 10, 1 );
function my_custom_automator_recipe_child_types( $child_types ) {
// Define your custom post type slug.
$custom_post_type = 'my_custom_recipe_element';
// Check if the custom post type exists before adding it.
// This is good practice to avoid errors if the post type is not registered.
if ( post_type_exists( $custom_post_type ) ) {
$child_types[] = $custom_post_type;
}
// You could also remove existing types if needed, for example:
// $child_types = array_diff($child_types, array(AUTOMATOR_POST_TYPE_CLOSURE));
return $child_types;
}
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/global-functions.php:82
function automator_get_direct_recipe_child_types() {
return apply_filters(
'automator_direct_recipe_child_types',
array(
AUTOMATOR_POST_TYPE_TRIGGER,
AUTOMATOR_POST_TYPE_ACTION,
AUTOMATOR_POST_TYPE_CLOSURE,
// AUTOMATOR_POST_TYPE_BLOCK,
)
);
}