Filter uncanny-automator

automator_integrations_setup

Filters the list of available integrations before they are displayed in the setup.

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

Description

Filters the list of available integrations before they are loaded. Developers can use this hook to add, remove, or modify integration definitions. It runs during the core integration setup process, allowing for dynamic control over which integrations are available. This filter is the successor to `uncanny_automator_integrations`.


Usage

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

Parameters

$integrations (mixed)
This parameter contains an array of all discovered and registered integrations for the Automator plugin.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to filter the 'automator_integrations_setup' hook.
 * This example will add a custom integration definition to the list.
 *
 * @param array $integrations An array of existing integration definitions.
 * @return array Modified array of integration definitions.
 */
function my_custom_automator_integrations( $integrations ) {

	// Define a hypothetical custom integration.
	// In a real scenario, this data would likely come from a plugin or theme file structure.
	$my_custom_integration = array(
		'my-custom-plugin' => array(
			'path'          => 'path/to/my-custom-plugin/integrations/',
			'file'          => 'my-custom-plugin-integration.php',
			'name'          => 'My Custom Plugin Integration',
			'namespace'     => 'MyCustomPlugin\Automator\Integration\',
			'trigger_count' => 5, // Example property
			'action_count'  => 3, // Example property
		),
	);

	// Merge our custom integration with the existing ones.
	// If a key exists in both, the value from $my_custom_integration will overwrite.
	$integrations = array_merge( $integrations, $my_custom_integration );

	return $integrations;
}

// Add the filter to the 'automator_integrations_setup' hook.
// We specify 10 as the priority (default) and 1 argument, which is the $integrations array.
add_filter( 'automator_integrations_setup', 'my_custom_automator_integrations', 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/integration-loader/class-integration-discovery.php:76

public function get_autoload_directories() {

		$map_file = dirname( AUTOMATOR_BASE_FILE )
			. DIRECTORY_SEPARATOR . 'vendor'
			. DIRECTORY_SEPARATOR . 'composer'
			. DIRECTORY_SEPARATOR . 'autoload_integrations_map.php';

		if ( file_exists( $map_file ) ) {
			$integrations = include $map_file;
		} else {
			// Fallback to runtime classmap scan when pre-built map is unavailable.
			try {
				$legacy_integrations = new Legacy_Integrations();
				$integrations        = $legacy_integrations->generate_integrations_file_map();
			} catch ( Throwable $e ) {
				throw new Automator_Exception( esc_html( $e->getTraceAsString() ) );
			}
		}

		$integrations                       = apply_filters_deprecated( 'uncanny_automator_integrations', array( $integrations ), '3.0', 'automator_integrations_setup' );
		Set_Up_Automator::$all_integrations = apply_filters( 'automator_integrations_setup', $integrations );

		Automator()->cache->set( 'automator_get_all_integrations', Set_Up_Automator::$all_integrations, 'automator', Automator()->cache->long_expires );

		return self::extract_integration_folders( Set_Up_Automator::$all_integrations, $this->integrations_directory_path );
	}

Scroll to Top