Filter uncanny-automator

automator_register_action_integration_code

Filters the integration code for an Automator action, allowing modification before registration.

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

Description

Filters the integration code for an Automator action before validation. Developers can use this hook to modify or validate the integration code, checking the $uap_action and $integration parameters for context. This hook fires during action registration.


Usage

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

Parameters

$integration_code (mixed)
This parameter contains the unique identifier code for the integration being registered.
$uap_action (mixed)
This parameter contains the integration code for a specific action, which can be modified by the filter.
$integration (mixed)
This parameter contains the specific action object being registered, which can be used to access its properties and methods.

Return Value

The filtered value.


Examples

add_filter( 'automator_register_action_integration_code', 'my_custom_automator_action_code', 10, 3 );

/**
 * Example of how to modify the integration code for a WordPress Automator action.
 * This function might be used to add custom data or modify existing data
 * before it's registered with the plugin.
 *
 * @param mixed $integration_code The original integration code.
 * @param mixed $uap_action       The action object.
 * @param mixed $integration      The integration object.
 * @return mixed The modified integration code.
 */
function my_custom_automator_action_code( $integration_code, $uap_action, $integration ) {

	// Example: If the integration code is an array, add a custom key-value pair.
	if ( is_array( $integration_code ) ) {
		$integration_code['custom_modifier'] = 'applied_by_my_plugin';
	}

	// Example: If the action is specifically for sending an email,
	// you might want to prepend a default subject line.
	if ( isset( $uap_action->ID ) && $uap_action->ID === 'send_email' ) {
		if ( isset( $integration_code['subject'] ) ) {
			$integration_code['subject'] = '[Custom Prefix] ' . $integration_code['subject'];
		} else {
			$integration_code['subject'] = '[Default Custom Prefix]';
		}
	}

	// Always return the modified (or original if no changes) integration code.
	return $integration_code;
}

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:357

*/
		$integration_code = apply_filters_deprecated(
			'uap_register_action_integration_code',
			array( $integration_code, $uap_action, $integration ),
			'3.0',
			'automator_register_action_integration_code'
		);
		$integration_code = apply_filters( 'automator_register_action_integration_code', $integration_code, $uap_action, $integration );

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


Scroll to Top