Filter uncanny-automator

automator_integration_directory

Filters the directories loaded for Automator integrations.

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

Description

Allow developers to dynamically modify the array of automatically loaded integration directories. This filter is applied late in the initialization process, after core integrations are registered, providing a robust point to add or remove custom integration directories before they are processed.


Usage

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

Parameters

$auto_loaded_directories (mixed)
This parameter is used to modify the list of directories that the Automator plugin automatically loads for integrations.

Return Value

The filtered value.


Examples

/**
 * Example of adding a custom integration directory to Uncanny Automator.
 *
 * This filter allows you to register a new directory where Uncanny Automator
 * can find custom integration files (actions, triggers, etc.).
 *
 * @param array $auto_loaded_directories An array of directories where Automator looks for integrations.
 *
 * @return array The modified array of integration directories.
 */
add_filter( 'automator_integration_directory', function( $auto_loaded_directories ) {

	// Define the path to your custom integration directory.
	// Ensure this path is correctly set relative to your plugin or theme.
	$custom_integration_path = trailingslashit( plugin_dir_path( __FILE__ ) . 'my-custom-integrations/' );

	// Add your custom directory to the array.
	// It's often good practice to add it at the beginning or end depending on
	// whether you want your integrations to be prioritized or loaded last.
	$auto_loaded_directories[] = $custom_integration_path;

	// Return the modified array of directories.
	return $auto_loaded_directories;
}, 10, 1 ); // 10 is the priority, 1 is the number of accepted arguments.

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/classes/class-initialize-automator.php:166

public function automator_configuration_complete_func() {

		//Let others hook in and add integrations
		do_action_deprecated( 'uncanny_automator_add_integration', array(), '3.0', 'automator_add_integration' );

		do_action( 'automator_add_integration' );

		// Pro/addons may have hooked automator_item_map during automator_add_integration.
		// Invalidate the early-cached item map so load_recipe_parts() picks up the merged map.
		Recipe_Manifest::get_instance()->invalidate_item_map();

		// Phase 3: Register legacy integrations.
		try {
			$this->initialize_add_integrations();
		} catch ( Error $e ) {
			throw new Automator_Error( esc_html( $e->getMessage() ) );
		} catch ( Exception $e ) {
			throw new Automator_Exception( esc_html( $e->getMessage() ) );
		}

		// Pro hooks here to merge its data into active_directories and directories_to_include.
		do_action( 'automator_after_add_integrations', $this );

		//Let others hook in to the directories and add their integration's actions / triggers etc
		self::$auto_loaded_directories = apply_filters_deprecated( 'uncanny_automator_integration_directory', array( self::$auto_loaded_directories ), '3.0', 'automator_integration_directory' );
		self::$auto_loaded_directories = apply_filters( 'automator_integration_directory', self::$auto_loaded_directories );

		//Let others hook in and add integrations
		do_action_deprecated( 'uncanny_automator_add_recipe_type', array(), '3.0', 'automator_add_recipe_type' );
		do_action( 'automator_add_recipe_type' );

		// Phase 4: Load helpers.
		$this->load_helpers();

		// Phase 5: Load recipe parts (triggers, actions, closures, conditions, loop-filters, tokens).
		// Deferred to a later init priority for 6.7 translation fix with trigger engine.
		add_action( 'init', array( $this, 'load_recipe_parts' ), AUTOMATOR_RECIPE_PARTS_PRIORITY_TRIGGER_ENGINE );
	}


Scroll to Top