Filter uncanny-automator

automator_register_trigger_integration_code

Filters the integration code for a trigger before it's registered.

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

Description

Filters the integration code for a trigger. Developers can use this hook to dynamically modify the integration code before it's validated, allowing for custom logic based on the trigger or integration being registered.


Usage

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

Parameters

$integration_code (mixed)
This parameter represents the unique code identifier for the integration the trigger belongs to.
$trigger (mixed)
This parameter represents the unique code identifier for the integration associated with the trigger.
$integration (mixed)
This parameter holds the trigger object, allowing modification or inspection of the trigger's properties.

Return Value

The filtered value.


Examples

/**
 * Filter to modify the integration code for a trigger.
 *
 * This function can be used to programmatically alter the integration code
 * associated with a specific trigger before it's registered within the
 * Automator plugin. For example, you might want to append a version number
 * or a specific identifier based on the trigger or integration.
 *
 * @param mixed $integration_code The current integration code for the trigger.
 * @param mixed $trigger          The trigger object being registered.
 * @param mixed $integration      The integration object associated with the trigger.
 * @return mixed The modified integration code.
 */
add_filter(
	'automator_register_trigger_integration_code',
	function( $integration_code, $trigger, $integration ) {
		// Example: Append a specific suffix to the integration code if the
		// integration is from a specific custom plugin.
		if ( isset( $integration['slug'] ) && 'my-custom-integration' === $integration['slug'] ) {
			$integration_code .= '_custom_suffix';
		}

		// Example: Add a timestamp to the integration code for debugging or unique identification.
		// You might not want to do this in production unless there's a very specific need.
		// $integration_code = $integration_code . '_' . time();

		return $integration_code;
	},
	10, // Priority
	3   // 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/lib/utilities/class-automator-registration.php:172

*/
		$integration_code = apply_filters_deprecated(
			'uap_register_trigger_integration_code',
			array( $integration_code, $trigger, $integration ),
			'3.0',
			'automator_register_trigger_integration_code'
		);
		$integration_code = apply_filters( 'automator_register_trigger_integration_code', $integration_code, $trigger, $integration );

		/**
		 * Use this hook to modify the integration_code before it is error checked and registered
		 */
		$integration = apply_filters_deprecated(
			'uap_register_trigger_integration',
			array( $integration, $trigger, $integration_code ),


Scroll to Top