Filter
uncanny-automator
automator_register_closure_integration_code
Filters the integration code before it's registered, allowing modifications to closure integrations.
add_filter( 'automator_register_closure_integration_code', $callback, 10, 3 );
Description
This filter hook allows developers to modify the integration code before it's validated. Use it to dynamically alter the integration code based on the provided closure and integration object. This filter fires during the registration of a closure-based integration, offering a late-stage opportunity for customization.
Usage
add_filter( 'automator_register_closure_integration_code', 'your_function_name', 10, 3 );
Parameters
-
$integration_code(mixed) - The original integration code before any modifications.
-
$closure(mixed) - This parameter holds the code or identifier for the integration being registered.
-
$integration(mixed) - This parameter contains the closure function that will be registered for the integration.
Return Value
The filtered value.
Examples
add_filter( 'automator_register_closure_integration_code', 'my_automator_modify_integration_code', 10, 3 );
/**
* Example callback function to modify the integration code.
*
* This function demonstrates how to intercept and potentially alter the integration
* code before it's registered. In this example, we'll append a version suffix
* to the integration code if a specific condition is met (e.g., if the integration
* type is 'my-custom-integration').
*
* @param mixed $integration_code The original integration code.
* @param mixed $closure The closure object associated with the integration.
* @param mixed $integration The integration object.
*
* @return mixed The modified (or original) integration code.
*/
function my_automator_modify_integration_code( $integration_code, $closure, $integration ) {
// Assuming $integration object has a 'type' property for demonstration.
// Replace 'my-custom-integration' with the actual integration type you want to target.
if ( isset( $integration->type ) && 'my-custom-integration' === $integration->type ) {
// Get the current version from somewhere, e.g., plugin header or a constant.
// For demonstration, we'll use a hardcoded version.
$plugin_version = '1.2.3';
// Append the version to the integration code.
$integration_code .= '_v' . $plugin_version;
// You could also perform other modifications:
// - Check for specific parameters in $closure or $integration.
// - Log the modification for debugging.
// - Conditionally return a completely different code.
}
// Always return the integration_code, whether modified or not.
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:475
*/
$integration_code = apply_filters_deprecated(
'uap_register_closure_integration_code',
array( $integration_code, $closure, $integration ),
'3.0',
'automator_register_closure_integration_code'
);
$integration_code = apply_filters( 'automator_register_closure_integration_code', $integration_code, $closure, $integration );
/**
* Use this hook to modify the integration_code before it is error checked and registered
*/
$integration = apply_filters_deprecated(
'uap_register_closure_integration',
array(