Filter uncanny-automator

automator_recipe_types

Filters the available recipe types, allowing customization of automation triggers and actions.

add_filter( 'automator_recipe_types', $callback, 10, 1 );

Description

Filters the registered recipe types before they are used. Developers can use this hook to add, remove, or modify available recipe types, enabling custom automation workflows within Uncanny Automator. This hook fires during the initialization of automator functions.


Usage

add_filter( 'automator_recipe_types', 'your_function_name', 10, 1 );

Parameters

$this (mixed)
This parameter contains the list of integrations that the automator plugin will use.

Return Value

The filtered value.


Examples

add_filter( 'automator_recipe_types', 'my_custom_automator_recipe_types', 10, 1 );

/**
 * Adds custom recipe types to Uncanny Automator.
 *
 * This function registers new types of recipes that can be created within the Uncanny Automator plugin.
 * It assumes that the provided `$recipe_types` array is structured to accept new recipe type definitions.
 *
 * @param array $recipe_types An array of existing recipe types.
 *
 * @return array The modified array of recipe types, including any new custom types.
 */
function my_custom_automator_recipe_types( $recipe_types ) {
	// Example: Add a new custom recipe type for "Form Submissions"
	// This assumes a structure where each recipe type is an array or object
	// containing properties like 'id', 'label', 'description', etc.
	$new_recipe_type = array(
		'id'          => 'my_custom_form_submission',
		'label'       => __( 'Form Submission', 'your-text-domain' ),
		'description' => __( 'Trigger an automation when a specific form is submitted.', 'your-text-domain' ),
		// Add other relevant properties as required by Uncanny Automator's internal structure
		'icon'        => 'dashicons-edit', // Example icon
		'priority'    => 20, // Example priority for ordering
	);

	// Append the new recipe type to the existing array
	// The actual method of adding will depend on the internal structure of $recipe_types.
	// This is a common approach for array modification.
	if ( is_array( $recipe_types ) ) {
		$recipe_types['my_custom_form_submission'] = $new_recipe_type;
	} else {
		// Handle cases where $recipe_types might not be an array as expected,
		// though in practice, it likely will be.
		error_log( 'Uncanny Automator: Unexpected type for $recipe_types in my_custom_automator_recipe_types.' );
	}

	return $recipe_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/core/lib/class-automator-functions.php:358
src/core/automator-post-types/uo-recipe/class-recipe-post-rest-api.php:947

public function filter_recipe_parts() {

		$this->integrations = apply_filters_deprecated( 'uap_integrations', array( $this->integrations ), '3.0', 'automator_integrations' );
		$this->integrations = apply_filters( 'automator_integrations', $this->integrations );

		$this->actions = apply_filters_deprecated( 'uap_actions', array( $this->actions ), '3.0', 'automator_actions' );
		$this->actions = apply_filters( 'automator_actions', $this->actions );

		$this->triggers = apply_filters_deprecated( 'uap_triggers', array( $this->triggers ), '3.0', 'automator_triggers' );
		$this->triggers = apply_filters( 'automator_triggers', $this->triggers );

		$this->closures = apply_filters_deprecated( 'uap_closures', array( $this->closures ), '3.0', 'automator_closures' );
		$this->closures = apply_filters( 'automator_closures', $this->closures );

		$this->recipe_items = apply_filters( 'automator_recipe_items', $this->recipe_items );

		$this->all_integrations = apply_filters( 'automator_all_integrations', $this->all_integrations );

		$this->recipe_types = apply_filters_deprecated( 'uap_recipe_types', array( $this->recipe_types ), '3.0', 'automator_recipe_types' );
		$this->recipe_types = apply_filters( 'automator_recipe_types', $this->recipe_types );
	}


Internal Usage

Found in src/core/anon/class-automator-handle-anon.php:17:

add_filter( 'automator_recipe_types', array( $this, 'uap_recipe_types_func' ), 10 );

Found in uncanny-automator-pro/src/core/classes/automator-pro-handle-anonymous.php:17:

add_filter( 'automator_recipe_types', [ $this, 'uap_recipe_types_func' ], 10 );
Scroll to Top