Filter
uncanny-automator
automator_item_map
Filters the item map used within automations, allowing modification of data passed between steps.
add_filter( 'automator_item_map', $callback, 10, 1 );
Description
Fires after Uncanny Automator Pro builds the core item map, allowing developers to filter and modify this array. This hook is crucial for extending Uncanny Automator's functionality by adding custom triggers and actions before the map is finalized and returned for use.
Usage
add_filter( 'automator_item_map', 'your_function_name', 10, 1 );
Parameters
-
$this(mixed) - This parameter contains the item map array, which is filtered before being returned.
Return Value
The filtered value.
Examples
add_filter( 'automator_item_map', 'my_custom_automator_item_map_filter', 10, 1 );
/**
* Example of how to filter the automator_item_map to add or modify integration mappings.
*
* This function demonstrates how to conditionally add a new item mapping based on
* the existing map. In a real-world scenario, you might use this to:
* - Add custom integrations that aren't automatically discovered.
* - Override existing mappings if your custom implementation needs to change the key.
* - Conditionally include/exclude certain default integrations.
*
* @param array $item_map The current array of item mappings (directory name => integration code).
* @return array The modified array of item mappings.
*/
function my_custom_automator_item_map_filter( $item_map ) {
// Example: Add a custom integration if it's not already present.
// Let's assume we have a custom integration located in 'my-custom-integrations/my-plugin-integration'
// and its integration code is 'my_plugin_integration_code'.
$custom_integration_directory = 'my-custom-integrations/my-plugin-integration';
$custom_integration_code = 'my_plugin_integration_code';
// Check if our custom integration directory is not already mapped.
if ( ! isset( $item_map[ $custom_integration_directory ] ) ) {
$item_map[ $custom_integration_directory ] = $custom_integration_code;
}
// Example: You could also conditionally remove an item.
// If you wanted to prevent a specific default integration from being available.
// $default_integration_to_remove = 'some/default/integration/directory';
// if ( isset( $item_map[ $default_integration_to_remove ] ) ) {
// unset( $item_map[ $default_integration_to_remove ] );
// }
// Always return the modified (or unmodified) item map.
return $item_map;
}
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/class-recipe-manifest.php:208
public function get_item_map() {
if ( null !== $this->item_map ) {
return $this->item_map;
}
$map_file = UA_ABSPATH . 'vendor/composer/autoload_item_map.php';
$this->item_map = file_exists( $map_file ) ? include $map_file : array();
$this->item_map = apply_filters( 'automator_item_map', $this->item_map );
return $this->item_map;
}
Internal Usage
Found in uncanny-automator-pro/src/core/includes/internal-triggers-actions.php:87:
add_filter( 'automator_item_map', array( $this, 'merge_pro_item_map' ) );