Filter uncanny-automator

automator_recipe_items

Filters the recipe items before they are displayed or processed, allowing modification of the available options.

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

Description

Fires after triggers, actions, and conditions are loaded. Developers can filter this array to add, remove, or modify available recipe items. Use this to customize the integration of custom triggers, actions, or conditions within the Automator's recipe builder interface.


Usage

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

Parameters

$this (mixed)
This parameter contains the current integrations array, which is filtered to allow modifications.

Return Value

The filtered value.


Examples

<?php
/**
 * Example: Add a custom recipe item type to the Automator plugin.
 *
 * This filter allows you to add new types of triggers or actions
 * that users can select when building automation recipes within the plugin.
 *
 * @param array $recipe_items The current array of available recipe items.
 * @return array The modified array of recipe items, including the new custom item.
 */
function my_custom_automator_recipe_items( $recipe_items ) {

	// Define a new custom recipe item.
	// In a real scenario, this would likely be a more complex array
	// defining the item's name, description, and how it interacts with other parts of the plugin.
	$new_custom_item = array(
		'slug'        => 'my-custom-action',
		'name'        => __( 'My Custom Action', 'my-text-domain' ),
		'description' => __( 'This is a custom action for my plugin.', 'my-text-domain' ),
		'type'        => 'action', // or 'trigger'
		'category'    => 'custom',
	);

	// Add the custom item to the existing array of recipe items.
	// You might want to add it to a specific category or ensure uniqueness.
	if ( ! isset( $recipe_items[ 'custom' ] ) ) {
		$recipe_items[ 'custom' ] = array();
	}
	$recipe_items[ 'custom' ][] = $new_custom_item;

	return $recipe_items;
}

// Add the filter to WordPress.
// The second parameter '10' is the priority, and '1' is the number of arguments
// the callback function accepts (excluding the filter's value itself).
// In this case, the filter 'automator_recipe_items' passes one argument, which is '$recipe_items'.
add_filter( 'automator_recipe_items', 'my_custom_automator_recipe_items', 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/lib/class-automator-functions.php:353

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 );
	}


Scroll to Top