Filter uncanny-automator-pro

automator_pro_integrations_setup

Filters available integrations for the Automator Pro core integration, allowing modification before setup.

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

Description

Allows developers to filter the integrations data before it's cached and made available. This hook enables modification or addition of integrations, offering deep control over how Uncanny Automator Pro interacts with other plugins and services.


Usage

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

Parameters

$integrations (mixed)
This parameter is used to modify or extend the list of available integrations for Uncanny Automator Pro.

Return Value

The filtered value.


Examples

<?php
/**
 * Example of how to filter the integrations setup for Uncanny Automator Pro.
 * This example would conditionally remove certain integrations based on user role.
 *
 * @param array $integrations The array of integrations data.
 * @return array The modified array of integrations data.
 */
add_filter( 'automator_pro_integrations_setup', 'my_custom_automator_pro_integrations_filter', 10, 1 );

function my_custom_automator_pro_integrations_filter( $integrations ) {

	// Check if the current user has a specific role, e.g., 'subscriber'.
	// If they do, we might want to hide certain integrations from them.
	if ( current_user_can( 'subscriber' ) ) {

		// Example: Remove an integration named 'custom_plugin_integration'.
		// This would typically be a key within the $integrations array.
		$integration_to_remove = 'custom_plugin_integration';

		if ( isset( $integrations[ $integration_to_remove ] ) ) {
			unset( $integrations[ $integration_to_remove ] );
			error_log( "Uncanny Automator Pro: Removed integration '{$integration_to_remove}' for subscriber role." );
		}
	}

	// Always return the modified (or unmodified) $integrations array.
	return $integrations;
}

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

uncanny-automator-pro/src/core/includes/internal-triggers-actions.php:57

public function __construct() {
		// Path of the Pro integration directory
		$this->integrations_directory_path = dirname( AUTOMATOR_PRO_FILE ) . '/src/integrations';

		// Load Pro's integration file map (cached).
		$integrations = Automator()->cache->get( 'automator_pro_get_all_integrations' );

		if ( empty( $integrations ) ) {
			$map_file = dirname( AUTOMATOR_PRO_FILE ) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'composer' . DIRECTORY_SEPARATOR . 'autoload_integrations_map.php';

			if ( file_exists( $map_file ) ) {
				$integrations = include $map_file;
			} else {
				$legacy_integrations = new Pro_Legacy_Integrations();
				$integrations        = $legacy_integrations->generate_integrations_file_map();
			}
			Automator()->cache->set( 'automator_pro_get_all_integrations', $integrations, 'automator', Automator()->cache->long_expires );
		}

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

		// ──────────────────────────────────────────────
		// Addon Registry API (Free >= 7.2)
		//
		// When Free ships the Addon_Registry class, Pro delegates to
		// Pro_Addon_Loader which composes Free's Addon_Registry and
		// encapsulates all Pro-specific config (vendor paths, filemap
		// detection, framework fallback).
		//
		// When Addon_Registry is absent (older Free), this class falls
		// back to the manual merge methods: merge_pro_files_into_free(),
		// register_pro_only_integrations(), and merge_pro_item_map().
		//
		// TODO: Phase 3 cleanup — Once Free >= 7.2 is the minimum
		// required version for Pro, remove the legacy fallback entirely:
		//   1. Delete the $addon_loader null check and the else branch
		//   2. Delete merge_pro_files_into_free(),
		//      register_pro_only_integrations(), merge_pro_item_map(),
		//      finalize_directory_merge(), init(),
		//      load_framework_integrations(), get_framework_file_map()
		//   3. Keep only register_via_addon_loader() as the sole init hook
		//   4. The wire_pro_helper_chains() hook stays (both paths need it)
		// See: Pro's src/core/integration-loader/class-pro-addon-loader.php
		// ──────────────────────────────────────────────
		if ( class_exists( 'Uncanny_Automator\Integration_Loader\Addon_Registry' ) ) {
			$this->addon_loader = new Pro_Addon_Loader( dirname( AUTOMATOR_PRO_FILE ) );
			add_action( 'automator_add_integration', array( $this, 'register_via_addon_loader' ), 11 );
		} else {
			// Legacy path: manual merge + hooks.
			add_filter( 'automator_item_map', array( $this, 'merge_pro_item_map' ) );
			add_action( 'automator_add_integration', array( $this, 'init' ), 11 );
		}

		// Both paths need this — finalize_directory_merge adds Pro-contributed types
		// (conditions, loop-filters) to Free's directories_to_include for shared integrations.
		// TODO: Phase 3 cleanup — Move this logic into Addon_Registry so addons don't
		// need a separate hook. The registry would accept a 'directory_types' config key
		// and merge them during register().
		add_action( 'automator_after_add_integrations', array( $this, 'finalize_directory_merge' ), 11 );

		// Both paths need this — wires Pro helper →pro chains after Free loads helpers.
		add_action( 'automator_add_integration_helpers', array( $this, 'wire_pro_helper_chains' ), 11 );
	}

Scroll to Top