Filter uncanny-automator

automator_get_integration_key

Filters the integration key before it's returned, allowing modification for specific integrations.

add_filter( 'automator_get_integration_key', $callback, 10, 3 );

Description

Filters the integration key used internally by Uncanny Automator. Developers can use this hook to modify the default integration key or provide a custom one based on the integration type or name. This is useful for custom integrations or aliasing existing ones before they are processed.


Usage

add_filter( 'automator_get_integration_key', 'your_function_name', 10, 3 );

Parameters

$return (mixed)
This parameter is used to return the integration key or a default value if no matching integration is found.
$integration (mixed)
This parameter holds the value that will be returned by the filter if none of the default logic applies.
$name (mixed)
This parameter contains the full integration object, allowing access to all its properties and methods.

Return Value

The filtered value.


Examples

// Modify the integration key for a specific integration if needed.
// This example checks if the integration is 'google_sheets' and returns a different key.
add_filter( 'automator_get_integration_key', function( $return, $integration, $name ) {
    // Example: If the integration name is 'google_sheets' in the filter,
    // we want to return a custom key like 'google_sheets_api'.
    if ( $name === 'google_sheets' && $integration === 'sheets' ) {
        $return = 'google_sheets_api';
    }

    // Always return the modified or original value.
    return $return;
}, 10, 3 );

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/global-functions.php:247

function automator_get_integration_by_name( $name ) {
	$integration      = strtolower(
		str_replace(
			array( ' ', '_' ),
			'-',
			$name
		)
	);
	$integration_keys = array_keys( Set_Up_Automator::$all_integrations );
	if ( in_array( $integration, $integration_keys, true ) ) {
		return $integration;
	}
	$return = '';
	switch ( $integration ) {
		case 'wordpress': //phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled,WordPress.WP.CapitalPDangit.MisspelledInText
			$return = 'wp';
			break;
		case 'easy-digital-downloads':
			$return = 'edd';
			break;
		case 'automator':
			$return = 'uncanny-automator';
			break;
	}

	return apply_filters( 'automator_get_integration_key', $return, $integration, $name );
}

Scroll to Top